PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.3
Elementor Website Builder – more than just a page builder v4.0.3
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 4.0.3, at assets/js/common.js

33,676 lines 1.3 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "../assets/dev/js/editor/utils/editor-one-events.js":
5 /*!**********************************************************!*\
6 !*** ../assets/dev/js/editor/utils/editor-one-events.js ***!
7 \**********************************************************/
8 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
9
10 "use strict";
11
12
13 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
14 Object.defineProperty(exports, "__esModule", ({
15 value: true
16 }));
17 exports["default"] = exports.createDebouncedWidgetPanelSearch = exports.createDebouncedFinderSearch = exports.EditorOneEventManager = void 0;
18 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
19 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
20 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
21 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; }
22 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; }
23 var EditorOneEventManager = exports.EditorOneEventManager = /*#__PURE__*/function () {
24 function EditorOneEventManager() {
25 (0, _classCallCheck2.default)(this, EditorOneEventManager);
26 }
27 return (0, _createClass2.default)(EditorOneEventManager, null, [{
28 key: "getEventsManager",
29 value: function getEventsManager() {
30 var _elementorCommon;
31 return (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.eventsManager;
32 }
33 }, {
34 key: "getConfig",
35 value: function getConfig() {
36 var _this$getEventsManage;
37 return (_this$getEventsManage = this.getEventsManager()) === null || _this$getEventsManage === void 0 ? void 0 : _this$getEventsManage.config;
38 }
39 }, {
40 key: "canSendEvents",
41 value: function canSendEvents() {
42 var _elementorCommon2;
43 return ((_elementorCommon2 = elementorCommon) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.config) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.editor_events) === null || _elementorCommon2 === void 0 ? void 0 : _elementorCommon2.can_send_events) || false;
44 }
45 }, {
46 key: "isEventsManagerAvailable",
47 value: function isEventsManagerAvailable() {
48 var eventsManager = this.getEventsManager();
49 return eventsManager && 'function' === typeof eventsManager.dispatchEvent;
50 }
51 }, {
52 key: "dispatchEvent",
53 value: function dispatchEvent(eventName, payload) {
54 if (!this.isEventsManagerAvailable() || !this.canSendEvents()) {
55 return false;
56 }
57 try {
58 return this.getEventsManager().dispatchEvent(eventName, payload);
59 } catch (error) {
60 return false;
61 }
62 }
63 }, {
64 key: "toLowerSnake",
65 value: function toLowerSnake(value) {
66 if (!value || 'string' !== typeof value) {
67 return value;
68 }
69 return value.replace(/\s+/g, '_').toLowerCase();
70 }
71 }, {
72 key: "decodeHtmlEntities",
73 value: function decodeHtmlEntities(text) {
74 if (!text || 'string' !== typeof text) {
75 return text;
76 }
77 var doc = new DOMParser().parseFromString(text, 'text/html');
78 return doc.body.textContent || text;
79 }
80 }, {
81 key: "isInEditorContext",
82 value: function isInEditorContext() {
83 var _window$elementor;
84 return 'undefined' !== typeof window.elementor && !!((_window$elementor = window.elementor) !== null && _window$elementor !== void 0 && _window$elementor.documents);
85 }
86 }, {
87 key: "getFinderContext",
88 value: function getFinderContext() {
89 var _config$appTypes, _config$appTypes2, _config$locations, _config$locations2;
90 var config = this.getConfig();
91 var isEditor = this.isInEditorContext();
92 return {
93 windowName: isEditor ? config === null || config === void 0 || (_config$appTypes = config.appTypes) === null || _config$appTypes === void 0 ? void 0 : _config$appTypes.editor : config === null || config === void 0 || (_config$appTypes2 = config.appTypes) === null || _config$appTypes2 === void 0 ? void 0 : _config$appTypes2.wpAdmin,
94 targetLocation: this.toLowerSnake(isEditor ? config === null || config === void 0 || (_config$locations = config.locations) === null || _config$locations === void 0 ? void 0 : _config$locations.topBar : config === null || config === void 0 || (_config$locations2 = config.locations) === null || _config$locations2 === void 0 ? void 0 : _config$locations2.sidebar)
95 };
96 }
97 }, {
98 key: "createBasePayload",
99 value: function createBasePayload() {
100 var _config$appTypes$edit, _config$appTypes3, _config$appTypes$edit2, _config$appTypes4;
101 var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102 var config = this.getConfig();
103 return _objectSpread({
104 app_type: (_config$appTypes$edit = config === null || config === void 0 || (_config$appTypes3 = config.appTypes) === null || _config$appTypes3 === void 0 ? void 0 : _config$appTypes3.editor) !== null && _config$appTypes$edit !== void 0 ? _config$appTypes$edit : 'editor',
105 window_name: (_config$appTypes$edit2 = config === null || config === void 0 || (_config$appTypes4 = config.appTypes) === null || _config$appTypes4 === void 0 ? void 0 : _config$appTypes4.editor) !== null && _config$appTypes$edit2 !== void 0 ? _config$appTypes$edit2 : 'editor'
106 }, overrides);
107 }
108 }, {
109 key: "sendTopBarPublishDropdown",
110 value: function sendTopBarPublishDropdown(targetName) {
111 var _config$names, _config$triggers, _config$targetTypes, _config$interactionRe, _config$locations3, _config$secondaryLoca, _config$targetTypes2;
112 var config = this.getConfig();
113 return this.dispatchEvent(config === null || config === void 0 || (_config$names = config.names) === null || _config$names === void 0 || (_config$names = _config$names.editorOne) === null || _config$names === void 0 ? void 0 : _config$names.topBarPublishDropdown, this.createBasePayload({
114 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers = config.triggers) === null || _config$triggers === void 0 ? void 0 : _config$triggers.click),
115 target_type: config === null || config === void 0 || (_config$targetTypes = config.targetTypes) === null || _config$targetTypes === void 0 ? void 0 : _config$targetTypes.dropdownItem,
116 target_name: targetName,
117 interaction_result: config === null || config === void 0 || (_config$interactionRe = config.interactionResults) === null || _config$interactionRe === void 0 ? void 0 : _config$interactionRe.actionSelected,
118 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations3 = config.locations) === null || _config$locations3 === void 0 ? void 0 : _config$locations3.topBar),
119 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca = config.secondaryLocations) === null || _config$secondaryLoca === void 0 ? void 0 : _config$secondaryLoca.publishDropdown),
120 location_l2: config === null || config === void 0 || (_config$targetTypes2 = config.targetTypes) === null || _config$targetTypes2 === void 0 ? void 0 : _config$targetTypes2.dropdownItem,
121 interaction_description: 'User selected an action from the publish dropdown'
122 }));
123 }
124 }, {
125 key: "sendTopBarPageList",
126 value: function sendTopBarPageList(targetName) {
127 var _config$names2, _config$triggers2, _config$targetTypes3, _config$interactionRe2, _config$interactionRe3, _config$locations4, _config$secondaryLoca2, _config$targetTypes4;
128 var isCreate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
129 var config = this.getConfig();
130 return this.dispatchEvent(config === null || config === void 0 || (_config$names2 = config.names) === null || _config$names2 === void 0 || (_config$names2 = _config$names2.editorOne) === null || _config$names2 === void 0 ? void 0 : _config$names2.topBarPageList, this.createBasePayload({
131 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers2 = config.triggers) === null || _config$triggers2 === void 0 ? void 0 : _config$triggers2.click),
132 target_type: config === null || config === void 0 || (_config$targetTypes3 = config.targetTypes) === null || _config$targetTypes3 === void 0 ? void 0 : _config$targetTypes3.dropdownItem,
133 target_name: targetName,
134 interaction_result: isCreate ? config === null || config === void 0 || (_config$interactionRe2 = config.interactionResults) === null || _config$interactionRe2 === void 0 ? void 0 : _config$interactionRe2.create : config === null || config === void 0 || (_config$interactionRe3 = config.interactionResults) === null || _config$interactionRe3 === void 0 ? void 0 : _config$interactionRe3.navigate,
135 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations4 = config.locations) === null || _config$locations4 === void 0 ? void 0 : _config$locations4.topBar),
136 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca2 = config.secondaryLocations) === null || _config$secondaryLoca2 === void 0 ? void 0 : _config$secondaryLoca2.pageListDropdown),
137 location_l2: config === null || config === void 0 || (_config$targetTypes4 = config.targetTypes) === null || _config$targetTypes4 === void 0 ? void 0 : _config$targetTypes4.dropdownItem,
138 interaction_description: 'User selected an action from the page list dropdown'
139 }));
140 }
141 }, {
142 key: "sendSiteSettingsSession",
143 value: function sendSiteSettingsSession(_ref) {
144 var _config$names3, _config$triggers3, _config$interactionRe4, _config$locations5, _config$secondaryLoca3;
145 var targetType = _ref.targetType,
146 _ref$visitedItems = _ref.visitedItems,
147 visitedItems = _ref$visitedItems === void 0 ? [] : _ref$visitedItems,
148 _ref$savedItems = _ref.savedItems,
149 savedItems = _ref$savedItems === void 0 ? [] : _ref$savedItems,
150 state = _ref.state;
151 var config = this.getConfig();
152 return this.dispatchEvent(config === null || config === void 0 || (_config$names3 = config.names) === null || _config$names3 === void 0 || (_config$names3 = _config$names3.editorOne) === null || _config$names3 === void 0 ? void 0 : _config$names3.siteSettingsSession, this.createBasePayload({
153 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers3 = config.triggers) === null || _config$triggers3 === void 0 ? void 0 : _config$triggers3.click),
154 target_type: targetType,
155 target_name: 'site_settings',
156 interaction_result: config === null || config === void 0 || (_config$interactionRe4 = config.interactionResults) === null || _config$interactionRe4 === void 0 ? void 0 : _config$interactionRe4.sessionEnd,
157 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations5 = config.locations) === null || _config$locations5 === void 0 ? void 0 : _config$locations5.leftPanel),
158 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca3 = config.secondaryLocations) === null || _config$secondaryLoca3 === void 0 ? void 0 : _config$secondaryLoca3.siteSettings),
159 interaction_description: 'Records areas visited as part of the site setting session',
160 metadata: {
161 visited_items: visitedItems,
162 saved_items: savedItems
163 },
164 state: state
165 }));
166 }
167 }, {
168 key: "sendELibraryNav",
169 value: function sendELibraryNav(tabName) {
170 var _config$names4, _config$triggers4, _config$targetTypes5, _config$interactionRe5, _config$locations6, _config$secondaryLoca4;
171 var config = this.getConfig();
172 return this.dispatchEvent(config === null || config === void 0 || (_config$names4 = config.names) === null || _config$names4 === void 0 || (_config$names4 = _config$names4.editorOne) === null || _config$names4 === void 0 ? void 0 : _config$names4.eLibraryNav, this.createBasePayload({
173 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers4 = config.triggers) === null || _config$triggers4 === void 0 ? void 0 : _config$triggers4.tabSelect),
174 target_type: config === null || config === void 0 || (_config$targetTypes5 = config.targetTypes) === null || _config$targetTypes5 === void 0 ? void 0 : _config$targetTypes5.tab,
175 target_name: this.toLowerSnake(tabName),
176 interaction_result: config === null || config === void 0 || (_config$interactionRe5 = config.interactionResults) === null || _config$interactionRe5 === void 0 ? void 0 : _config$interactionRe5.tabChanged,
177 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations6 = config.locations) === null || _config$locations6 === void 0 ? void 0 : _config$locations6.elementorLibrary),
178 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca4 = config.secondaryLocations) === null || _config$secondaryLoca4 === void 0 ? void 0 : _config$secondaryLoca4.libraryTabs),
179 interaction_description: 'User navigates within elementor library'
180 }));
181 }
182 }, {
183 key: "sendELibraryInsert",
184 value: function sendELibraryInsert(_ref2) {
185 var _config$triggers5, _config$targetTypes6, _config$interactionRe6, _config$locations7, _config$secondaryLoca5, _config$names5;
186 var assetId = _ref2.assetId,
187 assetName = _ref2.assetName,
188 libraryType = _ref2.libraryType,
189 _ref2$proRequired = _ref2.proRequired,
190 proRequired = _ref2$proRequired === void 0 ? false : _ref2$proRequired;
191 var config = this.getConfig();
192 var payload = this.createBasePayload({
193 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers5 = config.triggers) === null || _config$triggers5 === void 0 ? void 0 : _config$triggers5.insert),
194 target_type: config === null || config === void 0 || (_config$targetTypes6 = config.targetTypes) === null || _config$targetTypes6 === void 0 ? void 0 : _config$targetTypes6.button,
195 target_name: String(assetId),
196 interaction_result: config === null || config === void 0 || (_config$interactionRe6 = config.interactionResults) === null || _config$interactionRe6 === void 0 ? void 0 : _config$interactionRe6.assetInserted,
197 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations7 = config.locations) === null || _config$locations7 === void 0 ? void 0 : _config$locations7.elementorLibrary),
198 location_l1: this.toLowerSnake(libraryType),
199 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca5 = config.secondaryLocations) === null || _config$secondaryLoca5 === void 0 ? void 0 : _config$secondaryLoca5.assetCard),
200 interaction_description: 'User inserts block/pages from elementor library',
201 metadata: {
202 template_id: String(assetId),
203 template_name: this.decodeHtmlEntities(assetName) || ''
204 }
205 });
206 if (proRequired) {
207 payload.state = 'pro_plan_required';
208 }
209 return this.dispatchEvent(config === null || config === void 0 || (_config$names5 = config.names) === null || _config$names5 === void 0 || (_config$names5 = _config$names5.editorOne) === null || _config$names5 === void 0 ? void 0 : _config$names5.eLibraryInsert, payload);
210 }
211 }, {
212 key: "sendELibraryFavorite",
213 value: function sendELibraryFavorite(_ref3) {
214 var _config$triggers6, _config$targetTypes7, _config$interactionRe7, _config$locations8, _config$secondaryLoca6, _config$names6;
215 var assetId = _ref3.assetId,
216 assetName = _ref3.assetName,
217 libraryType = _ref3.libraryType,
218 isFavorite = _ref3.isFavorite,
219 _ref3$proRequired = _ref3.proRequired,
220 proRequired = _ref3$proRequired === void 0 ? false : _ref3$proRequired;
221 var config = this.getConfig();
222 var payload = this.createBasePayload({
223 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers6 = config.triggers) === null || _config$triggers6 === void 0 ? void 0 : _config$triggers6.click),
224 target_type: config === null || config === void 0 || (_config$targetTypes7 = config.targetTypes) === null || _config$targetTypes7 === void 0 ? void 0 : _config$targetTypes7.toggle,
225 target_name: String(assetId),
226 interaction_result: config === null || config === void 0 || (_config$interactionRe7 = config.interactionResults) === null || _config$interactionRe7 === void 0 ? void 0 : _config$interactionRe7.assetFavorite,
227 target_value: Boolean(isFavorite),
228 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations8 = config.locations) === null || _config$locations8 === void 0 ? void 0 : _config$locations8.elementorLibrary),
229 location_l1: this.toLowerSnake(libraryType),
230 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca6 = config.secondaryLocations) === null || _config$secondaryLoca6 === void 0 ? void 0 : _config$secondaryLoca6.assetCard),
231 interaction_description: 'User favorite block/pages from elementor library',
232 metadata: {
233 template_id: String(assetId),
234 template_name: this.decodeHtmlEntities(assetName) || ''
235 }
236 });
237 if (proRequired) {
238 payload.state = 'pro_plan_required';
239 }
240 return this.dispatchEvent(config === null || config === void 0 || (_config$names6 = config.names) === null || _config$names6 === void 0 || (_config$names6 = _config$names6.editorOne) === null || _config$names6 === void 0 ? void 0 : _config$names6.eLibraryFavorite, payload);
241 }
242 }, {
243 key: "sendELibraryGenerateAi",
244 value: function sendELibraryGenerateAi(_ref4) {
245 var _config$names7, _config$triggers7, _config$targetTypes8, _config$interactionRe8, _config$locations9, _config$secondaryLoca7;
246 var assetId = _ref4.assetId,
247 assetName = _ref4.assetName,
248 libraryType = _ref4.libraryType;
249 var config = this.getConfig();
250 return this.dispatchEvent(config === null || config === void 0 || (_config$names7 = config.names) === null || _config$names7 === void 0 || (_config$names7 = _config$names7.editorOne) === null || _config$names7 === void 0 ? void 0 : _config$names7.eLibraryGenerateAi, this.createBasePayload({
251 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers7 = config.triggers) === null || _config$triggers7 === void 0 ? void 0 : _config$triggers7.click),
252 target_type: config === null || config === void 0 || (_config$targetTypes8 = config.targetTypes) === null || _config$targetTypes8 === void 0 ? void 0 : _config$targetTypes8.button,
253 target_name: String(assetId),
254 interaction_result: config === null || config === void 0 || (_config$interactionRe8 = config.interactionResults) === null || _config$interactionRe8 === void 0 ? void 0 : _config$interactionRe8.aiGenerate,
255 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations9 = config.locations) === null || _config$locations9 === void 0 ? void 0 : _config$locations9.elementorLibrary),
256 location_l1: this.toLowerSnake(libraryType),
257 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca7 = config.secondaryLocations) === null || _config$secondaryLoca7 === void 0 ? void 0 : _config$secondaryLoca7.assetCard),
258 interaction_description: 'User generated block/page based on a library asset',
259 metadata: {
260 template_id: String(assetId),
261 template_name: this.decodeHtmlEntities(assetName) || ''
262 }
263 }));
264 }
265 }, {
266 key: "sendFinderSearchInput",
267 value: function sendFinderSearchInput(_ref5) {
268 var _config$triggers8, _config$targetTypes9, _config$interactionRe9, _config$interactionRe0, _config$secondaryLoca8, _config$names8;
269 var resultsCount = _ref5.resultsCount,
270 _ref5$searchTerm = _ref5.searchTerm,
271 searchTerm = _ref5$searchTerm === void 0 ? null : _ref5$searchTerm;
272 var config = this.getConfig();
273 var hasResults = resultsCount > 0;
274 var finderContext = this.getFinderContext();
275 var payload = this.createBasePayload({
276 window_name: finderContext.windowName,
277 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers8 = config.triggers) === null || _config$triggers8 === void 0 ? void 0 : _config$triggers8.typing),
278 target_type: config === null || config === void 0 || (_config$targetTypes9 = config.targetTypes) === null || _config$targetTypes9 === void 0 ? void 0 : _config$targetTypes9.searchInput,
279 target_name: 'finder',
280 interaction_result: hasResults ? config === null || config === void 0 || (_config$interactionRe9 = config.interactionResults) === null || _config$interactionRe9 === void 0 ? void 0 : _config$interactionRe9.resultsUpdated : config === null || config === void 0 || (_config$interactionRe0 = config.interactionResults) === null || _config$interactionRe0 === void 0 ? void 0 : _config$interactionRe0.noResults,
281 target_location: finderContext.targetLocation,
282 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca8 = config.secondaryLocations) === null || _config$secondaryLoca8 === void 0 ? void 0 : _config$secondaryLoca8.finder),
283 interaction_description: 'Finder search input, follows debounce behavior',
284 metadata: {
285 results_count: resultsCount
286 }
287 });
288 if (!hasResults && searchTerm) {
289 payload.metadata.search_term = searchTerm;
290 }
291 return this.dispatchEvent(config === null || config === void 0 || (_config$names8 = config.names) === null || _config$names8 === void 0 || (_config$names8 = _config$names8.editorOne) === null || _config$names8 === void 0 ? void 0 : _config$names8.finderSearchInput, payload);
292 }
293 }, {
294 key: "sendFinderResultSelect",
295 value: function sendFinderResultSelect(choice) {
296 var _config$names9, _config$triggers9, _config$targetTypes0, _config$interactionRe1, _config$secondaryLoca9, _config$secondaryLoca0;
297 var config = this.getConfig();
298 var finderContext = this.getFinderContext();
299 return this.dispatchEvent(config === null || config === void 0 || (_config$names9 = config.names) === null || _config$names9 === void 0 || (_config$names9 = _config$names9.editorOne) === null || _config$names9 === void 0 ? void 0 : _config$names9.finderResultSelect, this.createBasePayload({
300 window_name: finderContext.windowName,
301 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers9 = config.triggers) === null || _config$triggers9 === void 0 ? void 0 : _config$triggers9.click),
302 target_type: config === null || config === void 0 || (_config$targetTypes0 = config.targetTypes) === null || _config$targetTypes0 === void 0 ? void 0 : _config$targetTypes0.searchResult,
303 target_name: choice,
304 interaction_result: config === null || config === void 0 || (_config$interactionRe1 = config.interactionResults) === null || _config$interactionRe1 === void 0 ? void 0 : _config$interactionRe1.selected,
305 target_location: finderContext.targetLocation,
306 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca9 = config.secondaryLocations) === null || _config$secondaryLoca9 === void 0 ? void 0 : _config$secondaryLoca9.finder),
307 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca0 = config.secondaryLocations) === null || _config$secondaryLoca0 === void 0 ? void 0 : _config$secondaryLoca0.finderResults),
308 interaction_description: 'Finder search results was selected'
309 }));
310 }
311 }, {
312 key: "sendCanvasEmptyBoxAction",
313 value: function sendCanvasEmptyBoxAction(_ref6) {
314 var _config$triggers0, _config$targetTypes1, _config$interactionRe10, _config$locations0, _config$secondaryLoca1, _config$names0;
315 var targetName = _ref6.targetName,
316 _ref6$metadata = _ref6.metadata,
317 metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata,
318 _ref6$containerCreate = _ref6.containerCreated,
319 containerCreated = _ref6$containerCreate === void 0 ? null : _ref6$containerCreate;
320 var config = this.getConfig();
321 var payload = this.createBasePayload({
322 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers0 = config.triggers) === null || _config$triggers0 === void 0 ? void 0 : _config$triggers0.click),
323 target_type: config === null || config === void 0 || (_config$targetTypes1 = config.targetTypes) === null || _config$targetTypes1 === void 0 ? void 0 : _config$targetTypes1.buttons,
324 target_name: targetName,
325 interaction_result: config === null || config === void 0 || (_config$interactionRe10 = config.interactionResults) === null || _config$interactionRe10 === void 0 ? void 0 : _config$interactionRe10.selected,
326 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations0 = config.locations) === null || _config$locations0 === void 0 ? void 0 : _config$locations0.canvas),
327 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca1 = config.secondaryLocations) === null || _config$secondaryLoca1 === void 0 ? void 0 : _config$secondaryLoca1.emptyBox),
328 interaction_description: 'Empty box on canvas actions'
329 });
330 if (Object.keys(metadata).length > 0) {
331 payload.metadata = metadata;
332 }
333 if (containerCreated !== null) {
334 payload.state = containerCreated;
335 }
336 return this.dispatchEvent(config === null || config === void 0 || (_config$names0 = config.names) === null || _config$names0 === void 0 || (_config$names0 = _config$names0.editorOne) === null || _config$names0 === void 0 ? void 0 : _config$names0.canvasEmptyBoxAction, payload);
337 }
338 }, {
339 key: "sendWidgetPanelSearch",
340 value: function sendWidgetPanelSearch(_ref7) {
341 var _config$triggers1, _config$targetTypes10, _config$interactionRe11, _config$interactionRe12, _config$locations1, _config$locations10, _config$secondaryLoca10, _config$names1;
342 var resultsCount = _ref7.resultsCount,
343 _ref7$userInput = _ref7.userInput,
344 userInput = _ref7$userInput === void 0 ? null : _ref7$userInput;
345 var config = this.getConfig();
346 var hasResults = resultsCount > 0;
347 var payload = this.createBasePayload({
348 interaction_type: this.toLowerSnake(config === null || config === void 0 || (_config$triggers1 = config.triggers) === null || _config$triggers1 === void 0 ? void 0 : _config$triggers1.typing),
349 target_type: config === null || config === void 0 || (_config$targetTypes10 = config.targetTypes) === null || _config$targetTypes10 === void 0 ? void 0 : _config$targetTypes10.searchWidget,
350 target_name: 'search_widget',
351 interaction_result: hasResults ? config === null || config === void 0 || (_config$interactionRe11 = config.interactionResults) === null || _config$interactionRe11 === void 0 ? void 0 : _config$interactionRe11.resultsUpdated : config === null || config === void 0 || (_config$interactionRe12 = config.interactionResults) === null || _config$interactionRe12 === void 0 ? void 0 : _config$interactionRe12.noResults,
352 target_location: this.toLowerSnake(config === null || config === void 0 || (_config$locations1 = config.locations) === null || _config$locations1 === void 0 ? void 0 : _config$locations1.leftPanel),
353 location_l1: this.toLowerSnake(config === null || config === void 0 || (_config$locations10 = config.locations) === null || _config$locations10 === void 0 ? void 0 : _config$locations10.widgetPanel),
354 location_l2: this.toLowerSnake(config === null || config === void 0 || (_config$secondaryLoca10 = config.secondaryLocations) === null || _config$secondaryLoca10 === void 0 ? void 0 : _config$secondaryLoca10.searchBar),
355 interaction_description: 'Widget search input, follows debounce behavior'
356 });
357 if (!hasResults && userInput) {
358 payload.metadata = {
359 user_input: userInput
360 };
361 }
362 return this.dispatchEvent(config === null || config === void 0 || (_config$names1 = config.names) === null || _config$names1 === void 0 || (_config$names1 = _config$names1.editorOne) === null || _config$names1 === void 0 ? void 0 : _config$names1.widgetPanelSearch, payload);
363 }
364 }]);
365 }();
366 var createDebouncedFinderSearch = exports.createDebouncedFinderSearch = function createDebouncedFinderSearch() {
367 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
368 return _.debounce(function (resultsCount, searchTerm) {
369 EditorOneEventManager.sendFinderSearchInput({
370 resultsCount: resultsCount,
371 searchTerm: searchTerm
372 });
373 }, delay);
374 };
375 var createDebouncedWidgetPanelSearch = exports.createDebouncedWidgetPanelSearch = function createDebouncedWidgetPanelSearch() {
376 var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
377 return _.debounce(function (resultsCount, userInput) {
378 EditorOneEventManager.sendWidgetPanelSearch({
379 resultsCount: resultsCount,
380 userInput: userInput
381 });
382 }, delay);
383 };
384 var _default = exports["default"] = EditorOneEventManager;
385
386 /***/ }),
387
388 /***/ "../assets/dev/js/editor/utils/files-upload-handler.js":
389 /*!*************************************************************!*\
390 !*** ../assets/dev/js/editor/utils/files-upload-handler.js ***!
391 \*************************************************************/
392 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
393
394 "use strict";
395 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
396
397
398 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
399 Object.defineProperty(exports, "__esModule", ({
400 value: true
401 }));
402 exports["default"] = void 0;
403 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
404 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
405 var FilesUploadHandler = exports["default"] = /*#__PURE__*/function () {
406 function FilesUploadHandler() {
407 (0, _classCallCheck2.default)(this, FilesUploadHandler);
408 }
409 return (0, _createClass2.default)(FilesUploadHandler, null, [{
410 key: "isUploadEnabled",
411 value: function isUploadEnabled(mediaType) {
412 var unfilteredFilesTypes = ['svg', 'application/json'];
413 if (!unfilteredFilesTypes.includes(mediaType)) {
414 return true;
415 }
416 return elementorCommon.config.filesUpload.unfilteredFiles;
417 }
418 }, {
419 key: "setUploadTypeCaller",
420 value: function setUploadTypeCaller(frame) {
421 frame.uploader.uploader.param('uploadTypeCaller', 'elementor-wp-media-upload');
422 }
423 }, {
424 key: "getUnfilteredFilesNonAdminDialog",
425 value: function getUnfilteredFilesNonAdminDialog() {
426 return elementorCommon.dialogsManager.createWidget('alert', {
427 id: 'e-unfiltered-files-disabled-dialog',
428 headerMessage: __('Sorry, you can\'t upload that file yet', 'elementor'),
429 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'),
430 strings: {
431 confirm: __('Got it', 'elementor')
432 }
433 });
434 }
435 }, {
436 key: "getUnfilteredFilesNotEnabledDialog",
437 value: function getUnfilteredFilesNotEnabledDialog(callback) {
438 var elementorInstance = window.elementorAdmin || window.elementor;
439 if (!elementorInstance.config.user.is_administrator) {
440 return this.getUnfilteredFilesNonAdminDialog();
441 }
442 var onConfirm = function onConfirm() {
443 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {}, true);
444 elementorCommon.config.filesUpload.unfilteredFiles = true;
445 callback();
446 };
447 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);
448 }
449 }, {
450 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
451 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
452 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) {
453 return this.getUnfilteredFilesNonAdminDialog();
454 }
455 return elementorCommon.dialogsManager.createWidget('confirm', {
456 id: 'e-enable-unfiltered-files-dialog-import-template',
457 headerMessage: __('Enable Unfiltered File Uploads', 'elementor'),
458 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'),
459 position: {
460 my: 'center center',
461 at: 'center center'
462 },
463 strings: {
464 confirm: __('Enable and Import', 'elementor'),
465 cancel: __('Import Without Enabling', 'elementor')
466 },
467 onConfirm: function onConfirm() {
468 elementorCommon.ajax.addRequest('enable_unfiltered_files_upload', {
469 success: function success() {
470 // This utility is used in both the admin and the Editor.
471 elementorCommon.config.filesUpload.unfilteredFiles = true;
472 callback();
473 }
474 }, true);
475 },
476 onCancel: function onCancel() {
477 return callback();
478 }
479 });
480 }
481 }]);
482 }();
483
484 /***/ }),
485
486 /***/ "../assets/dev/js/editor/utils/is-instanceof.js":
487 /*!******************************************************!*\
488 !*** ../assets/dev/js/editor/utils/is-instanceof.js ***!
489 \******************************************************/
490 /***/ ((__unused_webpack_module, exports) => {
491
492 "use strict";
493
494
495 Object.defineProperty(exports, "__esModule", ({
496 value: true
497 }));
498 exports["default"] = void 0;
499 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; } } }; }
500 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; } }
501 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; }
502 /**
503 * Some FileAPI objects such as FileList, DataTransferItem and DataTransferItemList has inconsistency with the retrieved
504 * object (from events, etc.) and the actual JavaScript object so a regular instanceof doesn't work. This function can
505 * check whether it's instanceof by using the objects constructor and prototype names.
506 *
507 * @param object
508 * @param constructors
509 * @return {boolean}
510 */
511 var _default = exports["default"] = function _default(object, constructors) {
512 constructors = Array.isArray(constructors) ? constructors : [constructors];
513 var _iterator = _createForOfIteratorHelper(constructors),
514 _step;
515 try {
516 for (_iterator.s(); !(_step = _iterator.n()).done;) {
517 var constructor = _step.value;
518 if (object.constructor.name === constructor.prototype[Symbol.toStringTag]) {
519 return true;
520 }
521 }
522 } catch (err) {
523 _iterator.e(err);
524 } finally {
525 _iterator.f();
526 }
527 return false;
528 };
529
530 /***/ }),
531
532 /***/ "../assets/dev/js/modules/imports/args-object.js":
533 /*!*******************************************************!*\
534 !*** ../assets/dev/js/modules/imports/args-object.js ***!
535 \*******************************************************/
536 /***/ ((__unused_webpack_module, 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 Object.defineProperty(exports, "__esModule", ({
543 value: true
544 }));
545 exports["default"] = void 0;
546 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
547 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
548 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
549 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
550 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
551 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
552 var _instanceType = _interopRequireDefault(__webpack_require__(/*! ./instance-type */ "../assets/dev/js/modules/imports/instance-type.js"));
553 var _isInstanceof = _interopRequireDefault(__webpack_require__(/*! ../../editor/utils/is-instanceof */ "../assets/dev/js/editor/utils/is-instanceof.js"));
554 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)); }
555 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
556 var ArgsObject = exports["default"] = /*#__PURE__*/function (_InstanceType) {
557 /**
558 * Function constructor().
559 *
560 * Create ArgsObject.
561 *
562 * @param {{}} args
563 */
564 function ArgsObject(args) {
565 var _this;
566 (0, _classCallCheck2.default)(this, ArgsObject);
567 _this = _callSuper(this, ArgsObject);
568 _this.args = args;
569 return _this;
570 }
571
572 /**
573 * Function requireArgument().
574 *
575 * Validate property in args.
576 *
577 * @param {string} property
578 * @param {{}} args
579 *
580 * @throws {Error}
581 */
582 (0, _inherits2.default)(ArgsObject, _InstanceType);
583 return (0, _createClass2.default)(ArgsObject, [{
584 key: "requireArgument",
585 value: function requireArgument(property) {
586 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.args;
587 if (!Object.prototype.hasOwnProperty.call(args, property)) {
588 throw Error("".concat(property, " is required."));
589 }
590 }
591
592 /**
593 * Function requireArgumentType().
594 *
595 * Validate property in args using `type === typeof(args.whatever)`.
596 *
597 * @param {string} property
598 * @param {string} type
599 * @param {{}} args
600 *
601 * @throws {Error}
602 */
603 }, {
604 key: "requireArgumentType",
605 value: function requireArgumentType(property, type) {
606 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
607 this.requireArgument(property, args);
608 if ((0, _typeof2.default)(args[property]) !== type) {
609 throw Error("".concat(property, " invalid type: ").concat(type, "."));
610 }
611 }
612
613 /**
614 * Function requireArgumentInstance().
615 *
616 * Validate property in args using `args.whatever instanceof instance`.
617 *
618 * @param {string} property
619 * @param {*} instance
620 * @param {{}} args
621 *
622 * @throws {Error}
623 */
624 }, {
625 key: "requireArgumentInstance",
626 value: function requireArgumentInstance(property, instance) {
627 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
628 this.requireArgument(property, args);
629 if (!(args[property] instanceof instance) && !(0, _isInstanceof.default)(args[property], instance)) {
630 throw Error("".concat(property, " invalid instance."));
631 }
632 }
633
634 /**
635 * Function requireArgumentConstructor().
636 *
637 * Validate property in args using `type === args.whatever.constructor`.
638 *
639 * @param {string} property
640 * @param {*} type
641 * @param {{}} args
642 *
643 * @throws {Error}
644 */
645 }, {
646 key: "requireArgumentConstructor",
647 value: function requireArgumentConstructor(property, type) {
648 var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.args;
649 this.requireArgument(property, args);
650
651 // Note: Converting the constructor to string in order to avoid equation issues
652 // due to different memory addresses between iframes (window.Object !== window.top.Object).
653 if (args[property].constructor.toString() !== type.prototype.constructor.toString()) {
654 throw Error("".concat(property, " invalid constructor type."));
655 }
656 }
657 }], [{
658 key: "getInstanceType",
659 value: function getInstanceType() {
660 return 'ArgsObject';
661 }
662 }]);
663 }(_instanceType.default);
664
665 /***/ }),
666
667 /***/ "../assets/dev/js/modules/imports/instance-type.js":
668 /*!*********************************************************!*\
669 !*** ../assets/dev/js/modules/imports/instance-type.js ***!
670 \*********************************************************/
671 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
672
673 "use strict";
674
675
676 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
677 Object.defineProperty(exports, "__esModule", ({
678 value: true
679 }));
680 exports["default"] = void 0;
681 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
682 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
683 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
684 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
685 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; }
686 var InstanceType = exports["default"] = /*#__PURE__*/function () {
687 function InstanceType() {
688 var _this = this;
689 (0, _classCallCheck2.default)(this, InstanceType);
690 // Since anonymous classes sometimes do not get validated by babel, do it manually.
691 var target = this instanceof InstanceType ? this.constructor : void 0;
692 var prototypes = [];
693 while (target.__proto__ && target.__proto__.name) {
694 prototypes.push(target.__proto__);
695 target = target.__proto__;
696 }
697 prototypes.reverse().forEach(function (proto) {
698 return _this instanceof proto;
699 });
700 }
701 return (0, _createClass2.default)(InstanceType, null, [{
702 key: Symbol.hasInstance,
703 value: function value(target) {
704 /**
705 * This is function extending being called each time JS uses instanceOf, since babel use it each time it create new class
706 * its give's opportunity to mange capabilities of instanceOf operator.
707 * saving current class each time will give option later to handle instanceOf manually.
708 */
709 var result = _superPropGet(InstanceType, Symbol.hasInstance, this, 2)([target]);
710
711 // Act normal when validate a class, which does not have instance type.
712 if (target && !target.constructor.getInstanceType) {
713 return result;
714 }
715 if (target) {
716 if (!target.instanceTypes) {
717 target.instanceTypes = [];
718 }
719 if (!result) {
720 if (this.getInstanceType() === target.constructor.getInstanceType()) {
721 result = true;
722 }
723 }
724 if (result) {
725 var name = this.getInstanceType === InstanceType.getInstanceType ? 'BaseInstanceType' : this.getInstanceType();
726 if (-1 === target.instanceTypes.indexOf(name)) {
727 target.instanceTypes.push(name);
728 }
729 }
730 }
731 if (!result && target) {
732 // Check if the given 'target', is instance of known types.
733 result = target.instanceTypes && Array.isArray(target.instanceTypes) && -1 !== target.instanceTypes.indexOf(this.getInstanceType());
734 }
735 return result;
736 }
737 }, {
738 key: "getInstanceType",
739 value: function getInstanceType() {
740 elementorModules.ForceMethodImplementation();
741 }
742 }]);
743 }();
744
745 /***/ }),
746
747 /***/ "../assets/dev/js/modules/imports/module.js":
748 /*!**************************************************!*\
749 !*** ../assets/dev/js/modules/imports/module.js ***!
750 \**************************************************/
751 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
752
753 "use strict";
754
755
756 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
757 var _typeof2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js"));
758 var Module = function Module() {
759 var $ = jQuery,
760 instanceParams = arguments,
761 self = this,
762 events = {};
763 var settings;
764 var ensureClosureMethods = function ensureClosureMethods() {
765 $.each(self, function (methodName) {
766 var oldMethod = self[methodName];
767 if ('function' !== typeof oldMethod) {
768 return;
769 }
770 self[methodName] = function () {
771 return oldMethod.apply(self, arguments);
772 };
773 });
774 };
775 var initSettings = function initSettings() {
776 settings = self.getDefaultSettings();
777 var instanceSettings = instanceParams[0];
778 if (instanceSettings) {
779 $.extend(true, settings, instanceSettings);
780 }
781 };
782 var init = function init() {
783 self.__construct.apply(self, instanceParams);
784 ensureClosureMethods();
785 initSettings();
786 self.trigger('init');
787 };
788 this.getItems = function (items, itemKey) {
789 if (itemKey) {
790 var keyStack = itemKey.split('.'),
791 currentKey = keyStack.splice(0, 1);
792 if (!keyStack.length) {
793 return items[currentKey];
794 }
795 if (!items[currentKey]) {
796 return;
797 }
798 return this.getItems(items[currentKey], keyStack.join('.'));
799 }
800 return items;
801 };
802 this.getSettings = function (setting) {
803 return this.getItems(settings, setting);
804 };
805 this.setSettings = function (settingKey, value, settingsContainer) {
806 if (!settingsContainer) {
807 settingsContainer = settings;
808 }
809 if ('object' === (0, _typeof2.default)(settingKey)) {
810 $.extend(settingsContainer, settingKey);
811 return self;
812 }
813 var keyStack = settingKey.split('.'),
814 currentKey = keyStack.splice(0, 1);
815 if (!keyStack.length) {
816 settingsContainer[currentKey] = value;
817 return self;
818 }
819 if (!settingsContainer[currentKey]) {
820 settingsContainer[currentKey] = {};
821 }
822 return self.setSettings(keyStack.join('.'), value, settingsContainer[currentKey]);
823 };
824 this.getErrorMessage = function (type, functionName) {
825 var message;
826 switch (type) {
827 case 'forceMethodImplementation':
828 message = "The method '".concat(functionName, "' must to be implemented in the inheritor child.");
829 break;
830 default:
831 message = 'An error occurs';
832 }
833 return message;
834 };
835
836 // TODO: This function should be deleted ?.
837 this.forceMethodImplementation = function (functionName) {
838 throw new Error(this.getErrorMessage('forceMethodImplementation', functionName));
839 };
840 this.on = function (eventName, callback) {
841 if ('object' === (0, _typeof2.default)(eventName)) {
842 $.each(eventName, function (singleEventName) {
843 self.on(singleEventName, this);
844 });
845 return self;
846 }
847 var eventNames = eventName.split(' ');
848 eventNames.forEach(function (singleEventName) {
849 if (!events[singleEventName]) {
850 events[singleEventName] = [];
851 }
852 events[singleEventName].push(callback);
853 });
854 return self;
855 };
856 this.off = function (eventName, callback) {
857 if (!events[eventName]) {
858 return self;
859 }
860 if (!callback) {
861 delete events[eventName];
862 return self;
863 }
864 var callbackIndex = events[eventName].indexOf(callback);
865 if (-1 !== callbackIndex) {
866 delete events[eventName][callbackIndex];
867
868 // Reset array index (for next off on same event).
869 events[eventName] = events[eventName].filter(function (val) {
870 return val;
871 });
872 }
873 return self;
874 };
875 this.trigger = function (eventName) {
876 var methodName = 'on' + eventName[0].toUpperCase() + eventName.slice(1),
877 params = Array.prototype.slice.call(arguments, 1);
878 if (self[methodName]) {
879 self[methodName].apply(self, params);
880 }
881 var callbacks = events[eventName];
882 if (!callbacks) {
883 return self;
884 }
885 $.each(callbacks, function (index, callback) {
886 callback.apply(self, params);
887 });
888 return self;
889 };
890 init();
891 };
892 Module.prototype.__construct = function () {};
893 Module.prototype.getDefaultSettings = function () {
894 return {};
895 };
896 Module.prototype.getConstructorID = function () {
897 return this.constructor.name;
898 };
899 Module.extend = function (properties) {
900 var $ = jQuery,
901 parent = this;
902 var child = function child() {
903 return parent.apply(this, arguments);
904 };
905 $.extend(child, parent);
906 child.prototype = Object.create($.extend({}, parent.prototype, properties));
907 child.prototype.constructor = child;
908 child.__super__ = parent.prototype;
909 return child;
910 };
911 module.exports = Module;
912
913 /***/ }),
914
915 /***/ "../assets/dev/js/utils/notifications.js":
916 /*!***********************************************!*\
917 !*** ../assets/dev/js/utils/notifications.js ***!
918 \***********************************************/
919 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
920
921 "use strict";
922
923
924 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
925 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
926 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; }
927 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; }
928 module.exports = elementorModules.Module.extend({
929 initToast: function initToast() {
930 var toast = elementorCommon.dialogsManager.createWidget('buttons', {
931 id: 'elementor-toast',
932 position: {
933 my: 'center bottom',
934 at: 'center bottom-10',
935 of: '#elementor-panel-inner',
936 autoRefresh: true
937 },
938 hide: {
939 onClick: true,
940 auto: true,
941 autoDelay: 10000
942 },
943 effects: {
944 show: function show() {
945 var $widget = toast.getElements('widget');
946 $widget.show();
947 toast.refreshPosition();
948 var top = parseInt($widget.css('top'), 10);
949 $widget.hide().css('top', top + 100);
950 $widget.animate({
951 opacity: 'show',
952 height: 'show',
953 paddingBottom: 'show',
954 paddingTop: 'show',
955 top: top
956 }, {
957 easing: 'linear',
958 duration: 300
959 });
960 },
961 hide: function hide() {
962 var $widget = toast.getElements('widget'),
963 top = parseInt($widget.css('top'), 10);
964 $widget.animate({
965 opacity: 'hide',
966 height: 'hide',
967 paddingBottom: 'hide',
968 paddingTop: 'hide',
969 top: top + 100
970 }, {
971 easing: 'linear',
972 duration: 300
973 });
974 }
975 },
976 button: {
977 tag: 'button'
978 }
979 });
980
981 // Add role="status" and aria-live for screen reader announcement
982 toast.getElements('widget').attr({
983 role: 'status',
984 'aria-live': 'polite',
985 'aria-atomic': 'true'
986 });
987 this.getToast = function () {
988 return toast;
989 };
990 },
991 showToast: function showToast(options) {
992 var toast = this.getToast();
993 toast.setMessage(options.message);
994 toast.getElements('buttonsWrapper').empty();
995 toast.focusedButton = null;
996 toast.buttons = [];
997 var isPositionValid = this.isPositionValid(options === null || options === void 0 ? void 0 : options.position);
998 if (!isPositionValid) {
999 this.positionToWindow();
1000 }
1001 if (options !== null && options !== void 0 && options.position && isPositionValid) {
1002 toast.setSettings('position', options.position);
1003 }
1004 if (options.buttons) {
1005 options.buttons.forEach(function (button) {
1006 toast.addButton(button);
1007 });
1008 }
1009 if (options.classes) {
1010 toast.getElements('widget').addClass(options.classes);
1011 }
1012 if (options.sticky) {
1013 toast.setSettings({
1014 hide: {
1015 auto: false,
1016 onClick: false
1017 }
1018 });
1019 }
1020 return toast.show();
1021 },
1022 isPositionValid: function isPositionValid(position) {
1023 var _position$of;
1024 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;
1025 if (!positionToCheck) {
1026 return false;
1027 }
1028 return !!document.querySelector(positionToCheck);
1029 },
1030 positionToWindow: function positionToWindow() {
1031 var toast = this.getToast();
1032 var position = _objectSpread(_objectSpread({}, toast.getSettings('position')), {}, {
1033 my: 'right top',
1034 at: 'right-10 top+42',
1035 // 42px is the default admin bar height + 10px
1036 of: ''
1037 });
1038 toast.setSettings('position', position);
1039 toast.getElements('widget').addClass('dialog-position-window');
1040 },
1041 onInit: function onInit() {
1042 this.initToast();
1043 }
1044 });
1045
1046 /***/ }),
1047
1048 /***/ "../assets/dev/js/utils/tiers.js":
1049 /*!***************************************!*\
1050 !*** ../assets/dev/js/utils/tiers.js ***!
1051 \***************************************/
1052 /***/ ((__unused_webpack_module, exports) => {
1053
1054 "use strict";
1055
1056
1057 Object.defineProperty(exports, "__esModule", ({
1058 value: true
1059 }));
1060 exports.isTierAtLeast = exports.TIERS_PRIORITY = exports.TIERS = void 0;
1061 var TIERS_PRIORITY = exports.TIERS_PRIORITY = Object.freeze(['free', 'essential', 'essential-oct2023', 'advanced', 'expert', 'agency']);
1062
1063 /**
1064 * @type {Readonly<{
1065 * free: string;
1066 * essential: string;
1067 * 'essential-oct2023': string;
1068 * advanced: string;
1069 * expert: string;
1070 * agency: string;
1071 * }>}
1072 */
1073 var TIERS = exports.TIERS = Object.freeze(TIERS_PRIORITY.reduce(function (acc, tier) {
1074 acc[tier] = tier;
1075 return acc;
1076 }, {}));
1077 var isTierAtLeast = exports.isTierAtLeast = function isTierAtLeast(currentTier, expectedTier) {
1078 var currentTierIndex = TIERS_PRIORITY.indexOf(currentTier);
1079 var expectedTierIndex = TIERS_PRIORITY.indexOf(expectedTier);
1080 if (-1 === currentTierIndex || -1 === expectedTierIndex) {
1081 return false;
1082 }
1083 return currentTierIndex >= expectedTierIndex;
1084 };
1085
1086 /***/ }),
1087
1088 /***/ "../assets/dev/js/utils/time.js":
1089 /*!**************************************!*\
1090 !*** ../assets/dev/js/utils/time.js ***!
1091 \**************************************/
1092 /***/ ((__unused_webpack_module, exports) => {
1093
1094 "use strict";
1095
1096
1097 Object.defineProperty(exports, "__esModule", ({
1098 value: true
1099 }));
1100 exports["default"] = getUserTimestamp;
1101 /**
1102 * Returns the timestamp in ISO8601 format with the UTC timezone offset.
1103 *
1104 * @since 3.6.0
1105 *
1106 * @param {Date} date
1107 * @return {Date} timestamp
1108 */
1109 function getUserTimestamp() {
1110 var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
1111 var timezoneOffset = date.getTimezoneOffset();
1112
1113 // Local time for the user
1114 var UTCTimestamp = new Date(date.getTime() - timezoneOffset * 60000).toISOString();
1115
1116 // Remove the Z suffix from the string.
1117 UTCTimestamp = UTCTimestamp.slice(0, -1);
1118
1119 // Create the offset string in the format `+HH:00` (or minus (-) prefix for negative offset instead of plus)
1120 var decimalTimezoneOffset = timezoneOffset / 60,
1121 // Negative offsets include a '-' sign in the getTimezoneOffset value, positive values need a '+' prefix (ISO8601).
1122 sign = 0 <= decimalTimezoneOffset ? '+' : '-',
1123 hours = Math.abs(Math.floor(decimalTimezoneOffset)),
1124 minutes = Math.abs(decimalTimezoneOffset % 1) * 60,
1125 addZeroToHour = 10 > hours ? '0' : '',
1126 addZeroToMinutes = 10 > minutes ? '0' : '';
1127 var formattedTimezoneOffset = sign + addZeroToHour + hours + ':' + addZeroToMinutes + minutes;
1128 return UTCTimestamp + formattedTimezoneOffset;
1129 }
1130
1131 /***/ }),
1132
1133 /***/ "../core/common/assets/js/components/wordpress/commands-data/index.js":
1134 /*!****************************************************************************!*\
1135 !*** ../core/common/assets/js/components/wordpress/commands-data/index.js ***!
1136 \****************************************************************************/
1137 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1138
1139 "use strict";
1140
1141
1142 Object.defineProperty(exports, "__esModule", ({
1143 value: true
1144 }));
1145 Object.defineProperty(exports, "Media", ({
1146 enumerable: true,
1147 get: function get() {
1148 return _media.Media;
1149 }
1150 }));
1151 var _media = __webpack_require__(/*! ./media */ "../core/common/assets/js/components/wordpress/commands-data/media.js");
1152
1153 /***/ }),
1154
1155 /***/ "../core/common/assets/js/components/wordpress/commands-data/media.js":
1156 /*!****************************************************************************!*\
1157 !*** ../core/common/assets/js/components/wordpress/commands-data/media.js ***!
1158 \****************************************************************************/
1159 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1160
1161 "use strict";
1162 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1163
1164
1165 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1166 Object.defineProperty(exports, "__esModule", ({
1167 value: true
1168 }));
1169 exports.Media = void 0;
1170 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
1171 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
1172 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1173 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1174 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1175 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1176 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1177 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1178 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
1179 var _filesUploadHandler = _interopRequireDefault(__webpack_require__(/*! elementor-editor/utils/files-upload-handler */ "../assets/dev/js/editor/utils/files-upload-handler.js"));
1180 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)); }
1181 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1182 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; }
1183 var Media = exports.Media = /*#__PURE__*/function (_CommandData) {
1184 function Media() {
1185 (0, _classCallCheck2.default)(this, Media);
1186 return _callSuper(this, Media, arguments);
1187 }
1188 (0, _inherits2.default)(Media, _CommandData);
1189 return (0, _createClass2.default)(Media, [{
1190 key: "validateArgs",
1191 value: function validateArgs() {
1192 this.requireArgumentInstance('file', File);
1193 }
1194 }, {
1195 key: "getRequestData",
1196 value: function getRequestData() {
1197 var requestData = _superPropGet(Media, "getRequestData", this, 3)([]);
1198 requestData.namespace = 'wp';
1199 requestData.version = '2';
1200 return requestData;
1201 }
1202 }, {
1203 key: "applyBeforeCreate",
1204 value: function applyBeforeCreate(args) {
1205 var _args$options;
1206 args.headers = {
1207 'Content-Disposition': "attachment; filename=".concat(this.file.name),
1208 'Content-Type': this.file.type
1209 };
1210 args.query = {
1211 uploadTypeCaller: 'elementor-wp-media-upload'
1212 };
1213 args.data = this.file;
1214 if ((_args$options = args.options) !== null && _args$options !== void 0 && _args$options.progress) {
1215 this.toast = elementor.notifications.showToast({
1216 // eslint-disable-next-line @wordpress/i18n-ellipsis
1217 message: __('Uploading...'),
1218 sticky: true
1219 });
1220 }
1221 return args;
1222 }
1223 }, {
1224 key: "applyAfterCreate",
1225 value: function applyAfterCreate(data, args) {
1226 var _args$options2;
1227 if ((_args$options2 = args.options) !== null && _args$options2 !== void 0 && _args$options2.progress) {
1228 this.toast.hide();
1229 }
1230 return data;
1231 }
1232 }, {
1233 key: "run",
1234 value: function () {
1235 var _run = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
1236 return _regenerator.default.wrap(function (_context) {
1237 while (1) switch (_context.prev = _context.next) {
1238 case 0:
1239 this.file = this.args.file;
1240 if (!(this.file.size > parseInt(window._wpPluploadSettings.defaults.filters.max_file_size, 10))) {
1241 _context.next = 1;
1242 break;
1243 }
1244 throw new Error(__('The file exceeds the maximum upload size for this site.', 'elementor'));
1245 case 1:
1246 if (!(!window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(',').includes(this.file.name.split('.').pop()) && !elementor.config.filesUpload.unfilteredFiles)) {
1247 _context.next = 2;
1248 break;
1249 }
1250 _filesUploadHandler.default.getUnfilteredFilesNotEnabledDialog(function () {}).show();
1251 return _context.abrupt("return");
1252 case 2:
1253 _context.next = 3;
1254 return _superPropGet(Media, "run", this, 3)([]);
1255 case 3:
1256 return _context.abrupt("return", _context.sent);
1257 case 4:
1258 case "end":
1259 return _context.stop();
1260 }
1261 }, _callee, this);
1262 }));
1263 function run() {
1264 return _run.apply(this, arguments);
1265 }
1266 return run;
1267 }()
1268 }], [{
1269 key: "getEndpointFormat",
1270 value: function getEndpointFormat() {
1271 // 'wp/media' to 'media' since `requestData.namespace` is 'wp'.
1272 return 'media';
1273 }
1274 }]);
1275 }(_commandData.default);
1276
1277 /***/ }),
1278
1279 /***/ "../core/common/assets/js/components/wordpress/component.js":
1280 /*!******************************************************************!*\
1281 !*** ../core/common/assets/js/components/wordpress/component.js ***!
1282 \******************************************************************/
1283 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1284
1285 "use strict";
1286
1287
1288 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1289 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
1290 Object.defineProperty(exports, "__esModule", ({
1291 value: true
1292 }));
1293 exports["default"] = void 0;
1294 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1295 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1296 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1297 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1298 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1299 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
1300 var dataCommands = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/assets/js/components/wordpress/commands-data/index.js"));
1301 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); }
1302 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)); }
1303 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1304 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
1305 function Component() {
1306 (0, _classCallCheck2.default)(this, Component);
1307 return _callSuper(this, Component, arguments);
1308 }
1309 (0, _inherits2.default)(Component, _ComponentBase);
1310 return (0, _createClass2.default)(Component, [{
1311 key: "getNamespace",
1312 value: function getNamespace() {
1313 return 'wp';
1314 }
1315 }, {
1316 key: "defaultData",
1317 value: function defaultData() {
1318 return this.importCommands(dataCommands);
1319 }
1320 }]);
1321 }(_componentBase.default);
1322
1323 /***/ }),
1324
1325 /***/ "../core/common/assets/js/utils/debug.js":
1326 /*!***********************************************!*\
1327 !*** ../core/common/assets/js/utils/debug.js ***!
1328 \***********************************************/
1329 /***/ ((module) => {
1330
1331 "use strict";
1332
1333
1334 // Moved from assets/dev/js/editor/utils
1335 var Debug = function Debug() {
1336 var self = this,
1337 errorStack = [],
1338 settings = {},
1339 elements = {};
1340 var initSettings = function initSettings() {
1341 settings = {
1342 debounceDelay: 500,
1343 urlsToWatch: ['elementor/assets']
1344 };
1345 };
1346 var initElements = function initElements() {
1347 elements.$window = jQuery(window);
1348 };
1349 var onError = function onError(event) {
1350 var _event$originalEvent;
1351 var error = (_event$originalEvent = event.originalEvent) === null || _event$originalEvent === void 0 ? void 0 : _event$originalEvent.error;
1352 if (!error) {
1353 return;
1354 }
1355 var isInWatchList = false,
1356 urlsToWatch = settings.urlsToWatch;
1357 jQuery.each(urlsToWatch, function () {
1358 if (-1 !== error.stack.indexOf(this)) {
1359 isInWatchList = true;
1360 return false;
1361 }
1362 });
1363 if (!isInWatchList) {
1364 return;
1365 }
1366 self.addError({
1367 type: error.name,
1368 message: error.message,
1369 url: event.originalEvent.filename,
1370 line: event.originalEvent.lineno,
1371 column: event.originalEvent.colno
1372 });
1373 };
1374 var bindEvents = function bindEvents() {
1375 elements.$window.on('error', onError);
1376 };
1377 var init = function init() {
1378 initSettings();
1379 initElements();
1380 bindEvents();
1381 self.sendErrors = _.debounce(self.sendErrors, settings.debounceDelay);
1382 };
1383 this.addURLToWatch = function (url) {
1384 settings.urlsToWatch.push(url);
1385 };
1386 this.addCustomError = function (error, category, tag) {
1387 var errorInfo = {
1388 type: error.name,
1389 message: error.message,
1390 url: error.fileName || error.sourceURL,
1391 line: error.lineNumber || error.line,
1392 column: error.columnNumber || error.column,
1393 customFields: {
1394 category: category || 'general',
1395 tag: tag
1396 }
1397 };
1398 if (!errorInfo.url) {
1399 var stackInfo = error.stack.match(/\n {4}at (.*?(?=:(\d+):(\d+)))/);
1400 if (stackInfo) {
1401 errorInfo.url = stackInfo[1];
1402 errorInfo.line = stackInfo[2];
1403 errorInfo.column = stackInfo[3];
1404 }
1405 }
1406 this.addError(errorInfo);
1407 };
1408 this.addError = function (errorParams) {
1409 var defaultParams = {
1410 type: 'Error',
1411 timestamp: Math.floor(new Date().getTime() / 1000),
1412 message: null,
1413 url: null,
1414 line: null,
1415 column: null,
1416 customFields: {}
1417 };
1418 errorStack.push(jQuery.extend(true, defaultParams, errorParams));
1419 self.sendErrors();
1420 };
1421 this.sendErrors = function () {
1422 // Avoid recursions on errors in ajax
1423 elements.$window.off('error', onError);
1424 jQuery.ajax({
1425 url: elementorCommon.config.ajax.url,
1426 method: 'POST',
1427 data: {
1428 action: 'elementor_js_log',
1429 _nonce: elementorCommon.ajax.getSettings('nonce'),
1430 data: errorStack
1431 },
1432 success: function success() {
1433 errorStack = [];
1434
1435 // Restore error handler
1436 elements.$window.on('error', onError);
1437 }
1438 });
1439 };
1440 init();
1441 };
1442 module.exports = Debug;
1443
1444 /***/ }),
1445
1446 /***/ "../core/common/assets/js/utils/helpers.js":
1447 /*!*************************************************!*\
1448 !*** ../core/common/assets/js/utils/helpers.js ***!
1449 \*************************************************/
1450 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1451
1452 "use strict";
1453
1454
1455 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1456 Object.defineProperty(exports, "__esModule", ({
1457 value: true
1458 }));
1459 exports["default"] = void 0;
1460 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1461 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1462 var Helpers = exports["default"] = /*#__PURE__*/function () {
1463 function Helpers() {
1464 (0, _classCallCheck2.default)(this, Helpers);
1465 }
1466 return (0, _createClass2.default)(Helpers, [{
1467 key: "consoleWarn",
1468 value:
1469 /**
1470 * @param {*} args
1471 * @deprecated since 3.7.0, use `elementorDevTools.consoleWarn()` instead.
1472 */
1473 function consoleWarn() {
1474 var _elementorDevTools;
1475 (_elementorDevTools = elementorDevTools).consoleWarn.apply(_elementorDevTools, arguments);
1476
1477 // This is is self is deprecated.
1478 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleWarn()', '3.7.0', 'elementorDevTools.consoleWarn()');
1479 }
1480
1481 /**
1482 * @param {string} message
1483 * @deprecated since 3.7.0, use `console.error()` instead.
1484 */
1485 }, {
1486 key: "consoleError",
1487 value: function consoleError(message) {
1488 // eslint-disable-next-line no-console
1489 console.error(message);
1490
1491 // This is is self is deprecated.
1492 elementorDevTools.deprecation.deprecated('elementorCommon.helpers.consoleError()', '3.7.0', 'console.error()');
1493 }
1494 }, {
1495 key: "cloneObject",
1496 value: function cloneObject(object) {
1497 return JSON.parse(JSON.stringify(object));
1498 }
1499 }, {
1500 key: "upperCaseWords",
1501 value: function upperCaseWords(string) {
1502 return (string + '').replace(/^(.)|\s+(.)/g, function ($1) {
1503 return $1.toUpperCase();
1504 });
1505 }
1506 }, {
1507 key: "getUniqueId",
1508 value: function getUniqueId() {
1509 return Math.random().toString(16).substr(2, 7);
1510 }
1511 }]);
1512 }();
1513
1514 /***/ }),
1515
1516 /***/ "../core/common/assets/js/utils/storage.js":
1517 /*!*************************************************!*\
1518 !*** ../core/common/assets/js/utils/storage.js ***!
1519 \*************************************************/
1520 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1521
1522 "use strict";
1523
1524
1525 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1526 Object.defineProperty(exports, "__esModule", ({
1527 value: true
1528 }));
1529 exports["default"] = void 0;
1530 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1531 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1532 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1533 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1534 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1535 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)); }
1536 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1537 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1538 function _default() {
1539 (0, _classCallCheck2.default)(this, _default);
1540 return _callSuper(this, _default, arguments);
1541 }
1542 (0, _inherits2.default)(_default, _elementorModules$Mod);
1543 return (0, _createClass2.default)(_default, [{
1544 key: "get",
1545 value: function get(key, options) {
1546 options = options || {};
1547 var storage;
1548 try {
1549 storage = options.session ? sessionStorage : localStorage;
1550 } catch (e) {
1551 return key ? undefined : {};
1552 }
1553 var elementorStorage = storage.getItem('elementor');
1554 if (elementorStorage) {
1555 elementorStorage = JSON.parse(elementorStorage);
1556 } else {
1557 elementorStorage = {};
1558 }
1559 if (!elementorStorage.__expiration) {
1560 elementorStorage.__expiration = {};
1561 }
1562 var expiration = elementorStorage.__expiration;
1563 var expirationToCheck = [];
1564 if (key) {
1565 if (expiration[key]) {
1566 expirationToCheck = [key];
1567 }
1568 } else {
1569 expirationToCheck = Object.keys(expiration);
1570 }
1571 var entryExpired = false;
1572 expirationToCheck.forEach(function (expirationKey) {
1573 if (new Date(expiration[expirationKey]) < new Date()) {
1574 delete elementorStorage[expirationKey];
1575 delete expiration[expirationKey];
1576 entryExpired = true;
1577 }
1578 });
1579 if (entryExpired) {
1580 this.save(elementorStorage, options.session);
1581 }
1582 if (key) {
1583 return elementorStorage[key];
1584 }
1585 return elementorStorage;
1586 }
1587 }, {
1588 key: "set",
1589 value: function set(key, value, options) {
1590 options = options || {};
1591 var elementorStorage = this.get(null, options);
1592 elementorStorage[key] = value;
1593 if (options.lifetimeInSeconds) {
1594 var date = new Date();
1595 date.setTime(date.getTime() + options.lifetimeInSeconds * 1000);
1596 elementorStorage.__expiration[key] = date.getTime();
1597 }
1598 this.save(elementorStorage, options.session);
1599 }
1600 }, {
1601 key: "save",
1602 value: function save(object, session) {
1603 var storage;
1604 try {
1605 storage = session ? sessionStorage : localStorage;
1606 } catch (e) {
1607 return;
1608 }
1609 storage.setItem('elementor', JSON.stringify(object));
1610 }
1611 }]);
1612 }(elementorModules.Module);
1613
1614 /***/ }),
1615
1616 /***/ "../core/common/modules/ajax/assets/js/ajax.js":
1617 /*!*****************************************************!*\
1618 !*** ../core/common/modules/ajax/assets/js/ajax.js ***!
1619 \*****************************************************/
1620 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1621
1622 "use strict";
1623
1624
1625 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1626 Object.defineProperty(exports, "__esModule", ({
1627 value: true
1628 }));
1629 exports["default"] = void 0;
1630 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
1631 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1632 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1633 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1634 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1635 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1636 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)); }
1637 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1638 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
1639 function _default() {
1640 var _this;
1641 (0, _classCallCheck2.default)(this, _default);
1642 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1643 args[_key] = arguments[_key];
1644 }
1645 _this = _callSuper(this, _default, [].concat(args));
1646 _this.requests = {};
1647 _this.cache = {};
1648 _this.initRequestConstants();
1649 _this.debounceSendBatch = _.debounce(_this.sendBatch.bind(_this), 500);
1650 return _this;
1651 }
1652 (0, _inherits2.default)(_default, _elementorModules$Mod);
1653 return (0, _createClass2.default)(_default, [{
1654 key: "getDefaultSettings",
1655 value: function getDefaultSettings() {
1656 return {
1657 ajaxParams: {
1658 type: 'POST',
1659 url: elementorCommon.config.ajax.url,
1660 data: {},
1661 dataType: 'json'
1662 },
1663 actionPrefix: 'elementor_'
1664 };
1665 }
1666 }, {
1667 key: "initRequestConstants",
1668 value: function initRequestConstants() {
1669 this.requestConstants = {
1670 _nonce: this.getSettings('nonce')
1671 };
1672 }
1673 }, {
1674 key: "addRequestConstant",
1675 value: function addRequestConstant(key, value) {
1676 this.requestConstants[key] = value;
1677 }
1678 }, {
1679 key: "getCacheKey",
1680 value: function getCacheKey(request) {
1681 return JSON.stringify({
1682 unique_id: request.unique_id,
1683 data: request.data
1684 });
1685 }
1686 }, {
1687 key: "loadObjects",
1688 value: function loadObjects(options) {
1689 var _this2 = this;
1690 var dataCollection = {};
1691 var deferredArray = [];
1692 if (options.before) {
1693 options.before();
1694 }
1695 options.ids.forEach(function (objectId) {
1696 deferredArray.push(_this2.load({
1697 action: options.action,
1698 unique_id: options.data.unique_id + objectId,
1699 data: jQuery.extend({
1700 id: objectId
1701 }, options.data)
1702 }).done(function (data) {
1703 return dataCollection = jQuery.extend(dataCollection, data);
1704 }));
1705 });
1706 jQuery.when.apply(jQuery, deferredArray).done(function () {
1707 return options.success(dataCollection);
1708 });
1709 }
1710 }, {
1711 key: "load",
1712 value: function load(request, immediately) {
1713 var _this3 = this;
1714 if (!request.unique_id) {
1715 request.unique_id = request.action;
1716 }
1717 if (request.before) {
1718 request.before();
1719 }
1720 var deferred;
1721 var cacheKey = this.getCacheKey(request);
1722 if (_.has(this.cache, cacheKey)) {
1723 deferred = jQuery.Deferred().done(request.success).resolve(this.cache[cacheKey]);
1724 } else {
1725 var _request$error;
1726 deferred = this.addRequest(request.action, {
1727 data: request.data,
1728 unique_id: request.unique_id,
1729 success: function success(data) {
1730 return _this3.cache[cacheKey] = data;
1731 },
1732 error: (_request$error = request.error) !== null && _request$error !== void 0 ? _request$error : function () {}
1733 }, immediately).done(request.success);
1734 }
1735 return deferred;
1736 }
1737 }, {
1738 key: "cancelRequest",
1739 value: function cancelRequest(requestId) {
1740 var request = this.requests[requestId];
1741 if (!request) {
1742 return null;
1743 }
1744 if (request.options.deferred.jqXhr) {
1745 return request.options.deferred.jqXhr.abort('Request canceled');
1746 }
1747 if (request.options.deferred) {
1748 return request.options.deferred.reject('Request canceled');
1749 }
1750 }
1751 }, {
1752 key: "addRequest",
1753 value: function addRequest(action, options, immediately) {
1754 options = options || {};
1755 if (!options.unique_id) {
1756 options.unique_id = action;
1757 }
1758 options.deferred = jQuery.Deferred().done(options.success).fail(options.error).always(options.complete);
1759 var request = {
1760 action: action,
1761 options: options
1762 };
1763 if (immediately) {
1764 var requests = {};
1765 requests[options.unique_id] = request;
1766 options.deferred.jqXhr = this.sendBatch(requests);
1767 } else {
1768 this.requests[options.unique_id] = request;
1769 this.debounceSendBatch();
1770 }
1771 return options.deferred;
1772 }
1773 }, {
1774 key: "sendBatch",
1775 value: function sendBatch(requests) {
1776 var actions = {};
1777 if (!requests) {
1778 requests = this.requests;
1779
1780 // Empty for next batch.
1781 this.requests = {};
1782 }
1783 Object.entries(requests).forEach(function (_ref) {
1784 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
1785 id = _ref2[0],
1786 request = _ref2[1];
1787 return actions[id] = {
1788 action: request.action,
1789 data: request.options.data
1790 };
1791 });
1792 return this.send('ajax', {
1793 data: {
1794 actions: JSON.stringify(actions)
1795 },
1796 success: function success(data) {
1797 Object.entries(data.responses).forEach(function (_ref3) {
1798 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
1799 id = _ref4[0],
1800 response = _ref4[1];
1801 var options = requests[id].options;
1802 if (options) {
1803 if (response.success) {
1804 options.deferred.resolve(response.data);
1805 } else if (!response.success) {
1806 options.deferred.reject(response.data);
1807 }
1808 }
1809 });
1810 },
1811 error: function error(data) {
1812 return Object.values(requests).forEach(function (args) {
1813 if (args.options) {
1814 args.options.deferred.reject(data);
1815 }
1816 });
1817 }
1818 });
1819 }
1820 }, {
1821 key: "prepareSend",
1822 value: function prepareSend(action, options) {
1823 var _this4 = this;
1824 var settings = this.getSettings(),
1825 ajaxParams = elementorCommon.helpers.cloneObject(settings.ajaxParams);
1826 options = options || {};
1827 action = settings.actionPrefix + action;
1828 jQuery.extend(ajaxParams, options);
1829 var requestConstants = elementorCommon.helpers.cloneObject(this.requestConstants);
1830 requestConstants.action = action;
1831 var isFormData = ajaxParams.data instanceof FormData;
1832 Object.entries(requestConstants).forEach(function (_ref5) {
1833 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
1834 key = _ref6[0],
1835 value = _ref6[1];
1836 if (isFormData) {
1837 ajaxParams.data.append(key, value);
1838 } else {
1839 ajaxParams.data[key] = value;
1840 }
1841 });
1842 var successCallback = ajaxParams.success,
1843 errorCallback = ajaxParams.error;
1844 if (successCallback || errorCallback) {
1845 ajaxParams.success = function (response) {
1846 if (response.success && successCallback) {
1847 successCallback(response.data);
1848 }
1849 if (!response.success && errorCallback) {
1850 errorCallback(response.data);
1851 }
1852 };
1853 if (errorCallback) {
1854 ajaxParams.error = function (data) {
1855 return errorCallback(data);
1856 };
1857 } else {
1858 ajaxParams.error = function (xmlHttpRequest) {
1859 if (xmlHttpRequest.readyState || 'abort' !== xmlHttpRequest.statusText) {
1860 _this4.trigger('request:unhandledError', xmlHttpRequest);
1861 }
1862 };
1863 }
1864 }
1865 return ajaxParams;
1866 }
1867 }, {
1868 key: "send",
1869 value: function send(action, options) {
1870 return jQuery.ajax(this.prepareSend(action, options));
1871 }
1872 }, {
1873 key: "addRequestCache",
1874 value: function addRequestCache(request, data) {
1875 var cacheKey = this.getCacheKey(request);
1876 this.cache[cacheKey] = data;
1877 }
1878 }, {
1879 key: "invalidateCache",
1880 value: function invalidateCache(request) {
1881 var cacheKey = this.getCacheKey(request);
1882 delete this.cache[cacheKey];
1883 }
1884 }]);
1885 }(elementorModules.Module);
1886
1887 /***/ }),
1888
1889 /***/ "../core/common/modules/connect/assets/js/connect.js":
1890 /*!***********************************************************!*\
1891 !*** ../core/common/modules/connect/assets/js/connect.js ***!
1892 \***********************************************************/
1893 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1894
1895 "use strict";
1896 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
1897
1898
1899 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
1900 Object.defineProperty(exports, "__esModule", ({
1901 value: true
1902 }));
1903 exports["default"] = void 0;
1904 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
1905 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
1906 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
1907 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
1908 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
1909 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
1910 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)); }
1911 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1912 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; }
1913 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Vie) {
1914 function _default() {
1915 (0, _classCallCheck2.default)(this, _default);
1916 return _callSuper(this, _default, arguments);
1917 }
1918 (0, _inherits2.default)(_default, _elementorModules$Vie);
1919 return (0, _createClass2.default)(_default, [{
1920 key: "addPopupPlugin",
1921 value: function addPopupPlugin() {
1922 var counter = 0;
1923 jQuery.fn.elementorConnect = function (options) {
1924 var _this = this;
1925 // Open the Connect Dialog in a popup window.
1926 if (options !== null && options !== void 0 && options.popup) {
1927 jQuery(this).on('click', function (event) {
1928 var _options$popup, _options$popup2;
1929 event.preventDefault();
1930 var width = ((_options$popup = options.popup) === null || _options$popup === void 0 ? void 0 : _options$popup.width) || 600,
1931 height = ((_options$popup2 = options.popup) === null || _options$popup2 === void 0 ? void 0 : _options$popup2.height) || 700;
1932 window.open(jQuery(_this).attr('href') + '&mode=popup', 'elementorConnect', "toolbar=no, menubar=no, width=".concat(width, ", height=").concat(height, ", top=200, left=0"));
1933 });
1934 delete options.popup;
1935 }
1936 var settings = jQuery.extend({
1937 // These are the defaults.
1938 success: function success() {
1939 return location.reload();
1940 },
1941 error: function error() {
1942 elementor.notifications.showToast({
1943 message: __('Unable to connect', 'elementor')
1944 });
1945 },
1946 parseUrl: function parseUrl(url) {
1947 return url;
1948 } // Allow to change the url, e.g: replace placeholders like '%%template_type%%' with actual value.
1949 }, options);
1950 this.each(function () {
1951 counter++;
1952 var $this = jQuery(this),
1953 callbackId = 'cb' + counter;
1954 $this.attr({
1955 target: '_blank',
1956 rel: 'opener',
1957 href: settings.parseUrl($this.attr('href') + '&mode=popup&callback_id=' + callbackId)
1958 });
1959 elementorCommon.elements.$window.on('elementor/connect/success/' + callbackId, settings.success).on('elementor/connect/error/' + callbackId, settings.error);
1960 });
1961 return this;
1962 };
1963 }
1964 }, {
1965 key: "getDefaultSettings",
1966 value: function getDefaultSettings() {
1967 return {
1968 selectors: {
1969 connectButton: '#elementor-template-library-connect__button'
1970 }
1971 };
1972 }
1973 }, {
1974 key: "getDefaultElements",
1975 value: function getDefaultElements() {
1976 return {
1977 $connectButton: jQuery(this.getSettings('selectors.connectButton'))
1978 };
1979 }
1980 }, {
1981 key: "applyPopup",
1982 value: function applyPopup() {
1983 this.elements.$connectButton.elementorConnect();
1984 }
1985 }, {
1986 key: "onInit",
1987 value: function onInit() {
1988 _superPropGet(_default, "onInit", this, 3)([]);
1989 this.addPopupPlugin();
1990 this.applyPopup();
1991 }
1992 }]);
1993 }(elementorModules.ViewModule);
1994
1995 /***/ }),
1996
1997 /***/ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js":
1998 /*!**********************************************************************************!*\
1999 !*** ../core/common/modules/event-tracker/assets/js/data/commands-data/index.js ***!
2000 \**********************************************************************************/
2001 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2002
2003 "use strict";
2004
2005
2006 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2007 Object.defineProperty(exports, "__esModule", ({
2008 value: true
2009 }));
2010 exports.Index = void 0;
2011 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2012 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2013 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2014 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2015 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2016 var _commandData = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-data */ "../modules/web-cli/assets/js/modules/command-data.js"));
2017 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)); }
2018 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2019 var Index = exports.Index = /*#__PURE__*/function (_CommandData) {
2020 function Index() {
2021 (0, _classCallCheck2.default)(this, Index);
2022 return _callSuper(this, Index, arguments);
2023 }
2024 (0, _inherits2.default)(Index, _CommandData);
2025 return (0, _createClass2.default)(Index, null, [{
2026 key: "getEndpointFormat",
2027 value: function getEndpointFormat() {
2028 return 'send-event';
2029 }
2030 }]);
2031 }(_commandData.default);
2032
2033 /***/ }),
2034
2035 /***/ "../core/common/modules/event-tracker/assets/js/data/component.js":
2036 /*!************************************************************************!*\
2037 !*** ../core/common/modules/event-tracker/assets/js/data/component.js ***!
2038 \************************************************************************/
2039 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2040
2041 "use strict";
2042
2043
2044 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2045 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2046 Object.defineProperty(exports, "__esModule", ({
2047 value: true
2048 }));
2049 exports["default"] = void 0;
2050 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2051 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2052 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2053 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2054 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2055 var _componentBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
2056 var commandsData = _interopRequireWildcard(__webpack_require__(/*! ./commands-data/ */ "../core/common/modules/event-tracker/assets/js/data/commands-data/index.js"));
2057 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); }
2058 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)); }
2059 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2060 var Component = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
2061 function Component() {
2062 (0, _classCallCheck2.default)(this, Component);
2063 return _callSuper(this, Component, arguments);
2064 }
2065 (0, _inherits2.default)(Component, _ComponentBase);
2066 return (0, _createClass2.default)(Component, [{
2067 key: "getNamespace",
2068 value: function getNamespace() {
2069 return 'event-tracker';
2070 }
2071 }, {
2072 key: "defaultData",
2073 value: function defaultData() {
2074 return this.importCommands(commandsData);
2075 }
2076 }]);
2077 }(_componentBase.default);
2078
2079 /***/ }),
2080
2081 /***/ "../core/common/modules/event-tracker/assets/js/events.js":
2082 /*!****************************************************************!*\
2083 !*** ../core/common/modules/event-tracker/assets/js/events.js ***!
2084 \****************************************************************/
2085 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2086
2087 "use strict";
2088
2089
2090 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2091 Object.defineProperty(exports, "__esModule", ({
2092 value: true
2093 }));
2094 exports["default"] = void 0;
2095 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2096 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2097 var _time = _interopRequireDefault(__webpack_require__(/*! elementor-utils/time */ "../assets/dev/js/utils/time.js"));
2098 var Events = exports["default"] = /*#__PURE__*/function () {
2099 function Events() {
2100 (0, _classCallCheck2.default)(this, Events);
2101 }
2102 return (0, _createClass2.default)(Events, [{
2103 key: "dispatchEvent",
2104 value: function dispatchEvent(eventData) {
2105 if (!eventData) {
2106 return;
2107 }
2108 eventData.ts = (0, _time.default)();
2109
2110 // No need to wait for response, no need to block browser in any way.
2111 $e.data.create('event-tracker/index', {
2112 event_data: eventData
2113 });
2114 }
2115 }]);
2116 }();
2117
2118 /***/ }),
2119
2120 /***/ "../core/common/modules/events-manager/assets/js/events-config.js":
2121 /*!************************************************************************!*\
2122 !*** ../core/common/modules/events-manager/assets/js/events-config.js ***!
2123 \************************************************************************/
2124 /***/ ((__unused_webpack_module, exports) => {
2125
2126 "use strict";
2127
2128
2129 Object.defineProperty(exports, "__esModule", ({
2130 value: true
2131 }));
2132 exports["default"] = void 0;
2133 var eventsConfig = {
2134 appTypes: {
2135 editor: 'editor',
2136 wpAdmin: 'wpadmin'
2137 },
2138 targetTypes: {
2139 dropdownItem: 'dropdown_item',
2140 button: 'button',
2141 tab: 'tab',
2142 toggle: 'toggle',
2143 searchInput: 'search_input',
2144 searchResult: 'search_result',
2145 buttons: 'buttons',
2146 searchWidget: 'search_widget'
2147 },
2148 interactionResults: {
2149 actionSelected: 'action_selected',
2150 navigate: 'navigate',
2151 create: 'create',
2152 sessionEnd: 'session_end',
2153 tabChanged: 'tab_changed',
2154 assetInserted: 'asset_inserted',
2155 assetFavorite: 'asset_favorite',
2156 aiGenerate: 'ai_generate',
2157 resultsUpdated: 'results_updated',
2158 noResults: 'no_results',
2159 selected: 'selected',
2160 promotionViewed: 'promotion_viewed',
2161 upgradeNow: 'upgrade_now'
2162 },
2163 targetNames: {
2164 publishDropdown: {
2165 saveDraft: 'save_draft',
2166 saveAsTemplate: 'save_as_template',
2167 viewPage: 'view_page',
2168 copyAndShare: 'copy_and_share'
2169 },
2170 pageList: {
2171 addNewPage: 'add_new_page'
2172 }
2173 },
2174 triggers: {
2175 click: 'Click',
2176 rightClick: 'Right Click',
2177 doubleClick: 'Double Click',
2178 accordionClick: 'Accordion Click',
2179 toggleClick: 'Toggle Click',
2180 dropdownClick: 'Click Dropdown',
2181 editorLoaded: 'Editor Loaded',
2182 visible: 'Visible',
2183 pageLoaded: 'Page Loaded',
2184 typing: 'Typing',
2185 tabSelect: 'Tab Select',
2186 insert: 'Insert'
2187 },
2188 locations: {
2189 widgetPanel: 'Widget Panel',
2190 topBar: 'Top Bar',
2191 sidebar: 'Sidebar',
2192 elementorEditor: 'Elementor Editor',
2193 templatesLibrary: {
2194 library: 'Templates Library'
2195 },
2196 app: {
2197 import: 'Import Kit',
2198 export: 'Export Kit',
2199 kitLibrary: 'Kit Library',
2200 cloudKitLibrary: 'Cloud Kit Library'
2201 },
2202 variables: 'Variables Panel',
2203 variablesManager: 'Variables Manager',
2204 admin: 'WP admin',
2205 structurePanel: 'Structure Panel',
2206 canvas: 'Canvas',
2207 leftPanel: 'Left Panel',
2208 elementorLibrary: 'Elementor Library',
2209 components: {
2210 instanceEditingPanel: 'Instance Editing Panel'
2211 }
2212 },
2213 secondaryLocations: {
2214 layout: 'Layout Section',
2215 basic: 'Basic Section',
2216 'pro-elements': 'Pro Section',
2217 general: 'General Section',
2218 'theme-elements': 'Site Section',
2219 'theme-elements-single': 'Single Section',
2220 'woocommerce-elements': 'WooCommerce Section',
2221 wordpress: 'WordPress Section',
2222 categories: 'Widgets Tab',
2223 global: 'Globals Tab',
2224 'whats-new': 'What\'s New',
2225 'document-settings': 'Document Settings icon',
2226 'preview-page': 'Preview Page',
2227 'publish-button': 'Publish Button',
2228 'widget-panel': 'Widget Panel Icon',
2229 finder: 'Finder',
2230 help: 'Help',
2231 elementorLogoDropdown: 'top_bar_elementor_logo_dropdown',
2232 elementorLogo: 'Elementor Logo',
2233 eLogoMenu: 'E-logo Menu',
2234 notes: 'Notes',
2235 siteSettings: 'Site Settings',
2236 structure: 'Structure',
2237 documentNameDropdown: 'Document Name dropdown',
2238 responsiveControls: 'Responsive controls',
2239 launchpad: 'launchpad',
2240 checklistHeader: 'Checklist Header',
2241 checklistSteps: 'Checklist Steps',
2242 userPreferences: 'User Preferences',
2243 contextMenu: 'Context Menu',
2244 templateLibrary: {
2245 saveModal: 'Save to Modal',
2246 moveModal: 'Move to Modal',
2247 bulkMoveModal: 'Bulk Move to Modal',
2248 copyModal: 'Copy to Modal',
2249 bulkCopyModal: 'Bulk Copy to Modal',
2250 saveModalSelectFolder: 'Save to Modal - select folder',
2251 saveModalSelectConnect: 'Save to Modal - connect',
2252 saveModalSelectUpgrade: 'Save to Modal - upgrade',
2253 importModal: 'Import Modal',
2254 newFolderModal: 'New Folder Modal',
2255 deleteDialog: 'Delete Dialog',
2256 deleteFolderDialog: 'Delete Folder Dialog',
2257 renameDialog: 'Rename Dialog',
2258 createFolderDialog: 'Create Folder Dialog',
2259 applySettingsDialog: 'Apply Settings Dialog',
2260 cloudTab: 'Cloud Tab',
2261 siteTab: 'Site Tab',
2262 cloudTabFolder: 'Cloud Tab - Folder',
2263 cloudTabConnect: 'Cloud Tab - Connect',
2264 cloudTabUpgrade: 'Cloud Tab - Upgrade',
2265 morePopup: 'Context Menu',
2266 quotaBar: 'Quota Bar'
2267 },
2268 kitLibrary: {
2269 cloudKitLibrary: 'kits_cloud_library',
2270 cloudKitLibraryConnect: 'kits_cloud_library_connect',
2271 cloudKitLibraryUpgrade: 'kits_cloud_library_upgrade',
2272 kitExportCustomization: 'kit_export_customization',
2273 kitExport: 'kit_export',
2274 kitExportCustomizationEdit: 'kit_export_customization_edit',
2275 kitExportSummary: 'kit_export_summary',
2276 kitImportUploadBox: 'kit_import_upload_box',
2277 kitImportCustomization: 'kit_import_customization',
2278 kitImportSummary: 'kit_import_summary'
2279 },
2280 variablesPopover: 'Variables Popover',
2281 admin: {
2282 pluginToolsTab: 'plugin_tools_tab',
2283 pluginWebsiteTemplatesTab: 'plugin_website_templates_tab'
2284 },
2285 componentsTab: 'Components Tab',
2286 canvasElement: 'Canvas Element',
2287 publishDropdown: 'Publish Dropdown',
2288 pageListDropdown: 'Page List Dropdown',
2289 emptyBox: 'Empty Box',
2290 searchBar: 'Search Bar',
2291 finderResults: 'Finder Results',
2292 libraryTabs: 'Library Tabs',
2293 assetCard: 'Asset Card'
2294 },
2295 elements: {
2296 accordionSection: 'Accordion section',
2297 buttonIcon: 'Button Icon',
2298 mainCta: 'Main CTA',
2299 button: 'Button',
2300 link: 'Link',
2301 dropdown: 'Dropdown',
2302 toggle: 'Toggle',
2303 launchpadChecklist: 'Checklist popup'
2304 },
2305 names: {
2306 v1: {
2307 layout: 'v1_widgets_tab_layout_section',
2308 basic: 'v1_widgets_tab_basic_section',
2309 'pro-elements': 'v1_widgets_tab_pro_section',
2310 general: 'v1_widgets_tab_general_section',
2311 'theme-elements': 'v1_widgets_tab_site_section',
2312 'theme-elements-single': 'v1_widgets_tab_single_section',
2313 'woocommerce-elements': 'v1_widgets_tab_woocommerce_section',
2314 wordpress: 'v1_widgets_tab_wordpress_section',
2315 categories: 'v1_widgets_tab',
2316 global: 'v1_globals_tab'
2317 },
2318 topBar: {
2319 whatsNew: 'top_bar_whats_new',
2320 documentSettings: 'top_bar_document_settings_icon',
2321 previewPage: 'top_bar_preview_page',
2322 publishButton: 'top_bar_publish_button',
2323 widgetPanel: 'top_bar_widget_panel_icon',
2324 finder: 'top_bar_finder',
2325 help: 'top_bar_help',
2326 history: 'top_bar_elementor_logo_dropdown_history',
2327 userPreferences: 'top_bar_elementor_logo_dropdown_user_preferences',
2328 keyboardShortcuts: 'top_bar_elementor_logo_dropdown_keyboard_shortcuts',
2329 exitToWordpress: 'top_bar_elementor_logo_dropdown_exit_to_wordpress',
2330 themeBuilder: 'top_bar_elementor_logo_dropdown_theme_builder',
2331 notes: 'top_bar_notes',
2332 siteSettings: 'top_bar_site_setting',
2333 structure: 'top_bar_structure',
2334 documentNameDropdown: 'top_bar_document_name_dropdown',
2335 responsiveControls: 'top_bar_responsive_controls',
2336 launchpadOn: 'top_bar_checklist_icon_show',
2337 launchpadOff: 'top_bar_checklist_icon_hide',
2338 elementorLogoDropdown: 'open_e_menu',
2339 connectAccount: 'connect_account',
2340 accountConnected: 'account_connected'
2341 },
2342 // ChecklistSteps event names are generated dynamically, based on stepId and action type taken: title, action, done, undone, upgrade
2343 elementorEditor: {
2344 checklist: {
2345 checklistHeaderClose: 'checklist_header_close_icon',
2346 checklistFirstPopup: 'checklist popup triggered'
2347 },
2348 userPreferences: {
2349 checklistShow: 'checklist_userpreferences_toggle_show',
2350 checklistHide: 'checklist_userpreferences_toggle_hide'
2351 }
2352 },
2353 variables: {
2354 open: 'open_variables_popover',
2355 add: 'add_new_variable',
2356 connect: 'connect_variable',
2357 save: 'save_new_variable',
2358 openManager: 'open_variables_manager',
2359 saveChanges: 'save_variables_changes',
2360 delete: 'delete_variable',
2361 variableSyncToV3: 'variable_sync_to_v3'
2362 },
2363 components: {
2364 createClicked: 'component_create_clicked',
2365 createCancelled: 'component_creation_cancelled',
2366 created: 'component_created',
2367 instanceAdded: 'component_instance_added',
2368 edited: 'component_edited',
2369 propertiesPanelOpened: 'component_properties_panel_opened',
2370 propertiesGroupCreated: 'component_properties_group_created',
2371 propertyExposed: 'component_property_exposed',
2372 propertyRemoved: 'component_property_removed',
2373 detached: 'component_detached'
2374 },
2375 global_classes: {
2376 classApplied: 'class_applied',
2377 classRemoved: 'class_removed',
2378 classManagerFilterCleared: 'class_manager_filter_cleared',
2379 classDeleted: 'class_deleted',
2380 classPublishConflict: 'class_publish_conflict',
2381 classRenamed: 'class_renamed',
2382 classCreated: 'class_created',
2383 classManagerSearched: 'class_manager_searched',
2384 classManagerFiltersOpened: 'class_manager_filters_opened',
2385 classManagerOpened: 'class_manager_opened',
2386 classManagerReorder: 'class_manager_reorder',
2387 classManagerFilterUsed: 'class_manager_filter_used',
2388 classUsageLocate: 'class_usage_locate',
2389 classUsageHovered: 'class_usage_hovered',
2390 classStyled: 'class_styled',
2391 classStateClicked: 'class_state_clicked',
2392 classUsageClicked: 'class_usage_clicked',
2393 classDuplicate: 'class_duplicate',
2394 classSyncToV3PopupShown: 'class_sync_to_v3_popup_shown',
2395 classSyncToV3: 'class_sync_to_v3',
2396 classSyncToV3PopupClick: 'class_sync_to_v3_popup_click'
2397 },
2398 editorOne: {
2399 topBarPublishDropdown: 'top_bar_publish_dropdown',
2400 topBarPageList: 'top_bar_page_list',
2401 siteSettingsSession: 'site_settings_session',
2402 eLibraryNav: 'e_library_nav',
2403 eLibraryInsert: 'e_library_insert',
2404 eLibraryFavorite: 'e_library_favorite',
2405 eLibraryGenerateAi: 'e_library_generate_ai',
2406 finderSearchInput: 'finder_search_input',
2407 finderResultSelect: 'finder_result_select',
2408 canvasEmptyBoxAction: 'canvas_empty_box_action',
2409 widgetPanelSearch: 'widget_panel_search'
2410 },
2411 interactions: {
2412 created: 'interactions_created'
2413 },
2414 promotions: {
2415 viewPromotion: 'view_promotion',
2416 upgradePromotionClick: 'upgrade_promotion_click'
2417 }
2418 }
2419 };
2420 var _default = exports["default"] = eventsConfig;
2421
2422 /***/ }),
2423
2424 /***/ "../core/common/modules/events-manager/assets/js/module.js":
2425 /*!*****************************************************************!*\
2426 !*** ../core/common/modules/events-manager/assets/js/module.js ***!
2427 \*****************************************************************/
2428 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2429
2430 "use strict";
2431
2432
2433 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2434 Object.defineProperty(exports, "__esModule", ({
2435 value: true
2436 }));
2437 exports["default"] = void 0;
2438 var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "../node_modules/@babel/runtime/regenerator/index.js"));
2439 var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
2440 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2441 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2442 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2443 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2444 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2445 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2446 var _eventsConfig = _interopRequireDefault(__webpack_require__(/*! ./events-config */ "../core/common/modules/events-manager/assets/js/events-config.js"));
2447 var _mixpanelBrowser = _interopRequireDefault(__webpack_require__(/*! mixpanel-browser */ "../node_modules/mixpanel-browser/dist/mixpanel.module.js"));
2448 var _tiers = __webpack_require__(/*! elementor-utils/tiers */ "../assets/dev/js/utils/tiers.js");
2449 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; }
2450 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; }
2451 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)); }
2452 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2453 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2454 function _default() {
2455 var _this;
2456 (0, _classCallCheck2.default)(this, _default);
2457 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2458 args[_key] = arguments[_key];
2459 }
2460 _this = _callSuper(this, _default, [].concat(args));
2461 (0, _defineProperty2.default)(_this, "trackingEnabled", false);
2462 (0, _defineProperty2.default)(_this, "availableExperiments", []);
2463 return _this;
2464 }
2465 (0, _inherits2.default)(_default, _elementorModules$Mod);
2466 return (0, _createClass2.default)(_default, [{
2467 key: "onInit",
2468 value: function onInit() {
2469 var _this2 = this;
2470 this.config = _eventsConfig.default;
2471 if (!this.canSendEvents()) {
2472 return;
2473 }
2474 this.initializeMixpanel(function () {
2475 return _this2.enableTracking();
2476 });
2477 }
2478 }, {
2479 key: "initializeMixpanel",
2480 value: function initializeMixpanel(onLoaded) {
2481 var _elementorCommon$conf;
2482 _mixpanelBrowser.default.init((_elementorCommon$conf = elementorCommon.config.editor_events) === null || _elementorCommon$conf === void 0 ? void 0 : _elementorCommon$conf.token, {
2483 persistence: 'localStorage',
2484 autocapture: false,
2485 flags: true,
2486 api_hosts: {
2487 flags: 'https://api-eu.mixpanel.com'
2488 },
2489 loaded: onLoaded
2490 });
2491 }
2492 }, {
2493 key: "enableTracking",
2494 value: function enableTracking() {
2495 var _elementorCommon$conf2;
2496 if (!this.isMixpanelReady()) {
2497 return;
2498 }
2499 var userId = (_elementorCommon$conf2 = elementorCommon.config.editor_events) === null || _elementorCommon$conf2 === void 0 ? void 0 : _elementorCommon$conf2.user_id;
2500 if (userId) {
2501 var _elementorCommon$conf3;
2502 _mixpanelBrowser.default.identify(userId);
2503 _mixpanelBrowser.default.register({
2504 appType: 'Editor'
2505 });
2506 _mixpanelBrowser.default.people.set_once({
2507 $user_id: userId,
2508 $last_login: new Date().toISOString(),
2509 $plan_type: ((_elementorCommon$conf3 = elementorCommon.config.library_connect) === null || _elementorCommon$conf3 === void 0 ? void 0 : _elementorCommon$conf3.plan_type) || _tiers.TIERS.free
2510 });
2511 }
2512 this.trackingEnabled = true;
2513 this.availableExperiments = Object.keys(elementorCommon.config.experimentalFeatures || {});
2514 }
2515 }, {
2516 key: "dispatchEvent",
2517 value: function dispatchEvent(name, data) {
2518 var _elementorCommon$conf4, _elementorCommon$conf5, _elementorCommon$conf6, _elementorCommon$conf7, _elementorCommon$conf8, _elementorCommon$conf9, _elementorCommon$conf0, _elementorCommon$conf1, _elementorCommon$conf10;
2519 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2520 if (!this.canSendEvents()) {
2521 return;
2522 }
2523 if (!this.trackingEnabled) {
2524 this.enableTracking();
2525 }
2526 var eventData = _objectSpread({
2527 user_id: ((_elementorCommon$conf4 = elementorCommon.config.editor_events) === null || _elementorCommon$conf4 === void 0 ? void 0 : _elementorCommon$conf4.user_id) || null,
2528 user_roles: ((_elementorCommon$conf5 = elementorCommon.config.library_connect) === null || _elementorCommon$conf5 === void 0 ? void 0 : _elementorCommon$conf5.user_roles) || [],
2529 subscription_id: ((_elementorCommon$conf6 = elementorCommon.config.editor_events) === null || _elementorCommon$conf6 === void 0 ? void 0 : _elementorCommon$conf6.subscription_id) || null,
2530 user_tier: ((_elementorCommon$conf7 = elementorCommon.config.library_connect) === null || _elementorCommon$conf7 === void 0 ? void 0 : _elementorCommon$conf7.current_access_tier) || null,
2531 url: (_elementorCommon$conf8 = elementorCommon.config.editor_events) === null || _elementorCommon$conf8 === void 0 ? void 0 : _elementorCommon$conf8.site_url,
2532 wp_version: (_elementorCommon$conf9 = elementorCommon.config.editor_events) === null || _elementorCommon$conf9 === void 0 ? void 0 : _elementorCommon$conf9.wp_version,
2533 client_id: (_elementorCommon$conf0 = elementorCommon.config.editor_events) === null || _elementorCommon$conf0 === void 0 ? void 0 : _elementorCommon$conf0.site_key,
2534 app_version: (_elementorCommon$conf1 = elementorCommon.config.editor_events) === null || _elementorCommon$conf1 === void 0 ? void 0 : _elementorCommon$conf1.elementor_version,
2535 site_language: (_elementorCommon$conf10 = elementorCommon.config.editor_events) === null || _elementorCommon$conf10 === void 0 ? void 0 : _elementorCommon$conf10.site_language,
2536 experiments: this.availableExperiments
2537 }, data);
2538 _mixpanelBrowser.default.track(name, eventData, options);
2539 }
2540 }, {
2541 key: "featureFlagIsActive",
2542 value: function () {
2543 var _featureFlagIsActive = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(flagName) {
2544 var _mixpanel$flags;
2545 var isEnabled;
2546 return _regenerator.default.wrap(function (_context) {
2547 while (1) switch (_context.prev = _context.next) {
2548 case 0:
2549 if (!('function' !== typeof (_mixpanelBrowser.default === null || _mixpanelBrowser.default === void 0 || (_mixpanel$flags = _mixpanelBrowser.default.flags) === null || _mixpanel$flags === void 0 ? void 0 : _mixpanel$flags.is_enabled))) {
2550 _context.next = 1;
2551 break;
2552 }
2553 return _context.abrupt("return", false);
2554 case 1:
2555 _context.next = 2;
2556 return _mixpanelBrowser.default.flags.is_enabled(flagName, false);
2557 case 2:
2558 isEnabled = _context.sent;
2559 return _context.abrupt("return", true === isEnabled);
2560 case 3:
2561 case "end":
2562 return _context.stop();
2563 }
2564 }, _callee);
2565 }));
2566 function featureFlagIsActive(_x) {
2567 return _featureFlagIsActive.apply(this, arguments);
2568 }
2569 return featureFlagIsActive;
2570 }()
2571 }, {
2572 key: "getExperimentVariant",
2573 value: function () {
2574 var _getExperimentVariant = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(experimentName) {
2575 var defaultValue,
2576 _elementorCommon$conf11,
2577 _elementorCommon$conf12,
2578 isAbTestingEnabled,
2579 variant,
2580 _args2 = arguments,
2581 _t;
2582 return _regenerator.default.wrap(function (_context2) {
2583 while (1) switch (_context2.prev = _context2.next) {
2584 case 0:
2585 defaultValue = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 'control';
2586 _context2.prev = 1;
2587 if (this.canSendEvents()) {
2588 _context2.next = 2;
2589 break;
2590 }
2591 return _context2.abrupt("return", defaultValue);
2592 case 2:
2593 isAbTestingEnabled = (_elementorCommon$conf11 = (_elementorCommon$conf12 = elementorCommon.config.editor_events) === null || _elementorCommon$conf12 === void 0 ? void 0 : _elementorCommon$conf12.flags_enabled) !== null && _elementorCommon$conf11 !== void 0 ? _elementorCommon$conf11 : false;
2594 if (isAbTestingEnabled) {
2595 _context2.next = 3;
2596 break;
2597 }
2598 return _context2.abrupt("return", defaultValue);
2599 case 3:
2600 if (_mixpanelBrowser.default) {
2601 _context2.next = 4;
2602 break;
2603 }
2604 return _context2.abrupt("return", defaultValue);
2605 case 4:
2606 if (!this.trackingEnabled) {
2607 this.enableTracking();
2608 }
2609 if (_mixpanelBrowser.default.flags) {
2610 _context2.next = 5;
2611 break;
2612 }
2613 return _context2.abrupt("return", defaultValue);
2614 case 5:
2615 if (!('function' !== typeof _mixpanelBrowser.default.flags.get_variant_value)) {
2616 _context2.next = 6;
2617 break;
2618 }
2619 return _context2.abrupt("return", defaultValue);
2620 case 6:
2621 _context2.next = 7;
2622 return _mixpanelBrowser.default.flags.get_variant_value(experimentName, defaultValue);
2623 case 7:
2624 variant = _context2.sent;
2625 if (!(undefined === variant || null === variant)) {
2626 _context2.next = 8;
2627 break;
2628 }
2629 return _context2.abrupt("return", defaultValue);
2630 case 8:
2631 return _context2.abrupt("return", variant);
2632 case 9:
2633 _context2.prev = 9;
2634 _t = _context2["catch"](1);
2635 return _context2.abrupt("return", defaultValue);
2636 case 10:
2637 case "end":
2638 return _context2.stop();
2639 }
2640 }, _callee2, this, [[1, 9]]);
2641 }));
2642 function getExperimentVariant(_x2) {
2643 return _getExperimentVariant.apply(this, arguments);
2644 }
2645 return getExperimentVariant;
2646 }()
2647 }, {
2648 key: "startExperiment",
2649 value: function startExperiment(experimentName, experimentVariant) {
2650 if (!this.trackingEnabled) {
2651 return;
2652 }
2653 _mixpanelBrowser.default.track('$experiment_started', {
2654 'Experiment name': experimentName,
2655 'Variant name': experimentVariant
2656 });
2657 }
2658 }, {
2659 key: "isMixpanelReady",
2660 value: function isMixpanelReady() {
2661 if ('undefined' === typeof _mixpanelBrowser.default || !_mixpanelBrowser.default) {
2662 return false;
2663 }
2664 try {
2665 var distinctId = _mixpanelBrowser.default.get_distinct_id();
2666 return distinctId !== undefined && distinctId !== null;
2667 } catch (error) {
2668 return false;
2669 }
2670 }
2671 }, {
2672 key: "canSendEvents",
2673 value: function canSendEvents() {
2674 var _elementorCommon;
2675 return !!((_elementorCommon = elementorCommon) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.config) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.editor_events) !== null && _elementorCommon !== void 0 && _elementorCommon.can_send_events);
2676 }
2677 }, {
2678 key: "getMixpanelInstance",
2679 value: function getMixpanelInstance() {
2680 return this.isMixpanelReady() ? _mixpanelBrowser.default : undefined;
2681 }
2682 }]);
2683 }(elementorModules.Module);
2684
2685 /***/ }),
2686
2687 /***/ "../core/common/modules/finder/assets/js/commands/index.js":
2688 /*!*****************************************************************!*\
2689 !*** ../core/common/modules/finder/assets/js/commands/index.js ***!
2690 \*****************************************************************/
2691 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2692
2693 "use strict";
2694
2695
2696 Object.defineProperty(exports, "__esModule", ({
2697 value: true
2698 }));
2699 Object.defineProperty(exports, "NavigateDown", ({
2700 enumerable: true,
2701 get: function get() {
2702 return _navigateDown.NavigateDown;
2703 }
2704 }));
2705 Object.defineProperty(exports, "NavigateSelect", ({
2706 enumerable: true,
2707 get: function get() {
2708 return _navigateSelect.NavigateSelect;
2709 }
2710 }));
2711 Object.defineProperty(exports, "NavigateUp", ({
2712 enumerable: true,
2713 get: function get() {
2714 return _navigateUp.NavigateUp;
2715 }
2716 }));
2717 var _navigateDown = __webpack_require__(/*! ./navigate-down */ "../core/common/modules/finder/assets/js/commands/navigate-down.js");
2718 var _navigateSelect = __webpack_require__(/*! ./navigate-select */ "../core/common/modules/finder/assets/js/commands/navigate-select.js");
2719 var _navigateUp = __webpack_require__(/*! ./navigate-up */ "../core/common/modules/finder/assets/js/commands/navigate-up.js");
2720
2721 /***/ }),
2722
2723 /***/ "../core/common/modules/finder/assets/js/commands/navigate-down.js":
2724 /*!*************************************************************************!*\
2725 !*** ../core/common/modules/finder/assets/js/commands/navigate-down.js ***!
2726 \*************************************************************************/
2727 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2728
2729 "use strict";
2730
2731
2732 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2733 Object.defineProperty(exports, "__esModule", ({
2734 value: true
2735 }));
2736 exports["default"] = exports.NavigateDown = void 0;
2737 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2738 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2739 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2740 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2741 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2742 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2743 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)); }
2744 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2745 var NavigateDown = exports.NavigateDown = /*#__PURE__*/function (_CommandBase) {
2746 function NavigateDown() {
2747 (0, _classCallCheck2.default)(this, NavigateDown);
2748 return _callSuper(this, NavigateDown, arguments);
2749 }
2750 (0, _inherits2.default)(NavigateDown, _CommandBase);
2751 return (0, _createClass2.default)(NavigateDown, [{
2752 key: "apply",
2753 value: function apply() {
2754 this.component.getItemsView().activateNextItem();
2755 }
2756 }]);
2757 }(_commandBase.default);
2758 var _default = exports["default"] = NavigateDown;
2759
2760 /***/ }),
2761
2762 /***/ "../core/common/modules/finder/assets/js/commands/navigate-select.js":
2763 /*!***************************************************************************!*\
2764 !*** ../core/common/modules/finder/assets/js/commands/navigate-select.js ***!
2765 \***************************************************************************/
2766 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2767
2768 "use strict";
2769
2770
2771 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2772 Object.defineProperty(exports, "__esModule", ({
2773 value: true
2774 }));
2775 exports["default"] = exports.NavigateSelect = void 0;
2776 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2777 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2778 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2779 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2780 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2781 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2782 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)); }
2783 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2784 var NavigateSelect = exports.NavigateSelect = /*#__PURE__*/function (_CommandBase) {
2785 function NavigateSelect() {
2786 (0, _classCallCheck2.default)(this, NavigateSelect);
2787 return _callSuper(this, NavigateSelect, arguments);
2788 }
2789 (0, _inherits2.default)(NavigateSelect, _CommandBase);
2790 return (0, _createClass2.default)(NavigateSelect, [{
2791 key: "apply",
2792 value: function apply(args) {
2793 this.component.getItemsView().goToActiveItem(args);
2794 }
2795 }]);
2796 }(_commandBase.default);
2797 var _default = exports["default"] = NavigateSelect;
2798
2799 /***/ }),
2800
2801 /***/ "../core/common/modules/finder/assets/js/commands/navigate-up.js":
2802 /*!***********************************************************************!*\
2803 !*** ../core/common/modules/finder/assets/js/commands/navigate-up.js ***!
2804 \***********************************************************************/
2805 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2806
2807 "use strict";
2808
2809
2810 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2811 Object.defineProperty(exports, "__esModule", ({
2812 value: true
2813 }));
2814 exports["default"] = exports.NavigateUp = void 0;
2815 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2816 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2817 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2818 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2819 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2820 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
2821 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)); }
2822 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2823 var NavigateUp = exports.NavigateUp = /*#__PURE__*/function (_CommandBase) {
2824 function NavigateUp() {
2825 (0, _classCallCheck2.default)(this, NavigateUp);
2826 return _callSuper(this, NavigateUp, arguments);
2827 }
2828 (0, _inherits2.default)(NavigateUp, _CommandBase);
2829 return (0, _createClass2.default)(NavigateUp, [{
2830 key: "apply",
2831 value: function apply() {
2832 this.component.getItemsView().activateNextItem(true);
2833 }
2834 }]);
2835 }(_commandBase.default);
2836 var _default = exports["default"] = NavigateUp;
2837
2838 /***/ }),
2839
2840 /***/ "../core/common/modules/finder/assets/js/component.js":
2841 /*!************************************************************!*\
2842 !*** ../core/common/modules/finder/assets/js/component.js ***!
2843 \************************************************************/
2844 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2845
2846 "use strict";
2847
2848
2849 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2850 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
2851 Object.defineProperty(exports, "__esModule", ({
2852 value: true
2853 }));
2854 exports["default"] = void 0;
2855 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
2856 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2857 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2858 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2859 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2860 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
2861 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2862 var _componentModalBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/component-modal-base */ "../modules/web-cli/assets/js/modules/component-modal-base.js"));
2863 var _layout = _interopRequireDefault(__webpack_require__(/*! ./modal/views/layout */ "../core/common/modules/finder/assets/js/modal/views/layout.js"));
2864 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../core/common/modules/finder/assets/js/commands/index.js"));
2865 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); }
2866 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; }
2867 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; }
2868 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)); }
2869 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2870 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; }
2871 var Component = exports["default"] = /*#__PURE__*/function (_ComponentModalBase) {
2872 function Component() {
2873 (0, _classCallCheck2.default)(this, Component);
2874 return _callSuper(this, Component, arguments);
2875 }
2876 (0, _inherits2.default)(Component, _ComponentModalBase);
2877 return (0, _createClass2.default)(Component, [{
2878 key: "getNamespace",
2879 value: function getNamespace() {
2880 return 'finder';
2881 }
2882 }, {
2883 key: "defaultShortcuts",
2884 value: function defaultShortcuts() {
2885 var _this = this;
2886 return {
2887 '': {
2888 keys: 'ctrl+e'
2889 },
2890 'navigate-down': {
2891 keys: 'down',
2892 scopes: [this.getNamespace()],
2893 dependency: function dependency() {
2894 return _this.getItemsView();
2895 }
2896 },
2897 'navigate-up': {
2898 keys: 'up',
2899 scopes: [this.getNamespace()],
2900 dependency: function dependency() {
2901 return _this.getItemsView();
2902 }
2903 },
2904 'navigate-select': {
2905 keys: 'enter',
2906 scopes: [this.getNamespace()],
2907 dependency: function dependency() {
2908 return _this.getItemsView().$activeItem;
2909 }
2910 }
2911 };
2912 }
2913 }, {
2914 key: "defaultCommands",
2915 value: function defaultCommands() {
2916 var modalCommands = _superPropGet(Component, "defaultCommands", this, 3)([]);
2917 return _objectSpread(_objectSpread({
2918 'navigate/down': function navigate_down() {
2919 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/down' )", '3.0.0', "$e.run( 'finder/navigate-down' )");
2920 $e.run('finder/navigate-down');
2921 },
2922 'navigate/up': function navigate_up() {
2923 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/up' )", '3.0.0', "$e.run( 'finder/navigate-up' )");
2924 $e.run('finder/navigate-up');
2925 },
2926 'navigate/select': function navigate_select(event) {
2927 elementorDevTools.deprecation.deprecated("$e.run( 'finder/navigate/select', event )", '3.0.0', "$e.run( 'finder/navigate-select', event )");
2928
2929 // TODO: Fix $e.shortcuts use args. ( args.event ).
2930 $e.run('finder/navigate-select', event);
2931 }
2932 }, modalCommands), this.importCommands(commands));
2933 }
2934 }, {
2935 key: "getModalLayout",
2936 value: function getModalLayout() {
2937 return _layout.default;
2938 }
2939 }, {
2940 key: "getItemsView",
2941 value: function getItemsView() {
2942 return this.layout.modalContent.currentView.content.currentView;
2943 }
2944 }]);
2945 }(_componentModalBase.default);
2946
2947 /***/ }),
2948
2949 /***/ "../core/common/modules/finder/assets/js/finder.js":
2950 /*!*********************************************************!*\
2951 !*** ../core/common/modules/finder/assets/js/finder.js ***!
2952 \*********************************************************/
2953 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2954
2955 "use strict";
2956
2957
2958 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
2959 Object.defineProperty(exports, "__esModule", ({
2960 value: true
2961 }));
2962 exports["default"] = void 0;
2963 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
2964 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
2965 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
2966 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
2967 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
2968 var _component = _interopRequireDefault(__webpack_require__(/*! ./component */ "../core/common/modules/finder/assets/js/component.js"));
2969 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)); }
2970 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
2971 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$Mod) {
2972 function _default() {
2973 (0, _classCallCheck2.default)(this, _default);
2974 return _callSuper(this, _default, arguments);
2975 }
2976 (0, _inherits2.default)(_default, _elementorModules$Mod);
2977 return (0, _createClass2.default)(_default, [{
2978 key: "onInit",
2979 value: function onInit() {
2980 // TODO: Temp fix, do not load finder in theme-builder.
2981 // Better to pass into '$e' constructor the app owner. ( admin, editor, preview, iframe ).
2982 if (window.top !== window) {
2983 return;
2984 }
2985 this.channel = Backbone.Radio.channel('ELEMENTOR:finder');
2986 $e.components.register(new _component.default({
2987 manager: this
2988 }));
2989 }
2990 }]);
2991 }(elementorModules.Module);
2992
2993 /***/ }),
2994
2995 /***/ "../core/common/modules/finder/assets/js/modal/model/item.js":
2996 /*!*******************************************************************!*\
2997 !*** ../core/common/modules/finder/assets/js/modal/model/item.js ***!
2998 \*******************************************************************/
2999 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3000
3001 "use strict";
3002
3003
3004 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3005 Object.defineProperty(exports, "__esModule", ({
3006 value: true
3007 }));
3008 exports["default"] = void 0;
3009 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3010 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3011 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3012 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3013 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3014 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)); }
3015 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3016 var _default = exports["default"] = /*#__PURE__*/function (_Backbone$Model) {
3017 function _default() {
3018 (0, _classCallCheck2.default)(this, _default);
3019 return _callSuper(this, _default, arguments);
3020 }
3021 (0, _inherits2.default)(_default, _Backbone$Model);
3022 return (0, _createClass2.default)(_default, [{
3023 key: "defaults",
3024 value: function defaults() {
3025 return {
3026 description: '',
3027 icon: 'settings',
3028 url: '',
3029 keywords: [],
3030 actions: [],
3031 lock: null
3032 };
3033 }
3034 }]);
3035 }(Backbone.Model);
3036
3037 /***/ }),
3038
3039 /***/ "../core/common/modules/finder/assets/js/modal/views/categories.js":
3040 /*!*************************************************************************!*\
3041 !*** ../core/common/modules/finder/assets/js/modal/views/categories.js ***!
3042 \*************************************************************************/
3043 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3044
3045 "use strict";
3046
3047
3048 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3049 Object.defineProperty(exports, "__esModule", ({
3050 value: true
3051 }));
3052 exports["default"] = void 0;
3053 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3054 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3055 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3056 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3057 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3058 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3059 var _dynamicCategory = _interopRequireDefault(__webpack_require__(/*! ./dynamic-category */ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js"));
3060 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)); }
3061 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3062 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3063 function _default() {
3064 (0, _classCallCheck2.default)(this, _default);
3065 return _callSuper(this, _default, arguments);
3066 }
3067 (0, _inherits2.default)(_default, _Marionette$Composite);
3068 return (0, _createClass2.default)(_default, [{
3069 key: "id",
3070 value: function id() {
3071 return 'elementor-finder__results-container';
3072 }
3073 }, {
3074 key: "ui",
3075 value: function ui() {
3076 this.selectors = {
3077 noResults: '#elementor-finder__no-results',
3078 categoryItem: '.elementor-finder__results__item'
3079 };
3080 return this.selectors;
3081 }
3082 }, {
3083 key: "events",
3084 value: function events() {
3085 return {
3086 'mouseenter @ui.categoryItem': 'onCategoryItemMouseEnter'
3087 };
3088 }
3089 }, {
3090 key: "getTemplate",
3091 value: function getTemplate() {
3092 return '#tmpl-elementor-finder-results-container';
3093 }
3094 }, {
3095 key: "getChildView",
3096 value: function getChildView(childModel) {
3097 return childModel.get('dynamic') ? _dynamicCategory.default : _category.default;
3098 }
3099 }, {
3100 key: "initialize",
3101 value: function initialize() {
3102 this.$activeItem = null;
3103 this.childViewContainer = '#elementor-finder__results';
3104 this.collection = new Backbone.Collection(Object.values(elementorCommon.finder.getSettings('data')));
3105 }
3106 }, {
3107 key: "activateItem",
3108 value: function activateItem($item) {
3109 if (this.$activeItem) {
3110 this.$activeItem.removeClass('elementor-active');
3111 }
3112 $item.addClass('elementor-active');
3113 this.$activeItem = $item;
3114 }
3115 }, {
3116 key: "activateNextItem",
3117 value: function activateNextItem(reverse) {
3118 var $allItems = jQuery(this.selectors.categoryItem);
3119 var nextItemIndex = 0;
3120 if (this.$activeItem) {
3121 nextItemIndex = $allItems.index(this.$activeItem) + (reverse ? -1 : 1);
3122 if (nextItemIndex >= $allItems.length) {
3123 nextItemIndex = 0;
3124 } else if (nextItemIndex < 0) {
3125 nextItemIndex = $allItems.length - 1;
3126 }
3127 }
3128 var $nextItem = $allItems.eq(nextItemIndex);
3129 this.activateItem($nextItem);
3130 $nextItem[0].scrollIntoView({
3131 block: 'nearest'
3132 });
3133 }
3134 }, {
3135 key: "goToActiveItem",
3136 value: function goToActiveItem(event) {
3137 var $a = this.$activeItem.children('a'),
3138 isControlClicked = $e.shortcuts.isControlEvent(event);
3139 if (isControlClicked) {
3140 $a.attr('target', '_blank');
3141 }
3142 $a[0].click();
3143 if (isControlClicked) {
3144 $a.removeAttr('target');
3145 }
3146 }
3147 }, {
3148 key: "onCategoryItemMouseEnter",
3149 value: function onCategoryItemMouseEnter(event) {
3150 this.activateItem(jQuery(event.currentTarget));
3151 }
3152 }, {
3153 key: "onChildviewToggleVisibility",
3154 value: function onChildviewToggleVisibility() {
3155 var allCategoriesAreEmpty = this.children.every(function (child) {
3156 return !child.isVisible;
3157 });
3158 this.ui.noResults.toggle(allCategoriesAreEmpty);
3159 }
3160 }]);
3161 }(Marionette.CompositeView);
3162
3163 /***/ }),
3164
3165 /***/ "../core/common/modules/finder/assets/js/modal/views/category.js":
3166 /*!***********************************************************************!*\
3167 !*** ../core/common/modules/finder/assets/js/modal/views/category.js ***!
3168 \***********************************************************************/
3169 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3170
3171 "use strict";
3172
3173
3174 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3175 Object.defineProperty(exports, "__esModule", ({
3176 value: true
3177 }));
3178 exports["default"] = void 0;
3179 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3180 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3181 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3182 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3183 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3184 var _item = _interopRequireDefault(__webpack_require__(/*! ./item */ "../core/common/modules/finder/assets/js/modal/views/item.js"));
3185 var _item2 = _interopRequireDefault(__webpack_require__(/*! ../model/item */ "../core/common/modules/finder/assets/js/modal/model/item.js"));
3186 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)); }
3187 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3188 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$Composite) {
3189 function _default() {
3190 (0, _classCallCheck2.default)(this, _default);
3191 return _callSuper(this, _default, arguments);
3192 }
3193 (0, _inherits2.default)(_default, _Marionette$Composite);
3194 return (0, _createClass2.default)(_default, [{
3195 key: "className",
3196 value: function className() {
3197 return 'elementor-finder__results__category';
3198 }
3199 }, {
3200 key: "getTemplate",
3201 value: function getTemplate() {
3202 return '#tmpl-elementor-finder__results__category';
3203 }
3204 }, {
3205 key: "getChildView",
3206 value: function getChildView() {
3207 return _item.default;
3208 }
3209 }, {
3210 key: "initialize",
3211 value: function initialize() {
3212 this.childViewContainer = '.elementor-finder__results__category__items';
3213 this.isVisible = true;
3214 var items = this.model.get('items');
3215 if (items) {
3216 items = Object.values(items);
3217 }
3218 this.collection = new Backbone.Collection(items, {
3219 model: _item2.default
3220 });
3221 }
3222 }, {
3223 key: "filter",
3224 value: function filter(childModel) {
3225 var textFilter = this.getTextFilter();
3226 if (childModel.get('title').toLowerCase().indexOf(textFilter) >= 0) {
3227 return true;
3228 }
3229 return childModel.get('keywords').some(function (keyword) {
3230 return keyword.indexOf(textFilter) >= 0;
3231 });
3232 }
3233 }, {
3234 key: "getTextFilter",
3235 value: function getTextFilter() {
3236 return elementorCommon.finder.channel.request('filter:text').trim().toLowerCase();
3237 }
3238 }, {
3239 key: "toggleElement",
3240 value: function toggleElement() {
3241 var isCurrentlyVisible = !!this.children.length;
3242 if (isCurrentlyVisible !== this.isVisible) {
3243 this.isVisible = isCurrentlyVisible;
3244 this.$el.toggle(isCurrentlyVisible);
3245 this.triggerMethod('toggle:visibility');
3246 }
3247 }
3248 }, {
3249 key: "onRender",
3250 value: function onRender() {
3251 this.listenTo(elementorCommon.finder.channel, 'filter:change', this.onFilterChange.bind(this));
3252 }
3253 }, {
3254 key: "onFilterChange",
3255 value: function onFilterChange() {
3256 this._renderChildren();
3257 }
3258 }, {
3259 key: "onRenderCollection",
3260 value: function onRenderCollection() {
3261 this.toggleElement();
3262 }
3263 }]);
3264 }(Marionette.CompositeView);
3265
3266 /***/ }),
3267
3268 /***/ "../core/common/modules/finder/assets/js/modal/views/content.js":
3269 /*!**********************************************************************!*\
3270 !*** ../core/common/modules/finder/assets/js/modal/views/content.js ***!
3271 \**********************************************************************/
3272 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3273
3274 "use strict";
3275
3276
3277 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3278 Object.defineProperty(exports, "__esModule", ({
3279 value: true
3280 }));
3281 exports["default"] = void 0;
3282 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3283 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3284 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3285 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3286 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3287 var _categories = _interopRequireDefault(__webpack_require__(/*! ./categories */ "../core/common/modules/finder/assets/js/modal/views/categories.js"));
3288 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3289 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)); }
3290 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3291 var FINDER_SEARCH_DEBOUNCE_MS = 300;
3292 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$LayoutVie) {
3293 function _default() {
3294 (0, _classCallCheck2.default)(this, _default);
3295 return _callSuper(this, _default, arguments);
3296 }
3297 (0, _inherits2.default)(_default, _Marionette$LayoutVie);
3298 return (0, _createClass2.default)(_default, [{
3299 key: "id",
3300 value: function id() {
3301 return 'elementor-finder';
3302 }
3303 }, {
3304 key: "getTemplate",
3305 value: function getTemplate() {
3306 return '#tmpl-elementor-finder';
3307 }
3308 }, {
3309 key: "ui",
3310 value: function ui() {
3311 return {
3312 searchInput: '#elementor-finder__search__input'
3313 };
3314 }
3315 }, {
3316 key: "events",
3317 value: function events() {
3318 return {
3319 'input @ui.searchInput': 'onSearchInputInput'
3320 };
3321 }
3322 }, {
3323 key: "regions",
3324 value: function regions() {
3325 return {
3326 content: '#elementor-finder__content'
3327 };
3328 }
3329 }, {
3330 key: "initialize",
3331 value: function initialize() {
3332 this.debouncedTrackSearch = (0, _editorOneEvents.createDebouncedFinderSearch)(FINDER_SEARCH_DEBOUNCE_MS);
3333 }
3334 }, {
3335 key: "showCategoriesView",
3336 value: function showCategoriesView() {
3337 this.content.show(new _categories.default());
3338 }
3339 }, {
3340 key: "getResultsCount",
3341 value: function getResultsCount() {
3342 if (!this.content.currentView) {
3343 return 0;
3344 }
3345 var $visibleItems = this.content.currentView.$el.find('.elementor-finder__results__item:visible');
3346 return $visibleItems.length;
3347 }
3348 }, {
3349 key: "onSearchInputInput",
3350 value: function onSearchInputInput() {
3351 var _this = this;
3352 var value = this.ui.searchInput.val();
3353 if (value) {
3354 elementorCommon.finder.channel.reply('filter:text', value).trigger('filter:change');
3355 if (!(this.content.currentView instanceof _categories.default)) {
3356 this.showCategoriesView();
3357 }
3358 setTimeout(function () {
3359 var resultsCount = _this.getResultsCount();
3360 _this.debouncedTrackSearch(resultsCount, value);
3361 }, 50);
3362 }
3363 this.content.currentView.$el.toggle(!!value);
3364 }
3365 }, {
3366 key: "onDestroy",
3367 value: function onDestroy() {
3368 var _this$debouncedTrackS;
3369 if ((_this$debouncedTrackS = this.debouncedTrackSearch) !== null && _this$debouncedTrackS !== void 0 && _this$debouncedTrackS.cancel) {
3370 this.debouncedTrackSearch.cancel();
3371 }
3372 }
3373 }]);
3374 }(Marionette.LayoutView);
3375
3376 /***/ }),
3377
3378 /***/ "../core/common/modules/finder/assets/js/modal/views/dynamic-category.js":
3379 /*!*******************************************************************************!*\
3380 !*** ../core/common/modules/finder/assets/js/modal/views/dynamic-category.js ***!
3381 \*******************************************************************************/
3382 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3383
3384 "use strict";
3385
3386
3387 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3388 Object.defineProperty(exports, "__esModule", ({
3389 value: true
3390 }));
3391 exports["default"] = void 0;
3392 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3393 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3394 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3395 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3396 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3397 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3398 var _category = _interopRequireDefault(__webpack_require__(/*! ./category */ "../core/common/modules/finder/assets/js/modal/views/category.js"));
3399 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)); }
3400 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3401 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; }
3402 var _default = exports["default"] = /*#__PURE__*/function (_Category) {
3403 function _default() {
3404 (0, _classCallCheck2.default)(this, _default);
3405 return _callSuper(this, _default, arguments);
3406 }
3407 (0, _inherits2.default)(_default, _Category);
3408 return (0, _createClass2.default)(_default, [{
3409 key: "className",
3410 value: function className() {
3411 return _superPropGet(_default, "className", this, 3)([]) + ' elementor-finder__results__category--dynamic';
3412 }
3413 }, {
3414 key: "ui",
3415 value: function ui() {
3416 return {
3417 title: '.elementor-finder__results__category__title'
3418 };
3419 }
3420 }, {
3421 key: "fetchData",
3422 value: function fetchData() {
3423 var _this = this;
3424 this.ui.loadingIcon.show();
3425 elementorCommon.ajax.addRequest('finder_get_category_items', {
3426 data: {
3427 category: this.model.get('name'),
3428 filter: this.getTextFilter()
3429 },
3430 success: function success(data) {
3431 if (_this.isDestroyed) {
3432 return;
3433 }
3434 _this.collection.set(data);
3435 _this.toggleElement();
3436 _this.ui.loadingIcon.hide();
3437 }
3438 });
3439 }
3440 }, {
3441 key: "filter",
3442 value: function filter() {
3443 return true;
3444 }
3445 }, {
3446 key: "onFilterChange",
3447 value: function onFilterChange() {
3448 this.fetchData();
3449 }
3450 }, {
3451 key: "onRender",
3452 value: function onRender() {
3453 _superPropGet(_default, "onRender", this, 3)([]);
3454 this.ui.loadingIcon = jQuery('<i>', {
3455 class: 'eicon-loading eicon-animation-spin'
3456 });
3457 this.ui.title.after(this.ui.loadingIcon);
3458 this.fetchData();
3459 }
3460 }]);
3461 }(_category.default);
3462
3463 /***/ }),
3464
3465 /***/ "../core/common/modules/finder/assets/js/modal/views/item.js":
3466 /*!*******************************************************************!*\
3467 !*** ../core/common/modules/finder/assets/js/modal/views/item.js ***!
3468 \*******************************************************************/
3469 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3470
3471 "use strict";
3472 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3473
3474
3475 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3476 Object.defineProperty(exports, "__esModule", ({
3477 value: true
3478 }));
3479 exports["default"] = void 0;
3480 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3481 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3482 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3483 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3484 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3485 var _editorOneEvents = __webpack_require__(/*! elementor-editor-utils/editor-one-events */ "../assets/dev/js/editor/utils/editor-one-events.js");
3486 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)); }
3487 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3488 var _default = exports["default"] = /*#__PURE__*/function (_Marionette$ItemView) {
3489 function _default() {
3490 (0, _classCallCheck2.default)(this, _default);
3491 return _callSuper(this, _default, arguments);
3492 }
3493 (0, _inherits2.default)(_default, _Marionette$ItemView);
3494 return (0, _createClass2.default)(_default, [{
3495 key: "className",
3496 value: function className() {
3497 return 'elementor-finder__results__item';
3498 }
3499 }, {
3500 key: "getTemplate",
3501 value: function getTemplate() {
3502 return '#tmpl-elementor-finder__results__item';
3503 }
3504 }, {
3505 key: "events",
3506 value: function events() {
3507 this.$el[0].addEventListener('click', this.onClick.bind(this), true);
3508 }
3509 }, {
3510 key: "trackResultSelect",
3511 value: function trackResultSelect() {
3512 var title = this.model.get('title');
3513 _editorOneEvents.EditorOneEventManager.sendFinderResultSelect(title);
3514 }
3515 }, {
3516 key: "onClick",
3517 value: function onClick(e) {
3518 var _this = this;
3519 var lockOptions = this.model.get('lock');
3520 if (!(lockOptions !== null && lockOptions !== void 0 && lockOptions.is_locked)) {
3521 this.trackResultSelect();
3522 return;
3523 }
3524 e.preventDefault();
3525 e.stopImmediatePropagation();
3526 elementorCommon.dialogsManager.createWidget('confirm', {
3527 id: 'elementor-finder__lock-dialog',
3528 headerMessage: lockOptions.content.heading,
3529 message: lockOptions.content.description,
3530 position: {
3531 my: 'center center',
3532 at: 'center center'
3533 },
3534 strings: {
3535 confirm: lockOptions.button.text,
3536 cancel: __('Cancel', 'elementor')
3537 },
3538 onConfirm: function onConfirm() {
3539 _this.trackResultSelect();
3540 var link = _this.replaceLockLinkPlaceholders(lockOptions.button.url);
3541 window.open(link, '_blank');
3542 }
3543 }).show();
3544 }
3545 }, {
3546 key: "replaceLockLinkPlaceholders",
3547 value: function replaceLockLinkPlaceholders(link) {
3548 return link.replace(/%%utm_source%%/g, 'finder').replace(/%%utm_medium%%/g, 'wp-dash');
3549 }
3550 }]);
3551 }(Marionette.ItemView);
3552
3553 /***/ }),
3554
3555 /***/ "../core/common/modules/finder/assets/js/modal/views/layout.js":
3556 /*!*********************************************************************!*\
3557 !*** ../core/common/modules/finder/assets/js/modal/views/layout.js ***!
3558 \*********************************************************************/
3559 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3560
3561 "use strict";
3562 /* provided dependency */ var __ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n")["__"];
3563
3564
3565 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3566 Object.defineProperty(exports, "__esModule", ({
3567 value: true
3568 }));
3569 exports["default"] = void 0;
3570 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3571 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3572 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3573 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3574 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
3575 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3576 var _content = _interopRequireDefault(__webpack_require__(/*! ./content */ "../core/common/modules/finder/assets/js/modal/views/content.js"));
3577 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)); }
3578 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3579 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; }
3580 var _default = exports["default"] = /*#__PURE__*/function (_elementorModules$com) {
3581 function _default() {
3582 (0, _classCallCheck2.default)(this, _default);
3583 return _callSuper(this, _default, arguments);
3584 }
3585 (0, _inherits2.default)(_default, _elementorModules$com);
3586 return (0, _createClass2.default)(_default, [{
3587 key: "getModalOptions",
3588 value: function getModalOptions() {
3589 return {
3590 id: 'elementor-finder__modal',
3591 draggable: true,
3592 effects: {
3593 show: 'show',
3594 hide: 'hide'
3595 },
3596 position: {
3597 enable: false
3598 }
3599 };
3600 }
3601 }, {
3602 key: "getLogoOptions",
3603 value: function getLogoOptions() {
3604 return {
3605 title: __('Finder', 'elementor')
3606 };
3607 }
3608 }, {
3609 key: "initialize",
3610 value: function initialize() {
3611 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3612 args[_key] = arguments[_key];
3613 }
3614 _superPropGet(_default, "initialize", this, 3)(args);
3615 this.showLogo();
3616 this.showContentView();
3617 }
3618 }, {
3619 key: "showContentView",
3620 value: function showContentView() {
3621 this.modalContent.show(new _content.default());
3622 }
3623 }, {
3624 key: "showModal",
3625 value: function showModal() {
3626 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3627 args[_key2] = arguments[_key2];
3628 }
3629 _superPropGet(_default, "showModal", this, 3)(args);
3630 this.modalContent.currentView.ui.searchInput.focus();
3631 }
3632 }]);
3633 }(elementorModules.common.views.modal.Layout);
3634
3635 /***/ }),
3636
3637 /***/ "../modules/web-cli/assets/js/core/data/errors/base-error.js":
3638 /*!*******************************************************************!*\
3639 !*** ../modules/web-cli/assets/js/core/data/errors/base-error.js ***!
3640 \*******************************************************************/
3641 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3642
3643 "use strict";
3644
3645
3646 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3647 Object.defineProperty(exports, "__esModule", ({
3648 value: true
3649 }));
3650 exports["default"] = void 0;
3651 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3652 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3653 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3654 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3655 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3656 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
3657 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
3658 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3659 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../../../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
3660 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; }
3661 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; }
3662 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)); }
3663 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3664 var BaseError = exports["default"] = /*#__PURE__*/function (_Error) {
3665 /**
3666 * Error constructor.
3667 *
3668 * @param {string} message
3669 * @param {string} code
3670 * @param {*} data
3671 */
3672 function BaseError() {
3673 var _this;
3674 var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
3675 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3676 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3677 (0, _classCallCheck2.default)(this, BaseError);
3678 _this = _callSuper(this, BaseError, [message]);
3679 /**
3680 * The server error code.
3681 *
3682 * @type {string}
3683 */
3684 (0, _defineProperty2.default)(_this, "code", '');
3685 /**
3686 * Additional data about the current error.
3687 *
3688 * @type {*[]}
3689 */
3690 (0, _defineProperty2.default)(_this, "data", []);
3691 _this.code = code;
3692 _this.data = data;
3693 return _this;
3694 }
3695
3696 /**
3697 * Notify a message when the error occurs.
3698 */
3699 (0, _inherits2.default)(BaseError, _Error);
3700 return (0, _createClass2.default)(BaseError, [{
3701 key: "notify",
3702 value: function notify() {
3703 _console.default.error(_objectSpread({
3704 message: this.message
3705 }, this));
3706 }
3707 }], [{
3708 key: "create",
3709 value:
3710 /**
3711 * Static helper function to create the error.
3712 *
3713 * @param {string} message
3714 * @param {string} code
3715 * @param {*} data
3716 * @return {BaseError} error
3717 */
3718 function create(message) {
3719 var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3720 var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
3721 return new this(message, code, data);
3722 }
3723
3724 /**
3725 * Returns the status code of the error.
3726 */
3727 }, {
3728 key: "getHTTPErrorCode",
3729 value: function getHTTPErrorCode() {
3730 (0, _forceMethodImplementation.default)();
3731 }
3732 }]);
3733 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
3734
3735 /***/ }),
3736
3737 /***/ "../modules/web-cli/assets/js/core/data/errors/default-error.js":
3738 /*!**********************************************************************!*\
3739 !*** ../modules/web-cli/assets/js/core/data/errors/default-error.js ***!
3740 \**********************************************************************/
3741 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3742
3743 "use strict";
3744
3745
3746 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3747 Object.defineProperty(exports, "__esModule", ({
3748 value: true
3749 }));
3750 exports["default"] = exports.DefaultError = void 0;
3751 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3752 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3753 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3754 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3755 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3756 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3757 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)); }
3758 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3759 var DefaultError = exports.DefaultError = /*#__PURE__*/function (_BaseError) {
3760 function DefaultError() {
3761 (0, _classCallCheck2.default)(this, DefaultError);
3762 return _callSuper(this, DefaultError, arguments);
3763 }
3764 (0, _inherits2.default)(DefaultError, _BaseError);
3765 return (0, _createClass2.default)(DefaultError, null, [{
3766 key: "getHTTPErrorCode",
3767 value: function getHTTPErrorCode() {
3768 return 501;
3769 }
3770 }]);
3771 }(_baseError.default);
3772 var _default = exports["default"] = DefaultError;
3773
3774 /***/ }),
3775
3776 /***/ "../modules/web-cli/assets/js/core/data/errors/error-404.js":
3777 /*!******************************************************************!*\
3778 !*** ../modules/web-cli/assets/js/core/data/errors/error-404.js ***!
3779 \******************************************************************/
3780 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3781
3782 "use strict";
3783
3784
3785 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3786 Object.defineProperty(exports, "__esModule", ({
3787 value: true
3788 }));
3789 exports["default"] = exports.Error404 = void 0;
3790 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3791 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3792 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3793 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3794 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3795 var _baseError = _interopRequireDefault(__webpack_require__(/*! ./base-error */ "../modules/web-cli/assets/js/core/data/errors/base-error.js"));
3796 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
3797 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)); }
3798 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3799 var Error404 = exports.Error404 = /*#__PURE__*/function (_BaseError) {
3800 function Error404() {
3801 (0, _classCallCheck2.default)(this, Error404);
3802 return _callSuper(this, Error404, arguments);
3803 }
3804 (0, _inherits2.default)(Error404, _BaseError);
3805 return (0, _createClass2.default)(Error404, [{
3806 key: "notify",
3807 value: function notify() {
3808 _console.default.warn(this.message);
3809 }
3810 }], [{
3811 key: "getHTTPErrorCode",
3812 value: function getHTTPErrorCode() {
3813 return 404;
3814 }
3815 }]);
3816 }(_baseError.default);
3817 var _default = exports["default"] = Error404;
3818
3819 /***/ }),
3820
3821 /***/ "../modules/web-cli/assets/js/core/data/errors/index.js":
3822 /*!**************************************************************!*\
3823 !*** ../modules/web-cli/assets/js/core/data/errors/index.js ***!
3824 \**************************************************************/
3825 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3826
3827 "use strict";
3828
3829
3830 Object.defineProperty(exports, "__esModule", ({
3831 value: true
3832 }));
3833 Object.defineProperty(exports, "DefaultError", ({
3834 enumerable: true,
3835 get: function get() {
3836 return _defaultError.DefaultError;
3837 }
3838 }));
3839 Object.defineProperty(exports, "Error404", ({
3840 enumerable: true,
3841 get: function get() {
3842 return _error.Error404;
3843 }
3844 }));
3845 var _defaultError = __webpack_require__(/*! ./default-error */ "../modules/web-cli/assets/js/core/data/errors/default-error.js");
3846 var _error = __webpack_require__(/*! ./error-404 */ "../modules/web-cli/assets/js/core/data/errors/error-404.js");
3847
3848 /***/ }),
3849
3850 /***/ "../modules/web-cli/assets/js/modules/command-base.js":
3851 /*!************************************************************!*\
3852 !*** ../modules/web-cli/assets/js/modules/command-base.js ***!
3853 \************************************************************/
3854 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3855
3856 "use strict";
3857
3858
3859 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3860 Object.defineProperty(exports, "__esModule", ({
3861 value: true
3862 }));
3863 exports["default"] = void 0;
3864 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3865 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3866 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3867 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3868 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3869 var _commandInfra = _interopRequireDefault(__webpack_require__(/*! ./command-infra */ "../modules/web-cli/assets/js/modules/command-infra.js"));
3870 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
3871 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)); }
3872 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3873 /**
3874 * @name $e.modules.CommandBase
3875 */
3876 var CommandBase = exports["default"] = /*#__PURE__*/function (_CommandInfra) {
3877 function CommandBase() {
3878 (0, _classCallCheck2.default)(this, CommandBase);
3879 return _callSuper(this, CommandBase, arguments);
3880 }
3881 (0, _inherits2.default)(CommandBase, _CommandInfra);
3882 return (0, _createClass2.default)(CommandBase, [{
3883 key: "onBeforeRun",
3884 value: function onBeforeRun() {
3885 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3886 $e.hooks.runUIBefore(this.command, args);
3887 }
3888 }, {
3889 key: "onAfterRun",
3890 value: function onAfterRun() {
3891 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3892 var result = arguments.length > 1 ? arguments[1] : undefined;
3893 $e.hooks.runUIAfter(this.command, args, result);
3894 }
3895 }, {
3896 key: "onBeforeApply",
3897 value: function onBeforeApply() {
3898 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3899 $e.hooks.runDataDependency(this.command, args);
3900 }
3901 }, {
3902 key: "onAfterApply",
3903 value: function onAfterApply() {
3904 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3905 var result = arguments.length > 1 ? arguments[1] : undefined;
3906 return $e.hooks.runDataAfter(this.command, args, result);
3907 }
3908 }, {
3909 key: "onCatchApply",
3910 value: function onCatchApply(e) {
3911 this.runCatchHooks(e);
3912 }
3913
3914 /**
3915 * Run all the catch hooks.
3916 *
3917 * @param {Error} e
3918 */
3919 }, {
3920 key: "runCatchHooks",
3921 value: function runCatchHooks(e) {
3922 $e.hooks.runDataCatch(this.command, this.args, e);
3923 $e.hooks.runUICatch(this.command, this.args, e);
3924 }
3925
3926 /**
3927 * TODO - Remove - Backwards compatibility.
3928 *
3929 * Function requireContainer().
3930 *
3931 * Validate `arg.container` & `arg.containers`.
3932 *
3933 * @param {{}} args
3934 * @deprecated since 3.7.0, extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase` instead.
3935 *
3936 * @throws {Error}
3937 */
3938 }, {
3939 key: "requireContainer",
3940 value: function requireContainer() {
3941 var _this = this;
3942 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.args;
3943 _deprecation.default.deprecated('requireContainer()', '3.7.0', 'Extend `$e.modules.editor.CommandContainerBase` or `$e.modules.editor.CommandContainerInternalBase`');
3944 if (!args.container && !args.containers) {
3945 throw Error('container or containers are required.');
3946 }
3947 if (args.container && args.containers) {
3948 throw Error('container and containers cannot go together please select one of them.');
3949 }
3950 var containers = args.containers || [args.container];
3951 containers.forEach(function (container) {
3952 _this.requireArgumentInstance('container', elementorModules.editor.Container, {
3953 container: container
3954 });
3955 });
3956 }
3957 }], [{
3958 key: "getInstanceType",
3959 value: function getInstanceType() {
3960 return 'CommandBase';
3961 }
3962 }]);
3963 }(_commandInfra.default);
3964
3965 /***/ }),
3966
3967 /***/ "../modules/web-cli/assets/js/modules/command-callback-base.js":
3968 /*!*********************************************************************!*\
3969 !*** ../modules/web-cli/assets/js/modules/command-callback-base.js ***!
3970 \*********************************************************************/
3971 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3972
3973 "use strict";
3974
3975
3976 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
3977 Object.defineProperty(exports, "__esModule", ({
3978 value: true
3979 }));
3980 exports["default"] = void 0;
3981 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
3982 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
3983 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
3984 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
3985 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
3986 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
3987 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)); }
3988 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
3989 /**
3990 * To support pure callbacks in the API(commands.js), to ensure they have registered with the proper context.
3991 */
3992 var CommandCallbackBase = exports["default"] = /*#__PURE__*/function (_CommandBase) {
3993 function CommandCallbackBase() {
3994 (0, _classCallCheck2.default)(this, CommandCallbackBase);
3995 return _callSuper(this, CommandCallbackBase, arguments);
3996 }
3997 (0, _inherits2.default)(CommandCallbackBase, _CommandBase);
3998 return (0, _createClass2.default)(CommandCallbackBase, [{
3999 key: "apply",
4000 value: function apply() {
4001 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4002 return this.constructor.getCallback()(args);
4003 }
4004 }], [{
4005 key: "getInstanceType",
4006 value: function getInstanceType() {
4007 return 'CommandCallbackBase';
4008 }
4009
4010 /**
4011 * Get original callback of the command.
4012 *
4013 * Support pure callbacks ( Non command-base ).
4014 *
4015 * @return {()=>{}} Command Results.
4016 */
4017 }, {
4018 key: "getCallback",
4019 value: function getCallback() {
4020 return this.registerConfig.callback;
4021 }
4022 }]);
4023 }(_commandBase.default);
4024
4025 /***/ }),
4026
4027 /***/ "../modules/web-cli/assets/js/modules/command-data.js":
4028 /*!************************************************************!*\
4029 !*** ../modules/web-cli/assets/js/modules/command-data.js ***!
4030 \************************************************************/
4031 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4032
4033 "use strict";
4034
4035
4036 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4037 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
4038 Object.defineProperty(exports, "__esModule", ({
4039 value: true
4040 }));
4041 exports["default"] = void 0;
4042 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4043 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4044 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4045 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4046 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4047 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4048 var _commandBase = _interopRequireDefault(__webpack_require__(/*! ./command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4049 var errors = _interopRequireWildcard(__webpack_require__(/*! ../core/data/errors/ */ "../modules/web-cli/assets/js/core/data/errors/index.js"));
4050 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); }
4051 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)); }
4052 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4053 /**
4054 * @name $e.modules.CommandData
4055 */
4056 /**
4057 * @typedef {('create'|'delete'|'get'|'update'|'options')} DataTypes
4058 */
4059 /**
4060 * @typedef {{}} RequestData
4061 */
4062 /**
4063 * @typedef {import('../core/data/errors/base-error')} BaseError
4064 */
4065 var CommandData = exports["default"] = /*#__PURE__*/function (_CommandBase) {
4066 function CommandData(args) {
4067 var _this$args$options;
4068 var _this;
4069 var commandsAPI = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $e.data;
4070 (0, _classCallCheck2.default)(this, CommandData);
4071 _this = _callSuper(this, CommandData, [args, commandsAPI]);
4072 /**
4073 * Data returned from remote.
4074 *
4075 * @type {*}
4076 */
4077 (0, _defineProperty2.default)(_this, "data", void 0);
4078 /**
4079 * Fetch type.
4080 *
4081 * @type {DataTypes}
4082 */
4083 (0, _defineProperty2.default)(_this, "type", void 0);
4084 if ((_this$args$options = _this.args.options) !== null && _this$args$options !== void 0 && _this$args$options.type) {
4085 _this.type = _this.args.options.type;
4086 }
4087 return _this;
4088 }
4089
4090 /**
4091 * Function getEndpointFormat().
4092 *
4093 * @return {null|string} endpoint format
4094 */
4095 (0, _inherits2.default)(CommandData, _CommandBase);
4096 return (0, _createClass2.default)(CommandData, [{
4097 key: "getApplyMethods",
4098 value:
4099 /**
4100 * @param {DataTypes} type
4101 *
4102 * @return {boolean|{before: (function(*=): {}), after: (function({}, *=): {})}} apply methods
4103 */
4104 function getApplyMethods() {
4105 var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.type;
4106 var before, after;
4107 switch (type) {
4108 case 'create':
4109 before = this.applyBeforeCreate;
4110 after = this.applyAfterCreate;
4111 break;
4112 case 'delete':
4113 before = this.applyBeforeDelete;
4114 after = this.applyAfterDelete;
4115 break;
4116 case 'get':
4117 before = this.applyBeforeGet;
4118 after = this.applyAfterGet;
4119 break;
4120 case 'update':
4121 before = this.applyBeforeUpdate;
4122 after = this.applyAfterUpdate;
4123 break;
4124 case 'options':
4125 before = this.applyBeforeOptions;
4126 after = this.applyAfterOptions;
4127 break;
4128 default:
4129 return false;
4130 }
4131 return {
4132 before: before.bind(this),
4133 after: after.bind(this)
4134 };
4135 }
4136
4137 /**
4138 * Function getRequestData().
4139 *
4140 * @return {RequestData} request data
4141 */
4142 }, {
4143 key: "getRequestData",
4144 value: function getRequestData() {
4145 return {
4146 type: this.type,
4147 args: this.args,
4148 timestamp: new Date().getTime(),
4149 component: this.component,
4150 command: this.command,
4151 endpoint: $e.data.commandToEndpoint(this.command, JSON.parse(JSON.stringify(this.args)), this.constructor.getEndpointFormat())
4152 };
4153 }
4154 }, {
4155 key: "apply",
4156 value: function apply() {
4157 var _this2 = this;
4158 var applyMethods = this.getApplyMethods();
4159
4160 // Run 'before' method.
4161 this.args = applyMethods.before(this.args);
4162 var requestData = this.getRequestData();
4163 return $e.data.fetch(requestData).then(function (data) {
4164 _this2.data = data;
4165
4166 // Run 'after' method.
4167 _this2.data = applyMethods.after(data, _this2.args);
4168 _this2.data = {
4169 data: _this2.data
4170 };
4171
4172 // Append requestData.
4173 _this2.data = Object.assign({
4174 __requestData__: requestData
4175 }, _this2.data);
4176 return _this2.data;
4177 });
4178 }
4179
4180 /**
4181 * @param {*} [args={}]
4182 * @return {{}} filtered args
4183 */
4184 }, {
4185 key: "applyBeforeCreate",
4186 value: function applyBeforeCreate() {
4187 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4188 return args;
4189 }
4190
4191 /**
4192 * @param {{}} data
4193 * @param {*} [args={}]
4194 * @return {{}} filtered result
4195 */
4196 }, {
4197 key: "applyAfterCreate",
4198 value: function applyAfterCreate(data) {
4199 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4200 // eslint-disable-line no-unused-vars
4201 return data;
4202 }
4203
4204 /**
4205 * @param {*} [args={}]
4206 * @return {{}} filtered args
4207 */
4208 }, {
4209 key: "applyBeforeDelete",
4210 value: function applyBeforeDelete() {
4211 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4212 return args;
4213 }
4214
4215 /**
4216 * @param {{}} data
4217 * @param {*} [args={}]
4218 * @return {{}} filtered result
4219 */
4220 }, {
4221 key: "applyAfterDelete",
4222 value: function applyAfterDelete(data) {
4223 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4224 // eslint-disable-line no-unused-vars
4225 return data;
4226 }
4227
4228 /**
4229 * @param {*} [args={}]
4230 * @return {{}} filtered args
4231 */
4232 }, {
4233 key: "applyBeforeGet",
4234 value: function applyBeforeGet() {
4235 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4236 return args;
4237 }
4238
4239 /**
4240 * @param {{}} data
4241 * @param {*} [args={}]
4242 * @return {{}} filtered result
4243 */
4244 }, {
4245 key: "applyAfterGet",
4246 value: function applyAfterGet(data) {
4247 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4248 // eslint-disable-line no-unused-vars
4249 return data;
4250 }
4251
4252 /**
4253 * @param {*} [args={}]
4254 * @return {{}} filtered args
4255 */
4256 }, {
4257 key: "applyBeforeUpdate",
4258 value: function applyBeforeUpdate() {
4259 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4260 return args;
4261 }
4262
4263 /**
4264 * @param {{}} data
4265 * @param {*} [args={}]
4266 * @return {{}} filtered result
4267 */
4268 }, {
4269 key: "applyAfterUpdate",
4270 value: function applyAfterUpdate(data) {
4271 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4272 // eslint-disable-line no-unused-vars
4273 return data;
4274 }
4275
4276 /**
4277 * @param {*} [args={}]
4278 * @return {{}} filtered args
4279 */
4280 }, {
4281 key: "applyBeforeOptions",
4282 value: function applyBeforeOptions() {
4283 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4284 return args;
4285 }
4286
4287 /**
4288 * @param {{}} data
4289 * @param {*} [args={}]
4290 * @return {{}} filtered result
4291 */
4292 }, {
4293 key: "applyAfterOptions",
4294 value: function applyAfterOptions(data) {
4295 var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4296 // eslint-disable-line no-unused-vars
4297 return data;
4298 }
4299
4300 /**
4301 * @param {BaseError} e
4302 */
4303 }, {
4304 key: "applyAfterCatch",
4305 value: function applyAfterCatch(e) {
4306 e.notify();
4307 }
4308 }, {
4309 key: "onCatchApply",
4310 value: function onCatchApply(e) {
4311 var _e;
4312 // TODO: If the errors that returns from the server is consistent remove the '?' from 'e'
4313 var httpErrorCode = ((_e = e) === null || _e === void 0 || (_e = _e.data) === null || _e === void 0 ? void 0 : _e.status) || 501;
4314 var dataError = Object.values(errors).find(function (error) {
4315 return error.getHTTPErrorCode() === httpErrorCode;
4316 });
4317 if (!dataError) {
4318 dataError = errors.DefaultError;
4319 }
4320 e = dataError.create(e.message, e.code, e.data || []);
4321 this.runCatchHooks(e);
4322 this.applyAfterCatch(e);
4323 }
4324 }], [{
4325 key: "getInstanceType",
4326 value: function getInstanceType() {
4327 return 'CommandData';
4328 }
4329 }, {
4330 key: "getEndpointFormat",
4331 value: function getEndpointFormat() {
4332 return null;
4333 }
4334 }]);
4335 }(_commandBase.default);
4336
4337 /***/ }),
4338
4339 /***/ "../modules/web-cli/assets/js/modules/command-infra.js":
4340 /*!*************************************************************!*\
4341 !*** ../modules/web-cli/assets/js/modules/command-infra.js ***!
4342 \*************************************************************/
4343 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4344
4345 "use strict";
4346
4347
4348 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4349 Object.defineProperty(exports, "__esModule", ({
4350 value: true
4351 }));
4352 exports["default"] = void 0;
4353 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4354 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4355 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4356 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4357 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4358 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4359 var _argsObject = _interopRequireDefault(__webpack_require__(/*! elementor-assets-js/modules/imports/args-object */ "../assets/dev/js/modules/imports/args-object.js"));
4360 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4361 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)); }
4362 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4363 /**
4364 * @typedef {import('../modules/component-base')} ComponentBase
4365 */
4366 var CommandInfra = exports["default"] = /*#__PURE__*/function (_ArgsObject) {
4367 /**
4368 * Function constructor().
4369 *
4370 * Create Commands Base.
4371 *
4372 * @param {{}} args
4373 */
4374 function CommandInfra() {
4375 var _this;
4376 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4377 (0, _classCallCheck2.default)(this, CommandInfra);
4378 _this = _callSuper(this, CommandInfra, [args]);
4379 if (!_this.constructor.registerConfig) {
4380 throw RangeError('Doing it wrong: Each command type should have `registerConfig`.');
4381 }
4382
4383 // Acknowledge self about which command it run.
4384 _this.command = _this.constructor.getCommand();
4385
4386 // Assign instance of current component.
4387 _this.component = _this.constructor.getComponent();
4388
4389 // Who ever need do something before without `super` the constructor can use `initialize` method.
4390 _this.initialize(args);
4391
4392 // Refresh args, maybe the changed via `initialize`.
4393 args = _this.args;
4394
4395 // Validate args before run.
4396 _this.validateArgs(args);
4397 return _this;
4398 }
4399
4400 /**
4401 * Function initialize().
4402 *
4403 * Initialize command, called after construction.
4404 *
4405 * @param {{}} args
4406 */
4407 (0, _inherits2.default)(CommandInfra, _ArgsObject);
4408 return (0, _createClass2.default)(CommandInfra, [{
4409 key: "currentCommand",
4410 get:
4411 /**
4412 * @deprecated since 3.7.0, use `this.command` instead.
4413 */
4414 function get() {
4415 _deprecation.default.deprecated('this.currentCommand', '3.7.0', 'this.command');
4416 return this.command;
4417 }
4418 }, {
4419 key: "initialize",
4420 value: function initialize() {
4421 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4422 } // eslint-disable-line no-unused-vars
4423
4424 /**
4425 * Function validateArgs().
4426 *
4427 * Validate command arguments.
4428 *
4429 * @param {{}} args
4430 */
4431 }, {
4432 key: "validateArgs",
4433 value: function validateArgs() {
4434 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4435 } // eslint-disable-line no-unused-vars
4436
4437 // eslint-disable-next-line jsdoc/require-returns-check
4438 /**
4439 * Function apply().
4440 *
4441 * Do the actual command.
4442 *
4443 * @param {{}} args
4444 *
4445 * @return {*} Command results.
4446 */
4447 }, {
4448 key: "apply",
4449 value: function apply() {
4450 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4451 // eslint-disable-line no-unused-vars
4452 elementorModules.ForceMethodImplementation();
4453 }
4454
4455 /**
4456 * Function run().
4457 *
4458 * Run command with history & hooks.
4459 *
4460 * @return {*} Command results.
4461 */
4462 }, {
4463 key: "run",
4464 value: function run() {
4465 return this.apply(this.args);
4466 }
4467
4468 /**
4469 * Function onBeforeRun.
4470 *
4471 * Called before run().
4472 *
4473 * @param {{}} args
4474 */
4475 }, {
4476 key: "onBeforeRun",
4477 value: function onBeforeRun() {
4478 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4479 } // eslint-disable-line no-unused-vars
4480
4481 /**
4482 * Function onAfterRun.
4483 *
4484 * Called after run().
4485 *
4486 * @param {{}} args
4487 * @param {*} result
4488 */
4489 }, {
4490 key: "onAfterRun",
4491 value: function onAfterRun() {
4492 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4493 var result = arguments.length > 1 ? arguments[1] : undefined;
4494 } // eslint-disable-line no-unused-vars
4495
4496 /**
4497 * Function onBeforeApply.
4498 *
4499 * Called before apply().
4500 *
4501 * @param {{}} args
4502 */
4503 }, {
4504 key: "onBeforeApply",
4505 value: function onBeforeApply() {
4506 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4507 } // eslint-disable-line no-unused-vars
4508
4509 /**
4510 * Function onAfterApply.
4511 *
4512 * Called after apply().
4513 *
4514 * @param {{}} args
4515 * @param {*} result
4516 */
4517 }, {
4518 key: "onAfterApply",
4519 value: function onAfterApply() {
4520 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4521 var result = arguments.length > 1 ? arguments[1] : undefined;
4522 } // eslint-disable-line no-unused-vars
4523
4524 /**
4525 * Function onCatchApply.
4526 *
4527 * Called after apply() failed.
4528 *
4529 * @param {Error} e
4530 */
4531 }, {
4532 key: "onCatchApply",
4533 value: function onCatchApply(e) {} // eslint-disable-line no-unused-vars
4534 }], [{
4535 key: "getInstanceType",
4536 value: function getInstanceType() {
4537 return 'CommandInfra';
4538 }
4539
4540 /**
4541 * Get info of command.
4542 *
4543 * @return {Object} Extra information about the command.
4544 */
4545 }, {
4546 key: "getInfo",
4547 value: function getInfo() {
4548 return {};
4549 }
4550
4551 /**
4552 * @return {string} Self command name.
4553 */
4554 }, {
4555 key: "getCommand",
4556 value: function getCommand() {
4557 return this.registerConfig.command;
4558 }
4559
4560 /**
4561 * @return {ComponentBase} Self component
4562 */
4563 }, {
4564 key: "getComponent",
4565 value: function getComponent() {
4566 return this.registerConfig.component;
4567 }
4568 }, {
4569 key: "setRegisterConfig",
4570 value: function setRegisterConfig(config) {
4571 this.registerConfig = Object.freeze(config);
4572 }
4573 }]);
4574 }(_argsObject.default);
4575 /**
4576 * @type {Object}
4577 */
4578 (0, _defineProperty2.default)(CommandInfra, "registerConfig", null);
4579
4580 /***/ }),
4581
4582 /***/ "../modules/web-cli/assets/js/modules/commands/close.js":
4583 /*!**************************************************************!*\
4584 !*** ../modules/web-cli/assets/js/modules/commands/close.js ***!
4585 \**************************************************************/
4586 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4587
4588 "use strict";
4589
4590
4591 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4592 Object.defineProperty(exports, "__esModule", ({
4593 value: true
4594 }));
4595 exports["default"] = exports.Close = void 0;
4596 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4597 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4598 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4599 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4600 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4601 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4602 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)); }
4603 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4604 var Close = exports.Close = /*#__PURE__*/function (_CommandBase) {
4605 function Close() {
4606 (0, _classCallCheck2.default)(this, Close);
4607 return _callSuper(this, Close, arguments);
4608 }
4609 (0, _inherits2.default)(Close, _CommandBase);
4610 return (0, _createClass2.default)(Close, [{
4611 key: "apply",
4612 value: function apply() {
4613 this.component.close();
4614 }
4615 }]);
4616 }(_commandBase.default);
4617 var _default = exports["default"] = Close;
4618
4619 /***/ }),
4620
4621 /***/ "../modules/web-cli/assets/js/modules/commands/index.js":
4622 /*!**************************************************************!*\
4623 !*** ../modules/web-cli/assets/js/modules/commands/index.js ***!
4624 \**************************************************************/
4625 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4626
4627 "use strict";
4628
4629
4630 Object.defineProperty(exports, "__esModule", ({
4631 value: true
4632 }));
4633 Object.defineProperty(exports, "Close", ({
4634 enumerable: true,
4635 get: function get() {
4636 return _close.Close;
4637 }
4638 }));
4639 Object.defineProperty(exports, "Open", ({
4640 enumerable: true,
4641 get: function get() {
4642 return _open.Open;
4643 }
4644 }));
4645 Object.defineProperty(exports, "Toggle", ({
4646 enumerable: true,
4647 get: function get() {
4648 return _toggle.Toggle;
4649 }
4650 }));
4651 var _close = __webpack_require__(/*! ./close */ "../modules/web-cli/assets/js/modules/commands/close.js");
4652 var _open = __webpack_require__(/*! ./open */ "../modules/web-cli/assets/js/modules/commands/open.js");
4653 var _toggle = __webpack_require__(/*! ./toggle */ "../modules/web-cli/assets/js/modules/commands/toggle.js");
4654
4655 /***/ }),
4656
4657 /***/ "../modules/web-cli/assets/js/modules/commands/open.js":
4658 /*!*************************************************************!*\
4659 !*** ../modules/web-cli/assets/js/modules/commands/open.js ***!
4660 \*************************************************************/
4661 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4662
4663 "use strict";
4664
4665
4666 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4667 Object.defineProperty(exports, "__esModule", ({
4668 value: true
4669 }));
4670 exports["default"] = exports.Open = void 0;
4671 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4672 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4673 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4674 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4675 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4676 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4677 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)); }
4678 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4679 var Open = exports.Open = /*#__PURE__*/function (_CommandBase) {
4680 function Open() {
4681 (0, _classCallCheck2.default)(this, Open);
4682 return _callSuper(this, Open, arguments);
4683 }
4684 (0, _inherits2.default)(Open, _CommandBase);
4685 return (0, _createClass2.default)(Open, [{
4686 key: "apply",
4687 value: function apply() {
4688 $e.route(this.component.getNamespace());
4689 }
4690 }]);
4691 }(_commandBase.default);
4692 var _default = exports["default"] = Open;
4693
4694 /***/ }),
4695
4696 /***/ "../modules/web-cli/assets/js/modules/commands/toggle.js":
4697 /*!***************************************************************!*\
4698 !*** ../modules/web-cli/assets/js/modules/commands/toggle.js ***!
4699 \***************************************************************/
4700 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4701
4702 "use strict";
4703
4704
4705 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4706 Object.defineProperty(exports, "__esModule", ({
4707 value: true
4708 }));
4709 exports["default"] = exports.Toggle = void 0;
4710 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4711 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4712 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4713 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4714 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4715 var _commandBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-base */ "../modules/web-cli/assets/js/modules/command-base.js"));
4716 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)); }
4717 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4718 var Toggle = exports.Toggle = /*#__PURE__*/function (_CommandBase) {
4719 function Toggle() {
4720 (0, _classCallCheck2.default)(this, Toggle);
4721 return _callSuper(this, Toggle, arguments);
4722 }
4723 (0, _inherits2.default)(Toggle, _CommandBase);
4724 return (0, _createClass2.default)(Toggle, [{
4725 key: "apply",
4726 value: function apply() {
4727 if (this.component.isOpen) {
4728 this.component.close();
4729 } else {
4730 $e.route(this.component.getNamespace());
4731 }
4732 }
4733 }]);
4734 }(_commandBase.default);
4735 var _default = exports["default"] = Toggle;
4736
4737 /***/ }),
4738
4739 /***/ "../modules/web-cli/assets/js/modules/component-base.js":
4740 /*!**************************************************************!*\
4741 !*** ../modules/web-cli/assets/js/modules/component-base.js ***!
4742 \**************************************************************/
4743 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
4744
4745 "use strict";
4746
4747
4748 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
4749 Object.defineProperty(exports, "__esModule", ({
4750 value: true
4751 }));
4752 exports["default"] = void 0;
4753 var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "../node_modules/@babel/runtime/helpers/defineProperty.js"));
4754 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
4755 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
4756 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
4757 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
4758 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
4759 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
4760 var _commandCallbackBase = _interopRequireDefault(__webpack_require__(/*! elementor-api/modules/command-callback-base */ "../modules/web-cli/assets/js/modules/command-callback-base.js"));
4761 var _toolkit = __webpack_require__(/*! @reduxjs/toolkit */ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js");
4762 var _module = _interopRequireDefault(__webpack_require__(/*! elementor/assets/dev/js/modules/imports/module.js */ "../assets/dev/js/modules/imports/module.js"));
4763 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
4764 var _deprecation = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/deprecation */ "../modules/web-cli/assets/js/utils/deprecation.js"));
4765 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; }
4766 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; }
4767 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)); }
4768 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
4769 /**
4770 * @typedef {import('./command-infra')} CommandInfra
4771 * @typedef {import('./hook-base')} HookBase
4772 * @typedef {import('../core/states/ui-state-base')} UiStateBase
4773 */
4774 var ComponentBase = exports["default"] = /*#__PURE__*/function (_Module) {
4775 function ComponentBase() {
4776 (0, _classCallCheck2.default)(this, ComponentBase);
4777 return _callSuper(this, ComponentBase, arguments);
4778 }
4779 (0, _inherits2.default)(ComponentBase, _Module);
4780 return (0, _createClass2.default)(ComponentBase, [{
4781 key: "__construct",
4782 value: function __construct() {
4783 var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4784 if (args.manager) {
4785 this.manager = args.manager;
4786 }
4787 this.commands = this.defaultCommands();
4788 this.commandsInternal = this.defaultCommandsInternal();
4789 this.hooks = this.defaultHooks();
4790 this.routes = this.defaultRoutes();
4791 this.tabs = this.defaultTabs();
4792 this.shortcuts = this.defaultShortcuts();
4793 this.utils = this.defaultUtils();
4794 this.data = this.defaultData();
4795 this.uiStates = this.defaultUiStates();
4796 this.states = this.defaultStates();
4797 this.defaultRoute = '';
4798 this.currentTab = '';
4799 }
4800 }, {
4801 key: "registerAPI",
4802 value: function registerAPI() {
4803 var _this = this;
4804 Object.entries(this.getTabs()).forEach(function (tab) {
4805 return _this.registerTabRoute(tab[0]);
4806 });
4807 Object.entries(this.getRoutes()).forEach(function (_ref) {
4808 var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
4809 route = _ref2[0],
4810 callback = _ref2[1];
4811 return _this.registerRoute(route, callback);
4812 });
4813 Object.entries(this.getCommands()).forEach(function (_ref3) {
4814 var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
4815 command = _ref4[0],
4816 callback = _ref4[1];
4817 return _this.registerCommand(command, callback);
4818 });
4819 Object.entries(this.getCommandsInternal()).forEach(function (_ref5) {
4820 var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
4821 command = _ref6[0],
4822 callback = _ref6[1];
4823 return _this.registerCommandInternal(command, callback);
4824 });
4825 Object.values(this.getHooks()).forEach(function (instance) {
4826 return _this.registerHook(instance);
4827 });
4828 Object.entries(this.getData()).forEach(function (_ref7) {
4829 var _ref8 = (0, _slicedToArray2.default)(_ref7, 2),
4830 command = _ref8[0],
4831 callback = _ref8[1];
4832 return _this.registerData(command, callback);
4833 });
4834 Object.values(this.getUiStates()).forEach(function (instance) {
4835 return _this.registerUiState(instance);
4836 });
4837 Object.entries(this.getStates()).forEach(function (_ref9) {
4838 var _ref0 = (0, _slicedToArray2.default)(_ref9, 2),
4839 id = _ref0[0],
4840 state = _ref0[1];
4841 return _this.registerState(id, state);
4842 });
4843 }
4844
4845 // eslint-disable-next-line jsdoc/require-returns-check
4846 /**
4847 * @return {string} namespace
4848 */
4849 }, {
4850 key: "getNamespace",
4851 value: function getNamespace() {
4852 (0, _forceMethodImplementation.default)();
4853 }
4854
4855 /**
4856 * @deprecated since 3.7.0, use `getServiceName()` instead.
4857 */
4858 }, {
4859 key: "getRootContainer",
4860 value: function getRootContainer() {
4861 _deprecation.default.deprecated('getRootContainer()', '3.7.0', 'getServiceName()');
4862 return this.getServiceName();
4863 }
4864 }, {
4865 key: "getServiceName",
4866 value: function getServiceName() {
4867 return this.getNamespace().split('/')[0];
4868 }
4869 }, {
4870 key: "store",
4871 get: function get() {
4872 return $e.store.get(this.getNamespace());
4873 }
4874 }, {
4875 key: "defaultTabs",
4876 value: function defaultTabs() {
4877 return {};
4878 }
4879 }, {
4880 key: "defaultRoutes",
4881 value: function defaultRoutes() {
4882 return {};
4883 }
4884 }, {
4885 key: "defaultCommands",
4886 value: function defaultCommands() {
4887 return {};
4888 }
4889 }, {
4890 key: "defaultCommandsInternal",
4891 value: function defaultCommandsInternal() {
4892 return {};
4893 }
4894 }, {
4895 key: "defaultHooks",
4896 value: function defaultHooks() {
4897 return {};
4898 }
4899
4900 /**
4901 * Get the component's default UI states.
4902 *
4903 * @return {Object} default UI states
4904 */
4905 }, {
4906 key: "defaultUiStates",
4907 value: function defaultUiStates() {
4908 return {};
4909 }
4910
4911 /**
4912 * Get the component's Redux slice settings.
4913 *
4914 * @return {Object} Redux slice settings
4915 */
4916 }, {
4917 key: "defaultStates",
4918 value: function defaultStates() {
4919 return {};
4920 }
4921 }, {
4922 key: "defaultShortcuts",
4923 value: function defaultShortcuts() {
4924 return {};
4925 }
4926 }, {
4927 key: "defaultUtils",
4928 value: function defaultUtils() {
4929 return {};
4930 }
4931 }, {
4932 key: "defaultData",
4933 value: function defaultData() {
4934 return {};
4935 }
4936 }, {
4937 key: "getCommands",
4938 value: function getCommands() {
4939 return this.commands;
4940 }
4941 }, {
4942 key: "getCommandsInternal",
4943 value: function getCommandsInternal() {
4944 return this.commandsInternal;
4945 }
4946 }, {
4947 key: "getHooks",
4948 value: function getHooks() {
4949 return this.hooks;
4950 }
4951
4952 /**
4953 * Retrieve the component's UI states.
4954 *
4955 * @return {Object} UI states
4956 */
4957 }, {
4958 key: "getUiStates",
4959 value: function getUiStates() {
4960 return this.uiStates;
4961 }
4962
4963 /**
4964 * Retrieve the component's Redux Slice.
4965 *
4966 * @return {Object} Redux Slice
4967 */
4968 }, {
4969 key: "getStates",
4970 value: function getStates() {
4971 return this.states;
4972 }
4973 }, {
4974 key: "getRoutes",
4975 value: function getRoutes() {
4976 return this.routes;
4977 }
4978 }, {
4979 key: "getTabs",
4980 value: function getTabs() {
4981 return this.tabs;
4982 }
4983 }, {
4984 key: "getShortcuts",
4985 value: function getShortcuts() {
4986 return this.shortcuts;
4987 }
4988 }, {
4989 key: "getData",
4990 value: function getData() {
4991 return this.data;
4992 }
4993
4994 /**
4995 * @param {string} command
4996 * @param {(()=>{}|CommandInfra)} context
4997 * @param {'default'|'internal'|'data'} commandsType
4998 */
4999 }, {
5000 key: "registerCommand",
5001 value: function registerCommand(command, context) {
5002 var commandsType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
5003 var commandsManager;
5004 switch (commandsType) {
5005 case 'default':
5006 commandsManager = $e.commands;
5007 break;
5008 case 'internal':
5009 commandsManager = $e.commandsInternal;
5010 break;
5011 case 'data':
5012 commandsManager = $e.data;
5013 break;
5014 default:
5015 throw new Error("Invalid commands type: '".concat(command, "'"));
5016 }
5017 var fullCommand = this.getNamespace() + '/' + command,
5018 instanceType = context.getInstanceType ? context.getInstanceType() : false,
5019 registerConfig = {
5020 command: fullCommand,
5021 component: this
5022 };
5023
5024 // Support pure callback.
5025 if (!instanceType) {
5026 if ($e.devTools) {
5027 $e.devTools.log.warn("Attach command-callback-base, on command: '".concat(fullCommand, "', context is unknown type."));
5028 }
5029 registerConfig.callback = context;
5030
5031 // Unique class.
5032 context = /*#__PURE__*/function (_CommandCallbackBase) {
5033 function context() {
5034 (0, _classCallCheck2.default)(this, context);
5035 return _callSuper(this, context, arguments);
5036 }
5037 (0, _inherits2.default)(context, _CommandCallbackBase);
5038 return (0, _createClass2.default)(context);
5039 }(_commandCallbackBase.default);
5040 }
5041 context.setRegisterConfig(registerConfig);
5042 commandsManager.register(this, command, context);
5043 }
5044
5045 /**
5046 * @param {HookBase} instance
5047 */
5048 }, {
5049 key: "registerHook",
5050 value: function registerHook(instance) {
5051 return instance.register();
5052 }
5053 }, {
5054 key: "registerCommandInternal",
5055 value: function registerCommandInternal(command, context) {
5056 this.registerCommand(command, context, 'internal');
5057 }
5058
5059 /**
5060 * Register a UI state.
5061 *
5062 * @param {UiStateBase} instance - UI state instance.
5063 *
5064 * @return {void}
5065 */
5066 }, {
5067 key: "registerUiState",
5068 value: function registerUiState(instance) {
5069 $e.uiStates.register(instance);
5070 }
5071
5072 /**
5073 * Register a Redux Slice.
5074 *
5075 * @param {string} id - State id.
5076 * @param {Object} stateConfig - The state config.
5077 *
5078 * @return {void}
5079 */
5080 }, {
5081 key: "registerState",
5082 value: function registerState(id, stateConfig) {
5083 id = this.getNamespace() + (id ? "/".concat(id) : '');
5084 var slice = (0, _toolkit.createSlice)(_objectSpread(_objectSpread({}, stateConfig), {}, {
5085 name: id
5086 }));
5087 $e.store.register(id, slice);
5088 }
5089 }, {
5090 key: "registerRoute",
5091 value: function registerRoute(route, callback) {
5092 $e.routes.register(this, route, callback);
5093 }
5094 }, {
5095 key: "registerData",
5096 value: function registerData(command, context) {
5097 this.registerCommand(command, context, 'data');
5098 }
5099 }, {
5100 key: "unregisterRoute",
5101 value: function unregisterRoute(route) {
5102 $e.routes.unregister(this, route);
5103 }
5104 }, {
5105 key: "registerTabRoute",
5106 value: function registerTabRoute(tab) {
5107 var _this2 = this;
5108 this.registerRoute(tab, function (args) {
5109 return _this2.activateTab(tab, args);
5110 });
5111 }
5112 }, {
5113 key: "dependency",
5114 value: function dependency() {
5115 return true;
5116 }
5117 }, {
5118 key: "open",
5119 value: function open() {
5120 return true;
5121 }
5122 }, {
5123 key: "close",
5124 value: function close() {
5125 if (!this.isOpen) {
5126 return false;
5127 }
5128 this.isOpen = false;
5129 this.inactivate();
5130 $e.routes.clearCurrent(this.getNamespace());
5131 $e.routes.clearHistory(this.getServiceName());
5132 return true;
5133 }
5134 }, {
5135 key: "activate",
5136 value: function activate() {
5137 $e.components.activate(this.getNamespace());
5138 }
5139 }, {
5140 key: "inactivate",
5141 value: function inactivate() {
5142 $e.components.inactivate(this.getNamespace());
5143 }
5144 }, {
5145 key: "isActive",
5146 value: function isActive() {
5147 return $e.components.isActive(this.getNamespace());
5148 }
5149 }, {
5150 key: "onRoute",
5151 value: function onRoute(route) {
5152 this.toggleRouteClass(route, true);
5153 this.toggleHistoryClass();
5154 this.activate();
5155 this.trigger('route/open', route);
5156 }
5157 }, {
5158 key: "onCloseRoute",
5159 value: function onCloseRoute(route) {
5160 this.toggleRouteClass(route, false);
5161 this.inactivate();
5162 this.trigger('route/close', route);
5163 }
5164 }, {
5165 key: "setDefaultRoute",
5166 value: function setDefaultRoute(route) {
5167 this.defaultRoute = this.getNamespace() + '/' + route;
5168 }
5169 }, {
5170 key: "getDefaultRoute",
5171 value: function getDefaultRoute() {
5172 return this.defaultRoute;
5173 }
5174 }, {
5175 key: "removeTab",
5176 value: function removeTab(tab) {
5177 delete this.tabs[tab];
5178 this.unregisterRoute(tab);
5179 }
5180 }, {
5181 key: "hasTab",
5182 value: function hasTab(tab) {
5183 return !!this.tabs[tab];
5184 }
5185 }, {
5186 key: "addTab",
5187 value: function addTab(tab, args, position) {
5188 var _this3 = this;
5189 this.tabs[tab] = args;
5190 // It can be 0.
5191 if ('undefined' !== typeof position) {
5192 var newTabs = {};
5193 var ids = Object.keys(this.tabs);
5194 // Remove new tab
5195 ids.pop();
5196
5197 // Add it to position.
5198 ids.splice(position, 0, tab);
5199 ids.forEach(function (id) {
5200 newTabs[id] = _this3.tabs[id];
5201 });
5202 this.tabs = newTabs;
5203 }
5204 this.registerTabRoute(tab);
5205 }
5206 }, {
5207 key: "getTabsWrapperSelector",
5208 value: function getTabsWrapperSelector() {
5209 return '';
5210 }
5211 }, {
5212 key: "getTabRoute",
5213 value: function getTabRoute(tab) {
5214 return this.getNamespace() + '/' + tab;
5215 }
5216 }, {
5217 key: "renderTab",
5218 value: function renderTab(tab) {} // eslint-disable-line
5219 }, {
5220 key: "activateTab",
5221 value: function activateTab(tab, args) {
5222 var _this4 = this;
5223 this.renderTab(tab, args);
5224 jQuery(this.getTabsWrapperSelector() + ' .elementor-component-tab').off('click').on('click', function (event) {
5225 $e.route(_this4.getTabRoute(event.currentTarget.dataset.tab), args);
5226 }).removeClass('elementor-active').filter('[data-tab="' + tab + '"]').addClass('elementor-active');
5227 }
5228 }, {
5229 key: "getActiveTabConfig",
5230 value: function getActiveTabConfig() {
5231 return this.tabs[this.currentTab] || {};
5232 }
5233 }, {
5234 key: "getBodyClass",
5235 value: function getBodyClass(route) {
5236 return 'e-route-' + route.replace(/\//g, '-');
5237 }
5238
5239 /**
5240 * If command includes uppercase character convert it to lowercase and add `-`.
5241 * e.g: `CopyAll` is converted to `copy-all`.
5242 *
5243 * @param {string} commandName
5244 */
5245 }, {
5246 key: "normalizeCommandName",
5247 value: function normalizeCommandName(commandName) {
5248 return commandName.replace(/[A-Z]/g, function (match, offset) {
5249 return (offset > 0 ? '-' : '') + match.toLowerCase();
5250 });
5251 }
5252
5253 /**
5254 * @param {{}} commandsFromImport
5255 * @return {{}} imported commands
5256 */
5257 }, {
5258 key: "importCommands",
5259 value: function importCommands(commandsFromImport) {
5260 var _this5 = this;
5261 var commands = {};
5262
5263 // Convert `Commands` to `ComponentBase` workable format.
5264 Object.entries(commandsFromImport).forEach(function (_ref1) {
5265 var _ref10 = (0, _slicedToArray2.default)(_ref1, 2),
5266 className = _ref10[0],
5267 Class = _ref10[1];
5268 var command = _this5.normalizeCommandName(className);
5269 commands[command] = Class;
5270 });
5271 return commands;
5272 }
5273 }, {
5274 key: "importHooks",
5275 value: function importHooks(hooksFromImport) {
5276 var hooks = {};
5277 for (var key in hooksFromImport) {
5278 var hook = new hooksFromImport[key]();
5279 hooks[hook.getId()] = hook;
5280 }
5281 return hooks;
5282 }
5283
5284 /**
5285 * Import & initialize the component's UI states.
5286 * Should be used inside `defaultUiState()`.
5287 *
5288 * @param {Object} statesFromImport - UI states from import.
5289 *
5290 * @return {Object} UI States
5291 */
5292 }, {
5293 key: "importUiStates",
5294 value: function importUiStates(statesFromImport) {
5295 var _this6 = this;
5296 var uiStates = {};
5297 Object.values(statesFromImport).forEach(function (className) {
5298 var uiState = new className(_this6);
5299 uiStates[uiState.getId()] = uiState;
5300 });
5301 return uiStates;
5302 }
5303
5304 /**
5305 * Set a UI state value.
5306 * TODO: Should we provide such function? Maybe the developer should implicitly pass the full state ID?
5307 *
5308 * @param {string} state - Non-prefixed state ID.
5309 * @param {*} value - New state value.
5310 *
5311 * @return {void}
5312 */
5313 }, {
5314 key: "setUiState",
5315 value: function setUiState(state, value) {
5316 $e.uiStates.set("".concat(this.getNamespace(), "/").concat(state), value);
5317 }
5318 }, {
5319 key: "toggleRouteClass",
5320 value: function toggleRouteClass(route, state) {
5321 document.body.classList.toggle(this.getBodyClass(route), state);
5322 }
5323 }, {
5324 key: "toggleHistoryClass",
5325 value: function toggleHistoryClass() {
5326 document.body.classList.toggle('e-routes-has-history', !!$e.routes.getHistory(this.getServiceName()).length);
5327 }
5328 }]);
5329 }(_module.default);
5330
5331 /***/ }),
5332
5333 /***/ "../modules/web-cli/assets/js/modules/component-modal-base.js":
5334 /*!********************************************************************!*\
5335 !*** ../modules/web-cli/assets/js/modules/component-modal-base.js ***!
5336 \********************************************************************/
5337 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5338
5339 "use strict";
5340
5341
5342 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5343 var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "../node_modules/@babel/runtime/helpers/typeof.js");
5344 Object.defineProperty(exports, "__esModule", ({
5345 value: true
5346 }));
5347 exports["default"] = void 0;
5348 var _readOnlyError2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/readOnlyError */ "../node_modules/@babel/runtime/helpers/readOnlyError.js"));
5349 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5350 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5351 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5352 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5353 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
5354 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5355 var _componentBase = _interopRequireDefault(__webpack_require__(/*! ./component-base */ "../modules/web-cli/assets/js/modules/component-base.js"));
5356 var commands = _interopRequireWildcard(__webpack_require__(/*! ./commands/ */ "../modules/web-cli/assets/js/modules/commands/index.js"));
5357 var _forceMethodImplementation = _interopRequireDefault(__webpack_require__(/*! ../utils/force-method-implementation */ "../modules/web-cli/assets/js/utils/force-method-implementation.js"));
5358 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); }
5359 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)); }
5360 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5361 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; }
5362 var ComponentModalBase = exports["default"] = /*#__PURE__*/function (_ComponentBase) {
5363 function ComponentModalBase() {
5364 (0, _classCallCheck2.default)(this, ComponentModalBase);
5365 return _callSuper(this, ComponentModalBase, arguments);
5366 }
5367 (0, _inherits2.default)(ComponentModalBase, _ComponentBase);
5368 return (0, _createClass2.default)(ComponentModalBase, [{
5369 key: "registerAPI",
5370 value: function registerAPI() {
5371 var _this = this;
5372 _superPropGet(ComponentModalBase, "registerAPI", this, 3)([]);
5373 $e.shortcuts.register('esc', {
5374 scopes: [this.getNamespace()],
5375 callback: function callback() {
5376 return _this.close();
5377 }
5378 });
5379 }
5380 }, {
5381 key: "defaultCommands",
5382 value: function defaultCommands() {
5383 return this.importCommands(commands);
5384 }
5385 }, {
5386 key: "defaultRoutes",
5387 value: function defaultRoutes() {
5388 return {
5389 '': function _() {/* Nothing to do, it's already rendered. */}
5390 };
5391 }
5392 }, {
5393 key: "open",
5394 value: function open() {
5395 var _this2 = this;
5396 if (!this.layout) {
5397 var layout = this.getModalLayout();
5398 this.layout = new layout({
5399 component: this
5400 });
5401 this.layout.getModal().on('hide', function () {
5402 return _this2.close();
5403 });
5404 }
5405 this.layout.showModal();
5406 return true;
5407 }
5408 }, {
5409 key: "close",
5410 value: function close() {
5411 if (!_superPropGet(ComponentModalBase, "close", this, 3)([])) {
5412 return false;
5413 }
5414 var close = elementor.hooks.applyFilters('component/modal/close', this.layout.getModal().hide.bind(this.layout.getModal()), this);
5415 close();
5416 return true;
5417 }
5418 }, {
5419 key: "getModalLayout",
5420 value: function getModalLayout() {
5421 (0, _forceMethodImplementation.default)();
5422 }
5423 }]);
5424 }(_componentBase.default);
5425
5426 /***/ }),
5427
5428 /***/ "../modules/web-cli/assets/js/utils/console.js":
5429 /*!*****************************************************!*\
5430 !*** ../modules/web-cli/assets/js/utils/console.js ***!
5431 \*****************************************************/
5432 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5433
5434 "use strict";
5435
5436
5437 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5438 Object.defineProperty(exports, "__esModule", ({
5439 value: true
5440 }));
5441 exports["default"] = void 0;
5442 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5443 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5444 var Console = exports["default"] = /*#__PURE__*/function () {
5445 function Console() {
5446 (0, _classCallCheck2.default)(this, Console);
5447 }
5448 return (0, _createClass2.default)(Console, null, [{
5449 key: "error",
5450 value: function error(message) {
5451 // Show an error if devTools is available.
5452 if ($e.devTools) {
5453 $e.devTools.log.error(message);
5454 }
5455
5456 // If not a 'Hook-Break' then show error.
5457 if (!(message instanceof $e.modules.HookBreak)) {
5458 // eslint-disable-next-line no-console
5459 console.error(message);
5460 }
5461 }
5462 }, {
5463 key: "warn",
5464 value: function warn() {
5465 var _console;
5466 var style = "font-size: 12px; background-image: url(\"".concat(elementorWebCliConfig.urls.assets, "images/logo-icon.png\"); background-repeat: no-repeat; background-size: contain;");
5467 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5468 args[_key] = arguments[_key];
5469 }
5470 args.unshift('%c %c', style, '');
5471 (_console = console).warn.apply(_console, args); // eslint-disable-line no-console
5472 }
5473 }]);
5474 }();
5475
5476 /***/ }),
5477
5478 /***/ "../modules/web-cli/assets/js/utils/deprecation.js":
5479 /*!*********************************************************!*\
5480 !*** ../modules/web-cli/assets/js/utils/deprecation.js ***!
5481 \*********************************************************/
5482 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5483
5484 "use strict";
5485
5486
5487 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5488 Object.defineProperty(exports, "__esModule", ({
5489 value: true
5490 }));
5491 exports["default"] = void 0;
5492 var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "../node_modules/@babel/runtime/helpers/slicedToArray.js"));
5493 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5494 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5495 var _console = _interopRequireDefault(__webpack_require__(/*! elementor-api/utils/console */ "../modules/web-cli/assets/js/utils/console.js"));
5496 // Copied from `modules/dev-tools/assets/js/deprecation.js`
5497 /**
5498 * @typedef {Object} Version
5499 * @property {number} major1 The first number
5500 * @property {number} major2 The second number
5501 * @property {number} minor The third number
5502 * @property {string} build The fourth number
5503 */
5504
5505 var softDeprecated = function softDeprecated(name, version, replacement) {
5506 if (elementorWebCliConfig.isDebug) {
5507 deprecatedMessage('soft', name, version, replacement);
5508 }
5509 };
5510 var hardDeprecated = function hardDeprecated(name, version, replacement) {
5511 deprecatedMessage('hard', name, version, replacement);
5512 };
5513 var deprecatedMessage = function deprecatedMessage(type, name, version, replacement) {
5514 var message = "`".concat(name, "` is ").concat(type, " deprecated since ").concat(version);
5515 if (replacement) {
5516 message += " - Use `".concat(replacement, "` instead");
5517 }
5518 _console.default.warn(message);
5519 };
5520 var Deprecation = exports["default"] = /*#__PURE__*/function () {
5521 function Deprecation() {
5522 (0, _classCallCheck2.default)(this, Deprecation);
5523 }
5524 return (0, _createClass2.default)(Deprecation, null, [{
5525 key: "deprecated",
5526 value: function deprecated(name, version, replacement) {
5527 if (this.isHardDeprecated(version)) {
5528 hardDeprecated(name, version, replacement);
5529 } else {
5530 softDeprecated(name, version, replacement);
5531 }
5532 }
5533
5534 /**
5535 * @param {string} version
5536 *
5537 * @return {Version}
5538 */
5539 }, {
5540 key: "parseVersion",
5541 value: function parseVersion(version) {
5542 var versionParts = version.split('.');
5543 if (versionParts.length < 3 || versionParts.length > 4) {
5544 throw new RangeError('Invalid Semantic Version string provided');
5545 }
5546 var _versionParts = (0, _slicedToArray2.default)(versionParts, 4),
5547 major1 = _versionParts[0],
5548 major2 = _versionParts[1],
5549 minor = _versionParts[2],
5550 _versionParts$ = _versionParts[3],
5551 build = _versionParts$ === void 0 ? '' : _versionParts$;
5552 return {
5553 major1: parseInt(major1),
5554 major2: parseInt(major2),
5555 minor: parseInt(minor),
5556 build: build
5557 };
5558 }
5559
5560 /**
5561 * Get total of major.
5562 *
5563 * 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,
5564 * versions with major2 more then 9 will be added to total.
5565 *
5566 * @param {Version} versionObj
5567 *
5568 * @return {number}
5569 */
5570 }, {
5571 key: "getTotalMajor",
5572 value: function getTotalMajor(versionObj) {
5573 var total = parseInt("".concat(versionObj.major1).concat(versionObj.major2, "0"));
5574 total = Number((total / 10).toFixed(0));
5575 if (versionObj.major2 > 9) {
5576 total = versionObj.major2 - 9;
5577 }
5578 return total;
5579 }
5580
5581 /**
5582 * @param {string} version1
5583 * @param {string} version2
5584 *
5585 * @return {number}
5586 */
5587 }, {
5588 key: "compareVersion",
5589 value: function compareVersion(version1, version2) {
5590 var _this = this;
5591 return [this.parseVersion(version1), this.parseVersion(version2)].map(function (versionObj) {
5592 return _this.getTotalMajor(versionObj);
5593 }).reduce(function (acc, major) {
5594 return acc - major;
5595 });
5596 }
5597
5598 /**
5599 * @param {string} version
5600 *
5601 * @return {boolean}
5602 */
5603 }, {
5604 key: "isSoftDeprecated",
5605 value: function isSoftDeprecated(version) {
5606 var total = this.compareVersion(version, elementorWebCliConfig.version);
5607 return total <= 4;
5608 }
5609
5610 /**
5611 * @param {string} version
5612 * @return {boolean}
5613 */
5614 }, {
5615 key: "isHardDeprecated",
5616 value: function isHardDeprecated(version) {
5617 var total = this.compareVersion(version, elementorWebCliConfig.version);
5618 return total < 0 || total >= 8;
5619 }
5620 }]);
5621 }();
5622
5623 /***/ }),
5624
5625 /***/ "../modules/web-cli/assets/js/utils/force-method-implementation.js":
5626 /*!*************************************************************************!*\
5627 !*** ../modules/web-cli/assets/js/utils/force-method-implementation.js ***!
5628 \*************************************************************************/
5629 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
5630
5631 "use strict";
5632
5633
5634 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5635 Object.defineProperty(exports, "__esModule", ({
5636 value: true
5637 }));
5638 exports["default"] = exports.ForceMethodImplementation = void 0;
5639 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
5640 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
5641 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
5642 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
5643 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
5644 var _wrapNativeSuper2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/wrapNativeSuper */ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js"));
5645 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)); }
5646 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
5647 // TODO: Copied from `assets/dev/js/modules/imports/force-method-implementation.js`;
5648 var ForceMethodImplementation = exports.ForceMethodImplementation = /*#__PURE__*/function (_Error) {
5649 function ForceMethodImplementation() {
5650 var _this;
5651 var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5652 (0, _classCallCheck2.default)(this, ForceMethodImplementation);
5653 _this = _callSuper(this, ForceMethodImplementation, ["".concat(info.isStatic ? 'static ' : '').concat(info.fullName, "() should be implemented, please provide '").concat(info.functionName || info.fullName, "' functionality.")]);
5654 Error.captureStackTrace(_this, ForceMethodImplementation);
5655 return _this;
5656 }
5657 (0, _inherits2.default)(ForceMethodImplementation, _Error);
5658 return (0, _createClass2.default)(ForceMethodImplementation);
5659 }(/*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
5660 var _default = exports["default"] = function _default() {
5661 var stack = Error().stack,
5662 caller = stack.split('\n')[2].trim(),
5663 callerName = caller.startsWith('at new') ? 'constructor' : caller.split(' ')[1],
5664 info = {};
5665 info.functionName = callerName;
5666 info.fullName = callerName;
5667 if (info.functionName.includes('.')) {
5668 var parts = info.functionName.split('.');
5669 info.className = parts[0];
5670 info.functionName = parts[1];
5671 } else {
5672 info.isStatic = true;
5673 }
5674 throw new ForceMethodImplementation(info);
5675 };
5676
5677 /***/ }),
5678
5679 /***/ "../node_modules/@babel/runtime/helpers/OverloadYield.js":
5680 /*!***************************************************************!*\
5681 !*** ../node_modules/@babel/runtime/helpers/OverloadYield.js ***!
5682 \***************************************************************/
5683 /***/ ((module) => {
5684
5685 function _OverloadYield(e, d) {
5686 this.v = e, this.k = d;
5687 }
5688 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
5689
5690 /***/ }),
5691
5692 /***/ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
5693 /*!******************************************************************!*\
5694 !*** ../node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
5695 \******************************************************************/
5696 /***/ ((module) => {
5697
5698 function _arrayLikeToArray(r, a) {
5699 (null == a || a > r.length) && (a = r.length);
5700 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
5701 return n;
5702 }
5703 module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
5704
5705 /***/ }),
5706
5707 /***/ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js":
5708 /*!****************************************************************!*\
5709 !*** ../node_modules/@babel/runtime/helpers/arrayWithHoles.js ***!
5710 \****************************************************************/
5711 /***/ ((module) => {
5712
5713 function _arrayWithHoles(r) {
5714 if (Array.isArray(r)) return r;
5715 }
5716 module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
5717
5718 /***/ }),
5719
5720 /***/ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js":
5721 /*!***********************************************************************!*\
5722 !*** ../node_modules/@babel/runtime/helpers/assertThisInitialized.js ***!
5723 \***********************************************************************/
5724 /***/ ((module) => {
5725
5726 function _assertThisInitialized(e) {
5727 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5728 return e;
5729 }
5730 module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
5731
5732 /***/ }),
5733
5734 /***/ "../node_modules/@babel/runtime/helpers/asyncToGenerator.js":
5735 /*!******************************************************************!*\
5736 !*** ../node_modules/@babel/runtime/helpers/asyncToGenerator.js ***!
5737 \******************************************************************/
5738 /***/ ((module) => {
5739
5740 function asyncGeneratorStep(n, t, e, r, o, a, c) {
5741 try {
5742 var i = n[a](c),
5743 u = i.value;
5744 } catch (n) {
5745 return void e(n);
5746 }
5747 i.done ? t(u) : Promise.resolve(u).then(r, o);
5748 }
5749 function _asyncToGenerator(n) {
5750 return function () {
5751 var t = this,
5752 e = arguments;
5753 return new Promise(function (r, o) {
5754 var a = n.apply(t, e);
5755 function _next(n) {
5756 asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
5757 }
5758 function _throw(n) {
5759 asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
5760 }
5761 _next(void 0);
5762 });
5763 };
5764 }
5765 module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
5766
5767 /***/ }),
5768
5769 /***/ "../node_modules/@babel/runtime/helpers/classCallCheck.js":
5770 /*!****************************************************************!*\
5771 !*** ../node_modules/@babel/runtime/helpers/classCallCheck.js ***!
5772 \****************************************************************/
5773 /***/ ((module) => {
5774
5775 function _classCallCheck(a, n) {
5776 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
5777 }
5778 module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
5779
5780 /***/ }),
5781
5782 /***/ "../node_modules/@babel/runtime/helpers/construct.js":
5783 /*!***********************************************************!*\
5784 !*** ../node_modules/@babel/runtime/helpers/construct.js ***!
5785 \***********************************************************/
5786 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5787
5788 var isNativeReflectConstruct = __webpack_require__(/*! ./isNativeReflectConstruct.js */ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js");
5789 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
5790 function _construct(t, e, r) {
5791 if (isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
5792 var o = [null];
5793 o.push.apply(o, e);
5794 var p = new (t.bind.apply(t, o))();
5795 return r && setPrototypeOf(p, r.prototype), p;
5796 }
5797 module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
5798
5799 /***/ }),
5800
5801 /***/ "../node_modules/@babel/runtime/helpers/createClass.js":
5802 /*!*************************************************************!*\
5803 !*** ../node_modules/@babel/runtime/helpers/createClass.js ***!
5804 \*************************************************************/
5805 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5806
5807 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5808 function _defineProperties(e, r) {
5809 for (var t = 0; t < r.length; t++) {
5810 var o = r[t];
5811 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
5812 }
5813 }
5814 function _createClass(e, r, t) {
5815 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
5816 writable: !1
5817 }), e;
5818 }
5819 module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
5820
5821 /***/ }),
5822
5823 /***/ "../node_modules/@babel/runtime/helpers/defineProperty.js":
5824 /*!****************************************************************!*\
5825 !*** ../node_modules/@babel/runtime/helpers/defineProperty.js ***!
5826 \****************************************************************/
5827 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5828
5829 var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/toPropertyKey.js");
5830 function _defineProperty(e, r, t) {
5831 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5832 value: t,
5833 enumerable: !0,
5834 configurable: !0,
5835 writable: !0
5836 }) : e[r] = t, e;
5837 }
5838 module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
5839
5840 /***/ }),
5841
5842 /***/ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js":
5843 /*!********************************************************************!*\
5844 !*** ../node_modules/@babel/runtime/helpers/esm/defineProperty.js ***!
5845 \********************************************************************/
5846 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5847
5848 "use strict";
5849 __webpack_require__.r(__webpack_exports__);
5850 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5851 /* harmony export */ "default": () => (/* binding */ _defineProperty)
5852 /* harmony export */ });
5853 /* harmony import */ var _toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./toPropertyKey.js */ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js");
5854
5855 function _defineProperty(e, r, t) {
5856 return (r = (0,_toPropertyKey_js__WEBPACK_IMPORTED_MODULE_0__["default"])(r)) in e ? Object.defineProperty(e, r, {
5857 value: t,
5858 enumerable: !0,
5859 configurable: !0,
5860 writable: !0
5861 }) : e[r] = t, e;
5862 }
5863
5864
5865 /***/ }),
5866
5867 /***/ "../node_modules/@babel/runtime/helpers/esm/objectSpread2.js":
5868 /*!*******************************************************************!*\
5869 !*** ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js ***!
5870 \*******************************************************************/
5871 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5872
5873 "use strict";
5874 __webpack_require__.r(__webpack_exports__);
5875 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5876 /* harmony export */ "default": () => (/* binding */ _objectSpread2)
5877 /* harmony export */ });
5878 /* harmony import */ var _defineProperty_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defineProperty.js */ "../node_modules/@babel/runtime/helpers/esm/defineProperty.js");
5879
5880 function ownKeys(e, r) {
5881 var t = Object.keys(e);
5882 if (Object.getOwnPropertySymbols) {
5883 var o = Object.getOwnPropertySymbols(e);
5884 r && (o = o.filter(function (r) {
5885 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5886 })), t.push.apply(t, o);
5887 }
5888 return t;
5889 }
5890 function _objectSpread2(e) {
5891 for (var r = 1; r < arguments.length; r++) {
5892 var t = null != arguments[r] ? arguments[r] : {};
5893 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
5894 (0,_defineProperty_js__WEBPACK_IMPORTED_MODULE_0__["default"])(e, r, t[r]);
5895 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
5896 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5897 });
5898 }
5899 return e;
5900 }
5901
5902
5903 /***/ }),
5904
5905 /***/ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js":
5906 /*!*****************************************************************!*\
5907 !*** ../node_modules/@babel/runtime/helpers/esm/toPrimitive.js ***!
5908 \*****************************************************************/
5909 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5910
5911 "use strict";
5912 __webpack_require__.r(__webpack_exports__);
5913 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5914 /* harmony export */ "default": () => (/* binding */ toPrimitive)
5915 /* harmony export */ });
5916 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5917
5918 function toPrimitive(t, r) {
5919 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(t) || !t) return t;
5920 var e = t[Symbol.toPrimitive];
5921 if (void 0 !== e) {
5922 var i = e.call(t, r || "default");
5923 if ("object" != (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i)) return i;
5924 throw new TypeError("@@toPrimitive must return a primitive value.");
5925 }
5926 return ("string" === r ? String : Number)(t);
5927 }
5928
5929
5930 /***/ }),
5931
5932 /***/ "../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js":
5933 /*!*******************************************************************!*\
5934 !*** ../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js ***!
5935 \*******************************************************************/
5936 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5937
5938 "use strict";
5939 __webpack_require__.r(__webpack_exports__);
5940 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5941 /* harmony export */ "default": () => (/* binding */ toPropertyKey)
5942 /* harmony export */ });
5943 /* harmony import */ var _typeof_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/esm/typeof.js");
5944 /* harmony import */ var _toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/esm/toPrimitive.js");
5945
5946
5947 function toPropertyKey(t) {
5948 var i = (0,_toPrimitive_js__WEBPACK_IMPORTED_MODULE_1__["default"])(t, "string");
5949 return "symbol" == (0,_typeof_js__WEBPACK_IMPORTED_MODULE_0__["default"])(i) ? i : i + "";
5950 }
5951
5952
5953 /***/ }),
5954
5955 /***/ "../node_modules/@babel/runtime/helpers/esm/typeof.js":
5956 /*!************************************************************!*\
5957 !*** ../node_modules/@babel/runtime/helpers/esm/typeof.js ***!
5958 \************************************************************/
5959 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
5960
5961 "use strict";
5962 __webpack_require__.r(__webpack_exports__);
5963 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5964 /* harmony export */ "default": () => (/* binding */ _typeof)
5965 /* harmony export */ });
5966 function _typeof(o) {
5967 "@babel/helpers - typeof";
5968
5969 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5970 return typeof o;
5971 } : function (o) {
5972 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5973 }, _typeof(o);
5974 }
5975
5976
5977 /***/ }),
5978
5979 /***/ "../node_modules/@babel/runtime/helpers/get.js":
5980 /*!*****************************************************!*\
5981 !*** ../node_modules/@babel/runtime/helpers/get.js ***!
5982 \*****************************************************/
5983 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
5984
5985 var superPropBase = __webpack_require__(/*! ./superPropBase.js */ "../node_modules/@babel/runtime/helpers/superPropBase.js");
5986 function _get() {
5987 return module.exports = _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
5988 var p = superPropBase(e, t);
5989 if (p) {
5990 var n = Object.getOwnPropertyDescriptor(p, t);
5991 return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
5992 }
5993 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _get.apply(null, arguments);
5994 }
5995 module.exports = _get, module.exports.__esModule = true, module.exports["default"] = module.exports;
5996
5997 /***/ }),
5998
5999 /***/ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js":
6000 /*!****************************************************************!*\
6001 !*** ../node_modules/@babel/runtime/helpers/getPrototypeOf.js ***!
6002 \****************************************************************/
6003 /***/ ((module) => {
6004
6005 function _getPrototypeOf(t) {
6006 return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
6007 return t.__proto__ || Object.getPrototypeOf(t);
6008 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _getPrototypeOf(t);
6009 }
6010 module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6011
6012 /***/ }),
6013
6014 /***/ "../node_modules/@babel/runtime/helpers/inherits.js":
6015 /*!**********************************************************!*\
6016 !*** ../node_modules/@babel/runtime/helpers/inherits.js ***!
6017 \**********************************************************/
6018 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6019
6020 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6021 function _inherits(t, e) {
6022 if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
6023 t.prototype = Object.create(e && e.prototype, {
6024 constructor: {
6025 value: t,
6026 writable: !0,
6027 configurable: !0
6028 }
6029 }), Object.defineProperty(t, "prototype", {
6030 writable: !1
6031 }), e && setPrototypeOf(t, e);
6032 }
6033 module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
6034
6035 /***/ }),
6036
6037 /***/ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js":
6038 /*!***********************************************************************!*\
6039 !*** ../node_modules/@babel/runtime/helpers/interopRequireDefault.js ***!
6040 \***********************************************************************/
6041 /***/ ((module) => {
6042
6043 function _interopRequireDefault(e) {
6044 return e && e.__esModule ? e : {
6045 "default": e
6046 };
6047 }
6048 module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
6049
6050 /***/ }),
6051
6052 /***/ "../node_modules/@babel/runtime/helpers/isNativeFunction.js":
6053 /*!******************************************************************!*\
6054 !*** ../node_modules/@babel/runtime/helpers/isNativeFunction.js ***!
6055 \******************************************************************/
6056 /***/ ((module) => {
6057
6058 function _isNativeFunction(t) {
6059 try {
6060 return -1 !== Function.toString.call(t).indexOf("[native code]");
6061 } catch (n) {
6062 return "function" == typeof t;
6063 }
6064 }
6065 module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports;
6066
6067 /***/ }),
6068
6069 /***/ "../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js":
6070 /*!**************************************************************************!*\
6071 !*** ../node_modules/@babel/runtime/helpers/isNativeReflectConstruct.js ***!
6072 \**************************************************************************/
6073 /***/ ((module) => {
6074
6075 function _isNativeReflectConstruct() {
6076 try {
6077 var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
6078 } catch (t) {}
6079 return (module.exports = _isNativeReflectConstruct = function _isNativeReflectConstruct() {
6080 return !!t;
6081 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6082 }
6083 module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
6084
6085 /***/ }),
6086
6087 /***/ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":
6088 /*!**********************************************************************!*\
6089 !*** ../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js ***!
6090 \**********************************************************************/
6091 /***/ ((module) => {
6092
6093 function _iterableToArrayLimit(r, l) {
6094 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
6095 if (null != t) {
6096 var e,
6097 n,
6098 i,
6099 u,
6100 a = [],
6101 f = !0,
6102 o = !1;
6103 try {
6104 if (i = (t = t.call(r)).next, 0 === l) {
6105 if (Object(t) !== t) return;
6106 f = !1;
6107 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
6108 } catch (r) {
6109 o = !0, n = r;
6110 } finally {
6111 try {
6112 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
6113 } finally {
6114 if (o) throw n;
6115 }
6116 }
6117 return a;
6118 }
6119 }
6120 module.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports["default"] = module.exports;
6121
6122 /***/ }),
6123
6124 /***/ "../node_modules/@babel/runtime/helpers/nonIterableRest.js":
6125 /*!*****************************************************************!*\
6126 !*** ../node_modules/@babel/runtime/helpers/nonIterableRest.js ***!
6127 \*****************************************************************/
6128 /***/ ((module) => {
6129
6130 function _nonIterableRest() {
6131 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6132 }
6133 module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
6134
6135 /***/ }),
6136
6137 /***/ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js":
6138 /*!***************************************************************************!*\
6139 !*** ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js ***!
6140 \***************************************************************************/
6141 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6142
6143 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6144 var assertThisInitialized = __webpack_require__(/*! ./assertThisInitialized.js */ "../node_modules/@babel/runtime/helpers/assertThisInitialized.js");
6145 function _possibleConstructorReturn(t, e) {
6146 if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
6147 if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
6148 return assertThisInitialized(t);
6149 }
6150 module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
6151
6152 /***/ }),
6153
6154 /***/ "../node_modules/@babel/runtime/helpers/readOnlyError.js":
6155 /*!***************************************************************!*\
6156 !*** ../node_modules/@babel/runtime/helpers/readOnlyError.js ***!
6157 \***************************************************************/
6158 /***/ ((module) => {
6159
6160 function _readOnlyError(r) {
6161 throw new TypeError('"' + r + '" is read-only');
6162 }
6163 module.exports = _readOnlyError, module.exports.__esModule = true, module.exports["default"] = module.exports;
6164
6165 /***/ }),
6166
6167 /***/ "../node_modules/@babel/runtime/helpers/regenerator.js":
6168 /*!*************************************************************!*\
6169 !*** ../node_modules/@babel/runtime/helpers/regenerator.js ***!
6170 \*************************************************************/
6171 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6172
6173 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6174 function _regenerator() {
6175 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
6176 var e,
6177 t,
6178 r = "function" == typeof Symbol ? Symbol : {},
6179 n = r.iterator || "@@iterator",
6180 o = r.toStringTag || "@@toStringTag";
6181 function i(r, n, o, i) {
6182 var c = n && n.prototype instanceof Generator ? n : Generator,
6183 u = Object.create(c.prototype);
6184 return regeneratorDefine(u, "_invoke", function (r, n, o) {
6185 var i,
6186 c,
6187 u,
6188 f = 0,
6189 p = o || [],
6190 y = !1,
6191 G = {
6192 p: 0,
6193 n: 0,
6194 v: e,
6195 a: d,
6196 f: d.bind(e, 4),
6197 d: function d(t, r) {
6198 return i = t, c = 0, u = e, G.n = r, a;
6199 }
6200 };
6201 function d(r, n) {
6202 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
6203 var o,
6204 i = p[t],
6205 d = G.p,
6206 l = i[2];
6207 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));
6208 }
6209 if (o || r > 1) return a;
6210 throw y = !0, n;
6211 }
6212 return function (o, p, l) {
6213 if (f > 1) throw TypeError("Generator is already running");
6214 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
6215 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
6216 try {
6217 if (f = 2, i) {
6218 if (c || (o = "next"), t = i[o]) {
6219 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
6220 if (!t.done) return t;
6221 u = t.value, c < 2 && (c = 0);
6222 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
6223 i = e;
6224 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
6225 } catch (t) {
6226 i = e, c = 1, u = t;
6227 } finally {
6228 f = 1;
6229 }
6230 }
6231 return {
6232 value: t,
6233 done: y
6234 };
6235 };
6236 }(r, o, i), !0), u;
6237 }
6238 var a = {};
6239 function Generator() {}
6240 function GeneratorFunction() {}
6241 function GeneratorFunctionPrototype() {}
6242 t = Object.getPrototypeOf;
6243 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function () {
6244 return this;
6245 }), t),
6246 u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
6247 function f(e) {
6248 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
6249 }
6250 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 () {
6251 return this;
6252 }), regeneratorDefine(u, "toString", function () {
6253 return "[object Generator]";
6254 }), (module.exports = _regenerator = function _regenerator() {
6255 return {
6256 w: i,
6257 m: f
6258 };
6259 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6260 }
6261 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6262
6263 /***/ }),
6264
6265 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js":
6266 /*!******************************************************************!*\
6267 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsync.js ***!
6268 \******************************************************************/
6269 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6270
6271 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6272 function _regeneratorAsync(n, e, r, t, o) {
6273 var a = regeneratorAsyncGen(n, e, r, t, o);
6274 return a.next().then(function (n) {
6275 return n.done ? n.value : a.next();
6276 });
6277 }
6278 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
6279
6280 /***/ }),
6281
6282 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js":
6283 /*!*********************************************************************!*\
6284 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js ***!
6285 \*********************************************************************/
6286 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6287
6288 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6289 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6290 function _regeneratorAsyncGen(r, e, t, o, n) {
6291 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
6292 }
6293 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
6294
6295 /***/ }),
6296
6297 /***/ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js":
6298 /*!**************************************************************************!*\
6299 !*** ../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js ***!
6300 \**************************************************************************/
6301 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6302
6303 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6304 var regeneratorDefine = __webpack_require__(/*! ./regeneratorDefine.js */ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js");
6305 function AsyncIterator(t, e) {
6306 function n(r, o, i, f) {
6307 try {
6308 var c = t[r](o),
6309 u = c.value;
6310 return u instanceof OverloadYield ? e.resolve(u.v).then(function (t) {
6311 n("next", t, i, f);
6312 }, function (t) {
6313 n("throw", t, i, f);
6314 }) : e.resolve(u).then(function (t) {
6315 c.value = t, i(c);
6316 }, function (t) {
6317 return n("throw", t, i, f);
6318 });
6319 } catch (t) {
6320 f(t);
6321 }
6322 }
6323 var r;
6324 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
6325 return this;
6326 })), regeneratorDefine(this, "_invoke", function (t, o, i) {
6327 function f() {
6328 return new e(function (e, r) {
6329 n(t, i, e, r);
6330 });
6331 }
6332 return r = r ? r.then(f, f) : f();
6333 }, !0);
6334 }
6335 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
6336
6337 /***/ }),
6338
6339 /***/ "../node_modules/@babel/runtime/helpers/regeneratorDefine.js":
6340 /*!*******************************************************************!*\
6341 !*** ../node_modules/@babel/runtime/helpers/regeneratorDefine.js ***!
6342 \*******************************************************************/
6343 /***/ ((module) => {
6344
6345 function _regeneratorDefine(e, r, n, t) {
6346 var i = Object.defineProperty;
6347 try {
6348 i({}, "", {});
6349 } catch (e) {
6350 i = 0;
6351 }
6352 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
6353 function o(r, n) {
6354 _regeneratorDefine(e, r, function (e) {
6355 return this._invoke(r, n, e);
6356 });
6357 }
6358 r ? i ? i(e, r, {
6359 value: n,
6360 enumerable: !t,
6361 configurable: !t,
6362 writable: !t
6363 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
6364 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
6365 }
6366 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
6367
6368 /***/ }),
6369
6370 /***/ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js":
6371 /*!*****************************************************************!*\
6372 !*** ../node_modules/@babel/runtime/helpers/regeneratorKeys.js ***!
6373 \*****************************************************************/
6374 /***/ ((module) => {
6375
6376 function _regeneratorKeys(e) {
6377 var n = Object(e),
6378 r = [];
6379 for (var t in n) r.unshift(t);
6380 return function e() {
6381 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
6382 return e.done = !0, e;
6383 };
6384 }
6385 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
6386
6387 /***/ }),
6388
6389 /***/ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js":
6390 /*!********************************************************************!*\
6391 !*** ../node_modules/@babel/runtime/helpers/regeneratorRuntime.js ***!
6392 \********************************************************************/
6393 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6394
6395 var OverloadYield = __webpack_require__(/*! ./OverloadYield.js */ "../node_modules/@babel/runtime/helpers/OverloadYield.js");
6396 var regenerator = __webpack_require__(/*! ./regenerator.js */ "../node_modules/@babel/runtime/helpers/regenerator.js");
6397 var regeneratorAsync = __webpack_require__(/*! ./regeneratorAsync.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsync.js");
6398 var regeneratorAsyncGen = __webpack_require__(/*! ./regeneratorAsyncGen.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js");
6399 var regeneratorAsyncIterator = __webpack_require__(/*! ./regeneratorAsyncIterator.js */ "../node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js");
6400 var regeneratorKeys = __webpack_require__(/*! ./regeneratorKeys.js */ "../node_modules/@babel/runtime/helpers/regeneratorKeys.js");
6401 var regeneratorValues = __webpack_require__(/*! ./regeneratorValues.js */ "../node_modules/@babel/runtime/helpers/regeneratorValues.js");
6402 function _regeneratorRuntime() {
6403 "use strict";
6404
6405 var r = regenerator(),
6406 e = r.m(_regeneratorRuntime),
6407 t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
6408 function n(r) {
6409 var e = "function" == typeof r && r.constructor;
6410 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
6411 }
6412 var o = {
6413 "throw": 1,
6414 "return": 2,
6415 "break": 3,
6416 "continue": 3
6417 };
6418 function a(r) {
6419 var e, t;
6420 return function (n) {
6421 e || (e = {
6422 stop: function stop() {
6423 return t(n.a, 2);
6424 },
6425 "catch": function _catch() {
6426 return n.v;
6427 },
6428 abrupt: function abrupt(r, e) {
6429 return t(n.a, o[r], e);
6430 },
6431 delegateYield: function delegateYield(r, o, a) {
6432 return e.resultName = o, t(n.d, regeneratorValues(r), a);
6433 },
6434 finish: function finish(r) {
6435 return t(n.f, r);
6436 }
6437 }, t = function t(r, _t, o) {
6438 n.p = e.prev, n.n = e.next;
6439 try {
6440 return r(_t, o);
6441 } finally {
6442 e.next = n.n;
6443 }
6444 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
6445 try {
6446 return r.call(this, e);
6447 } finally {
6448 n.p = e.prev, n.n = e.next;
6449 }
6450 };
6451 }
6452 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
6453 return {
6454 wrap: function wrap(e, t, n, o) {
6455 return r.w(a(e), t, n, o && o.reverse());
6456 },
6457 isGeneratorFunction: n,
6458 mark: r.m,
6459 awrap: function awrap(r, e) {
6460 return new OverloadYield(r, e);
6461 },
6462 AsyncIterator: regeneratorAsyncIterator,
6463 async: function async(r, e, t, o, u) {
6464 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
6465 },
6466 keys: regeneratorKeys,
6467 values: regeneratorValues
6468 };
6469 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
6470 }
6471 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
6472
6473 /***/ }),
6474
6475 /***/ "../node_modules/@babel/runtime/helpers/regeneratorValues.js":
6476 /*!*******************************************************************!*\
6477 !*** ../node_modules/@babel/runtime/helpers/regeneratorValues.js ***!
6478 \*******************************************************************/
6479 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6480
6481 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6482 function _regeneratorValues(e) {
6483 if (null != e) {
6484 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
6485 r = 0;
6486 if (t) return t.call(e);
6487 if ("function" == typeof e.next) return e;
6488 if (!isNaN(e.length)) return {
6489 next: function next() {
6490 return e && r >= e.length && (e = void 0), {
6491 value: e && e[r++],
6492 done: !e
6493 };
6494 }
6495 };
6496 }
6497 throw new TypeError(_typeof(e) + " is not iterable");
6498 }
6499 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
6500
6501 /***/ }),
6502
6503 /***/ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js":
6504 /*!****************************************************************!*\
6505 !*** ../node_modules/@babel/runtime/helpers/setPrototypeOf.js ***!
6506 \****************************************************************/
6507 /***/ ((module) => {
6508
6509 function _setPrototypeOf(t, e) {
6510 return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
6511 return t.__proto__ = e, t;
6512 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _setPrototypeOf(t, e);
6513 }
6514 module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
6515
6516 /***/ }),
6517
6518 /***/ "../node_modules/@babel/runtime/helpers/slicedToArray.js":
6519 /*!***************************************************************!*\
6520 !*** ../node_modules/@babel/runtime/helpers/slicedToArray.js ***!
6521 \***************************************************************/
6522 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6523
6524 var arrayWithHoles = __webpack_require__(/*! ./arrayWithHoles.js */ "../node_modules/@babel/runtime/helpers/arrayWithHoles.js");
6525 var iterableToArrayLimit = __webpack_require__(/*! ./iterableToArrayLimit.js */ "../node_modules/@babel/runtime/helpers/iterableToArrayLimit.js");
6526 var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
6527 var nonIterableRest = __webpack_require__(/*! ./nonIterableRest.js */ "../node_modules/@babel/runtime/helpers/nonIterableRest.js");
6528 function _slicedToArray(r, e) {
6529 return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();
6530 }
6531 module.exports = _slicedToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6532
6533 /***/ }),
6534
6535 /***/ "../node_modules/@babel/runtime/helpers/superPropBase.js":
6536 /*!***************************************************************!*\
6537 !*** ../node_modules/@babel/runtime/helpers/superPropBase.js ***!
6538 \***************************************************************/
6539 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6540
6541 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6542 function _superPropBase(t, o) {
6543 for (; !{}.hasOwnProperty.call(t, o) && null !== (t = getPrototypeOf(t)););
6544 return t;
6545 }
6546 module.exports = _superPropBase, module.exports.__esModule = true, module.exports["default"] = module.exports;
6547
6548 /***/ }),
6549
6550 /***/ "../node_modules/@babel/runtime/helpers/toPrimitive.js":
6551 /*!*************************************************************!*\
6552 !*** ../node_modules/@babel/runtime/helpers/toPrimitive.js ***!
6553 \*************************************************************/
6554 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6555
6556 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6557 function toPrimitive(t, r) {
6558 if ("object" != _typeof(t) || !t) return t;
6559 var e = t[Symbol.toPrimitive];
6560 if (void 0 !== e) {
6561 var i = e.call(t, r || "default");
6562 if ("object" != _typeof(i)) return i;
6563 throw new TypeError("@@toPrimitive must return a primitive value.");
6564 }
6565 return ("string" === r ? String : Number)(t);
6566 }
6567 module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
6568
6569 /***/ }),
6570
6571 /***/ "../node_modules/@babel/runtime/helpers/toPropertyKey.js":
6572 /*!***************************************************************!*\
6573 !*** ../node_modules/@babel/runtime/helpers/toPropertyKey.js ***!
6574 \***************************************************************/
6575 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6576
6577 var _typeof = (__webpack_require__(/*! ./typeof.js */ "../node_modules/@babel/runtime/helpers/typeof.js")["default"]);
6578 var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "../node_modules/@babel/runtime/helpers/toPrimitive.js");
6579 function toPropertyKey(t) {
6580 var i = toPrimitive(t, "string");
6581 return "symbol" == _typeof(i) ? i : i + "";
6582 }
6583 module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
6584
6585 /***/ }),
6586
6587 /***/ "../node_modules/@babel/runtime/helpers/typeof.js":
6588 /*!********************************************************!*\
6589 !*** ../node_modules/@babel/runtime/helpers/typeof.js ***!
6590 \********************************************************/
6591 /***/ ((module) => {
6592
6593 function _typeof(o) {
6594 "@babel/helpers - typeof";
6595
6596 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
6597 return typeof o;
6598 } : function (o) {
6599 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
6600 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
6601 }
6602 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
6603
6604 /***/ }),
6605
6606 /***/ "../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
6607 /*!****************************************************************************!*\
6608 !*** ../node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
6609 \****************************************************************************/
6610 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6611
6612 var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "../node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
6613 function _unsupportedIterableToArray(r, a) {
6614 if (r) {
6615 if ("string" == typeof r) return arrayLikeToArray(r, a);
6616 var t = {}.toString.call(r).slice(8, -1);
6617 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;
6618 }
6619 }
6620 module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
6621
6622 /***/ }),
6623
6624 /***/ "../node_modules/@babel/runtime/helpers/wrapNativeSuper.js":
6625 /*!*****************************************************************!*\
6626 !*** ../node_modules/@babel/runtime/helpers/wrapNativeSuper.js ***!
6627 \*****************************************************************/
6628 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6629
6630 var getPrototypeOf = __webpack_require__(/*! ./getPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js");
6631 var setPrototypeOf = __webpack_require__(/*! ./setPrototypeOf.js */ "../node_modules/@babel/runtime/helpers/setPrototypeOf.js");
6632 var isNativeFunction = __webpack_require__(/*! ./isNativeFunction.js */ "../node_modules/@babel/runtime/helpers/isNativeFunction.js");
6633 var construct = __webpack_require__(/*! ./construct.js */ "../node_modules/@babel/runtime/helpers/construct.js");
6634 function _wrapNativeSuper(t) {
6635 var r = "function" == typeof Map ? new Map() : void 0;
6636 return module.exports = _wrapNativeSuper = function _wrapNativeSuper(t) {
6637 if (null === t || !isNativeFunction(t)) return t;
6638 if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
6639 if (void 0 !== r) {
6640 if (r.has(t)) return r.get(t);
6641 r.set(t, Wrapper);
6642 }
6643 function Wrapper() {
6644 return construct(t, arguments, getPrototypeOf(this).constructor);
6645 }
6646 return Wrapper.prototype = Object.create(t.prototype, {
6647 constructor: {
6648 value: Wrapper,
6649 enumerable: !1,
6650 writable: !0,
6651 configurable: !0
6652 }
6653 }), setPrototypeOf(Wrapper, t);
6654 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _wrapNativeSuper(t);
6655 }
6656 module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports;
6657
6658 /***/ }),
6659
6660 /***/ "../node_modules/@babel/runtime/regenerator/index.js":
6661 /*!***********************************************************!*\
6662 !*** ../node_modules/@babel/runtime/regenerator/index.js ***!
6663 \***********************************************************/
6664 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
6665
6666 // TODO(Babel 8): Remove this file.
6667
6668 var runtime = __webpack_require__(/*! ../helpers/regeneratorRuntime */ "../node_modules/@babel/runtime/helpers/regeneratorRuntime.js")();
6669 module.exports = runtime;
6670
6671 // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
6672 try {
6673 regeneratorRuntime = runtime;
6674 } catch (accidentalStrictMode) {
6675 if (typeof globalThis === "object") {
6676 globalThis.regeneratorRuntime = runtime;
6677 } else {
6678 Function("r", "regeneratorRuntime = r")(runtime);
6679 }
6680 }
6681
6682
6683 /***/ }),
6684
6685 /***/ "../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js":
6686 /*!******************************************************************!*\
6687 !*** ../node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js ***!
6688 \******************************************************************/
6689 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6690
6691 "use strict";
6692 __webpack_require__.r(__webpack_exports__);
6693 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6694 /* harmony export */ EnhancerArray: () => (/* binding */ EnhancerArray),
6695 /* harmony export */ MiddlewareArray: () => (/* binding */ MiddlewareArray),
6696 /* harmony export */ SHOULD_AUTOBATCH: () => (/* binding */ SHOULD_AUTOBATCH),
6697 /* harmony export */ TaskAbortError: () => (/* binding */ TaskAbortError),
6698 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.__DO_NOT_USE__ActionTypes),
6699 /* harmony export */ addListener: () => (/* binding */ addListener),
6700 /* harmony export */ applyMiddleware: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware),
6701 /* harmony export */ autoBatchEnhancer: () => (/* binding */ autoBatchEnhancer),
6702 /* harmony export */ bindActionCreators: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.bindActionCreators),
6703 /* harmony export */ clearAllListeners: () => (/* binding */ clearAllListeners),
6704 /* harmony export */ combineReducers: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers),
6705 /* harmony export */ compose: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.compose),
6706 /* harmony export */ configureStore: () => (/* binding */ configureStore),
6707 /* harmony export */ createAction: () => (/* binding */ createAction),
6708 /* harmony export */ createActionCreatorInvariantMiddleware: () => (/* binding */ createActionCreatorInvariantMiddleware),
6709 /* harmony export */ createAsyncThunk: () => (/* binding */ createAsyncThunk),
6710 /* harmony export */ createDraftSafeSelector: () => (/* binding */ createDraftSafeSelector),
6711 /* harmony export */ createEntityAdapter: () => (/* binding */ createEntityAdapter),
6712 /* harmony export */ createImmutableStateInvariantMiddleware: () => (/* binding */ createImmutableStateInvariantMiddleware),
6713 /* harmony export */ createListenerMiddleware: () => (/* binding */ createListenerMiddleware),
6714 /* harmony export */ createNextState: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__["default"]),
6715 /* harmony export */ createReducer: () => (/* binding */ createReducer),
6716 /* harmony export */ createSelector: () => (/* reexport safe */ reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector),
6717 /* harmony export */ createSerializableStateInvariantMiddleware: () => (/* binding */ createSerializableStateInvariantMiddleware),
6718 /* harmony export */ createSlice: () => (/* binding */ createSlice),
6719 /* harmony export */ createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.createStore),
6720 /* harmony export */ current: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.current),
6721 /* harmony export */ findNonSerializableValue: () => (/* binding */ findNonSerializableValue),
6722 /* harmony export */ freeze: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.freeze),
6723 /* harmony export */ getDefaultMiddleware: () => (/* binding */ getDefaultMiddleware),
6724 /* harmony export */ getType: () => (/* binding */ getType),
6725 /* harmony export */ isAction: () => (/* binding */ isAction),
6726 /* harmony export */ isActionCreator: () => (/* binding */ isActionCreator),
6727 /* harmony export */ isAllOf: () => (/* binding */ isAllOf),
6728 /* harmony export */ isAnyOf: () => (/* binding */ isAnyOf),
6729 /* harmony export */ isAsyncThunkAction: () => (/* binding */ isAsyncThunkAction),
6730 /* harmony export */ isDraft: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.isDraft),
6731 /* harmony export */ isFluxStandardAction: () => (/* binding */ isFSA),
6732 /* harmony export */ isFulfilled: () => (/* binding */ isFulfilled),
6733 /* harmony export */ isImmutableDefault: () => (/* binding */ isImmutableDefault),
6734 /* harmony export */ isPending: () => (/* binding */ isPending),
6735 /* harmony export */ isPlain: () => (/* binding */ isPlain),
6736 /* harmony export */ isPlainObject: () => (/* binding */ isPlainObject),
6737 /* harmony export */ isRejected: () => (/* binding */ isRejected),
6738 /* harmony export */ isRejectedWithValue: () => (/* binding */ isRejectedWithValue),
6739 /* harmony export */ legacy_createStore: () => (/* reexport safe */ redux__WEBPACK_IMPORTED_MODULE_1__.legacy_createStore),
6740 /* harmony export */ miniSerializeError: () => (/* binding */ miniSerializeError),
6741 /* harmony export */ nanoid: () => (/* binding */ nanoid),
6742 /* harmony export */ original: () => (/* reexport safe */ immer__WEBPACK_IMPORTED_MODULE_0__.original),
6743 /* harmony export */ prepareAutoBatched: () => (/* binding */ prepareAutoBatched),
6744 /* harmony export */ removeListener: () => (/* binding */ removeListener),
6745 /* harmony export */ unwrapResult: () => (/* binding */ unwrapResult)
6746 /* harmony export */ });
6747 /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! immer */ "../node_modules/immer/dist/immer.esm.mjs");
6748 /* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! redux */ "../node_modules/redux/es/redux.js");
6749 /* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../node_modules/reselect/es/index.js");
6750 /* harmony import */ var redux_thunk__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! redux-thunk */ "../node_modules/redux-thunk/es/index.js");
6751 var __extends = (undefined && undefined.__extends) || (function () {
6752 var extendStatics = function (d, b) {
6753 extendStatics = Object.setPrototypeOf ||
6754 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6755 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6756 return extendStatics(d, b);
6757 };
6758 return function (d, b) {
6759 if (typeof b !== "function" && b !== null)
6760 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
6761 extendStatics(d, b);
6762 function __() { this.constructor = d; }
6763 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6764 };
6765 })();
6766 var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
6767 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
6768 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
6769 function verb(n) { return function (v) { return step([n, v]); }; }
6770 function step(op) {
6771 if (f) throw new TypeError("Generator is already executing.");
6772 while (_) try {
6773 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;
6774 if (y = 0, t) op = [op[0] & 2, t.value];
6775 switch (op[0]) {
6776 case 0: case 1: t = op; break;
6777 case 4: _.label++; return { value: op[1], done: false };
6778 case 5: _.label++; y = op[1]; op = [0]; continue;
6779 case 7: op = _.ops.pop(); _.trys.pop(); continue;
6780 default:
6781 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
6782 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
6783 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
6784 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
6785 if (t[2]) _.ops.pop();
6786 _.trys.pop(); continue;
6787 }
6788 op = body.call(thisArg, _);
6789 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
6790 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
6791 }
6792 };
6793 var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
6794 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
6795 to[j] = from[i];
6796 return to;
6797 };
6798 var __defProp = Object.defineProperty;
6799 var __defProps = Object.defineProperties;
6800 var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6801 var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6802 var __hasOwnProp = Object.prototype.hasOwnProperty;
6803 var __propIsEnum = Object.prototype.propertyIsEnumerable;
6804 var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
6805 var __spreadValues = function (a, b) {
6806 for (var prop in b || (b = {}))
6807 if (__hasOwnProp.call(b, prop))
6808 __defNormalProp(a, prop, b[prop]);
6809 if (__getOwnPropSymbols)
6810 for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
6811 var prop = _c[_i];
6812 if (__propIsEnum.call(b, prop))
6813 __defNormalProp(a, prop, b[prop]);
6814 }
6815 return a;
6816 };
6817 var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
6818 var __async = function (__this, __arguments, generator) {
6819 return new Promise(function (resolve, reject) {
6820 var fulfilled = function (value) {
6821 try {
6822 step(generator.next(value));
6823 }
6824 catch (e) {
6825 reject(e);
6826 }
6827 };
6828 var rejected = function (value) {
6829 try {
6830 step(generator.throw(value));
6831 }
6832 catch (e) {
6833 reject(e);
6834 }
6835 };
6836 var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
6837 step((generator = generator.apply(__this, __arguments)).next());
6838 });
6839 };
6840 // src/index.ts
6841
6842
6843
6844
6845 // src/createDraftSafeSelector.ts
6846
6847
6848 var createDraftSafeSelector = function () {
6849 var args = [];
6850 for (var _i = 0; _i < arguments.length; _i++) {
6851 args[_i] = arguments[_i];
6852 }
6853 var selector = reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector.apply(void 0, args);
6854 var wrappedSelector = function (value) {
6855 var rest = [];
6856 for (var _i = 1; _i < arguments.length; _i++) {
6857 rest[_i - 1] = arguments[_i];
6858 }
6859 return selector.apply(void 0, __spreadArray([(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(value) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__.current)(value) : value], rest));
6860 };
6861 return wrappedSelector;
6862 };
6863 // src/configureStore.ts
6864
6865 // src/devtoolsExtension.ts
6866
6867 var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
6868 if (arguments.length === 0)
6869 return void 0;
6870 if (typeof arguments[0] === "object")
6871 return redux__WEBPACK_IMPORTED_MODULE_1__.compose;
6872 return redux__WEBPACK_IMPORTED_MODULE_1__.compose.apply(null, arguments);
6873 };
6874 var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function () {
6875 return function (noop2) {
6876 return noop2;
6877 };
6878 };
6879 // src/isPlainObject.ts
6880 function isPlainObject(value) {
6881 if (typeof value !== "object" || value === null)
6882 return false;
6883 var proto = Object.getPrototypeOf(value);
6884 if (proto === null)
6885 return true;
6886 var baseProto = proto;
6887 while (Object.getPrototypeOf(baseProto) !== null) {
6888 baseProto = Object.getPrototypeOf(baseProto);
6889 }
6890 return proto === baseProto;
6891 }
6892 // src/getDefaultMiddleware.ts
6893
6894 // src/tsHelpers.ts
6895 var hasMatchFunction = function (v) {
6896 return v && typeof v.match === "function";
6897 };
6898 // src/createAction.ts
6899 function createAction(type, prepareAction) {
6900 function actionCreator() {
6901 var args = [];
6902 for (var _i = 0; _i < arguments.length; _i++) {
6903 args[_i] = arguments[_i];
6904 }
6905 if (prepareAction) {
6906 var prepared = prepareAction.apply(void 0, args);
6907 if (!prepared) {
6908 throw new Error("prepareAction did not return an object");
6909 }
6910 return __spreadValues(__spreadValues({
6911 type: type,
6912 payload: prepared.payload
6913 }, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
6914 }
6915 return { type: type, payload: args[0] };
6916 }
6917 actionCreator.toString = function () { return "" + type; };
6918 actionCreator.type = type;
6919 actionCreator.match = function (action) { return action.type === type; };
6920 return actionCreator;
6921 }
6922 function isAction(action) {
6923 return isPlainObject(action) && "type" in action;
6924 }
6925 function isActionCreator(action) {
6926 return typeof action === "function" && "type" in action && hasMatchFunction(action);
6927 }
6928 function isFSA(action) {
6929 return isAction(action) && typeof action.type === "string" && Object.keys(action).every(isValidKey);
6930 }
6931 function isValidKey(key) {
6932 return ["type", "payload", "error", "meta"].indexOf(key) > -1;
6933 }
6934 function getType(actionCreator) {
6935 return "" + actionCreator;
6936 }
6937 // src/actionCreatorInvariantMiddleware.ts
6938 function getMessage(type) {
6939 var splitType = type ? ("" + type).split("/") : [];
6940 var actionName = splitType[splitType.length - 1] || "actionCreator";
6941 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.";
6942 }
6943 function createActionCreatorInvariantMiddleware(options) {
6944 if (options === void 0) { options = {}; }
6945 if (false) // removed by dead control flow
6946 {}
6947 var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
6948 return function () { return function (next) { return function (action) {
6949 if (isActionCreator2(action)) {
6950 console.warn(getMessage(action.type));
6951 }
6952 return next(action);
6953 }; }; };
6954 }
6955 // src/utils.ts
6956
6957 function getTimeMeasureUtils(maxDelay, fnName) {
6958 var elapsed = 0;
6959 return {
6960 measureTime: function (fn) {
6961 var started = Date.now();
6962 try {
6963 return fn();
6964 }
6965 finally {
6966 var finished = Date.now();
6967 elapsed += finished - started;
6968 }
6969 },
6970 warnIfExceeded: function () {
6971 if (elapsed > maxDelay) {
6972 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.");
6973 }
6974 }
6975 };
6976 }
6977 var MiddlewareArray = /** @class */ (function (_super) {
6978 __extends(MiddlewareArray, _super);
6979 function MiddlewareArray() {
6980 var args = [];
6981 for (var _i = 0; _i < arguments.length; _i++) {
6982 args[_i] = arguments[_i];
6983 }
6984 var _this = _super.apply(this, args) || this;
6985 Object.setPrototypeOf(_this, MiddlewareArray.prototype);
6986 return _this;
6987 }
6988 Object.defineProperty(MiddlewareArray, Symbol.species, {
6989 get: function () {
6990 return MiddlewareArray;
6991 },
6992 enumerable: false,
6993 configurable: true
6994 });
6995 MiddlewareArray.prototype.concat = function () {
6996 var arr = [];
6997 for (var _i = 0; _i < arguments.length; _i++) {
6998 arr[_i] = arguments[_i];
6999 }
7000 return _super.prototype.concat.apply(this, arr);
7001 };
7002 MiddlewareArray.prototype.prepend = function () {
7003 var arr = [];
7004 for (var _i = 0; _i < arguments.length; _i++) {
7005 arr[_i] = arguments[_i];
7006 }
7007 if (arr.length === 1 && Array.isArray(arr[0])) {
7008 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
7009 }
7010 return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
7011 };
7012 return MiddlewareArray;
7013 }(Array));
7014 var EnhancerArray = /** @class */ (function (_super) {
7015 __extends(EnhancerArray, _super);
7016 function EnhancerArray() {
7017 var args = [];
7018 for (var _i = 0; _i < arguments.length; _i++) {
7019 args[_i] = arguments[_i];
7020 }
7021 var _this = _super.apply(this, args) || this;
7022 Object.setPrototypeOf(_this, EnhancerArray.prototype);
7023 return _this;
7024 }
7025 Object.defineProperty(EnhancerArray, Symbol.species, {
7026 get: function () {
7027 return EnhancerArray;
7028 },
7029 enumerable: false,
7030 configurable: true
7031 });
7032 EnhancerArray.prototype.concat = function () {
7033 var arr = [];
7034 for (var _i = 0; _i < arguments.length; _i++) {
7035 arr[_i] = arguments[_i];
7036 }
7037 return _super.prototype.concat.apply(this, arr);
7038 };
7039 EnhancerArray.prototype.prepend = function () {
7040 var arr = [];
7041 for (var _i = 0; _i < arguments.length; _i++) {
7042 arr[_i] = arguments[_i];
7043 }
7044 if (arr.length === 1 && Array.isArray(arr[0])) {
7045 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(this))))();
7046 }
7047 return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(this))))();
7048 };
7049 return EnhancerArray;
7050 }(Array));
7051 function freezeDraftable(val) {
7052 return (0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(val) ? (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(val, function () {
7053 }) : val;
7054 }
7055 // src/immutableStateInvariantMiddleware.ts
7056 var isProduction = "development" === "production";
7057 var prefix = "Invariant failed";
7058 function invariant(condition, message) {
7059 if (condition) {
7060 return;
7061 }
7062 if (isProduction) {
7063 throw new Error(prefix);
7064 }
7065 throw new Error(prefix + ": " + (message || ""));
7066 }
7067 function stringify(obj, serializer, indent, decycler) {
7068 return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
7069 }
7070 function getSerialize(serializer, decycler) {
7071 var stack = [], keys = [];
7072 if (!decycler)
7073 decycler = function (_, value) {
7074 if (stack[0] === value)
7075 return "[Circular ~]";
7076 return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
7077 };
7078 return function (key, value) {
7079 if (stack.length > 0) {
7080 var thisPos = stack.indexOf(this);
7081 ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
7082 ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
7083 if (~stack.indexOf(value))
7084 value = decycler.call(this, key, value);
7085 }
7086 else
7087 stack.push(value);
7088 return serializer == null ? value : serializer.call(this, key, value);
7089 };
7090 }
7091 function isImmutableDefault(value) {
7092 return typeof value !== "object" || value == null || Object.isFrozen(value);
7093 }
7094 function trackForMutations(isImmutable, ignorePaths, obj) {
7095 var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
7096 return {
7097 detectMutations: function () {
7098 return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
7099 }
7100 };
7101 }
7102 function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
7103 if (ignorePaths === void 0) { ignorePaths = []; }
7104 if (path === void 0) { path = ""; }
7105 if (checkedObjects === void 0) { checkedObjects = new Set(); }
7106 var tracked = { value: obj };
7107 if (!isImmutable(obj) && !checkedObjects.has(obj)) {
7108 checkedObjects.add(obj);
7109 tracked.children = {};
7110 for (var key in obj) {
7111 var childPath = path ? path + "." + key : key;
7112 if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
7113 continue;
7114 }
7115 tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
7116 }
7117 }
7118 return tracked;
7119 }
7120 function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
7121 if (ignoredPaths === void 0) { ignoredPaths = []; }
7122 if (sameParentRef === void 0) { sameParentRef = false; }
7123 if (path === void 0) { path = ""; }
7124 var prevObj = trackedProperty ? trackedProperty.value : void 0;
7125 var sameRef = prevObj === obj;
7126 if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
7127 return { wasMutated: true, path: path };
7128 }
7129 if (isImmutable(prevObj) || isImmutable(obj)) {
7130 return { wasMutated: false };
7131 }
7132 var keysToDetect = {};
7133 for (var key in trackedProperty.children) {
7134 keysToDetect[key] = true;
7135 }
7136 for (var key in obj) {
7137 keysToDetect[key] = true;
7138 }
7139 var hasIgnoredPaths = ignoredPaths.length > 0;
7140 var _loop_1 = function (key) {
7141 var nestedPath = path ? path + "." + key : key;
7142 if (hasIgnoredPaths) {
7143 var hasMatches = ignoredPaths.some(function (ignored) {
7144 if (ignored instanceof RegExp) {
7145 return ignored.test(nestedPath);
7146 }
7147 return nestedPath === ignored;
7148 });
7149 if (hasMatches) {
7150 return "continue";
7151 }
7152 }
7153 var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key], obj[key], sameRef, nestedPath);
7154 if (result.wasMutated) {
7155 return { value: result };
7156 }
7157 };
7158 for (var key in keysToDetect) {
7159 var state_1 = _loop_1(key);
7160 if (typeof state_1 === "object")
7161 return state_1.value;
7162 }
7163 return { wasMutated: false };
7164 }
7165 function createImmutableStateInvariantMiddleware(options) {
7166 if (options === void 0) { options = {}; }
7167 if (false) // removed by dead control flow
7168 {}
7169 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;
7170 ignoredPaths = ignoredPaths || ignore;
7171 var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
7172 return function (_c) {
7173 var getState = _c.getState;
7174 var state = getState();
7175 var tracker = track(state);
7176 var result;
7177 return function (next) { return function (action) {
7178 var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
7179 measureUtils.measureTime(function () {
7180 state = getState();
7181 result = tracker.detectMutations();
7182 tracker = track(state);
7183 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)");
7184 });
7185 var dispatchedAction = next(action);
7186 measureUtils.measureTime(function () {
7187 state = getState();
7188 result = tracker.detectMutations();
7189 tracker = track(state);
7190 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)");
7191 });
7192 measureUtils.warnIfExceeded();
7193 return dispatchedAction;
7194 }; };
7195 };
7196 }
7197 // src/serializableStateInvariantMiddleware.ts
7198 function isPlain(val) {
7199 var type = typeof val;
7200 return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
7201 }
7202 function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
7203 if (path === void 0) { path = ""; }
7204 if (isSerializable === void 0) { isSerializable = isPlain; }
7205 if (ignoredPaths === void 0) { ignoredPaths = []; }
7206 var foundNestedSerializable;
7207 if (!isSerializable(value)) {
7208 return {
7209 keyPath: path || "<root>",
7210 value: value
7211 };
7212 }
7213 if (typeof value !== "object" || value === null) {
7214 return false;
7215 }
7216 if (cache == null ? void 0 : cache.has(value))
7217 return false;
7218 var entries = getEntries != null ? getEntries(value) : Object.entries(value);
7219 var hasIgnoredPaths = ignoredPaths.length > 0;
7220 var _loop_2 = function (key, nestedValue) {
7221 var nestedPath = path ? path + "." + key : key;
7222 if (hasIgnoredPaths) {
7223 var hasMatches = ignoredPaths.some(function (ignored) {
7224 if (ignored instanceof RegExp) {
7225 return ignored.test(nestedPath);
7226 }
7227 return nestedPath === ignored;
7228 });
7229 if (hasMatches) {
7230 return "continue";
7231 }
7232 }
7233 if (!isSerializable(nestedValue)) {
7234 return { value: {
7235 keyPath: nestedPath,
7236 value: nestedValue
7237 } };
7238 }
7239 if (typeof nestedValue === "object") {
7240 foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
7241 if (foundNestedSerializable) {
7242 return { value: foundNestedSerializable };
7243 }
7244 }
7245 };
7246 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
7247 var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
7248 var state_2 = _loop_2(key, nestedValue);
7249 if (typeof state_2 === "object")
7250 return state_2.value;
7251 }
7252 if (cache && isNestedFrozen(value))
7253 cache.add(value);
7254 return false;
7255 }
7256 function isNestedFrozen(value) {
7257 if (!Object.isFrozen(value))
7258 return false;
7259 for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
7260 var nestedValue = _c[_i];
7261 if (typeof nestedValue !== "object" || nestedValue === null)
7262 continue;
7263 if (!isNestedFrozen(nestedValue))
7264 return false;
7265 }
7266 return true;
7267 }
7268 function createSerializableStateInvariantMiddleware(options) {
7269 if (options === void 0) { options = {}; }
7270 if (false) // removed by dead control flow
7271 {}
7272 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;
7273 var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
7274 return function (storeAPI) { return function (next) { return function (action) {
7275 var result = next(action);
7276 var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
7277 if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
7278 measureUtils.measureTime(function () {
7279 var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
7280 if (foundActionNonSerializableValue) {
7281 var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
7282 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)");
7283 }
7284 });
7285 }
7286 if (!ignoreState) {
7287 measureUtils.measureTime(function () {
7288 var state = storeAPI.getState();
7289 var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
7290 if (foundStateNonSerializableValue) {
7291 var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
7292 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)");
7293 }
7294 });
7295 measureUtils.warnIfExceeded();
7296 }
7297 return result;
7298 }; }; };
7299 }
7300 // src/getDefaultMiddleware.ts
7301 function isBoolean(x) {
7302 return typeof x === "boolean";
7303 }
7304 function curryGetDefaultMiddleware() {
7305 return function curriedGetDefaultMiddleware(options) {
7306 return getDefaultMiddleware(options);
7307 };
7308 }
7309 function getDefaultMiddleware(options) {
7310 if (options === void 0) { options = {}; }
7311 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;
7312 var middlewareArray = new MiddlewareArray();
7313 if (thunk) {
7314 if (isBoolean(thunk)) {
7315 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"]);
7316 }
7317 else {
7318 middlewareArray.push(redux_thunk__WEBPACK_IMPORTED_MODULE_3__["default"].withExtraArgument(thunk.extraArgument));
7319 }
7320 }
7321 if (true) {
7322 if (immutableCheck) {
7323 var immutableOptions = {};
7324 if (!isBoolean(immutableCheck)) {
7325 immutableOptions = immutableCheck;
7326 }
7327 middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
7328 }
7329 if (serializableCheck) {
7330 var serializableOptions = {};
7331 if (!isBoolean(serializableCheck)) {
7332 serializableOptions = serializableCheck;
7333 }
7334 middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
7335 }
7336 if (actionCreatorCheck) {
7337 var actionCreatorOptions = {};
7338 if (!isBoolean(actionCreatorCheck)) {
7339 actionCreatorOptions = actionCreatorCheck;
7340 }
7341 middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
7342 }
7343 }
7344 return middlewareArray;
7345 }
7346 // src/configureStore.ts
7347 var IS_PRODUCTION = "development" === "production";
7348 function configureStore(options) {
7349 var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
7350 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;
7351 var rootReducer;
7352 if (typeof reducer === "function") {
7353 rootReducer = reducer;
7354 }
7355 else if (isPlainObject(reducer)) {
7356 rootReducer = (0,redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)(reducer);
7357 }
7358 else {
7359 throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
7360 }
7361 var finalMiddleware = middleware;
7362 if (typeof finalMiddleware === "function") {
7363 finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
7364 if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
7365 throw new Error("when using a middleware builder function, an array of middleware must be returned");
7366 }
7367 }
7368 if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
7369 throw new Error("each middleware provided to configureStore must be a function");
7370 }
7371 var middlewareEnhancer = redux__WEBPACK_IMPORTED_MODULE_1__.applyMiddleware.apply(void 0, finalMiddleware);
7372 var finalCompose = redux__WEBPACK_IMPORTED_MODULE_1__.compose;
7373 if (devTools) {
7374 finalCompose = composeWithDevTools(__spreadValues({
7375 trace: !IS_PRODUCTION
7376 }, typeof devTools === "object" && devTools));
7377 }
7378 var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
7379 var storeEnhancers = defaultEnhancers;
7380 if (Array.isArray(enhancers)) {
7381 storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
7382 }
7383 else if (typeof enhancers === "function") {
7384 storeEnhancers = enhancers(defaultEnhancers);
7385 }
7386 var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
7387 return (0,redux__WEBPACK_IMPORTED_MODULE_1__.createStore)(rootReducer, preloadedState, composedEnhancer);
7388 }
7389 // src/createReducer.ts
7390
7391 // src/mapBuilders.ts
7392 function executeReducerBuilderCallback(builderCallback) {
7393 var actionsMap = {};
7394 var actionMatchers = [];
7395 var defaultCaseReducer;
7396 var builder = {
7397 addCase: function (typeOrActionCreator, reducer) {
7398 if (true) {
7399 if (actionMatchers.length > 0) {
7400 throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
7401 }
7402 if (defaultCaseReducer) {
7403 throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
7404 }
7405 }
7406 var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
7407 if (!type) {
7408 throw new Error("`builder.addCase` cannot be called with an empty action type");
7409 }
7410 if (type in actionsMap) {
7411 throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
7412 }
7413 actionsMap[type] = reducer;
7414 return builder;
7415 },
7416 addMatcher: function (matcher, reducer) {
7417 if (true) {
7418 if (defaultCaseReducer) {
7419 throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
7420 }
7421 }
7422 actionMatchers.push({ matcher: matcher, reducer: reducer });
7423 return builder;
7424 },
7425 addDefaultCase: function (reducer) {
7426 if (true) {
7427 if (defaultCaseReducer) {
7428 throw new Error("`builder.addDefaultCase` can only be called once");
7429 }
7430 }
7431 defaultCaseReducer = reducer;
7432 return builder;
7433 }
7434 };
7435 builderCallback(builder);
7436 return [actionsMap, actionMatchers, defaultCaseReducer];
7437 }
7438 // src/createReducer.ts
7439 function isStateFunction(x) {
7440 return typeof x === "function";
7441 }
7442 var hasWarnedAboutObjectNotation = false;
7443 function createReducer(initialState, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
7444 if (actionMatchers === void 0) { actionMatchers = []; }
7445 if (true) {
7446 if (typeof mapOrBuilderCallback === "object") {
7447 if (!hasWarnedAboutObjectNotation) {
7448 hasWarnedAboutObjectNotation = true;
7449 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");
7450 }
7451 }
7452 }
7453 var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
7454 var getInitialState;
7455 if (isStateFunction(initialState)) {
7456 getInitialState = function () { return freezeDraftable(initialState()); };
7457 }
7458 else {
7459 var frozenInitialState_1 = freezeDraftable(initialState);
7460 getInitialState = function () { return frozenInitialState_1; };
7461 }
7462 function reducer(state, action) {
7463 if (state === void 0) { state = getInitialState(); }
7464 var caseReducers = __spreadArray([
7465 actionsMap[action.type]
7466 ], finalActionMatchers.filter(function (_c) {
7467 var matcher = _c.matcher;
7468 return matcher(action);
7469 }).map(function (_c) {
7470 var reducer2 = _c.reducer;
7471 return reducer2;
7472 }));
7473 if (caseReducers.filter(function (cr) { return !!cr; }).length === 0) {
7474 caseReducers = [finalDefaultCaseReducer];
7475 }
7476 return caseReducers.reduce(function (previousState, caseReducer) {
7477 if (caseReducer) {
7478 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(previousState)) {
7479 var draft = previousState;
7480 var result = caseReducer(draft, action);
7481 if (result === void 0) {
7482 return previousState;
7483 }
7484 return result;
7485 }
7486 else if (!(0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraftable)(previousState)) {
7487 var result = caseReducer(previousState, action);
7488 if (result === void 0) {
7489 if (previousState === null) {
7490 return previousState;
7491 }
7492 throw Error("A case reducer on a non-draftable value must not return undefined");
7493 }
7494 return result;
7495 }
7496 else {
7497 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(previousState, function (draft) {
7498 return caseReducer(draft, action);
7499 });
7500 }
7501 }
7502 return previousState;
7503 }, state);
7504 }
7505 reducer.getInitialState = getInitialState;
7506 return reducer;
7507 }
7508 // src/createSlice.ts
7509 var hasWarnedAboutObjectNotation2 = false;
7510 function getType2(slice, actionKey) {
7511 return slice + "/" + actionKey;
7512 }
7513 function createSlice(options) {
7514 var name = options.name;
7515 if (!name) {
7516 throw new Error("`name` is a required option for createSlice");
7517 }
7518 if (typeof process !== "undefined" && "development" === "development") {
7519 if (options.initialState === void 0) {
7520 console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
7521 }
7522 }
7523 var initialState = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
7524 var reducers = options.reducers || {};
7525 var reducerNames = Object.keys(reducers);
7526 var sliceCaseReducersByName = {};
7527 var sliceCaseReducersByType = {};
7528 var actionCreators = {};
7529 reducerNames.forEach(function (reducerName) {
7530 var maybeReducerWithPrepare = reducers[reducerName];
7531 var type = getType2(name, reducerName);
7532 var caseReducer;
7533 var prepareCallback;
7534 if ("reducer" in maybeReducerWithPrepare) {
7535 caseReducer = maybeReducerWithPrepare.reducer;
7536 prepareCallback = maybeReducerWithPrepare.prepare;
7537 }
7538 else {
7539 caseReducer = maybeReducerWithPrepare;
7540 }
7541 sliceCaseReducersByName[reducerName] = caseReducer;
7542 sliceCaseReducersByType[type] = caseReducer;
7543 actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
7544 });
7545 function buildReducer() {
7546 if (true) {
7547 if (typeof options.extraReducers === "object") {
7548 if (!hasWarnedAboutObjectNotation2) {
7549 hasWarnedAboutObjectNotation2 = true;
7550 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");
7551 }
7552 }
7553 }
7554 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;
7555 var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
7556 return createReducer(initialState, function (builder) {
7557 for (var key in finalCaseReducers) {
7558 builder.addCase(key, finalCaseReducers[key]);
7559 }
7560 for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
7561 var m = actionMatchers_1[_i];
7562 builder.addMatcher(m.matcher, m.reducer);
7563 }
7564 if (defaultCaseReducer) {
7565 builder.addDefaultCase(defaultCaseReducer);
7566 }
7567 });
7568 }
7569 var _reducer;
7570 return {
7571 name: name,
7572 reducer: function (state, action) {
7573 if (!_reducer)
7574 _reducer = buildReducer();
7575 return _reducer(state, action);
7576 },
7577 actions: actionCreators,
7578 caseReducers: sliceCaseReducersByName,
7579 getInitialState: function () {
7580 if (!_reducer)
7581 _reducer = buildReducer();
7582 return _reducer.getInitialState();
7583 }
7584 };
7585 }
7586 // src/entities/entity_state.ts
7587 function getInitialEntityState() {
7588 return {
7589 ids: [],
7590 entities: {}
7591 };
7592 }
7593 function createInitialStateFactory() {
7594 function getInitialState(additionalState) {
7595 if (additionalState === void 0) { additionalState = {}; }
7596 return Object.assign(getInitialEntityState(), additionalState);
7597 }
7598 return { getInitialState: getInitialState };
7599 }
7600 // src/entities/state_selectors.ts
7601 function createSelectorsFactory() {
7602 function getSelectors(selectState) {
7603 var selectIds = function (state) { return state.ids; };
7604 var selectEntities = function (state) { return state.entities; };
7605 var selectAll = createDraftSafeSelector(selectIds, selectEntities, function (ids, entities) { return ids.map(function (id) { return entities[id]; }); });
7606 var selectId = function (_, id) { return id; };
7607 var selectById = function (entities, id) { return entities[id]; };
7608 var selectTotal = createDraftSafeSelector(selectIds, function (ids) { return ids.length; });
7609 if (!selectState) {
7610 return {
7611 selectIds: selectIds,
7612 selectEntities: selectEntities,
7613 selectAll: selectAll,
7614 selectTotal: selectTotal,
7615 selectById: createDraftSafeSelector(selectEntities, selectId, selectById)
7616 };
7617 }
7618 var selectGlobalizedEntities = createDraftSafeSelector(selectState, selectEntities);
7619 return {
7620 selectIds: createDraftSafeSelector(selectState, selectIds),
7621 selectEntities: selectGlobalizedEntities,
7622 selectAll: createDraftSafeSelector(selectState, selectAll),
7623 selectTotal: createDraftSafeSelector(selectState, selectTotal),
7624 selectById: createDraftSafeSelector(selectGlobalizedEntities, selectId, selectById)
7625 };
7626 }
7627 return { getSelectors: getSelectors };
7628 }
7629 // src/entities/state_adapter.ts
7630
7631 function createSingleArgumentStateOperator(mutator) {
7632 var operator = createStateOperator(function (_, state) { return mutator(state); });
7633 return function operation(state) {
7634 return operator(state, void 0);
7635 };
7636 }
7637 function createStateOperator(mutator) {
7638 return function operation(state, arg) {
7639 function isPayloadActionArgument(arg2) {
7640 return isFSA(arg2);
7641 }
7642 var runMutator = function (draft) {
7643 if (isPayloadActionArgument(arg)) {
7644 mutator(arg.payload, draft);
7645 }
7646 else {
7647 mutator(arg, draft);
7648 }
7649 };
7650 if ((0,immer__WEBPACK_IMPORTED_MODULE_0__.isDraft)(state)) {
7651 runMutator(state);
7652 return state;
7653 }
7654 else {
7655 return (0,immer__WEBPACK_IMPORTED_MODULE_0__["default"])(state, runMutator);
7656 }
7657 };
7658 }
7659 // src/entities/utils.ts
7660 function selectIdValue(entity, selectId) {
7661 var key = selectId(entity);
7662 if ( true && key === void 0) {
7663 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());
7664 }
7665 return key;
7666 }
7667 function ensureEntitiesArray(entities) {
7668 if (!Array.isArray(entities)) {
7669 entities = Object.values(entities);
7670 }
7671 return entities;
7672 }
7673 function splitAddedUpdatedEntities(newEntities, selectId, state) {
7674 newEntities = ensureEntitiesArray(newEntities);
7675 var added = [];
7676 var updated = [];
7677 for (var _i = 0, newEntities_1 = newEntities; _i < newEntities_1.length; _i++) {
7678 var entity = newEntities_1[_i];
7679 var id = selectIdValue(entity, selectId);
7680 if (id in state.entities) {
7681 updated.push({ id: id, changes: entity });
7682 }
7683 else {
7684 added.push(entity);
7685 }
7686 }
7687 return [added, updated];
7688 }
7689 // src/entities/unsorted_state_adapter.ts
7690 function createUnsortedStateAdapter(selectId) {
7691 function addOneMutably(entity, state) {
7692 var key = selectIdValue(entity, selectId);
7693 if (key in state.entities) {
7694 return;
7695 }
7696 state.ids.push(key);
7697 state.entities[key] = entity;
7698 }
7699 function addManyMutably(newEntities, state) {
7700 newEntities = ensureEntitiesArray(newEntities);
7701 for (var _i = 0, newEntities_2 = newEntities; _i < newEntities_2.length; _i++) {
7702 var entity = newEntities_2[_i];
7703 addOneMutably(entity, state);
7704 }
7705 }
7706 function setOneMutably(entity, state) {
7707 var key = selectIdValue(entity, selectId);
7708 if (!(key in state.entities)) {
7709 state.ids.push(key);
7710 }
7711 state.entities[key] = entity;
7712 }
7713 function setManyMutably(newEntities, state) {
7714 newEntities = ensureEntitiesArray(newEntities);
7715 for (var _i = 0, newEntities_3 = newEntities; _i < newEntities_3.length; _i++) {
7716 var entity = newEntities_3[_i];
7717 setOneMutably(entity, state);
7718 }
7719 }
7720 function setAllMutably(newEntities, state) {
7721 newEntities = ensureEntitiesArray(newEntities);
7722 state.ids = [];
7723 state.entities = {};
7724 addManyMutably(newEntities, state);
7725 }
7726 function removeOneMutably(key, state) {
7727 return removeManyMutably([key], state);
7728 }
7729 function removeManyMutably(keys, state) {
7730 var didMutate = false;
7731 keys.forEach(function (key) {
7732 if (key in state.entities) {
7733 delete state.entities[key];
7734 didMutate = true;
7735 }
7736 });
7737 if (didMutate) {
7738 state.ids = state.ids.filter(function (id) { return id in state.entities; });
7739 }
7740 }
7741 function removeAllMutably(state) {
7742 Object.assign(state, {
7743 ids: [],
7744 entities: {}
7745 });
7746 }
7747 function takeNewKey(keys, update, state) {
7748 var original2 = state.entities[update.id];
7749 var updated = Object.assign({}, original2, update.changes);
7750 var newKey = selectIdValue(updated, selectId);
7751 var hasNewKey = newKey !== update.id;
7752 if (hasNewKey) {
7753 keys[update.id] = newKey;
7754 delete state.entities[update.id];
7755 }
7756 state.entities[newKey] = updated;
7757 return hasNewKey;
7758 }
7759 function updateOneMutably(update, state) {
7760 return updateManyMutably([update], state);
7761 }
7762 function updateManyMutably(updates, state) {
7763 var newKeys = {};
7764 var updatesPerEntity = {};
7765 updates.forEach(function (update) {
7766 if (update.id in state.entities) {
7767 updatesPerEntity[update.id] = {
7768 id: update.id,
7769 changes: __spreadValues(__spreadValues({}, updatesPerEntity[update.id] ? updatesPerEntity[update.id].changes : null), update.changes)
7770 };
7771 }
7772 });
7773 updates = Object.values(updatesPerEntity);
7774 var didMutateEntities = updates.length > 0;
7775 if (didMutateEntities) {
7776 var didMutateIds = updates.filter(function (update) { return takeNewKey(newKeys, update, state); }).length > 0;
7777 if (didMutateIds) {
7778 state.ids = Object.keys(state.entities);
7779 }
7780 }
7781 }
7782 function upsertOneMutably(entity, state) {
7783 return upsertManyMutably([entity], state);
7784 }
7785 function upsertManyMutably(newEntities, state) {
7786 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7787 updateManyMutably(updated, state);
7788 addManyMutably(added, state);
7789 }
7790 return {
7791 removeAll: createSingleArgumentStateOperator(removeAllMutably),
7792 addOne: createStateOperator(addOneMutably),
7793 addMany: createStateOperator(addManyMutably),
7794 setOne: createStateOperator(setOneMutably),
7795 setMany: createStateOperator(setManyMutably),
7796 setAll: createStateOperator(setAllMutably),
7797 updateOne: createStateOperator(updateOneMutably),
7798 updateMany: createStateOperator(updateManyMutably),
7799 upsertOne: createStateOperator(upsertOneMutably),
7800 upsertMany: createStateOperator(upsertManyMutably),
7801 removeOne: createStateOperator(removeOneMutably),
7802 removeMany: createStateOperator(removeManyMutably)
7803 };
7804 }
7805 // src/entities/sorted_state_adapter.ts
7806 function createSortedStateAdapter(selectId, sort) {
7807 var _c = createUnsortedStateAdapter(selectId), removeOne = _c.removeOne, removeMany = _c.removeMany, removeAll = _c.removeAll;
7808 function addOneMutably(entity, state) {
7809 return addManyMutably([entity], state);
7810 }
7811 function addManyMutably(newEntities, state) {
7812 newEntities = ensureEntitiesArray(newEntities);
7813 var models = newEntities.filter(function (model) { return !(selectIdValue(model, selectId) in state.entities); });
7814 if (models.length !== 0) {
7815 merge(models, state);
7816 }
7817 }
7818 function setOneMutably(entity, state) {
7819 return setManyMutably([entity], state);
7820 }
7821 function setManyMutably(newEntities, state) {
7822 newEntities = ensureEntitiesArray(newEntities);
7823 if (newEntities.length !== 0) {
7824 merge(newEntities, state);
7825 }
7826 }
7827 function setAllMutably(newEntities, state) {
7828 newEntities = ensureEntitiesArray(newEntities);
7829 state.entities = {};
7830 state.ids = [];
7831 addManyMutably(newEntities, state);
7832 }
7833 function updateOneMutably(update, state) {
7834 return updateManyMutably([update], state);
7835 }
7836 function updateManyMutably(updates, state) {
7837 var appliedUpdates = false;
7838 for (var _i = 0, updates_1 = updates; _i < updates_1.length; _i++) {
7839 var update = updates_1[_i];
7840 var entity = state.entities[update.id];
7841 if (!entity) {
7842 continue;
7843 }
7844 appliedUpdates = true;
7845 Object.assign(entity, update.changes);
7846 var newId = selectId(entity);
7847 if (update.id !== newId) {
7848 delete state.entities[update.id];
7849 state.entities[newId] = entity;
7850 }
7851 }
7852 if (appliedUpdates) {
7853 resortEntities(state);
7854 }
7855 }
7856 function upsertOneMutably(entity, state) {
7857 return upsertManyMutably([entity], state);
7858 }
7859 function upsertManyMutably(newEntities, state) {
7860 var _c = splitAddedUpdatedEntities(newEntities, selectId, state), added = _c[0], updated = _c[1];
7861 updateManyMutably(updated, state);
7862 addManyMutably(added, state);
7863 }
7864 function areArraysEqual(a, b) {
7865 if (a.length !== b.length) {
7866 return false;
7867 }
7868 for (var i = 0; i < a.length && i < b.length; i++) {
7869 if (a[i] === b[i]) {
7870 continue;
7871 }
7872 return false;
7873 }
7874 return true;
7875 }
7876 function merge(models, state) {
7877 models.forEach(function (model) {
7878 state.entities[selectId(model)] = model;
7879 });
7880 resortEntities(state);
7881 }
7882 function resortEntities(state) {
7883 var allEntities = Object.values(state.entities);
7884 allEntities.sort(sort);
7885 var newSortedIds = allEntities.map(selectId);
7886 var ids = state.ids;
7887 if (!areArraysEqual(ids, newSortedIds)) {
7888 state.ids = newSortedIds;
7889 }
7890 }
7891 return {
7892 removeOne: removeOne,
7893 removeMany: removeMany,
7894 removeAll: removeAll,
7895 addOne: createStateOperator(addOneMutably),
7896 updateOne: createStateOperator(updateOneMutably),
7897 upsertOne: createStateOperator(upsertOneMutably),
7898 setOne: createStateOperator(setOneMutably),
7899 setMany: createStateOperator(setManyMutably),
7900 setAll: createStateOperator(setAllMutably),
7901 addMany: createStateOperator(addManyMutably),
7902 updateMany: createStateOperator(updateManyMutably),
7903 upsertMany: createStateOperator(upsertManyMutably)
7904 };
7905 }
7906 // src/entities/create_adapter.ts
7907 function createEntityAdapter(options) {
7908 if (options === void 0) { options = {}; }
7909 var _c = __spreadValues({
7910 sortComparer: false,
7911 selectId: function (instance) { return instance.id; }
7912 }, options), selectId = _c.selectId, sortComparer = _c.sortComparer;
7913 var stateFactory = createInitialStateFactory();
7914 var selectorsFactory = createSelectorsFactory();
7915 var stateAdapter = sortComparer ? createSortedStateAdapter(selectId, sortComparer) : createUnsortedStateAdapter(selectId);
7916 return __spreadValues(__spreadValues(__spreadValues({
7917 selectId: selectId,
7918 sortComparer: sortComparer
7919 }, stateFactory), selectorsFactory), stateAdapter);
7920 }
7921 // src/nanoid.ts
7922 var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
7923 var nanoid = function (size) {
7924 if (size === void 0) { size = 21; }
7925 var id = "";
7926 var i = size;
7927 while (i--) {
7928 id += urlAlphabet[Math.random() * 64 | 0];
7929 }
7930 return id;
7931 };
7932 // src/createAsyncThunk.ts
7933 var commonProperties = [
7934 "name",
7935 "message",
7936 "stack",
7937 "code"
7938 ];
7939 var RejectWithValue = /** @class */ (function () {
7940 function RejectWithValue(payload, meta) {
7941 this.payload = payload;
7942 this.meta = meta;
7943 }
7944 return RejectWithValue;
7945 }());
7946 var FulfillWithMeta = /** @class */ (function () {
7947 function FulfillWithMeta(payload, meta) {
7948 this.payload = payload;
7949 this.meta = meta;
7950 }
7951 return FulfillWithMeta;
7952 }());
7953 var miniSerializeError = function (value) {
7954 if (typeof value === "object" && value !== null) {
7955 var simpleError = {};
7956 for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
7957 var property = commonProperties_1[_i];
7958 if (typeof value[property] === "string") {
7959 simpleError[property] = value[property];
7960 }
7961 }
7962 return simpleError;
7963 }
7964 return { message: String(value) };
7965 };
7966 var createAsyncThunk = (function () {
7967 function createAsyncThunk2(typePrefix, payloadCreator, options) {
7968 var fulfilled = createAction(typePrefix + "/fulfilled", function (payload, requestId, arg, meta) { return ({
7969 payload: payload,
7970 meta: __spreadProps(__spreadValues({}, meta || {}), {
7971 arg: arg,
7972 requestId: requestId,
7973 requestStatus: "fulfilled"
7974 })
7975 }); });
7976 var pending = createAction(typePrefix + "/pending", function (requestId, arg, meta) { return ({
7977 payload: void 0,
7978 meta: __spreadProps(__spreadValues({}, meta || {}), {
7979 arg: arg,
7980 requestId: requestId,
7981 requestStatus: "pending"
7982 })
7983 }); });
7984 var rejected = createAction(typePrefix + "/rejected", function (error, requestId, arg, payload, meta) { return ({
7985 payload: payload,
7986 error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
7987 meta: __spreadProps(__spreadValues({}, meta || {}), {
7988 arg: arg,
7989 requestId: requestId,
7990 rejectedWithValue: !!payload,
7991 requestStatus: "rejected",
7992 aborted: (error == null ? void 0 : error.name) === "AbortError",
7993 condition: (error == null ? void 0 : error.name) === "ConditionError"
7994 })
7995 }); });
7996 var displayedWarning = false;
7997 var AC = typeof AbortController !== "undefined" ? AbortController : /** @class */ (function () {
7998 function class_1() {
7999 this.signal = {
8000 aborted: false,
8001 addEventListener: function () {
8002 },
8003 dispatchEvent: function () {
8004 return false;
8005 },
8006 onabort: function () {
8007 },
8008 removeEventListener: function () {
8009 },
8010 reason: void 0,
8011 throwIfAborted: function () {
8012 }
8013 };
8014 }
8015 class_1.prototype.abort = function () {
8016 if (true) {
8017 if (!displayedWarning) {
8018 displayedWarning = true;
8019 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'.");
8020 }
8021 }
8022 };
8023 return class_1;
8024 }());
8025 function actionCreator(arg) {
8026 return function (dispatch, getState, extra) {
8027 var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
8028 var abortController = new AC();
8029 var abortReason;
8030 var started = false;
8031 function abort(reason) {
8032 abortReason = reason;
8033 abortController.abort();
8034 }
8035 var promise2 = function () {
8036 return __async(this, null, function () {
8037 var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
8038 return __generator(this, function (_c) {
8039 switch (_c.label) {
8040 case 0:
8041 _c.trys.push([0, 4, , 5]);
8042 conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState: getState, extra: extra });
8043 if (!isThenable(conditionResult)) return [3 /*break*/, 2];
8044 return [4 /*yield*/, conditionResult];
8045 case 1:
8046 conditionResult = _c.sent();
8047 _c.label = 2;
8048 case 2:
8049 if (conditionResult === false || abortController.signal.aborted) {
8050 throw {
8051 name: "ConditionError",
8052 message: "Aborted due to condition callback returning false."
8053 };
8054 }
8055 started = true;
8056 abortedPromise = new Promise(function (_, reject) { return abortController.signal.addEventListener("abort", function () { return reject({
8057 name: "AbortError",
8058 message: abortReason || "Aborted"
8059 }); }); });
8060 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 })));
8061 return [4 /*yield*/, Promise.race([
8062 abortedPromise,
8063 Promise.resolve(payloadCreator(arg, {
8064 dispatch: dispatch,
8065 getState: getState,
8066 extra: extra,
8067 requestId: requestId,
8068 signal: abortController.signal,
8069 abort: abort,
8070 rejectWithValue: function (value, meta) {
8071 return new RejectWithValue(value, meta);
8072 },
8073 fulfillWithValue: function (value, meta) {
8074 return new FulfillWithMeta(value, meta);
8075 }
8076 })).then(function (result) {
8077 if (result instanceof RejectWithValue) {
8078 throw result;
8079 }
8080 if (result instanceof FulfillWithMeta) {
8081 return fulfilled(result.payload, requestId, arg, result.meta);
8082 }
8083 return fulfilled(result, requestId, arg);
8084 })
8085 ])];
8086 case 3:
8087 finalAction = _c.sent();
8088 return [3 /*break*/, 5];
8089 case 4:
8090 err_1 = _c.sent();
8091 finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
8092 return [3 /*break*/, 5];
8093 case 5:
8094 skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
8095 if (!skipDispatch) {
8096 dispatch(finalAction);
8097 }
8098 return [2 /*return*/, finalAction];
8099 }
8100 });
8101 });
8102 }();
8103 return Object.assign(promise2, {
8104 abort: abort,
8105 requestId: requestId,
8106 arg: arg,
8107 unwrap: function () {
8108 return promise2.then(unwrapResult);
8109 }
8110 });
8111 };
8112 }
8113 return Object.assign(actionCreator, {
8114 pending: pending,
8115 rejected: rejected,
8116 fulfilled: fulfilled,
8117 typePrefix: typePrefix
8118 });
8119 }
8120 createAsyncThunk2.withTypes = function () { return createAsyncThunk2; };
8121 return createAsyncThunk2;
8122 })();
8123 function unwrapResult(action) {
8124 if (action.meta && action.meta.rejectedWithValue) {
8125 throw action.payload;
8126 }
8127 if (action.error) {
8128 throw action.error;
8129 }
8130 return action.payload;
8131 }
8132 function isThenable(value) {
8133 return value !== null && typeof value === "object" && typeof value.then === "function";
8134 }
8135 // src/matchers.ts
8136 var matches = function (matcher, action) {
8137 if (hasMatchFunction(matcher)) {
8138 return matcher.match(action);
8139 }
8140 else {
8141 return matcher(action);
8142 }
8143 };
8144 function isAnyOf() {
8145 var matchers = [];
8146 for (var _i = 0; _i < arguments.length; _i++) {
8147 matchers[_i] = arguments[_i];
8148 }
8149 return function (action) {
8150 return matchers.some(function (matcher) { return matches(matcher, action); });
8151 };
8152 }
8153 function isAllOf() {
8154 var matchers = [];
8155 for (var _i = 0; _i < arguments.length; _i++) {
8156 matchers[_i] = arguments[_i];
8157 }
8158 return function (action) {
8159 return matchers.every(function (matcher) { return matches(matcher, action); });
8160 };
8161 }
8162 function hasExpectedRequestMetadata(action, validStatus) {
8163 if (!action || !action.meta)
8164 return false;
8165 var hasValidRequestId = typeof action.meta.requestId === "string";
8166 var hasValidRequestStatus = validStatus.indexOf(action.meta.requestStatus) > -1;
8167 return hasValidRequestId && hasValidRequestStatus;
8168 }
8169 function isAsyncThunkArray(a) {
8170 return typeof a[0] === "function" && "pending" in a[0] && "fulfilled" in a[0] && "rejected" in a[0];
8171 }
8172 function isPending() {
8173 var asyncThunks = [];
8174 for (var _i = 0; _i < arguments.length; _i++) {
8175 asyncThunks[_i] = arguments[_i];
8176 }
8177 if (asyncThunks.length === 0) {
8178 return function (action) { return hasExpectedRequestMetadata(action, ["pending"]); };
8179 }
8180 if (!isAsyncThunkArray(asyncThunks)) {
8181 return isPending()(asyncThunks[0]);
8182 }
8183 return function (action) {
8184 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.pending; });
8185 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8186 return combinedMatcher(action);
8187 };
8188 }
8189 function isRejected() {
8190 var asyncThunks = [];
8191 for (var _i = 0; _i < arguments.length; _i++) {
8192 asyncThunks[_i] = arguments[_i];
8193 }
8194 if (asyncThunks.length === 0) {
8195 return function (action) { return hasExpectedRequestMetadata(action, ["rejected"]); };
8196 }
8197 if (!isAsyncThunkArray(asyncThunks)) {
8198 return isRejected()(asyncThunks[0]);
8199 }
8200 return function (action) {
8201 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.rejected; });
8202 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8203 return combinedMatcher(action);
8204 };
8205 }
8206 function isRejectedWithValue() {
8207 var asyncThunks = [];
8208 for (var _i = 0; _i < arguments.length; _i++) {
8209 asyncThunks[_i] = arguments[_i];
8210 }
8211 var hasFlag = function (action) {
8212 return action && action.meta && action.meta.rejectedWithValue;
8213 };
8214 if (asyncThunks.length === 0) {
8215 return function (action) {
8216 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8217 return combinedMatcher(action);
8218 };
8219 }
8220 if (!isAsyncThunkArray(asyncThunks)) {
8221 return isRejectedWithValue()(asyncThunks[0]);
8222 }
8223 return function (action) {
8224 var combinedMatcher = isAllOf(isRejected.apply(void 0, asyncThunks), hasFlag);
8225 return combinedMatcher(action);
8226 };
8227 }
8228 function isFulfilled() {
8229 var asyncThunks = [];
8230 for (var _i = 0; _i < arguments.length; _i++) {
8231 asyncThunks[_i] = arguments[_i];
8232 }
8233 if (asyncThunks.length === 0) {
8234 return function (action) { return hasExpectedRequestMetadata(action, ["fulfilled"]); };
8235 }
8236 if (!isAsyncThunkArray(asyncThunks)) {
8237 return isFulfilled()(asyncThunks[0]);
8238 }
8239 return function (action) {
8240 var matchers = asyncThunks.map(function (asyncThunk) { return asyncThunk.fulfilled; });
8241 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8242 return combinedMatcher(action);
8243 };
8244 }
8245 function isAsyncThunkAction() {
8246 var asyncThunks = [];
8247 for (var _i = 0; _i < arguments.length; _i++) {
8248 asyncThunks[_i] = arguments[_i];
8249 }
8250 if (asyncThunks.length === 0) {
8251 return function (action) { return hasExpectedRequestMetadata(action, ["pending", "fulfilled", "rejected"]); };
8252 }
8253 if (!isAsyncThunkArray(asyncThunks)) {
8254 return isAsyncThunkAction()(asyncThunks[0]);
8255 }
8256 return function (action) {
8257 var matchers = [];
8258 for (var _i = 0, asyncThunks_1 = asyncThunks; _i < asyncThunks_1.length; _i++) {
8259 var asyncThunk = asyncThunks_1[_i];
8260 matchers.push(asyncThunk.pending, asyncThunk.rejected, asyncThunk.fulfilled);
8261 }
8262 var combinedMatcher = isAnyOf.apply(void 0, matchers);
8263 return combinedMatcher(action);
8264 };
8265 }
8266 // src/listenerMiddleware/utils.ts
8267 var assertFunction = function (func, expected) {
8268 if (typeof func !== "function") {
8269 throw new TypeError(expected + " is not a function");
8270 }
8271 };
8272 var noop = function () {
8273 };
8274 var catchRejection = function (promise2, onError) {
8275 if (onError === void 0) { onError = noop; }
8276 promise2.catch(onError);
8277 return promise2;
8278 };
8279 var addAbortSignalListener = function (abortSignal, callback) {
8280 abortSignal.addEventListener("abort", callback, { once: true });
8281 return function () { return abortSignal.removeEventListener("abort", callback); };
8282 };
8283 var abortControllerWithReason = function (abortController, reason) {
8284 var signal = abortController.signal;
8285 if (signal.aborted) {
8286 return;
8287 }
8288 if (!("reason" in signal)) {
8289 Object.defineProperty(signal, "reason", {
8290 enumerable: true,
8291 value: reason,
8292 configurable: true,
8293 writable: true
8294 });
8295 }
8296 ;
8297 abortController.abort(reason);
8298 };
8299 // src/listenerMiddleware/exceptions.ts
8300 var task = "task";
8301 var listener = "listener";
8302 var completed = "completed";
8303 var cancelled = "cancelled";
8304 var taskCancelled = "task-" + cancelled;
8305 var taskCompleted = "task-" + completed;
8306 var listenerCancelled = listener + "-" + cancelled;
8307 var listenerCompleted = listener + "-" + completed;
8308 var TaskAbortError = /** @class */ (function () {
8309 function TaskAbortError(code) {
8310 this.code = code;
8311 this.name = "TaskAbortError";
8312 this.message = task + " " + cancelled + " (reason: " + code + ")";
8313 }
8314 return TaskAbortError;
8315 }());
8316 // src/listenerMiddleware/task.ts
8317 var validateActive = function (signal) {
8318 if (signal.aborted) {
8319 throw new TaskAbortError(signal.reason);
8320 }
8321 };
8322 function raceWithSignal(signal, promise2) {
8323 var cleanup = noop;
8324 return new Promise(function (resolve, reject) {
8325 var notifyRejection = function () { return reject(new TaskAbortError(signal.reason)); };
8326 if (signal.aborted) {
8327 notifyRejection();
8328 return;
8329 }
8330 cleanup = addAbortSignalListener(signal, notifyRejection);
8331 promise2.finally(function () { return cleanup(); }).then(resolve, reject);
8332 }).finally(function () {
8333 cleanup = noop;
8334 });
8335 }
8336 var runTask = function (task2, cleanUp) { return __async(void 0, null, function () {
8337 var value, error_1;
8338 return __generator(this, function (_c) {
8339 switch (_c.label) {
8340 case 0:
8341 _c.trys.push([0, 3, 4, 5]);
8342 return [4 /*yield*/, Promise.resolve()];
8343 case 1:
8344 _c.sent();
8345 return [4 /*yield*/, task2()];
8346 case 2:
8347 value = _c.sent();
8348 return [2 /*return*/, {
8349 status: "ok",
8350 value: value
8351 }];
8352 case 3:
8353 error_1 = _c.sent();
8354 return [2 /*return*/, {
8355 status: error_1 instanceof TaskAbortError ? "cancelled" : "rejected",
8356 error: error_1
8357 }];
8358 case 4:
8359 cleanUp == null ? void 0 : cleanUp();
8360 return [7 /*endfinally*/];
8361 case 5: return [2 /*return*/];
8362 }
8363 });
8364 }); };
8365 var createPause = function (signal) {
8366 return function (promise2) {
8367 return catchRejection(raceWithSignal(signal, promise2).then(function (output) {
8368 validateActive(signal);
8369 return output;
8370 }));
8371 };
8372 };
8373 var createDelay = function (signal) {
8374 var pause = createPause(signal);
8375 return function (timeoutMs) {
8376 return pause(new Promise(function (resolve) { return setTimeout(resolve, timeoutMs); }));
8377 };
8378 };
8379 // src/listenerMiddleware/index.ts
8380 var assign = Object.assign;
8381 var INTERNAL_NIL_TOKEN = {};
8382 var alm = "listenerMiddleware";
8383 var createFork = function (parentAbortSignal, parentBlockingPromises) {
8384 var linkControllers = function (controller) { return addAbortSignalListener(parentAbortSignal, function () { return abortControllerWithReason(controller, parentAbortSignal.reason); }); };
8385 return function (taskExecutor, opts) {
8386 assertFunction(taskExecutor, "taskExecutor");
8387 var childAbortController = new AbortController();
8388 linkControllers(childAbortController);
8389 var result = runTask(function () { return __async(void 0, null, function () {
8390 var result2;
8391 return __generator(this, function (_c) {
8392 switch (_c.label) {
8393 case 0:
8394 validateActive(parentAbortSignal);
8395 validateActive(childAbortController.signal);
8396 return [4 /*yield*/, taskExecutor({
8397 pause: createPause(childAbortController.signal),
8398 delay: createDelay(childAbortController.signal),
8399 signal: childAbortController.signal
8400 })];
8401 case 1:
8402 result2 = _c.sent();
8403 validateActive(childAbortController.signal);
8404 return [2 /*return*/, result2];
8405 }
8406 });
8407 }); }, function () { return abortControllerWithReason(childAbortController, taskCompleted); });
8408 if (opts == null ? void 0 : opts.autoJoin) {
8409 parentBlockingPromises.push(result);
8410 }
8411 return {
8412 result: createPause(parentAbortSignal)(result),
8413 cancel: function () {
8414 abortControllerWithReason(childAbortController, taskCancelled);
8415 }
8416 };
8417 };
8418 };
8419 var createTakePattern = function (startListening, signal) {
8420 var take = function (predicate, timeout) { return __async(void 0, null, function () {
8421 var unsubscribe, tuplePromise, promises, output;
8422 return __generator(this, function (_c) {
8423 switch (_c.label) {
8424 case 0:
8425 validateActive(signal);
8426 unsubscribe = function () {
8427 };
8428 tuplePromise = new Promise(function (resolve, reject) {
8429 var stopListening = startListening({
8430 predicate: predicate,
8431 effect: function (action, listenerApi) {
8432 listenerApi.unsubscribe();
8433 resolve([
8434 action,
8435 listenerApi.getState(),
8436 listenerApi.getOriginalState()
8437 ]);
8438 }
8439 });
8440 unsubscribe = function () {
8441 stopListening();
8442 reject();
8443 };
8444 });
8445 promises = [
8446 tuplePromise
8447 ];
8448 if (timeout != null) {
8449 promises.push(new Promise(function (resolve) { return setTimeout(resolve, timeout, null); }));
8450 }
8451 _c.label = 1;
8452 case 1:
8453 _c.trys.push([1, , 3, 4]);
8454 return [4 /*yield*/, raceWithSignal(signal, Promise.race(promises))];
8455 case 2:
8456 output = _c.sent();
8457 validateActive(signal);
8458 return [2 /*return*/, output];
8459 case 3:
8460 unsubscribe();
8461 return [7 /*endfinally*/];
8462 case 4: return [2 /*return*/];
8463 }
8464 });
8465 }); };
8466 return function (predicate, timeout) { return catchRejection(take(predicate, timeout)); };
8467 };
8468 var getListenerEntryPropsFrom = function (options) {
8469 var type = options.type, actionCreator = options.actionCreator, matcher = options.matcher, predicate = options.predicate, effect = options.effect;
8470 if (type) {
8471 predicate = createAction(type).match;
8472 }
8473 else if (actionCreator) {
8474 type = actionCreator.type;
8475 predicate = actionCreator.match;
8476 }
8477 else if (matcher) {
8478 predicate = matcher;
8479 }
8480 else if (predicate) {
8481 }
8482 else {
8483 throw new Error("Creating or removing a listener requires one of the known fields for matching an action");
8484 }
8485 assertFunction(effect, "options.listener");
8486 return { predicate: predicate, type: type, effect: effect };
8487 };
8488 var createListenerEntry = function (options) {
8489 var _c = getListenerEntryPropsFrom(options), type = _c.type, predicate = _c.predicate, effect = _c.effect;
8490 var id = nanoid();
8491 var entry = {
8492 id: id,
8493 effect: effect,
8494 type: type,
8495 predicate: predicate,
8496 pending: new Set(),
8497 unsubscribe: function () {
8498 throw new Error("Unsubscribe not initialized");
8499 }
8500 };
8501 return entry;
8502 };
8503 var cancelActiveListeners = function (entry) {
8504 entry.pending.forEach(function (controller) {
8505 abortControllerWithReason(controller, listenerCancelled);
8506 });
8507 };
8508 var createClearListenerMiddleware = function (listenerMap) {
8509 return function () {
8510 listenerMap.forEach(cancelActiveListeners);
8511 listenerMap.clear();
8512 };
8513 };
8514 var safelyNotifyError = function (errorHandler, errorToNotify, errorInfo) {
8515 try {
8516 errorHandler(errorToNotify, errorInfo);
8517 }
8518 catch (errorHandlerError) {
8519 setTimeout(function () {
8520 throw errorHandlerError;
8521 }, 0);
8522 }
8523 };
8524 var addListener = createAction(alm + "/add");
8525 var clearAllListeners = createAction(alm + "/removeAll");
8526 var removeListener = createAction(alm + "/remove");
8527 var defaultErrorHandler = function () {
8528 var args = [];
8529 for (var _i = 0; _i < arguments.length; _i++) {
8530 args[_i] = arguments[_i];
8531 }
8532 console.error.apply(console, __spreadArray([alm + "/error"], args));
8533 };
8534 function createListenerMiddleware(middlewareOptions) {
8535 var _this = this;
8536 if (middlewareOptions === void 0) { middlewareOptions = {}; }
8537 var listenerMap = new Map();
8538 var extra = middlewareOptions.extra, _c = middlewareOptions.onError, onError = _c === void 0 ? defaultErrorHandler : _c;
8539 assertFunction(onError, "onError");
8540 var insertEntry = function (entry) {
8541 entry.unsubscribe = function () { return listenerMap.delete(entry.id); };
8542 listenerMap.set(entry.id, entry);
8543 return function (cancelOptions) {
8544 entry.unsubscribe();
8545 if (cancelOptions == null ? void 0 : cancelOptions.cancelActive) {
8546 cancelActiveListeners(entry);
8547 }
8548 };
8549 };
8550 var findListenerEntry = function (comparator) {
8551 for (var _i = 0, _c = Array.from(listenerMap.values()); _i < _c.length; _i++) {
8552 var entry = _c[_i];
8553 if (comparator(entry)) {
8554 return entry;
8555 }
8556 }
8557 return void 0;
8558 };
8559 var startListening = function (options) {
8560 var entry = findListenerEntry(function (existingEntry) { return existingEntry.effect === options.effect; });
8561 if (!entry) {
8562 entry = createListenerEntry(options);
8563 }
8564 return insertEntry(entry);
8565 };
8566 var stopListening = function (options) {
8567 var _c = getListenerEntryPropsFrom(options), type = _c.type, effect = _c.effect, predicate = _c.predicate;
8568 var entry = findListenerEntry(function (entry2) {
8569 var matchPredicateOrType = typeof type === "string" ? entry2.type === type : entry2.predicate === predicate;
8570 return matchPredicateOrType && entry2.effect === effect;
8571 });
8572 if (entry) {
8573 entry.unsubscribe();
8574 if (options.cancelActive) {
8575 cancelActiveListeners(entry);
8576 }
8577 }
8578 return !!entry;
8579 };
8580 var notifyListener = function (entry, action, api, getOriginalState) { return __async(_this, null, function () {
8581 var internalTaskController, take, autoJoinPromises, listenerError_1;
8582 return __generator(this, function (_c) {
8583 switch (_c.label) {
8584 case 0:
8585 internalTaskController = new AbortController();
8586 take = createTakePattern(startListening, internalTaskController.signal);
8587 autoJoinPromises = [];
8588 _c.label = 1;
8589 case 1:
8590 _c.trys.push([1, 3, 4, 6]);
8591 entry.pending.add(internalTaskController);
8592 return [4 /*yield*/, Promise.resolve(entry.effect(action, assign({}, api, {
8593 getOriginalState: getOriginalState,
8594 condition: function (predicate, timeout) { return take(predicate, timeout).then(Boolean); },
8595 take: take,
8596 delay: createDelay(internalTaskController.signal),
8597 pause: createPause(internalTaskController.signal),
8598 extra: extra,
8599 signal: internalTaskController.signal,
8600 fork: createFork(internalTaskController.signal, autoJoinPromises),
8601 unsubscribe: entry.unsubscribe,
8602 subscribe: function () {
8603 listenerMap.set(entry.id, entry);
8604 },
8605 cancelActiveListeners: function () {
8606 entry.pending.forEach(function (controller, _, set) {
8607 if (controller !== internalTaskController) {
8608 abortControllerWithReason(controller, listenerCancelled);
8609 set.delete(controller);
8610 }
8611 });
8612 }
8613 })))];
8614 case 2:
8615 _c.sent();
8616 return [3 /*break*/, 6];
8617 case 3:
8618 listenerError_1 = _c.sent();
8619 if (!(listenerError_1 instanceof TaskAbortError)) {
8620 safelyNotifyError(onError, listenerError_1, {
8621 raisedBy: "effect"
8622 });
8623 }
8624 return [3 /*break*/, 6];
8625 case 4: return [4 /*yield*/, Promise.allSettled(autoJoinPromises)];
8626 case 5:
8627 _c.sent();
8628 abortControllerWithReason(internalTaskController, listenerCompleted);
8629 entry.pending.delete(internalTaskController);
8630 return [7 /*endfinally*/];
8631 case 6: return [2 /*return*/];
8632 }
8633 });
8634 }); };
8635 var clearListenerMiddleware = createClearListenerMiddleware(listenerMap);
8636 var middleware = function (api) { return function (next) { return function (action) {
8637 if (!isAction(action)) {
8638 return next(action);
8639 }
8640 if (addListener.match(action)) {
8641 return startListening(action.payload);
8642 }
8643 if (clearAllListeners.match(action)) {
8644 clearListenerMiddleware();
8645 return;
8646 }
8647 if (removeListener.match(action)) {
8648 return stopListening(action.payload);
8649 }
8650 var originalState = api.getState();
8651 var getOriginalState = function () {
8652 if (originalState === INTERNAL_NIL_TOKEN) {
8653 throw new Error(alm + ": getOriginalState can only be called synchronously");
8654 }
8655 return originalState;
8656 };
8657 var result;
8658 try {
8659 result = next(action);
8660 if (listenerMap.size > 0) {
8661 var currentState = api.getState();
8662 var listenerEntries = Array.from(listenerMap.values());
8663 for (var _i = 0, listenerEntries_1 = listenerEntries; _i < listenerEntries_1.length; _i++) {
8664 var entry = listenerEntries_1[_i];
8665 var runListener = false;
8666 try {
8667 runListener = entry.predicate(action, currentState, originalState);
8668 }
8669 catch (predicateError) {
8670 runListener = false;
8671 safelyNotifyError(onError, predicateError, {
8672 raisedBy: "predicate"
8673 });
8674 }
8675 if (!runListener) {
8676 continue;
8677 }
8678 notifyListener(entry, action, api, getOriginalState);
8679 }
8680 }
8681 }
8682 finally {
8683 originalState = INTERNAL_NIL_TOKEN;
8684 }
8685 return result;
8686 }; }; };
8687 return {
8688 middleware: middleware,
8689 startListening: startListening,
8690 stopListening: stopListening,
8691 clearListeners: clearListenerMiddleware
8692 };
8693 }
8694 // src/autoBatchEnhancer.ts
8695 var SHOULD_AUTOBATCH = "RTK_autoBatch";
8696 var prepareAutoBatched = function () { return function (payload) {
8697 var _c;
8698 return ({
8699 payload: payload,
8700 meta: (_c = {}, _c[SHOULD_AUTOBATCH] = true, _c)
8701 });
8702 }; };
8703 var promise;
8704 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 () {
8705 throw err;
8706 }, 0); }); };
8707 var createQueueWithTimer = function (timeout) {
8708 return function (notify) {
8709 setTimeout(notify, timeout);
8710 };
8711 };
8712 var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
8713 var autoBatchEnhancer = function (options) {
8714 if (options === void 0) { options = { type: "raf" }; }
8715 return function (next) { return function () {
8716 var args = [];
8717 for (var _i = 0; _i < arguments.length; _i++) {
8718 args[_i] = arguments[_i];
8719 }
8720 var store = next.apply(void 0, args);
8721 var notifying = true;
8722 var shouldNotifyAtEndOfTick = false;
8723 var notificationQueued = false;
8724 var listeners = new Set();
8725 var queueCallback = options.type === "tick" ? queueMicrotaskShim : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
8726 var notifyListeners = function () {
8727 notificationQueued = false;
8728 if (shouldNotifyAtEndOfTick) {
8729 shouldNotifyAtEndOfTick = false;
8730 listeners.forEach(function (l) { return l(); });
8731 }
8732 };
8733 return Object.assign({}, store, {
8734 subscribe: function (listener2) {
8735 var wrappedListener = function () { return notifying && listener2(); };
8736 var unsubscribe = store.subscribe(wrappedListener);
8737 listeners.add(listener2);
8738 return function () {
8739 unsubscribe();
8740 listeners.delete(listener2);
8741 };
8742 },
8743 dispatch: function (action) {
8744 var _a;
8745 try {
8746 notifying = !((_a = action == null ? void 0 : action.meta) == null ? void 0 : _a[SHOULD_AUTOBATCH]);
8747 shouldNotifyAtEndOfTick = !notifying;
8748 if (shouldNotifyAtEndOfTick) {
8749 if (!notificationQueued) {
8750 notificationQueued = true;
8751 queueCallback(notifyListeners);
8752 }
8753 }
8754 return store.dispatch(action);
8755 }
8756 finally {
8757 notifying = true;
8758 }
8759 }
8760 });
8761 }; };
8762 };
8763 // src/index.ts
8764 (0,immer__WEBPACK_IMPORTED_MODULE_0__.enableES5)();
8765
8766 //# sourceMappingURL=redux-toolkit.esm.js.map
8767
8768 /***/ }),
8769
8770 /***/ "../node_modules/immer/dist/immer.esm.mjs":
8771 /*!************************************************!*\
8772 !*** ../node_modules/immer/dist/immer.esm.mjs ***!
8773 \************************************************/
8774 /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8775
8776 "use strict";
8777 __webpack_require__.r(__webpack_exports__);
8778 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8779 /* harmony export */ Immer: () => (/* binding */ un),
8780 /* harmony export */ applyPatches: () => (/* binding */ pn),
8781 /* harmony export */ castDraft: () => (/* binding */ K),
8782 /* harmony export */ castImmutable: () => (/* binding */ $),
8783 /* harmony export */ createDraft: () => (/* binding */ ln),
8784 /* harmony export */ current: () => (/* binding */ R),
8785 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
8786 /* harmony export */ enableAllPlugins: () => (/* binding */ J),
8787 /* harmony export */ enableES5: () => (/* binding */ F),
8788 /* harmony export */ enableMapSet: () => (/* binding */ C),
8789 /* harmony export */ enablePatches: () => (/* binding */ T),
8790 /* harmony export */ finishDraft: () => (/* binding */ dn),
8791 /* harmony export */ freeze: () => (/* binding */ d),
8792 /* harmony export */ immerable: () => (/* binding */ L),
8793 /* harmony export */ isDraft: () => (/* binding */ r),
8794 /* harmony export */ isDraftable: () => (/* binding */ t),
8795 /* harmony export */ nothing: () => (/* binding */ H),
8796 /* harmony export */ original: () => (/* binding */ e),
8797 /* harmony export */ produce: () => (/* binding */ fn),
8798 /* harmony export */ produceWithPatches: () => (/* binding */ cn),
8799 /* harmony export */ setAutoFreeze: () => (/* binding */ sn),
8800 /* harmony export */ setUseProxies: () => (/* binding */ vn)
8801 /* harmony export */ });
8802 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
8803 }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);
8804 //# sourceMappingURL=immer.esm.js.map
8805
8806
8807 /***/ }),
8808
8809 /***/ "../node_modules/mixpanel-browser/dist/mixpanel.module.js":
8810 /*!****************************************************************!*\
8811 !*** ../node_modules/mixpanel-browser/dist/mixpanel.module.js ***!
8812 \****************************************************************/
8813 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8814
8815 "use strict";
8816 __webpack_require__.r(__webpack_exports__);
8817 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8818 /* harmony export */ "default": () => (/* binding */ mixpanel)
8819 /* harmony export */ });
8820 // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
8821 var win;
8822 if (typeof(window) === 'undefined') {
8823 var loc = {
8824 hostname: ''
8825 };
8826 win = {
8827 crypto: {randomUUID: function() {throw Error('unsupported');}},
8828 navigator: { userAgent: '', onLine: true },
8829 document: {
8830 createElement: function() { return {}; },
8831 location: loc,
8832 referrer: ''
8833 },
8834 screen: { width: 0, height: 0 },
8835 location: loc,
8836 addEventListener: function() {},
8837 removeEventListener: function() {}
8838 };
8839 } else {
8840 win = window;
8841 }
8842
8843 function _array_like_to_array(arr, len) {
8844 if (len == null || len > arr.length) len = arr.length;
8845 for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
8846 return arr2;
8847 }
8848 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8849 try {
8850 var info = gen[key](arg);
8851 var value = info.value;
8852 } catch (error) {
8853 reject(error);
8854 return;
8855 }
8856 if (info.done) {
8857 resolve(value);
8858 } else {
8859 Promise.resolve(value).then(_next, _throw);
8860 }
8861 }
8862 function _async_to_generator(fn) {
8863 return function() {
8864 var self = this, args = arguments;
8865 return new Promise(function(resolve, reject) {
8866 var gen = fn.apply(self, args);
8867 function _next(value) {
8868 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8869 }
8870 function _throw(err) {
8871 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8872 }
8873 _next(undefined);
8874 });
8875 };
8876 }
8877 function _construct(Parent, args, Class) {
8878 if (_is_native_reflect_construct()) {
8879 _construct = Reflect.construct;
8880 } else {
8881 _construct = function construct(Parent, args, Class) {
8882 var a = [
8883 null
8884 ];
8885 a.push.apply(a, args);
8886 var Constructor = Function.bind.apply(Parent, a);
8887 var instance = new Constructor();
8888 if (Class) _set_prototype_of(instance, Class.prototype);
8889 return instance;
8890 };
8891 }
8892 return _construct.apply(null, arguments);
8893 }
8894 function _defineProperties(target, props) {
8895 for(var i = 0; i < props.length; i++){
8896 var descriptor = props[i];
8897 descriptor.enumerable = descriptor.enumerable || false;
8898 descriptor.configurable = true;
8899 if ("value" in descriptor) descriptor.writable = true;
8900 Object.defineProperty(target, descriptor.key, descriptor);
8901 }
8902 }
8903 function _create_class(Constructor, protoProps, staticProps) {
8904 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
8905 return Constructor;
8906 }
8907 function _extends() {
8908 _extends = Object.assign || function(target) {
8909 for(var i = 1; i < arguments.length; i++){
8910 var source = arguments[i];
8911 for(var key in source){
8912 if (Object.prototype.hasOwnProperty.call(source, key)) {
8913 target[key] = source[key];
8914 }
8915 }
8916 }
8917 return target;
8918 };
8919 return _extends.apply(this, arguments);
8920 }
8921 function _get_prototype_of(o) {
8922 _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
8923 return o.__proto__ || Object.getPrototypeOf(o);
8924 };
8925 return _get_prototype_of(o);
8926 }
8927 function _inherits(subClass, superClass) {
8928 if (typeof superClass !== "function" && superClass !== null) {
8929 throw new TypeError("Super expression must either be null or a function");
8930 }
8931 subClass.prototype = Object.create(superClass && superClass.prototype, {
8932 constructor: {
8933 value: subClass,
8934 writable: true,
8935 configurable: true
8936 }
8937 });
8938 if (superClass) _set_prototype_of(subClass, superClass);
8939 }
8940 function _instanceof(left, right) {
8941 if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
8942 return !!right[Symbol.hasInstance](left);
8943 } else {
8944 return left instanceof right;
8945 }
8946 }
8947 function _is_native_function(fn) {
8948 return Function.toString.call(fn).indexOf("[native code]") !== -1;
8949 }
8950 function _object_without_properties_loose(source, excluded) {
8951 if (source == null) return {};
8952 var target = {};
8953 var sourceKeys = Object.keys(source);
8954 var key, i;
8955 for(i = 0; i < sourceKeys.length; i++){
8956 key = sourceKeys[i];
8957 if (excluded.indexOf(key) >= 0) continue;
8958 target[key] = source[key];
8959 }
8960 return target;
8961 }
8962 function _set_prototype_of(o, p) {
8963 _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8964 o.__proto__ = p;
8965 return o;
8966 };
8967 return _set_prototype_of(o, p);
8968 }
8969 function _type_of(obj) {
8970 "@swc/helpers - typeof";
8971 return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8972 }
8973 function _unsupported_iterable_to_array(o, minLen) {
8974 if (!o) return;
8975 if (typeof o === "string") return _array_like_to_array(o, minLen);
8976 var n = Object.prototype.toString.call(o).slice(8, -1);
8977 if (n === "Object" && o.constructor) n = o.constructor.name;
8978 if (n === "Map" || n === "Set") return Array.from(n);
8979 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
8980 }
8981 function _wrap_native_super(Class) {
8982 var _cache = typeof Map === "function" ? new Map() : undefined;
8983 _wrap_native_super = function wrapNativeSuper(Class) {
8984 if (Class === null || !_is_native_function(Class)) return Class;
8985 if (typeof Class !== "function") {
8986 throw new TypeError("Super expression must either be null or a function");
8987 }
8988 if (typeof _cache !== "undefined") {
8989 if (_cache.has(Class)) return _cache.get(Class);
8990 _cache.set(Class, Wrapper);
8991 }
8992 function Wrapper() {
8993 return _construct(Class, arguments, _get_prototype_of(this).constructor);
8994 }
8995 Wrapper.prototype = Object.create(Class.prototype, {
8996 constructor: {
8997 value: Wrapper,
8998 enumerable: false,
8999 writable: true,
9000 configurable: true
9001 }
9002 });
9003 return _set_prototype_of(Wrapper, Class);
9004 };
9005 return _wrap_native_super(Class);
9006 }
9007 function _is_native_reflect_construct() {
9008 try {
9009 var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
9010 } catch (_) {}
9011 return (_is_native_reflect_construct = function() {
9012 return !!result;
9013 })();
9014 }
9015 function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
9016 var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
9017 if (it) return (it = it.call(o)).next.bind(it);
9018 if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike) {
9019 if (it) o = it;
9020 var i = 0;
9021 return function() {
9022 if (i >= o.length) {
9023 return {
9024 done: true
9025 };
9026 }
9027 return {
9028 done: false,
9029 value: o[i++]
9030 };
9031 };
9032 }
9033 throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9034 }
9035 function _ts_generator(thisArg, body) {
9036 var f, y, t, g, _ = {
9037 label: 0,
9038 sent: function() {
9039 if (t[0] & 1) throw t[1];
9040 return t[1];
9041 },
9042 trys: [],
9043 ops: []
9044 };
9045 return g = {
9046 next: verb(0),
9047 "throw": verb(1),
9048 "return": verb(2)
9049 }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
9050 return this;
9051 }), g;
9052 function verb(n) {
9053 return function(v) {
9054 return step([
9055 n,
9056 v
9057 ]);
9058 };
9059 }
9060 function step(op) {
9061 if (f) throw new TypeError("Generator is already executing.");
9062 while(_)try {
9063 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;
9064 if (y = 0, t) op = [
9065 op[0] & 2,
9066 t.value
9067 ];
9068 switch(op[0]){
9069 case 0:
9070 case 1:
9071 t = op;
9072 break;
9073 case 4:
9074 _.label++;
9075 return {
9076 value: op[1],
9077 done: false
9078 };
9079 case 5:
9080 _.label++;
9081 y = op[1];
9082 op = [
9083 0
9084 ];
9085 continue;
9086 case 7:
9087 op = _.ops.pop();
9088 _.trys.pop();
9089 continue;
9090 default:
9091 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
9092 _ = 0;
9093 continue;
9094 }
9095 if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
9096 _.label = op[1];
9097 break;
9098 }
9099 if (op[0] === 6 && _.label < t[1]) {
9100 _.label = t[1];
9101 t = op;
9102 break;
9103 }
9104 if (t && _.label < t[2]) {
9105 _.label = t[2];
9106 _.ops.push(op);
9107 break;
9108 }
9109 if (t[2]) _.ops.pop();
9110 _.trys.pop();
9111 continue;
9112 }
9113 op = body.call(thisArg, _);
9114 } catch (e) {
9115 op = [
9116 6,
9117 e
9118 ];
9119 y = 0;
9120 } finally{
9121 f = t = 0;
9122 }
9123 if (op[0] & 5) throw op[1];
9124 return {
9125 value: op[0] ? op[1] : void 0,
9126 done: true
9127 };
9128 }
9129 }
9130 function _ts_values(o) {
9131 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
9132 if (m) return m.call(o);
9133 if (o && typeof o.length === "number") return {
9134 next: function() {
9135 if (o && i >= o.length) o = void 0;
9136 return {
9137 value: o && o[i++],
9138 done: !o
9139 };
9140 }
9141 };
9142 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
9143 }
9144 var __defProp = Object.defineProperty;
9145 var __defNormalProp = function(obj, key, value) {
9146 return key in obj ? __defProp(obj, key, {
9147 enumerable: true,
9148 configurable: true,
9149 writable: true,
9150 value: value
9151 }) : obj[key] = value;
9152 };
9153 var __publicField = function(obj, key, value) {
9154 return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9155 };
9156 var _a;
9157 var __defProp$1 = Object.defineProperty;
9158 var __defNormalProp$1 = function(obj, key, value) {
9159 return key in obj ? __defProp$1(obj, key, {
9160 enumerable: true,
9161 configurable: true,
9162 writable: true,
9163 value: value
9164 }) : obj[key] = value;
9165 };
9166 var __publicField$1 = function(obj, key, value) {
9167 return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
9168 };
9169 var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
9170 NodeType2[NodeType2["Document"] = 0] = "Document";
9171 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9172 NodeType2[NodeType2["Element"] = 2] = "Element";
9173 NodeType2[NodeType2["Text"] = 3] = "Text";
9174 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
9175 NodeType2[NodeType2["Comment"] = 5] = "Comment";
9176 return NodeType2;
9177 }(NodeType$3 || {});
9178 var testableAccessors$1 = {
9179 Node: [
9180 "childNodes",
9181 "parentNode",
9182 "parentElement",
9183 "textContent"
9184 ],
9185 ShadowRoot: [
9186 "host",
9187 "styleSheets"
9188 ],
9189 Element: [
9190 "shadowRoot",
9191 "querySelector",
9192 "querySelectorAll"
9193 ],
9194 MutationObserver: []
9195 };
9196 var testableMethods$1 = {
9197 Node: [
9198 "contains",
9199 "getRootNode"
9200 ],
9201 ShadowRoot: [
9202 "getSelection"
9203 ],
9204 Element: [],
9205 MutationObserver: [
9206 "constructor"
9207 ]
9208 };
9209 var untaintedBasePrototype$1 = {};
9210 var isAngularZonePresent$1 = function() {
9211 return !!globalThis.Zone;
9212 };
9213 function getUntaintedPrototype$1(key) {
9214 if (untaintedBasePrototype$1[key]) return untaintedBasePrototype$1[key];
9215 var defaultObj = globalThis[key];
9216 var defaultPrototype = defaultObj.prototype;
9217 var accessorNames = key in testableAccessors$1 ? testableAccessors$1[key] : void 0;
9218 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
9219 accessorNames.every(function(accessor) {
9220 var _a2, _b;
9221 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
9222 }));
9223 var methodNames = key in testableMethods$1 ? testableMethods$1[key] : void 0;
9224 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
9225 function(method) {
9226 var _a2;
9227 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
9228 }));
9229 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent$1()) {
9230 untaintedBasePrototype$1[key] = defaultObj.prototype;
9231 return defaultObj.prototype;
9232 }
9233 try {
9234 var iframeEl = document.createElement("iframe");
9235 document.body.appendChild(iframeEl);
9236 var win = iframeEl.contentWindow;
9237 if (!win) return defaultObj.prototype;
9238 var untaintedObject = win[key].prototype;
9239 document.body.removeChild(iframeEl);
9240 if (!untaintedObject) return defaultPrototype;
9241 return untaintedBasePrototype$1[key] = untaintedObject;
9242 } catch (e) {
9243 return defaultPrototype;
9244 }
9245 }
9246 var untaintedAccessorCache$1 = {};
9247 function getUntaintedAccessor$1(key, instance, accessor) {
9248 var _a2;
9249 var cacheKey = key + "." + String(accessor);
9250 if (untaintedAccessorCache$1[cacheKey]) return untaintedAccessorCache$1[cacheKey].call(instance);
9251 var untaintedPrototype = getUntaintedPrototype$1(key);
9252 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
9253 if (!untaintedAccessor) return instance[accessor];
9254 untaintedAccessorCache$1[cacheKey] = untaintedAccessor;
9255 return untaintedAccessor.call(instance);
9256 }
9257 var untaintedMethodCache$1 = {};
9258 function getUntaintedMethod$1(key, instance, method) {
9259 var cacheKey = key + "." + String(method);
9260 if (untaintedMethodCache$1[cacheKey]) return untaintedMethodCache$1[cacheKey].bind(instance);
9261 var untaintedPrototype = getUntaintedPrototype$1(key);
9262 var untaintedMethod = untaintedPrototype[method];
9263 if (typeof untaintedMethod !== "function") return instance[method];
9264 untaintedMethodCache$1[cacheKey] = untaintedMethod;
9265 return untaintedMethod.bind(instance);
9266 }
9267 function childNodes$1(n2) {
9268 return getUntaintedAccessor$1("Node", n2, "childNodes");
9269 }
9270 function parentNode$1(n2) {
9271 return getUntaintedAccessor$1("Node", n2, "parentNode");
9272 }
9273 function parentElement$1(n2) {
9274 return getUntaintedAccessor$1("Node", n2, "parentElement");
9275 }
9276 function textContent$1(n2) {
9277 return getUntaintedAccessor$1("Node", n2, "textContent");
9278 }
9279 function contains$1(n2, other) {
9280 return getUntaintedMethod$1("Node", n2, "contains")(other);
9281 }
9282 function getRootNode$1(n2) {
9283 return getUntaintedMethod$1("Node", n2, "getRootNode")();
9284 }
9285 function host$1(n2) {
9286 if (!n2 || !("host" in n2)) return null;
9287 return getUntaintedAccessor$1("ShadowRoot", n2, "host");
9288 }
9289 function styleSheets$1(n2) {
9290 return n2.styleSheets;
9291 }
9292 function shadowRoot$1(n2) {
9293 if (!n2 || !("shadowRoot" in n2)) return null;
9294 return getUntaintedAccessor$1("Element", n2, "shadowRoot");
9295 }
9296 function querySelector$1(n2, selectors) {
9297 return getUntaintedAccessor$1("Element", n2, "querySelector")(selectors);
9298 }
9299 function querySelectorAll$1(n2, selectors) {
9300 return getUntaintedAccessor$1("Element", n2, "querySelectorAll")(selectors);
9301 }
9302 function mutationObserverCtor$1() {
9303 return getUntaintedPrototype$1("MutationObserver").constructor;
9304 }
9305 function patch$1(source, name, replacement) {
9306 try {
9307 if (!(name in source)) {
9308 return function() {};
9309 }
9310 var original = source[name];
9311 var wrapped = replacement(original);
9312 if (typeof wrapped === "function") {
9313 wrapped.prototype = wrapped.prototype || {};
9314 Object.defineProperties(wrapped, {
9315 __rrweb_original__: {
9316 enumerable: false,
9317 value: original
9318 }
9319 });
9320 }
9321 source[name] = wrapped;
9322 return function() {
9323 source[name] = original;
9324 };
9325 } catch (e) {
9326 return function() {};
9327 }
9328 }
9329 var index$1 = {
9330 childNodes: childNodes$1,
9331 parentNode: parentNode$1,
9332 parentElement: parentElement$1,
9333 textContent: textContent$1,
9334 contains: contains$1,
9335 getRootNode: getRootNode$1,
9336 host: host$1,
9337 styleSheets: styleSheets$1,
9338 shadowRoot: shadowRoot$1,
9339 querySelector: querySelector$1,
9340 querySelectorAll: querySelectorAll$1,
9341 mutationObserver: mutationObserverCtor$1,
9342 patch: patch$1
9343 };
9344 function isElement(n2) {
9345 return n2.nodeType === n2.ELEMENT_NODE;
9346 }
9347 function isShadowRoot(n2) {
9348 var hostEl = // anchor and textarea elements also have a `host` property
9349 // but only shadow roots have a `mode` property
9350 n2 && "host" in n2 && "mode" in n2 && index$1.host(n2) || null;
9351 return Boolean(hostEl && "shadowRoot" in hostEl && index$1.shadowRoot(hostEl) === n2);
9352 }
9353 function isNativeShadowDom(shadowRoot2) {
9354 return Object.prototype.toString.call(shadowRoot2) === "[object ShadowRoot]";
9355 }
9356 function fixBrowserCompatibilityIssuesInCSS(cssText) {
9357 if (cssText.includes(" background-clip: text;") && !cssText.includes(" -webkit-background-clip: text;")) {
9358 cssText = cssText.replace(/\sbackground-clip:\s*text;/g, " -webkit-background-clip: text; background-clip: text;");
9359 }
9360 return cssText;
9361 }
9362 function escapeImportStatement(rule2) {
9363 var cssText = rule2.cssText;
9364 if (cssText.split('"').length < 3) return cssText;
9365 var statement = [
9366 "@import",
9367 "url(" + JSON.stringify(rule2.href) + ")"
9368 ];
9369 if (rule2.layerName === "") {
9370 statement.push("layer");
9371 } else if (rule2.layerName) {
9372 statement.push("layer(" + rule2.layerName + ")");
9373 }
9374 if (rule2.supportsText) {
9375 statement.push("supports(" + rule2.supportsText + ")");
9376 }
9377 if (rule2.media.length) {
9378 statement.push(rule2.media.mediaText);
9379 }
9380 return statement.join(" ") + ";";
9381 }
9382 function stringifyStylesheet(s2) {
9383 try {
9384 var rules2 = s2.rules || s2.cssRules;
9385 if (!rules2) {
9386 return null;
9387 }
9388 var sheetHref = s2.href;
9389 if (!sheetHref && s2.ownerNode && s2.ownerNode.ownerDocument) {
9390 sheetHref = s2.ownerNode.ownerDocument.location.href;
9391 }
9392 var stringifiedRules = Array.from(rules2, function(rule2) {
9393 return stringifyRule(rule2, sheetHref);
9394 }).join("");
9395 return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
9396 } catch (error) {
9397 return null;
9398 }
9399 }
9400 function stringifyRule(rule2, sheetHref) {
9401 if (isCSSImportRule(rule2)) {
9402 var importStringified;
9403 try {
9404 importStringified = // we can access the imported stylesheet rules directly
9405 stringifyStylesheet(rule2.styleSheet) || // work around browser issues with the raw string `@import url(...)` statement
9406 escapeImportStatement(rule2);
9407 } catch (error) {
9408 importStringified = rule2.cssText;
9409 }
9410 if (rule2.styleSheet.href) {
9411 return absolutifyURLs(importStringified, rule2.styleSheet.href);
9412 }
9413 return importStringified;
9414 } else {
9415 var ruleStringified = rule2.cssText;
9416 if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
9417 ruleStringified = fixSafariColons(ruleStringified);
9418 }
9419 if (sheetHref) {
9420 return absolutifyURLs(ruleStringified, sheetHref);
9421 }
9422 return ruleStringified;
9423 }
9424 }
9425 function fixSafariColons(cssStringified) {
9426 var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
9427 return cssStringified.replace(regex, "$1\\$2");
9428 }
9429 function isCSSImportRule(rule2) {
9430 return "styleSheet" in rule2;
9431 }
9432 function isCSSStyleRule(rule2) {
9433 return "selectorText" in rule2;
9434 }
9435 var Mirror = /*#__PURE__*/ function() {
9436 function Mirror() {
9437 __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
9438 __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
9439 }
9440 var _proto = Mirror.prototype;
9441 _proto.getId = function getId(n2) {
9442 var _a2;
9443 if (!n2) return -1;
9444 var id = (_a2 = this.getMeta(n2)) == null ? void 0 : _a2.id;
9445 return id != null ? id : -1;
9446 };
9447 _proto.getNode = function getNode(id) {
9448 return this.idNodeMap.get(id) || null;
9449 };
9450 _proto.getIds = function getIds() {
9451 return Array.from(this.idNodeMap.keys());
9452 };
9453 _proto.getMeta = function getMeta(n2) {
9454 return this.nodeMetaMap.get(n2) || null;
9455 };
9456 // removes the node from idNodeMap
9457 // doesn't remove the node from nodeMetaMap
9458 _proto.removeNodeFromMap = function removeNodeFromMap(n2) {
9459 var _this = this;
9460 var id = this.getId(n2);
9461 this.idNodeMap.delete(id);
9462 if (n2.childNodes) {
9463 n2.childNodes.forEach(function(childNode) {
9464 return _this.removeNodeFromMap(childNode);
9465 });
9466 }
9467 };
9468 _proto.has = function has(id) {
9469 return this.idNodeMap.has(id);
9470 };
9471 _proto.hasNode = function hasNode(node2) {
9472 return this.nodeMetaMap.has(node2);
9473 };
9474 _proto.add = function add(n2, meta) {
9475 var id = meta.id;
9476 this.idNodeMap.set(id, n2);
9477 this.nodeMetaMap.set(n2, meta);
9478 };
9479 _proto.replace = function replace(id, n2) {
9480 var oldNode = this.getNode(id);
9481 if (oldNode) {
9482 var meta = this.nodeMetaMap.get(oldNode);
9483 if (meta) this.nodeMetaMap.set(n2, meta);
9484 }
9485 this.idNodeMap.set(id, n2);
9486 };
9487 _proto.reset = function reset() {
9488 this.idNodeMap = /* @__PURE__ */ new Map();
9489 this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
9490 };
9491 return Mirror;
9492 }();
9493 function createMirror$2() {
9494 return new Mirror();
9495 }
9496 function maskInputValue(param) {
9497 var element = param.element, maskInputOptions = param.maskInputOptions, tagName = param.tagName, type = param.type, value = param.value, maskInputFn = param.maskInputFn;
9498 var text = value || "";
9499 var actualType = type && toLowerCase(type);
9500 if (maskInputOptions[tagName.toLowerCase()] || actualType && maskInputOptions[actualType]) {
9501 if (maskInputFn) {
9502 text = maskInputFn(text, element);
9503 } else {
9504 text = "*".repeat(text.length);
9505 }
9506 }
9507 return text;
9508 }
9509 function toLowerCase(str) {
9510 return str.toLowerCase();
9511 }
9512 var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
9513 function is2DCanvasBlank(canvas) {
9514 var ctx = canvas.getContext("2d");
9515 if (!ctx) return true;
9516 var chunkSize = 50;
9517 for(var x2 = 0; x2 < canvas.width; x2 += chunkSize){
9518 for(var y = 0; y < canvas.height; y += chunkSize){
9519 var getImageData = ctx.getImageData;
9520 var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
9521 var pixelBuffer = new Uint32Array(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
9522 originalGetImageData.call(ctx, x2, y, Math.min(chunkSize, canvas.width - x2), Math.min(chunkSize, canvas.height - y)).data.buffer);
9523 if (pixelBuffer.some(function(pixel) {
9524 return pixel !== 0;
9525 })) return false;
9526 }
9527 }
9528 return true;
9529 }
9530 function getInputType(element) {
9531 var type = element.type;
9532 return element.hasAttribute("data-rr-is-password") ? "password" : type ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
9533 toLowerCase(type) : null;
9534 }
9535 function extractFileExtension(path, baseURL) {
9536 var url;
9537 try {
9538 url = new URL(path, baseURL != null ? baseURL : window.location.href);
9539 } catch (err) {
9540 return null;
9541 }
9542 var regex = /\.([0-9a-z]+)(?:$)/i;
9543 var match = url.pathname.match(regex);
9544 var _ref;
9545 return (_ref = match == null ? void 0 : match[1]) != null ? _ref : null;
9546 }
9547 function extractOrigin(url) {
9548 var origin = "";
9549 if (url.indexOf("//") > -1) {
9550 origin = url.split("/").slice(0, 3).join("/");
9551 } else {
9552 origin = url.split("/")[0];
9553 }
9554 origin = origin.split("?")[0];
9555 return origin;
9556 }
9557 var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
9558 var URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
9559 var URL_WWW_MATCH = /^www\..*/i;
9560 var DATA_URI = /^(data:)([^,]*),(.*)/i;
9561 function absolutifyURLs(cssText, href) {
9562 return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
9563 var filePath = path1 || path2 || path3;
9564 var maybeQuote = quote1 || quote2 || "";
9565 if (!filePath) {
9566 return origin;
9567 }
9568 if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
9569 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9570 }
9571 if (DATA_URI.test(filePath)) {
9572 return "url(" + maybeQuote + filePath + maybeQuote + ")";
9573 }
9574 if (filePath[0] === "/") {
9575 return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
9576 }
9577 var stack = href.split("/");
9578 var parts = filePath.split("/");
9579 stack.pop();
9580 for(var _iterator = _create_for_of_iterator_helper_loose(parts), _step; !(_step = _iterator()).done;){
9581 var part = _step.value;
9582 if (part === ".") {
9583 continue;
9584 } else if (part === "..") {
9585 stack.pop();
9586 } else {
9587 stack.push(part);
9588 }
9589 }
9590 return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
9591 });
9592 }
9593 function normalizeCssString(cssText, _testNoPxNorm) {
9594 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9595 if (_testNoPxNorm) {
9596 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
9597 } else {
9598 return cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "").replace(/0px/g, "0");
9599 }
9600 }
9601 function splitCssText(cssText, style, _testNoPxNorm) {
9602 if (_testNoPxNorm === void 0) _testNoPxNorm = false;
9603 var childNodes2 = Array.from(style.childNodes);
9604 var splits = [];
9605 var iterCount = 0;
9606 if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
9607 var cssTextNorm = normalizeCssString(cssText, _testNoPxNorm);
9608 var normFactor = cssTextNorm.length / cssText.length;
9609 for(var i2 = 1; i2 < childNodes2.length; i2++){
9610 if (childNodes2[i2].textContent && typeof childNodes2[i2].textContent === "string") {
9611 var textContentNorm = normalizeCssString(childNodes2[i2].textContent, _testNoPxNorm);
9612 var jLimit = 100;
9613 var j = 3;
9614 for(; j < textContentNorm.length; j++){
9615 if (// keep consuming css identifiers (to get a decent chunk more quickly)
9616 textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
9617 textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1) {
9618 continue;
9619 }
9620 break;
9621 }
9622 for(; j < textContentNorm.length; j++){
9623 var startSubstring = textContentNorm.substring(0, j);
9624 var cssNormSplits = cssTextNorm.split(startSubstring);
9625 var splitNorm = -1;
9626 if (cssNormSplits.length === 2) {
9627 splitNorm = cssNormSplits[0].length;
9628 } else if (cssNormSplits.length > 2 && cssNormSplits[0] === "" && childNodes2[i2 - 1].textContent !== "") {
9629 splitNorm = cssTextNorm.indexOf(startSubstring, 1);
9630 } else if (cssNormSplits.length === 1) {
9631 startSubstring = startSubstring.substring(0, startSubstring.length - 1);
9632 cssNormSplits = cssTextNorm.split(startSubstring);
9633 if (cssNormSplits.length <= 1) {
9634 splits.push(cssText);
9635 return splits;
9636 }
9637 j = jLimit + 1;
9638 } else if (j === textContentNorm.length - 1) {
9639 splitNorm = cssTextNorm.indexOf(startSubstring);
9640 }
9641 if (cssNormSplits.length >= 2 && j > jLimit) {
9642 var prevTextContent = childNodes2[i2 - 1].textContent;
9643 if (prevTextContent && typeof prevTextContent === "string") {
9644 var prevMinLength = normalizeCssString(prevTextContent).length;
9645 splitNorm = cssTextNorm.indexOf(startSubstring, prevMinLength);
9646 }
9647 if (splitNorm === -1) {
9648 splitNorm = cssNormSplits[0].length;
9649 }
9650 }
9651 if (splitNorm !== -1) {
9652 var k = Math.floor(splitNorm / normFactor);
9653 for(; k > 0 && k < cssText.length;){
9654 iterCount += 1;
9655 if (iterCount > 50 * childNodes2.length) {
9656 splits.push(cssText);
9657 return splits;
9658 }
9659 var normPart = normalizeCssString(cssText.substring(0, k), _testNoPxNorm);
9660 if (normPart.length === splitNorm) {
9661 splits.push(cssText.substring(0, k));
9662 cssText = cssText.substring(k);
9663 cssTextNorm = cssTextNorm.substring(splitNorm);
9664 break;
9665 } else if (normPart.length < splitNorm) {
9666 k += Math.max(1, Math.floor((splitNorm - normPart.length) / normFactor));
9667 } else {
9668 k -= Math.max(1, Math.floor((normPart.length - splitNorm) * normFactor));
9669 }
9670 }
9671 break;
9672 }
9673 }
9674 }
9675 }
9676 }
9677 splits.push(cssText);
9678 return splits;
9679 }
9680 function markCssSplits(cssText, style) {
9681 return splitCssText(cssText, style).join("/* rr_split */");
9682 }
9683 var _id = 1;
9684 var tagNameRegex = new RegExp("[^a-z0-9-_:]");
9685 var IGNORED_NODE = -2;
9686 function genId() {
9687 return _id++;
9688 }
9689 function getValidTagName$1(element) {
9690 if (_instanceof(element, HTMLFormElement)) {
9691 return "form";
9692 }
9693 var processedTagName = toLowerCase(element.tagName);
9694 if (tagNameRegex.test(processedTagName)) {
9695 return "div";
9696 }
9697 return processedTagName;
9698 }
9699 var canvasService;
9700 var canvasCtx;
9701 var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
9702 var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
9703 function getAbsoluteSrcsetString(doc, attributeValue) {
9704 if (attributeValue.trim() === "") {
9705 return attributeValue;
9706 }
9707 var pos = 0;
9708 function collectCharacters(regEx) {
9709 var chars2;
9710 var match = regEx.exec(attributeValue.substring(pos));
9711 if (match) {
9712 chars2 = match[0];
9713 pos += chars2.length;
9714 return chars2;
9715 }
9716 return "";
9717 }
9718 var output = [];
9719 while(true){
9720 collectCharacters(SRCSET_COMMAS_OR_SPACES);
9721 if (pos >= attributeValue.length) {
9722 break;
9723 }
9724 var url = collectCharacters(SRCSET_NOT_SPACES);
9725 if (url.slice(-1) === ",") {
9726 url = absoluteToDoc(doc, url.substring(0, url.length - 1));
9727 output.push(url);
9728 } else {
9729 var descriptorsStr = "";
9730 url = absoluteToDoc(doc, url);
9731 var inParens = false;
9732 while(true){
9733 var c2 = attributeValue.charAt(pos);
9734 if (c2 === "") {
9735 output.push((url + descriptorsStr).trim());
9736 break;
9737 } else if (!inParens) {
9738 if (c2 === ",") {
9739 pos += 1;
9740 output.push((url + descriptorsStr).trim());
9741 break;
9742 } else if (c2 === "(") {
9743 inParens = true;
9744 }
9745 } else {
9746 if (c2 === ")") {
9747 inParens = false;
9748 }
9749 }
9750 descriptorsStr += c2;
9751 pos += 1;
9752 }
9753 }
9754 }
9755 return output.join(", ");
9756 }
9757 var cachedDocument = /* @__PURE__ */ new WeakMap();
9758 function absoluteToDoc(doc, attributeValue) {
9759 if (!attributeValue || attributeValue.trim() === "") {
9760 return attributeValue;
9761 }
9762 return getHref(doc, attributeValue);
9763 }
9764 function isSVGElement(el) {
9765 return Boolean(el.tagName === "svg" || el.ownerSVGElement);
9766 }
9767 function getHref(doc, customHref) {
9768 var a2 = cachedDocument.get(doc);
9769 if (!a2) {
9770 a2 = doc.createElement("a");
9771 cachedDocument.set(doc, a2);
9772 }
9773 if (!customHref) {
9774 customHref = "";
9775 } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
9776 return customHref;
9777 }
9778 a2.setAttribute("href", customHref);
9779 return a2.href;
9780 }
9781 function transformAttribute(doc, tagName, name, value) {
9782 if (!value) {
9783 return value;
9784 }
9785 if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
9786 return absoluteToDoc(doc, value);
9787 } else if (name === "xlink:href" && value[0] !== "#") {
9788 return absoluteToDoc(doc, value);
9789 } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
9790 return absoluteToDoc(doc, value);
9791 } else if (name === "srcset") {
9792 return getAbsoluteSrcsetString(doc, value);
9793 } else if (name === "style") {
9794 return absolutifyURLs(value, getHref(doc));
9795 } else if (tagName === "object" && name === "data") {
9796 return absoluteToDoc(doc, value);
9797 }
9798 return value;
9799 }
9800 function ignoreAttribute(tagName, name, _value) {
9801 return (tagName === "video" || tagName === "audio") && name === "autoplay";
9802 }
9803 function _isBlockedElement(element, blockClass, blockSelector) {
9804 try {
9805 if (typeof blockClass === "string") {
9806 if (element.classList.contains(blockClass)) {
9807 return true;
9808 }
9809 } else {
9810 for(var eIndex = element.classList.length; eIndex--;){
9811 var className = element.classList[eIndex];
9812 if (blockClass.test(className)) {
9813 return true;
9814 }
9815 }
9816 }
9817 if (blockSelector) {
9818 return element.matches(blockSelector);
9819 }
9820 } catch (e2) {}
9821 return false;
9822 }
9823 function classMatchesRegex(node2, regex, checkAncestors) {
9824 if (!node2) return false;
9825 if (node2.nodeType !== node2.ELEMENT_NODE) {
9826 if (!checkAncestors) return false;
9827 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9828 }
9829 for(var eIndex = node2.classList.length; eIndex--;){
9830 var className = node2.classList[eIndex];
9831 if (regex.test(className)) {
9832 return true;
9833 }
9834 }
9835 if (!checkAncestors) return false;
9836 return classMatchesRegex(index$1.parentNode(node2), regex, checkAncestors);
9837 }
9838 function needMaskingText(node2, maskTextClass, maskTextSelector, checkAncestors) {
9839 var el;
9840 if (isElement(node2)) {
9841 el = node2;
9842 if (!index$1.childNodes(el).length) {
9843 return false;
9844 }
9845 } else if (index$1.parentElement(node2) === null) {
9846 return false;
9847 } else {
9848 el = index$1.parentElement(node2);
9849 }
9850 try {
9851 if (typeof maskTextClass === "string") {
9852 if (checkAncestors) {
9853 if (el.closest("." + maskTextClass)) return true;
9854 } else {
9855 if (el.classList.contains(maskTextClass)) return true;
9856 }
9857 } else {
9858 if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
9859 }
9860 if (maskTextSelector) {
9861 if (checkAncestors) {
9862 if (el.closest(maskTextSelector)) return true;
9863 } else {
9864 if (el.matches(maskTextSelector)) return true;
9865 }
9866 }
9867 } catch (e2) {}
9868 return false;
9869 }
9870 function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
9871 var win = iframeEl.contentWindow;
9872 if (!win) {
9873 return;
9874 }
9875 var fired = false;
9876 var readyState;
9877 try {
9878 readyState = win.document.readyState;
9879 } catch (error) {
9880 return;
9881 }
9882 if (readyState !== "complete") {
9883 var timer = setTimeout(function() {
9884 if (!fired) {
9885 listener();
9886 fired = true;
9887 }
9888 }, iframeLoadTimeout);
9889 iframeEl.addEventListener("load", function() {
9890 clearTimeout(timer);
9891 fired = true;
9892 listener();
9893 });
9894 return;
9895 }
9896 var blankUrl = "about:blank";
9897 if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
9898 setTimeout(listener, 0);
9899 return iframeEl.addEventListener("load", listener);
9900 }
9901 iframeEl.addEventListener("load", listener);
9902 }
9903 function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
9904 var fired = false;
9905 var styleSheetLoaded;
9906 try {
9907 styleSheetLoaded = link.sheet;
9908 } catch (error) {
9909 return;
9910 }
9911 if (styleSheetLoaded) return;
9912 var timer = setTimeout(function() {
9913 if (!fired) {
9914 listener();
9915 fired = true;
9916 }
9917 }, styleSheetLoadTimeout);
9918 link.addEventListener("load", function() {
9919 clearTimeout(timer);
9920 fired = true;
9921 listener();
9922 });
9923 }
9924 function serializeNode(n2, options) {
9925 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;
9926 var rootId = getRootId(doc, mirror2);
9927 switch(n2.nodeType){
9928 case n2.DOCUMENT_NODE:
9929 if (n2.compatMode !== "CSS1Compat") {
9930 return {
9931 type: NodeType$3.Document,
9932 childNodes: [],
9933 compatMode: n2.compatMode
9934 };
9935 } else {
9936 return {
9937 type: NodeType$3.Document,
9938 childNodes: []
9939 };
9940 }
9941 case n2.DOCUMENT_TYPE_NODE:
9942 return {
9943 type: NodeType$3.DocumentType,
9944 name: n2.name,
9945 publicId: n2.publicId,
9946 systemId: n2.systemId,
9947 rootId: rootId
9948 };
9949 case n2.ELEMENT_NODE:
9950 return serializeElementNode(n2, {
9951 doc: doc,
9952 blockClass: blockClass,
9953 blockSelector: blockSelector,
9954 inlineStylesheet: inlineStylesheet,
9955 maskInputOptions: maskInputOptions,
9956 maskInputFn: maskInputFn,
9957 dataURLOptions: dataURLOptions,
9958 inlineImages: inlineImages,
9959 recordCanvas: recordCanvas,
9960 keepIframeSrcFn: keepIframeSrcFn,
9961 newlyAddedElement: newlyAddedElement,
9962 rootId: rootId
9963 });
9964 case n2.TEXT_NODE:
9965 return serializeTextNode(n2, {
9966 doc: doc,
9967 needsMask: needsMask,
9968 maskTextFn: maskTextFn,
9969 rootId: rootId,
9970 cssCaptured: cssCaptured
9971 });
9972 case n2.CDATA_SECTION_NODE:
9973 return {
9974 type: NodeType$3.CDATA,
9975 textContent: "",
9976 rootId: rootId
9977 };
9978 case n2.COMMENT_NODE:
9979 return {
9980 type: NodeType$3.Comment,
9981 textContent: index$1.textContent(n2) || "",
9982 rootId: rootId
9983 };
9984 default:
9985 return false;
9986 }
9987 }
9988 function getRootId(doc, mirror2) {
9989 if (!mirror2.hasNode(doc)) return void 0;
9990 var docId = mirror2.getId(doc);
9991 return docId === 1 ? void 0 : docId;
9992 }
9993 function serializeTextNode(n2, options) {
9994 var needsMask = options.needsMask, maskTextFn = options.maskTextFn, rootId = options.rootId, cssCaptured = options.cssCaptured;
9995 var parent = index$1.parentNode(n2);
9996 var parentTagName = parent && parent.tagName;
9997 var textContent2 = "";
9998 var isStyle = parentTagName === "STYLE" ? true : void 0;
9999 var isScript = parentTagName === "SCRIPT" ? true : void 0;
10000 if (isScript) {
10001 textContent2 = "SCRIPT_PLACEHOLDER";
10002 } else if (!cssCaptured) {
10003 textContent2 = index$1.textContent(n2);
10004 if (isStyle && textContent2) {
10005 textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
10006 }
10007 }
10008 if (!isStyle && !isScript && textContent2 && needsMask) {
10009 textContent2 = maskTextFn ? maskTextFn(textContent2, index$1.parentElement(n2)) : textContent2.replace(/[\S]/g, "*");
10010 }
10011 return {
10012 type: NodeType$3.Text,
10013 textContent: textContent2 || "",
10014 rootId: rootId
10015 };
10016 }
10017 function serializeElementNode(n2, options) {
10018 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;
10019 var needBlock = _isBlockedElement(n2, blockClass, blockSelector);
10020 var tagName = getValidTagName$1(n2);
10021 var attributes = {};
10022 var len = n2.attributes.length;
10023 for(var i2 = 0; i2 < len; i2++){
10024 var attr = n2.attributes[i2];
10025 if (!ignoreAttribute(tagName, attr.name, attr.value)) {
10026 attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
10027 }
10028 }
10029 if (tagName === "link" && inlineStylesheet) {
10030 var stylesheet = Array.from(doc.styleSheets).find(function(s2) {
10031 return s2.href === n2.href;
10032 });
10033 var cssText = null;
10034 if (stylesheet) {
10035 cssText = stringifyStylesheet(stylesheet);
10036 }
10037 if (cssText) {
10038 delete attributes.rel;
10039 delete attributes.href;
10040 attributes._cssText = cssText;
10041 }
10042 }
10043 if (tagName === "style" && n2.sheet) {
10044 var cssText1 = stringifyStylesheet(n2.sheet);
10045 if (cssText1) {
10046 if (n2.childNodes.length > 1) {
10047 cssText1 = markCssSplits(cssText1, n2);
10048 }
10049 attributes._cssText = cssText1;
10050 }
10051 }
10052 if (tagName === "input" || tagName === "textarea" || tagName === "select") {
10053 var value = n2.value;
10054 var checked = n2.checked;
10055 if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
10056 attributes.value = maskInputValue({
10057 element: n2,
10058 type: getInputType(n2),
10059 tagName: tagName,
10060 value: value,
10061 maskInputOptions: maskInputOptions,
10062 maskInputFn: maskInputFn
10063 });
10064 } else if (checked) {
10065 attributes.checked = checked;
10066 }
10067 }
10068 if (tagName === "option") {
10069 if (n2.selected && !maskInputOptions["select"]) {
10070 attributes.selected = true;
10071 } else {
10072 delete attributes.selected;
10073 }
10074 }
10075 if (tagName === "dialog" && n2.open) {
10076 attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
10077 }
10078 if (tagName === "canvas" && recordCanvas) {
10079 if (n2.__context === "2d") {
10080 if (!is2DCanvasBlank(n2)) {
10081 attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10082 }
10083 } else if (!("__context" in n2)) {
10084 var canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10085 var blankCanvas = doc.createElement("canvas");
10086 blankCanvas.width = n2.width;
10087 blankCanvas.height = n2.height;
10088 var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10089 if (canvasDataURL !== blankCanvasDataURL) {
10090 attributes.rr_dataURL = canvasDataURL;
10091 }
10092 }
10093 }
10094 if (tagName === "img" && inlineImages) {
10095 if (!canvasService) {
10096 canvasService = doc.createElement("canvas");
10097 canvasCtx = canvasService.getContext("2d");
10098 }
10099 var image = n2;
10100 var imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
10101 var priorCrossOrigin = image.crossOrigin;
10102 var recordInlineImage = function() {
10103 image.removeEventListener("load", recordInlineImage);
10104 try {
10105 canvasService.width = image.naturalWidth;
10106 canvasService.height = image.naturalHeight;
10107 canvasCtx.drawImage(image, 0, 0);
10108 attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
10109 } catch (err) {
10110 if (image.crossOrigin !== "anonymous") {
10111 image.crossOrigin = "anonymous";
10112 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10113 else image.addEventListener("load", recordInlineImage);
10114 return;
10115 } else {
10116 console.warn("Cannot inline img src=" + imageSrc + "! Error: " + err);
10117 }
10118 }
10119 if (image.crossOrigin === "anonymous") {
10120 priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
10121 }
10122 };
10123 if (image.complete && image.naturalWidth !== 0) recordInlineImage();
10124 else image.addEventListener("load", recordInlineImage);
10125 }
10126 if (tagName === "audio" || tagName === "video") {
10127 var mediaAttributes = attributes;
10128 mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
10129 mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
10130 mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
10131 mediaAttributes.rr_mediaMuted = n2.muted;
10132 mediaAttributes.rr_mediaLoop = n2.loop;
10133 mediaAttributes.rr_mediaVolume = n2.volume;
10134 }
10135 if (!newlyAddedElement) {
10136 if (n2.scrollLeft) {
10137 attributes.rr_scrollLeft = n2.scrollLeft;
10138 }
10139 if (n2.scrollTop) {
10140 attributes.rr_scrollTop = n2.scrollTop;
10141 }
10142 }
10143 if (needBlock) {
10144 var _n2_getBoundingClientRect = n2.getBoundingClientRect(), width = _n2_getBoundingClientRect.width, height = _n2_getBoundingClientRect.height;
10145 attributes = {
10146 class: attributes.class,
10147 rr_width: "" + width + "px",
10148 rr_height: "" + height + "px"
10149 };
10150 }
10151 if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
10152 if (!n2.contentDocument) {
10153 attributes.rr_src = attributes.src;
10154 }
10155 delete attributes.src;
10156 }
10157 var isCustomElement;
10158 try {
10159 if (customElements.get(tagName)) isCustomElement = true;
10160 } catch (e2) {}
10161 return {
10162 type: NodeType$3.Element,
10163 tagName: tagName,
10164 attributes: attributes,
10165 childNodes: [],
10166 isSVG: isSVGElement(n2) || void 0,
10167 needBlock: needBlock,
10168 rootId: rootId,
10169 isCustom: isCustomElement
10170 };
10171 }
10172 function lowerIfExists(maybeAttr) {
10173 if (maybeAttr === void 0 || maybeAttr === null) {
10174 return "";
10175 } else {
10176 return maybeAttr.toLowerCase();
10177 }
10178 }
10179 function slimDOMExcluded(sn, slimDOMOptions) {
10180 if (slimDOMOptions.comment && sn.type === NodeType$3.Comment) {
10181 return true;
10182 } else if (sn.type === NodeType$3.Element) {
10183 if (slimDOMOptions.script && // script tag
10184 (sn.tagName === "script" || // (module)preload link
10185 sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
10186 sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && extractFileExtension(sn.attributes.href) === "js")) {
10187 return true;
10188 } 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"))) {
10189 return true;
10190 } else if (sn.tagName === "meta") {
10191 if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
10192 return true;
10193 } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
10194 lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
10195 return true;
10196 } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
10197 return true;
10198 } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
10199 return true;
10200 } 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:/))) {
10201 return true;
10202 } 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")) {
10203 return true;
10204 }
10205 }
10206 }
10207 return false;
10208 }
10209 function serializeNodeWithId(n2, options) {
10210 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() {
10211 return false;
10212 } : _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;
10213 var needsMask = options.needsMask;
10214 var _options_preserveWhiteSpace = options.preserveWhiteSpace, preserveWhiteSpace = _options_preserveWhiteSpace === void 0 ? true : _options_preserveWhiteSpace;
10215 if (!needsMask) {
10216 var checkAncestors = needsMask === void 0;
10217 needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
10218 }
10219 var _serializedNode = serializeNode(n2, {
10220 doc: doc,
10221 mirror: mirror2,
10222 blockClass: blockClass,
10223 blockSelector: blockSelector,
10224 needsMask: needsMask,
10225 inlineStylesheet: inlineStylesheet,
10226 maskInputOptions: maskInputOptions,
10227 maskTextFn: maskTextFn,
10228 maskInputFn: maskInputFn,
10229 dataURLOptions: dataURLOptions,
10230 inlineImages: inlineImages,
10231 recordCanvas: recordCanvas,
10232 keepIframeSrcFn: keepIframeSrcFn,
10233 newlyAddedElement: newlyAddedElement,
10234 cssCaptured: cssCaptured
10235 });
10236 if (!_serializedNode) {
10237 console.warn(n2, "not serialized");
10238 return null;
10239 }
10240 var id;
10241 if (mirror2.hasNode(n2)) {
10242 id = mirror2.getId(n2);
10243 } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$3.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
10244 id = IGNORED_NODE;
10245 } else {
10246 id = genId();
10247 }
10248 var serializedNode = Object.assign(_serializedNode, {
10249 id: id
10250 });
10251 mirror2.add(n2, serializedNode);
10252 if (id === IGNORED_NODE) {
10253 return null;
10254 }
10255 if (onSerialize) {
10256 onSerialize(n2);
10257 }
10258 var recordChild = !skipChild;
10259 if (serializedNode.type === NodeType$3.Element) {
10260 recordChild = recordChild && !serializedNode.needBlock;
10261 delete serializedNode.needBlock;
10262 var shadowRootEl = index$1.shadowRoot(n2);
10263 if (shadowRootEl && isNativeShadowDom(shadowRootEl)) serializedNode.isShadowHost = true;
10264 }
10265 if ((serializedNode.type === NodeType$3.Document || serializedNode.type === NodeType$3.Element) && recordChild) {
10266 if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$3.Element && serializedNode.tagName === "head") {
10267 preserveWhiteSpace = false;
10268 }
10269 var bypassOptions = {
10270 doc: doc,
10271 mirror: mirror2,
10272 blockClass: blockClass,
10273 blockSelector: blockSelector,
10274 needsMask: needsMask,
10275 maskTextClass: maskTextClass,
10276 maskTextSelector: maskTextSelector,
10277 skipChild: skipChild,
10278 inlineStylesheet: inlineStylesheet,
10279 maskInputOptions: maskInputOptions,
10280 maskTextFn: maskTextFn,
10281 maskInputFn: maskInputFn,
10282 slimDOMOptions: slimDOMOptions,
10283 dataURLOptions: dataURLOptions,
10284 inlineImages: inlineImages,
10285 recordCanvas: recordCanvas,
10286 preserveWhiteSpace: preserveWhiteSpace,
10287 onSerialize: onSerialize,
10288 onIframeLoad: onIframeLoad,
10289 iframeLoadTimeout: iframeLoadTimeout,
10290 onStylesheetLoad: onStylesheetLoad,
10291 stylesheetLoadTimeout: stylesheetLoadTimeout,
10292 keepIframeSrcFn: keepIframeSrcFn,
10293 cssCaptured: false
10294 };
10295 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
10296 else {
10297 if (serializedNode.type === NodeType$3.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
10298 bypassOptions.cssCaptured = true;
10299 }
10300 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(n2))), _step; !(_step = _iterator()).done;){
10301 var childN = _step.value;
10302 var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
10303 if (serializedChildNode) {
10304 serializedNode.childNodes.push(serializedChildNode);
10305 }
10306 }
10307 }
10308 var shadowRootEl1 = null;
10309 if (isElement(n2) && (shadowRootEl1 = index$1.shadowRoot(n2))) {
10310 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(index$1.childNodes(shadowRootEl1))), _step1; !(_step1 = _iterator1()).done;){
10311 var childN1 = _step1.value;
10312 var serializedChildNode1 = serializeNodeWithId(childN1, bypassOptions);
10313 if (serializedChildNode1) {
10314 isNativeShadowDom(shadowRootEl1) && (serializedChildNode1.isShadow = true);
10315 serializedNode.childNodes.push(serializedChildNode1);
10316 }
10317 }
10318 }
10319 }
10320 var parent = index$1.parentNode(n2);
10321 if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
10322 serializedNode.isShadow = true;
10323 }
10324 if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "iframe") {
10325 onceIframeLoaded(n2, function() {
10326 var iframeDoc = n2.contentDocument;
10327 if (iframeDoc && onIframeLoad) {
10328 var serializedIframeNode = serializeNodeWithId(iframeDoc, {
10329 doc: iframeDoc,
10330 mirror: mirror2,
10331 blockClass: blockClass,
10332 blockSelector: blockSelector,
10333 needsMask: needsMask,
10334 maskTextClass: maskTextClass,
10335 maskTextSelector: maskTextSelector,
10336 skipChild: false,
10337 inlineStylesheet: inlineStylesheet,
10338 maskInputOptions: maskInputOptions,
10339 maskTextFn: maskTextFn,
10340 maskInputFn: maskInputFn,
10341 slimDOMOptions: slimDOMOptions,
10342 dataURLOptions: dataURLOptions,
10343 inlineImages: inlineImages,
10344 recordCanvas: recordCanvas,
10345 preserveWhiteSpace: preserveWhiteSpace,
10346 onSerialize: onSerialize,
10347 onIframeLoad: onIframeLoad,
10348 iframeLoadTimeout: iframeLoadTimeout,
10349 onStylesheetLoad: onStylesheetLoad,
10350 stylesheetLoadTimeout: stylesheetLoadTimeout,
10351 keepIframeSrcFn: keepIframeSrcFn
10352 });
10353 if (serializedIframeNode) {
10354 onIframeLoad(n2, serializedIframeNode);
10355 }
10356 }
10357 }, iframeLoadTimeout);
10358 }
10359 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")) {
10360 onceStylesheetLoaded(n2, function() {
10361 if (onStylesheetLoad) {
10362 var serializedLinkNode = serializeNodeWithId(n2, {
10363 doc: doc,
10364 mirror: mirror2,
10365 blockClass: blockClass,
10366 blockSelector: blockSelector,
10367 needsMask: needsMask,
10368 maskTextClass: maskTextClass,
10369 maskTextSelector: maskTextSelector,
10370 skipChild: false,
10371 inlineStylesheet: inlineStylesheet,
10372 maskInputOptions: maskInputOptions,
10373 maskTextFn: maskTextFn,
10374 maskInputFn: maskInputFn,
10375 slimDOMOptions: slimDOMOptions,
10376 dataURLOptions: dataURLOptions,
10377 inlineImages: inlineImages,
10378 recordCanvas: recordCanvas,
10379 preserveWhiteSpace: preserveWhiteSpace,
10380 onSerialize: onSerialize,
10381 onIframeLoad: onIframeLoad,
10382 iframeLoadTimeout: iframeLoadTimeout,
10383 onStylesheetLoad: onStylesheetLoad,
10384 stylesheetLoadTimeout: stylesheetLoadTimeout,
10385 keepIframeSrcFn: keepIframeSrcFn
10386 });
10387 if (serializedLinkNode) {
10388 onStylesheetLoad(n2, serializedLinkNode);
10389 }
10390 }
10391 }, stylesheetLoadTimeout);
10392 }
10393 return serializedNode;
10394 }
10395 function snapshot(n2, options) {
10396 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() {
10397 return false;
10398 } : _ref_keepIframeSrcFn;
10399 var maskInputOptions = maskAllInputs === true ? {
10400 color: true,
10401 date: true,
10402 "datetime-local": true,
10403 email: true,
10404 month: true,
10405 number: true,
10406 range: true,
10407 search: true,
10408 tel: true,
10409 text: true,
10410 time: true,
10411 url: true,
10412 week: true,
10413 textarea: true,
10414 select: true,
10415 password: true,
10416 hidden: true
10417 } : maskAllInputs === false ? {
10418 password: true
10419 } : maskAllInputs;
10420 var slimDOMOptions = slimDOM === true || slimDOM === "all" ? // if true: set of sensible options that should not throw away any information
10421 {
10422 script: true,
10423 comment: true,
10424 headFavicon: true,
10425 headWhitespace: true,
10426 headMetaDescKeywords: slimDOM === "all",
10427 // destructive
10428 headMetaSocial: true,
10429 headMetaRobots: true,
10430 headMetaHttpEquiv: true,
10431 headMetaAuthorship: true,
10432 headMetaVerification: true
10433 } : slimDOM === false ? {} : slimDOM;
10434 return serializeNodeWithId(n2, {
10435 doc: n2,
10436 mirror: mirror2,
10437 blockClass: blockClass,
10438 blockSelector: blockSelector,
10439 maskTextClass: maskTextClass,
10440 maskTextSelector: maskTextSelector,
10441 skipChild: false,
10442 inlineStylesheet: inlineStylesheet,
10443 maskInputOptions: maskInputOptions,
10444 maskTextFn: maskTextFn,
10445 maskInputFn: maskInputFn,
10446 slimDOMOptions: slimDOMOptions,
10447 dataURLOptions: dataURLOptions,
10448 inlineImages: inlineImages,
10449 recordCanvas: recordCanvas,
10450 preserveWhiteSpace: preserveWhiteSpace,
10451 onSerialize: onSerialize,
10452 onIframeLoad: onIframeLoad,
10453 iframeLoadTimeout: iframeLoadTimeout,
10454 onStylesheetLoad: onStylesheetLoad,
10455 stylesheetLoadTimeout: stylesheetLoadTimeout,
10456 keepIframeSrcFn: keepIframeSrcFn,
10457 newlyAddedElement: false
10458 });
10459 }
10460 function getDefaultExportFromCjs$1(x2) {
10461 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
10462 }
10463 function getAugmentedNamespace$1(n2) {
10464 if (n2.__esModule) return n2;
10465 var f2 = n2.default;
10466 if (typeof f2 == "function") {
10467 var a2 = function a22() {
10468 if (_instanceof(this, a22)) {
10469 return Reflect.construct(f2, arguments, this.constructor);
10470 }
10471 return f2.apply(this, arguments);
10472 };
10473 a2.prototype = f2.prototype;
10474 } else a2 = {};
10475 Object.defineProperty(a2, "__esModule", {
10476 value: true
10477 });
10478 Object.keys(n2).forEach(function(k) {
10479 var d = Object.getOwnPropertyDescriptor(n2, k);
10480 Object.defineProperty(a2, k, d.get ? d : {
10481 enumerable: true,
10482 get: function get() {
10483 return n2[k];
10484 }
10485 });
10486 });
10487 return a2;
10488 }
10489 var picocolors_browser$1 = {
10490 exports: {}
10491 };
10492 var x$1 = String;
10493 var create$1 = function create$1() {
10494 return {
10495 isColorSupported: false,
10496 reset: x$1,
10497 bold: x$1,
10498 dim: x$1,
10499 italic: x$1,
10500 underline: x$1,
10501 inverse: x$1,
10502 hidden: x$1,
10503 strikethrough: x$1,
10504 black: x$1,
10505 red: x$1,
10506 green: x$1,
10507 yellow: x$1,
10508 blue: x$1,
10509 magenta: x$1,
10510 cyan: x$1,
10511 white: x$1,
10512 gray: x$1,
10513 bgBlack: x$1,
10514 bgRed: x$1,
10515 bgGreen: x$1,
10516 bgYellow: x$1,
10517 bgBlue: x$1,
10518 bgMagenta: x$1,
10519 bgCyan: x$1,
10520 bgWhite: x$1
10521 };
10522 };
10523 picocolors_browser$1.exports = create$1();
10524 picocolors_browser$1.exports.createColors = create$1;
10525 var picocolors_browserExports$1 = picocolors_browser$1.exports;
10526 var __viteBrowserExternal$2 = {};
10527 var __viteBrowserExternal$1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10528 __proto__: null,
10529 default: __viteBrowserExternal$2
10530 }, Symbol.toStringTag, {
10531 value: "Module"
10532 }));
10533 var require$$2$1 = /* @__PURE__ */ getAugmentedNamespace$1(__viteBrowserExternal$1$1);
10534 var pico$1 = picocolors_browserExports$1;
10535 var terminalHighlight$1$1 = require$$2$1;
10536 var CssSyntaxError$3$1 = /*#__PURE__*/ function(Error1) {
10537 _inherits(CssSyntaxError, Error1);
10538 function CssSyntaxError(message, line, column, source, file, plugin22) {
10539 var _this;
10540 _this = Error1.call(this, message) || this;
10541 _this.name = "CssSyntaxError";
10542 _this.reason = message;
10543 if (file) {
10544 _this.file = file;
10545 }
10546 if (source) {
10547 _this.source = source;
10548 }
10549 if (plugin22) {
10550 _this.plugin = plugin22;
10551 }
10552 if (typeof line !== "undefined" && typeof column !== "undefined") {
10553 if (typeof line === "number") {
10554 _this.line = line;
10555 _this.column = column;
10556 } else {
10557 _this.line = line.line;
10558 _this.column = line.column;
10559 _this.endLine = column.line;
10560 _this.endColumn = column.column;
10561 }
10562 }
10563 _this.setMessage();
10564 if (Error.captureStackTrace) {
10565 Error.captureStackTrace(_this, CssSyntaxError);
10566 }
10567 return _this;
10568 }
10569 var _proto = CssSyntaxError.prototype;
10570 _proto.setMessage = function setMessage() {
10571 this.message = this.plugin ? this.plugin + ": " : "";
10572 this.message += this.file ? this.file : "<css input>";
10573 if (typeof this.line !== "undefined") {
10574 this.message += ":" + this.line + ":" + this.column;
10575 }
10576 this.message += ": " + this.reason;
10577 };
10578 _proto.showSourceCode = function showSourceCode(color) {
10579 var _this = this;
10580 if (!this.source) return "";
10581 var css = this.source;
10582 if (color == null) color = pico$1.isColorSupported;
10583 if (terminalHighlight$1$1) {
10584 if (color) css = terminalHighlight$1$1(css);
10585 }
10586 var lines = css.split(/\r?\n/);
10587 var start = Math.max(this.line - 3, 0);
10588 var end = Math.min(this.line + 2, lines.length);
10589 var maxWidth = String(end).length;
10590 var mark, aside;
10591 if (color) {
10592 var _pico$1_createColors = pico$1.createColors(true), bold = _pico$1_createColors.bold, gray = _pico$1_createColors.gray, red = _pico$1_createColors.red;
10593 mark = function(text) {
10594 return bold(red(text));
10595 };
10596 aside = function(text) {
10597 return gray(text);
10598 };
10599 } else {
10600 mark = aside = function(str) {
10601 return str;
10602 };
10603 }
10604 return lines.slice(start, end).map(function(line, index2) {
10605 var number = start + 1 + index2;
10606 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
10607 if (number === _this.line) {
10608 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
10609 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
10610 }
10611 return " " + aside(gutter) + line;
10612 }).join("\n");
10613 };
10614 _proto.toString = function toString() {
10615 var code = this.showSourceCode();
10616 if (code) {
10617 code = "\n\n" + code + "\n";
10618 }
10619 return this.name + ": " + this.message + code;
10620 };
10621 return CssSyntaxError;
10622 }(_wrap_native_super(Error));
10623 var cssSyntaxError$1 = CssSyntaxError$3$1;
10624 CssSyntaxError$3$1.default = CssSyntaxError$3$1;
10625 var symbols$1 = {};
10626 symbols$1.isClean = Symbol("isClean");
10627 symbols$1.my = Symbol("my");
10628 var DEFAULT_RAW$1 = {
10629 after: "\n",
10630 beforeClose: "\n",
10631 beforeComment: "\n",
10632 beforeDecl: "\n",
10633 beforeOpen: " ",
10634 beforeRule: "\n",
10635 colon: ": ",
10636 commentLeft: " ",
10637 commentRight: " ",
10638 emptyBody: "",
10639 indent: " ",
10640 semicolon: false
10641 };
10642 function capitalize$1(str) {
10643 return str[0].toUpperCase() + str.slice(1);
10644 }
10645 var Stringifier$2$1 = /*#__PURE__*/ function() {
10646 function Stringifier(builder) {
10647 this.builder = builder;
10648 }
10649 var _proto = Stringifier.prototype;
10650 _proto.atrule = function atrule(node2, semicolon) {
10651 var name = "@" + node2.name;
10652 var params = node2.params ? this.rawValue(node2, "params") : "";
10653 if (typeof node2.raws.afterName !== "undefined") {
10654 name += node2.raws.afterName;
10655 } else if (params) {
10656 name += " ";
10657 }
10658 if (node2.nodes) {
10659 this.block(node2, name + params);
10660 } else {
10661 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
10662 this.builder(name + params + end, node2);
10663 }
10664 };
10665 _proto.beforeAfter = function beforeAfter(node2, detect) {
10666 var value;
10667 if (node2.type === "decl") {
10668 value = this.raw(node2, null, "beforeDecl");
10669 } else if (node2.type === "comment") {
10670 value = this.raw(node2, null, "beforeComment");
10671 } else if (detect === "before") {
10672 value = this.raw(node2, null, "beforeRule");
10673 } else {
10674 value = this.raw(node2, null, "beforeClose");
10675 }
10676 var buf = node2.parent;
10677 var depth = 0;
10678 while(buf && buf.type !== "root"){
10679 depth += 1;
10680 buf = buf.parent;
10681 }
10682 if (value.includes("\n")) {
10683 var indent = this.raw(node2, null, "indent");
10684 if (indent.length) {
10685 for(var step = 0; step < depth; step++)value += indent;
10686 }
10687 }
10688 return value;
10689 };
10690 _proto.block = function block(node2, start) {
10691 var between = this.raw(node2, "between", "beforeOpen");
10692 this.builder(start + between + "{", node2, "start");
10693 var after;
10694 if (node2.nodes && node2.nodes.length) {
10695 this.body(node2);
10696 after = this.raw(node2, "after");
10697 } else {
10698 after = this.raw(node2, "after", "emptyBody");
10699 }
10700 if (after) this.builder(after);
10701 this.builder("}", node2, "end");
10702 };
10703 _proto.body = function body(node2) {
10704 var last = node2.nodes.length - 1;
10705 while(last > 0){
10706 if (node2.nodes[last].type !== "comment") break;
10707 last -= 1;
10708 }
10709 var semicolon = this.raw(node2, "semicolon");
10710 for(var i2 = 0; i2 < node2.nodes.length; i2++){
10711 var child = node2.nodes[i2];
10712 var before = this.raw(child, "before");
10713 if (before) this.builder(before);
10714 this.stringify(child, last !== i2 || semicolon);
10715 }
10716 };
10717 _proto.comment = function comment(node2) {
10718 var left = this.raw(node2, "left", "commentLeft");
10719 var right = this.raw(node2, "right", "commentRight");
10720 this.builder("/*" + left + node2.text + right + "*/", node2);
10721 };
10722 _proto.decl = function decl(node2, semicolon) {
10723 var between = this.raw(node2, "between", "colon");
10724 var string = node2.prop + between + this.rawValue(node2, "value");
10725 if (node2.important) {
10726 string += node2.raws.important || " !important";
10727 }
10728 if (semicolon) string += ";";
10729 this.builder(string, node2);
10730 };
10731 _proto.document = function document1(node2) {
10732 this.body(node2);
10733 };
10734 _proto.raw = function raw(node2, own, detect) {
10735 var value;
10736 if (!detect) detect = own;
10737 if (own) {
10738 value = node2.raws[own];
10739 if (typeof value !== "undefined") return value;
10740 }
10741 var parent = node2.parent;
10742 if (detect === "before") {
10743 if (!parent || parent.type === "root" && parent.first === node2) {
10744 return "";
10745 }
10746 if (parent && parent.type === "document") {
10747 return "";
10748 }
10749 }
10750 if (!parent) return DEFAULT_RAW$1[detect];
10751 var root2 = node2.root();
10752 if (!root2.rawCache) root2.rawCache = {};
10753 if (typeof root2.rawCache[detect] !== "undefined") {
10754 return root2.rawCache[detect];
10755 }
10756 if (detect === "before" || detect === "after") {
10757 return this.beforeAfter(node2, detect);
10758 } else {
10759 var method = "raw" + capitalize$1(detect);
10760 if (this[method]) {
10761 value = this[method](root2, node2);
10762 } else {
10763 root2.walk(function(i2) {
10764 value = i2.raws[own];
10765 if (typeof value !== "undefined") return false;
10766 });
10767 }
10768 }
10769 if (typeof value === "undefined") value = DEFAULT_RAW$1[detect];
10770 root2.rawCache[detect] = value;
10771 return value;
10772 };
10773 _proto.rawBeforeClose = function rawBeforeClose(root2) {
10774 var value;
10775 root2.walk(function(i2) {
10776 if (i2.nodes && i2.nodes.length > 0) {
10777 if (typeof i2.raws.after !== "undefined") {
10778 value = i2.raws.after;
10779 if (value.includes("\n")) {
10780 value = value.replace(/[^\n]+$/, "");
10781 }
10782 return false;
10783 }
10784 }
10785 });
10786 if (value) value = value.replace(/\S/g, "");
10787 return value;
10788 };
10789 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
10790 var value;
10791 root2.walkComments(function(i2) {
10792 if (typeof i2.raws.before !== "undefined") {
10793 value = i2.raws.before;
10794 if (value.includes("\n")) {
10795 value = value.replace(/[^\n]+$/, "");
10796 }
10797 return false;
10798 }
10799 });
10800 if (typeof value === "undefined") {
10801 value = this.raw(node2, null, "beforeDecl");
10802 } else if (value) {
10803 value = value.replace(/\S/g, "");
10804 }
10805 return value;
10806 };
10807 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
10808 var value;
10809 root2.walkDecls(function(i2) {
10810 if (typeof i2.raws.before !== "undefined") {
10811 value = i2.raws.before;
10812 if (value.includes("\n")) {
10813 value = value.replace(/[^\n]+$/, "");
10814 }
10815 return false;
10816 }
10817 });
10818 if (typeof value === "undefined") {
10819 value = this.raw(node2, null, "beforeRule");
10820 } else if (value) {
10821 value = value.replace(/\S/g, "");
10822 }
10823 return value;
10824 };
10825 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
10826 var value;
10827 root2.walk(function(i2) {
10828 if (i2.type !== "decl") {
10829 value = i2.raws.between;
10830 if (typeof value !== "undefined") return false;
10831 }
10832 });
10833 return value;
10834 };
10835 _proto.rawBeforeRule = function rawBeforeRule(root2) {
10836 var value;
10837 root2.walk(function(i2) {
10838 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
10839 if (typeof i2.raws.before !== "undefined") {
10840 value = i2.raws.before;
10841 if (value.includes("\n")) {
10842 value = value.replace(/[^\n]+$/, "");
10843 }
10844 return false;
10845 }
10846 }
10847 });
10848 if (value) value = value.replace(/\S/g, "");
10849 return value;
10850 };
10851 _proto.rawColon = function rawColon(root2) {
10852 var value;
10853 root2.walkDecls(function(i2) {
10854 if (typeof i2.raws.between !== "undefined") {
10855 value = i2.raws.between.replace(/[^\s:]/g, "");
10856 return false;
10857 }
10858 });
10859 return value;
10860 };
10861 _proto.rawEmptyBody = function rawEmptyBody(root2) {
10862 var value;
10863 root2.walk(function(i2) {
10864 if (i2.nodes && i2.nodes.length === 0) {
10865 value = i2.raws.after;
10866 if (typeof value !== "undefined") return false;
10867 }
10868 });
10869 return value;
10870 };
10871 _proto.rawIndent = function rawIndent(root2) {
10872 if (root2.raws.indent) return root2.raws.indent;
10873 var value;
10874 root2.walk(function(i2) {
10875 var p = i2.parent;
10876 if (p && p !== root2 && p.parent && p.parent === root2) {
10877 if (typeof i2.raws.before !== "undefined") {
10878 var parts = i2.raws.before.split("\n");
10879 value = parts[parts.length - 1];
10880 value = value.replace(/\S/g, "");
10881 return false;
10882 }
10883 }
10884 });
10885 return value;
10886 };
10887 _proto.rawSemicolon = function rawSemicolon(root2) {
10888 var value;
10889 root2.walk(function(i2) {
10890 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
10891 value = i2.raws.semicolon;
10892 if (typeof value !== "undefined") return false;
10893 }
10894 });
10895 return value;
10896 };
10897 _proto.rawValue = function rawValue(node2, prop) {
10898 var value = node2[prop];
10899 var raw = node2.raws[prop];
10900 if (raw && raw.value === value) {
10901 return raw.raw;
10902 }
10903 return value;
10904 };
10905 _proto.root = function root(node2) {
10906 this.body(node2);
10907 if (node2.raws.after) this.builder(node2.raws.after);
10908 };
10909 _proto.rule = function rule(node2) {
10910 this.block(node2, this.rawValue(node2, "selector"));
10911 if (node2.raws.ownSemicolon) {
10912 this.builder(node2.raws.ownSemicolon, node2, "end");
10913 }
10914 };
10915 _proto.stringify = function stringify(node2, semicolon) {
10916 if (!this[node2.type]) {
10917 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
10918 }
10919 this[node2.type](node2, semicolon);
10920 };
10921 return Stringifier;
10922 }();
10923 var stringifier$1 = Stringifier$2$1;
10924 Stringifier$2$1.default = Stringifier$2$1;
10925 var Stringifier$1$1 = stringifier$1;
10926 function stringify$4$1(node2, builder) {
10927 var str = new Stringifier$1$1(builder);
10928 str.stringify(node2);
10929 }
10930 var stringify_1$1 = stringify$4$1;
10931 stringify$4$1.default = stringify$4$1;
10932 var isClean$2$1 = symbols$1.isClean, my$2$1 = symbols$1.my;
10933 var CssSyntaxError$2$1 = cssSyntaxError$1;
10934 var Stringifier2$1 = stringifier$1;
10935 var stringify$3$1 = stringify_1$1;
10936 function cloneNode$1(obj, parent) {
10937 var cloned = new obj.constructor();
10938 for(var i2 in obj){
10939 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
10940 continue;
10941 }
10942 if (i2 === "proxyCache") continue;
10943 var value = obj[i2];
10944 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
10945 if (i2 === "parent" && type === "object") {
10946 if (parent) cloned[i2] = parent;
10947 } else if (i2 === "source") {
10948 cloned[i2] = value;
10949 } else if (Array.isArray(value)) {
10950 cloned[i2] = value.map(function(j) {
10951 return cloneNode$1(j, cloned);
10952 });
10953 } else {
10954 if (type === "object" && value !== null) value = cloneNode$1(value);
10955 cloned[i2] = value;
10956 }
10957 }
10958 return cloned;
10959 }
10960 var Node$4$1 = /*#__PURE__*/ function() {
10961 function Node2(defaults) {
10962 if (defaults === void 0) defaults = {};
10963 this.raws = {};
10964 this[isClean$2$1] = false;
10965 this[my$2$1] = true;
10966 for(var name in defaults){
10967 if (name === "nodes") {
10968 this.nodes = [];
10969 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
10970 var node2 = _step.value;
10971 if (typeof node2.clone === "function") {
10972 this.append(node2.clone());
10973 } else {
10974 this.append(node2);
10975 }
10976 }
10977 } else {
10978 this[name] = defaults[name];
10979 }
10980 }
10981 }
10982 var _proto = Node2.prototype;
10983 _proto.addToError = function addToError(error) {
10984 error.postcssNode = this;
10985 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
10986 var s2 = this.source;
10987 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
10988 }
10989 return error;
10990 };
10991 _proto.after = function after(add) {
10992 this.parent.insertAfter(this, add);
10993 return this;
10994 };
10995 _proto.assign = function assign(overrides) {
10996 if (overrides === void 0) overrides = {};
10997 for(var name in overrides){
10998 this[name] = overrides[name];
10999 }
11000 return this;
11001 };
11002 _proto.before = function before(add) {
11003 this.parent.insertBefore(this, add);
11004 return this;
11005 };
11006 _proto.cleanRaws = function cleanRaws(keepBetween) {
11007 delete this.raws.before;
11008 delete this.raws.after;
11009 if (!keepBetween) delete this.raws.between;
11010 };
11011 _proto.clone = function clone(overrides) {
11012 if (overrides === void 0) overrides = {};
11013 var cloned = cloneNode$1(this);
11014 for(var name in overrides){
11015 cloned[name] = overrides[name];
11016 }
11017 return cloned;
11018 };
11019 _proto.cloneAfter = function cloneAfter(overrides) {
11020 if (overrides === void 0) overrides = {};
11021 var cloned = this.clone(overrides);
11022 this.parent.insertAfter(this, cloned);
11023 return cloned;
11024 };
11025 _proto.cloneBefore = function cloneBefore(overrides) {
11026 if (overrides === void 0) overrides = {};
11027 var cloned = this.clone(overrides);
11028 this.parent.insertBefore(this, cloned);
11029 return cloned;
11030 };
11031 _proto.error = function error(message, opts) {
11032 if (opts === void 0) opts = {};
11033 if (this.source) {
11034 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
11035 return this.source.input.error(message, {
11036 column: start.column,
11037 line: start.line
11038 }, {
11039 column: end.column,
11040 line: end.line
11041 }, opts);
11042 }
11043 return new CssSyntaxError$2$1(message);
11044 };
11045 _proto.getProxyProcessor = function getProxyProcessor() {
11046 return {
11047 get: function get(node2, prop) {
11048 if (prop === "proxyOf") {
11049 return node2;
11050 } else if (prop === "root") {
11051 return function() {
11052 return node2.root().toProxy();
11053 };
11054 } else {
11055 return node2[prop];
11056 }
11057 },
11058 set: function set(node2, prop, value) {
11059 if (node2[prop] === value) return true;
11060 node2[prop] = value;
11061 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
11062 node2.markDirty();
11063 }
11064 return true;
11065 }
11066 };
11067 };
11068 _proto.markDirty = function markDirty() {
11069 if (this[isClean$2$1]) {
11070 this[isClean$2$1] = false;
11071 var next = this;
11072 while(next = next.parent){
11073 next[isClean$2$1] = false;
11074 }
11075 }
11076 };
11077 _proto.next = function next() {
11078 if (!this.parent) return void 0;
11079 var index2 = this.parent.index(this);
11080 return this.parent.nodes[index2 + 1];
11081 };
11082 _proto.positionBy = function positionBy(opts, stringRepresentation) {
11083 var pos = this.source.start;
11084 if (opts.index) {
11085 pos = this.positionInside(opts.index, stringRepresentation);
11086 } else if (opts.word) {
11087 stringRepresentation = this.toString();
11088 var index2 = stringRepresentation.indexOf(opts.word);
11089 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
11090 }
11091 return pos;
11092 };
11093 _proto.positionInside = function positionInside(index2, stringRepresentation) {
11094 var string = stringRepresentation || this.toString();
11095 var column = this.source.start.column;
11096 var line = this.source.start.line;
11097 for(var i2 = 0; i2 < index2; i2++){
11098 if (string[i2] === "\n") {
11099 column = 1;
11100 line += 1;
11101 } else {
11102 column += 1;
11103 }
11104 }
11105 return {
11106 column: column,
11107 line: line
11108 };
11109 };
11110 _proto.prev = function prev() {
11111 if (!this.parent) return void 0;
11112 var index2 = this.parent.index(this);
11113 return this.parent.nodes[index2 - 1];
11114 };
11115 _proto.rangeBy = function rangeBy(opts) {
11116 var start = {
11117 column: this.source.start.column,
11118 line: this.source.start.line
11119 };
11120 var end = this.source.end ? {
11121 column: this.source.end.column + 1,
11122 line: this.source.end.line
11123 } : {
11124 column: start.column + 1,
11125 line: start.line
11126 };
11127 if (opts.word) {
11128 var stringRepresentation = this.toString();
11129 var index2 = stringRepresentation.indexOf(opts.word);
11130 if (index2 !== -1) {
11131 start = this.positionInside(index2, stringRepresentation);
11132 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
11133 }
11134 } else {
11135 if (opts.start) {
11136 start = {
11137 column: opts.start.column,
11138 line: opts.start.line
11139 };
11140 } else if (opts.index) {
11141 start = this.positionInside(opts.index);
11142 }
11143 if (opts.end) {
11144 end = {
11145 column: opts.end.column,
11146 line: opts.end.line
11147 };
11148 } else if (typeof opts.endIndex === "number") {
11149 end = this.positionInside(opts.endIndex);
11150 } else if (opts.index) {
11151 end = this.positionInside(opts.index + 1);
11152 }
11153 }
11154 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
11155 end = {
11156 column: start.column + 1,
11157 line: start.line
11158 };
11159 }
11160 return {
11161 end: end,
11162 start: start
11163 };
11164 };
11165 _proto.raw = function raw(prop, defaultType) {
11166 var str = new Stringifier2$1();
11167 return str.raw(this, prop, defaultType);
11168 };
11169 _proto.remove = function remove() {
11170 if (this.parent) {
11171 this.parent.removeChild(this);
11172 }
11173 this.parent = void 0;
11174 return this;
11175 };
11176 _proto.replaceWith = function replaceWith() {
11177 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
11178 nodes[_key] = arguments[_key];
11179 }
11180 if (this.parent) {
11181 var bookmark = this;
11182 var foundSelf = false;
11183 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
11184 var node2 = _step.value;
11185 if (node2 === this) {
11186 foundSelf = true;
11187 } else if (foundSelf) {
11188 this.parent.insertAfter(bookmark, node2);
11189 bookmark = node2;
11190 } else {
11191 this.parent.insertBefore(bookmark, node2);
11192 }
11193 }
11194 if (!foundSelf) {
11195 this.remove();
11196 }
11197 }
11198 return this;
11199 };
11200 _proto.root = function root() {
11201 var result2 = this;
11202 while(result2.parent && result2.parent.type !== "document"){
11203 result2 = result2.parent;
11204 }
11205 return result2;
11206 };
11207 _proto.toJSON = function toJSON(_, inputs) {
11208 var fixed = {};
11209 var emitInputs = inputs == null;
11210 inputs = inputs || /* @__PURE__ */ new Map();
11211 var inputsNextIndex = 0;
11212 for(var name in this){
11213 if (!Object.prototype.hasOwnProperty.call(this, name)) {
11214 continue;
11215 }
11216 if (name === "parent" || name === "proxyCache") continue;
11217 var value = this[name];
11218 if (Array.isArray(value)) {
11219 fixed[name] = value.map(function(i2) {
11220 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
11221 return i2.toJSON(null, inputs);
11222 } else {
11223 return i2;
11224 }
11225 });
11226 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
11227 fixed[name] = value.toJSON(null, inputs);
11228 } else if (name === "source") {
11229 var inputId = inputs.get(value.input);
11230 if (inputId == null) {
11231 inputId = inputsNextIndex;
11232 inputs.set(value.input, inputsNextIndex);
11233 inputsNextIndex++;
11234 }
11235 fixed[name] = {
11236 end: value.end,
11237 inputId: inputId,
11238 start: value.start
11239 };
11240 } else {
11241 fixed[name] = value;
11242 }
11243 }
11244 if (emitInputs) {
11245 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
11246 return input2.toJSON();
11247 });
11248 }
11249 return fixed;
11250 };
11251 _proto.toProxy = function toProxy() {
11252 if (!this.proxyCache) {
11253 this.proxyCache = new Proxy(this, this.getProxyProcessor());
11254 }
11255 return this.proxyCache;
11256 };
11257 _proto.toString = function toString(stringifier2) {
11258 if (stringifier2 === void 0) stringifier2 = stringify$3$1;
11259 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
11260 var result2 = "";
11261 stringifier2(this, function(i2) {
11262 result2 += i2;
11263 });
11264 return result2;
11265 };
11266 _proto.warn = function warn(result2, text, opts) {
11267 var data = {
11268 node: this
11269 };
11270 for(var i2 in opts)data[i2] = opts[i2];
11271 return result2.warn(text, data);
11272 };
11273 _create_class(Node2, [
11274 {
11275 key: "proxyOf",
11276 get: function get() {
11277 return this;
11278 }
11279 }
11280 ]);
11281 return Node2;
11282 }();
11283 var node$1 = Node$4$1;
11284 Node$4$1.default = Node$4$1;
11285 var Node$3$1 = node$1;
11286 var Declaration$4$1 = /*#__PURE__*/ function(Node$3$1) {
11287 _inherits(Declaration, Node$3$1);
11288 function Declaration(defaults) {
11289 var _this;
11290 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
11291 defaults = _extends({}, defaults, {
11292 value: String(defaults.value)
11293 });
11294 }
11295 _this = Node$3$1.call(this, defaults) || this;
11296 _this.type = "decl";
11297 return _this;
11298 }
11299 _create_class(Declaration, [
11300 {
11301 key: "variable",
11302 get: function get() {
11303 return this.prop.startsWith("--") || this.prop[0] === "$";
11304 }
11305 }
11306 ]);
11307 return Declaration;
11308 }(Node$3$1);
11309 var declaration$1 = Declaration$4$1;
11310 Declaration$4$1.default = Declaration$4$1;
11311 var urlAlphabet$1 = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
11312 var nanoid$1$1 = function(size) {
11313 if (size === void 0) size = 21;
11314 var id = "";
11315 var i2 = size;
11316 while(i2--){
11317 id += urlAlphabet$1[Math.random() * 64 | 0];
11318 }
11319 return id;
11320 };
11321 var nonSecure$1 = {
11322 nanoid: nanoid$1$1};
11323 var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
11324 var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
11325 var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
11326 function fromBase64$1(str) {
11327 if (Buffer) {
11328 return Buffer.from(str, "base64").toString();
11329 } else {
11330 return window.atob(str);
11331 }
11332 }
11333 var PreviousMap$2$1 = /*#__PURE__*/ function() {
11334 function PreviousMap(css, opts) {
11335 if (opts.map === false) return;
11336 this.loadAnnotation(css);
11337 this.inline = this.startWith(this.annotation, "data:");
11338 var prev = opts.map ? opts.map.prev : void 0;
11339 var text = this.loadMap(opts.from, prev);
11340 if (!this.mapFile && opts.from) {
11341 this.mapFile = opts.from;
11342 }
11343 if (this.mapFile) this.root = dirname$1$1(this.mapFile);
11344 if (text) this.text = text;
11345 }
11346 var _proto = PreviousMap.prototype;
11347 _proto.consumer = function consumer() {
11348 if (!this.consumerCache) {
11349 this.consumerCache = new SourceMapConsumer$2$1(this.text);
11350 }
11351 return this.consumerCache;
11352 };
11353 _proto.decodeInline = function decodeInline(text) {
11354 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
11355 var baseUri = /^data:application\/json;base64,/;
11356 var charsetUri = /^data:application\/json;charset=utf-?8,/;
11357 var uri = /^data:application\/json,/;
11358 if (charsetUri.test(text) || uri.test(text)) {
11359 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
11360 }
11361 if (baseCharsetUri.test(text) || baseUri.test(text)) {
11362 return fromBase64$1(text.substr(RegExp.lastMatch.length));
11363 }
11364 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
11365 throw new Error("Unsupported source map encoding " + encoding);
11366 };
11367 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
11368 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
11369 };
11370 _proto.isMap = function isMap(map) {
11371 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
11372 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
11373 };
11374 _proto.loadAnnotation = function loadAnnotation(css) {
11375 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
11376 if (!comments) return;
11377 var start = css.lastIndexOf(comments.pop());
11378 var end = css.indexOf("*/", start);
11379 if (start > -1 && end > -1) {
11380 this.annotation = this.getAnnotationURL(css.substring(start, end));
11381 }
11382 };
11383 _proto.loadFile = function loadFile(path) {
11384 this.root = dirname$1$1(path);
11385 if (existsSync$1(path)) {
11386 this.mapFile = path;
11387 return readFileSync$1(path, "utf-8").toString().trim();
11388 }
11389 };
11390 _proto.loadMap = function loadMap(file, prev) {
11391 if (prev === false) return false;
11392 if (prev) {
11393 if (typeof prev === "string") {
11394 return prev;
11395 } else if (typeof prev === "function") {
11396 var prevPath = prev(file);
11397 if (prevPath) {
11398 var map = this.loadFile(prevPath);
11399 if (!map) {
11400 throw new Error("Unable to load previous source map: " + prevPath.toString());
11401 }
11402 return map;
11403 }
11404 } else if (_instanceof(prev, SourceMapConsumer$2$1)) {
11405 return SourceMapGenerator$2$1.fromSourceMap(prev).toString();
11406 } else if (_instanceof(prev, SourceMapGenerator$2$1)) {
11407 return prev.toString();
11408 } else if (this.isMap(prev)) {
11409 return JSON.stringify(prev);
11410 } else {
11411 throw new Error("Unsupported previous source map format: " + prev.toString());
11412 }
11413 } else if (this.inline) {
11414 return this.decodeInline(this.annotation);
11415 } else if (this.annotation) {
11416 var map1 = this.annotation;
11417 if (file) map1 = join$1(dirname$1$1(file), map1);
11418 return this.loadFile(map1);
11419 }
11420 };
11421 _proto.startWith = function startWith(string, start) {
11422 if (!string) return false;
11423 return string.substr(0, start.length) === start;
11424 };
11425 _proto.withContent = function withContent() {
11426 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
11427 };
11428 return PreviousMap;
11429 }();
11430 var previousMap$1 = PreviousMap$2$1;
11431 PreviousMap$2$1.default = PreviousMap$2$1;
11432 var SourceMapConsumer$1$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$1$1 = require$$2$1.SourceMapGenerator;
11433 var fileURLToPath$1 = require$$2$1.fileURLToPath, pathToFileURL$1$1 = require$$2$1.pathToFileURL;
11434 var isAbsolute$1 = require$$2$1.isAbsolute, resolve$1$1 = require$$2$1.resolve;
11435 var nanoid$2 = nonSecure$1.nanoid;
11436 var terminalHighlight$2 = require$$2$1;
11437 var CssSyntaxError$1$1 = cssSyntaxError$1;
11438 var PreviousMap$1$1 = previousMap$1;
11439 var fromOffsetCache$1 = Symbol("fromOffsetCache");
11440 var sourceMapAvailable$1$1 = Boolean(SourceMapConsumer$1$1 && SourceMapGenerator$1$1);
11441 var pathAvailable$1$1 = Boolean(resolve$1$1 && isAbsolute$1);
11442 var Input$4$1 = /*#__PURE__*/ function() {
11443 function Input(css, opts) {
11444 if (opts === void 0) opts = {};
11445 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
11446 throw new Error("PostCSS received " + css + " instead of CSS string");
11447 }
11448 this.css = css.toString();
11449 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
11450 this.hasBOM = true;
11451 this.css = this.css.slice(1);
11452 } else {
11453 this.hasBOM = false;
11454 }
11455 if (opts.from) {
11456 if (!pathAvailable$1$1 || /^\w+:\/\//.test(opts.from) || isAbsolute$1(opts.from)) {
11457 this.file = opts.from;
11458 } else {
11459 this.file = resolve$1$1(opts.from);
11460 }
11461 }
11462 if (pathAvailable$1$1 && sourceMapAvailable$1$1) {
11463 var map = new PreviousMap$1$1(this.css, opts);
11464 if (map.text) {
11465 this.map = map;
11466 var file = map.consumer().file;
11467 if (!this.file && file) this.file = this.mapResolve(file);
11468 }
11469 }
11470 if (!this.file) {
11471 this.id = "<input css " + nanoid$2(6) + ">";
11472 }
11473 if (this.map) this.map.file = this.from;
11474 }
11475 var _proto = Input.prototype;
11476 _proto.error = function error(message, line, column, opts) {
11477 if (opts === void 0) opts = {};
11478 var result2, endLine, endColumn;
11479 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
11480 var start = line;
11481 var end = column;
11482 if (typeof start.offset === "number") {
11483 var pos = this.fromOffset(start.offset);
11484 line = pos.line;
11485 column = pos.col;
11486 } else {
11487 line = start.line;
11488 column = start.column;
11489 }
11490 if (typeof end.offset === "number") {
11491 var pos1 = this.fromOffset(end.offset);
11492 endLine = pos1.line;
11493 endColumn = pos1.col;
11494 } else {
11495 endLine = end.line;
11496 endColumn = end.column;
11497 }
11498 } else if (!column) {
11499 var pos2 = this.fromOffset(line);
11500 line = pos2.line;
11501 column = pos2.col;
11502 }
11503 var origin = this.origin(line, column, endLine, endColumn);
11504 if (origin) {
11505 result2 = new CssSyntaxError$1$1(message, origin.endLine === void 0 ? origin.line : {
11506 column: origin.column,
11507 line: origin.line
11508 }, origin.endLine === void 0 ? origin.column : {
11509 column: origin.endColumn,
11510 line: origin.endLine
11511 }, origin.source, origin.file, opts.plugin);
11512 } else {
11513 result2 = new CssSyntaxError$1$1(message, endLine === void 0 ? line : {
11514 column: column,
11515 line: line
11516 }, endLine === void 0 ? column : {
11517 column: endColumn,
11518 line: endLine
11519 }, this.css, this.file, opts.plugin);
11520 }
11521 result2.input = {
11522 column: column,
11523 endColumn: endColumn,
11524 endLine: endLine,
11525 line: line,
11526 source: this.css
11527 };
11528 if (this.file) {
11529 if (pathToFileURL$1$1) {
11530 result2.input.url = pathToFileURL$1$1(this.file).toString();
11531 }
11532 result2.input.file = this.file;
11533 }
11534 return result2;
11535 };
11536 _proto.fromOffset = function fromOffset(offset) {
11537 var lastLine, lineToIndex;
11538 if (!this[fromOffsetCache$1]) {
11539 var lines = this.css.split("\n");
11540 lineToIndex = new Array(lines.length);
11541 var prevIndex = 0;
11542 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
11543 lineToIndex[i2] = prevIndex;
11544 prevIndex += lines[i2].length + 1;
11545 }
11546 this[fromOffsetCache$1] = lineToIndex;
11547 } else {
11548 lineToIndex = this[fromOffsetCache$1];
11549 }
11550 lastLine = lineToIndex[lineToIndex.length - 1];
11551 var min = 0;
11552 if (offset >= lastLine) {
11553 min = lineToIndex.length - 1;
11554 } else {
11555 var max = lineToIndex.length - 2;
11556 var mid;
11557 while(min < max){
11558 mid = min + (max - min >> 1);
11559 if (offset < lineToIndex[mid]) {
11560 max = mid - 1;
11561 } else if (offset >= lineToIndex[mid + 1]) {
11562 min = mid + 1;
11563 } else {
11564 min = mid;
11565 break;
11566 }
11567 }
11568 }
11569 return {
11570 col: offset - lineToIndex[min] + 1,
11571 line: min + 1
11572 };
11573 };
11574 _proto.mapResolve = function mapResolve(file) {
11575 if (/^\w+:\/\//.test(file)) {
11576 return file;
11577 }
11578 return resolve$1$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
11579 };
11580 _proto.origin = function origin(line, column, endLine, endColumn) {
11581 if (!this.map) return false;
11582 var consumer = this.map.consumer();
11583 var from = consumer.originalPositionFor({
11584 column: column,
11585 line: line
11586 });
11587 if (!from.source) return false;
11588 var to;
11589 if (typeof endLine === "number") {
11590 to = consumer.originalPositionFor({
11591 column: endColumn,
11592 line: endLine
11593 });
11594 }
11595 var fromUrl;
11596 if (isAbsolute$1(from.source)) {
11597 fromUrl = pathToFileURL$1$1(from.source);
11598 } else {
11599 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1$1(this.map.mapFile));
11600 }
11601 var result2 = {
11602 column: from.column,
11603 endColumn: to && to.column,
11604 endLine: to && to.line,
11605 line: from.line,
11606 url: fromUrl.toString()
11607 };
11608 if (fromUrl.protocol === "file:") {
11609 if (fileURLToPath$1) {
11610 result2.file = fileURLToPath$1(fromUrl);
11611 } else {
11612 throw new Error("file: protocol is not available in this PostCSS build");
11613 }
11614 }
11615 var source = consumer.sourceContentFor(from.source);
11616 if (source) result2.source = source;
11617 return result2;
11618 };
11619 _proto.toJSON = function toJSON() {
11620 var json = {};
11621 for(var _i = 0, _iter = [
11622 "hasBOM",
11623 "css",
11624 "file",
11625 "id"
11626 ]; _i < _iter.length; _i++){
11627 var name = _iter[_i];
11628 if (this[name] != null) {
11629 json[name] = this[name];
11630 }
11631 }
11632 if (this.map) {
11633 json.map = _extends({}, this.map);
11634 if (json.map.consumerCache) {
11635 json.map.consumerCache = void 0;
11636 }
11637 }
11638 return json;
11639 };
11640 _create_class(Input, [
11641 {
11642 key: "from",
11643 get: function get() {
11644 return this.file || this.id;
11645 }
11646 }
11647 ]);
11648 return Input;
11649 }();
11650 var input$1 = Input$4$1;
11651 Input$4$1.default = Input$4$1;
11652 if (terminalHighlight$2 && terminalHighlight$2.registerInput) {
11653 terminalHighlight$2.registerInput(Input$4$1);
11654 }
11655 var SourceMapConsumer$3 = require$$2$1.SourceMapConsumer, SourceMapGenerator$3 = require$$2$1.SourceMapGenerator;
11656 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;
11657 var pathToFileURL$2 = require$$2$1.pathToFileURL;
11658 var Input$3$1 = input$1;
11659 var sourceMapAvailable$2 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$3);
11660 var pathAvailable$2 = Boolean(dirname$2 && resolve$2 && relative$1 && sep$1);
11661 var MapGenerator$2$1 = /*#__PURE__*/ function() {
11662 function MapGenerator(stringify2, root2, opts, cssString) {
11663 this.stringify = stringify2;
11664 this.mapOpts = opts.map || {};
11665 this.root = root2;
11666 this.opts = opts;
11667 this.css = cssString;
11668 this.originalCSS = cssString;
11669 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
11670 this.memoizedFileURLs = /* @__PURE__ */ new Map();
11671 this.memoizedPaths = /* @__PURE__ */ new Map();
11672 this.memoizedURLs = /* @__PURE__ */ new Map();
11673 }
11674 var _proto = MapGenerator.prototype;
11675 _proto.addAnnotation = function addAnnotation() {
11676 var content;
11677 if (this.isInline()) {
11678 content = "data:application/json;base64," + this.toBase64(this.map.toString());
11679 } else if (typeof this.mapOpts.annotation === "string") {
11680 content = this.mapOpts.annotation;
11681 } else if (typeof this.mapOpts.annotation === "function") {
11682 content = this.mapOpts.annotation(this.opts.to, this.root);
11683 } else {
11684 content = this.outputFile() + ".map";
11685 }
11686 var eol = "\n";
11687 if (this.css.includes("\r\n")) eol = "\r\n";
11688 this.css += eol + "/*# sourceMappingURL=" + content + " */";
11689 };
11690 _proto.applyPrevMaps = function applyPrevMaps() {
11691 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
11692 var prev = _step.value;
11693 var from = this.toUrl(this.path(prev.file));
11694 var root2 = prev.root || dirname$2(prev.file);
11695 var map = void 0;
11696 if (this.mapOpts.sourcesContent === false) {
11697 map = new SourceMapConsumer$3(prev.text);
11698 if (map.sourcesContent) {
11699 map.sourcesContent = null;
11700 }
11701 } else {
11702 map = prev.consumer();
11703 }
11704 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
11705 }
11706 };
11707 _proto.clearAnnotation = function clearAnnotation() {
11708 if (this.mapOpts.annotation === false) return;
11709 if (this.root) {
11710 var node2;
11711 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
11712 node2 = this.root.nodes[i2];
11713 if (node2.type !== "comment") continue;
11714 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
11715 this.root.removeChild(i2);
11716 }
11717 }
11718 } else if (this.css) {
11719 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
11720 }
11721 };
11722 _proto.generate = function generate() {
11723 this.clearAnnotation();
11724 if (pathAvailable$2 && sourceMapAvailable$2 && this.isMap()) {
11725 return this.generateMap();
11726 } else {
11727 var result2 = "";
11728 this.stringify(this.root, function(i2) {
11729 result2 += i2;
11730 });
11731 return [
11732 result2
11733 ];
11734 }
11735 };
11736 _proto.generateMap = function generateMap() {
11737 if (this.root) {
11738 this.generateString();
11739 } else if (this.previous().length === 1) {
11740 var prev = this.previous()[0].consumer();
11741 prev.file = this.outputFile();
11742 this.map = SourceMapGenerator$3.fromSourceMap(prev, {
11743 ignoreInvalidMapping: true
11744 });
11745 } else {
11746 this.map = new SourceMapGenerator$3({
11747 file: this.outputFile(),
11748 ignoreInvalidMapping: true
11749 });
11750 this.map.addMapping({
11751 generated: {
11752 column: 0,
11753 line: 1
11754 },
11755 original: {
11756 column: 0,
11757 line: 1
11758 },
11759 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
11760 });
11761 }
11762 if (this.isSourcesContent()) this.setSourcesContent();
11763 if (this.root && this.previous().length > 0) this.applyPrevMaps();
11764 if (this.isAnnotation()) this.addAnnotation();
11765 if (this.isInline()) {
11766 return [
11767 this.css
11768 ];
11769 } else {
11770 return [
11771 this.css,
11772 this.map
11773 ];
11774 }
11775 };
11776 _proto.generateString = function generateString() {
11777 var _this = this;
11778 this.css = "";
11779 this.map = new SourceMapGenerator$3({
11780 file: this.outputFile(),
11781 ignoreInvalidMapping: true
11782 });
11783 var line = 1;
11784 var column = 1;
11785 var noSource = "<no source>";
11786 var mapping = {
11787 generated: {
11788 column: 0,
11789 line: 0
11790 },
11791 original: {
11792 column: 0,
11793 line: 0
11794 },
11795 source: ""
11796 };
11797 var lines, last;
11798 this.stringify(this.root, function(str, node2, type) {
11799 _this.css += str;
11800 if (node2 && type !== "end") {
11801 mapping.generated.line = line;
11802 mapping.generated.column = column - 1;
11803 if (node2.source && node2.source.start) {
11804 mapping.source = _this.sourcePath(node2);
11805 mapping.original.line = node2.source.start.line;
11806 mapping.original.column = node2.source.start.column - 1;
11807 _this.map.addMapping(mapping);
11808 } else {
11809 mapping.source = noSource;
11810 mapping.original.line = 1;
11811 mapping.original.column = 0;
11812 _this.map.addMapping(mapping);
11813 }
11814 }
11815 lines = str.match(/\n/g);
11816 if (lines) {
11817 line += lines.length;
11818 last = str.lastIndexOf("\n");
11819 column = str.length - last;
11820 } else {
11821 column += str.length;
11822 }
11823 if (node2 && type !== "start") {
11824 var p = node2.parent || {
11825 raws: {}
11826 };
11827 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
11828 if (!childless || node2 !== p.last || p.raws.semicolon) {
11829 if (node2.source && node2.source.end) {
11830 mapping.source = _this.sourcePath(node2);
11831 mapping.original.line = node2.source.end.line;
11832 mapping.original.column = node2.source.end.column - 1;
11833 mapping.generated.line = line;
11834 mapping.generated.column = column - 2;
11835 _this.map.addMapping(mapping);
11836 } else {
11837 mapping.source = noSource;
11838 mapping.original.line = 1;
11839 mapping.original.column = 0;
11840 mapping.generated.line = line;
11841 mapping.generated.column = column - 1;
11842 _this.map.addMapping(mapping);
11843 }
11844 }
11845 }
11846 });
11847 };
11848 _proto.isAnnotation = function isAnnotation() {
11849 if (this.isInline()) {
11850 return true;
11851 }
11852 if (typeof this.mapOpts.annotation !== "undefined") {
11853 return this.mapOpts.annotation;
11854 }
11855 if (this.previous().length) {
11856 return this.previous().some(function(i2) {
11857 return i2.annotation;
11858 });
11859 }
11860 return true;
11861 };
11862 _proto.isInline = function isInline() {
11863 if (typeof this.mapOpts.inline !== "undefined") {
11864 return this.mapOpts.inline;
11865 }
11866 var annotation = this.mapOpts.annotation;
11867 if (typeof annotation !== "undefined" && annotation !== true) {
11868 return false;
11869 }
11870 if (this.previous().length) {
11871 return this.previous().some(function(i2) {
11872 return i2.inline;
11873 });
11874 }
11875 return true;
11876 };
11877 _proto.isMap = function isMap() {
11878 if (typeof this.opts.map !== "undefined") {
11879 return !!this.opts.map;
11880 }
11881 return this.previous().length > 0;
11882 };
11883 _proto.isSourcesContent = function isSourcesContent() {
11884 if (typeof this.mapOpts.sourcesContent !== "undefined") {
11885 return this.mapOpts.sourcesContent;
11886 }
11887 if (this.previous().length) {
11888 return this.previous().some(function(i2) {
11889 return i2.withContent();
11890 });
11891 }
11892 return true;
11893 };
11894 _proto.outputFile = function outputFile() {
11895 if (this.opts.to) {
11896 return this.path(this.opts.to);
11897 } else if (this.opts.from) {
11898 return this.path(this.opts.from);
11899 } else {
11900 return "to.css";
11901 }
11902 };
11903 _proto.path = function path(file) {
11904 if (this.mapOpts.absolute) return file;
11905 if (file.charCodeAt(0) === 60) return file;
11906 if (/^\w+:\/\//.test(file)) return file;
11907 var cached = this.memoizedPaths.get(file);
11908 if (cached) return cached;
11909 var from = this.opts.to ? dirname$2(this.opts.to) : ".";
11910 if (typeof this.mapOpts.annotation === "string") {
11911 from = dirname$2(resolve$2(from, this.mapOpts.annotation));
11912 }
11913 var path = relative$1(from, file);
11914 this.memoizedPaths.set(file, path);
11915 return path;
11916 };
11917 _proto.previous = function previous() {
11918 var _this = this;
11919 if (!this.previousMaps) {
11920 this.previousMaps = [];
11921 if (this.root) {
11922 this.root.walk(function(node2) {
11923 if (node2.source && node2.source.input.map) {
11924 var map = node2.source.input.map;
11925 if (!_this.previousMaps.includes(map)) {
11926 _this.previousMaps.push(map);
11927 }
11928 }
11929 });
11930 } else {
11931 var input2 = new Input$3$1(this.originalCSS, this.opts);
11932 if (input2.map) this.previousMaps.push(input2.map);
11933 }
11934 }
11935 return this.previousMaps;
11936 };
11937 _proto.setSourcesContent = function setSourcesContent() {
11938 var _this = this;
11939 var already = {};
11940 if (this.root) {
11941 this.root.walk(function(node2) {
11942 if (node2.source) {
11943 var from = node2.source.input.from;
11944 if (from && !already[from]) {
11945 already[from] = true;
11946 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
11947 _this.map.setSourceContent(fromUrl, node2.source.input.css);
11948 }
11949 }
11950 });
11951 } else if (this.css) {
11952 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
11953 this.map.setSourceContent(from, this.css);
11954 }
11955 };
11956 _proto.sourcePath = function sourcePath(node2) {
11957 if (this.mapOpts.from) {
11958 return this.toUrl(this.mapOpts.from);
11959 } else if (this.usesFileUrls) {
11960 return this.toFileUrl(node2.source.input.from);
11961 } else {
11962 return this.toUrl(this.path(node2.source.input.from));
11963 }
11964 };
11965 _proto.toBase64 = function toBase64(str) {
11966 if (Buffer) {
11967 return Buffer.from(str).toString("base64");
11968 } else {
11969 return window.btoa(unescape(encodeURIComponent(str)));
11970 }
11971 };
11972 _proto.toFileUrl = function toFileUrl(path) {
11973 var cached = this.memoizedFileURLs.get(path);
11974 if (cached) return cached;
11975 if (pathToFileURL$2) {
11976 var fileURL = pathToFileURL$2(path).toString();
11977 this.memoizedFileURLs.set(path, fileURL);
11978 return fileURL;
11979 } else {
11980 throw new Error("`map.absolute` option is not available in this PostCSS build");
11981 }
11982 };
11983 _proto.toUrl = function toUrl(path) {
11984 var cached = this.memoizedURLs.get(path);
11985 if (cached) return cached;
11986 if (sep$1 === "\\") {
11987 path = path.replace(/\\/g, "/");
11988 }
11989 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
11990 this.memoizedURLs.set(path, url);
11991 return url;
11992 };
11993 return MapGenerator;
11994 }();
11995 var mapGenerator$1 = MapGenerator$2$1;
11996 var Node$2$1 = node$1;
11997 var Comment$4$1 = /*#__PURE__*/ function(Node$2$1) {
11998 _inherits(Comment, Node$2$1);
11999 function Comment(defaults) {
12000 var _this;
12001 _this = Node$2$1.call(this, defaults) || this;
12002 _this.type = "comment";
12003 return _this;
12004 }
12005 return Comment;
12006 }(Node$2$1);
12007 var comment$1 = Comment$4$1;
12008 Comment$4$1.default = Comment$4$1;
12009 var isClean$1$1 = symbols$1.isClean, my$1$1 = symbols$1.my;
12010 var Declaration$3$1 = declaration$1;
12011 var Comment$3$1 = comment$1;
12012 var Node$1$1 = node$1;
12013 var parse$4$1, Rule$4$1, AtRule$4$1, Root$6$1;
12014 function cleanSource$1(nodes) {
12015 return nodes.map(function(i2) {
12016 if (i2.nodes) i2.nodes = cleanSource$1(i2.nodes);
12017 delete i2.source;
12018 return i2;
12019 });
12020 }
12021 function markDirtyUp$1(node2) {
12022 node2[isClean$1$1] = false;
12023 if (node2.proxyOf.nodes) {
12024 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12025 var i2 = _step.value;
12026 markDirtyUp$1(i2);
12027 }
12028 }
12029 }
12030 var Container$7$1 = /*#__PURE__*/ function(Node$1$1) {
12031 _inherits(Container, Node$1$1);
12032 function Container() {
12033 return Node$1$1.apply(this, arguments) || this;
12034 }
12035 var _proto = Container.prototype;
12036 _proto.append = function append() {
12037 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12038 children[_key] = arguments[_key];
12039 }
12040 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12041 var child = _step.value;
12042 var nodes = this.normalize(child, this.last);
12043 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12044 var node2 = _step1.value;
12045 this.proxyOf.nodes.push(node2);
12046 }
12047 }
12048 this.markDirty();
12049 return this;
12050 };
12051 _proto.cleanRaws = function cleanRaws(keepBetween) {
12052 Node$1$1.prototype.cleanRaws.call(this, keepBetween);
12053 if (this.nodes) {
12054 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
12055 var node2 = _step.value;
12056 node2.cleanRaws(keepBetween);
12057 }
12058 }
12059 };
12060 _proto.each = function each(callback) {
12061 if (!this.proxyOf.nodes) return void 0;
12062 var iterator = this.getIterator();
12063 var index2, result2;
12064 while(this.indexes[iterator] < this.proxyOf.nodes.length){
12065 index2 = this.indexes[iterator];
12066 result2 = callback(this.proxyOf.nodes[index2], index2);
12067 if (result2 === false) break;
12068 this.indexes[iterator] += 1;
12069 }
12070 delete this.indexes[iterator];
12071 return result2;
12072 };
12073 _proto.every = function every(condition) {
12074 return this.nodes.every(condition);
12075 };
12076 _proto.getIterator = function getIterator() {
12077 if (!this.lastEach) this.lastEach = 0;
12078 if (!this.indexes) this.indexes = {};
12079 this.lastEach += 1;
12080 var iterator = this.lastEach;
12081 this.indexes[iterator] = 0;
12082 return iterator;
12083 };
12084 _proto.getProxyProcessor = function getProxyProcessor() {
12085 return {
12086 get: function get(node2, prop) {
12087 if (prop === "proxyOf") {
12088 return node2;
12089 } else if (!node2[prop]) {
12090 return node2[prop];
12091 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
12092 return function() {
12093 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12094 args[_key] = arguments[_key];
12095 }
12096 var _node2;
12097 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
12098 if (typeof i2 === "function") {
12099 return function(child, index2) {
12100 return i2(child.toProxy(), index2);
12101 };
12102 } else {
12103 return i2;
12104 }
12105 })));
12106 };
12107 } else if (prop === "every" || prop === "some") {
12108 return function(cb) {
12109 return node2[prop](function(child) {
12110 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12111 other[_key - 1] = arguments[_key];
12112 }
12113 return cb.apply(void 0, [].concat([
12114 child.toProxy()
12115 ], other));
12116 });
12117 };
12118 } else if (prop === "root") {
12119 return function() {
12120 return node2.root().toProxy();
12121 };
12122 } else if (prop === "nodes") {
12123 return node2.nodes.map(function(i2) {
12124 return i2.toProxy();
12125 });
12126 } else if (prop === "first" || prop === "last") {
12127 return node2[prop].toProxy();
12128 } else {
12129 return node2[prop];
12130 }
12131 },
12132 set: function set(node2, prop, value) {
12133 if (node2[prop] === value) return true;
12134 node2[prop] = value;
12135 if (prop === "name" || prop === "params" || prop === "selector") {
12136 node2.markDirty();
12137 }
12138 return true;
12139 }
12140 };
12141 };
12142 _proto.index = function index(child) {
12143 if (typeof child === "number") return child;
12144 if (child.proxyOf) child = child.proxyOf;
12145 return this.proxyOf.nodes.indexOf(child);
12146 };
12147 _proto.insertAfter = function insertAfter(exist, add) {
12148 var existIndex = this.index(exist);
12149 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
12150 existIndex = this.index(exist);
12151 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12152 var node2 = _step.value;
12153 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
12154 }
12155 var index2;
12156 for(var id in this.indexes){
12157 index2 = this.indexes[id];
12158 if (existIndex < index2) {
12159 this.indexes[id] = index2 + nodes.length;
12160 }
12161 }
12162 this.markDirty();
12163 return this;
12164 };
12165 _proto.insertBefore = function insertBefore(exist, add) {
12166 var existIndex = this.index(exist);
12167 var type = existIndex === 0 ? "prepend" : false;
12168 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
12169 existIndex = this.index(exist);
12170 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12171 var node2 = _step.value;
12172 this.proxyOf.nodes.splice(existIndex, 0, node2);
12173 }
12174 var index2;
12175 for(var id in this.indexes){
12176 index2 = this.indexes[id];
12177 if (existIndex <= index2) {
12178 this.indexes[id] = index2 + nodes.length;
12179 }
12180 }
12181 this.markDirty();
12182 return this;
12183 };
12184 _proto.normalize = function normalize(nodes, sample) {
12185 var _this = this;
12186 if (typeof nodes === "string") {
12187 nodes = cleanSource$1(parse$4$1(nodes).nodes);
12188 } else if (typeof nodes === "undefined") {
12189 nodes = [];
12190 } else if (Array.isArray(nodes)) {
12191 nodes = nodes.slice(0);
12192 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12193 var i2 = _step.value;
12194 if (i2.parent) i2.parent.removeChild(i2, "ignore");
12195 }
12196 } else if (nodes.type === "root" && this.type !== "document") {
12197 nodes = nodes.nodes.slice(0);
12198 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12199 var i21 = _step1.value;
12200 if (i21.parent) i21.parent.removeChild(i21, "ignore");
12201 }
12202 } else if (nodes.type) {
12203 nodes = [
12204 nodes
12205 ];
12206 } else if (nodes.prop) {
12207 if (typeof nodes.value === "undefined") {
12208 throw new Error("Value field is missed in node creation");
12209 } else if (typeof nodes.value !== "string") {
12210 nodes.value = String(nodes.value);
12211 }
12212 nodes = [
12213 new Declaration$3$1(nodes)
12214 ];
12215 } else if (nodes.selector) {
12216 nodes = [
12217 new Rule$4$1(nodes)
12218 ];
12219 } else if (nodes.name) {
12220 nodes = [
12221 new AtRule$4$1(nodes)
12222 ];
12223 } else if (nodes.text) {
12224 nodes = [
12225 new Comment$3$1(nodes)
12226 ];
12227 } else {
12228 throw new Error("Unknown node type in node creation");
12229 }
12230 var processed = nodes.map(function(i2) {
12231 if (!i2[my$1$1]) Container.rebuild(i2);
12232 i2 = i2.proxyOf;
12233 if (i2.parent) i2.parent.removeChild(i2);
12234 if (i2[isClean$1$1]) markDirtyUp$1(i2);
12235 if (typeof i2.raws.before === "undefined") {
12236 if (sample && typeof sample.raws.before !== "undefined") {
12237 i2.raws.before = sample.raws.before.replace(/\S/g, "");
12238 }
12239 }
12240 i2.parent = _this.proxyOf;
12241 return i2;
12242 });
12243 return processed;
12244 };
12245 _proto.prepend = function prepend() {
12246 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12247 children[_key] = arguments[_key];
12248 }
12249 children = children.reverse();
12250 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
12251 var child = _step.value;
12252 var nodes = this.normalize(child, this.first, "prepend").reverse();
12253 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
12254 var node2 = _step1.value;
12255 this.proxyOf.nodes.unshift(node2);
12256 }
12257 for(var id in this.indexes){
12258 this.indexes[id] = this.indexes[id] + nodes.length;
12259 }
12260 }
12261 this.markDirty();
12262 return this;
12263 };
12264 _proto.push = function push(child) {
12265 child.parent = this;
12266 this.proxyOf.nodes.push(child);
12267 return this;
12268 };
12269 _proto.removeAll = function removeAll() {
12270 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
12271 var node2 = _step.value;
12272 node2.parent = void 0;
12273 }
12274 this.proxyOf.nodes = [];
12275 this.markDirty();
12276 return this;
12277 };
12278 _proto.removeChild = function removeChild(child) {
12279 child = this.index(child);
12280 this.proxyOf.nodes[child].parent = void 0;
12281 this.proxyOf.nodes.splice(child, 1);
12282 var index2;
12283 for(var id in this.indexes){
12284 index2 = this.indexes[id];
12285 if (index2 >= child) {
12286 this.indexes[id] = index2 - 1;
12287 }
12288 }
12289 this.markDirty();
12290 return this;
12291 };
12292 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
12293 if (!callback) {
12294 callback = opts;
12295 opts = {};
12296 }
12297 this.walkDecls(function(decl) {
12298 if (opts.props && !opts.props.includes(decl.prop)) return;
12299 if (opts.fast && !decl.value.includes(opts.fast)) return;
12300 decl.value = decl.value.replace(pattern, callback);
12301 });
12302 this.markDirty();
12303 return this;
12304 };
12305 _proto.some = function some(condition) {
12306 return this.nodes.some(condition);
12307 };
12308 _proto.walk = function walk(callback) {
12309 return this.each(function(child, i2) {
12310 var result2;
12311 try {
12312 result2 = callback(child, i2);
12313 } catch (e2) {
12314 throw child.addToError(e2);
12315 }
12316 if (result2 !== false && child.walk) {
12317 result2 = child.walk(callback);
12318 }
12319 return result2;
12320 });
12321 };
12322 _proto.walkAtRules = function walkAtRules(name, callback) {
12323 if (!callback) {
12324 callback = name;
12325 return this.walk(function(child, i2) {
12326 if (child.type === "atrule") {
12327 return callback(child, i2);
12328 }
12329 });
12330 }
12331 if (_instanceof(name, RegExp)) {
12332 return this.walk(function(child, i2) {
12333 if (child.type === "atrule" && name.test(child.name)) {
12334 return callback(child, i2);
12335 }
12336 });
12337 }
12338 return this.walk(function(child, i2) {
12339 if (child.type === "atrule" && child.name === name) {
12340 return callback(child, i2);
12341 }
12342 });
12343 };
12344 _proto.walkComments = function walkComments(callback) {
12345 return this.walk(function(child, i2) {
12346 if (child.type === "comment") {
12347 return callback(child, i2);
12348 }
12349 });
12350 };
12351 _proto.walkDecls = function walkDecls(prop, callback) {
12352 if (!callback) {
12353 callback = prop;
12354 return this.walk(function(child, i2) {
12355 if (child.type === "decl") {
12356 return callback(child, i2);
12357 }
12358 });
12359 }
12360 if (_instanceof(prop, RegExp)) {
12361 return this.walk(function(child, i2) {
12362 if (child.type === "decl" && prop.test(child.prop)) {
12363 return callback(child, i2);
12364 }
12365 });
12366 }
12367 return this.walk(function(child, i2) {
12368 if (child.type === "decl" && child.prop === prop) {
12369 return callback(child, i2);
12370 }
12371 });
12372 };
12373 _proto.walkRules = function walkRules(selector, callback) {
12374 if (!callback) {
12375 callback = selector;
12376 return this.walk(function(child, i2) {
12377 if (child.type === "rule") {
12378 return callback(child, i2);
12379 }
12380 });
12381 }
12382 if (_instanceof(selector, RegExp)) {
12383 return this.walk(function(child, i2) {
12384 if (child.type === "rule" && selector.test(child.selector)) {
12385 return callback(child, i2);
12386 }
12387 });
12388 }
12389 return this.walk(function(child, i2) {
12390 if (child.type === "rule" && child.selector === selector) {
12391 return callback(child, i2);
12392 }
12393 });
12394 };
12395 _create_class(Container, [
12396 {
12397 key: "first",
12398 get: function get() {
12399 if (!this.proxyOf.nodes) return void 0;
12400 return this.proxyOf.nodes[0];
12401 }
12402 },
12403 {
12404 key: "last",
12405 get: function get() {
12406 if (!this.proxyOf.nodes) return void 0;
12407 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
12408 }
12409 }
12410 ]);
12411 return Container;
12412 }(Node$1$1);
12413 Container$7$1.registerParse = function(dependant) {
12414 parse$4$1 = dependant;
12415 };
12416 Container$7$1.registerRule = function(dependant) {
12417 Rule$4$1 = dependant;
12418 };
12419 Container$7$1.registerAtRule = function(dependant) {
12420 AtRule$4$1 = dependant;
12421 };
12422 Container$7$1.registerRoot = function(dependant) {
12423 Root$6$1 = dependant;
12424 };
12425 var container$1 = Container$7$1;
12426 Container$7$1.default = Container$7$1;
12427 Container$7$1.rebuild = function(node2) {
12428 if (node2.type === "atrule") {
12429 Object.setPrototypeOf(node2, AtRule$4$1.prototype);
12430 } else if (node2.type === "rule") {
12431 Object.setPrototypeOf(node2, Rule$4$1.prototype);
12432 } else if (node2.type === "decl") {
12433 Object.setPrototypeOf(node2, Declaration$3$1.prototype);
12434 } else if (node2.type === "comment") {
12435 Object.setPrototypeOf(node2, Comment$3$1.prototype);
12436 } else if (node2.type === "root") {
12437 Object.setPrototypeOf(node2, Root$6$1.prototype);
12438 }
12439 node2[my$1$1] = true;
12440 if (node2.nodes) {
12441 node2.nodes.forEach(function(child) {
12442 Container$7$1.rebuild(child);
12443 });
12444 }
12445 };
12446 var Container$6$1 = container$1;
12447 var LazyResult$4$1, Processor$3$1;
12448 var Document$3$1 = /*#__PURE__*/ function(Container$6$1) {
12449 _inherits(Document2, Container$6$1);
12450 function Document2(defaults) {
12451 var _this;
12452 _this = Container$6$1.call(this, _extends({
12453 type: "document"
12454 }, defaults)) || this;
12455 if (!_this.nodes) {
12456 _this.nodes = [];
12457 }
12458 return _this;
12459 }
12460 var _proto = Document2.prototype;
12461 _proto.toResult = function toResult(opts) {
12462 if (opts === void 0) opts = {};
12463 var lazy = new LazyResult$4$1(new Processor$3$1(), this, opts);
12464 return lazy.stringify();
12465 };
12466 return Document2;
12467 }(Container$6$1);
12468 Document$3$1.registerLazyResult = function(dependant) {
12469 LazyResult$4$1 = dependant;
12470 };
12471 Document$3$1.registerProcessor = function(dependant) {
12472 Processor$3$1 = dependant;
12473 };
12474 var document$1$1 = Document$3$1;
12475 Document$3$1.default = Document$3$1;
12476 var printed$1 = {};
12477 var warnOnce$2$1 = function warnOnce(message) {
12478 if (printed$1[message]) return;
12479 printed$1[message] = true;
12480 if (typeof console !== "undefined" && console.warn) {
12481 console.warn(message);
12482 }
12483 };
12484 var Warning$2$1 = /*#__PURE__*/ function() {
12485 function Warning(text, opts) {
12486 if (opts === void 0) opts = {};
12487 this.type = "warning";
12488 this.text = text;
12489 if (opts.node && opts.node.source) {
12490 var range = opts.node.rangeBy(opts);
12491 this.line = range.start.line;
12492 this.column = range.start.column;
12493 this.endLine = range.end.line;
12494 this.endColumn = range.end.column;
12495 }
12496 for(var opt in opts)this[opt] = opts[opt];
12497 }
12498 var _proto = Warning.prototype;
12499 _proto.toString = function toString() {
12500 if (this.node) {
12501 return this.node.error(this.text, {
12502 index: this.index,
12503 plugin: this.plugin,
12504 word: this.word
12505 }).message;
12506 }
12507 if (this.plugin) {
12508 return this.plugin + ": " + this.text;
12509 }
12510 return this.text;
12511 };
12512 return Warning;
12513 }();
12514 var warning$1 = Warning$2$1;
12515 Warning$2$1.default = Warning$2$1;
12516 var Warning$1$1 = warning$1;
12517 var Result$3$1 = /*#__PURE__*/ function() {
12518 function Result(processor2, root2, opts) {
12519 this.processor = processor2;
12520 this.messages = [];
12521 this.root = root2;
12522 this.opts = opts;
12523 this.css = void 0;
12524 this.map = void 0;
12525 }
12526 var _proto = Result.prototype;
12527 _proto.toString = function toString() {
12528 return this.css;
12529 };
12530 _proto.warn = function warn(text, opts) {
12531 if (opts === void 0) opts = {};
12532 if (!opts.plugin) {
12533 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
12534 opts.plugin = this.lastPlugin.postcssPlugin;
12535 }
12536 }
12537 var warning2 = new Warning$1$1(text, opts);
12538 this.messages.push(warning2);
12539 return warning2;
12540 };
12541 _proto.warnings = function warnings() {
12542 return this.messages.filter(function(i2) {
12543 return i2.type === "warning";
12544 });
12545 };
12546 _create_class(Result, [
12547 {
12548 key: "content",
12549 get: function get() {
12550 return this.css;
12551 }
12552 }
12553 ]);
12554 return Result;
12555 }();
12556 var result$1 = Result$3$1;
12557 Result$3$1.default = Result$3$1;
12558 var SINGLE_QUOTE$1 = "'".charCodeAt(0);
12559 var DOUBLE_QUOTE$1 = '"'.charCodeAt(0);
12560 var BACKSLASH$1 = "\\".charCodeAt(0);
12561 var SLASH$1 = "/".charCodeAt(0);
12562 var NEWLINE$1 = "\n".charCodeAt(0);
12563 var SPACE$1 = " ".charCodeAt(0);
12564 var FEED$1 = "\f".charCodeAt(0);
12565 var TAB$1 = " ".charCodeAt(0);
12566 var CR$1 = "\r".charCodeAt(0);
12567 var OPEN_SQUARE$1 = "[".charCodeAt(0);
12568 var CLOSE_SQUARE$1 = "]".charCodeAt(0);
12569 var OPEN_PARENTHESES$1 = "(".charCodeAt(0);
12570 var CLOSE_PARENTHESES$1 = ")".charCodeAt(0);
12571 var OPEN_CURLY$1 = "{".charCodeAt(0);
12572 var CLOSE_CURLY$1 = "}".charCodeAt(0);
12573 var SEMICOLON$1 = ";".charCodeAt(0);
12574 var ASTERISK$1 = "*".charCodeAt(0);
12575 var COLON$1 = ":".charCodeAt(0);
12576 var AT$1 = "@".charCodeAt(0);
12577 var RE_AT_END$1 = /[\t\n\f\r "#'()/;[\\\]{}]/g;
12578 var RE_WORD_END$1 = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
12579 var RE_BAD_BRACKET$1 = /.[\r\n"'(/\\]/;
12580 var RE_HEX_ESCAPE$1 = /[\da-f]/i;
12581 var tokenize$1 = function tokenizer(input2, options) {
12582 if (options === void 0) options = {};
12583 var css = input2.css.valueOf();
12584 var ignore = options.ignoreErrors;
12585 var code, next, quote, content, escape;
12586 var escaped, escapePos, prev, n2, currentToken;
12587 var length = css.length;
12588 var pos = 0;
12589 var buffer = [];
12590 var returned = [];
12591 function position() {
12592 return pos;
12593 }
12594 function unclosed(what) {
12595 throw input2.error("Unclosed " + what, pos);
12596 }
12597 function endOfFile() {
12598 return returned.length === 0 && pos >= length;
12599 }
12600 function nextToken(opts) {
12601 if (returned.length) return returned.pop();
12602 if (pos >= length) return;
12603 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
12604 code = css.charCodeAt(pos);
12605 switch(code){
12606 case NEWLINE$1:
12607 case SPACE$1:
12608 case TAB$1:
12609 case CR$1:
12610 case FEED$1:
12611 {
12612 next = pos;
12613 do {
12614 next += 1;
12615 code = css.charCodeAt(next);
12616 }while (code === SPACE$1 || code === NEWLINE$1 || code === TAB$1 || code === CR$1 || code === FEED$1);
12617 currentToken = [
12618 "space",
12619 css.slice(pos, next)
12620 ];
12621 pos = next - 1;
12622 break;
12623 }
12624 case OPEN_SQUARE$1:
12625 case CLOSE_SQUARE$1:
12626 case OPEN_CURLY$1:
12627 case CLOSE_CURLY$1:
12628 case COLON$1:
12629 case SEMICOLON$1:
12630 case CLOSE_PARENTHESES$1:
12631 {
12632 var controlChar = String.fromCharCode(code);
12633 currentToken = [
12634 controlChar,
12635 controlChar,
12636 pos
12637 ];
12638 break;
12639 }
12640 case OPEN_PARENTHESES$1:
12641 {
12642 prev = buffer.length ? buffer.pop()[1] : "";
12643 n2 = css.charCodeAt(pos + 1);
12644 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) {
12645 next = pos;
12646 do {
12647 escaped = false;
12648 next = css.indexOf(")", next + 1);
12649 if (next === -1) {
12650 if (ignore || ignoreUnclosed) {
12651 next = pos;
12652 break;
12653 } else {
12654 unclosed("bracket");
12655 }
12656 }
12657 escapePos = next;
12658 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12659 escapePos -= 1;
12660 escaped = !escaped;
12661 }
12662 }while (escaped);
12663 currentToken = [
12664 "brackets",
12665 css.slice(pos, next + 1),
12666 pos,
12667 next
12668 ];
12669 pos = next;
12670 } else {
12671 next = css.indexOf(")", pos + 1);
12672 content = css.slice(pos, next + 1);
12673 if (next === -1 || RE_BAD_BRACKET$1.test(content)) {
12674 currentToken = [
12675 "(",
12676 "(",
12677 pos
12678 ];
12679 } else {
12680 currentToken = [
12681 "brackets",
12682 content,
12683 pos,
12684 next
12685 ];
12686 pos = next;
12687 }
12688 }
12689 break;
12690 }
12691 case SINGLE_QUOTE$1:
12692 case DOUBLE_QUOTE$1:
12693 {
12694 quote = code === SINGLE_QUOTE$1 ? "'" : '"';
12695 next = pos;
12696 do {
12697 escaped = false;
12698 next = css.indexOf(quote, next + 1);
12699 if (next === -1) {
12700 if (ignore || ignoreUnclosed) {
12701 next = pos + 1;
12702 break;
12703 } else {
12704 unclosed("string");
12705 }
12706 }
12707 escapePos = next;
12708 while(css.charCodeAt(escapePos - 1) === BACKSLASH$1){
12709 escapePos -= 1;
12710 escaped = !escaped;
12711 }
12712 }while (escaped);
12713 currentToken = [
12714 "string",
12715 css.slice(pos, next + 1),
12716 pos,
12717 next
12718 ];
12719 pos = next;
12720 break;
12721 }
12722 case AT$1:
12723 {
12724 RE_AT_END$1.lastIndex = pos + 1;
12725 RE_AT_END$1.test(css);
12726 if (RE_AT_END$1.lastIndex === 0) {
12727 next = css.length - 1;
12728 } else {
12729 next = RE_AT_END$1.lastIndex - 2;
12730 }
12731 currentToken = [
12732 "at-word",
12733 css.slice(pos, next + 1),
12734 pos,
12735 next
12736 ];
12737 pos = next;
12738 break;
12739 }
12740 case BACKSLASH$1:
12741 {
12742 next = pos;
12743 escape = true;
12744 while(css.charCodeAt(next + 1) === BACKSLASH$1){
12745 next += 1;
12746 escape = !escape;
12747 }
12748 code = css.charCodeAt(next + 1);
12749 if (escape && code !== SLASH$1 && code !== SPACE$1 && code !== NEWLINE$1 && code !== TAB$1 && code !== CR$1 && code !== FEED$1) {
12750 next += 1;
12751 if (RE_HEX_ESCAPE$1.test(css.charAt(next))) {
12752 while(RE_HEX_ESCAPE$1.test(css.charAt(next + 1))){
12753 next += 1;
12754 }
12755 if (css.charCodeAt(next + 1) === SPACE$1) {
12756 next += 1;
12757 }
12758 }
12759 }
12760 currentToken = [
12761 "word",
12762 css.slice(pos, next + 1),
12763 pos,
12764 next
12765 ];
12766 pos = next;
12767 break;
12768 }
12769 default:
12770 {
12771 if (code === SLASH$1 && css.charCodeAt(pos + 1) === ASTERISK$1) {
12772 next = css.indexOf("*/", pos + 2) + 1;
12773 if (next === 0) {
12774 if (ignore || ignoreUnclosed) {
12775 next = css.length;
12776 } else {
12777 unclosed("comment");
12778 }
12779 }
12780 currentToken = [
12781 "comment",
12782 css.slice(pos, next + 1),
12783 pos,
12784 next
12785 ];
12786 pos = next;
12787 } else {
12788 RE_WORD_END$1.lastIndex = pos + 1;
12789 RE_WORD_END$1.test(css);
12790 if (RE_WORD_END$1.lastIndex === 0) {
12791 next = css.length - 1;
12792 } else {
12793 next = RE_WORD_END$1.lastIndex - 2;
12794 }
12795 currentToken = [
12796 "word",
12797 css.slice(pos, next + 1),
12798 pos,
12799 next
12800 ];
12801 buffer.push(currentToken);
12802 pos = next;
12803 }
12804 break;
12805 }
12806 }
12807 pos++;
12808 return currentToken;
12809 }
12810 function back(token) {
12811 returned.push(token);
12812 }
12813 return {
12814 back: back,
12815 endOfFile: endOfFile,
12816 nextToken: nextToken,
12817 position: position
12818 };
12819 };
12820 var Container$5$1 = container$1;
12821 var AtRule$3$1 = /*#__PURE__*/ function(Container$5$1) {
12822 _inherits(AtRule, Container$5$1);
12823 function AtRule(defaults) {
12824 var _this;
12825 _this = Container$5$1.call(this, defaults) || this;
12826 _this.type = "atrule";
12827 return _this;
12828 }
12829 var _proto = AtRule.prototype;
12830 _proto.append = function append() {
12831 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12832 children[_key] = arguments[_key];
12833 }
12834 var _Container$5$1_prototype_append;
12835 if (!this.proxyOf.nodes) this.nodes = [];
12836 return (_Container$5$1_prototype_append = Container$5$1.prototype.append).call.apply(_Container$5$1_prototype_append, [].concat([
12837 this
12838 ], children));
12839 };
12840 _proto.prepend = function prepend() {
12841 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
12842 children[_key] = arguments[_key];
12843 }
12844 var _Container$5$1_prototype_prepend;
12845 if (!this.proxyOf.nodes) this.nodes = [];
12846 return (_Container$5$1_prototype_prepend = Container$5$1.prototype.prepend).call.apply(_Container$5$1_prototype_prepend, [].concat([
12847 this
12848 ], children));
12849 };
12850 return AtRule;
12851 }(Container$5$1);
12852 var atRule$1 = AtRule$3$1;
12853 AtRule$3$1.default = AtRule$3$1;
12854 Container$5$1.registerAtRule(AtRule$3$1);
12855 var Container$4$1 = container$1;
12856 var LazyResult$3$1, Processor$2$1;
12857 var Root$5$1 = /*#__PURE__*/ function(Container$4$1) {
12858 _inherits(Root, Container$4$1);
12859 function Root(defaults) {
12860 var _this;
12861 _this = Container$4$1.call(this, defaults) || this;
12862 _this.type = "root";
12863 if (!_this.nodes) _this.nodes = [];
12864 return _this;
12865 }
12866 var _proto = Root.prototype;
12867 _proto.normalize = function normalize(child, sample, type) {
12868 var nodes = Container$4$1.prototype.normalize.call(this, child);
12869 if (sample) {
12870 if (type === "prepend") {
12871 if (this.nodes.length > 1) {
12872 sample.raws.before = this.nodes[1].raws.before;
12873 } else {
12874 delete sample.raws.before;
12875 }
12876 } else if (this.first !== sample) {
12877 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
12878 var node2 = _step.value;
12879 node2.raws.before = sample.raws.before;
12880 }
12881 }
12882 }
12883 return nodes;
12884 };
12885 _proto.removeChild = function removeChild(child, ignore) {
12886 var index2 = this.index(child);
12887 if (!ignore && index2 === 0 && this.nodes.length > 1) {
12888 this.nodes[1].raws.before = this.nodes[index2].raws.before;
12889 }
12890 return Container$4$1.prototype.removeChild.call(this, child);
12891 };
12892 _proto.toResult = function toResult(opts) {
12893 if (opts === void 0) opts = {};
12894 var lazy = new LazyResult$3$1(new Processor$2$1(), this, opts);
12895 return lazy.stringify();
12896 };
12897 return Root;
12898 }(Container$4$1);
12899 Root$5$1.registerLazyResult = function(dependant) {
12900 LazyResult$3$1 = dependant;
12901 };
12902 Root$5$1.registerProcessor = function(dependant) {
12903 Processor$2$1 = dependant;
12904 };
12905 var root$1 = Root$5$1;
12906 Root$5$1.default = Root$5$1;
12907 Container$4$1.registerRoot(Root$5$1);
12908 var list$2$1 = {
12909 comma: function comma(string) {
12910 return list$2$1.split(string, [
12911 ","
12912 ], true);
12913 },
12914 space: function space(string) {
12915 var spaces = [
12916 " ",
12917 "\n",
12918 " "
12919 ];
12920 return list$2$1.split(string, spaces);
12921 },
12922 split: function split(string, separators, last) {
12923 var array = [];
12924 var current = "";
12925 var split = false;
12926 var func = 0;
12927 var inQuote = false;
12928 var prevQuote = "";
12929 var escape = false;
12930 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
12931 var letter = _step.value;
12932 if (escape) {
12933 escape = false;
12934 } else if (letter === "\\") {
12935 escape = true;
12936 } else if (inQuote) {
12937 if (letter === prevQuote) {
12938 inQuote = false;
12939 }
12940 } else if (letter === '"' || letter === "'") {
12941 inQuote = true;
12942 prevQuote = letter;
12943 } else if (letter === "(") {
12944 func += 1;
12945 } else if (letter === ")") {
12946 if (func > 0) func -= 1;
12947 } else if (func === 0) {
12948 if (separators.includes(letter)) split = true;
12949 }
12950 if (split) {
12951 if (current !== "") array.push(current.trim());
12952 current = "";
12953 split = false;
12954 } else {
12955 current += letter;
12956 }
12957 }
12958 if (last || current !== "") array.push(current.trim());
12959 return array;
12960 }
12961 };
12962 var list_1$1 = list$2$1;
12963 list$2$1.default = list$2$1;
12964 var Container$3$1 = container$1;
12965 var list$1$1 = list_1$1;
12966 var Rule$3$1 = /*#__PURE__*/ function(Container$3$1) {
12967 _inherits(Rule, Container$3$1);
12968 function Rule(defaults) {
12969 var _this;
12970 _this = Container$3$1.call(this, defaults) || this;
12971 _this.type = "rule";
12972 if (!_this.nodes) _this.nodes = [];
12973 return _this;
12974 }
12975 _create_class(Rule, [
12976 {
12977 key: "selectors",
12978 get: function get() {
12979 return list$1$1.comma(this.selector);
12980 },
12981 set: function set(values) {
12982 var match = this.selector ? this.selector.match(/,\s*/) : null;
12983 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
12984 this.selector = values.join(sep2);
12985 }
12986 }
12987 ]);
12988 return Rule;
12989 }(Container$3$1);
12990 var rule$1 = Rule$3$1;
12991 Rule$3$1.default = Rule$3$1;
12992 Container$3$1.registerRule(Rule$3$1);
12993 var Declaration$2$1 = declaration$1;
12994 var tokenizer2$1 = tokenize$1;
12995 var Comment$2$1 = comment$1;
12996 var AtRule$2$1 = atRule$1;
12997 var Root$4$1 = root$1;
12998 var Rule$2$1 = rule$1;
12999 var SAFE_COMMENT_NEIGHBOR$1 = {
13000 empty: true,
13001 space: true
13002 };
13003 function findLastWithPosition$1(tokens) {
13004 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13005 var token = tokens[i2];
13006 var pos = token[3] || token[2];
13007 if (pos) return pos;
13008 }
13009 }
13010 var Parser$1$1 = /*#__PURE__*/ function() {
13011 function Parser(input2) {
13012 this.input = input2;
13013 this.root = new Root$4$1();
13014 this.current = this.root;
13015 this.spaces = "";
13016 this.semicolon = false;
13017 this.createTokenizer();
13018 this.root.source = {
13019 input: input2,
13020 start: {
13021 column: 1,
13022 line: 1,
13023 offset: 0
13024 }
13025 };
13026 }
13027 var _proto = Parser.prototype;
13028 _proto.atrule = function atrule(token) {
13029 var node2 = new AtRule$2$1();
13030 node2.name = token[1].slice(1);
13031 if (node2.name === "") {
13032 this.unnamedAtrule(node2, token);
13033 }
13034 this.init(node2, token[2]);
13035 var type;
13036 var prev;
13037 var shift;
13038 var last = false;
13039 var open = false;
13040 var params = [];
13041 var brackets = [];
13042 while(!this.tokenizer.endOfFile()){
13043 token = this.tokenizer.nextToken();
13044 type = token[0];
13045 if (type === "(" || type === "[") {
13046 brackets.push(type === "(" ? ")" : "]");
13047 } else if (type === "{" && brackets.length > 0) {
13048 brackets.push("}");
13049 } else if (type === brackets[brackets.length - 1]) {
13050 brackets.pop();
13051 }
13052 if (brackets.length === 0) {
13053 if (type === ";") {
13054 node2.source.end = this.getPosition(token[2]);
13055 node2.source.end.offset++;
13056 this.semicolon = true;
13057 break;
13058 } else if (type === "{") {
13059 open = true;
13060 break;
13061 } else if (type === "}") {
13062 if (params.length > 0) {
13063 shift = params.length - 1;
13064 prev = params[shift];
13065 while(prev && prev[0] === "space"){
13066 prev = params[--shift];
13067 }
13068 if (prev) {
13069 node2.source.end = this.getPosition(prev[3] || prev[2]);
13070 node2.source.end.offset++;
13071 }
13072 }
13073 this.end(token);
13074 break;
13075 } else {
13076 params.push(token);
13077 }
13078 } else {
13079 params.push(token);
13080 }
13081 if (this.tokenizer.endOfFile()) {
13082 last = true;
13083 break;
13084 }
13085 }
13086 node2.raws.between = this.spacesAndCommentsFromEnd(params);
13087 if (params.length) {
13088 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
13089 this.raw(node2, "params", params);
13090 if (last) {
13091 token = params[params.length - 1];
13092 node2.source.end = this.getPosition(token[3] || token[2]);
13093 node2.source.end.offset++;
13094 this.spaces = node2.raws.between;
13095 node2.raws.between = "";
13096 }
13097 } else {
13098 node2.raws.afterName = "";
13099 node2.params = "";
13100 }
13101 if (open) {
13102 node2.nodes = [];
13103 this.current = node2;
13104 }
13105 };
13106 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
13107 var colon = this.colon(tokens);
13108 if (colon === false) return;
13109 var founded = 0;
13110 var token;
13111 for(var j = colon - 1; j >= 0; j--){
13112 token = tokens[j];
13113 if (token[0] !== "space") {
13114 founded += 1;
13115 if (founded === 2) break;
13116 }
13117 }
13118 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
13119 };
13120 _proto.colon = function colon(tokens) {
13121 var brackets = 0;
13122 var token, type, prev;
13123 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
13124 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
13125 token = element;
13126 type = token[0];
13127 if (type === "(") {
13128 brackets += 1;
13129 }
13130 if (type === ")") {
13131 brackets -= 1;
13132 }
13133 if (brackets === 0 && type === ":") {
13134 if (!prev) {
13135 this.doubleColon(token);
13136 } else if (prev[0] === "word" && prev[1] === "progid") {
13137 continue;
13138 } else {
13139 return i2;
13140 }
13141 }
13142 prev = token;
13143 }
13144 return false;
13145 };
13146 _proto.comment = function comment(token) {
13147 var node2 = new Comment$2$1();
13148 this.init(node2, token[2]);
13149 node2.source.end = this.getPosition(token[3] || token[2]);
13150 node2.source.end.offset++;
13151 var text = token[1].slice(2, -2);
13152 if (/^\s*$/.test(text)) {
13153 node2.text = "";
13154 node2.raws.left = text;
13155 node2.raws.right = "";
13156 } else {
13157 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
13158 node2.text = match[2];
13159 node2.raws.left = match[1];
13160 node2.raws.right = match[3];
13161 }
13162 };
13163 _proto.createTokenizer = function createTokenizer() {
13164 this.tokenizer = tokenizer2$1(this.input);
13165 };
13166 _proto.decl = function decl(tokens, customProperty) {
13167 var node2 = new Declaration$2$1();
13168 this.init(node2, tokens[0][2]);
13169 var last = tokens[tokens.length - 1];
13170 if (last[0] === ";") {
13171 this.semicolon = true;
13172 tokens.pop();
13173 }
13174 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition$1(tokens));
13175 node2.source.end.offset++;
13176 while(tokens[0][0] !== "word"){
13177 if (tokens.length === 1) this.unknownWord(tokens);
13178 node2.raws.before += tokens.shift()[1];
13179 }
13180 node2.source.start = this.getPosition(tokens[0][2]);
13181 node2.prop = "";
13182 while(tokens.length){
13183 var type = tokens[0][0];
13184 if (type === ":" || type === "space" || type === "comment") {
13185 break;
13186 }
13187 node2.prop += tokens.shift()[1];
13188 }
13189 node2.raws.between = "";
13190 var token;
13191 while(tokens.length){
13192 token = tokens.shift();
13193 if (token[0] === ":") {
13194 node2.raws.between += token[1];
13195 break;
13196 } else {
13197 if (token[0] === "word" && /\w/.test(token[1])) {
13198 this.unknownWord([
13199 token
13200 ]);
13201 }
13202 node2.raws.between += token[1];
13203 }
13204 }
13205 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
13206 node2.raws.before += node2.prop[0];
13207 node2.prop = node2.prop.slice(1);
13208 }
13209 var firstSpaces = [];
13210 var next;
13211 while(tokens.length){
13212 next = tokens[0][0];
13213 if (next !== "space" && next !== "comment") break;
13214 firstSpaces.push(tokens.shift());
13215 }
13216 this.precheckMissedSemicolon(tokens);
13217 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
13218 token = tokens[i2];
13219 if (token[1].toLowerCase() === "!important") {
13220 node2.important = true;
13221 var string = this.stringFrom(tokens, i2);
13222 string = this.spacesFromEnd(tokens) + string;
13223 if (string !== " !important") node2.raws.important = string;
13224 break;
13225 } else if (token[1].toLowerCase() === "important") {
13226 var cache = tokens.slice(0);
13227 var str = "";
13228 for(var j = i2; j > 0; j--){
13229 var type1 = cache[j][0];
13230 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
13231 break;
13232 }
13233 str = cache.pop()[1] + str;
13234 }
13235 if (str.trim().indexOf("!") === 0) {
13236 node2.important = true;
13237 node2.raws.important = str;
13238 tokens = cache;
13239 }
13240 }
13241 if (token[0] !== "space" && token[0] !== "comment") {
13242 break;
13243 }
13244 }
13245 var hasWord = tokens.some(function(i2) {
13246 return i2[0] !== "space" && i2[0] !== "comment";
13247 });
13248 if (hasWord) {
13249 node2.raws.between += firstSpaces.map(function(i2) {
13250 return i2[1];
13251 }).join("");
13252 firstSpaces = [];
13253 }
13254 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
13255 if (node2.value.includes(":") && !customProperty) {
13256 this.checkMissedSemicolon(tokens);
13257 }
13258 };
13259 _proto.doubleColon = function doubleColon(token) {
13260 throw this.input.error("Double colon", {
13261 offset: token[2]
13262 }, {
13263 offset: token[2] + token[1].length
13264 });
13265 };
13266 _proto.emptyRule = function emptyRule(token) {
13267 var node2 = new Rule$2$1();
13268 this.init(node2, token[2]);
13269 node2.selector = "";
13270 node2.raws.between = "";
13271 this.current = node2;
13272 };
13273 _proto.end = function end(token) {
13274 if (this.current.nodes && this.current.nodes.length) {
13275 this.current.raws.semicolon = this.semicolon;
13276 }
13277 this.semicolon = false;
13278 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13279 this.spaces = "";
13280 if (this.current.parent) {
13281 this.current.source.end = this.getPosition(token[2]);
13282 this.current.source.end.offset++;
13283 this.current = this.current.parent;
13284 } else {
13285 this.unexpectedClose(token);
13286 }
13287 };
13288 _proto.endFile = function endFile() {
13289 if (this.current.parent) this.unclosedBlock();
13290 if (this.current.nodes && this.current.nodes.length) {
13291 this.current.raws.semicolon = this.semicolon;
13292 }
13293 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
13294 this.root.source.end = this.getPosition(this.tokenizer.position());
13295 };
13296 _proto.freeSemicolon = function freeSemicolon(token) {
13297 this.spaces += token[1];
13298 if (this.current.nodes) {
13299 var prev = this.current.nodes[this.current.nodes.length - 1];
13300 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
13301 prev.raws.ownSemicolon = this.spaces;
13302 this.spaces = "";
13303 }
13304 }
13305 };
13306 // Helpers
13307 _proto.getPosition = function getPosition(offset) {
13308 var pos = this.input.fromOffset(offset);
13309 return {
13310 column: pos.col,
13311 line: pos.line,
13312 offset: offset
13313 };
13314 };
13315 _proto.init = function init(node2, offset) {
13316 this.current.push(node2);
13317 node2.source = {
13318 input: this.input,
13319 start: this.getPosition(offset)
13320 };
13321 node2.raws.before = this.spaces;
13322 this.spaces = "";
13323 if (node2.type !== "comment") this.semicolon = false;
13324 };
13325 _proto.other = function other(start) {
13326 var end = false;
13327 var type = null;
13328 var colon = false;
13329 var bracket = null;
13330 var brackets = [];
13331 var customProperty = start[1].startsWith("--");
13332 var tokens = [];
13333 var token = start;
13334 while(token){
13335 type = token[0];
13336 tokens.push(token);
13337 if (type === "(" || type === "[") {
13338 if (!bracket) bracket = token;
13339 brackets.push(type === "(" ? ")" : "]");
13340 } else if (customProperty && colon && type === "{") {
13341 if (!bracket) bracket = token;
13342 brackets.push("}");
13343 } else if (brackets.length === 0) {
13344 if (type === ";") {
13345 if (colon) {
13346 this.decl(tokens, customProperty);
13347 return;
13348 } else {
13349 break;
13350 }
13351 } else if (type === "{") {
13352 this.rule(tokens);
13353 return;
13354 } else if (type === "}") {
13355 this.tokenizer.back(tokens.pop());
13356 end = true;
13357 break;
13358 } else if (type === ":") {
13359 colon = true;
13360 }
13361 } else if (type === brackets[brackets.length - 1]) {
13362 brackets.pop();
13363 if (brackets.length === 0) bracket = null;
13364 }
13365 token = this.tokenizer.nextToken();
13366 }
13367 if (this.tokenizer.endOfFile()) end = true;
13368 if (brackets.length > 0) this.unclosedBracket(bracket);
13369 if (end && colon) {
13370 if (!customProperty) {
13371 while(tokens.length){
13372 token = tokens[tokens.length - 1][0];
13373 if (token !== "space" && token !== "comment") break;
13374 this.tokenizer.back(tokens.pop());
13375 }
13376 }
13377 this.decl(tokens, customProperty);
13378 } else {
13379 this.unknownWord(tokens);
13380 }
13381 };
13382 _proto.parse = function parse() {
13383 var token;
13384 while(!this.tokenizer.endOfFile()){
13385 token = this.tokenizer.nextToken();
13386 switch(token[0]){
13387 case "space":
13388 this.spaces += token[1];
13389 break;
13390 case ";":
13391 this.freeSemicolon(token);
13392 break;
13393 case "}":
13394 this.end(token);
13395 break;
13396 case "comment":
13397 this.comment(token);
13398 break;
13399 case "at-word":
13400 this.atrule(token);
13401 break;
13402 case "{":
13403 this.emptyRule(token);
13404 break;
13405 default:
13406 this.other(token);
13407 break;
13408 }
13409 }
13410 this.endFile();
13411 };
13412 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
13413 _proto.raw = function raw(node2, prop, tokens, customProperty) {
13414 var token, type;
13415 var length = tokens.length;
13416 var value = "";
13417 var clean = true;
13418 var next, prev;
13419 for(var i2 = 0; i2 < length; i2 += 1){
13420 token = tokens[i2];
13421 type = token[0];
13422 if (type === "space" && i2 === length - 1 && !customProperty) {
13423 clean = false;
13424 } else if (type === "comment") {
13425 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
13426 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
13427 if (!SAFE_COMMENT_NEIGHBOR$1[prev] && !SAFE_COMMENT_NEIGHBOR$1[next]) {
13428 if (value.slice(-1) === ",") {
13429 clean = false;
13430 } else {
13431 value += token[1];
13432 }
13433 } else {
13434 clean = false;
13435 }
13436 } else {
13437 value += token[1];
13438 }
13439 }
13440 if (!clean) {
13441 var raw = tokens.reduce(function(all, i2) {
13442 return all + i2[1];
13443 }, "");
13444 node2.raws[prop] = {
13445 raw: raw,
13446 value: value
13447 };
13448 }
13449 node2[prop] = value;
13450 };
13451 _proto.rule = function rule(tokens) {
13452 tokens.pop();
13453 var node2 = new Rule$2$1();
13454 this.init(node2, tokens[0][2]);
13455 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
13456 this.raw(node2, "selector", tokens);
13457 this.current = node2;
13458 };
13459 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
13460 var lastTokenType;
13461 var spaces = "";
13462 while(tokens.length){
13463 lastTokenType = tokens[tokens.length - 1][0];
13464 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
13465 spaces = tokens.pop()[1] + spaces;
13466 }
13467 return spaces;
13468 };
13469 // Errors
13470 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
13471 var next;
13472 var spaces = "";
13473 while(tokens.length){
13474 next = tokens[0][0];
13475 if (next !== "space" && next !== "comment") break;
13476 spaces += tokens.shift()[1];
13477 }
13478 return spaces;
13479 };
13480 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
13481 var lastTokenType;
13482 var spaces = "";
13483 while(tokens.length){
13484 lastTokenType = tokens[tokens.length - 1][0];
13485 if (lastTokenType !== "space") break;
13486 spaces = tokens.pop()[1] + spaces;
13487 }
13488 return spaces;
13489 };
13490 _proto.stringFrom = function stringFrom(tokens, from) {
13491 var result2 = "";
13492 for(var i2 = from; i2 < tokens.length; i2++){
13493 result2 += tokens[i2][1];
13494 }
13495 tokens.splice(from, tokens.length - from);
13496 return result2;
13497 };
13498 _proto.unclosedBlock = function unclosedBlock() {
13499 var pos = this.current.source.start;
13500 throw this.input.error("Unclosed block", pos.line, pos.column);
13501 };
13502 _proto.unclosedBracket = function unclosedBracket(bracket) {
13503 throw this.input.error("Unclosed bracket", {
13504 offset: bracket[2]
13505 }, {
13506 offset: bracket[2] + 1
13507 });
13508 };
13509 _proto.unexpectedClose = function unexpectedClose(token) {
13510 throw this.input.error("Unexpected }", {
13511 offset: token[2]
13512 }, {
13513 offset: token[2] + 1
13514 });
13515 };
13516 _proto.unknownWord = function unknownWord(tokens) {
13517 throw this.input.error("Unknown word", {
13518 offset: tokens[0][2]
13519 }, {
13520 offset: tokens[0][2] + tokens[0][1].length
13521 });
13522 };
13523 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
13524 throw this.input.error("At-rule without name", {
13525 offset: token[2]
13526 }, {
13527 offset: token[2] + token[1].length
13528 });
13529 };
13530 return Parser;
13531 }();
13532 var parser$1 = Parser$1$1;
13533 var Container$2$1 = container$1;
13534 var Parser2$1 = parser$1;
13535 var Input$2$1 = input$1;
13536 function parse$3$1(css, opts) {
13537 var input2 = new Input$2$1(css, opts);
13538 var parser2 = new Parser2$1(input2);
13539 try {
13540 parser2.parse();
13541 } catch (e2) {
13542 if (true) {
13543 if (e2.name === "CssSyntaxError" && opts && opts.from) {
13544 if (/\.scss$/i.test(opts.from)) {
13545 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
13546 } else if (/\.sass/i.test(opts.from)) {
13547 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
13548 } else if (/\.less$/i.test(opts.from)) {
13549 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
13550 }
13551 }
13552 }
13553 throw e2;
13554 }
13555 return parser2.root;
13556 }
13557 var parse_1$1 = parse$3$1;
13558 parse$3$1.default = parse$3$1;
13559 Container$2$1.registerParse(parse$3$1);
13560 var isClean$3 = symbols$1.isClean, my$3 = symbols$1.my;
13561 var MapGenerator$1$1 = mapGenerator$1;
13562 var stringify$2$1 = stringify_1$1;
13563 var Container$1$1 = container$1;
13564 var Document$2$1 = document$1$1;
13565 var warnOnce$1$1 = warnOnce$2$1;
13566 var Result$2$1 = result$1;
13567 var parse$2$1 = parse_1$1;
13568 var Root$3$1 = root$1;
13569 var TYPE_TO_CLASS_NAME$1 = {
13570 atrule: "AtRule",
13571 comment: "Comment",
13572 decl: "Declaration",
13573 document: "Document",
13574 root: "Root",
13575 rule: "Rule"
13576 };
13577 var PLUGIN_PROPS$1 = {
13578 AtRule: true,
13579 AtRuleExit: true,
13580 Comment: true,
13581 CommentExit: true,
13582 Declaration: true,
13583 DeclarationExit: true,
13584 Document: true,
13585 DocumentExit: true,
13586 Once: true,
13587 OnceExit: true,
13588 postcssPlugin: true,
13589 prepare: true,
13590 Root: true,
13591 RootExit: true,
13592 Rule: true,
13593 RuleExit: true
13594 };
13595 var NOT_VISITORS$1 = {
13596 Once: true,
13597 postcssPlugin: true,
13598 prepare: true
13599 };
13600 var CHILDREN$1 = 0;
13601 function isPromise$1(obj) {
13602 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
13603 }
13604 function getEvents$1(node2) {
13605 var key = false;
13606 var type = TYPE_TO_CLASS_NAME$1[node2.type];
13607 if (node2.type === "decl") {
13608 key = node2.prop.toLowerCase();
13609 } else if (node2.type === "atrule") {
13610 key = node2.name.toLowerCase();
13611 }
13612 if (key && node2.append) {
13613 return [
13614 type,
13615 type + "-" + key,
13616 CHILDREN$1,
13617 type + "Exit",
13618 type + "Exit-" + key
13619 ];
13620 } else if (key) {
13621 return [
13622 type,
13623 type + "-" + key,
13624 type + "Exit",
13625 type + "Exit-" + key
13626 ];
13627 } else if (node2.append) {
13628 return [
13629 type,
13630 CHILDREN$1,
13631 type + "Exit"
13632 ];
13633 } else {
13634 return [
13635 type,
13636 type + "Exit"
13637 ];
13638 }
13639 }
13640 function toStack$1(node2) {
13641 var events;
13642 if (node2.type === "document") {
13643 events = [
13644 "Document",
13645 CHILDREN$1,
13646 "DocumentExit"
13647 ];
13648 } else if (node2.type === "root") {
13649 events = [
13650 "Root",
13651 CHILDREN$1,
13652 "RootExit"
13653 ];
13654 } else {
13655 events = getEvents$1(node2);
13656 }
13657 return {
13658 eventIndex: 0,
13659 events: events,
13660 iterator: 0,
13661 node: node2,
13662 visitorIndex: 0,
13663 visitors: []
13664 };
13665 }
13666 function cleanMarks$1(node2) {
13667 node2[isClean$3] = false;
13668 if (node2.nodes) node2.nodes.forEach(function(i2) {
13669 return cleanMarks$1(i2);
13670 });
13671 return node2;
13672 }
13673 var postcss$2$1 = {};
13674 var LazyResult$2$1 = /*#__PURE__*/ function() {
13675 function LazyResult(processor2, css, opts) {
13676 var _this = this;
13677 this.stringified = false;
13678 this.processed = false;
13679 var root2;
13680 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
13681 root2 = cleanMarks$1(css);
13682 } else if (_instanceof(css, LazyResult) || _instanceof(css, Result$2$1)) {
13683 root2 = cleanMarks$1(css.root);
13684 if (css.map) {
13685 if (typeof opts.map === "undefined") opts.map = {};
13686 if (!opts.map.inline) opts.map.inline = false;
13687 opts.map.prev = css.map;
13688 }
13689 } else {
13690 var parser2 = parse$2$1;
13691 if (opts.syntax) parser2 = opts.syntax.parse;
13692 if (opts.parser) parser2 = opts.parser;
13693 if (parser2.parse) parser2 = parser2.parse;
13694 try {
13695 root2 = parser2(css, opts);
13696 } catch (error) {
13697 this.processed = true;
13698 this.error = error;
13699 }
13700 if (root2 && !root2[my$3]) {
13701 Container$1$1.rebuild(root2);
13702 }
13703 }
13704 this.result = new Result$2$1(processor2, root2, opts);
13705 this.helpers = _extends({}, postcss$2$1, {
13706 postcss: postcss$2$1,
13707 result: this.result
13708 });
13709 this.plugins = this.processor.plugins.map(function(plugin22) {
13710 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
13711 return _extends({}, plugin22, plugin22.prepare(_this.result));
13712 } else {
13713 return plugin22;
13714 }
13715 });
13716 }
13717 var _proto = LazyResult.prototype;
13718 _proto.async = function async() {
13719 if (this.error) return Promise.reject(this.error);
13720 if (this.processed) return Promise.resolve(this.result);
13721 if (!this.processing) {
13722 this.processing = this.runAsync();
13723 }
13724 return this.processing;
13725 };
13726 _proto.catch = function _catch(onRejected) {
13727 return this.async().catch(onRejected);
13728 };
13729 _proto.finally = function _finally(onFinally) {
13730 return this.async().then(onFinally, onFinally);
13731 };
13732 _proto.getAsyncError = function getAsyncError() {
13733 throw new Error("Use process(css).then(cb) to work with async plugins");
13734 };
13735 _proto.handleError = function handleError(error, node2) {
13736 var plugin22 = this.result.lastPlugin;
13737 try {
13738 if (node2) node2.addToError(error);
13739 this.error = error;
13740 if (error.name === "CssSyntaxError" && !error.plugin) {
13741 error.plugin = plugin22.postcssPlugin;
13742 error.setMessage();
13743 } else if (plugin22.postcssVersion) {
13744 if (true) {
13745 var pluginName = plugin22.postcssPlugin;
13746 var pluginVer = plugin22.postcssVersion;
13747 var runtimeVer = this.result.processor.version;
13748 var a2 = pluginVer.split(".");
13749 var b = runtimeVer.split(".");
13750 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
13751 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.");
13752 }
13753 }
13754 }
13755 } catch (err) {
13756 if (console && console.error) console.error(err);
13757 }
13758 return error;
13759 };
13760 _proto.prepareVisitors = function prepareVisitors() {
13761 var _this = this;
13762 this.listeners = {};
13763 var add = function(plugin22, type, cb) {
13764 if (!_this.listeners[type]) _this.listeners[type] = [];
13765 _this.listeners[type].push([
13766 plugin22,
13767 cb
13768 ]);
13769 };
13770 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
13771 var plugin22 = _step.value;
13772 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
13773 for(var event in plugin22){
13774 if (!PLUGIN_PROPS$1[event] && /^[A-Z]/.test(event)) {
13775 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
13776 }
13777 if (!NOT_VISITORS$1[event]) {
13778 if (_type_of(plugin22[event]) === "object") {
13779 for(var filter in plugin22[event]){
13780 if (filter === "*") {
13781 add(plugin22, event, plugin22[event][filter]);
13782 } else {
13783 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
13784 }
13785 }
13786 } else if (typeof plugin22[event] === "function") {
13787 add(plugin22, event, plugin22[event]);
13788 }
13789 }
13790 }
13791 }
13792 }
13793 this.hasListener = Object.keys(this.listeners).length > 0;
13794 };
13795 _proto.runAsync = function runAsync() {
13796 var _this = this;
13797 return _async_to_generator(function() {
13798 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
13799 return _ts_generator(this, function(_state) {
13800 switch(_state.label){
13801 case 0:
13802 _this.plugin = 0;
13803 i2 = 0;
13804 _state.label = 1;
13805 case 1:
13806 if (!(i2 < _this.plugins.length)) return [
13807 3,
13808 6
13809 ];
13810 plugin22 = _this.plugins[i2];
13811 promise = _this.runOnRoot(plugin22);
13812 if (!isPromise$1(promise)) return [
13813 3,
13814 5
13815 ];
13816 _state.label = 2;
13817 case 2:
13818 _state.trys.push([
13819 2,
13820 4,
13821 ,
13822 5
13823 ]);
13824 return [
13825 4,
13826 promise
13827 ];
13828 case 3:
13829 _state.sent();
13830 return [
13831 3,
13832 5
13833 ];
13834 case 4:
13835 error = _state.sent();
13836 throw _this.handleError(error);
13837 case 5:
13838 i2++;
13839 return [
13840 3,
13841 1
13842 ];
13843 case 6:
13844 _this.prepareVisitors();
13845 if (!_this.hasListener) return [
13846 3,
13847 18
13848 ];
13849 root2 = _this.result.root;
13850 _state.label = 7;
13851 case 7:
13852 if (!!root2[isClean$3]) return [
13853 3,
13854 14
13855 ];
13856 root2[isClean$3] = true;
13857 stack = [
13858 toStack$1(root2)
13859 ];
13860 _state.label = 8;
13861 case 8:
13862 if (!(stack.length > 0)) return [
13863 3,
13864 13
13865 ];
13866 promise1 = _this.visitTick(stack);
13867 if (!isPromise$1(promise1)) return [
13868 3,
13869 12
13870 ];
13871 _state.label = 9;
13872 case 9:
13873 _state.trys.push([
13874 9,
13875 11,
13876 ,
13877 12
13878 ]);
13879 return [
13880 4,
13881 promise1
13882 ];
13883 case 10:
13884 _state.sent();
13885 return [
13886 3,
13887 12
13888 ];
13889 case 11:
13890 e2 = _state.sent();
13891 node2 = stack[stack.length - 1].node;
13892 throw _this.handleError(e2, node2);
13893 case 12:
13894 return [
13895 3,
13896 8
13897 ];
13898 case 13:
13899 return [
13900 3,
13901 7
13902 ];
13903 case 14:
13904 if (!_this.listeners.OnceExit) return [
13905 3,
13906 18
13907 ];
13908 _loop = function() {
13909 var _step_value, plugin22, visitor, roots, e2;
13910 return _ts_generator(this, function(_state) {
13911 switch(_state.label){
13912 case 0:
13913 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
13914 _this.result.lastPlugin = plugin22;
13915 _state.label = 1;
13916 case 1:
13917 _state.trys.push([
13918 1,
13919 6,
13920 ,
13921 7
13922 ]);
13923 if (!(root2.type === "document")) return [
13924 3,
13925 3
13926 ];
13927 roots = root2.nodes.map(function(subRoot) {
13928 return visitor(subRoot, _this.helpers);
13929 });
13930 return [
13931 4,
13932 Promise.all(roots)
13933 ];
13934 case 2:
13935 _state.sent();
13936 return [
13937 3,
13938 5
13939 ];
13940 case 3:
13941 return [
13942 4,
13943 visitor(root2, _this.helpers)
13944 ];
13945 case 4:
13946 _state.sent();
13947 _state.label = 5;
13948 case 5:
13949 return [
13950 3,
13951 7
13952 ];
13953 case 6:
13954 e2 = _state.sent();
13955 throw _this.handleError(e2);
13956 case 7:
13957 return [
13958 2
13959 ];
13960 }
13961 });
13962 };
13963 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
13964 _state.label = 15;
13965 case 15:
13966 if (!!(_step = _iterator()).done) return [
13967 3,
13968 18
13969 ];
13970 return [
13971 5,
13972 _ts_values(_loop())
13973 ];
13974 case 16:
13975 _state.sent();
13976 _state.label = 17;
13977 case 17:
13978 return [
13979 3,
13980 15
13981 ];
13982 case 18:
13983 _this.processed = true;
13984 return [
13985 2,
13986 _this.stringify()
13987 ];
13988 }
13989 });
13990 })();
13991 };
13992 _proto.runOnRoot = function runOnRoot(plugin22) {
13993 var _this = this;
13994 this.result.lastPlugin = plugin22;
13995 try {
13996 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
13997 if (this.result.root.type === "document") {
13998 var roots = this.result.root.nodes.map(function(root2) {
13999 return plugin22.Once(root2, _this.helpers);
14000 });
14001 if (isPromise$1(roots[0])) {
14002 return Promise.all(roots);
14003 }
14004 return roots;
14005 }
14006 return plugin22.Once(this.result.root, this.helpers);
14007 } else if (typeof plugin22 === "function") {
14008 return plugin22(this.result.root, this.result);
14009 }
14010 } catch (error) {
14011 throw this.handleError(error);
14012 }
14013 };
14014 _proto.stringify = function stringify() {
14015 if (this.error) throw this.error;
14016 if (this.stringified) return this.result;
14017 this.stringified = true;
14018 this.sync();
14019 var opts = this.result.opts;
14020 var str = stringify$2$1;
14021 if (opts.syntax) str = opts.syntax.stringify;
14022 if (opts.stringifier) str = opts.stringifier;
14023 if (str.stringify) str = str.stringify;
14024 var map = new MapGenerator$1$1(str, this.result.root, this.result.opts);
14025 var data = map.generate();
14026 this.result.css = data[0];
14027 this.result.map = data[1];
14028 return this.result;
14029 };
14030 _proto.sync = function sync() {
14031 if (this.error) throw this.error;
14032 if (this.processed) return this.result;
14033 this.processed = true;
14034 if (this.processing) {
14035 throw this.getAsyncError();
14036 }
14037 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
14038 var plugin22 = _step.value;
14039 var promise = this.runOnRoot(plugin22);
14040 if (isPromise$1(promise)) {
14041 throw this.getAsyncError();
14042 }
14043 }
14044 this.prepareVisitors();
14045 if (this.hasListener) {
14046 var root2 = this.result.root;
14047 while(!root2[isClean$3]){
14048 root2[isClean$3] = true;
14049 this.walkSync(root2);
14050 }
14051 if (this.listeners.OnceExit) {
14052 if (root2.type === "document") {
14053 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
14054 var subRoot = _step1.value;
14055 this.visitSync(this.listeners.OnceExit, subRoot);
14056 }
14057 } else {
14058 this.visitSync(this.listeners.OnceExit, root2);
14059 }
14060 }
14061 }
14062 return this.result;
14063 };
14064 _proto.then = function then(onFulfilled, onRejected) {
14065 if (true) {
14066 if (!("from" in this.opts)) {
14067 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.");
14068 }
14069 }
14070 return this.async().then(onFulfilled, onRejected);
14071 };
14072 _proto.toString = function toString() {
14073 return this.css;
14074 };
14075 _proto.visitSync = function visitSync(visitors, node2) {
14076 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
14077 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
14078 this.result.lastPlugin = plugin22;
14079 var promise = void 0;
14080 try {
14081 promise = visitor(node2, this.helpers);
14082 } catch (e2) {
14083 throw this.handleError(e2, node2.proxyOf);
14084 }
14085 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14086 return true;
14087 }
14088 if (isPromise$1(promise)) {
14089 throw this.getAsyncError();
14090 }
14091 }
14092 };
14093 _proto.visitTick = function visitTick(stack) {
14094 var visit2 = stack[stack.length - 1];
14095 var node2 = visit2.node, visitors = visit2.visitors;
14096 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
14097 stack.pop();
14098 return;
14099 }
14100 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
14101 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
14102 visit2.visitorIndex += 1;
14103 if (visit2.visitorIndex === visitors.length) {
14104 visit2.visitors = [];
14105 visit2.visitorIndex = 0;
14106 }
14107 this.result.lastPlugin = plugin22;
14108 try {
14109 return visitor(node2.toProxy(), this.helpers);
14110 } catch (e2) {
14111 throw this.handleError(e2, node2);
14112 }
14113 }
14114 if (visit2.iterator !== 0) {
14115 var iterator = visit2.iterator;
14116 var child;
14117 while(child = node2.nodes[node2.indexes[iterator]]){
14118 node2.indexes[iterator] += 1;
14119 if (!child[isClean$3]) {
14120 child[isClean$3] = true;
14121 stack.push(toStack$1(child));
14122 return;
14123 }
14124 }
14125 visit2.iterator = 0;
14126 delete node2.indexes[iterator];
14127 }
14128 var events = visit2.events;
14129 while(visit2.eventIndex < events.length){
14130 var event = events[visit2.eventIndex];
14131 visit2.eventIndex += 1;
14132 if (event === CHILDREN$1) {
14133 if (node2.nodes && node2.nodes.length) {
14134 node2[isClean$3] = true;
14135 visit2.iterator = node2.getIterator();
14136 }
14137 return;
14138 } else if (this.listeners[event]) {
14139 visit2.visitors = this.listeners[event];
14140 return;
14141 }
14142 }
14143 stack.pop();
14144 };
14145 _proto.walkSync = function walkSync(node2) {
14146 var _this = this;
14147 node2[isClean$3] = true;
14148 var events = getEvents$1(node2);
14149 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
14150 var event = _step.value;
14151 if (event === CHILDREN$1) {
14152 if (node2.nodes) {
14153 node2.each(function(child) {
14154 if (!child[isClean$3]) _this.walkSync(child);
14155 });
14156 }
14157 } else {
14158 var visitors = this.listeners[event];
14159 if (visitors) {
14160 if (this.visitSync(visitors, node2.toProxy())) return;
14161 }
14162 }
14163 }
14164 };
14165 _proto.warnings = function warnings() {
14166 return this.sync().warnings();
14167 };
14168 _create_class(LazyResult, [
14169 {
14170 key: "content",
14171 get: function get() {
14172 return this.stringify().content;
14173 }
14174 },
14175 {
14176 key: "css",
14177 get: function get() {
14178 return this.stringify().css;
14179 }
14180 },
14181 {
14182 key: "map",
14183 get: function get() {
14184 return this.stringify().map;
14185 }
14186 },
14187 {
14188 key: "messages",
14189 get: function get() {
14190 return this.sync().messages;
14191 }
14192 },
14193 {
14194 key: "opts",
14195 get: function get() {
14196 return this.result.opts;
14197 }
14198 },
14199 {
14200 key: "processor",
14201 get: function get() {
14202 return this.result.processor;
14203 }
14204 },
14205 {
14206 key: "root",
14207 get: function get() {
14208 return this.sync().root;
14209 }
14210 },
14211 {
14212 key: Symbol.toStringTag,
14213 get: function get() {
14214 return "LazyResult";
14215 }
14216 }
14217 ]);
14218 return LazyResult;
14219 }();
14220 LazyResult$2$1.registerPostcss = function(dependant) {
14221 postcss$2$1 = dependant;
14222 };
14223 var lazyResult$1 = LazyResult$2$1;
14224 LazyResult$2$1.default = LazyResult$2$1;
14225 Root$3$1.registerLazyResult(LazyResult$2$1);
14226 Document$2$1.registerLazyResult(LazyResult$2$1);
14227 var MapGenerator2$1 = mapGenerator$1;
14228 var stringify$1$1 = stringify_1$1;
14229 var warnOnce2$1 = warnOnce$2$1;
14230 var parse$1$1 = parse_1$1;
14231 var Result$1$1 = result$1;
14232 var NoWorkResult$1$1 = /*#__PURE__*/ function() {
14233 function NoWorkResult(processor2, css, opts) {
14234 css = css.toString();
14235 this.stringified = false;
14236 this._processor = processor2;
14237 this._css = css;
14238 this._opts = opts;
14239 this._map = void 0;
14240 var root2;
14241 var str = stringify$1$1;
14242 this.result = new Result$1$1(this._processor, root2, this._opts);
14243 this.result.css = css;
14244 var self = this;
14245 Object.defineProperty(this.result, "root", {
14246 get: function get() {
14247 return self.root;
14248 }
14249 });
14250 var map = new MapGenerator2$1(str, root2, this._opts, css);
14251 if (map.isMap()) {
14252 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
14253 if (generatedCSS) {
14254 this.result.css = generatedCSS;
14255 }
14256 if (generatedMap) {
14257 this.result.map = generatedMap;
14258 }
14259 } else {
14260 map.clearAnnotation();
14261 this.result.css = map.css;
14262 }
14263 }
14264 var _proto = NoWorkResult.prototype;
14265 _proto.async = function async() {
14266 if (this.error) return Promise.reject(this.error);
14267 return Promise.resolve(this.result);
14268 };
14269 _proto.catch = function _catch(onRejected) {
14270 return this.async().catch(onRejected);
14271 };
14272 _proto.finally = function _finally(onFinally) {
14273 return this.async().then(onFinally, onFinally);
14274 };
14275 _proto.sync = function sync() {
14276 if (this.error) throw this.error;
14277 return this.result;
14278 };
14279 _proto.then = function then(onFulfilled, onRejected) {
14280 if (true) {
14281 if (!("from" in this._opts)) {
14282 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.");
14283 }
14284 }
14285 return this.async().then(onFulfilled, onRejected);
14286 };
14287 _proto.toString = function toString() {
14288 return this._css;
14289 };
14290 _proto.warnings = function warnings() {
14291 return [];
14292 };
14293 _create_class(NoWorkResult, [
14294 {
14295 key: "content",
14296 get: function get() {
14297 return this.result.css;
14298 }
14299 },
14300 {
14301 key: "css",
14302 get: function get() {
14303 return this.result.css;
14304 }
14305 },
14306 {
14307 key: "map",
14308 get: function get() {
14309 return this.result.map;
14310 }
14311 },
14312 {
14313 key: "messages",
14314 get: function get() {
14315 return [];
14316 }
14317 },
14318 {
14319 key: "opts",
14320 get: function get() {
14321 return this.result.opts;
14322 }
14323 },
14324 {
14325 key: "processor",
14326 get: function get() {
14327 return this.result.processor;
14328 }
14329 },
14330 {
14331 key: "root",
14332 get: function get() {
14333 if (this._root) {
14334 return this._root;
14335 }
14336 var root2;
14337 var parser2 = parse$1$1;
14338 try {
14339 root2 = parser2(this._css, this._opts);
14340 } catch (error) {
14341 this.error = error;
14342 }
14343 if (this.error) {
14344 throw this.error;
14345 } else {
14346 this._root = root2;
14347 return root2;
14348 }
14349 }
14350 },
14351 {
14352 key: Symbol.toStringTag,
14353 get: function get() {
14354 return "NoWorkResult";
14355 }
14356 }
14357 ]);
14358 return NoWorkResult;
14359 }();
14360 var noWorkResult$1 = NoWorkResult$1$1;
14361 NoWorkResult$1$1.default = NoWorkResult$1$1;
14362 var NoWorkResult2$1 = noWorkResult$1;
14363 var LazyResult$1$1 = lazyResult$1;
14364 var Document$1$1 = document$1$1;
14365 var Root$2$1 = root$1;
14366 var Processor$1$1 = /*#__PURE__*/ function() {
14367 function Processor(plugins) {
14368 if (plugins === void 0) plugins = [];
14369 this.version = "8.4.38";
14370 this.plugins = this.normalize(plugins);
14371 }
14372 var _proto = Processor.prototype;
14373 _proto.normalize = function normalize(plugins) {
14374 var normalized = [];
14375 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
14376 var i2 = _step.value;
14377 if (i2.postcss === true) {
14378 i2 = i2();
14379 } else if (i2.postcss) {
14380 i2 = i2.postcss;
14381 }
14382 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
14383 normalized = normalized.concat(i2.plugins);
14384 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
14385 normalized.push(i2);
14386 } else if (typeof i2 === "function") {
14387 normalized.push(i2);
14388 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
14389 if (true) {
14390 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.");
14391 }
14392 } else {
14393 throw new Error(i2 + " is not a PostCSS plugin");
14394 }
14395 }
14396 return normalized;
14397 };
14398 _proto.process = function process1(css, opts) {
14399 if (opts === void 0) opts = {};
14400 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
14401 return new NoWorkResult2$1(this, css, opts);
14402 } else {
14403 return new LazyResult$1$1(this, css, opts);
14404 }
14405 };
14406 _proto.use = function use(plugin22) {
14407 this.plugins = this.plugins.concat(this.normalize([
14408 plugin22
14409 ]));
14410 return this;
14411 };
14412 return Processor;
14413 }();
14414 var processor$1 = Processor$1$1;
14415 Processor$1$1.default = Processor$1$1;
14416 Root$2$1.registerProcessor(Processor$1$1);
14417 Document$1$1.registerProcessor(Processor$1$1);
14418 var Declaration$1$1 = declaration$1;
14419 var PreviousMap2$1 = previousMap$1;
14420 var Comment$1$1 = comment$1;
14421 var AtRule$1$1 = atRule$1;
14422 var Input$1$1 = input$1;
14423 var Root$1$1 = root$1;
14424 var Rule$1$1 = rule$1;
14425 function fromJSON$1$1(json, inputs) {
14426 if (Array.isArray(json)) return json.map(function(n2) {
14427 return fromJSON$1$1(n2);
14428 });
14429 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
14430 "inputs"
14431 ]);
14432 if (ownInputs) {
14433 inputs = [];
14434 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
14435 var input2 = _step.value;
14436 var inputHydrated = _extends({}, input2, {
14437 __proto__: Input$1$1.prototype
14438 });
14439 if (inputHydrated.map) {
14440 inputHydrated.map = _extends({}, inputHydrated.map, {
14441 __proto__: PreviousMap2$1.prototype
14442 });
14443 }
14444 inputs.push(inputHydrated);
14445 }
14446 }
14447 if (defaults.nodes) {
14448 defaults.nodes = json.nodes.map(function(n2) {
14449 return fromJSON$1$1(n2, inputs);
14450 });
14451 }
14452 if (defaults.source) {
14453 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
14454 "inputId"
14455 ]);
14456 defaults.source = source;
14457 if (inputId != null) {
14458 defaults.source.input = inputs[inputId];
14459 }
14460 }
14461 if (defaults.type === "root") {
14462 return new Root$1$1(defaults);
14463 } else if (defaults.type === "decl") {
14464 return new Declaration$1$1(defaults);
14465 } else if (defaults.type === "rule") {
14466 return new Rule$1$1(defaults);
14467 } else if (defaults.type === "comment") {
14468 return new Comment$1$1(defaults);
14469 } else if (defaults.type === "atrule") {
14470 return new AtRule$1$1(defaults);
14471 } else {
14472 throw new Error("Unknown node type: " + json.type);
14473 }
14474 }
14475 var fromJSON_1$1 = fromJSON$1$1;
14476 fromJSON$1$1.default = fromJSON$1$1;
14477 var CssSyntaxError2$1 = cssSyntaxError$1;
14478 var Declaration2$1 = declaration$1;
14479 var LazyResult2$1 = lazyResult$1;
14480 var Container2$1 = container$1;
14481 var Processor2$1 = processor$1;
14482 var stringify$5 = stringify_1$1;
14483 var fromJSON$2 = fromJSON_1$1;
14484 var Document22 = document$1$1;
14485 var Warning2$1 = warning$1;
14486 var Comment2$1 = comment$1;
14487 var AtRule2$1 = atRule$1;
14488 var Result2$1 = result$1;
14489 var Input2$1 = input$1;
14490 var parse$5 = parse_1$1;
14491 var list$3 = list_1$1;
14492 var Rule2$1 = rule$1;
14493 var Root2$1 = root$1;
14494 var Node2$1 = node$1;
14495 function postcss$3() {
14496 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
14497 plugins[_key] = arguments[_key];
14498 }
14499 if (plugins.length === 1 && Array.isArray(plugins[0])) {
14500 plugins = plugins[0];
14501 }
14502 return new Processor2$1(plugins);
14503 }
14504 postcss$3.plugin = function plugin(name, initializer) {
14505 var warningPrinted = false;
14506 function creator() {
14507 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14508 args[_key] = arguments[_key];
14509 }
14510 if (console && console.warn && !warningPrinted) {
14511 warningPrinted = true;
14512 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
14513 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
14514 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
14515 }
14516 }
14517 var transformer = initializer.apply(void 0, [].concat(args));
14518 transformer.postcssPlugin = name;
14519 transformer.postcssVersion = new Processor2$1().version;
14520 return transformer;
14521 }
14522 var cache;
14523 Object.defineProperty(creator, "postcss", {
14524 get: function get() {
14525 if (!cache) cache = creator();
14526 return cache;
14527 }
14528 });
14529 creator.process = function(css, processOpts, pluginOpts) {
14530 return postcss$3([
14531 creator(pluginOpts)
14532 ]).process(css, processOpts);
14533 };
14534 return creator;
14535 };
14536 postcss$3.stringify = stringify$5;
14537 postcss$3.parse = parse$5;
14538 postcss$3.fromJSON = fromJSON$2;
14539 postcss$3.list = list$3;
14540 postcss$3.comment = function(defaults) {
14541 return new Comment2$1(defaults);
14542 };
14543 postcss$3.atRule = function(defaults) {
14544 return new AtRule2$1(defaults);
14545 };
14546 postcss$3.decl = function(defaults) {
14547 return new Declaration2$1(defaults);
14548 };
14549 postcss$3.rule = function(defaults) {
14550 return new Rule2$1(defaults);
14551 };
14552 postcss$3.root = function(defaults) {
14553 return new Root2$1(defaults);
14554 };
14555 postcss$3.document = function(defaults) {
14556 return new Document22(defaults);
14557 };
14558 postcss$3.CssSyntaxError = CssSyntaxError2$1;
14559 postcss$3.Declaration = Declaration2$1;
14560 postcss$3.Container = Container2$1;
14561 postcss$3.Processor = Processor2$1;
14562 postcss$3.Document = Document22;
14563 postcss$3.Comment = Comment2$1;
14564 postcss$3.Warning = Warning2$1;
14565 postcss$3.AtRule = AtRule2$1;
14566 postcss$3.Result = Result2$1;
14567 postcss$3.Input = Input2$1;
14568 postcss$3.Rule = Rule2$1;
14569 postcss$3.Root = Root2$1;
14570 postcss$3.Node = Node2$1;
14571 LazyResult2$1.registerPostcss(postcss$3);
14572 var postcss_1$1 = postcss$3;
14573 postcss$3.default = postcss$3;
14574 var postcss$1$1 = /* @__PURE__ */ getDefaultExportFromCjs$1(postcss_1$1);
14575 postcss$1$1.stringify;
14576 postcss$1$1.fromJSON;
14577 postcss$1$1.plugin;
14578 postcss$1$1.parse;
14579 postcss$1$1.list;
14580 postcss$1$1.document;
14581 postcss$1$1.comment;
14582 postcss$1$1.atRule;
14583 postcss$1$1.rule;
14584 postcss$1$1.decl;
14585 postcss$1$1.root;
14586 postcss$1$1.CssSyntaxError;
14587 postcss$1$1.Declaration;
14588 postcss$1$1.Container;
14589 postcss$1$1.Processor;
14590 postcss$1$1.Document;
14591 postcss$1$1.Comment;
14592 postcss$1$1.Warning;
14593 postcss$1$1.AtRule;
14594 postcss$1$1.Result;
14595 postcss$1$1.Input;
14596 postcss$1$1.Rule;
14597 postcss$1$1.Root;
14598 postcss$1$1.Node;
14599 var __defProp2 = Object.defineProperty;
14600 var __defNormalProp2 = function(obj, key, value) {
14601 return key in obj ? __defProp2(obj, key, {
14602 enumerable: true,
14603 configurable: true,
14604 writable: true,
14605 value: value
14606 }) : obj[key] = value;
14607 };
14608 var __publicField2 = function(obj, key, value) {
14609 return __defNormalProp2(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
14610 };
14611 function getDefaultExportFromCjs(x2) {
14612 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
14613 }
14614 function getAugmentedNamespace(n2) {
14615 if (n2.__esModule) return n2;
14616 var f2 = n2.default;
14617 if (typeof f2 == "function") {
14618 var a2 = function a22() {
14619 if (_instanceof(this, a22)) {
14620 return Reflect.construct(f2, arguments, this.constructor);
14621 }
14622 return f2.apply(this, arguments);
14623 };
14624 a2.prototype = f2.prototype;
14625 } else a2 = {};
14626 Object.defineProperty(a2, "__esModule", {
14627 value: true
14628 });
14629 Object.keys(n2).forEach(function(k) {
14630 var d = Object.getOwnPropertyDescriptor(n2, k);
14631 Object.defineProperty(a2, k, d.get ? d : {
14632 enumerable: true,
14633 get: function get() {
14634 return n2[k];
14635 }
14636 });
14637 });
14638 return a2;
14639 }
14640 var picocolors_browser = {
14641 exports: {}
14642 };
14643 var x = String;
14644 var create = function create() {
14645 return {
14646 isColorSupported: false,
14647 reset: x,
14648 bold: x,
14649 dim: x,
14650 italic: x,
14651 underline: x,
14652 inverse: x,
14653 hidden: x,
14654 strikethrough: x,
14655 black: x,
14656 red: x,
14657 green: x,
14658 yellow: x,
14659 blue: x,
14660 magenta: x,
14661 cyan: x,
14662 white: x,
14663 gray: x,
14664 bgBlack: x,
14665 bgRed: x,
14666 bgGreen: x,
14667 bgYellow: x,
14668 bgBlue: x,
14669 bgMagenta: x,
14670 bgCyan: x,
14671 bgWhite: x
14672 };
14673 };
14674 picocolors_browser.exports = create();
14675 picocolors_browser.exports.createColors = create;
14676 var picocolors_browserExports = picocolors_browser.exports;
14677 var __viteBrowserExternal = {};
14678 var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14679 __proto__: null,
14680 default: __viteBrowserExternal
14681 }, Symbol.toStringTag, {
14682 value: "Module"
14683 }));
14684 var require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
14685 var pico = picocolors_browserExports;
14686 var terminalHighlight$1 = require$$2;
14687 var CssSyntaxError$3 = /*#__PURE__*/ function(Error1) {
14688 _inherits(CssSyntaxError2, Error1);
14689 function CssSyntaxError2(message, line, column, source, file, plugin22) {
14690 var _this;
14691 _this = Error1.call(this, message) || this;
14692 _this.name = "CssSyntaxError";
14693 _this.reason = message;
14694 if (file) {
14695 _this.file = file;
14696 }
14697 if (source) {
14698 _this.source = source;
14699 }
14700 if (plugin22) {
14701 _this.plugin = plugin22;
14702 }
14703 if (typeof line !== "undefined" && typeof column !== "undefined") {
14704 if (typeof line === "number") {
14705 _this.line = line;
14706 _this.column = column;
14707 } else {
14708 _this.line = line.line;
14709 _this.column = line.column;
14710 _this.endLine = column.line;
14711 _this.endColumn = column.column;
14712 }
14713 }
14714 _this.setMessage();
14715 if (Error.captureStackTrace) {
14716 Error.captureStackTrace(_this, CssSyntaxError2);
14717 }
14718 return _this;
14719 }
14720 var _proto = CssSyntaxError2.prototype;
14721 _proto.setMessage = function setMessage() {
14722 this.message = this.plugin ? this.plugin + ": " : "";
14723 this.message += this.file ? this.file : "<css input>";
14724 if (typeof this.line !== "undefined") {
14725 this.message += ":" + this.line + ":" + this.column;
14726 }
14727 this.message += ": " + this.reason;
14728 };
14729 _proto.showSourceCode = function showSourceCode(color) {
14730 var _this = this;
14731 if (!this.source) return "";
14732 var css = this.source;
14733 if (color == null) color = pico.isColorSupported;
14734 if (terminalHighlight$1) {
14735 if (color) css = terminalHighlight$1(css);
14736 }
14737 var lines = css.split(/\r?\n/);
14738 var start = Math.max(this.line - 3, 0);
14739 var end = Math.min(this.line + 2, lines.length);
14740 var maxWidth = String(end).length;
14741 var mark, aside;
14742 if (color) {
14743 var _pico_createColors = pico.createColors(true), bold = _pico_createColors.bold, gray = _pico_createColors.gray, red = _pico_createColors.red;
14744 mark = function(text) {
14745 return bold(red(text));
14746 };
14747 aside = function(text) {
14748 return gray(text);
14749 };
14750 } else {
14751 mark = aside = function(str) {
14752 return str;
14753 };
14754 }
14755 return lines.slice(start, end).map(function(line, index2) {
14756 var number = start + 1 + index2;
14757 var gutter = " " + (" " + number).slice(-maxWidth) + " | ";
14758 if (number === _this.line) {
14759 var spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, _this.column - 1).replace(/[^\t]/g, " ");
14760 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^");
14761 }
14762 return " " + aside(gutter) + line;
14763 }).join("\n");
14764 };
14765 _proto.toString = function toString() {
14766 var code = this.showSourceCode();
14767 if (code) {
14768 code = "\n\n" + code + "\n";
14769 }
14770 return this.name + ": " + this.message + code;
14771 };
14772 return CssSyntaxError2;
14773 }(_wrap_native_super(Error));
14774 var cssSyntaxError = CssSyntaxError$3;
14775 CssSyntaxError$3.default = CssSyntaxError$3;
14776 var symbols = {};
14777 symbols.isClean = Symbol("isClean");
14778 symbols.my = Symbol("my");
14779 var DEFAULT_RAW = {
14780 after: "\n",
14781 beforeClose: "\n",
14782 beforeComment: "\n",
14783 beforeDecl: "\n",
14784 beforeOpen: " ",
14785 beforeRule: "\n",
14786 colon: ": ",
14787 commentLeft: " ",
14788 commentRight: " ",
14789 emptyBody: "",
14790 indent: " ",
14791 semicolon: false
14792 };
14793 function capitalize(str) {
14794 return str[0].toUpperCase() + str.slice(1);
14795 }
14796 var Stringifier$2 = /*#__PURE__*/ function() {
14797 function Stringifier2(builder) {
14798 this.builder = builder;
14799 }
14800 var _proto = Stringifier2.prototype;
14801 _proto.atrule = function atrule(node2, semicolon) {
14802 var name = "@" + node2.name;
14803 var params = node2.params ? this.rawValue(node2, "params") : "";
14804 if (typeof node2.raws.afterName !== "undefined") {
14805 name += node2.raws.afterName;
14806 } else if (params) {
14807 name += " ";
14808 }
14809 if (node2.nodes) {
14810 this.block(node2, name + params);
14811 } else {
14812 var end = (node2.raws.between || "") + (semicolon ? ";" : "");
14813 this.builder(name + params + end, node2);
14814 }
14815 };
14816 _proto.beforeAfter = function beforeAfter(node2, detect) {
14817 var value;
14818 if (node2.type === "decl") {
14819 value = this.raw(node2, null, "beforeDecl");
14820 } else if (node2.type === "comment") {
14821 value = this.raw(node2, null, "beforeComment");
14822 } else if (detect === "before") {
14823 value = this.raw(node2, null, "beforeRule");
14824 } else {
14825 value = this.raw(node2, null, "beforeClose");
14826 }
14827 var buf = node2.parent;
14828 var depth = 0;
14829 while(buf && buf.type !== "root"){
14830 depth += 1;
14831 buf = buf.parent;
14832 }
14833 if (value.includes("\n")) {
14834 var indent = this.raw(node2, null, "indent");
14835 if (indent.length) {
14836 for(var step = 0; step < depth; step++)value += indent;
14837 }
14838 }
14839 return value;
14840 };
14841 _proto.block = function block(node2, start) {
14842 var between = this.raw(node2, "between", "beforeOpen");
14843 this.builder(start + between + "{", node2, "start");
14844 var after;
14845 if (node2.nodes && node2.nodes.length) {
14846 this.body(node2);
14847 after = this.raw(node2, "after");
14848 } else {
14849 after = this.raw(node2, "after", "emptyBody");
14850 }
14851 if (after) this.builder(after);
14852 this.builder("}", node2, "end");
14853 };
14854 _proto.body = function body(node2) {
14855 var last = node2.nodes.length - 1;
14856 while(last > 0){
14857 if (node2.nodes[last].type !== "comment") break;
14858 last -= 1;
14859 }
14860 var semicolon = this.raw(node2, "semicolon");
14861 for(var i2 = 0; i2 < node2.nodes.length; i2++){
14862 var child = node2.nodes[i2];
14863 var before = this.raw(child, "before");
14864 if (before) this.builder(before);
14865 this.stringify(child, last !== i2 || semicolon);
14866 }
14867 };
14868 _proto.comment = function comment(node2) {
14869 var left = this.raw(node2, "left", "commentLeft");
14870 var right = this.raw(node2, "right", "commentRight");
14871 this.builder("/*" + left + node2.text + right + "*/", node2);
14872 };
14873 _proto.decl = function decl(node2, semicolon) {
14874 var between = this.raw(node2, "between", "colon");
14875 var string = node2.prop + between + this.rawValue(node2, "value");
14876 if (node2.important) {
14877 string += node2.raws.important || " !important";
14878 }
14879 if (semicolon) string += ";";
14880 this.builder(string, node2);
14881 };
14882 _proto.document = function document1(node2) {
14883 this.body(node2);
14884 };
14885 _proto.raw = function raw(node2, own, detect) {
14886 var value;
14887 if (!detect) detect = own;
14888 if (own) {
14889 value = node2.raws[own];
14890 if (typeof value !== "undefined") return value;
14891 }
14892 var parent = node2.parent;
14893 if (detect === "before") {
14894 if (!parent || parent.type === "root" && parent.first === node2) {
14895 return "";
14896 }
14897 if (parent && parent.type === "document") {
14898 return "";
14899 }
14900 }
14901 if (!parent) return DEFAULT_RAW[detect];
14902 var root2 = node2.root();
14903 if (!root2.rawCache) root2.rawCache = {};
14904 if (typeof root2.rawCache[detect] !== "undefined") {
14905 return root2.rawCache[detect];
14906 }
14907 if (detect === "before" || detect === "after") {
14908 return this.beforeAfter(node2, detect);
14909 } else {
14910 var method = "raw" + capitalize(detect);
14911 if (this[method]) {
14912 value = this[method](root2, node2);
14913 } else {
14914 root2.walk(function(i2) {
14915 value = i2.raws[own];
14916 if (typeof value !== "undefined") return false;
14917 });
14918 }
14919 }
14920 if (typeof value === "undefined") value = DEFAULT_RAW[detect];
14921 root2.rawCache[detect] = value;
14922 return value;
14923 };
14924 _proto.rawBeforeClose = function rawBeforeClose(root2) {
14925 var value;
14926 root2.walk(function(i2) {
14927 if (i2.nodes && i2.nodes.length > 0) {
14928 if (typeof i2.raws.after !== "undefined") {
14929 value = i2.raws.after;
14930 if (value.includes("\n")) {
14931 value = value.replace(/[^\n]+$/, "");
14932 }
14933 return false;
14934 }
14935 }
14936 });
14937 if (value) value = value.replace(/\S/g, "");
14938 return value;
14939 };
14940 _proto.rawBeforeComment = function rawBeforeComment(root2, node2) {
14941 var value;
14942 root2.walkComments(function(i2) {
14943 if (typeof i2.raws.before !== "undefined") {
14944 value = i2.raws.before;
14945 if (value.includes("\n")) {
14946 value = value.replace(/[^\n]+$/, "");
14947 }
14948 return false;
14949 }
14950 });
14951 if (typeof value === "undefined") {
14952 value = this.raw(node2, null, "beforeDecl");
14953 } else if (value) {
14954 value = value.replace(/\S/g, "");
14955 }
14956 return value;
14957 };
14958 _proto.rawBeforeDecl = function rawBeforeDecl(root2, node2) {
14959 var value;
14960 root2.walkDecls(function(i2) {
14961 if (typeof i2.raws.before !== "undefined") {
14962 value = i2.raws.before;
14963 if (value.includes("\n")) {
14964 value = value.replace(/[^\n]+$/, "");
14965 }
14966 return false;
14967 }
14968 });
14969 if (typeof value === "undefined") {
14970 value = this.raw(node2, null, "beforeRule");
14971 } else if (value) {
14972 value = value.replace(/\S/g, "");
14973 }
14974 return value;
14975 };
14976 _proto.rawBeforeOpen = function rawBeforeOpen(root2) {
14977 var value;
14978 root2.walk(function(i2) {
14979 if (i2.type !== "decl") {
14980 value = i2.raws.between;
14981 if (typeof value !== "undefined") return false;
14982 }
14983 });
14984 return value;
14985 };
14986 _proto.rawBeforeRule = function rawBeforeRule(root2) {
14987 var value;
14988 root2.walk(function(i2) {
14989 if (i2.nodes && (i2.parent !== root2 || root2.first !== i2)) {
14990 if (typeof i2.raws.before !== "undefined") {
14991 value = i2.raws.before;
14992 if (value.includes("\n")) {
14993 value = value.replace(/[^\n]+$/, "");
14994 }
14995 return false;
14996 }
14997 }
14998 });
14999 if (value) value = value.replace(/\S/g, "");
15000 return value;
15001 };
15002 _proto.rawColon = function rawColon(root2) {
15003 var value;
15004 root2.walkDecls(function(i2) {
15005 if (typeof i2.raws.between !== "undefined") {
15006 value = i2.raws.between.replace(/[^\s:]/g, "");
15007 return false;
15008 }
15009 });
15010 return value;
15011 };
15012 _proto.rawEmptyBody = function rawEmptyBody(root2) {
15013 var value;
15014 root2.walk(function(i2) {
15015 if (i2.nodes && i2.nodes.length === 0) {
15016 value = i2.raws.after;
15017 if (typeof value !== "undefined") return false;
15018 }
15019 });
15020 return value;
15021 };
15022 _proto.rawIndent = function rawIndent(root2) {
15023 if (root2.raws.indent) return root2.raws.indent;
15024 var value;
15025 root2.walk(function(i2) {
15026 var p = i2.parent;
15027 if (p && p !== root2 && p.parent && p.parent === root2) {
15028 if (typeof i2.raws.before !== "undefined") {
15029 var parts = i2.raws.before.split("\n");
15030 value = parts[parts.length - 1];
15031 value = value.replace(/\S/g, "");
15032 return false;
15033 }
15034 }
15035 });
15036 return value;
15037 };
15038 _proto.rawSemicolon = function rawSemicolon(root2) {
15039 var value;
15040 root2.walk(function(i2) {
15041 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") {
15042 value = i2.raws.semicolon;
15043 if (typeof value !== "undefined") return false;
15044 }
15045 });
15046 return value;
15047 };
15048 _proto.rawValue = function rawValue(node2, prop) {
15049 var value = node2[prop];
15050 var raw = node2.raws[prop];
15051 if (raw && raw.value === value) {
15052 return raw.raw;
15053 }
15054 return value;
15055 };
15056 _proto.root = function root(node2) {
15057 this.body(node2);
15058 if (node2.raws.after) this.builder(node2.raws.after);
15059 };
15060 _proto.rule = function rule(node2) {
15061 this.block(node2, this.rawValue(node2, "selector"));
15062 if (node2.raws.ownSemicolon) {
15063 this.builder(node2.raws.ownSemicolon, node2, "end");
15064 }
15065 };
15066 _proto.stringify = function stringify(node2, semicolon) {
15067 if (!this[node2.type]) {
15068 throw new Error("Unknown AST node type " + node2.type + ". Maybe you need to change PostCSS stringifier.");
15069 }
15070 this[node2.type](node2, semicolon);
15071 };
15072 return Stringifier2;
15073 }();
15074 var stringifier = Stringifier$2;
15075 Stringifier$2.default = Stringifier$2;
15076 var Stringifier$1 = stringifier;
15077 function stringify$4(node2, builder) {
15078 var str = new Stringifier$1(builder);
15079 str.stringify(node2);
15080 }
15081 var stringify_1 = stringify$4;
15082 stringify$4.default = stringify$4;
15083 var isClean$2 = symbols.isClean, my$2 = symbols.my;
15084 var CssSyntaxError$2 = cssSyntaxError;
15085 var Stringifier22 = stringifier;
15086 var stringify$3 = stringify_1;
15087 function cloneNode(obj, parent) {
15088 var cloned = new obj.constructor();
15089 for(var i2 in obj){
15090 if (!Object.prototype.hasOwnProperty.call(obj, i2)) {
15091 continue;
15092 }
15093 if (i2 === "proxyCache") continue;
15094 var value = obj[i2];
15095 var type = typeof value === "undefined" ? "undefined" : _type_of(value);
15096 if (i2 === "parent" && type === "object") {
15097 if (parent) cloned[i2] = parent;
15098 } else if (i2 === "source") {
15099 cloned[i2] = value;
15100 } else if (Array.isArray(value)) {
15101 cloned[i2] = value.map(function(j) {
15102 return cloneNode(j, cloned);
15103 });
15104 } else {
15105 if (type === "object" && value !== null) value = cloneNode(value);
15106 cloned[i2] = value;
15107 }
15108 }
15109 return cloned;
15110 }
15111 var Node$4 = /*#__PURE__*/ function() {
15112 function Node3(defaults) {
15113 if (defaults === void 0) defaults = {};
15114 this.raws = {};
15115 this[isClean$2] = false;
15116 this[my$2] = true;
15117 for(var name in defaults){
15118 if (name === "nodes") {
15119 this.nodes = [];
15120 for(var _iterator = _create_for_of_iterator_helper_loose(defaults[name]), _step; !(_step = _iterator()).done;){
15121 var node2 = _step.value;
15122 if (typeof node2.clone === "function") {
15123 this.append(node2.clone());
15124 } else {
15125 this.append(node2);
15126 }
15127 }
15128 } else {
15129 this[name] = defaults[name];
15130 }
15131 }
15132 }
15133 var _proto = Node3.prototype;
15134 _proto.addToError = function addToError(error) {
15135 error.postcssNode = this;
15136 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) {
15137 var s2 = this.source;
15138 error.stack = error.stack.replace(/\n\s{4}at /, "$&" + s2.input.from + ":" + s2.start.line + ":" + s2.start.column + "$&");
15139 }
15140 return error;
15141 };
15142 _proto.after = function after(add) {
15143 this.parent.insertAfter(this, add);
15144 return this;
15145 };
15146 _proto.assign = function assign(overrides) {
15147 if (overrides === void 0) overrides = {};
15148 for(var name in overrides){
15149 this[name] = overrides[name];
15150 }
15151 return this;
15152 };
15153 _proto.before = function before(add) {
15154 this.parent.insertBefore(this, add);
15155 return this;
15156 };
15157 _proto.cleanRaws = function cleanRaws(keepBetween) {
15158 delete this.raws.before;
15159 delete this.raws.after;
15160 if (!keepBetween) delete this.raws.between;
15161 };
15162 _proto.clone = function clone(overrides) {
15163 if (overrides === void 0) overrides = {};
15164 var cloned = cloneNode(this);
15165 for(var name in overrides){
15166 cloned[name] = overrides[name];
15167 }
15168 return cloned;
15169 };
15170 _proto.cloneAfter = function cloneAfter(overrides) {
15171 if (overrides === void 0) overrides = {};
15172 var cloned = this.clone(overrides);
15173 this.parent.insertAfter(this, cloned);
15174 return cloned;
15175 };
15176 _proto.cloneBefore = function cloneBefore(overrides) {
15177 if (overrides === void 0) overrides = {};
15178 var cloned = this.clone(overrides);
15179 this.parent.insertBefore(this, cloned);
15180 return cloned;
15181 };
15182 _proto.error = function error(message, opts) {
15183 if (opts === void 0) opts = {};
15184 if (this.source) {
15185 var _this_rangeBy = this.rangeBy(opts), end = _this_rangeBy.end, start = _this_rangeBy.start;
15186 return this.source.input.error(message, {
15187 column: start.column,
15188 line: start.line
15189 }, {
15190 column: end.column,
15191 line: end.line
15192 }, opts);
15193 }
15194 return new CssSyntaxError$2(message);
15195 };
15196 _proto.getProxyProcessor = function getProxyProcessor() {
15197 return {
15198 get: function get(node2, prop) {
15199 if (prop === "proxyOf") {
15200 return node2;
15201 } else if (prop === "root") {
15202 return function() {
15203 return node2.root().toProxy();
15204 };
15205 } else {
15206 return node2[prop];
15207 }
15208 },
15209 set: function set(node2, prop, value) {
15210 if (node2[prop] === value) return true;
15211 node2[prop] = value;
15212 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ prop === "text") {
15213 node2.markDirty();
15214 }
15215 return true;
15216 }
15217 };
15218 };
15219 _proto.markDirty = function markDirty() {
15220 if (this[isClean$2]) {
15221 this[isClean$2] = false;
15222 var next = this;
15223 while(next = next.parent){
15224 next[isClean$2] = false;
15225 }
15226 }
15227 };
15228 _proto.next = function next() {
15229 if (!this.parent) return void 0;
15230 var index2 = this.parent.index(this);
15231 return this.parent.nodes[index2 + 1];
15232 };
15233 _proto.positionBy = function positionBy(opts, stringRepresentation) {
15234 var pos = this.source.start;
15235 if (opts.index) {
15236 pos = this.positionInside(opts.index, stringRepresentation);
15237 } else if (opts.word) {
15238 stringRepresentation = this.toString();
15239 var index2 = stringRepresentation.indexOf(opts.word);
15240 if (index2 !== -1) pos = this.positionInside(index2, stringRepresentation);
15241 }
15242 return pos;
15243 };
15244 _proto.positionInside = function positionInside(index2, stringRepresentation) {
15245 var string = stringRepresentation || this.toString();
15246 var column = this.source.start.column;
15247 var line = this.source.start.line;
15248 for(var i2 = 0; i2 < index2; i2++){
15249 if (string[i2] === "\n") {
15250 column = 1;
15251 line += 1;
15252 } else {
15253 column += 1;
15254 }
15255 }
15256 return {
15257 column: column,
15258 line: line
15259 };
15260 };
15261 _proto.prev = function prev() {
15262 if (!this.parent) return void 0;
15263 var index2 = this.parent.index(this);
15264 return this.parent.nodes[index2 - 1];
15265 };
15266 _proto.rangeBy = function rangeBy(opts) {
15267 var start = {
15268 column: this.source.start.column,
15269 line: this.source.start.line
15270 };
15271 var end = this.source.end ? {
15272 column: this.source.end.column + 1,
15273 line: this.source.end.line
15274 } : {
15275 column: start.column + 1,
15276 line: start.line
15277 };
15278 if (opts.word) {
15279 var stringRepresentation = this.toString();
15280 var index2 = stringRepresentation.indexOf(opts.word);
15281 if (index2 !== -1) {
15282 start = this.positionInside(index2, stringRepresentation);
15283 end = this.positionInside(index2 + opts.word.length, stringRepresentation);
15284 }
15285 } else {
15286 if (opts.start) {
15287 start = {
15288 column: opts.start.column,
15289 line: opts.start.line
15290 };
15291 } else if (opts.index) {
15292 start = this.positionInside(opts.index);
15293 }
15294 if (opts.end) {
15295 end = {
15296 column: opts.end.column,
15297 line: opts.end.line
15298 };
15299 } else if (typeof opts.endIndex === "number") {
15300 end = this.positionInside(opts.endIndex);
15301 } else if (opts.index) {
15302 end = this.positionInside(opts.index + 1);
15303 }
15304 }
15305 if (end.line < start.line || end.line === start.line && end.column <= start.column) {
15306 end = {
15307 column: start.column + 1,
15308 line: start.line
15309 };
15310 }
15311 return {
15312 end: end,
15313 start: start
15314 };
15315 };
15316 _proto.raw = function raw(prop, defaultType) {
15317 var str = new Stringifier22();
15318 return str.raw(this, prop, defaultType);
15319 };
15320 _proto.remove = function remove() {
15321 if (this.parent) {
15322 this.parent.removeChild(this);
15323 }
15324 this.parent = void 0;
15325 return this;
15326 };
15327 _proto.replaceWith = function replaceWith() {
15328 for(var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++){
15329 nodes[_key] = arguments[_key];
15330 }
15331 if (this.parent) {
15332 var bookmark = this;
15333 var foundSelf = false;
15334 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
15335 var node2 = _step.value;
15336 if (node2 === this) {
15337 foundSelf = true;
15338 } else if (foundSelf) {
15339 this.parent.insertAfter(bookmark, node2);
15340 bookmark = node2;
15341 } else {
15342 this.parent.insertBefore(bookmark, node2);
15343 }
15344 }
15345 if (!foundSelf) {
15346 this.remove();
15347 }
15348 }
15349 return this;
15350 };
15351 _proto.root = function root() {
15352 var result2 = this;
15353 while(result2.parent && result2.parent.type !== "document"){
15354 result2 = result2.parent;
15355 }
15356 return result2;
15357 };
15358 _proto.toJSON = function toJSON(_, inputs) {
15359 var fixed = {};
15360 var emitInputs = inputs == null;
15361 inputs = inputs || /* @__PURE__ */ new Map();
15362 var inputsNextIndex = 0;
15363 for(var name in this){
15364 if (!Object.prototype.hasOwnProperty.call(this, name)) {
15365 continue;
15366 }
15367 if (name === "parent" || name === "proxyCache") continue;
15368 var value = this[name];
15369 if (Array.isArray(value)) {
15370 fixed[name] = value.map(function(i2) {
15371 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.toJSON) {
15372 return i2.toJSON(null, inputs);
15373 } else {
15374 return i2;
15375 }
15376 });
15377 } else if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value.toJSON) {
15378 fixed[name] = value.toJSON(null, inputs);
15379 } else if (name === "source") {
15380 var inputId = inputs.get(value.input);
15381 if (inputId == null) {
15382 inputId = inputsNextIndex;
15383 inputs.set(value.input, inputsNextIndex);
15384 inputsNextIndex++;
15385 }
15386 fixed[name] = {
15387 end: value.end,
15388 inputId: inputId,
15389 start: value.start
15390 };
15391 } else {
15392 fixed[name] = value;
15393 }
15394 }
15395 if (emitInputs) {
15396 fixed.inputs = [].concat(inputs.keys()).map(function(input2) {
15397 return input2.toJSON();
15398 });
15399 }
15400 return fixed;
15401 };
15402 _proto.toProxy = function toProxy() {
15403 if (!this.proxyCache) {
15404 this.proxyCache = new Proxy(this, this.getProxyProcessor());
15405 }
15406 return this.proxyCache;
15407 };
15408 _proto.toString = function toString(stringifier2) {
15409 if (stringifier2 === void 0) stringifier2 = stringify$3;
15410 if (stringifier2.stringify) stringifier2 = stringifier2.stringify;
15411 var result2 = "";
15412 stringifier2(this, function(i2) {
15413 result2 += i2;
15414 });
15415 return result2;
15416 };
15417 _proto.warn = function warn(result2, text, opts) {
15418 var data = {
15419 node: this
15420 };
15421 for(var i2 in opts)data[i2] = opts[i2];
15422 return result2.warn(text, data);
15423 };
15424 _create_class(Node3, [
15425 {
15426 key: "proxyOf",
15427 get: function get() {
15428 return this;
15429 }
15430 }
15431 ]);
15432 return Node3;
15433 }();
15434 var node = Node$4;
15435 Node$4.default = Node$4;
15436 var Node$3 = node;
15437 var Declaration$4 = /*#__PURE__*/ function(Node$3) {
15438 _inherits(Declaration2, Node$3);
15439 function Declaration2(defaults) {
15440 var _this;
15441 if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
15442 defaults = _extends({}, defaults, {
15443 value: String(defaults.value)
15444 });
15445 }
15446 _this = Node$3.call(this, defaults) || this;
15447 _this.type = "decl";
15448 return _this;
15449 }
15450 _create_class(Declaration2, [
15451 {
15452 key: "variable",
15453 get: function get() {
15454 return this.prop.startsWith("--") || this.prop[0] === "$";
15455 }
15456 }
15457 ]);
15458 return Declaration2;
15459 }(Node$3);
15460 var declaration = Declaration$4;
15461 Declaration$4.default = Declaration$4;
15462 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
15463 var nanoid$1 = function(size) {
15464 if (size === void 0) size = 21;
15465 var id = "";
15466 var i2 = size;
15467 while(i2--){
15468 id += urlAlphabet[Math.random() * 64 | 0];
15469 }
15470 return id;
15471 };
15472 var nonSecure = {
15473 nanoid: nanoid$1};
15474 var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
15475 var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
15476 var dirname$1 = require$$2.dirname, join = require$$2.join;
15477 function fromBase64(str) {
15478 if (Buffer) {
15479 return Buffer.from(str, "base64").toString();
15480 } else {
15481 return window.atob(str);
15482 }
15483 }
15484 var PreviousMap$2 = /*#__PURE__*/ function() {
15485 function PreviousMap2(css, opts) {
15486 if (opts.map === false) return;
15487 this.loadAnnotation(css);
15488 this.inline = this.startWith(this.annotation, "data:");
15489 var prev = opts.map ? opts.map.prev : void 0;
15490 var text = this.loadMap(opts.from, prev);
15491 if (!this.mapFile && opts.from) {
15492 this.mapFile = opts.from;
15493 }
15494 if (this.mapFile) this.root = dirname$1(this.mapFile);
15495 if (text) this.text = text;
15496 }
15497 var _proto = PreviousMap2.prototype;
15498 _proto.consumer = function consumer() {
15499 if (!this.consumerCache) {
15500 this.consumerCache = new SourceMapConsumer$2(this.text);
15501 }
15502 return this.consumerCache;
15503 };
15504 _proto.decodeInline = function decodeInline(text) {
15505 var baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
15506 var baseUri = /^data:application\/json;base64,/;
15507 var charsetUri = /^data:application\/json;charset=utf-?8,/;
15508 var uri = /^data:application\/json,/;
15509 if (charsetUri.test(text) || uri.test(text)) {
15510 return decodeURIComponent(text.substr(RegExp.lastMatch.length));
15511 }
15512 if (baseCharsetUri.test(text) || baseUri.test(text)) {
15513 return fromBase64(text.substr(RegExp.lastMatch.length));
15514 }
15515 var encoding = text.match(/data:application\/json;([^,]+),/)[1];
15516 throw new Error("Unsupported source map encoding " + encoding);
15517 };
15518 _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) {
15519 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim();
15520 };
15521 _proto.isMap = function isMap(map) {
15522 if ((typeof map === "undefined" ? "undefined" : _type_of(map)) !== "object") return false;
15523 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections);
15524 };
15525 _proto.loadAnnotation = function loadAnnotation(css) {
15526 var comments = css.match(/\/\*\s*# sourceMappingURL=/gm);
15527 if (!comments) return;
15528 var start = css.lastIndexOf(comments.pop());
15529 var end = css.indexOf("*/", start);
15530 if (start > -1 && end > -1) {
15531 this.annotation = this.getAnnotationURL(css.substring(start, end));
15532 }
15533 };
15534 _proto.loadFile = function loadFile(path) {
15535 this.root = dirname$1(path);
15536 if (existsSync(path)) {
15537 this.mapFile = path;
15538 return readFileSync(path, "utf-8").toString().trim();
15539 }
15540 };
15541 _proto.loadMap = function loadMap(file, prev) {
15542 if (prev === false) return false;
15543 if (prev) {
15544 if (typeof prev === "string") {
15545 return prev;
15546 } else if (typeof prev === "function") {
15547 var prevPath = prev(file);
15548 if (prevPath) {
15549 var map = this.loadFile(prevPath);
15550 if (!map) {
15551 throw new Error("Unable to load previous source map: " + prevPath.toString());
15552 }
15553 return map;
15554 }
15555 } else if (_instanceof(prev, SourceMapConsumer$2)) {
15556 return SourceMapGenerator$2.fromSourceMap(prev).toString();
15557 } else if (_instanceof(prev, SourceMapGenerator$2)) {
15558 return prev.toString();
15559 } else if (this.isMap(prev)) {
15560 return JSON.stringify(prev);
15561 } else {
15562 throw new Error("Unsupported previous source map format: " + prev.toString());
15563 }
15564 } else if (this.inline) {
15565 return this.decodeInline(this.annotation);
15566 } else if (this.annotation) {
15567 var map1 = this.annotation;
15568 if (file) map1 = join(dirname$1(file), map1);
15569 return this.loadFile(map1);
15570 }
15571 };
15572 _proto.startWith = function startWith(string, start) {
15573 if (!string) return false;
15574 return string.substr(0, start.length) === start;
15575 };
15576 _proto.withContent = function withContent() {
15577 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0);
15578 };
15579 return PreviousMap2;
15580 }();
15581 var previousMap = PreviousMap$2;
15582 PreviousMap$2.default = PreviousMap$2;
15583 var SourceMapConsumer$1 = require$$2.SourceMapConsumer, SourceMapGenerator$1 = require$$2.SourceMapGenerator;
15584 var fileURLToPath = require$$2.fileURLToPath, pathToFileURL$1 = require$$2.pathToFileURL;
15585 var isAbsolute = require$$2.isAbsolute, resolve$1 = require$$2.resolve;
15586 var nanoid = nonSecure.nanoid;
15587 var terminalHighlight = require$$2;
15588 var CssSyntaxError$1 = cssSyntaxError;
15589 var PreviousMap$1 = previousMap;
15590 var fromOffsetCache = Symbol("fromOffsetCache");
15591 var sourceMapAvailable$1 = Boolean(SourceMapConsumer$1 && SourceMapGenerator$1);
15592 var pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
15593 var Input$4 = /*#__PURE__*/ function() {
15594 function Input2(css, opts) {
15595 if (opts === void 0) opts = {};
15596 if (css === null || typeof css === "undefined" || (typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && !css.toString) {
15597 throw new Error("PostCSS received " + css + " instead of CSS string");
15598 }
15599 this.css = css.toString();
15600 if (this.css[0] === "\uFEFF" || this.css[0] === "￾") {
15601 this.hasBOM = true;
15602 this.css = this.css.slice(1);
15603 } else {
15604 this.hasBOM = false;
15605 }
15606 if (opts.from) {
15607 if (!pathAvailable$1 || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) {
15608 this.file = opts.from;
15609 } else {
15610 this.file = resolve$1(opts.from);
15611 }
15612 }
15613 if (pathAvailable$1 && sourceMapAvailable$1) {
15614 var map = new PreviousMap$1(this.css, opts);
15615 if (map.text) {
15616 this.map = map;
15617 var file = map.consumer().file;
15618 if (!this.file && file) this.file = this.mapResolve(file);
15619 }
15620 }
15621 if (!this.file) {
15622 this.id = "<input css " + nanoid(6) + ">";
15623 }
15624 if (this.map) this.map.file = this.from;
15625 }
15626 var _proto = Input2.prototype;
15627 _proto.error = function error(message, line, column, opts) {
15628 if (opts === void 0) opts = {};
15629 var result2, endLine, endColumn;
15630 if (line && (typeof line === "undefined" ? "undefined" : _type_of(line)) === "object") {
15631 var start = line;
15632 var end = column;
15633 if (typeof start.offset === "number") {
15634 var pos = this.fromOffset(start.offset);
15635 line = pos.line;
15636 column = pos.col;
15637 } else {
15638 line = start.line;
15639 column = start.column;
15640 }
15641 if (typeof end.offset === "number") {
15642 var pos1 = this.fromOffset(end.offset);
15643 endLine = pos1.line;
15644 endColumn = pos1.col;
15645 } else {
15646 endLine = end.line;
15647 endColumn = end.column;
15648 }
15649 } else if (!column) {
15650 var pos2 = this.fromOffset(line);
15651 line = pos2.line;
15652 column = pos2.col;
15653 }
15654 var origin = this.origin(line, column, endLine, endColumn);
15655 if (origin) {
15656 result2 = new CssSyntaxError$1(message, origin.endLine === void 0 ? origin.line : {
15657 column: origin.column,
15658 line: origin.line
15659 }, origin.endLine === void 0 ? origin.column : {
15660 column: origin.endColumn,
15661 line: origin.endLine
15662 }, origin.source, origin.file, opts.plugin);
15663 } else {
15664 result2 = new CssSyntaxError$1(message, endLine === void 0 ? line : {
15665 column: column,
15666 line: line
15667 }, endLine === void 0 ? column : {
15668 column: endColumn,
15669 line: endLine
15670 }, this.css, this.file, opts.plugin);
15671 }
15672 result2.input = {
15673 column: column,
15674 endColumn: endColumn,
15675 endLine: endLine,
15676 line: line,
15677 source: this.css
15678 };
15679 if (this.file) {
15680 if (pathToFileURL$1) {
15681 result2.input.url = pathToFileURL$1(this.file).toString();
15682 }
15683 result2.input.file = this.file;
15684 }
15685 return result2;
15686 };
15687 _proto.fromOffset = function fromOffset(offset) {
15688 var lastLine, lineToIndex;
15689 if (!this[fromOffsetCache]) {
15690 var lines = this.css.split("\n");
15691 lineToIndex = new Array(lines.length);
15692 var prevIndex = 0;
15693 for(var i2 = 0, l2 = lines.length; i2 < l2; i2++){
15694 lineToIndex[i2] = prevIndex;
15695 prevIndex += lines[i2].length + 1;
15696 }
15697 this[fromOffsetCache] = lineToIndex;
15698 } else {
15699 lineToIndex = this[fromOffsetCache];
15700 }
15701 lastLine = lineToIndex[lineToIndex.length - 1];
15702 var min = 0;
15703 if (offset >= lastLine) {
15704 min = lineToIndex.length - 1;
15705 } else {
15706 var max = lineToIndex.length - 2;
15707 var mid;
15708 while(min < max){
15709 mid = min + (max - min >> 1);
15710 if (offset < lineToIndex[mid]) {
15711 max = mid - 1;
15712 } else if (offset >= lineToIndex[mid + 1]) {
15713 min = mid + 1;
15714 } else {
15715 min = mid;
15716 break;
15717 }
15718 }
15719 }
15720 return {
15721 col: offset - lineToIndex[min] + 1,
15722 line: min + 1
15723 };
15724 };
15725 _proto.mapResolve = function mapResolve(file) {
15726 if (/^\w+:\/\//.test(file)) {
15727 return file;
15728 }
15729 return resolve$1(this.map.consumer().sourceRoot || this.map.root || ".", file);
15730 };
15731 _proto.origin = function origin(line, column, endLine, endColumn) {
15732 if (!this.map) return false;
15733 var consumer = this.map.consumer();
15734 var from = consumer.originalPositionFor({
15735 column: column,
15736 line: line
15737 });
15738 if (!from.source) return false;
15739 var to;
15740 if (typeof endLine === "number") {
15741 to = consumer.originalPositionFor({
15742 column: endColumn,
15743 line: endLine
15744 });
15745 }
15746 var fromUrl;
15747 if (isAbsolute(from.source)) {
15748 fromUrl = pathToFileURL$1(from.source);
15749 } else {
15750 fromUrl = new URL(from.source, this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile));
15751 }
15752 var result2 = {
15753 column: from.column,
15754 endColumn: to && to.column,
15755 endLine: to && to.line,
15756 line: from.line,
15757 url: fromUrl.toString()
15758 };
15759 if (fromUrl.protocol === "file:") {
15760 if (fileURLToPath) {
15761 result2.file = fileURLToPath(fromUrl);
15762 } else {
15763 throw new Error("file: protocol is not available in this PostCSS build");
15764 }
15765 }
15766 var source = consumer.sourceContentFor(from.source);
15767 if (source) result2.source = source;
15768 return result2;
15769 };
15770 _proto.toJSON = function toJSON() {
15771 var json = {};
15772 for(var _i = 0, _iter = [
15773 "hasBOM",
15774 "css",
15775 "file",
15776 "id"
15777 ]; _i < _iter.length; _i++){
15778 var name = _iter[_i];
15779 if (this[name] != null) {
15780 json[name] = this[name];
15781 }
15782 }
15783 if (this.map) {
15784 json.map = _extends({}, this.map);
15785 if (json.map.consumerCache) {
15786 json.map.consumerCache = void 0;
15787 }
15788 }
15789 return json;
15790 };
15791 _create_class(Input2, [
15792 {
15793 key: "from",
15794 get: function get() {
15795 return this.file || this.id;
15796 }
15797 }
15798 ]);
15799 return Input2;
15800 }();
15801 var input = Input$4;
15802 Input$4.default = Input$4;
15803 if (terminalHighlight && terminalHighlight.registerInput) {
15804 terminalHighlight.registerInput(Input$4);
15805 }
15806 var SourceMapConsumer = require$$2.SourceMapConsumer, SourceMapGenerator = require$$2.SourceMapGenerator;
15807 var dirname = require$$2.dirname, relative = require$$2.relative, resolve$3 = require$$2.resolve, sep = require$$2.sep;
15808 var pathToFileURL = require$$2.pathToFileURL;
15809 var Input$3 = input;
15810 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
15811 var pathAvailable = Boolean(dirname && resolve$3 && relative && sep);
15812 var MapGenerator$2 = /*#__PURE__*/ function() {
15813 function MapGenerator2(stringify2, root2, opts, cssString) {
15814 this.stringify = stringify2;
15815 this.mapOpts = opts.map || {};
15816 this.root = root2;
15817 this.opts = opts;
15818 this.css = cssString;
15819 this.originalCSS = cssString;
15820 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
15821 this.memoizedFileURLs = /* @__PURE__ */ new Map();
15822 this.memoizedPaths = /* @__PURE__ */ new Map();
15823 this.memoizedURLs = /* @__PURE__ */ new Map();
15824 }
15825 var _proto = MapGenerator2.prototype;
15826 _proto.addAnnotation = function addAnnotation() {
15827 var content;
15828 if (this.isInline()) {
15829 content = "data:application/json;base64," + this.toBase64(this.map.toString());
15830 } else if (typeof this.mapOpts.annotation === "string") {
15831 content = this.mapOpts.annotation;
15832 } else if (typeof this.mapOpts.annotation === "function") {
15833 content = this.mapOpts.annotation(this.opts.to, this.root);
15834 } else {
15835 content = this.outputFile() + ".map";
15836 }
15837 var eol = "\n";
15838 if (this.css.includes("\r\n")) eol = "\r\n";
15839 this.css += eol + "/*# sourceMappingURL=" + content + " */";
15840 };
15841 _proto.applyPrevMaps = function applyPrevMaps() {
15842 for(var _iterator = _create_for_of_iterator_helper_loose(this.previous()), _step; !(_step = _iterator()).done;){
15843 var prev = _step.value;
15844 var from = this.toUrl(this.path(prev.file));
15845 var root2 = prev.root || dirname(prev.file);
15846 var map = void 0;
15847 if (this.mapOpts.sourcesContent === false) {
15848 map = new SourceMapConsumer(prev.text);
15849 if (map.sourcesContent) {
15850 map.sourcesContent = null;
15851 }
15852 } else {
15853 map = prev.consumer();
15854 }
15855 this.map.applySourceMap(map, from, this.toUrl(this.path(root2)));
15856 }
15857 };
15858 _proto.clearAnnotation = function clearAnnotation() {
15859 if (this.mapOpts.annotation === false) return;
15860 if (this.root) {
15861 var node2;
15862 for(var i2 = this.root.nodes.length - 1; i2 >= 0; i2--){
15863 node2 = this.root.nodes[i2];
15864 if (node2.type !== "comment") continue;
15865 if (node2.text.indexOf("# sourceMappingURL=") === 0) {
15866 this.root.removeChild(i2);
15867 }
15868 }
15869 } else if (this.css) {
15870 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, "");
15871 }
15872 };
15873 _proto.generate = function generate() {
15874 this.clearAnnotation();
15875 if (pathAvailable && sourceMapAvailable && this.isMap()) {
15876 return this.generateMap();
15877 } else {
15878 var result2 = "";
15879 this.stringify(this.root, function(i2) {
15880 result2 += i2;
15881 });
15882 return [
15883 result2
15884 ];
15885 }
15886 };
15887 _proto.generateMap = function generateMap() {
15888 if (this.root) {
15889 this.generateString();
15890 } else if (this.previous().length === 1) {
15891 var prev = this.previous()[0].consumer();
15892 prev.file = this.outputFile();
15893 this.map = SourceMapGenerator.fromSourceMap(prev, {
15894 ignoreInvalidMapping: true
15895 });
15896 } else {
15897 this.map = new SourceMapGenerator({
15898 file: this.outputFile(),
15899 ignoreInvalidMapping: true
15900 });
15901 this.map.addMapping({
15902 generated: {
15903 column: 0,
15904 line: 1
15905 },
15906 original: {
15907 column: 0,
15908 line: 1
15909 },
15910 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"
15911 });
15912 }
15913 if (this.isSourcesContent()) this.setSourcesContent();
15914 if (this.root && this.previous().length > 0) this.applyPrevMaps();
15915 if (this.isAnnotation()) this.addAnnotation();
15916 if (this.isInline()) {
15917 return [
15918 this.css
15919 ];
15920 } else {
15921 return [
15922 this.css,
15923 this.map
15924 ];
15925 }
15926 };
15927 _proto.generateString = function generateString() {
15928 var _this = this;
15929 this.css = "";
15930 this.map = new SourceMapGenerator({
15931 file: this.outputFile(),
15932 ignoreInvalidMapping: true
15933 });
15934 var line = 1;
15935 var column = 1;
15936 var noSource = "<no source>";
15937 var mapping = {
15938 generated: {
15939 column: 0,
15940 line: 0
15941 },
15942 original: {
15943 column: 0,
15944 line: 0
15945 },
15946 source: ""
15947 };
15948 var lines, last;
15949 this.stringify(this.root, function(str, node2, type) {
15950 _this.css += str;
15951 if (node2 && type !== "end") {
15952 mapping.generated.line = line;
15953 mapping.generated.column = column - 1;
15954 if (node2.source && node2.source.start) {
15955 mapping.source = _this.sourcePath(node2);
15956 mapping.original.line = node2.source.start.line;
15957 mapping.original.column = node2.source.start.column - 1;
15958 _this.map.addMapping(mapping);
15959 } else {
15960 mapping.source = noSource;
15961 mapping.original.line = 1;
15962 mapping.original.column = 0;
15963 _this.map.addMapping(mapping);
15964 }
15965 }
15966 lines = str.match(/\n/g);
15967 if (lines) {
15968 line += lines.length;
15969 last = str.lastIndexOf("\n");
15970 column = str.length - last;
15971 } else {
15972 column += str.length;
15973 }
15974 if (node2 && type !== "start") {
15975 var p = node2.parent || {
15976 raws: {}
15977 };
15978 var childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
15979 if (!childless || node2 !== p.last || p.raws.semicolon) {
15980 if (node2.source && node2.source.end) {
15981 mapping.source = _this.sourcePath(node2);
15982 mapping.original.line = node2.source.end.line;
15983 mapping.original.column = node2.source.end.column - 1;
15984 mapping.generated.line = line;
15985 mapping.generated.column = column - 2;
15986 _this.map.addMapping(mapping);
15987 } else {
15988 mapping.source = noSource;
15989 mapping.original.line = 1;
15990 mapping.original.column = 0;
15991 mapping.generated.line = line;
15992 mapping.generated.column = column - 1;
15993 _this.map.addMapping(mapping);
15994 }
15995 }
15996 }
15997 });
15998 };
15999 _proto.isAnnotation = function isAnnotation() {
16000 if (this.isInline()) {
16001 return true;
16002 }
16003 if (typeof this.mapOpts.annotation !== "undefined") {
16004 return this.mapOpts.annotation;
16005 }
16006 if (this.previous().length) {
16007 return this.previous().some(function(i2) {
16008 return i2.annotation;
16009 });
16010 }
16011 return true;
16012 };
16013 _proto.isInline = function isInline() {
16014 if (typeof this.mapOpts.inline !== "undefined") {
16015 return this.mapOpts.inline;
16016 }
16017 var annotation = this.mapOpts.annotation;
16018 if (typeof annotation !== "undefined" && annotation !== true) {
16019 return false;
16020 }
16021 if (this.previous().length) {
16022 return this.previous().some(function(i2) {
16023 return i2.inline;
16024 });
16025 }
16026 return true;
16027 };
16028 _proto.isMap = function isMap() {
16029 if (typeof this.opts.map !== "undefined") {
16030 return !!this.opts.map;
16031 }
16032 return this.previous().length > 0;
16033 };
16034 _proto.isSourcesContent = function isSourcesContent() {
16035 if (typeof this.mapOpts.sourcesContent !== "undefined") {
16036 return this.mapOpts.sourcesContent;
16037 }
16038 if (this.previous().length) {
16039 return this.previous().some(function(i2) {
16040 return i2.withContent();
16041 });
16042 }
16043 return true;
16044 };
16045 _proto.outputFile = function outputFile() {
16046 if (this.opts.to) {
16047 return this.path(this.opts.to);
16048 } else if (this.opts.from) {
16049 return this.path(this.opts.from);
16050 } else {
16051 return "to.css";
16052 }
16053 };
16054 _proto.path = function path(file) {
16055 if (this.mapOpts.absolute) return file;
16056 if (file.charCodeAt(0) === 60) return file;
16057 if (/^\w+:\/\//.test(file)) return file;
16058 var cached = this.memoizedPaths.get(file);
16059 if (cached) return cached;
16060 var from = this.opts.to ? dirname(this.opts.to) : ".";
16061 if (typeof this.mapOpts.annotation === "string") {
16062 from = dirname(resolve$3(from, this.mapOpts.annotation));
16063 }
16064 var path = relative(from, file);
16065 this.memoizedPaths.set(file, path);
16066 return path;
16067 };
16068 _proto.previous = function previous() {
16069 var _this = this;
16070 if (!this.previousMaps) {
16071 this.previousMaps = [];
16072 if (this.root) {
16073 this.root.walk(function(node2) {
16074 if (node2.source && node2.source.input.map) {
16075 var map = node2.source.input.map;
16076 if (!_this.previousMaps.includes(map)) {
16077 _this.previousMaps.push(map);
16078 }
16079 }
16080 });
16081 } else {
16082 var input2 = new Input$3(this.originalCSS, this.opts);
16083 if (input2.map) this.previousMaps.push(input2.map);
16084 }
16085 }
16086 return this.previousMaps;
16087 };
16088 _proto.setSourcesContent = function setSourcesContent() {
16089 var _this = this;
16090 var already = {};
16091 if (this.root) {
16092 this.root.walk(function(node2) {
16093 if (node2.source) {
16094 var from = node2.source.input.from;
16095 if (from && !already[from]) {
16096 already[from] = true;
16097 var fromUrl = _this.usesFileUrls ? _this.toFileUrl(from) : _this.toUrl(_this.path(from));
16098 _this.map.setSourceContent(fromUrl, node2.source.input.css);
16099 }
16100 }
16101 });
16102 } else if (this.css) {
16103 var from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>";
16104 this.map.setSourceContent(from, this.css);
16105 }
16106 };
16107 _proto.sourcePath = function sourcePath(node2) {
16108 if (this.mapOpts.from) {
16109 return this.toUrl(this.mapOpts.from);
16110 } else if (this.usesFileUrls) {
16111 return this.toFileUrl(node2.source.input.from);
16112 } else {
16113 return this.toUrl(this.path(node2.source.input.from));
16114 }
16115 };
16116 _proto.toBase64 = function toBase64(str) {
16117 if (Buffer) {
16118 return Buffer.from(str).toString("base64");
16119 } else {
16120 return window.btoa(unescape(encodeURIComponent(str)));
16121 }
16122 };
16123 _proto.toFileUrl = function toFileUrl(path) {
16124 var cached = this.memoizedFileURLs.get(path);
16125 if (cached) return cached;
16126 if (pathToFileURL) {
16127 var fileURL = pathToFileURL(path).toString();
16128 this.memoizedFileURLs.set(path, fileURL);
16129 return fileURL;
16130 } else {
16131 throw new Error("`map.absolute` option is not available in this PostCSS build");
16132 }
16133 };
16134 _proto.toUrl = function toUrl(path) {
16135 var cached = this.memoizedURLs.get(path);
16136 if (cached) return cached;
16137 if (sep === "\\") {
16138 path = path.replace(/\\/g, "/");
16139 }
16140 var url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
16141 this.memoizedURLs.set(path, url);
16142 return url;
16143 };
16144 return MapGenerator2;
16145 }();
16146 var mapGenerator = MapGenerator$2;
16147 var Node$2 = node;
16148 var Comment$4 = /*#__PURE__*/ function(Node$2) {
16149 _inherits(Comment2, Node$2);
16150 function Comment2(defaults) {
16151 var _this;
16152 _this = Node$2.call(this, defaults) || this;
16153 _this.type = "comment";
16154 return _this;
16155 }
16156 return Comment2;
16157 }(Node$2);
16158 var comment = Comment$4;
16159 Comment$4.default = Comment$4;
16160 var isClean$1 = symbols.isClean, my$1 = symbols.my;
16161 var Declaration$3 = declaration;
16162 var Comment$3 = comment;
16163 var Node$1 = node;
16164 var parse$4, Rule$4, AtRule$4, Root$6;
16165 function cleanSource(nodes) {
16166 return nodes.map(function(i2) {
16167 if (i2.nodes) i2.nodes = cleanSource(i2.nodes);
16168 delete i2.source;
16169 return i2;
16170 });
16171 }
16172 function markDirtyUp(node2) {
16173 node2[isClean$1] = false;
16174 if (node2.proxyOf.nodes) {
16175 for(var _iterator = _create_for_of_iterator_helper_loose(node2.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16176 var i2 = _step.value;
16177 markDirtyUp(i2);
16178 }
16179 }
16180 }
16181 var Container$7 = /*#__PURE__*/ function(Node$1) {
16182 _inherits(Container2, Node$1);
16183 function Container2() {
16184 return Node$1.apply(this, arguments) || this;
16185 }
16186 var _proto = Container2.prototype;
16187 _proto.append = function append() {
16188 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16189 children[_key] = arguments[_key];
16190 }
16191 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16192 var child = _step.value;
16193 var nodes = this.normalize(child, this.last);
16194 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16195 var node2 = _step1.value;
16196 this.proxyOf.nodes.push(node2);
16197 }
16198 }
16199 this.markDirty();
16200 return this;
16201 };
16202 _proto.cleanRaws = function cleanRaws(keepBetween) {
16203 Node$1.prototype.cleanRaws.call(this, keepBetween);
16204 if (this.nodes) {
16205 for(var _iterator = _create_for_of_iterator_helper_loose(this.nodes), _step; !(_step = _iterator()).done;){
16206 var node2 = _step.value;
16207 node2.cleanRaws(keepBetween);
16208 }
16209 }
16210 };
16211 _proto.each = function each(callback) {
16212 if (!this.proxyOf.nodes) return void 0;
16213 var iterator = this.getIterator();
16214 var index2, result2;
16215 while(this.indexes[iterator] < this.proxyOf.nodes.length){
16216 index2 = this.indexes[iterator];
16217 result2 = callback(this.proxyOf.nodes[index2], index2);
16218 if (result2 === false) break;
16219 this.indexes[iterator] += 1;
16220 }
16221 delete this.indexes[iterator];
16222 return result2;
16223 };
16224 _proto.every = function every(condition) {
16225 return this.nodes.every(condition);
16226 };
16227 _proto.getIterator = function getIterator() {
16228 if (!this.lastEach) this.lastEach = 0;
16229 if (!this.indexes) this.indexes = {};
16230 this.lastEach += 1;
16231 var iterator = this.lastEach;
16232 this.indexes[iterator] = 0;
16233 return iterator;
16234 };
16235 _proto.getProxyProcessor = function getProxyProcessor() {
16236 return {
16237 get: function get(node2, prop) {
16238 if (prop === "proxyOf") {
16239 return node2;
16240 } else if (!node2[prop]) {
16241 return node2[prop];
16242 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) {
16243 return function() {
16244 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
16245 args[_key] = arguments[_key];
16246 }
16247 var _node2;
16248 return (_node2 = node2)[prop].apply(_node2, [].concat(args.map(function(i2) {
16249 if (typeof i2 === "function") {
16250 return function(child, index2) {
16251 return i2(child.toProxy(), index2);
16252 };
16253 } else {
16254 return i2;
16255 }
16256 })));
16257 };
16258 } else if (prop === "every" || prop === "some") {
16259 return function(cb) {
16260 return node2[prop](function(child) {
16261 for(var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
16262 other[_key - 1] = arguments[_key];
16263 }
16264 return cb.apply(void 0, [].concat([
16265 child.toProxy()
16266 ], other));
16267 });
16268 };
16269 } else if (prop === "root") {
16270 return function() {
16271 return node2.root().toProxy();
16272 };
16273 } else if (prop === "nodes") {
16274 return node2.nodes.map(function(i2) {
16275 return i2.toProxy();
16276 });
16277 } else if (prop === "first" || prop === "last") {
16278 return node2[prop].toProxy();
16279 } else {
16280 return node2[prop];
16281 }
16282 },
16283 set: function set(node2, prop, value) {
16284 if (node2[prop] === value) return true;
16285 node2[prop] = value;
16286 if (prop === "name" || prop === "params" || prop === "selector") {
16287 node2.markDirty();
16288 }
16289 return true;
16290 }
16291 };
16292 };
16293 _proto.index = function index(child) {
16294 if (typeof child === "number") return child;
16295 if (child.proxyOf) child = child.proxyOf;
16296 return this.proxyOf.nodes.indexOf(child);
16297 };
16298 _proto.insertAfter = function insertAfter(exist, add) {
16299 var existIndex = this.index(exist);
16300 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
16301 existIndex = this.index(exist);
16302 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16303 var node2 = _step.value;
16304 this.proxyOf.nodes.splice(existIndex + 1, 0, node2);
16305 }
16306 var index2;
16307 for(var id in this.indexes){
16308 index2 = this.indexes[id];
16309 if (existIndex < index2) {
16310 this.indexes[id] = index2 + nodes.length;
16311 }
16312 }
16313 this.markDirty();
16314 return this;
16315 };
16316 _proto.insertBefore = function insertBefore(exist, add) {
16317 var existIndex = this.index(exist);
16318 var type = existIndex === 0 ? "prepend" : false;
16319 var nodes = this.normalize(add, this.proxyOf.nodes[existIndex], type).reverse();
16320 existIndex = this.index(exist);
16321 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16322 var node2 = _step.value;
16323 this.proxyOf.nodes.splice(existIndex, 0, node2);
16324 }
16325 var index2;
16326 for(var id in this.indexes){
16327 index2 = this.indexes[id];
16328 if (existIndex <= index2) {
16329 this.indexes[id] = index2 + nodes.length;
16330 }
16331 }
16332 this.markDirty();
16333 return this;
16334 };
16335 _proto.normalize = function normalize(nodes, sample) {
16336 var _this = this;
16337 if (typeof nodes === "string") {
16338 nodes = cleanSource(parse$4(nodes).nodes);
16339 } else if (typeof nodes === "undefined") {
16340 nodes = [];
16341 } else if (Array.isArray(nodes)) {
16342 nodes = nodes.slice(0);
16343 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
16344 var i2 = _step.value;
16345 if (i2.parent) i2.parent.removeChild(i2, "ignore");
16346 }
16347 } else if (nodes.type === "root" && this.type !== "document") {
16348 nodes = nodes.nodes.slice(0);
16349 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16350 var i21 = _step1.value;
16351 if (i21.parent) i21.parent.removeChild(i21, "ignore");
16352 }
16353 } else if (nodes.type) {
16354 nodes = [
16355 nodes
16356 ];
16357 } else if (nodes.prop) {
16358 if (typeof nodes.value === "undefined") {
16359 throw new Error("Value field is missed in node creation");
16360 } else if (typeof nodes.value !== "string") {
16361 nodes.value = String(nodes.value);
16362 }
16363 nodes = [
16364 new Declaration$3(nodes)
16365 ];
16366 } else if (nodes.selector) {
16367 nodes = [
16368 new Rule$4(nodes)
16369 ];
16370 } else if (nodes.name) {
16371 nodes = [
16372 new AtRule$4(nodes)
16373 ];
16374 } else if (nodes.text) {
16375 nodes = [
16376 new Comment$3(nodes)
16377 ];
16378 } else {
16379 throw new Error("Unknown node type in node creation");
16380 }
16381 var processed = nodes.map(function(i2) {
16382 if (!i2[my$1]) Container2.rebuild(i2);
16383 i2 = i2.proxyOf;
16384 if (i2.parent) i2.parent.removeChild(i2);
16385 if (i2[isClean$1]) markDirtyUp(i2);
16386 if (typeof i2.raws.before === "undefined") {
16387 if (sample && typeof sample.raws.before !== "undefined") {
16388 i2.raws.before = sample.raws.before.replace(/\S/g, "");
16389 }
16390 }
16391 i2.parent = _this.proxyOf;
16392 return i2;
16393 });
16394 return processed;
16395 };
16396 _proto.prepend = function prepend() {
16397 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16398 children[_key] = arguments[_key];
16399 }
16400 children = children.reverse();
16401 for(var _iterator = _create_for_of_iterator_helper_loose(children), _step; !(_step = _iterator()).done;){
16402 var child = _step.value;
16403 var nodes = this.normalize(child, this.first, "prepend").reverse();
16404 for(var _iterator1 = _create_for_of_iterator_helper_loose(nodes), _step1; !(_step1 = _iterator1()).done;){
16405 var node2 = _step1.value;
16406 this.proxyOf.nodes.unshift(node2);
16407 }
16408 for(var id in this.indexes){
16409 this.indexes[id] = this.indexes[id] + nodes.length;
16410 }
16411 }
16412 this.markDirty();
16413 return this;
16414 };
16415 _proto.push = function push(child) {
16416 child.parent = this;
16417 this.proxyOf.nodes.push(child);
16418 return this;
16419 };
16420 _proto.removeAll = function removeAll() {
16421 for(var _iterator = _create_for_of_iterator_helper_loose(this.proxyOf.nodes), _step; !(_step = _iterator()).done;){
16422 var node2 = _step.value;
16423 node2.parent = void 0;
16424 }
16425 this.proxyOf.nodes = [];
16426 this.markDirty();
16427 return this;
16428 };
16429 _proto.removeChild = function removeChild(child) {
16430 child = this.index(child);
16431 this.proxyOf.nodes[child].parent = void 0;
16432 this.proxyOf.nodes.splice(child, 1);
16433 var index2;
16434 for(var id in this.indexes){
16435 index2 = this.indexes[id];
16436 if (index2 >= child) {
16437 this.indexes[id] = index2 - 1;
16438 }
16439 }
16440 this.markDirty();
16441 return this;
16442 };
16443 _proto.replaceValues = function replaceValues(pattern, opts, callback) {
16444 if (!callback) {
16445 callback = opts;
16446 opts = {};
16447 }
16448 this.walkDecls(function(decl) {
16449 if (opts.props && !opts.props.includes(decl.prop)) return;
16450 if (opts.fast && !decl.value.includes(opts.fast)) return;
16451 decl.value = decl.value.replace(pattern, callback);
16452 });
16453 this.markDirty();
16454 return this;
16455 };
16456 _proto.some = function some(condition) {
16457 return this.nodes.some(condition);
16458 };
16459 _proto.walk = function walk(callback) {
16460 return this.each(function(child, i2) {
16461 var result2;
16462 try {
16463 result2 = callback(child, i2);
16464 } catch (e2) {
16465 throw child.addToError(e2);
16466 }
16467 if (result2 !== false && child.walk) {
16468 result2 = child.walk(callback);
16469 }
16470 return result2;
16471 });
16472 };
16473 _proto.walkAtRules = function walkAtRules(name, callback) {
16474 if (!callback) {
16475 callback = name;
16476 return this.walk(function(child, i2) {
16477 if (child.type === "atrule") {
16478 return callback(child, i2);
16479 }
16480 });
16481 }
16482 if (_instanceof(name, RegExp)) {
16483 return this.walk(function(child, i2) {
16484 if (child.type === "atrule" && name.test(child.name)) {
16485 return callback(child, i2);
16486 }
16487 });
16488 }
16489 return this.walk(function(child, i2) {
16490 if (child.type === "atrule" && child.name === name) {
16491 return callback(child, i2);
16492 }
16493 });
16494 };
16495 _proto.walkComments = function walkComments(callback) {
16496 return this.walk(function(child, i2) {
16497 if (child.type === "comment") {
16498 return callback(child, i2);
16499 }
16500 });
16501 };
16502 _proto.walkDecls = function walkDecls(prop, callback) {
16503 if (!callback) {
16504 callback = prop;
16505 return this.walk(function(child, i2) {
16506 if (child.type === "decl") {
16507 return callback(child, i2);
16508 }
16509 });
16510 }
16511 if (_instanceof(prop, RegExp)) {
16512 return this.walk(function(child, i2) {
16513 if (child.type === "decl" && prop.test(child.prop)) {
16514 return callback(child, i2);
16515 }
16516 });
16517 }
16518 return this.walk(function(child, i2) {
16519 if (child.type === "decl" && child.prop === prop) {
16520 return callback(child, i2);
16521 }
16522 });
16523 };
16524 _proto.walkRules = function walkRules(selector, callback) {
16525 if (!callback) {
16526 callback = selector;
16527 return this.walk(function(child, i2) {
16528 if (child.type === "rule") {
16529 return callback(child, i2);
16530 }
16531 });
16532 }
16533 if (_instanceof(selector, RegExp)) {
16534 return this.walk(function(child, i2) {
16535 if (child.type === "rule" && selector.test(child.selector)) {
16536 return callback(child, i2);
16537 }
16538 });
16539 }
16540 return this.walk(function(child, i2) {
16541 if (child.type === "rule" && child.selector === selector) {
16542 return callback(child, i2);
16543 }
16544 });
16545 };
16546 _create_class(Container2, [
16547 {
16548 key: "first",
16549 get: function get() {
16550 if (!this.proxyOf.nodes) return void 0;
16551 return this.proxyOf.nodes[0];
16552 }
16553 },
16554 {
16555 key: "last",
16556 get: function get() {
16557 if (!this.proxyOf.nodes) return void 0;
16558 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
16559 }
16560 }
16561 ]);
16562 return Container2;
16563 }(Node$1);
16564 Container$7.registerParse = function(dependant) {
16565 parse$4 = dependant;
16566 };
16567 Container$7.registerRule = function(dependant) {
16568 Rule$4 = dependant;
16569 };
16570 Container$7.registerAtRule = function(dependant) {
16571 AtRule$4 = dependant;
16572 };
16573 Container$7.registerRoot = function(dependant) {
16574 Root$6 = dependant;
16575 };
16576 var container = Container$7;
16577 Container$7.default = Container$7;
16578 Container$7.rebuild = function(node2) {
16579 if (node2.type === "atrule") {
16580 Object.setPrototypeOf(node2, AtRule$4.prototype);
16581 } else if (node2.type === "rule") {
16582 Object.setPrototypeOf(node2, Rule$4.prototype);
16583 } else if (node2.type === "decl") {
16584 Object.setPrototypeOf(node2, Declaration$3.prototype);
16585 } else if (node2.type === "comment") {
16586 Object.setPrototypeOf(node2, Comment$3.prototype);
16587 } else if (node2.type === "root") {
16588 Object.setPrototypeOf(node2, Root$6.prototype);
16589 }
16590 node2[my$1] = true;
16591 if (node2.nodes) {
16592 node2.nodes.forEach(function(child) {
16593 Container$7.rebuild(child);
16594 });
16595 }
16596 };
16597 var Container$6 = container;
16598 var LazyResult$4, Processor$3;
16599 var Document$3 = /*#__PURE__*/ function(Container$6) {
16600 _inherits(Document23, Container$6);
16601 function Document23(defaults) {
16602 var _this;
16603 _this = Container$6.call(this, _extends({
16604 type: "document"
16605 }, defaults)) || this;
16606 if (!_this.nodes) {
16607 _this.nodes = [];
16608 }
16609 return _this;
16610 }
16611 var _proto = Document23.prototype;
16612 _proto.toResult = function toResult(opts) {
16613 if (opts === void 0) opts = {};
16614 var lazy = new LazyResult$4(new Processor$3(), this, opts);
16615 return lazy.stringify();
16616 };
16617 return Document23;
16618 }(Container$6);
16619 Document$3.registerLazyResult = function(dependant) {
16620 LazyResult$4 = dependant;
16621 };
16622 Document$3.registerProcessor = function(dependant) {
16623 Processor$3 = dependant;
16624 };
16625 var document$1$2 = Document$3;
16626 Document$3.default = Document$3;
16627 var printed = {};
16628 var warnOnce$2 = function warnOnce2(message) {
16629 if (printed[message]) return;
16630 printed[message] = true;
16631 if (typeof console !== "undefined" && console.warn) {
16632 console.warn(message);
16633 }
16634 };
16635 var Warning$2 = /*#__PURE__*/ function() {
16636 function Warning2(text, opts) {
16637 if (opts === void 0) opts = {};
16638 this.type = "warning";
16639 this.text = text;
16640 if (opts.node && opts.node.source) {
16641 var range = opts.node.rangeBy(opts);
16642 this.line = range.start.line;
16643 this.column = range.start.column;
16644 this.endLine = range.end.line;
16645 this.endColumn = range.end.column;
16646 }
16647 for(var opt in opts)this[opt] = opts[opt];
16648 }
16649 var _proto = Warning2.prototype;
16650 _proto.toString = function toString() {
16651 if (this.node) {
16652 return this.node.error(this.text, {
16653 index: this.index,
16654 plugin: this.plugin,
16655 word: this.word
16656 }).message;
16657 }
16658 if (this.plugin) {
16659 return this.plugin + ": " + this.text;
16660 }
16661 return this.text;
16662 };
16663 return Warning2;
16664 }();
16665 var warning = Warning$2;
16666 Warning$2.default = Warning$2;
16667 var Warning$1 = warning;
16668 var Result$3 = /*#__PURE__*/ function() {
16669 function Result2(processor2, root2, opts) {
16670 this.processor = processor2;
16671 this.messages = [];
16672 this.root = root2;
16673 this.opts = opts;
16674 this.css = void 0;
16675 this.map = void 0;
16676 }
16677 var _proto = Result2.prototype;
16678 _proto.toString = function toString() {
16679 return this.css;
16680 };
16681 _proto.warn = function warn(text, opts) {
16682 if (opts === void 0) opts = {};
16683 if (!opts.plugin) {
16684 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
16685 opts.plugin = this.lastPlugin.postcssPlugin;
16686 }
16687 }
16688 var warning2 = new Warning$1(text, opts);
16689 this.messages.push(warning2);
16690 return warning2;
16691 };
16692 _proto.warnings = function warnings() {
16693 return this.messages.filter(function(i2) {
16694 return i2.type === "warning";
16695 });
16696 };
16697 _create_class(Result2, [
16698 {
16699 key: "content",
16700 get: function get() {
16701 return this.css;
16702 }
16703 }
16704 ]);
16705 return Result2;
16706 }();
16707 var result = Result$3;
16708 Result$3.default = Result$3;
16709 var SINGLE_QUOTE = "'".charCodeAt(0);
16710 var DOUBLE_QUOTE = '"'.charCodeAt(0);
16711 var BACKSLASH = "\\".charCodeAt(0);
16712 var SLASH = "/".charCodeAt(0);
16713 var NEWLINE = "\n".charCodeAt(0);
16714 var SPACE = " ".charCodeAt(0);
16715 var FEED = "\f".charCodeAt(0);
16716 var TAB = " ".charCodeAt(0);
16717 var CR = "\r".charCodeAt(0);
16718 var OPEN_SQUARE = "[".charCodeAt(0);
16719 var CLOSE_SQUARE = "]".charCodeAt(0);
16720 var OPEN_PARENTHESES = "(".charCodeAt(0);
16721 var CLOSE_PARENTHESES = ")".charCodeAt(0);
16722 var OPEN_CURLY = "{".charCodeAt(0);
16723 var CLOSE_CURLY = "}".charCodeAt(0);
16724 var SEMICOLON = ";".charCodeAt(0);
16725 var ASTERISK = "*".charCodeAt(0);
16726 var COLON = ":".charCodeAt(0);
16727 var AT = "@".charCodeAt(0);
16728 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g;
16729 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g;
16730 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/;
16731 var RE_HEX_ESCAPE = /[\da-f]/i;
16732 var tokenize = function tokenizer2(input2, options) {
16733 if (options === void 0) options = {};
16734 var css = input2.css.valueOf();
16735 var ignore = options.ignoreErrors;
16736 var code, next, quote, content, escape;
16737 var escaped, escapePos, prev, n2, currentToken;
16738 var length = css.length;
16739 var pos = 0;
16740 var buffer = [];
16741 var returned = [];
16742 function position() {
16743 return pos;
16744 }
16745 function unclosed(what) {
16746 throw input2.error("Unclosed " + what, pos);
16747 }
16748 function endOfFile() {
16749 return returned.length === 0 && pos >= length;
16750 }
16751 function nextToken(opts) {
16752 if (returned.length) return returned.pop();
16753 if (pos >= length) return;
16754 var ignoreUnclosed = opts ? opts.ignoreUnclosed : false;
16755 code = css.charCodeAt(pos);
16756 switch(code){
16757 case NEWLINE:
16758 case SPACE:
16759 case TAB:
16760 case CR:
16761 case FEED:
16762 {
16763 next = pos;
16764 do {
16765 next += 1;
16766 code = css.charCodeAt(next);
16767 }while (code === SPACE || code === NEWLINE || code === TAB || code === CR || code === FEED);
16768 currentToken = [
16769 "space",
16770 css.slice(pos, next)
16771 ];
16772 pos = next - 1;
16773 break;
16774 }
16775 case OPEN_SQUARE:
16776 case CLOSE_SQUARE:
16777 case OPEN_CURLY:
16778 case CLOSE_CURLY:
16779 case COLON:
16780 case SEMICOLON:
16781 case CLOSE_PARENTHESES:
16782 {
16783 var controlChar = String.fromCharCode(code);
16784 currentToken = [
16785 controlChar,
16786 controlChar,
16787 pos
16788 ];
16789 break;
16790 }
16791 case OPEN_PARENTHESES:
16792 {
16793 prev = buffer.length ? buffer.pop()[1] : "";
16794 n2 = css.charCodeAt(pos + 1);
16795 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE && n2 !== NEWLINE && n2 !== TAB && n2 !== FEED && n2 !== CR) {
16796 next = pos;
16797 do {
16798 escaped = false;
16799 next = css.indexOf(")", next + 1);
16800 if (next === -1) {
16801 if (ignore || ignoreUnclosed) {
16802 next = pos;
16803 break;
16804 } else {
16805 unclosed("bracket");
16806 }
16807 }
16808 escapePos = next;
16809 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16810 escapePos -= 1;
16811 escaped = !escaped;
16812 }
16813 }while (escaped);
16814 currentToken = [
16815 "brackets",
16816 css.slice(pos, next + 1),
16817 pos,
16818 next
16819 ];
16820 pos = next;
16821 } else {
16822 next = css.indexOf(")", pos + 1);
16823 content = css.slice(pos, next + 1);
16824 if (next === -1 || RE_BAD_BRACKET.test(content)) {
16825 currentToken = [
16826 "(",
16827 "(",
16828 pos
16829 ];
16830 } else {
16831 currentToken = [
16832 "brackets",
16833 content,
16834 pos,
16835 next
16836 ];
16837 pos = next;
16838 }
16839 }
16840 break;
16841 }
16842 case SINGLE_QUOTE:
16843 case DOUBLE_QUOTE:
16844 {
16845 quote = code === SINGLE_QUOTE ? "'" : '"';
16846 next = pos;
16847 do {
16848 escaped = false;
16849 next = css.indexOf(quote, next + 1);
16850 if (next === -1) {
16851 if (ignore || ignoreUnclosed) {
16852 next = pos + 1;
16853 break;
16854 } else {
16855 unclosed("string");
16856 }
16857 }
16858 escapePos = next;
16859 while(css.charCodeAt(escapePos - 1) === BACKSLASH){
16860 escapePos -= 1;
16861 escaped = !escaped;
16862 }
16863 }while (escaped);
16864 currentToken = [
16865 "string",
16866 css.slice(pos, next + 1),
16867 pos,
16868 next
16869 ];
16870 pos = next;
16871 break;
16872 }
16873 case AT:
16874 {
16875 RE_AT_END.lastIndex = pos + 1;
16876 RE_AT_END.test(css);
16877 if (RE_AT_END.lastIndex === 0) {
16878 next = css.length - 1;
16879 } else {
16880 next = RE_AT_END.lastIndex - 2;
16881 }
16882 currentToken = [
16883 "at-word",
16884 css.slice(pos, next + 1),
16885 pos,
16886 next
16887 ];
16888 pos = next;
16889 break;
16890 }
16891 case BACKSLASH:
16892 {
16893 next = pos;
16894 escape = true;
16895 while(css.charCodeAt(next + 1) === BACKSLASH){
16896 next += 1;
16897 escape = !escape;
16898 }
16899 code = css.charCodeAt(next + 1);
16900 if (escape && code !== SLASH && code !== SPACE && code !== NEWLINE && code !== TAB && code !== CR && code !== FEED) {
16901 next += 1;
16902 if (RE_HEX_ESCAPE.test(css.charAt(next))) {
16903 while(RE_HEX_ESCAPE.test(css.charAt(next + 1))){
16904 next += 1;
16905 }
16906 if (css.charCodeAt(next + 1) === SPACE) {
16907 next += 1;
16908 }
16909 }
16910 }
16911 currentToken = [
16912 "word",
16913 css.slice(pos, next + 1),
16914 pos,
16915 next
16916 ];
16917 pos = next;
16918 break;
16919 }
16920 default:
16921 {
16922 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) {
16923 next = css.indexOf("*/", pos + 2) + 1;
16924 if (next === 0) {
16925 if (ignore || ignoreUnclosed) {
16926 next = css.length;
16927 } else {
16928 unclosed("comment");
16929 }
16930 }
16931 currentToken = [
16932 "comment",
16933 css.slice(pos, next + 1),
16934 pos,
16935 next
16936 ];
16937 pos = next;
16938 } else {
16939 RE_WORD_END.lastIndex = pos + 1;
16940 RE_WORD_END.test(css);
16941 if (RE_WORD_END.lastIndex === 0) {
16942 next = css.length - 1;
16943 } else {
16944 next = RE_WORD_END.lastIndex - 2;
16945 }
16946 currentToken = [
16947 "word",
16948 css.slice(pos, next + 1),
16949 pos,
16950 next
16951 ];
16952 buffer.push(currentToken);
16953 pos = next;
16954 }
16955 break;
16956 }
16957 }
16958 pos++;
16959 return currentToken;
16960 }
16961 function back(token) {
16962 returned.push(token);
16963 }
16964 return {
16965 back: back,
16966 endOfFile: endOfFile,
16967 nextToken: nextToken,
16968 position: position
16969 };
16970 };
16971 var Container$5 = container;
16972 var AtRule$3 = /*#__PURE__*/ function(Container$5) {
16973 _inherits(AtRule2, Container$5);
16974 function AtRule2(defaults) {
16975 var _this;
16976 _this = Container$5.call(this, defaults) || this;
16977 _this.type = "atrule";
16978 return _this;
16979 }
16980 var _proto = AtRule2.prototype;
16981 _proto.append = function append() {
16982 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16983 children[_key] = arguments[_key];
16984 }
16985 var _Container$5_prototype_append;
16986 if (!this.proxyOf.nodes) this.nodes = [];
16987 return (_Container$5_prototype_append = Container$5.prototype.append).call.apply(_Container$5_prototype_append, [].concat([
16988 this
16989 ], children));
16990 };
16991 _proto.prepend = function prepend() {
16992 for(var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++){
16993 children[_key] = arguments[_key];
16994 }
16995 var _Container$5_prototype_prepend;
16996 if (!this.proxyOf.nodes) this.nodes = [];
16997 return (_Container$5_prototype_prepend = Container$5.prototype.prepend).call.apply(_Container$5_prototype_prepend, [].concat([
16998 this
16999 ], children));
17000 };
17001 return AtRule2;
17002 }(Container$5);
17003 var atRule = AtRule$3;
17004 AtRule$3.default = AtRule$3;
17005 Container$5.registerAtRule(AtRule$3);
17006 var Container$4 = container;
17007 var LazyResult$3, Processor$2;
17008 var Root$5 = /*#__PURE__*/ function(Container$4) {
17009 _inherits(Root2, Container$4);
17010 function Root2(defaults) {
17011 var _this;
17012 _this = Container$4.call(this, defaults) || this;
17013 _this.type = "root";
17014 if (!_this.nodes) _this.nodes = [];
17015 return _this;
17016 }
17017 var _proto = Root2.prototype;
17018 _proto.normalize = function normalize(child, sample, type) {
17019 var nodes = Container$4.prototype.normalize.call(this, child);
17020 if (sample) {
17021 if (type === "prepend") {
17022 if (this.nodes.length > 1) {
17023 sample.raws.before = this.nodes[1].raws.before;
17024 } else {
17025 delete sample.raws.before;
17026 }
17027 } else if (this.first !== sample) {
17028 for(var _iterator = _create_for_of_iterator_helper_loose(nodes), _step; !(_step = _iterator()).done;){
17029 var node2 = _step.value;
17030 node2.raws.before = sample.raws.before;
17031 }
17032 }
17033 }
17034 return nodes;
17035 };
17036 _proto.removeChild = function removeChild(child, ignore) {
17037 var index2 = this.index(child);
17038 if (!ignore && index2 === 0 && this.nodes.length > 1) {
17039 this.nodes[1].raws.before = this.nodes[index2].raws.before;
17040 }
17041 return Container$4.prototype.removeChild.call(this, child);
17042 };
17043 _proto.toResult = function toResult(opts) {
17044 if (opts === void 0) opts = {};
17045 var lazy = new LazyResult$3(new Processor$2(), this, opts);
17046 return lazy.stringify();
17047 };
17048 return Root2;
17049 }(Container$4);
17050 Root$5.registerLazyResult = function(dependant) {
17051 LazyResult$3 = dependant;
17052 };
17053 Root$5.registerProcessor = function(dependant) {
17054 Processor$2 = dependant;
17055 };
17056 var root = Root$5;
17057 Root$5.default = Root$5;
17058 Container$4.registerRoot(Root$5);
17059 var list$2 = {
17060 comma: function comma(string) {
17061 return list$2.split(string, [
17062 ","
17063 ], true);
17064 },
17065 space: function space(string) {
17066 var spaces = [
17067 " ",
17068 "\n",
17069 " "
17070 ];
17071 return list$2.split(string, spaces);
17072 },
17073 split: function split(string, separators, last) {
17074 var array = [];
17075 var current = "";
17076 var split = false;
17077 var func = 0;
17078 var inQuote = false;
17079 var prevQuote = "";
17080 var escape = false;
17081 for(var _iterator = _create_for_of_iterator_helper_loose(string), _step; !(_step = _iterator()).done;){
17082 var letter = _step.value;
17083 if (escape) {
17084 escape = false;
17085 } else if (letter === "\\") {
17086 escape = true;
17087 } else if (inQuote) {
17088 if (letter === prevQuote) {
17089 inQuote = false;
17090 }
17091 } else if (letter === '"' || letter === "'") {
17092 inQuote = true;
17093 prevQuote = letter;
17094 } else if (letter === "(") {
17095 func += 1;
17096 } else if (letter === ")") {
17097 if (func > 0) func -= 1;
17098 } else if (func === 0) {
17099 if (separators.includes(letter)) split = true;
17100 }
17101 if (split) {
17102 if (current !== "") array.push(current.trim());
17103 current = "";
17104 split = false;
17105 } else {
17106 current += letter;
17107 }
17108 }
17109 if (last || current !== "") array.push(current.trim());
17110 return array;
17111 }
17112 };
17113 var list_1 = list$2;
17114 list$2.default = list$2;
17115 var Container$3 = container;
17116 var list$1 = list_1;
17117 var Rule$3 = /*#__PURE__*/ function(Container$3) {
17118 _inherits(Rule2, Container$3);
17119 function Rule2(defaults) {
17120 var _this;
17121 _this = Container$3.call(this, defaults) || this;
17122 _this.type = "rule";
17123 if (!_this.nodes) _this.nodes = [];
17124 return _this;
17125 }
17126 _create_class(Rule2, [
17127 {
17128 key: "selectors",
17129 get: function get() {
17130 return list$1.comma(this.selector);
17131 },
17132 set: function set(values) {
17133 var match = this.selector ? this.selector.match(/,\s*/) : null;
17134 var sep2 = match ? match[0] : "," + this.raw("between", "beforeOpen");
17135 this.selector = values.join(sep2);
17136 }
17137 }
17138 ]);
17139 return Rule2;
17140 }(Container$3);
17141 var rule = Rule$3;
17142 Rule$3.default = Rule$3;
17143 Container$3.registerRule(Rule$3);
17144 var Declaration$2 = declaration;
17145 var tokenizer22 = tokenize;
17146 var Comment$2 = comment;
17147 var AtRule$2 = atRule;
17148 var Root$4 = root;
17149 var Rule$2 = rule;
17150 var SAFE_COMMENT_NEIGHBOR = {
17151 empty: true,
17152 space: true
17153 };
17154 function findLastWithPosition(tokens) {
17155 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17156 var token = tokens[i2];
17157 var pos = token[3] || token[2];
17158 if (pos) return pos;
17159 }
17160 }
17161 var Parser$1 = /*#__PURE__*/ function() {
17162 function Parser2(input2) {
17163 this.input = input2;
17164 this.root = new Root$4();
17165 this.current = this.root;
17166 this.spaces = "";
17167 this.semicolon = false;
17168 this.createTokenizer();
17169 this.root.source = {
17170 input: input2,
17171 start: {
17172 column: 1,
17173 line: 1,
17174 offset: 0
17175 }
17176 };
17177 }
17178 var _proto = Parser2.prototype;
17179 _proto.atrule = function atrule(token) {
17180 var node2 = new AtRule$2();
17181 node2.name = token[1].slice(1);
17182 if (node2.name === "") {
17183 this.unnamedAtrule(node2, token);
17184 }
17185 this.init(node2, token[2]);
17186 var type;
17187 var prev;
17188 var shift;
17189 var last = false;
17190 var open = false;
17191 var params = [];
17192 var brackets = [];
17193 while(!this.tokenizer.endOfFile()){
17194 token = this.tokenizer.nextToken();
17195 type = token[0];
17196 if (type === "(" || type === "[") {
17197 brackets.push(type === "(" ? ")" : "]");
17198 } else if (type === "{" && brackets.length > 0) {
17199 brackets.push("}");
17200 } else if (type === brackets[brackets.length - 1]) {
17201 brackets.pop();
17202 }
17203 if (brackets.length === 0) {
17204 if (type === ";") {
17205 node2.source.end = this.getPosition(token[2]);
17206 node2.source.end.offset++;
17207 this.semicolon = true;
17208 break;
17209 } else if (type === "{") {
17210 open = true;
17211 break;
17212 } else if (type === "}") {
17213 if (params.length > 0) {
17214 shift = params.length - 1;
17215 prev = params[shift];
17216 while(prev && prev[0] === "space"){
17217 prev = params[--shift];
17218 }
17219 if (prev) {
17220 node2.source.end = this.getPosition(prev[3] || prev[2]);
17221 node2.source.end.offset++;
17222 }
17223 }
17224 this.end(token);
17225 break;
17226 } else {
17227 params.push(token);
17228 }
17229 } else {
17230 params.push(token);
17231 }
17232 if (this.tokenizer.endOfFile()) {
17233 last = true;
17234 break;
17235 }
17236 }
17237 node2.raws.between = this.spacesAndCommentsFromEnd(params);
17238 if (params.length) {
17239 node2.raws.afterName = this.spacesAndCommentsFromStart(params);
17240 this.raw(node2, "params", params);
17241 if (last) {
17242 token = params[params.length - 1];
17243 node2.source.end = this.getPosition(token[3] || token[2]);
17244 node2.source.end.offset++;
17245 this.spaces = node2.raws.between;
17246 node2.raws.between = "";
17247 }
17248 } else {
17249 node2.raws.afterName = "";
17250 node2.params = "";
17251 }
17252 if (open) {
17253 node2.nodes = [];
17254 this.current = node2;
17255 }
17256 };
17257 _proto.checkMissedSemicolon = function checkMissedSemicolon(tokens) {
17258 var colon = this.colon(tokens);
17259 if (colon === false) return;
17260 var founded = 0;
17261 var token;
17262 for(var j = colon - 1; j >= 0; j--){
17263 token = tokens[j];
17264 if (token[0] !== "space") {
17265 founded += 1;
17266 if (founded === 2) break;
17267 }
17268 }
17269 throw this.input.error("Missed semicolon", token[0] === "word" ? token[3] + 1 : token[2]);
17270 };
17271 _proto.colon = function colon(tokens) {
17272 var brackets = 0;
17273 var token, type, prev;
17274 for(var _iterator = _create_for_of_iterator_helper_loose(tokens.entries()), _step; !(_step = _iterator()).done;){
17275 var _step_value = _step.value, i2 = _step_value[0], element = _step_value[1];
17276 token = element;
17277 type = token[0];
17278 if (type === "(") {
17279 brackets += 1;
17280 }
17281 if (type === ")") {
17282 brackets -= 1;
17283 }
17284 if (brackets === 0 && type === ":") {
17285 if (!prev) {
17286 this.doubleColon(token);
17287 } else if (prev[0] === "word" && prev[1] === "progid") {
17288 continue;
17289 } else {
17290 return i2;
17291 }
17292 }
17293 prev = token;
17294 }
17295 return false;
17296 };
17297 _proto.comment = function comment(token) {
17298 var node2 = new Comment$2();
17299 this.init(node2, token[2]);
17300 node2.source.end = this.getPosition(token[3] || token[2]);
17301 node2.source.end.offset++;
17302 var text = token[1].slice(2, -2);
17303 if (/^\s*$/.test(text)) {
17304 node2.text = "";
17305 node2.raws.left = text;
17306 node2.raws.right = "";
17307 } else {
17308 var match = text.match(/^(\s*)([^]*\S)(\s*)$/);
17309 node2.text = match[2];
17310 node2.raws.left = match[1];
17311 node2.raws.right = match[3];
17312 }
17313 };
17314 _proto.createTokenizer = function createTokenizer() {
17315 this.tokenizer = tokenizer22(this.input);
17316 };
17317 _proto.decl = function decl(tokens, customProperty) {
17318 var node2 = new Declaration$2();
17319 this.init(node2, tokens[0][2]);
17320 var last = tokens[tokens.length - 1];
17321 if (last[0] === ";") {
17322 this.semicolon = true;
17323 tokens.pop();
17324 }
17325 node2.source.end = this.getPosition(last[3] || last[2] || findLastWithPosition(tokens));
17326 node2.source.end.offset++;
17327 while(tokens[0][0] !== "word"){
17328 if (tokens.length === 1) this.unknownWord(tokens);
17329 node2.raws.before += tokens.shift()[1];
17330 }
17331 node2.source.start = this.getPosition(tokens[0][2]);
17332 node2.prop = "";
17333 while(tokens.length){
17334 var type = tokens[0][0];
17335 if (type === ":" || type === "space" || type === "comment") {
17336 break;
17337 }
17338 node2.prop += tokens.shift()[1];
17339 }
17340 node2.raws.between = "";
17341 var token;
17342 while(tokens.length){
17343 token = tokens.shift();
17344 if (token[0] === ":") {
17345 node2.raws.between += token[1];
17346 break;
17347 } else {
17348 if (token[0] === "word" && /\w/.test(token[1])) {
17349 this.unknownWord([
17350 token
17351 ]);
17352 }
17353 node2.raws.between += token[1];
17354 }
17355 }
17356 if (node2.prop[0] === "_" || node2.prop[0] === "*") {
17357 node2.raws.before += node2.prop[0];
17358 node2.prop = node2.prop.slice(1);
17359 }
17360 var firstSpaces = [];
17361 var next;
17362 while(tokens.length){
17363 next = tokens[0][0];
17364 if (next !== "space" && next !== "comment") break;
17365 firstSpaces.push(tokens.shift());
17366 }
17367 this.precheckMissedSemicolon(tokens);
17368 for(var i2 = tokens.length - 1; i2 >= 0; i2--){
17369 token = tokens[i2];
17370 if (token[1].toLowerCase() === "!important") {
17371 node2.important = true;
17372 var string = this.stringFrom(tokens, i2);
17373 string = this.spacesFromEnd(tokens) + string;
17374 if (string !== " !important") node2.raws.important = string;
17375 break;
17376 } else if (token[1].toLowerCase() === "important") {
17377 var cache = tokens.slice(0);
17378 var str = "";
17379 for(var j = i2; j > 0; j--){
17380 var type1 = cache[j][0];
17381 if (str.trim().indexOf("!") === 0 && type1 !== "space") {
17382 break;
17383 }
17384 str = cache.pop()[1] + str;
17385 }
17386 if (str.trim().indexOf("!") === 0) {
17387 node2.important = true;
17388 node2.raws.important = str;
17389 tokens = cache;
17390 }
17391 }
17392 if (token[0] !== "space" && token[0] !== "comment") {
17393 break;
17394 }
17395 }
17396 var hasWord = tokens.some(function(i2) {
17397 return i2[0] !== "space" && i2[0] !== "comment";
17398 });
17399 if (hasWord) {
17400 node2.raws.between += firstSpaces.map(function(i2) {
17401 return i2[1];
17402 }).join("");
17403 firstSpaces = [];
17404 }
17405 this.raw(node2, "value", firstSpaces.concat(tokens), customProperty);
17406 if (node2.value.includes(":") && !customProperty) {
17407 this.checkMissedSemicolon(tokens);
17408 }
17409 };
17410 _proto.doubleColon = function doubleColon(token) {
17411 throw this.input.error("Double colon", {
17412 offset: token[2]
17413 }, {
17414 offset: token[2] + token[1].length
17415 });
17416 };
17417 _proto.emptyRule = function emptyRule(token) {
17418 var node2 = new Rule$2();
17419 this.init(node2, token[2]);
17420 node2.selector = "";
17421 node2.raws.between = "";
17422 this.current = node2;
17423 };
17424 _proto.end = function end(token) {
17425 if (this.current.nodes && this.current.nodes.length) {
17426 this.current.raws.semicolon = this.semicolon;
17427 }
17428 this.semicolon = false;
17429 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17430 this.spaces = "";
17431 if (this.current.parent) {
17432 this.current.source.end = this.getPosition(token[2]);
17433 this.current.source.end.offset++;
17434 this.current = this.current.parent;
17435 } else {
17436 this.unexpectedClose(token);
17437 }
17438 };
17439 _proto.endFile = function endFile() {
17440 if (this.current.parent) this.unclosedBlock();
17441 if (this.current.nodes && this.current.nodes.length) {
17442 this.current.raws.semicolon = this.semicolon;
17443 }
17444 this.current.raws.after = (this.current.raws.after || "") + this.spaces;
17445 this.root.source.end = this.getPosition(this.tokenizer.position());
17446 };
17447 _proto.freeSemicolon = function freeSemicolon(token) {
17448 this.spaces += token[1];
17449 if (this.current.nodes) {
17450 var prev = this.current.nodes[this.current.nodes.length - 1];
17451 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
17452 prev.raws.ownSemicolon = this.spaces;
17453 this.spaces = "";
17454 }
17455 }
17456 };
17457 // Helpers
17458 _proto.getPosition = function getPosition(offset) {
17459 var pos = this.input.fromOffset(offset);
17460 return {
17461 column: pos.col,
17462 line: pos.line,
17463 offset: offset
17464 };
17465 };
17466 _proto.init = function init(node2, offset) {
17467 this.current.push(node2);
17468 node2.source = {
17469 input: this.input,
17470 start: this.getPosition(offset)
17471 };
17472 node2.raws.before = this.spaces;
17473 this.spaces = "";
17474 if (node2.type !== "comment") this.semicolon = false;
17475 };
17476 _proto.other = function other(start) {
17477 var end = false;
17478 var type = null;
17479 var colon = false;
17480 var bracket = null;
17481 var brackets = [];
17482 var customProperty = start[1].startsWith("--");
17483 var tokens = [];
17484 var token = start;
17485 while(token){
17486 type = token[0];
17487 tokens.push(token);
17488 if (type === "(" || type === "[") {
17489 if (!bracket) bracket = token;
17490 brackets.push(type === "(" ? ")" : "]");
17491 } else if (customProperty && colon && type === "{") {
17492 if (!bracket) bracket = token;
17493 brackets.push("}");
17494 } else if (brackets.length === 0) {
17495 if (type === ";") {
17496 if (colon) {
17497 this.decl(tokens, customProperty);
17498 return;
17499 } else {
17500 break;
17501 }
17502 } else if (type === "{") {
17503 this.rule(tokens);
17504 return;
17505 } else if (type === "}") {
17506 this.tokenizer.back(tokens.pop());
17507 end = true;
17508 break;
17509 } else if (type === ":") {
17510 colon = true;
17511 }
17512 } else if (type === brackets[brackets.length - 1]) {
17513 brackets.pop();
17514 if (brackets.length === 0) bracket = null;
17515 }
17516 token = this.tokenizer.nextToken();
17517 }
17518 if (this.tokenizer.endOfFile()) end = true;
17519 if (brackets.length > 0) this.unclosedBracket(bracket);
17520 if (end && colon) {
17521 if (!customProperty) {
17522 while(tokens.length){
17523 token = tokens[tokens.length - 1][0];
17524 if (token !== "space" && token !== "comment") break;
17525 this.tokenizer.back(tokens.pop());
17526 }
17527 }
17528 this.decl(tokens, customProperty);
17529 } else {
17530 this.unknownWord(tokens);
17531 }
17532 };
17533 _proto.parse = function parse() {
17534 var token;
17535 while(!this.tokenizer.endOfFile()){
17536 token = this.tokenizer.nextToken();
17537 switch(token[0]){
17538 case "space":
17539 this.spaces += token[1];
17540 break;
17541 case ";":
17542 this.freeSemicolon(token);
17543 break;
17544 case "}":
17545 this.end(token);
17546 break;
17547 case "comment":
17548 this.comment(token);
17549 break;
17550 case "at-word":
17551 this.atrule(token);
17552 break;
17553 case "{":
17554 this.emptyRule(token);
17555 break;
17556 default:
17557 this.other(token);
17558 break;
17559 }
17560 }
17561 this.endFile();
17562 };
17563 _proto.precheckMissedSemicolon = function precheckMissedSemicolon() {};
17564 _proto.raw = function raw(node2, prop, tokens, customProperty) {
17565 var token, type;
17566 var length = tokens.length;
17567 var value = "";
17568 var clean = true;
17569 var next, prev;
17570 for(var i2 = 0; i2 < length; i2 += 1){
17571 token = tokens[i2];
17572 type = token[0];
17573 if (type === "space" && i2 === length - 1 && !customProperty) {
17574 clean = false;
17575 } else if (type === "comment") {
17576 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty";
17577 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty";
17578 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
17579 if (value.slice(-1) === ",") {
17580 clean = false;
17581 } else {
17582 value += token[1];
17583 }
17584 } else {
17585 clean = false;
17586 }
17587 } else {
17588 value += token[1];
17589 }
17590 }
17591 if (!clean) {
17592 var raw = tokens.reduce(function(all, i2) {
17593 return all + i2[1];
17594 }, "");
17595 node2.raws[prop] = {
17596 raw: raw,
17597 value: value
17598 };
17599 }
17600 node2[prop] = value;
17601 };
17602 _proto.rule = function rule(tokens) {
17603 tokens.pop();
17604 var node2 = new Rule$2();
17605 this.init(node2, tokens[0][2]);
17606 node2.raws.between = this.spacesAndCommentsFromEnd(tokens);
17607 this.raw(node2, "selector", tokens);
17608 this.current = node2;
17609 };
17610 _proto.spacesAndCommentsFromEnd = function spacesAndCommentsFromEnd(tokens) {
17611 var lastTokenType;
17612 var spaces = "";
17613 while(tokens.length){
17614 lastTokenType = tokens[tokens.length - 1][0];
17615 if (lastTokenType !== "space" && lastTokenType !== "comment") break;
17616 spaces = tokens.pop()[1] + spaces;
17617 }
17618 return spaces;
17619 };
17620 // Errors
17621 _proto.spacesAndCommentsFromStart = function spacesAndCommentsFromStart(tokens) {
17622 var next;
17623 var spaces = "";
17624 while(tokens.length){
17625 next = tokens[0][0];
17626 if (next !== "space" && next !== "comment") break;
17627 spaces += tokens.shift()[1];
17628 }
17629 return spaces;
17630 };
17631 _proto.spacesFromEnd = function spacesFromEnd(tokens) {
17632 var lastTokenType;
17633 var spaces = "";
17634 while(tokens.length){
17635 lastTokenType = tokens[tokens.length - 1][0];
17636 if (lastTokenType !== "space") break;
17637 spaces = tokens.pop()[1] + spaces;
17638 }
17639 return spaces;
17640 };
17641 _proto.stringFrom = function stringFrom(tokens, from) {
17642 var result2 = "";
17643 for(var i2 = from; i2 < tokens.length; i2++){
17644 result2 += tokens[i2][1];
17645 }
17646 tokens.splice(from, tokens.length - from);
17647 return result2;
17648 };
17649 _proto.unclosedBlock = function unclosedBlock() {
17650 var pos = this.current.source.start;
17651 throw this.input.error("Unclosed block", pos.line, pos.column);
17652 };
17653 _proto.unclosedBracket = function unclosedBracket(bracket) {
17654 throw this.input.error("Unclosed bracket", {
17655 offset: bracket[2]
17656 }, {
17657 offset: bracket[2] + 1
17658 });
17659 };
17660 _proto.unexpectedClose = function unexpectedClose(token) {
17661 throw this.input.error("Unexpected }", {
17662 offset: token[2]
17663 }, {
17664 offset: token[2] + 1
17665 });
17666 };
17667 _proto.unknownWord = function unknownWord(tokens) {
17668 throw this.input.error("Unknown word", {
17669 offset: tokens[0][2]
17670 }, {
17671 offset: tokens[0][2] + tokens[0][1].length
17672 });
17673 };
17674 _proto.unnamedAtrule = function unnamedAtrule(node2, token) {
17675 throw this.input.error("At-rule without name", {
17676 offset: token[2]
17677 }, {
17678 offset: token[2] + token[1].length
17679 });
17680 };
17681 return Parser2;
17682 }();
17683 var parser = Parser$1;
17684 var Container$2 = container;
17685 var Parser22 = parser;
17686 var Input$2 = input;
17687 function parse$3(css, opts) {
17688 var input2 = new Input$2(css, opts);
17689 var parser2 = new Parser22(input2);
17690 try {
17691 parser2.parse();
17692 } catch (e2) {
17693 if (true) {
17694 if (e2.name === "CssSyntaxError" && opts && opts.from) {
17695 if (/\.scss$/i.test(opts.from)) {
17696 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
17697 } else if (/\.sass/i.test(opts.from)) {
17698 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser";
17699 } else if (/\.less$/i.test(opts.from)) {
17700 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser";
17701 }
17702 }
17703 }
17704 throw e2;
17705 }
17706 return parser2.root;
17707 }
17708 var parse_1 = parse$3;
17709 parse$3.default = parse$3;
17710 Container$2.registerParse(parse$3);
17711 var isClean = symbols.isClean, my = symbols.my;
17712 var MapGenerator$1 = mapGenerator;
17713 var stringify$2 = stringify_1;
17714 var Container$1 = container;
17715 var Document$2 = document$1$2;
17716 var warnOnce$1 = warnOnce$2;
17717 var Result$2 = result;
17718 var parse$2 = parse_1;
17719 var Root$3 = root;
17720 var TYPE_TO_CLASS_NAME = {
17721 atrule: "AtRule",
17722 comment: "Comment",
17723 decl: "Declaration",
17724 document: "Document",
17725 root: "Root",
17726 rule: "Rule"
17727 };
17728 var PLUGIN_PROPS = {
17729 AtRule: true,
17730 AtRuleExit: true,
17731 Comment: true,
17732 CommentExit: true,
17733 Declaration: true,
17734 DeclarationExit: true,
17735 Document: true,
17736 DocumentExit: true,
17737 Once: true,
17738 OnceExit: true,
17739 postcssPlugin: true,
17740 prepare: true,
17741 Root: true,
17742 RootExit: true,
17743 Rule: true,
17744 RuleExit: true
17745 };
17746 var NOT_VISITORS = {
17747 Once: true,
17748 postcssPlugin: true,
17749 prepare: true
17750 };
17751 var CHILDREN = 0;
17752 function isPromise(obj) {
17753 return (typeof obj === "undefined" ? "undefined" : _type_of(obj)) === "object" && typeof obj.then === "function";
17754 }
17755 function getEvents(node2) {
17756 var key = false;
17757 var type = TYPE_TO_CLASS_NAME[node2.type];
17758 if (node2.type === "decl") {
17759 key = node2.prop.toLowerCase();
17760 } else if (node2.type === "atrule") {
17761 key = node2.name.toLowerCase();
17762 }
17763 if (key && node2.append) {
17764 return [
17765 type,
17766 type + "-" + key,
17767 CHILDREN,
17768 type + "Exit",
17769 type + "Exit-" + key
17770 ];
17771 } else if (key) {
17772 return [
17773 type,
17774 type + "-" + key,
17775 type + "Exit",
17776 type + "Exit-" + key
17777 ];
17778 } else if (node2.append) {
17779 return [
17780 type,
17781 CHILDREN,
17782 type + "Exit"
17783 ];
17784 } else {
17785 return [
17786 type,
17787 type + "Exit"
17788 ];
17789 }
17790 }
17791 function toStack(node2) {
17792 var events;
17793 if (node2.type === "document") {
17794 events = [
17795 "Document",
17796 CHILDREN,
17797 "DocumentExit"
17798 ];
17799 } else if (node2.type === "root") {
17800 events = [
17801 "Root",
17802 CHILDREN,
17803 "RootExit"
17804 ];
17805 } else {
17806 events = getEvents(node2);
17807 }
17808 return {
17809 eventIndex: 0,
17810 events: events,
17811 iterator: 0,
17812 node: node2,
17813 visitorIndex: 0,
17814 visitors: []
17815 };
17816 }
17817 function cleanMarks(node2) {
17818 node2[isClean] = false;
17819 if (node2.nodes) node2.nodes.forEach(function(i2) {
17820 return cleanMarks(i2);
17821 });
17822 return node2;
17823 }
17824 var postcss$2 = {};
17825 var LazyResult$2 = /*#__PURE__*/ function() {
17826 function LazyResult2(processor2, css, opts) {
17827 var _this = this;
17828 this.stringified = false;
17829 this.processed = false;
17830 var root2;
17831 if ((typeof css === "undefined" ? "undefined" : _type_of(css)) === "object" && css !== null && (css.type === "root" || css.type === "document")) {
17832 root2 = cleanMarks(css);
17833 } else if (_instanceof(css, LazyResult2) || _instanceof(css, Result$2)) {
17834 root2 = cleanMarks(css.root);
17835 if (css.map) {
17836 if (typeof opts.map === "undefined") opts.map = {};
17837 if (!opts.map.inline) opts.map.inline = false;
17838 opts.map.prev = css.map;
17839 }
17840 } else {
17841 var parser2 = parse$2;
17842 if (opts.syntax) parser2 = opts.syntax.parse;
17843 if (opts.parser) parser2 = opts.parser;
17844 if (parser2.parse) parser2 = parser2.parse;
17845 try {
17846 root2 = parser2(css, opts);
17847 } catch (error) {
17848 this.processed = true;
17849 this.error = error;
17850 }
17851 if (root2 && !root2[my]) {
17852 Container$1.rebuild(root2);
17853 }
17854 }
17855 this.result = new Result$2(processor2, root2, opts);
17856 this.helpers = _extends({}, postcss$2, {
17857 postcss: postcss$2,
17858 result: this.result
17859 });
17860 this.plugins = this.processor.plugins.map(function(plugin22) {
17861 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.prepare) {
17862 return _extends({}, plugin22, plugin22.prepare(_this.result));
17863 } else {
17864 return plugin22;
17865 }
17866 });
17867 }
17868 var _proto = LazyResult2.prototype;
17869 _proto.async = function async() {
17870 if (this.error) return Promise.reject(this.error);
17871 if (this.processed) return Promise.resolve(this.result);
17872 if (!this.processing) {
17873 this.processing = this.runAsync();
17874 }
17875 return this.processing;
17876 };
17877 _proto.catch = function _catch(onRejected) {
17878 return this.async().catch(onRejected);
17879 };
17880 _proto.finally = function _finally(onFinally) {
17881 return this.async().then(onFinally, onFinally);
17882 };
17883 _proto.getAsyncError = function getAsyncError() {
17884 throw new Error("Use process(css).then(cb) to work with async plugins");
17885 };
17886 _proto.handleError = function handleError(error, node2) {
17887 var plugin22 = this.result.lastPlugin;
17888 try {
17889 if (node2) node2.addToError(error);
17890 this.error = error;
17891 if (error.name === "CssSyntaxError" && !error.plugin) {
17892 error.plugin = plugin22.postcssPlugin;
17893 error.setMessage();
17894 } else if (plugin22.postcssVersion) {
17895 if (true) {
17896 var pluginName = plugin22.postcssPlugin;
17897 var pluginVer = plugin22.postcssVersion;
17898 var runtimeVer = this.result.processor.version;
17899 var a2 = pluginVer.split(".");
17900 var b = runtimeVer.split(".");
17901 if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
17902 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.");
17903 }
17904 }
17905 }
17906 } catch (err) {
17907 if (console && console.error) console.error(err);
17908 }
17909 return error;
17910 };
17911 _proto.prepareVisitors = function prepareVisitors() {
17912 var _this = this;
17913 this.listeners = {};
17914 var add = function(plugin22, type, cb) {
17915 if (!_this.listeners[type]) _this.listeners[type] = [];
17916 _this.listeners[type].push([
17917 plugin22,
17918 cb
17919 ]);
17920 };
17921 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
17922 var plugin22 = _step.value;
17923 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object") {
17924 for(var event in plugin22){
17925 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
17926 throw new Error("Unknown event " + event + " in " + plugin22.postcssPlugin + ". Try to update PostCSS (" + this.processor.version + " now).");
17927 }
17928 if (!NOT_VISITORS[event]) {
17929 if (_type_of(plugin22[event]) === "object") {
17930 for(var filter in plugin22[event]){
17931 if (filter === "*") {
17932 add(plugin22, event, plugin22[event][filter]);
17933 } else {
17934 add(plugin22, event + "-" + filter.toLowerCase(), plugin22[event][filter]);
17935 }
17936 }
17937 } else if (typeof plugin22[event] === "function") {
17938 add(plugin22, event, plugin22[event]);
17939 }
17940 }
17941 }
17942 }
17943 }
17944 this.hasListener = Object.keys(this.listeners).length > 0;
17945 };
17946 _proto.runAsync = function runAsync() {
17947 var _this = this;
17948 return _async_to_generator(function() {
17949 var i2, plugin22, promise, error, root2, stack, promise1, e2, node2, _loop, _iterator, _step;
17950 return _ts_generator(this, function(_state) {
17951 switch(_state.label){
17952 case 0:
17953 _this.plugin = 0;
17954 i2 = 0;
17955 _state.label = 1;
17956 case 1:
17957 if (!(i2 < _this.plugins.length)) return [
17958 3,
17959 6
17960 ];
17961 plugin22 = _this.plugins[i2];
17962 promise = _this.runOnRoot(plugin22);
17963 if (!isPromise(promise)) return [
17964 3,
17965 5
17966 ];
17967 _state.label = 2;
17968 case 2:
17969 _state.trys.push([
17970 2,
17971 4,
17972 ,
17973 5
17974 ]);
17975 return [
17976 4,
17977 promise
17978 ];
17979 case 3:
17980 _state.sent();
17981 return [
17982 3,
17983 5
17984 ];
17985 case 4:
17986 error = _state.sent();
17987 throw _this.handleError(error);
17988 case 5:
17989 i2++;
17990 return [
17991 3,
17992 1
17993 ];
17994 case 6:
17995 _this.prepareVisitors();
17996 if (!_this.hasListener) return [
17997 3,
17998 18
17999 ];
18000 root2 = _this.result.root;
18001 _state.label = 7;
18002 case 7:
18003 if (!!root2[isClean]) return [
18004 3,
18005 14
18006 ];
18007 root2[isClean] = true;
18008 stack = [
18009 toStack(root2)
18010 ];
18011 _state.label = 8;
18012 case 8:
18013 if (!(stack.length > 0)) return [
18014 3,
18015 13
18016 ];
18017 promise1 = _this.visitTick(stack);
18018 if (!isPromise(promise1)) return [
18019 3,
18020 12
18021 ];
18022 _state.label = 9;
18023 case 9:
18024 _state.trys.push([
18025 9,
18026 11,
18027 ,
18028 12
18029 ]);
18030 return [
18031 4,
18032 promise1
18033 ];
18034 case 10:
18035 _state.sent();
18036 return [
18037 3,
18038 12
18039 ];
18040 case 11:
18041 e2 = _state.sent();
18042 node2 = stack[stack.length - 1].node;
18043 throw _this.handleError(e2, node2);
18044 case 12:
18045 return [
18046 3,
18047 8
18048 ];
18049 case 13:
18050 return [
18051 3,
18052 7
18053 ];
18054 case 14:
18055 if (!_this.listeners.OnceExit) return [
18056 3,
18057 18
18058 ];
18059 _loop = function() {
18060 var _step_value, plugin22, visitor, roots, e2;
18061 return _ts_generator(this, function(_state) {
18062 switch(_state.label){
18063 case 0:
18064 _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18065 _this.result.lastPlugin = plugin22;
18066 _state.label = 1;
18067 case 1:
18068 _state.trys.push([
18069 1,
18070 6,
18071 ,
18072 7
18073 ]);
18074 if (!(root2.type === "document")) return [
18075 3,
18076 3
18077 ];
18078 roots = root2.nodes.map(function(subRoot) {
18079 return visitor(subRoot, _this.helpers);
18080 });
18081 return [
18082 4,
18083 Promise.all(roots)
18084 ];
18085 case 2:
18086 _state.sent();
18087 return [
18088 3,
18089 5
18090 ];
18091 case 3:
18092 return [
18093 4,
18094 visitor(root2, _this.helpers)
18095 ];
18096 case 4:
18097 _state.sent();
18098 _state.label = 5;
18099 case 5:
18100 return [
18101 3,
18102 7
18103 ];
18104 case 6:
18105 e2 = _state.sent();
18106 throw _this.handleError(e2);
18107 case 7:
18108 return [
18109 2
18110 ];
18111 }
18112 });
18113 };
18114 _iterator = _create_for_of_iterator_helper_loose(_this.listeners.OnceExit);
18115 _state.label = 15;
18116 case 15:
18117 if (!!(_step = _iterator()).done) return [
18118 3,
18119 18
18120 ];
18121 return [
18122 5,
18123 _ts_values(_loop())
18124 ];
18125 case 16:
18126 _state.sent();
18127 _state.label = 17;
18128 case 17:
18129 return [
18130 3,
18131 15
18132 ];
18133 case 18:
18134 _this.processed = true;
18135 return [
18136 2,
18137 _this.stringify()
18138 ];
18139 }
18140 });
18141 })();
18142 };
18143 _proto.runOnRoot = function runOnRoot(plugin22) {
18144 var _this = this;
18145 this.result.lastPlugin = plugin22;
18146 try {
18147 if ((typeof plugin22 === "undefined" ? "undefined" : _type_of(plugin22)) === "object" && plugin22.Once) {
18148 if (this.result.root.type === "document") {
18149 var roots = this.result.root.nodes.map(function(root2) {
18150 return plugin22.Once(root2, _this.helpers);
18151 });
18152 if (isPromise(roots[0])) {
18153 return Promise.all(roots);
18154 }
18155 return roots;
18156 }
18157 return plugin22.Once(this.result.root, this.helpers);
18158 } else if (typeof plugin22 === "function") {
18159 return plugin22(this.result.root, this.result);
18160 }
18161 } catch (error) {
18162 throw this.handleError(error);
18163 }
18164 };
18165 _proto.stringify = function stringify() {
18166 if (this.error) throw this.error;
18167 if (this.stringified) return this.result;
18168 this.stringified = true;
18169 this.sync();
18170 var opts = this.result.opts;
18171 var str = stringify$2;
18172 if (opts.syntax) str = opts.syntax.stringify;
18173 if (opts.stringifier) str = opts.stringifier;
18174 if (str.stringify) str = str.stringify;
18175 var map = new MapGenerator$1(str, this.result.root, this.result.opts);
18176 var data = map.generate();
18177 this.result.css = data[0];
18178 this.result.map = data[1];
18179 return this.result;
18180 };
18181 _proto.sync = function sync() {
18182 if (this.error) throw this.error;
18183 if (this.processed) return this.result;
18184 this.processed = true;
18185 if (this.processing) {
18186 throw this.getAsyncError();
18187 }
18188 for(var _iterator = _create_for_of_iterator_helper_loose(this.plugins), _step; !(_step = _iterator()).done;){
18189 var plugin22 = _step.value;
18190 var promise = this.runOnRoot(plugin22);
18191 if (isPromise(promise)) {
18192 throw this.getAsyncError();
18193 }
18194 }
18195 this.prepareVisitors();
18196 if (this.hasListener) {
18197 var root2 = this.result.root;
18198 while(!root2[isClean]){
18199 root2[isClean] = true;
18200 this.walkSync(root2);
18201 }
18202 if (this.listeners.OnceExit) {
18203 if (root2.type === "document") {
18204 for(var _iterator1 = _create_for_of_iterator_helper_loose(root2.nodes), _step1; !(_step1 = _iterator1()).done;){
18205 var subRoot = _step1.value;
18206 this.visitSync(this.listeners.OnceExit, subRoot);
18207 }
18208 } else {
18209 this.visitSync(this.listeners.OnceExit, root2);
18210 }
18211 }
18212 }
18213 return this.result;
18214 };
18215 _proto.then = function then(onFulfilled, onRejected) {
18216 if (true) {
18217 if (!("from" in this.opts)) {
18218 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.");
18219 }
18220 }
18221 return this.async().then(onFulfilled, onRejected);
18222 };
18223 _proto.toString = function toString() {
18224 return this.css;
18225 };
18226 _proto.visitSync = function visitSync(visitors, node2) {
18227 for(var _iterator = _create_for_of_iterator_helper_loose(visitors), _step; !(_step = _iterator()).done;){
18228 var _step_value = _step.value, plugin22 = _step_value[0], visitor = _step_value[1];
18229 this.result.lastPlugin = plugin22;
18230 var promise = void 0;
18231 try {
18232 promise = visitor(node2, this.helpers);
18233 } catch (e2) {
18234 throw this.handleError(e2, node2.proxyOf);
18235 }
18236 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18237 return true;
18238 }
18239 if (isPromise(promise)) {
18240 throw this.getAsyncError();
18241 }
18242 }
18243 };
18244 _proto.visitTick = function visitTick(stack) {
18245 var visit2 = stack[stack.length - 1];
18246 var node2 = visit2.node, visitors = visit2.visitors;
18247 if (node2.type !== "root" && node2.type !== "document" && !node2.parent) {
18248 stack.pop();
18249 return;
18250 }
18251 if (visitors.length > 0 && visit2.visitorIndex < visitors.length) {
18252 var _visitors_visit2_visitorIndex = visitors[visit2.visitorIndex], plugin22 = _visitors_visit2_visitorIndex[0], visitor = _visitors_visit2_visitorIndex[1];
18253 visit2.visitorIndex += 1;
18254 if (visit2.visitorIndex === visitors.length) {
18255 visit2.visitors = [];
18256 visit2.visitorIndex = 0;
18257 }
18258 this.result.lastPlugin = plugin22;
18259 try {
18260 return visitor(node2.toProxy(), this.helpers);
18261 } catch (e2) {
18262 throw this.handleError(e2, node2);
18263 }
18264 }
18265 if (visit2.iterator !== 0) {
18266 var iterator = visit2.iterator;
18267 var child;
18268 while(child = node2.nodes[node2.indexes[iterator]]){
18269 node2.indexes[iterator] += 1;
18270 if (!child[isClean]) {
18271 child[isClean] = true;
18272 stack.push(toStack(child));
18273 return;
18274 }
18275 }
18276 visit2.iterator = 0;
18277 delete node2.indexes[iterator];
18278 }
18279 var events = visit2.events;
18280 while(visit2.eventIndex < events.length){
18281 var event = events[visit2.eventIndex];
18282 visit2.eventIndex += 1;
18283 if (event === CHILDREN) {
18284 if (node2.nodes && node2.nodes.length) {
18285 node2[isClean] = true;
18286 visit2.iterator = node2.getIterator();
18287 }
18288 return;
18289 } else if (this.listeners[event]) {
18290 visit2.visitors = this.listeners[event];
18291 return;
18292 }
18293 }
18294 stack.pop();
18295 };
18296 _proto.walkSync = function walkSync(node2) {
18297 var _this = this;
18298 node2[isClean] = true;
18299 var events = getEvents(node2);
18300 for(var _iterator = _create_for_of_iterator_helper_loose(events), _step; !(_step = _iterator()).done;){
18301 var event = _step.value;
18302 if (event === CHILDREN) {
18303 if (node2.nodes) {
18304 node2.each(function(child) {
18305 if (!child[isClean]) _this.walkSync(child);
18306 });
18307 }
18308 } else {
18309 var visitors = this.listeners[event];
18310 if (visitors) {
18311 if (this.visitSync(visitors, node2.toProxy())) return;
18312 }
18313 }
18314 }
18315 };
18316 _proto.warnings = function warnings() {
18317 return this.sync().warnings();
18318 };
18319 _create_class(LazyResult2, [
18320 {
18321 key: "content",
18322 get: function get() {
18323 return this.stringify().content;
18324 }
18325 },
18326 {
18327 key: "css",
18328 get: function get() {
18329 return this.stringify().css;
18330 }
18331 },
18332 {
18333 key: "map",
18334 get: function get() {
18335 return this.stringify().map;
18336 }
18337 },
18338 {
18339 key: "messages",
18340 get: function get() {
18341 return this.sync().messages;
18342 }
18343 },
18344 {
18345 key: "opts",
18346 get: function get() {
18347 return this.result.opts;
18348 }
18349 },
18350 {
18351 key: "processor",
18352 get: function get() {
18353 return this.result.processor;
18354 }
18355 },
18356 {
18357 key: "root",
18358 get: function get() {
18359 return this.sync().root;
18360 }
18361 },
18362 {
18363 key: Symbol.toStringTag,
18364 get: function get() {
18365 return "LazyResult";
18366 }
18367 }
18368 ]);
18369 return LazyResult2;
18370 }();
18371 LazyResult$2.registerPostcss = function(dependant) {
18372 postcss$2 = dependant;
18373 };
18374 var lazyResult = LazyResult$2;
18375 LazyResult$2.default = LazyResult$2;
18376 Root$3.registerLazyResult(LazyResult$2);
18377 Document$2.registerLazyResult(LazyResult$2);
18378 var MapGenerator22 = mapGenerator;
18379 var stringify$1 = stringify_1;
18380 var warnOnce22 = warnOnce$2;
18381 var parse$1 = parse_1;
18382 var Result$1 = result;
18383 var NoWorkResult$1 = /*#__PURE__*/ function() {
18384 function NoWorkResult2(processor2, css, opts) {
18385 css = css.toString();
18386 this.stringified = false;
18387 this._processor = processor2;
18388 this._css = css;
18389 this._opts = opts;
18390 this._map = void 0;
18391 var root2;
18392 var str = stringify$1;
18393 this.result = new Result$1(this._processor, root2, this._opts);
18394 this.result.css = css;
18395 var self = this;
18396 Object.defineProperty(this.result, "root", {
18397 get: function get() {
18398 return self.root;
18399 }
18400 });
18401 var map = new MapGenerator22(str, root2, this._opts, css);
18402 if (map.isMap()) {
18403 var _map_generate = map.generate(), generatedCSS = _map_generate[0], generatedMap = _map_generate[1];
18404 if (generatedCSS) {
18405 this.result.css = generatedCSS;
18406 }
18407 if (generatedMap) {
18408 this.result.map = generatedMap;
18409 }
18410 } else {
18411 map.clearAnnotation();
18412 this.result.css = map.css;
18413 }
18414 }
18415 var _proto = NoWorkResult2.prototype;
18416 _proto.async = function async() {
18417 if (this.error) return Promise.reject(this.error);
18418 return Promise.resolve(this.result);
18419 };
18420 _proto.catch = function _catch(onRejected) {
18421 return this.async().catch(onRejected);
18422 };
18423 _proto.finally = function _finally(onFinally) {
18424 return this.async().then(onFinally, onFinally);
18425 };
18426 _proto.sync = function sync() {
18427 if (this.error) throw this.error;
18428 return this.result;
18429 };
18430 _proto.then = function then(onFulfilled, onRejected) {
18431 if (true) {
18432 if (!("from" in this._opts)) {
18433 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.");
18434 }
18435 }
18436 return this.async().then(onFulfilled, onRejected);
18437 };
18438 _proto.toString = function toString() {
18439 return this._css;
18440 };
18441 _proto.warnings = function warnings() {
18442 return [];
18443 };
18444 _create_class(NoWorkResult2, [
18445 {
18446 key: "content",
18447 get: function get() {
18448 return this.result.css;
18449 }
18450 },
18451 {
18452 key: "css",
18453 get: function get() {
18454 return this.result.css;
18455 }
18456 },
18457 {
18458 key: "map",
18459 get: function get() {
18460 return this.result.map;
18461 }
18462 },
18463 {
18464 key: "messages",
18465 get: function get() {
18466 return [];
18467 }
18468 },
18469 {
18470 key: "opts",
18471 get: function get() {
18472 return this.result.opts;
18473 }
18474 },
18475 {
18476 key: "processor",
18477 get: function get() {
18478 return this.result.processor;
18479 }
18480 },
18481 {
18482 key: "root",
18483 get: function get() {
18484 if (this._root) {
18485 return this._root;
18486 }
18487 var root2;
18488 var parser2 = parse$1;
18489 try {
18490 root2 = parser2(this._css, this._opts);
18491 } catch (error) {
18492 this.error = error;
18493 }
18494 if (this.error) {
18495 throw this.error;
18496 } else {
18497 this._root = root2;
18498 return root2;
18499 }
18500 }
18501 },
18502 {
18503 key: Symbol.toStringTag,
18504 get: function get() {
18505 return "NoWorkResult";
18506 }
18507 }
18508 ]);
18509 return NoWorkResult2;
18510 }();
18511 var noWorkResult = NoWorkResult$1;
18512 NoWorkResult$1.default = NoWorkResult$1;
18513 var NoWorkResult22 = noWorkResult;
18514 var LazyResult$1 = lazyResult;
18515 var Document$1 = document$1$2;
18516 var Root$2 = root;
18517 var Processor$1 = /*#__PURE__*/ function() {
18518 function Processor2(plugins) {
18519 if (plugins === void 0) plugins = [];
18520 this.version = "8.4.38";
18521 this.plugins = this.normalize(plugins);
18522 }
18523 var _proto = Processor2.prototype;
18524 _proto.normalize = function normalize(plugins) {
18525 var normalized = [];
18526 for(var _iterator = _create_for_of_iterator_helper_loose(plugins), _step; !(_step = _iterator()).done;){
18527 var i2 = _step.value;
18528 if (i2.postcss === true) {
18529 i2 = i2();
18530 } else if (i2.postcss) {
18531 i2 = i2.postcss;
18532 }
18533 if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && Array.isArray(i2.plugins)) {
18534 normalized = normalized.concat(i2.plugins);
18535 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && i2.postcssPlugin) {
18536 normalized.push(i2);
18537 } else if (typeof i2 === "function") {
18538 normalized.push(i2);
18539 } else if ((typeof i2 === "undefined" ? "undefined" : _type_of(i2)) === "object" && (i2.parse || i2.stringify)) {
18540 if (true) {
18541 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.");
18542 }
18543 } else {
18544 throw new Error(i2 + " is not a PostCSS plugin");
18545 }
18546 }
18547 return normalized;
18548 };
18549 _proto.process = function process1(css, opts) {
18550 if (opts === void 0) opts = {};
18551 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) {
18552 return new NoWorkResult22(this, css, opts);
18553 } else {
18554 return new LazyResult$1(this, css, opts);
18555 }
18556 };
18557 _proto.use = function use(plugin22) {
18558 this.plugins = this.plugins.concat(this.normalize([
18559 plugin22
18560 ]));
18561 return this;
18562 };
18563 return Processor2;
18564 }();
18565 var processor = Processor$1;
18566 Processor$1.default = Processor$1;
18567 Root$2.registerProcessor(Processor$1);
18568 Document$1.registerProcessor(Processor$1);
18569 var Declaration$1 = declaration;
18570 var PreviousMap22 = previousMap;
18571 var Comment$1 = comment;
18572 var AtRule$1 = atRule;
18573 var Input$1 = input;
18574 var Root$1 = root;
18575 var Rule$1 = rule;
18576 function fromJSON$1(json, inputs) {
18577 if (Array.isArray(json)) return json.map(function(n2) {
18578 return fromJSON$1(n2);
18579 });
18580 var ownInputs = json.inputs, defaults = _object_without_properties_loose(json, [
18581 "inputs"
18582 ]);
18583 if (ownInputs) {
18584 inputs = [];
18585 for(var _iterator = _create_for_of_iterator_helper_loose(ownInputs), _step; !(_step = _iterator()).done;){
18586 var input2 = _step.value;
18587 var inputHydrated = _extends({}, input2, {
18588 __proto__: Input$1.prototype
18589 });
18590 if (inputHydrated.map) {
18591 inputHydrated.map = _extends({}, inputHydrated.map, {
18592 __proto__: PreviousMap22.prototype
18593 });
18594 }
18595 inputs.push(inputHydrated);
18596 }
18597 }
18598 if (defaults.nodes) {
18599 defaults.nodes = json.nodes.map(function(n2) {
18600 return fromJSON$1(n2, inputs);
18601 });
18602 }
18603 if (defaults.source) {
18604 var _defaults_source = defaults.source, inputId = _defaults_source.inputId, source = _object_without_properties_loose(_defaults_source, [
18605 "inputId"
18606 ]);
18607 defaults.source = source;
18608 if (inputId != null) {
18609 defaults.source.input = inputs[inputId];
18610 }
18611 }
18612 if (defaults.type === "root") {
18613 return new Root$1(defaults);
18614 } else if (defaults.type === "decl") {
18615 return new Declaration$1(defaults);
18616 } else if (defaults.type === "rule") {
18617 return new Rule$1(defaults);
18618 } else if (defaults.type === "comment") {
18619 return new Comment$1(defaults);
18620 } else if (defaults.type === "atrule") {
18621 return new AtRule$1(defaults);
18622 } else {
18623 throw new Error("Unknown node type: " + json.type);
18624 }
18625 }
18626 var fromJSON_1 = fromJSON$1;
18627 fromJSON$1.default = fromJSON$1;
18628 var CssSyntaxError22 = cssSyntaxError;
18629 var Declaration22 = declaration;
18630 var LazyResult22 = lazyResult;
18631 var Container22 = container;
18632 var Processor22 = processor;
18633 var stringify = stringify_1;
18634 var fromJSON = fromJSON_1;
18635 var Document222 = document$1$2;
18636 var Warning22 = warning;
18637 var Comment22 = comment;
18638 var AtRule22 = atRule;
18639 var Result22 = result;
18640 var Input22 = input;
18641 var parse = parse_1;
18642 var list = list_1;
18643 var Rule22 = rule;
18644 var Root22 = root;
18645 var Node22 = node;
18646 function postcss() {
18647 for(var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++){
18648 plugins[_key] = arguments[_key];
18649 }
18650 if (plugins.length === 1 && Array.isArray(plugins[0])) {
18651 plugins = plugins[0];
18652 }
18653 return new Processor22(plugins);
18654 }
18655 postcss.plugin = function plugin2(name, initializer) {
18656 var warningPrinted = false;
18657 function creator() {
18658 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
18659 args[_key] = arguments[_key];
18660 }
18661 if (console && console.warn && !warningPrinted) {
18662 warningPrinted = true;
18663 console.warn(name + ": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration");
18664 if (process.env.LANG && process.env.LANG.startsWith("cn")) {
18665 console.warn(name + ": 里面 postcss.plugin 被弃用. 迁移指南:\nhttps://www.w3ctech.com/topic/2226");
18666 }
18667 }
18668 var transformer = initializer.apply(void 0, [].concat(args));
18669 transformer.postcssPlugin = name;
18670 transformer.postcssVersion = new Processor22().version;
18671 return transformer;
18672 }
18673 var cache;
18674 Object.defineProperty(creator, "postcss", {
18675 get: function get() {
18676 if (!cache) cache = creator();
18677 return cache;
18678 }
18679 });
18680 creator.process = function(css, processOpts, pluginOpts) {
18681 return postcss([
18682 creator(pluginOpts)
18683 ]).process(css, processOpts);
18684 };
18685 return creator;
18686 };
18687 postcss.stringify = stringify;
18688 postcss.parse = parse;
18689 postcss.fromJSON = fromJSON;
18690 postcss.list = list;
18691 postcss.comment = function(defaults) {
18692 return new Comment22(defaults);
18693 };
18694 postcss.atRule = function(defaults) {
18695 return new AtRule22(defaults);
18696 };
18697 postcss.decl = function(defaults) {
18698 return new Declaration22(defaults);
18699 };
18700 postcss.rule = function(defaults) {
18701 return new Rule22(defaults);
18702 };
18703 postcss.root = function(defaults) {
18704 return new Root22(defaults);
18705 };
18706 postcss.document = function(defaults) {
18707 return new Document222(defaults);
18708 };
18709 postcss.CssSyntaxError = CssSyntaxError22;
18710 postcss.Declaration = Declaration22;
18711 postcss.Container = Container22;
18712 postcss.Processor = Processor22;
18713 postcss.Document = Document222;
18714 postcss.Comment = Comment22;
18715 postcss.Warning = Warning22;
18716 postcss.AtRule = AtRule22;
18717 postcss.Result = Result22;
18718 postcss.Input = Input22;
18719 postcss.Rule = Rule22;
18720 postcss.Root = Root22;
18721 postcss.Node = Node22;
18722 LazyResult22.registerPostcss(postcss);
18723 var postcss_1 = postcss;
18724 postcss.default = postcss;
18725 var postcss$1 = /* @__PURE__ */ getDefaultExportFromCjs(postcss_1);
18726 postcss$1.stringify;
18727 postcss$1.fromJSON;
18728 postcss$1.plugin;
18729 postcss$1.parse;
18730 postcss$1.list;
18731 postcss$1.document;
18732 postcss$1.comment;
18733 postcss$1.atRule;
18734 postcss$1.rule;
18735 postcss$1.decl;
18736 postcss$1.root;
18737 postcss$1.CssSyntaxError;
18738 postcss$1.Declaration;
18739 postcss$1.Container;
18740 postcss$1.Processor;
18741 postcss$1.Document;
18742 postcss$1.Comment;
18743 postcss$1.Warning;
18744 postcss$1.AtRule;
18745 postcss$1.Result;
18746 postcss$1.Input;
18747 postcss$1.Rule;
18748 postcss$1.Root;
18749 postcss$1.Node;
18750 var BaseRRNode = /*#__PURE__*/ function() {
18751 function BaseRRNode() {
18752 for(var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++){
18753 _args[_key] = arguments[_key];
18754 }
18755 __publicField2(this, "parentElement", null);
18756 __publicField2(this, "parentNode", null);
18757 __publicField2(this, "ownerDocument");
18758 __publicField2(this, "firstChild", null);
18759 __publicField2(this, "lastChild", null);
18760 __publicField2(this, "previousSibling", null);
18761 __publicField2(this, "nextSibling", null);
18762 __publicField2(this, "ELEMENT_NODE", 1);
18763 __publicField2(this, "TEXT_NODE", 3);
18764 __publicField2(this, "nodeType");
18765 __publicField2(this, "nodeName");
18766 __publicField2(this, "RRNodeType");
18767 }
18768 var _proto = BaseRRNode.prototype;
18769 _proto.contains = function contains(node2) {
18770 if (!_instanceof(node2, BaseRRNode)) return false;
18771 else if (node2.ownerDocument !== this.ownerDocument) return false;
18772 else if (node2 === this) return true;
18773 while(node2.parentNode){
18774 if (node2.parentNode === this) return true;
18775 node2 = node2.parentNode;
18776 }
18777 return false;
18778 };
18779 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18780 _proto.appendChild = function appendChild(_newChild) {
18781 throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.");
18782 };
18783 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18784 _proto.insertBefore = function insertBefore(_newChild, _refChild) {
18785 throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.");
18786 };
18787 // eslint-disable-next-line @typescript-eslint/no-unused-vars
18788 _proto.removeChild = function removeChild(_node) {
18789 throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.");
18790 };
18791 _proto.toString = function toString() {
18792 return "RRNode";
18793 };
18794 _create_class(BaseRRNode, [
18795 {
18796 key: "childNodes",
18797 get: function get() {
18798 var childNodes2 = [];
18799 var childIterator = this.firstChild;
18800 while(childIterator){
18801 childNodes2.push(childIterator);
18802 childIterator = childIterator.nextSibling;
18803 }
18804 return childNodes2;
18805 }
18806 }
18807 ]);
18808 return BaseRRNode;
18809 }();
18810 var testableAccessors = {
18811 Node: [
18812 "childNodes",
18813 "parentNode",
18814 "parentElement",
18815 "textContent"
18816 ],
18817 ShadowRoot: [
18818 "host",
18819 "styleSheets"
18820 ],
18821 Element: [
18822 "shadowRoot",
18823 "querySelector",
18824 "querySelectorAll"
18825 ],
18826 MutationObserver: []
18827 };
18828 var testableMethods = {
18829 Node: [
18830 "contains",
18831 "getRootNode"
18832 ],
18833 ShadowRoot: [
18834 "getSelection"
18835 ],
18836 Element: [],
18837 MutationObserver: [
18838 "constructor"
18839 ]
18840 };
18841 var untaintedBasePrototype = {};
18842 var isAngularZonePresent = function() {
18843 return !!globalThis.Zone;
18844 };
18845 function getUntaintedPrototype(key) {
18846 if (untaintedBasePrototype[key]) return untaintedBasePrototype[key];
18847 var defaultObj = globalThis[key];
18848 var defaultPrototype = defaultObj.prototype;
18849 var accessorNames = key in testableAccessors ? testableAccessors[key] : void 0;
18850 var isUntaintedAccessors = Boolean(accessorNames && // @ts-expect-error 2345
18851 accessorNames.every(function(accessor) {
18852 var _a2, _b;
18853 return Boolean((_b = (_a2 = Object.getOwnPropertyDescriptor(defaultPrototype, accessor)) == null ? void 0 : _a2.get) == null ? void 0 : _b.toString().includes("[native code]"));
18854 }));
18855 var methodNames = key in testableMethods ? testableMethods[key] : void 0;
18856 var isUntaintedMethods = Boolean(methodNames && methodNames.every(// @ts-expect-error 2345
18857 function(method) {
18858 var _a2;
18859 return typeof defaultPrototype[method] === "function" && ((_a2 = defaultPrototype[method]) == null ? void 0 : _a2.toString().includes("[native code]"));
18860 }));
18861 if (isUntaintedAccessors && isUntaintedMethods && !isAngularZonePresent()) {
18862 untaintedBasePrototype[key] = defaultObj.prototype;
18863 return defaultObj.prototype;
18864 }
18865 try {
18866 var iframeEl = document.createElement("iframe");
18867 document.body.appendChild(iframeEl);
18868 var win = iframeEl.contentWindow;
18869 if (!win) return defaultObj.prototype;
18870 var untaintedObject = win[key].prototype;
18871 document.body.removeChild(iframeEl);
18872 if (!untaintedObject) return defaultPrototype;
18873 return untaintedBasePrototype[key] = untaintedObject;
18874 } catch (e) {
18875 return defaultPrototype;
18876 }
18877 }
18878 var untaintedAccessorCache = {};
18879 function getUntaintedAccessor(key, instance, accessor) {
18880 var _a2;
18881 var cacheKey = key + "." + String(accessor);
18882 if (untaintedAccessorCache[cacheKey]) return untaintedAccessorCache[cacheKey].call(instance);
18883 var untaintedPrototype = getUntaintedPrototype(key);
18884 var untaintedAccessor = (_a2 = Object.getOwnPropertyDescriptor(untaintedPrototype, accessor)) == null ? void 0 : _a2.get;
18885 if (!untaintedAccessor) return instance[accessor];
18886 untaintedAccessorCache[cacheKey] = untaintedAccessor;
18887 return untaintedAccessor.call(instance);
18888 }
18889 var untaintedMethodCache = {};
18890 function getUntaintedMethod(key, instance, method) {
18891 var cacheKey = key + "." + String(method);
18892 if (untaintedMethodCache[cacheKey]) return untaintedMethodCache[cacheKey].bind(instance);
18893 var untaintedPrototype = getUntaintedPrototype(key);
18894 var untaintedMethod = untaintedPrototype[method];
18895 if (typeof untaintedMethod !== "function") return instance[method];
18896 untaintedMethodCache[cacheKey] = untaintedMethod;
18897 return untaintedMethod.bind(instance);
18898 }
18899 function childNodes(n2) {
18900 return getUntaintedAccessor("Node", n2, "childNodes");
18901 }
18902 function parentNode(n2) {
18903 return getUntaintedAccessor("Node", n2, "parentNode");
18904 }
18905 function parentElement(n2) {
18906 return getUntaintedAccessor("Node", n2, "parentElement");
18907 }
18908 function textContent(n2) {
18909 return getUntaintedAccessor("Node", n2, "textContent");
18910 }
18911 function contains(n2, other) {
18912 return getUntaintedMethod("Node", n2, "contains")(other);
18913 }
18914 function getRootNode(n2) {
18915 return getUntaintedMethod("Node", n2, "getRootNode")();
18916 }
18917 function host(n2) {
18918 if (!n2 || !("host" in n2)) return null;
18919 return getUntaintedAccessor("ShadowRoot", n2, "host");
18920 }
18921 function styleSheets(n2) {
18922 return n2.styleSheets;
18923 }
18924 function shadowRoot(n2) {
18925 if (!n2 || !("shadowRoot" in n2)) return null;
18926 return getUntaintedAccessor("Element", n2, "shadowRoot");
18927 }
18928 function querySelector(n2, selectors) {
18929 return getUntaintedAccessor("Element", n2, "querySelector")(selectors);
18930 }
18931 function querySelectorAll(n2, selectors) {
18932 return getUntaintedAccessor("Element", n2, "querySelectorAll")(selectors);
18933 }
18934 function mutationObserverCtor() {
18935 return getUntaintedPrototype("MutationObserver").constructor;
18936 }
18937 function patch(source, name, replacement) {
18938 try {
18939 if (!(name in source)) {
18940 return function() {};
18941 }
18942 var original = source[name];
18943 var wrapped = replacement(original);
18944 if (typeof wrapped === "function") {
18945 wrapped.prototype = wrapped.prototype || {};
18946 Object.defineProperties(wrapped, {
18947 __rrweb_original__: {
18948 enumerable: false,
18949 value: original
18950 }
18951 });
18952 }
18953 source[name] = wrapped;
18954 return function() {
18955 source[name] = original;
18956 };
18957 } catch (e) {
18958 return function() {};
18959 }
18960 }
18961 var index = {
18962 childNodes: childNodes,
18963 parentNode: parentNode,
18964 parentElement: parentElement,
18965 textContent: textContent,
18966 contains: contains,
18967 getRootNode: getRootNode,
18968 host: host,
18969 styleSheets: styleSheets,
18970 shadowRoot: shadowRoot,
18971 querySelector: querySelector,
18972 querySelectorAll: querySelectorAll,
18973 mutationObserver: mutationObserverCtor,
18974 patch: patch
18975 };
18976 function on(type, fn, target) {
18977 if (target === void 0) target = document;
18978 var options = {
18979 capture: true,
18980 passive: true
18981 };
18982 target.addEventListener(type, fn, options);
18983 return function() {
18984 return target.removeEventListener(type, fn, options);
18985 };
18986 }
18987 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.";
18988 var _mirror = {
18989 map: {},
18990 getId: function getId() {
18991 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18992 return -1;
18993 },
18994 getNode: function getNode() {
18995 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
18996 return null;
18997 },
18998 removeNodeFromMap: function removeNodeFromMap() {
18999 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19000 },
19001 has: function has() {
19002 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19003 return false;
19004 },
19005 reset: function reset() {
19006 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19007 }
19008 };
19009 if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
19010 _mirror = new Proxy(_mirror, {
19011 get: function get(target, prop, receiver) {
19012 if (prop === "map") {
19013 console.error(DEPARTED_MIRROR_ACCESS_WARNING);
19014 }
19015 return Reflect.get(target, prop, receiver);
19016 }
19017 });
19018 }
19019 function throttle(func, wait, options) {
19020 if (options === void 0) options = {};
19021 var timeout = null;
19022 var previous = 0;
19023 return function() {
19024 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
19025 args[_key] = arguments[_key];
19026 }
19027 var now = Date.now();
19028 if (!previous && options.leading === false) {
19029 previous = now;
19030 }
19031 var remaining = wait - (now - previous);
19032 var context = this;
19033 if (remaining <= 0 || remaining > wait) {
19034 if (timeout) {
19035 clearTimeout(timeout);
19036 timeout = null;
19037 }
19038 previous = now;
19039 func.apply(context, args);
19040 } else if (!timeout && options.trailing !== false) {
19041 timeout = setTimeout(function() {
19042 previous = options.leading === false ? 0 : Date.now();
19043 timeout = null;
19044 func.apply(context, args);
19045 }, remaining);
19046 }
19047 };
19048 }
19049 function hookSetter(target, key, d, isRevoked, win) {
19050 if (win === void 0) win = window;
19051 var original = win.Object.getOwnPropertyDescriptor(target, key);
19052 win.Object.defineProperty(target, key, isRevoked ? d : {
19053 set: function set(value) {
19054 var _this = this;
19055 setTimeout(function() {
19056 d.set.call(_this, value);
19057 }, 0);
19058 if (original && original.set) {
19059 original.set.call(this, value);
19060 }
19061 }
19062 });
19063 return function() {
19064 return hookSetter(target, key, original || {}, true);
19065 };
19066 }
19067 var nowTimestamp = Date.now;
19068 if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
19069 nowTimestamp = function() {
19070 return /* @__PURE__ */ new Date().getTime();
19071 };
19072 }
19073 function getWindowScroll(win) {
19074 var _a2, _b, _c, _d;
19075 var doc = win.document;
19076 return {
19077 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,
19078 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
19079 };
19080 }
19081 function getWindowHeight() {
19082 return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
19083 }
19084 function getWindowWidth() {
19085 return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
19086 }
19087 function closestElementOfNode(node2) {
19088 if (!node2) {
19089 return null;
19090 }
19091 var el = node2.nodeType === node2.ELEMENT_NODE ? node2 : index.parentElement(node2);
19092 return el;
19093 }
19094 function isBlocked(node2, blockClass, blockSelector, checkAncestors) {
19095 if (!node2) {
19096 return false;
19097 }
19098 var el = closestElementOfNode(node2);
19099 if (!el) {
19100 return false;
19101 }
19102 try {
19103 if (typeof blockClass === "string") {
19104 if (el.classList.contains(blockClass)) return true;
19105 if (checkAncestors && el.closest("." + blockClass) !== null) return true;
19106 } else {
19107 if (classMatchesRegex(el, blockClass, checkAncestors)) return true;
19108 }
19109 } catch (e2) {}
19110 if (blockSelector) {
19111 if (el.matches(blockSelector)) return true;
19112 if (checkAncestors && el.closest(blockSelector) !== null) return true;
19113 }
19114 return false;
19115 }
19116 function isSerialized(n2, mirror2) {
19117 return mirror2.getId(n2) !== -1;
19118 }
19119 function isIgnored(n2, mirror2, slimDOMOptions) {
19120 if (n2.tagName === "TITLE" && slimDOMOptions.headTitleMutations) {
19121 return true;
19122 }
19123 return mirror2.getId(n2) === IGNORED_NODE;
19124 }
19125 function isAncestorRemoved(target, mirror2) {
19126 if (isShadowRoot(target)) {
19127 return false;
19128 }
19129 var id = mirror2.getId(target);
19130 if (!mirror2.has(id)) {
19131 return true;
19132 }
19133 var parent = index.parentNode(target);
19134 if (parent && parent.nodeType === target.DOCUMENT_NODE) {
19135 return false;
19136 }
19137 if (!parent) {
19138 return true;
19139 }
19140 return isAncestorRemoved(parent, mirror2);
19141 }
19142 function legacy_isTouchEvent(event) {
19143 return Boolean(event.changedTouches);
19144 }
19145 function polyfill$1(win) {
19146 if (win === void 0) win = window;
19147 if ("NodeList" in win && !win.NodeList.prototype.forEach) {
19148 win.NodeList.prototype.forEach = Array.prototype.forEach;
19149 }
19150 if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
19151 win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
19152 }
19153 }
19154 function isSerializedIframe(n2, mirror2) {
19155 return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
19156 }
19157 function isSerializedStylesheet(n2, mirror2) {
19158 return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
19159 }
19160 function hasShadowRoot(n2) {
19161 if (!n2) return false;
19162 if (_instanceof(n2, BaseRRNode) && "shadowRoot" in n2) {
19163 return Boolean(n2.shadowRoot);
19164 }
19165 return Boolean(index.shadowRoot(n2));
19166 }
19167 var StyleSheetMirror = /*#__PURE__*/ function() {
19168 function StyleSheetMirror() {
19169 __publicField(this, "id", 1);
19170 __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
19171 __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
19172 }
19173 var _proto = StyleSheetMirror.prototype;
19174 _proto.getId = function getId(stylesheet) {
19175 var _this_styleIDMap_get;
19176 return (_this_styleIDMap_get = this.styleIDMap.get(stylesheet)) != null ? _this_styleIDMap_get : -1;
19177 };
19178 _proto.has = function has(stylesheet) {
19179 return this.styleIDMap.has(stylesheet);
19180 };
19181 /**
19182 * @returns If the stylesheet is in the mirror, returns the id of the stylesheet. If not, return the new assigned id.
19183 */ _proto.add = function add(stylesheet, id) {
19184 if (this.has(stylesheet)) return this.getId(stylesheet);
19185 var newId;
19186 if (id === void 0) {
19187 newId = this.id++;
19188 } else newId = id;
19189 this.styleIDMap.set(stylesheet, newId);
19190 this.idStyleMap.set(newId, stylesheet);
19191 return newId;
19192 };
19193 _proto.getStyle = function getStyle(id) {
19194 return this.idStyleMap.get(id) || null;
19195 };
19196 _proto.reset = function reset() {
19197 this.styleIDMap = /* @__PURE__ */ new WeakMap();
19198 this.idStyleMap = /* @__PURE__ */ new Map();
19199 this.id = 1;
19200 };
19201 _proto.generateId = function generateId() {
19202 return this.id++;
19203 };
19204 return StyleSheetMirror;
19205 }();
19206 function getShadowHost(n2) {
19207 var _a2;
19208 var shadowHost = null;
19209 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));
19210 return shadowHost;
19211 }
19212 function getRootShadowHost(n2) {
19213 var rootShadowHost = n2;
19214 var shadowHost;
19215 while(shadowHost = getShadowHost(rootShadowHost))rootShadowHost = shadowHost;
19216 return rootShadowHost;
19217 }
19218 function shadowHostInDom(n2) {
19219 var doc = n2.ownerDocument;
19220 if (!doc) return false;
19221 var shadowHost = getRootShadowHost(n2);
19222 return index.contains(doc, shadowHost);
19223 }
19224 function inDom(n2) {
19225 var doc = n2.ownerDocument;
19226 if (!doc) return false;
19227 return index.contains(doc, n2) || shadowHostInDom(n2);
19228 }
19229 var EventType = /* @__PURE__ */ function(EventType2) {
19230 EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
19231 EventType2[EventType2["Load"] = 1] = "Load";
19232 EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
19233 EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
19234 EventType2[EventType2["Meta"] = 4] = "Meta";
19235 EventType2[EventType2["Custom"] = 5] = "Custom";
19236 EventType2[EventType2["Plugin"] = 6] = "Plugin";
19237 return EventType2;
19238 }(EventType || {});
19239 var IncrementalSource = /* @__PURE__ */ function(IncrementalSource2) {
19240 IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
19241 IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
19242 IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
19243 IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
19244 IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
19245 IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
19246 IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
19247 IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
19248 IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
19249 IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
19250 IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
19251 IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
19252 IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
19253 IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
19254 IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
19255 IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
19256 IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
19257 return IncrementalSource2;
19258 }(IncrementalSource || {});
19259 var MouseInteractions = /* @__PURE__ */ function(MouseInteractions2) {
19260 MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
19261 MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
19262 MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
19263 MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
19264 MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
19265 MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
19266 MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
19267 MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
19268 MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
19269 MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
19270 MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
19271 return MouseInteractions2;
19272 }(MouseInteractions || {});
19273 var PointerTypes = /* @__PURE__ */ function(PointerTypes2) {
19274 PointerTypes2[PointerTypes2["Mouse"] = 0] = "Mouse";
19275 PointerTypes2[PointerTypes2["Pen"] = 1] = "Pen";
19276 PointerTypes2[PointerTypes2["Touch"] = 2] = "Touch";
19277 return PointerTypes2;
19278 }(PointerTypes || {});
19279 var CanvasContext = /* @__PURE__ */ function(CanvasContext2) {
19280 CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
19281 CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
19282 CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
19283 return CanvasContext2;
19284 }(CanvasContext || {});
19285 var MediaInteractions = /* @__PURE__ */ function(MediaInteractions2) {
19286 MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
19287 MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
19288 MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
19289 MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
19290 MediaInteractions2[MediaInteractions2["RateChange"] = 4] = "RateChange";
19291 return MediaInteractions2;
19292 }(MediaInteractions || {});
19293 var NodeType = /* @__PURE__ */ function(NodeType2) {
19294 NodeType2[NodeType2["Document"] = 0] = "Document";
19295 NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
19296 NodeType2[NodeType2["Element"] = 2] = "Element";
19297 NodeType2[NodeType2["Text"] = 3] = "Text";
19298 NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
19299 NodeType2[NodeType2["Comment"] = 5] = "Comment";
19300 return NodeType2;
19301 }(NodeType || {});
19302 function isNodeInLinkedList(n2) {
19303 return "__ln" in n2;
19304 }
19305 var DoubleLinkedList = /*#__PURE__*/ function() {
19306 function DoubleLinkedList() {
19307 __publicField(this, "length", 0);
19308 __publicField(this, "head", null);
19309 __publicField(this, "tail", null);
19310 }
19311 var _proto = DoubleLinkedList.prototype;
19312 _proto.get = function get(position) {
19313 if (position >= this.length) {
19314 throw new Error("Position outside of list range");
19315 }
19316 var current = this.head;
19317 for(var index2 = 0; index2 < position; index2++){
19318 current = (current == null ? void 0 : current.next) || null;
19319 }
19320 return current;
19321 };
19322 _proto.addNode = function addNode(n2) {
19323 var node2 = {
19324 value: n2,
19325 previous: null,
19326 next: null
19327 };
19328 n2.__ln = node2;
19329 if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
19330 var current = n2.previousSibling.__ln.next;
19331 node2.next = current;
19332 node2.previous = n2.previousSibling.__ln;
19333 n2.previousSibling.__ln.next = node2;
19334 if (current) {
19335 current.previous = node2;
19336 }
19337 } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
19338 var current1 = n2.nextSibling.__ln.previous;
19339 node2.previous = current1;
19340 node2.next = n2.nextSibling.__ln;
19341 n2.nextSibling.__ln.previous = node2;
19342 if (current1) {
19343 current1.next = node2;
19344 }
19345 } else {
19346 if (this.head) {
19347 this.head.previous = node2;
19348 }
19349 node2.next = this.head;
19350 this.head = node2;
19351 }
19352 if (node2.next === null) {
19353 this.tail = node2;
19354 }
19355 this.length++;
19356 };
19357 _proto.removeNode = function removeNode(n2) {
19358 var current = n2.__ln;
19359 if (!this.head) {
19360 return;
19361 }
19362 if (!current.previous) {
19363 this.head = current.next;
19364 if (this.head) {
19365 this.head.previous = null;
19366 } else {
19367 this.tail = null;
19368 }
19369 } else {
19370 current.previous.next = current.next;
19371 if (current.next) {
19372 current.next.previous = current.previous;
19373 } else {
19374 this.tail = current.previous;
19375 }
19376 }
19377 if (n2.__ln) {
19378 delete n2.__ln;
19379 }
19380 this.length--;
19381 };
19382 return DoubleLinkedList;
19383 }();
19384 var moveKey = function(id, parentId) {
19385 return id + "@" + parentId;
19386 };
19387 var MutationBuffer = /*#__PURE__*/ function() {
19388 function MutationBuffer() {
19389 var _this = this;
19390 __publicField(this, "frozen", false);
19391 __publicField(this, "locked", false);
19392 __publicField(this, "texts", []);
19393 __publicField(this, "attributes", []);
19394 __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
19395 __publicField(this, "removes", []);
19396 __publicField(this, "mapRemoves", []);
19397 __publicField(this, "movedMap", {});
19398 /**
19399 * the browser MutationObserver emits multiple mutations after
19400 * a delay for performance reasons, making tracing added nodes hard
19401 * in our `processMutations` callback function.
19402 * For example, if we append an element el_1 into body, and then append
19403 * another element el_2 into el_1, these two mutations may be passed to the
19404 * callback function together when the two operations were done.
19405 * Generally we need to trace child nodes of newly added nodes, but in this
19406 * case if we count el_2 as el_1's child node in the first mutation record,
19407 * then we will count el_2 again in the second mutation record which was
19408 * duplicated.
19409 * To avoid of duplicate counting added nodes, we use a Set to store
19410 * added nodes and its child nodes during iterate mutation records. Then
19411 * collect added nodes from the Set which have no duplicate copy. But
19412 * this also causes newly added nodes will not be serialized with id ASAP,
19413 * which means all the id related calculation should be lazy too.
19414 */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
19415 __publicField(this, "movedSet", /* @__PURE__ */ new Set());
19416 __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
19417 __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
19418 __publicField(this, "mutationCb");
19419 __publicField(this, "blockClass");
19420 __publicField(this, "blockSelector");
19421 __publicField(this, "maskTextClass");
19422 __publicField(this, "maskTextSelector");
19423 __publicField(this, "inlineStylesheet");
19424 __publicField(this, "maskInputOptions");
19425 __publicField(this, "maskTextFn");
19426 __publicField(this, "maskInputFn");
19427 __publicField(this, "keepIframeSrcFn");
19428 __publicField(this, "recordCanvas");
19429 __publicField(this, "inlineImages");
19430 __publicField(this, "slimDOMOptions");
19431 __publicField(this, "dataURLOptions");
19432 __publicField(this, "doc");
19433 __publicField(this, "mirror");
19434 __publicField(this, "iframeManager");
19435 __publicField(this, "stylesheetManager");
19436 __publicField(this, "shadowDomManager");
19437 __publicField(this, "canvasManager");
19438 __publicField(this, "processedNodeManager");
19439 __publicField(this, "unattachedDoc");
19440 __publicField(this, "processMutations", function(mutations) {
19441 mutations.forEach(_this.processMutation);
19442 _this.emit();
19443 });
19444 __publicField(this, "emit", function() {
19445 if (_this.frozen || _this.locked) {
19446 return;
19447 }
19448 var adds = [];
19449 var addedIds = /* @__PURE__ */ new Set();
19450 var addList = new DoubleLinkedList();
19451 var getNextId = function(n2) {
19452 var ns = n2;
19453 var nextId = IGNORED_NODE;
19454 while(nextId === IGNORED_NODE){
19455 ns = ns && ns.nextSibling;
19456 nextId = ns && _this.mirror.getId(ns);
19457 }
19458 return nextId;
19459 };
19460 var pushAdd = function(n2) {
19461 var parent = index.parentNode(n2);
19462 if (!parent || !inDom(n2)) {
19463 return;
19464 }
19465 var cssCaptured = false;
19466 if (n2.nodeType === Node.TEXT_NODE) {
19467 var parentTag = parent.tagName;
19468 if (parentTag === "TEXTAREA") {
19469 return;
19470 } else if (parentTag === "STYLE" && _this.addedSet.has(parent)) {
19471 cssCaptured = true;
19472 }
19473 }
19474 var parentId = isShadowRoot(parent) ? _this.mirror.getId(getShadowHost(n2)) : _this.mirror.getId(parent);
19475 var nextId = getNextId(n2);
19476 if (parentId === -1 || nextId === -1) {
19477 return addList.addNode(n2);
19478 }
19479 var sn = serializeNodeWithId(n2, {
19480 doc: _this.doc,
19481 mirror: _this.mirror,
19482 blockClass: _this.blockClass,
19483 blockSelector: _this.blockSelector,
19484 maskTextClass: _this.maskTextClass,
19485 maskTextSelector: _this.maskTextSelector,
19486 skipChild: true,
19487 newlyAddedElement: true,
19488 inlineStylesheet: _this.inlineStylesheet,
19489 maskInputOptions: _this.maskInputOptions,
19490 maskTextFn: _this.maskTextFn,
19491 maskInputFn: _this.maskInputFn,
19492 slimDOMOptions: _this.slimDOMOptions,
19493 dataURLOptions: _this.dataURLOptions,
19494 recordCanvas: _this.recordCanvas,
19495 inlineImages: _this.inlineImages,
19496 onSerialize: function(currentN) {
19497 if (isSerializedIframe(currentN, _this.mirror)) {
19498 _this.iframeManager.addIframe(currentN);
19499 }
19500 if (isSerializedStylesheet(currentN, _this.mirror)) {
19501 _this.stylesheetManager.trackLinkElement(currentN);
19502 }
19503 if (hasShadowRoot(n2)) {
19504 _this.shadowDomManager.addShadowRoot(index.shadowRoot(n2), _this.doc);
19505 }
19506 },
19507 onIframeLoad: function(iframe, childSn) {
19508 _this.iframeManager.attachIframe(iframe, childSn);
19509 _this.shadowDomManager.observeAttachShadow(iframe);
19510 },
19511 onStylesheetLoad: function(link, childSn) {
19512 _this.stylesheetManager.attachLinkElement(link, childSn);
19513 },
19514 cssCaptured: cssCaptured
19515 });
19516 if (sn) {
19517 adds.push({
19518 parentId: parentId,
19519 nextId: nextId,
19520 node: sn
19521 });
19522 addedIds.add(sn.id);
19523 }
19524 };
19525 while(_this.mapRemoves.length){
19526 _this.mirror.removeNodeFromMap(_this.mapRemoves.shift());
19527 }
19528 for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
19529 var n2 = _step.value;
19530 if (isParentRemoved(_this.removesSubTreeCache, n2, _this.mirror) && !_this.movedSet.has(index.parentNode(n2))) {
19531 continue;
19532 }
19533 pushAdd(n2);
19534 }
19535 for(var _iterator1 = _create_for_of_iterator_helper_loose(_this.addedSet), _step1; !(_step1 = _iterator1()).done;){
19536 var n21 = _step1.value;
19537 if (!isAncestorInSet(_this.droppedSet, n21) && !isParentRemoved(_this.removesSubTreeCache, n21, _this.mirror)) {
19538 pushAdd(n21);
19539 } else if (isAncestorInSet(_this.movedSet, n21)) {
19540 pushAdd(n21);
19541 } else {
19542 _this.droppedSet.add(n21);
19543 }
19544 }
19545 var candidate = null;
19546 while(addList.length){
19547 var node2 = null;
19548 if (candidate) {
19549 var parentId = _this.mirror.getId(index.parentNode(candidate.value));
19550 var nextId = getNextId(candidate.value);
19551 if (parentId !== -1 && nextId !== -1) {
19552 node2 = candidate;
19553 }
19554 }
19555 if (!node2) {
19556 var tailNode = addList.tail;
19557 while(tailNode){
19558 var _node = tailNode;
19559 tailNode = tailNode.previous;
19560 if (_node) {
19561 var parentId1 = _this.mirror.getId(index.parentNode(_node.value));
19562 var nextId1 = getNextId(_node.value);
19563 if (nextId1 === -1) continue;
19564 else if (parentId1 !== -1) {
19565 node2 = _node;
19566 break;
19567 } else {
19568 var unhandledNode = _node.value;
19569 var parent = index.parentNode(unhandledNode);
19570 if (parent && parent.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
19571 var shadowHost = index.host(parent);
19572 var parentId2 = _this.mirror.getId(shadowHost);
19573 if (parentId2 !== -1) {
19574 node2 = _node;
19575 break;
19576 }
19577 }
19578 }
19579 }
19580 }
19581 }
19582 if (!node2) {
19583 while(addList.head){
19584 addList.removeNode(addList.head.value);
19585 }
19586 break;
19587 }
19588 candidate = node2.previous;
19589 addList.removeNode(node2.value);
19590 pushAdd(node2.value);
19591 }
19592 var payload = {
19593 texts: _this.texts.map(function(text) {
19594 var n2 = text.node;
19595 var parent = index.parentNode(n2);
19596 if (parent && parent.tagName === "TEXTAREA") {
19597 _this.genTextAreaValueMutation(parent);
19598 }
19599 return {
19600 id: _this.mirror.getId(n2),
19601 value: text.value
19602 };
19603 }).filter(function(text) {
19604 return !addedIds.has(text.id);
19605 }).filter(function(text) {
19606 return _this.mirror.has(text.id);
19607 }),
19608 attributes: _this.attributes.map(function(attribute) {
19609 var attributes = attribute.attributes;
19610 if (typeof attributes.style === "string") {
19611 var diffAsStr = JSON.stringify(attribute.styleDiff);
19612 var unchangedAsStr = JSON.stringify(attribute._unchangedStyles);
19613 if (diffAsStr.length < attributes.style.length) {
19614 if ((diffAsStr + unchangedAsStr).split("var(").length === attributes.style.split("var(").length) {
19615 attributes.style = attribute.styleDiff;
19616 }
19617 }
19618 }
19619 return {
19620 id: _this.mirror.getId(attribute.node),
19621 attributes: attributes
19622 };
19623 }).filter(function(attribute) {
19624 return !addedIds.has(attribute.id);
19625 }).filter(function(attribute) {
19626 return _this.mirror.has(attribute.id);
19627 }),
19628 removes: _this.removes,
19629 adds: adds
19630 };
19631 if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
19632 return;
19633 }
19634 _this.texts = [];
19635 _this.attributes = [];
19636 _this.attributeMap = /* @__PURE__ */ new WeakMap();
19637 _this.removes = [];
19638 _this.addedSet = /* @__PURE__ */ new Set();
19639 _this.movedSet = /* @__PURE__ */ new Set();
19640 _this.droppedSet = /* @__PURE__ */ new Set();
19641 _this.removesSubTreeCache = /* @__PURE__ */ new Set();
19642 _this.movedMap = {};
19643 _this.mutationCb(payload);
19644 });
19645 __publicField(this, "genTextAreaValueMutation", function(textarea) {
19646 var item = _this.attributeMap.get(textarea);
19647 if (!item) {
19648 item = {
19649 node: textarea,
19650 attributes: {},
19651 styleDiff: {},
19652 _unchangedStyles: {}
19653 };
19654 _this.attributes.push(item);
19655 _this.attributeMap.set(textarea, item);
19656 }
19657 var value = Array.from(index.childNodes(textarea), function(cn) {
19658 return index.textContent(cn) || "";
19659 }).join("");
19660 item.attributes.value = maskInputValue({
19661 element: textarea,
19662 maskInputOptions: _this.maskInputOptions,
19663 tagName: textarea.tagName,
19664 type: getInputType(textarea),
19665 value: value,
19666 maskInputFn: _this.maskInputFn
19667 });
19668 });
19669 __publicField(this, "processMutation", function(m) {
19670 if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
19671 return;
19672 }
19673 switch(m.type){
19674 case "characterData":
19675 {
19676 var value = index.textContent(m.target);
19677 if (!isBlocked(m.target, _this.blockClass, _this.blockSelector, false) && value !== m.oldValue) {
19678 _this.texts.push({
19679 value: needMaskingText(m.target, _this.maskTextClass, _this.maskTextSelector, true) && value ? _this.maskTextFn ? _this.maskTextFn(value, closestElementOfNode(m.target)) : value.replace(/[\S]/g, "*") : value,
19680 node: m.target
19681 });
19682 }
19683 break;
19684 }
19685 case "attributes":
19686 {
19687 var target = m.target;
19688 var attributeName = m.attributeName;
19689 var value1 = m.target.getAttribute(attributeName);
19690 if (attributeName === "value") {
19691 var type = getInputType(target);
19692 value1 = maskInputValue({
19693 element: target,
19694 maskInputOptions: _this.maskInputOptions,
19695 tagName: target.tagName,
19696 type: type,
19697 value: value1,
19698 maskInputFn: _this.maskInputFn
19699 });
19700 }
19701 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || value1 === m.oldValue) {
19702 return;
19703 }
19704 var item = _this.attributeMap.get(m.target);
19705 if (target.tagName === "IFRAME" && attributeName === "src" && !_this.keepIframeSrcFn(value1)) {
19706 if (!target.contentDocument) {
19707 attributeName = "rr_src";
19708 } else {
19709 return;
19710 }
19711 }
19712 if (!item) {
19713 item = {
19714 node: m.target,
19715 attributes: {},
19716 styleDiff: {},
19717 _unchangedStyles: {}
19718 };
19719 _this.attributes.push(item);
19720 _this.attributeMap.set(m.target, item);
19721 }
19722 if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
19723 target.setAttribute("data-rr-is-password", "true");
19724 }
19725 if (!ignoreAttribute(target.tagName, attributeName)) {
19726 item.attributes[attributeName] = transformAttribute(_this.doc, toLowerCase(target.tagName), toLowerCase(attributeName), value1);
19727 if (attributeName === "style") {
19728 if (!_this.unattachedDoc) {
19729 try {
19730 _this.unattachedDoc = document.implementation.createHTMLDocument();
19731 } catch (e2) {
19732 _this.unattachedDoc = _this.doc;
19733 }
19734 }
19735 var old = _this.unattachedDoc.createElement("span");
19736 if (m.oldValue) {
19737 old.setAttribute("style", m.oldValue);
19738 }
19739 for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(target.style)), _step; !(_step = _iterator()).done;){
19740 var pname = _step.value;
19741 var newValue = target.style.getPropertyValue(pname);
19742 var newPriority = target.style.getPropertyPriority(pname);
19743 if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
19744 if (newPriority === "") {
19745 item.styleDiff[pname] = newValue;
19746 } else {
19747 item.styleDiff[pname] = [
19748 newValue,
19749 newPriority
19750 ];
19751 }
19752 } else {
19753 item._unchangedStyles[pname] = [
19754 newValue,
19755 newPriority
19756 ];
19757 }
19758 }
19759 for(var _iterator1 = _create_for_of_iterator_helper_loose(Array.from(old.style)), _step1; !(_step1 = _iterator1()).done;){
19760 var pname1 = _step1.value;
19761 if (target.style.getPropertyValue(pname1) === "") {
19762 item.styleDiff[pname1] = false;
19763 }
19764 }
19765 } else if (attributeName === "open" && target.tagName === "DIALOG") {
19766 if (target.matches("dialog:modal")) {
19767 item.attributes["rr_open_mode"] = "modal";
19768 } else {
19769 item.attributes["rr_open_mode"] = "non-modal";
19770 }
19771 }
19772 }
19773 break;
19774 }
19775 case "childList":
19776 {
19777 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, true)) return;
19778 if (m.target.tagName === "TEXTAREA") {
19779 _this.genTextAreaValueMutation(m.target);
19780 return;
19781 }
19782 m.addedNodes.forEach(function(n2) {
19783 return _this.genAdds(n2, m.target);
19784 });
19785 m.removedNodes.forEach(function(n2) {
19786 var nodeId = _this.mirror.getId(n2);
19787 var parentId = isShadowRoot(m.target) ? _this.mirror.getId(index.host(m.target)) : _this.mirror.getId(m.target);
19788 if (isBlocked(m.target, _this.blockClass, _this.blockSelector, false) || isIgnored(n2, _this.mirror, _this.slimDOMOptions) || !isSerialized(n2, _this.mirror)) {
19789 return;
19790 }
19791 if (_this.addedSet.has(n2)) {
19792 deepDelete(_this.addedSet, n2);
19793 _this.droppedSet.add(n2);
19794 } else if (_this.addedSet.has(m.target) && nodeId === -1) ;
19795 else if (isAncestorRemoved(m.target, _this.mirror)) ;
19796 else if (_this.movedSet.has(n2) && _this.movedMap[moveKey(nodeId, parentId)]) {
19797 deepDelete(_this.movedSet, n2);
19798 } else {
19799 _this.removes.push({
19800 parentId: parentId,
19801 id: nodeId,
19802 isShadow: isShadowRoot(m.target) && isNativeShadowDom(m.target) ? true : void 0
19803 });
19804 processRemoves(n2, _this.removesSubTreeCache);
19805 }
19806 _this.mapRemoves.push(n2);
19807 });
19808 break;
19809 }
19810 }
19811 });
19812 /**
19813 * Make sure you check if `n`'s parent is blocked before calling this function
19814 * */ __publicField(this, "genAdds", function(n2, target) {
19815 if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
19816 if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
19817 if (_this.mirror.hasNode(n2)) {
19818 if (isIgnored(n2, _this.mirror, _this.slimDOMOptions)) {
19819 return;
19820 }
19821 _this.movedSet.add(n2);
19822 var targetId = null;
19823 if (target && _this.mirror.hasNode(target)) {
19824 targetId = _this.mirror.getId(target);
19825 }
19826 if (targetId && targetId !== -1) {
19827 _this.movedMap[moveKey(_this.mirror.getId(n2), targetId)] = true;
19828 }
19829 } else {
19830 _this.addedSet.add(n2);
19831 _this.droppedSet.delete(n2);
19832 }
19833 if (!isBlocked(n2, _this.blockClass, _this.blockSelector, false)) {
19834 index.childNodes(n2).forEach(function(childN) {
19835 return _this.genAdds(childN);
19836 });
19837 if (hasShadowRoot(n2)) {
19838 index.childNodes(index.shadowRoot(n2)).forEach(function(childN) {
19839 _this.processedNodeManager.add(childN, _this);
19840 _this.genAdds(childN, n2);
19841 });
19842 }
19843 }
19844 });
19845 }
19846 var _proto = MutationBuffer.prototype;
19847 _proto.init = function init(options) {
19848 var _this = this;
19849 [
19850 "mutationCb",
19851 "blockClass",
19852 "blockSelector",
19853 "maskTextClass",
19854 "maskTextSelector",
19855 "inlineStylesheet",
19856 "maskInputOptions",
19857 "maskTextFn",
19858 "maskInputFn",
19859 "keepIframeSrcFn",
19860 "recordCanvas",
19861 "inlineImages",
19862 "slimDOMOptions",
19863 "dataURLOptions",
19864 "doc",
19865 "mirror",
19866 "iframeManager",
19867 "stylesheetManager",
19868 "shadowDomManager",
19869 "canvasManager",
19870 "processedNodeManager"
19871 ].forEach(function(key) {
19872 _this[key] = options[key];
19873 });
19874 };
19875 _proto.freeze = function freeze() {
19876 this.frozen = true;
19877 this.canvasManager.freeze();
19878 };
19879 _proto.unfreeze = function unfreeze() {
19880 this.frozen = false;
19881 this.canvasManager.unfreeze();
19882 this.emit();
19883 };
19884 _proto.isFrozen = function isFrozen() {
19885 return this.frozen;
19886 };
19887 _proto.lock = function lock() {
19888 this.locked = true;
19889 this.canvasManager.lock();
19890 };
19891 _proto.unlock = function unlock() {
19892 this.locked = false;
19893 this.canvasManager.unlock();
19894 this.emit();
19895 };
19896 _proto.reset = function reset() {
19897 this.shadowDomManager.reset();
19898 this.canvasManager.reset();
19899 };
19900 return MutationBuffer;
19901 }();
19902 function deepDelete(addsSet, n2) {
19903 addsSet.delete(n2);
19904 index.childNodes(n2).forEach(function(childN) {
19905 return deepDelete(addsSet, childN);
19906 });
19907 }
19908 function processRemoves(n2, cache) {
19909 var queue = [
19910 n2
19911 ];
19912 while(queue.length){
19913 var next = queue.pop();
19914 if (cache.has(next)) continue;
19915 cache.add(next);
19916 index.childNodes(next).forEach(function(n22) {
19917 return queue.push(n22);
19918 });
19919 }
19920 return;
19921 }
19922 function isParentRemoved(removes, n2, mirror2) {
19923 if (removes.size === 0) return false;
19924 return _isParentRemoved(removes, n2);
19925 }
19926 function _isParentRemoved(removes, n2, _mirror2) {
19927 var node2 = index.parentNode(n2);
19928 if (!node2) return false;
19929 return removes.has(node2);
19930 }
19931 function isAncestorInSet(set, n2) {
19932 if (set.size === 0) return false;
19933 return _isAncestorInSet(set, n2);
19934 }
19935 function _isAncestorInSet(set, n2) {
19936 var parent = index.parentNode(n2);
19937 if (!parent) {
19938 return false;
19939 }
19940 if (set.has(parent)) {
19941 return true;
19942 }
19943 return _isAncestorInSet(set, parent);
19944 }
19945 var errorHandler;
19946 function registerErrorHandler(handler) {
19947 errorHandler = handler;
19948 }
19949 function unregisterErrorHandler() {
19950 errorHandler = void 0;
19951 }
19952 var callbackWrapper = function(cb) {
19953 if (!errorHandler) {
19954 return cb;
19955 }
19956 var rrwebWrapped = function() {
19957 for(var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++){
19958 rest[_key] = arguments[_key];
19959 }
19960 try {
19961 return cb.apply(void 0, [].concat(rest));
19962 } catch (error) {
19963 if (errorHandler && errorHandler(error) === true) {
19964 return;
19965 }
19966 throw error;
19967 }
19968 };
19969 return rrwebWrapped;
19970 };
19971 var mutationBuffers = [];
19972 function getEventTarget(event) {
19973 try {
19974 if ("composedPath" in event) {
19975 var path = event.composedPath();
19976 if (path.length) {
19977 return path[0];
19978 }
19979 } else if ("path" in event && event.path.length) {
19980 return event.path[0];
19981 }
19982 } catch (e) {}
19983 return event && event.target;
19984 }
19985 function initMutationObserver(options, rootEl) {
19986 var mutationBuffer = new MutationBuffer();
19987 mutationBuffers.push(mutationBuffer);
19988 mutationBuffer.init(options);
19989 var observer = new (mutationObserverCtor())(callbackWrapper(mutationBuffer.processMutations.bind(mutationBuffer)));
19990 observer.observe(rootEl, {
19991 attributes: true,
19992 attributeOldValue: true,
19993 characterData: true,
19994 characterDataOldValue: true,
19995 childList: true,
19996 subtree: true
19997 });
19998 return observer;
19999 }
20000 function initMoveObserver(param) {
20001 var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
20002 if (sampling.mousemove === false) {
20003 return function() {};
20004 }
20005 var threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
20006 var callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
20007 var positions = [];
20008 var timeBaseline;
20009 var wrappedCb = throttle(callbackWrapper(function(source) {
20010 var totalOffset = Date.now() - timeBaseline;
20011 mousemoveCb(positions.map(function(p) {
20012 p.timeOffset -= totalOffset;
20013 return p;
20014 }), source);
20015 positions = [];
20016 timeBaseline = null;
20017 }), callbackThreshold);
20018 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20019 var target = getEventTarget(evt);
20020 var _ref = legacy_isTouchEvent(evt) ? evt.changedTouches[0] : evt, clientX = _ref.clientX, clientY = _ref.clientY;
20021 if (!timeBaseline) {
20022 timeBaseline = nowTimestamp();
20023 }
20024 positions.push({
20025 x: clientX,
20026 y: clientY,
20027 id: mirror2.getId(target),
20028 timeOffset: nowTimestamp() - timeBaseline
20029 });
20030 wrappedCb(typeof DragEvent !== "undefined" && _instanceof(evt, DragEvent) ? IncrementalSource.Drag : _instanceof(evt, MouseEvent) ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
20031 }), threshold, {
20032 trailing: false
20033 }));
20034 var handlers = [
20035 on("mousemove", updatePosition, doc),
20036 on("touchmove", updatePosition, doc),
20037 on("drag", updatePosition, doc)
20038 ];
20039 return callbackWrapper(function() {
20040 handlers.forEach(function(h) {
20041 return h();
20042 });
20043 });
20044 }
20045 function initMouseInteractionObserver(param) {
20046 var mouseInteractionCb = param.mouseInteractionCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20047 if (sampling.mouseInteraction === false) {
20048 return function() {};
20049 }
20050 var disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
20051 var handlers = [];
20052 var currentPointerType = null;
20053 var getHandler = function(eventKey) {
20054 return function(event) {
20055 var target = getEventTarget(event);
20056 if (isBlocked(target, blockClass, blockSelector, true)) {
20057 return;
20058 }
20059 var pointerType = null;
20060 var thisEventKey = eventKey;
20061 if ("pointerType" in event) {
20062 switch(event.pointerType){
20063 case "mouse":
20064 pointerType = PointerTypes.Mouse;
20065 break;
20066 case "touch":
20067 pointerType = PointerTypes.Touch;
20068 break;
20069 case "pen":
20070 pointerType = PointerTypes.Pen;
20071 break;
20072 }
20073 if (pointerType === PointerTypes.Touch) {
20074 if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {
20075 thisEventKey = "TouchStart";
20076 } else if (MouseInteractions[eventKey] === MouseInteractions.MouseUp) {
20077 thisEventKey = "TouchEnd";
20078 }
20079 } else if (pointerType === PointerTypes.Pen) ;
20080 } else if (legacy_isTouchEvent(event)) {
20081 pointerType = PointerTypes.Touch;
20082 }
20083 if (pointerType !== null) {
20084 currentPointerType = pointerType;
20085 if (thisEventKey.startsWith("Touch") && pointerType === PointerTypes.Touch || thisEventKey.startsWith("Mouse") && pointerType === PointerTypes.Mouse) {
20086 pointerType = null;
20087 }
20088 } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {
20089 pointerType = currentPointerType;
20090 currentPointerType = null;
20091 }
20092 var e2 = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;
20093 if (!e2) {
20094 return;
20095 }
20096 var id = mirror2.getId(target);
20097 var clientX = e2.clientX, clientY = e2.clientY;
20098 callbackWrapper(mouseInteractionCb)(_extends({
20099 type: MouseInteractions[thisEventKey],
20100 id: id,
20101 x: clientX,
20102 y: clientY
20103 }, pointerType !== null && {
20104 pointerType: pointerType
20105 }));
20106 };
20107 };
20108 Object.keys(MouseInteractions).filter(function(key) {
20109 return Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false;
20110 }).forEach(function(eventKey) {
20111 var eventName = toLowerCase(eventKey);
20112 var handler = getHandler(eventKey);
20113 if (window.PointerEvent) {
20114 switch(MouseInteractions[eventKey]){
20115 case MouseInteractions.MouseDown:
20116 case MouseInteractions.MouseUp:
20117 eventName = eventName.replace("mouse", "pointer");
20118 break;
20119 case MouseInteractions.TouchStart:
20120 case MouseInteractions.TouchEnd:
20121 return;
20122 }
20123 }
20124 handlers.push(on(eventName, handler, doc));
20125 });
20126 return callbackWrapper(function() {
20127 handlers.forEach(function(h) {
20128 return h();
20129 });
20130 });
20131 }
20132 function initScrollObserver(param) {
20133 var scrollCb = param.scrollCb, doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, sampling = param.sampling;
20134 var updatePosition = callbackWrapper(throttle(callbackWrapper(function(evt) {
20135 var target = getEventTarget(evt);
20136 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20137 return;
20138 }
20139 var id = mirror2.getId(target);
20140 if (target === doc && doc.defaultView) {
20141 var scrollLeftTop = getWindowScroll(doc.defaultView);
20142 scrollCb({
20143 id: id,
20144 x: scrollLeftTop.left,
20145 y: scrollLeftTop.top
20146 });
20147 } else {
20148 scrollCb({
20149 id: id,
20150 x: target.scrollLeft,
20151 y: target.scrollTop
20152 });
20153 }
20154 }), sampling.scroll || 100));
20155 return on("scroll", updatePosition, doc);
20156 }
20157 function initViewportResizeObserver(param, param1) {
20158 var viewportResizeCb = param.viewportResizeCb;
20159 var win = param1.win;
20160 var lastH = -1;
20161 var lastW = -1;
20162 var updateDimension = callbackWrapper(throttle(callbackWrapper(function() {
20163 var height = getWindowHeight();
20164 var width = getWindowWidth();
20165 if (lastH !== height || lastW !== width) {
20166 viewportResizeCb({
20167 width: Number(width),
20168 height: Number(height)
20169 });
20170 lastH = height;
20171 lastW = width;
20172 }
20173 }), 200));
20174 return on("resize", updateDimension, win);
20175 }
20176 var INPUT_TAGS = [
20177 "INPUT",
20178 "TEXTAREA",
20179 "SELECT"
20180 ];
20181 var lastInputValueMap = /* @__PURE__ */ new WeakMap();
20182 function initInputObserver(param) {
20183 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;
20184 function eventHandler(event) {
20185 var target = getEventTarget(event);
20186 var userTriggered = event.isTrusted;
20187 var tagName = target && target.tagName;
20188 if (target && tagName === "OPTION") {
20189 target = index.parentElement(target);
20190 }
20191 if (!target || !tagName || INPUT_TAGS.indexOf(tagName) < 0 || isBlocked(target, blockClass, blockSelector, true)) {
20192 return;
20193 }
20194 if (target.classList.contains(ignoreClass) || ignoreSelector && target.matches(ignoreSelector)) {
20195 return;
20196 }
20197 var text = target.value;
20198 var isChecked = false;
20199 var type = getInputType(target) || "";
20200 if (type === "radio" || type === "checkbox") {
20201 isChecked = target.checked;
20202 } else if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
20203 text = maskInputValue({
20204 element: target,
20205 maskInputOptions: maskInputOptions,
20206 tagName: tagName,
20207 type: type,
20208 value: text,
20209 maskInputFn: maskInputFn
20210 });
20211 }
20212 cbWithDedup(target, userTriggeredOnInput ? {
20213 text: text,
20214 isChecked: isChecked,
20215 userTriggered: userTriggered
20216 } : {
20217 text: text,
20218 isChecked: isChecked
20219 });
20220 var name = target.name;
20221 if (type === "radio" && name && isChecked) {
20222 doc.querySelectorAll('input[type="radio"][name="' + name + '"]').forEach(function(el) {
20223 if (el !== target) {
20224 var text2 = el.value;
20225 cbWithDedup(el, userTriggeredOnInput ? {
20226 text: text2,
20227 isChecked: !isChecked,
20228 userTriggered: false
20229 } : {
20230 text: text2,
20231 isChecked: !isChecked
20232 });
20233 }
20234 });
20235 }
20236 }
20237 function cbWithDedup(target, v2) {
20238 var lastInputValue = lastInputValueMap.get(target);
20239 if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
20240 lastInputValueMap.set(target, v2);
20241 var id = mirror2.getId(target);
20242 callbackWrapper(inputCb)(_extends({}, v2, {
20243 id: id
20244 }));
20245 }
20246 }
20247 var events = sampling.input === "last" ? [
20248 "change"
20249 ] : [
20250 "input",
20251 "change"
20252 ];
20253 var handlers = events.map(function(eventName) {
20254 return on(eventName, callbackWrapper(eventHandler), doc);
20255 });
20256 var currentWindow = doc.defaultView;
20257 if (!currentWindow) {
20258 return function() {
20259 handlers.forEach(function(h) {
20260 return h();
20261 });
20262 };
20263 }
20264 var propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(currentWindow.HTMLInputElement.prototype, "value");
20265 var hookProperties = [
20266 [
20267 currentWindow.HTMLInputElement.prototype,
20268 "value"
20269 ],
20270 [
20271 currentWindow.HTMLInputElement.prototype,
20272 "checked"
20273 ],
20274 [
20275 currentWindow.HTMLSelectElement.prototype,
20276 "value"
20277 ],
20278 [
20279 currentWindow.HTMLTextAreaElement.prototype,
20280 "value"
20281 ],
20282 // Some UI library use selectedIndex to set select value
20283 [
20284 currentWindow.HTMLSelectElement.prototype,
20285 "selectedIndex"
20286 ],
20287 [
20288 currentWindow.HTMLOptionElement.prototype,
20289 "selected"
20290 ]
20291 ];
20292 if (propertyDescriptor && propertyDescriptor.set) {
20293 var _handlers;
20294 (_handlers = handlers).push.apply(_handlers, [].concat(hookProperties.map(function(p) {
20295 return hookSetter(p[0], p[1], {
20296 set: function set() {
20297 callbackWrapper(eventHandler)({
20298 target: this,
20299 isTrusted: false
20300 });
20301 }
20302 }, false, currentWindow);
20303 })));
20304 }
20305 return callbackWrapper(function() {
20306 handlers.forEach(function(h) {
20307 return h();
20308 });
20309 });
20310 }
20311 function getNestedCSSRulePositions(rule2) {
20312 var positions = [];
20313 function recurse(childRule, pos) {
20314 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)) {
20315 var rules2 = Array.from(childRule.parentRule.cssRules);
20316 var index2 = rules2.indexOf(childRule);
20317 pos.unshift(index2);
20318 } else if (childRule.parentStyleSheet) {
20319 var rules21 = Array.from(childRule.parentStyleSheet.cssRules);
20320 var index21 = rules21.indexOf(childRule);
20321 pos.unshift(index21);
20322 }
20323 return pos;
20324 }
20325 return recurse(rule2, positions);
20326 }
20327 function getIdAndStyleId(sheet, mirror2, styleMirror) {
20328 var id, styleId;
20329 if (!sheet) return {};
20330 if (sheet.ownerNode) id = mirror2.getId(sheet.ownerNode);
20331 else styleId = styleMirror.getId(sheet);
20332 return {
20333 styleId: styleId,
20334 id: id
20335 };
20336 }
20337 function initStyleSheetObserver(param, param1) {
20338 var styleSheetRuleCb = param.styleSheetRuleCb, mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20339 var win = param1.win;
20340 if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {
20341 return function() {};
20342 }
20343 var insertRule = win.CSSStyleSheet.prototype.insertRule;
20344 win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {
20345 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20346 var rule2 = argumentsList[0], index2 = argumentsList[1];
20347 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20348 if (id && id !== -1 || styleId && styleId !== -1) {
20349 styleSheetRuleCb({
20350 id: id,
20351 styleId: styleId,
20352 adds: [
20353 {
20354 rule: rule2,
20355 index: index2
20356 }
20357 ]
20358 });
20359 }
20360 return target.apply(thisArg, argumentsList);
20361 })
20362 });
20363 win.CSSStyleSheet.prototype.addRule = function(selector, styleBlock, index2) {
20364 if (index2 === void 0) index2 = this.cssRules.length;
20365 var rule2 = selector + " { " + styleBlock + " }";
20366 return win.CSSStyleSheet.prototype.insertRule.apply(this, [
20367 rule2,
20368 index2
20369 ]);
20370 };
20371 var deleteRule = win.CSSStyleSheet.prototype.deleteRule;
20372 win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {
20373 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20374 var index2 = argumentsList[0];
20375 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20376 if (id && id !== -1 || styleId && styleId !== -1) {
20377 styleSheetRuleCb({
20378 id: id,
20379 styleId: styleId,
20380 removes: [
20381 {
20382 index: index2
20383 }
20384 ]
20385 });
20386 }
20387 return target.apply(thisArg, argumentsList);
20388 })
20389 });
20390 win.CSSStyleSheet.prototype.removeRule = function(index2) {
20391 return win.CSSStyleSheet.prototype.deleteRule.apply(this, [
20392 index2
20393 ]);
20394 };
20395 var replace;
20396 if (win.CSSStyleSheet.prototype.replace) {
20397 replace = win.CSSStyleSheet.prototype.replace;
20398 win.CSSStyleSheet.prototype.replace = new Proxy(replace, {
20399 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20400 var text = argumentsList[0];
20401 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20402 if (id && id !== -1 || styleId && styleId !== -1) {
20403 styleSheetRuleCb({
20404 id: id,
20405 styleId: styleId,
20406 replace: text
20407 });
20408 }
20409 return target.apply(thisArg, argumentsList);
20410 })
20411 });
20412 }
20413 var replaceSync;
20414 if (win.CSSStyleSheet.prototype.replaceSync) {
20415 replaceSync = win.CSSStyleSheet.prototype.replaceSync;
20416 win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {
20417 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20418 var text = argumentsList[0];
20419 var _getIdAndStyleId = getIdAndStyleId(thisArg, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20420 if (id && id !== -1 || styleId && styleId !== -1) {
20421 styleSheetRuleCb({
20422 id: id,
20423 styleId: styleId,
20424 replaceSync: text
20425 });
20426 }
20427 return target.apply(thisArg, argumentsList);
20428 })
20429 });
20430 }
20431 var supportedNestedCSSRuleTypes = {};
20432 if (canMonkeyPatchNestedCSSRule("CSSGroupingRule")) {
20433 supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
20434 } else {
20435 if (canMonkeyPatchNestedCSSRule("CSSMediaRule")) {
20436 supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
20437 }
20438 if (canMonkeyPatchNestedCSSRule("CSSConditionRule")) {
20439 supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
20440 }
20441 if (canMonkeyPatchNestedCSSRule("CSSSupportsRule")) {
20442 supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
20443 }
20444 }
20445 var unmodifiedFunctions = {};
20446 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20447 var typeKey = param[0], type = param[1];
20448 unmodifiedFunctions[typeKey] = {
20449 // eslint-disable-next-line @typescript-eslint/unbound-method
20450 insertRule: type.prototype.insertRule,
20451 // eslint-disable-next-line @typescript-eslint/unbound-method
20452 deleteRule: type.prototype.deleteRule
20453 };
20454 type.prototype.insertRule = new Proxy(unmodifiedFunctions[typeKey].insertRule, {
20455 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20456 var rule2 = argumentsList[0], index2 = argumentsList[1];
20457 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20458 if (id && id !== -1 || styleId && styleId !== -1) {
20459 styleSheetRuleCb({
20460 id: id,
20461 styleId: styleId,
20462 adds: [
20463 {
20464 rule: rule2,
20465 index: [].concat(getNestedCSSRulePositions(thisArg), [
20466 index2 || 0
20467 ])
20468 }
20469 ]
20470 });
20471 }
20472 return target.apply(thisArg, argumentsList);
20473 })
20474 });
20475 type.prototype.deleteRule = new Proxy(unmodifiedFunctions[typeKey].deleteRule, {
20476 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20477 var index2 = argumentsList[0];
20478 var _getIdAndStyleId = getIdAndStyleId(thisArg.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20479 if (id && id !== -1 || styleId && styleId !== -1) {
20480 styleSheetRuleCb({
20481 id: id,
20482 styleId: styleId,
20483 removes: [
20484 {
20485 index: [].concat(getNestedCSSRulePositions(thisArg), [
20486 index2
20487 ])
20488 }
20489 ]
20490 });
20491 }
20492 return target.apply(thisArg, argumentsList);
20493 })
20494 });
20495 });
20496 return callbackWrapper(function() {
20497 win.CSSStyleSheet.prototype.insertRule = insertRule;
20498 win.CSSStyleSheet.prototype.deleteRule = deleteRule;
20499 replace && (win.CSSStyleSheet.prototype.replace = replace);
20500 replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);
20501 Object.entries(supportedNestedCSSRuleTypes).forEach(function(param) {
20502 var typeKey = param[0], type = param[1];
20503 type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
20504 type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
20505 });
20506 });
20507 }
20508 function initAdoptedStyleSheetObserver(param, host2) {
20509 var mirror2 = param.mirror, stylesheetManager = param.stylesheetManager;
20510 var _a2, _b, _c;
20511 var hostId = null;
20512 if (host2.nodeName === "#document") hostId = mirror2.getId(host2);
20513 else hostId = mirror2.getId(index.host(host2));
20514 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;
20515 var originalPropertyDescriptor = (patchTarget == null ? void 0 : patchTarget.prototype) ? Object.getOwnPropertyDescriptor(patchTarget == null ? void 0 : patchTarget.prototype, "adoptedStyleSheets") : void 0;
20516 if (hostId === null || hostId === -1 || !patchTarget || !originalPropertyDescriptor) return function() {};
20517 Object.defineProperty(host2, "adoptedStyleSheets", {
20518 configurable: originalPropertyDescriptor.configurable,
20519 enumerable: originalPropertyDescriptor.enumerable,
20520 get: function get() {
20521 var _a3;
20522 return (_a3 = originalPropertyDescriptor.get) == null ? void 0 : _a3.call(this);
20523 },
20524 set: function set(sheets) {
20525 var _a3;
20526 var result2 = (_a3 = originalPropertyDescriptor.set) == null ? void 0 : _a3.call(this, sheets);
20527 if (hostId !== null && hostId !== -1) {
20528 try {
20529 stylesheetManager.adoptStyleSheets(sheets, hostId);
20530 } catch (e2) {}
20531 }
20532 return result2;
20533 }
20534 });
20535 return callbackWrapper(function() {
20536 Object.defineProperty(host2, "adoptedStyleSheets", {
20537 configurable: originalPropertyDescriptor.configurable,
20538 enumerable: originalPropertyDescriptor.enumerable,
20539 // eslint-disable-next-line @typescript-eslint/unbound-method
20540 get: originalPropertyDescriptor.get,
20541 // eslint-disable-next-line @typescript-eslint/unbound-method
20542 set: originalPropertyDescriptor.set
20543 });
20544 });
20545 }
20546 function initStyleDeclarationObserver(param, param1) {
20547 var styleDeclarationCb = param.styleDeclarationCb, mirror2 = param.mirror, ignoreCSSAttributes = param.ignoreCSSAttributes, stylesheetManager = param.stylesheetManager;
20548 var win = param1.win;
20549 var setProperty = win.CSSStyleDeclaration.prototype.setProperty;
20550 win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
20551 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20552 var _a2;
20553 var property = argumentsList[0], value = argumentsList[1], priority = argumentsList[2];
20554 if (ignoreCSSAttributes.has(property)) {
20555 return setProperty.apply(thisArg, [
20556 property,
20557 value,
20558 priority
20559 ]);
20560 }
20561 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20562 if (id && id !== -1 || styleId && styleId !== -1) {
20563 styleDeclarationCb({
20564 id: id,
20565 styleId: styleId,
20566 set: {
20567 property: property,
20568 value: value,
20569 priority: priority
20570 },
20571 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20572 index: getNestedCSSRulePositions(thisArg.parentRule)
20573 });
20574 }
20575 return target.apply(thisArg, argumentsList);
20576 })
20577 });
20578 var removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
20579 win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
20580 apply: callbackWrapper(function(target, thisArg, argumentsList) {
20581 var _a2;
20582 var property = argumentsList[0];
20583 if (ignoreCSSAttributes.has(property)) {
20584 return removeProperty.apply(thisArg, [
20585 property
20586 ]);
20587 }
20588 var _getIdAndStyleId = getIdAndStyleId((_a2 = thisArg.parentRule) == null ? void 0 : _a2.parentStyleSheet, mirror2, stylesheetManager.styleMirror), id = _getIdAndStyleId.id, styleId = _getIdAndStyleId.styleId;
20589 if (id && id !== -1 || styleId && styleId !== -1) {
20590 styleDeclarationCb({
20591 id: id,
20592 styleId: styleId,
20593 remove: {
20594 property: property
20595 },
20596 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20597 index: getNestedCSSRulePositions(thisArg.parentRule)
20598 });
20599 }
20600 return target.apply(thisArg, argumentsList);
20601 })
20602 });
20603 return callbackWrapper(function() {
20604 win.CSSStyleDeclaration.prototype.setProperty = setProperty;
20605 win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
20606 });
20607 }
20608 function initMediaInteractionObserver(param) {
20609 var mediaInteractionCb = param.mediaInteractionCb, blockClass = param.blockClass, blockSelector = param.blockSelector, mirror2 = param.mirror, sampling = param.sampling, doc = param.doc;
20610 var handler = callbackWrapper(function(type) {
20611 return throttle(callbackWrapper(function(event) {
20612 var target = getEventTarget(event);
20613 if (!target || isBlocked(target, blockClass, blockSelector, true)) {
20614 return;
20615 }
20616 var currentTime = target.currentTime, volume = target.volume, muted = target.muted, playbackRate = target.playbackRate, loop = target.loop;
20617 mediaInteractionCb({
20618 type: type,
20619 id: mirror2.getId(target),
20620 currentTime: currentTime,
20621 volume: volume,
20622 muted: muted,
20623 playbackRate: playbackRate,
20624 loop: loop
20625 });
20626 }), sampling.media || 500);
20627 });
20628 var handlers = [
20629 on("play", handler(MediaInteractions.Play), doc),
20630 on("pause", handler(MediaInteractions.Pause), doc),
20631 on("seeked", handler(MediaInteractions.Seeked), doc),
20632 on("volumechange", handler(MediaInteractions.VolumeChange), doc),
20633 on("ratechange", handler(MediaInteractions.RateChange), doc)
20634 ];
20635 return callbackWrapper(function() {
20636 handlers.forEach(function(h) {
20637 return h();
20638 });
20639 });
20640 }
20641 function initFontObserver(param) {
20642 var fontCb = param.fontCb, doc = param.doc;
20643 var win = doc.defaultView;
20644 if (!win) {
20645 return function() {};
20646 }
20647 var handlers = [];
20648 var fontMap = /* @__PURE__ */ new WeakMap();
20649 var originalFontFace = win.FontFace;
20650 win.FontFace = function FontFace2(family, source, descriptors) {
20651 var fontFace = new originalFontFace(family, source, descriptors);
20652 fontMap.set(fontFace, {
20653 family: family,
20654 buffer: typeof source !== "string",
20655 descriptors: descriptors,
20656 fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
20657 });
20658 return fontFace;
20659 };
20660 var restoreHandler = patch(doc.fonts, "add", function(original) {
20661 return function(fontFace) {
20662 setTimeout(callbackWrapper(function() {
20663 var p = fontMap.get(fontFace);
20664 if (p) {
20665 fontCb(p);
20666 fontMap.delete(fontFace);
20667 }
20668 }), 0);
20669 return original.apply(this, [
20670 fontFace
20671 ]);
20672 };
20673 });
20674 handlers.push(function() {
20675 win.FontFace = originalFontFace;
20676 });
20677 handlers.push(restoreHandler);
20678 return callbackWrapper(function() {
20679 handlers.forEach(function(h) {
20680 return h();
20681 });
20682 });
20683 }
20684 function initSelectionObserver(param) {
20685 var doc = param.doc, mirror2 = param.mirror, blockClass = param.blockClass, blockSelector = param.blockSelector, selectionCb = param.selectionCb;
20686 var collapsed = true;
20687 var updateSelection = callbackWrapper(function() {
20688 var selection = doc.getSelection();
20689 if (!selection || collapsed && (selection == null ? void 0 : selection.isCollapsed)) return;
20690 collapsed = selection.isCollapsed || false;
20691 var ranges = [];
20692 var count = selection.rangeCount || 0;
20693 for(var i2 = 0; i2 < count; i2++){
20694 var range = selection.getRangeAt(i2);
20695 var startContainer = range.startContainer, startOffset = range.startOffset, endContainer = range.endContainer, endOffset = range.endOffset;
20696 var blocked = isBlocked(startContainer, blockClass, blockSelector, true) || isBlocked(endContainer, blockClass, blockSelector, true);
20697 if (blocked) continue;
20698 ranges.push({
20699 start: mirror2.getId(startContainer),
20700 startOffset: startOffset,
20701 end: mirror2.getId(endContainer),
20702 endOffset: endOffset
20703 });
20704 }
20705 selectionCb({
20706 ranges: ranges
20707 });
20708 });
20709 updateSelection();
20710 return on("selectionchange", updateSelection);
20711 }
20712 function initCustomElementObserver(param) {
20713 var doc = param.doc, customElementCb = param.customElementCb;
20714 var win = doc.defaultView;
20715 if (!win || !win.customElements) return function() {};
20716 var restoreHandler = patch(win.customElements, "define", function(original) {
20717 return function(name, constructor, options) {
20718 try {
20719 customElementCb({
20720 define: {
20721 name: name
20722 }
20723 });
20724 } catch (e2) {
20725 console.warn("Custom element callback failed for " + name);
20726 }
20727 return original.apply(this, [
20728 name,
20729 constructor,
20730 options
20731 ]);
20732 };
20733 });
20734 return restoreHandler;
20735 }
20736 function mergeHooks(o2, hooks) {
20737 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;
20738 o2.mutationCb = function() {
20739 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20740 p[_key] = arguments[_key];
20741 }
20742 if (hooks.mutation) {
20743 var _hooks;
20744 (_hooks = hooks).mutation.apply(_hooks, [].concat(p));
20745 }
20746 mutationCb.apply(void 0, [].concat(p));
20747 };
20748 o2.mousemoveCb = function() {
20749 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20750 p[_key] = arguments[_key];
20751 }
20752 if (hooks.mousemove) {
20753 var _hooks;
20754 (_hooks = hooks).mousemove.apply(_hooks, [].concat(p));
20755 }
20756 mousemoveCb.apply(void 0, [].concat(p));
20757 };
20758 o2.mouseInteractionCb = function() {
20759 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20760 p[_key] = arguments[_key];
20761 }
20762 if (hooks.mouseInteraction) {
20763 var _hooks;
20764 (_hooks = hooks).mouseInteraction.apply(_hooks, [].concat(p));
20765 }
20766 mouseInteractionCb.apply(void 0, [].concat(p));
20767 };
20768 o2.scrollCb = function() {
20769 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20770 p[_key] = arguments[_key];
20771 }
20772 if (hooks.scroll) {
20773 var _hooks;
20774 (_hooks = hooks).scroll.apply(_hooks, [].concat(p));
20775 }
20776 scrollCb.apply(void 0, [].concat(p));
20777 };
20778 o2.viewportResizeCb = function() {
20779 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20780 p[_key] = arguments[_key];
20781 }
20782 if (hooks.viewportResize) {
20783 var _hooks;
20784 (_hooks = hooks).viewportResize.apply(_hooks, [].concat(p));
20785 }
20786 viewportResizeCb.apply(void 0, [].concat(p));
20787 };
20788 o2.inputCb = function() {
20789 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20790 p[_key] = arguments[_key];
20791 }
20792 if (hooks.input) {
20793 var _hooks;
20794 (_hooks = hooks).input.apply(_hooks, [].concat(p));
20795 }
20796 inputCb.apply(void 0, [].concat(p));
20797 };
20798 o2.mediaInteractionCb = function() {
20799 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20800 p[_key] = arguments[_key];
20801 }
20802 if (hooks.mediaInteaction) {
20803 var _hooks;
20804 (_hooks = hooks).mediaInteaction.apply(_hooks, [].concat(p));
20805 }
20806 mediaInteractionCb.apply(void 0, [].concat(p));
20807 };
20808 o2.styleSheetRuleCb = function() {
20809 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20810 p[_key] = arguments[_key];
20811 }
20812 if (hooks.styleSheetRule) {
20813 var _hooks;
20814 (_hooks = hooks).styleSheetRule.apply(_hooks, [].concat(p));
20815 }
20816 styleSheetRuleCb.apply(void 0, [].concat(p));
20817 };
20818 o2.styleDeclarationCb = function() {
20819 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20820 p[_key] = arguments[_key];
20821 }
20822 if (hooks.styleDeclaration) {
20823 var _hooks;
20824 (_hooks = hooks).styleDeclaration.apply(_hooks, [].concat(p));
20825 }
20826 styleDeclarationCb.apply(void 0, [].concat(p));
20827 };
20828 o2.canvasMutationCb = function() {
20829 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20830 p[_key] = arguments[_key];
20831 }
20832 if (hooks.canvasMutation) {
20833 var _hooks;
20834 (_hooks = hooks).canvasMutation.apply(_hooks, [].concat(p));
20835 }
20836 canvasMutationCb.apply(void 0, [].concat(p));
20837 };
20838 o2.fontCb = function() {
20839 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20840 p[_key] = arguments[_key];
20841 }
20842 if (hooks.font) {
20843 var _hooks;
20844 (_hooks = hooks).font.apply(_hooks, [].concat(p));
20845 }
20846 fontCb.apply(void 0, [].concat(p));
20847 };
20848 o2.selectionCb = function() {
20849 for(var _len = arguments.length, p = new Array(_len), _key = 0; _key < _len; _key++){
20850 p[_key] = arguments[_key];
20851 }
20852 if (hooks.selection) {
20853 var _hooks;
20854 (_hooks = hooks).selection.apply(_hooks, [].concat(p));
20855 }
20856 selectionCb.apply(void 0, [].concat(p));
20857 };
20858 o2.customElementCb = function() {
20859 for(var _len = arguments.length, c2 = new Array(_len), _key = 0; _key < _len; _key++){
20860 c2[_key] = arguments[_key];
20861 }
20862 if (hooks.customElement) {
20863 var _hooks;
20864 (_hooks = hooks).customElement.apply(_hooks, [].concat(c2));
20865 }
20866 customElementCb.apply(void 0, [].concat(c2));
20867 };
20868 }
20869 function initObservers(o2, hooks) {
20870 if (hooks === void 0) hooks = {};
20871 var currentWindow = o2.doc.defaultView;
20872 if (!currentWindow) {
20873 return function() {};
20874 }
20875 mergeHooks(o2, hooks);
20876 var mutationObserver;
20877 if (o2.recordDOM) {
20878 mutationObserver = initMutationObserver(o2, o2.doc);
20879 }
20880 var mousemoveHandler = initMoveObserver(o2);
20881 var mouseInteractionHandler = initMouseInteractionObserver(o2);
20882 var scrollHandler = initScrollObserver(o2);
20883 var viewportResizeHandler = initViewportResizeObserver(o2, {
20884 win: currentWindow
20885 });
20886 var inputHandler = initInputObserver(o2);
20887 var mediaInteractionHandler = initMediaInteractionObserver(o2);
20888 var styleSheetObserver = function() {};
20889 var adoptedStyleSheetObserver = function() {};
20890 var styleDeclarationObserver = function() {};
20891 var fontObserver = function() {};
20892 if (o2.recordDOM) {
20893 styleSheetObserver = initStyleSheetObserver(o2, {
20894 win: currentWindow
20895 });
20896 adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o2, o2.doc);
20897 styleDeclarationObserver = initStyleDeclarationObserver(o2, {
20898 win: currentWindow
20899 });
20900 if (o2.collectFonts) {
20901 fontObserver = initFontObserver(o2);
20902 }
20903 }
20904 var selectionObserver = initSelectionObserver(o2);
20905 var customElementObserver = initCustomElementObserver(o2);
20906 var pluginHandlers = [];
20907 for(var _iterator = _create_for_of_iterator_helper_loose(o2.plugins), _step; !(_step = _iterator()).done;){
20908 var plugin3 = _step.value;
20909 pluginHandlers.push(plugin3.observer(plugin3.callback, currentWindow, plugin3.options));
20910 }
20911 return callbackWrapper(function() {
20912 mutationBuffers.forEach(function(b) {
20913 return b.reset();
20914 });
20915 mutationObserver == null ? void 0 : mutationObserver.disconnect();
20916 mousemoveHandler();
20917 mouseInteractionHandler();
20918 scrollHandler();
20919 viewportResizeHandler();
20920 inputHandler();
20921 mediaInteractionHandler();
20922 styleSheetObserver();
20923 adoptedStyleSheetObserver();
20924 styleDeclarationObserver();
20925 fontObserver();
20926 selectionObserver();
20927 customElementObserver();
20928 pluginHandlers.forEach(function(h) {
20929 return h();
20930 });
20931 });
20932 }
20933 function hasNestedCSSRule(prop) {
20934 return typeof window[prop] !== "undefined";
20935 }
20936 function canMonkeyPatchNestedCSSRule(prop) {
20937 return Boolean(typeof window[prop] !== "undefined" && // Note: Generally, this check _shouldn't_ be necessary
20938 // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here
20939 window[prop].prototype && "insertRule" in window[prop].prototype && "deleteRule" in window[prop].prototype);
20940 }
20941 var CrossOriginIframeMirror = /*#__PURE__*/ function() {
20942 function CrossOriginIframeMirror(generateIdFn) {
20943 __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
20944 __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
20945 this.generateIdFn = generateIdFn;
20946 }
20947 var _proto = CrossOriginIframeMirror.prototype;
20948 _proto.getId = function getId(iframe, remoteId, idToRemoteMap, remoteToIdMap) {
20949 var idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);
20950 var remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);
20951 var id = idToRemoteIdMap.get(remoteId);
20952 if (!id) {
20953 id = this.generateIdFn();
20954 idToRemoteIdMap.set(remoteId, id);
20955 remoteIdToIdMap.set(id, remoteId);
20956 }
20957 return id;
20958 };
20959 _proto.getIds = function getIds(iframe, remoteId) {
20960 var _this = this;
20961 var idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);
20962 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20963 return remoteId.map(function(id) {
20964 return _this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap);
20965 });
20966 };
20967 _proto.getRemoteId = function getRemoteId(iframe, id, map) {
20968 var remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);
20969 if (typeof id !== "number") return id;
20970 var remoteId = remoteIdToIdMap.get(id);
20971 if (!remoteId) return -1;
20972 return remoteId;
20973 };
20974 _proto.getRemoteIds = function getRemoteIds(iframe, ids) {
20975 var _this = this;
20976 var remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);
20977 return ids.map(function(id) {
20978 return _this.getRemoteId(iframe, id, remoteIdToIdMap);
20979 });
20980 };
20981 _proto.reset = function reset(iframe) {
20982 if (!iframe) {
20983 this.iframeIdToRemoteIdMap = /* @__PURE__ */ new WeakMap();
20984 this.iframeRemoteIdToIdMap = /* @__PURE__ */ new WeakMap();
20985 return;
20986 }
20987 this.iframeIdToRemoteIdMap.delete(iframe);
20988 this.iframeRemoteIdToIdMap.delete(iframe);
20989 };
20990 _proto.getIdToRemoteIdMap = function getIdToRemoteIdMap(iframe) {
20991 var idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);
20992 if (!idToRemoteIdMap) {
20993 idToRemoteIdMap = /* @__PURE__ */ new Map();
20994 this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);
20995 }
20996 return idToRemoteIdMap;
20997 };
20998 _proto.getRemoteIdToIdMap = function getRemoteIdToIdMap(iframe) {
20999 var remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);
21000 if (!remoteIdToIdMap) {
21001 remoteIdToIdMap = /* @__PURE__ */ new Map();
21002 this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);
21003 }
21004 return remoteIdToIdMap;
21005 };
21006 return CrossOriginIframeMirror;
21007 }();
21008 var IframeManager = /*#__PURE__*/ function() {
21009 function IframeManager(options) {
21010 __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
21011 __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
21012 __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
21013 __publicField(this, "crossOriginIframeStyleMirror");
21014 __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
21015 __publicField(this, "mirror");
21016 __publicField(this, "mutationCb");
21017 __publicField(this, "wrappedEmit");
21018 __publicField(this, "loadListener");
21019 __publicField(this, "stylesheetManager");
21020 __publicField(this, "recordCrossOriginIframes");
21021 this.mutationCb = options.mutationCb;
21022 this.wrappedEmit = options.wrappedEmit;
21023 this.stylesheetManager = options.stylesheetManager;
21024 this.recordCrossOriginIframes = options.recordCrossOriginIframes;
21025 this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror));
21026 this.mirror = options.mirror;
21027 if (this.recordCrossOriginIframes) {
21028 window.addEventListener("message", this.handleMessage.bind(this));
21029 }
21030 }
21031 var _proto = IframeManager.prototype;
21032 _proto.addIframe = function addIframe(iframeEl) {
21033 this.iframes.set(iframeEl, true);
21034 if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
21035 };
21036 _proto.addLoadListener = function addLoadListener(cb) {
21037 this.loadListener = cb;
21038 };
21039 _proto.attachIframe = function attachIframe(iframeEl, childSn) {
21040 var _a2, _b;
21041 this.mutationCb({
21042 adds: [
21043 {
21044 parentId: this.mirror.getId(iframeEl),
21045 nextId: null,
21046 node: childSn
21047 }
21048 ],
21049 removes: [],
21050 texts: [],
21051 attributes: [],
21052 isAttachIframe: true
21053 });
21054 if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
21055 (_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
21056 if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
21057 };
21058 _proto.handleMessage = function handleMessage(message) {
21059 var crossOriginMessageEvent = message;
21060 if (crossOriginMessageEvent.data.type !== "rrweb" || // To filter out the rrweb messages which are forwarded by some sites.
21061 crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin) return;
21062 var iframeSourceWindow = message.source;
21063 if (!iframeSourceWindow) return;
21064 var iframeEl = this.crossOriginIframeMap.get(message.source);
21065 if (!iframeEl) return;
21066 var transformedEvent = this.transformCrossOriginEvent(iframeEl, crossOriginMessageEvent.data.event);
21067 if (transformedEvent) this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
21068 };
21069 _proto.transformCrossOriginEvent = function transformCrossOriginEvent(iframeEl, e2) {
21070 var _this = this;
21071 var _a2;
21072 switch(e2.type){
21073 case EventType.FullSnapshot:
21074 {
21075 this.crossOriginIframeMirror.reset(iframeEl);
21076 this.crossOriginIframeStyleMirror.reset(iframeEl);
21077 this.replaceIdOnNode(e2.data.node, iframeEl);
21078 var rootId = e2.data.node.id;
21079 this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
21080 this.patchRootIdOnNode(e2.data.node, rootId);
21081 return {
21082 timestamp: e2.timestamp,
21083 type: EventType.IncrementalSnapshot,
21084 data: {
21085 source: IncrementalSource.Mutation,
21086 adds: [
21087 {
21088 parentId: this.mirror.getId(iframeEl),
21089 nextId: null,
21090 node: e2.data.node
21091 }
21092 ],
21093 removes: [],
21094 texts: [],
21095 attributes: [],
21096 isAttachIframe: true
21097 }
21098 };
21099 }
21100 case EventType.Meta:
21101 case EventType.Load:
21102 case EventType.DomContentLoaded:
21103 {
21104 return false;
21105 }
21106 case EventType.Plugin:
21107 {
21108 return e2;
21109 }
21110 case EventType.Custom:
21111 {
21112 this.replaceIds(e2.data.payload, iframeEl, [
21113 "id",
21114 "parentId",
21115 "previousId",
21116 "nextId"
21117 ]);
21118 return e2;
21119 }
21120 case EventType.IncrementalSnapshot:
21121 {
21122 switch(e2.data.source){
21123 case IncrementalSource.Mutation:
21124 {
21125 e2.data.adds.forEach(function(n2) {
21126 _this.replaceIds(n2, iframeEl, [
21127 "parentId",
21128 "nextId",
21129 "previousId"
21130 ]);
21131 _this.replaceIdOnNode(n2.node, iframeEl);
21132 var rootId = _this.crossOriginIframeRootIdMap.get(iframeEl);
21133 rootId && _this.patchRootIdOnNode(n2.node, rootId);
21134 });
21135 e2.data.removes.forEach(function(n2) {
21136 _this.replaceIds(n2, iframeEl, [
21137 "parentId",
21138 "id"
21139 ]);
21140 });
21141 e2.data.attributes.forEach(function(n2) {
21142 _this.replaceIds(n2, iframeEl, [
21143 "id"
21144 ]);
21145 });
21146 e2.data.texts.forEach(function(n2) {
21147 _this.replaceIds(n2, iframeEl, [
21148 "id"
21149 ]);
21150 });
21151 return e2;
21152 }
21153 case IncrementalSource.Drag:
21154 case IncrementalSource.TouchMove:
21155 case IncrementalSource.MouseMove:
21156 {
21157 e2.data.positions.forEach(function(p) {
21158 _this.replaceIds(p, iframeEl, [
21159 "id"
21160 ]);
21161 });
21162 return e2;
21163 }
21164 case IncrementalSource.ViewportResize:
21165 {
21166 return false;
21167 }
21168 case IncrementalSource.MediaInteraction:
21169 case IncrementalSource.MouseInteraction:
21170 case IncrementalSource.Scroll:
21171 case IncrementalSource.CanvasMutation:
21172 case IncrementalSource.Input:
21173 {
21174 this.replaceIds(e2.data, iframeEl, [
21175 "id"
21176 ]);
21177 return e2;
21178 }
21179 case IncrementalSource.StyleSheetRule:
21180 case IncrementalSource.StyleDeclaration:
21181 {
21182 this.replaceIds(e2.data, iframeEl, [
21183 "id"
21184 ]);
21185 this.replaceStyleIds(e2.data, iframeEl, [
21186 "styleId"
21187 ]);
21188 return e2;
21189 }
21190 case IncrementalSource.Font:
21191 {
21192 return e2;
21193 }
21194 case IncrementalSource.Selection:
21195 {
21196 e2.data.ranges.forEach(function(range) {
21197 _this.replaceIds(range, iframeEl, [
21198 "start",
21199 "end"
21200 ]);
21201 });
21202 return e2;
21203 }
21204 case IncrementalSource.AdoptedStyleSheet:
21205 {
21206 this.replaceIds(e2.data, iframeEl, [
21207 "id"
21208 ]);
21209 this.replaceStyleIds(e2.data, iframeEl, [
21210 "styleIds"
21211 ]);
21212 (_a2 = e2.data.styles) == null ? void 0 : _a2.forEach(function(style) {
21213 _this.replaceStyleIds(style, iframeEl, [
21214 "styleId"
21215 ]);
21216 });
21217 return e2;
21218 }
21219 }
21220 }
21221 }
21222 return false;
21223 };
21224 _proto.replace = function replace(iframeMirror, obj, iframeEl, keys) {
21225 for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
21226 var key = _step.value;
21227 if (!Array.isArray(obj[key]) && typeof obj[key] !== "number") continue;
21228 if (Array.isArray(obj[key])) {
21229 obj[key] = iframeMirror.getIds(iframeEl, obj[key]);
21230 } else {
21231 obj[key] = iframeMirror.getId(iframeEl, obj[key]);
21232 }
21233 }
21234 return obj;
21235 };
21236 _proto.replaceIds = function replaceIds(obj, iframeEl, keys) {
21237 return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);
21238 };
21239 _proto.replaceStyleIds = function replaceStyleIds(obj, iframeEl, keys) {
21240 return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);
21241 };
21242 _proto.replaceIdOnNode = function replaceIdOnNode(node2, iframeEl) {
21243 var _this = this;
21244 this.replaceIds(node2, iframeEl, [
21245 "id",
21246 "rootId"
21247 ]);
21248 if ("childNodes" in node2) {
21249 node2.childNodes.forEach(function(child) {
21250 _this.replaceIdOnNode(child, iframeEl);
21251 });
21252 }
21253 };
21254 _proto.patchRootIdOnNode = function patchRootIdOnNode(node2, rootId) {
21255 var _this = this;
21256 if (node2.type !== NodeType.Document && !node2.rootId) node2.rootId = rootId;
21257 if ("childNodes" in node2) {
21258 node2.childNodes.forEach(function(child) {
21259 _this.patchRootIdOnNode(child, rootId);
21260 });
21261 }
21262 };
21263 return IframeManager;
21264 }();
21265 var ShadowDomManager = /*#__PURE__*/ function() {
21266 function ShadowDomManager(options) {
21267 __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
21268 __publicField(this, "mutationCb");
21269 __publicField(this, "scrollCb");
21270 __publicField(this, "bypassOptions");
21271 __publicField(this, "mirror");
21272 __publicField(this, "restoreHandlers", []);
21273 this.mutationCb = options.mutationCb;
21274 this.scrollCb = options.scrollCb;
21275 this.bypassOptions = options.bypassOptions;
21276 this.mirror = options.mirror;
21277 this.init();
21278 }
21279 var _proto = ShadowDomManager.prototype;
21280 _proto.init = function init() {
21281 this.reset();
21282 this.patchAttachShadow(Element, document);
21283 };
21284 _proto.addShadowRoot = function addShadowRoot(shadowRoot2, doc) {
21285 var _this = this;
21286 if (!isNativeShadowDom(shadowRoot2)) return;
21287 if (this.shadowDoms.has(shadowRoot2)) return;
21288 this.shadowDoms.add(shadowRoot2);
21289 var observer = initMutationObserver(_extends({}, this.bypassOptions, {
21290 doc: doc,
21291 mutationCb: this.mutationCb,
21292 mirror: this.mirror,
21293 shadowDomManager: this
21294 }), shadowRoot2);
21295 this.restoreHandlers.push(function() {
21296 return observer.disconnect();
21297 });
21298 this.restoreHandlers.push(initScrollObserver(_extends({}, this.bypassOptions, {
21299 scrollCb: this.scrollCb,
21300 // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813
21301 // scroll is not allowed to pass the boundary, so we need to listen the shadow document
21302 doc: shadowRoot2,
21303 mirror: this.mirror
21304 })));
21305 setTimeout(function() {
21306 if (shadowRoot2.adoptedStyleSheets && shadowRoot2.adoptedStyleSheets.length > 0) _this.bypassOptions.stylesheetManager.adoptStyleSheets(shadowRoot2.adoptedStyleSheets, _this.mirror.getId(index.host(shadowRoot2)));
21307 _this.restoreHandlers.push(initAdoptedStyleSheetObserver({
21308 mirror: _this.mirror,
21309 stylesheetManager: _this.bypassOptions.stylesheetManager
21310 }, shadowRoot2));
21311 }, 0);
21312 };
21313 /**
21314 * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.
21315 */ _proto.observeAttachShadow = function observeAttachShadow(iframeElement) {
21316 if (!iframeElement.contentWindow || !iframeElement.contentDocument) return;
21317 this.patchAttachShadow(iframeElement.contentWindow.Element, iframeElement.contentDocument);
21318 };
21319 /**
21320 * Patch 'attachShadow' to observe newly added shadow doms.
21321 */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
21322 var manager = this;
21323 this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
21324 return function(option) {
21325 var sRoot = original.call(this, option);
21326 var shadowRootEl = index.shadowRoot(this);
21327 if (shadowRootEl && inDom(this)) manager.addShadowRoot(shadowRootEl, doc);
21328 return sRoot;
21329 };
21330 }));
21331 };
21332 _proto.reset = function reset() {
21333 this.restoreHandlers.forEach(function(handler) {
21334 try {
21335 handler();
21336 } catch (e2) {}
21337 });
21338 this.restoreHandlers = [];
21339 this.shadowDoms = /* @__PURE__ */ new WeakSet();
21340 };
21341 return ShadowDomManager;
21342 }();
21343 var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
21344 var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
21345 for(var i$1 = 0; i$1 < chars.length; i$1++){
21346 lookup[chars.charCodeAt(i$1)] = i$1;
21347 }
21348 var encode = function encode(arraybuffer) {
21349 var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
21350 for(i2 = 0; i2 < len; i2 += 3){
21351 base64 += chars[bytes[i2] >> 2];
21352 base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
21353 base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
21354 base64 += chars[bytes[i2 + 2] & 63];
21355 }
21356 if (len % 3 === 2) {
21357 base64 = base64.substring(0, base64.length - 1) + "=";
21358 } else if (len % 3 === 1) {
21359 base64 = base64.substring(0, base64.length - 2) + "==";
21360 }
21361 return base64;
21362 };
21363 var canvasVarMap = /* @__PURE__ */ new Map();
21364 function variableListFor$1(ctx, ctor) {
21365 var contextMap = canvasVarMap.get(ctx);
21366 if (!contextMap) {
21367 contextMap = /* @__PURE__ */ new Map();
21368 canvasVarMap.set(ctx, contextMap);
21369 }
21370 if (!contextMap.has(ctor)) {
21371 contextMap.set(ctor, []);
21372 }
21373 return contextMap.get(ctor);
21374 }
21375 var saveWebGLVar = function(value, win, ctx) {
21376 if (!value || !(isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object")) return;
21377 var name = value.constructor.name;
21378 var list2 = variableListFor$1(ctx, name);
21379 var index2 = list2.indexOf(value);
21380 if (index2 === -1) {
21381 index2 = list2.length;
21382 list2.push(value);
21383 }
21384 return index2;
21385 };
21386 function serializeArg(value, win, ctx) {
21387 if (_instanceof(value, Array)) {
21388 return value.map(function(arg) {
21389 return serializeArg(arg, win, ctx);
21390 });
21391 } else if (value === null) {
21392 return value;
21393 } 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)) {
21394 var name = value.constructor.name;
21395 return {
21396 rr_type: name,
21397 args: [
21398 Object.values(value)
21399 ]
21400 };
21401 } else if (// SharedArrayBuffer disabled on most browsers due to spectre.
21402 // More info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/SharedArrayBuffer
21403 // value instanceof SharedArrayBuffer ||
21404 _instanceof(value, ArrayBuffer)) {
21405 var name1 = value.constructor.name;
21406 var base64 = encode(value);
21407 return {
21408 rr_type: name1,
21409 base64: base64
21410 };
21411 } else if (_instanceof(value, DataView)) {
21412 var name2 = value.constructor.name;
21413 return {
21414 rr_type: name2,
21415 args: [
21416 serializeArg(value.buffer, win, ctx),
21417 value.byteOffset,
21418 value.byteLength
21419 ]
21420 };
21421 } else if (_instanceof(value, HTMLImageElement)) {
21422 var name3 = value.constructor.name;
21423 var src = value.src;
21424 return {
21425 rr_type: name3,
21426 src: src
21427 };
21428 } else if (_instanceof(value, HTMLCanvasElement)) {
21429 var name4 = "HTMLImageElement";
21430 var src1 = value.toDataURL();
21431 return {
21432 rr_type: name4,
21433 src: src1
21434 };
21435 } else if (_instanceof(value, ImageData)) {
21436 var name5 = value.constructor.name;
21437 return {
21438 rr_type: name5,
21439 args: [
21440 serializeArg(value.data, win, ctx),
21441 value.width,
21442 value.height
21443 ]
21444 };
21445 } else if (isInstanceOfWebGLObject(value, win) || (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object") {
21446 var name6 = value.constructor.name;
21447 var index2 = saveWebGLVar(value, win, ctx);
21448 return {
21449 rr_type: name6,
21450 index: index2
21451 };
21452 }
21453 return value;
21454 }
21455 var serializeArgs = function(args, win, ctx) {
21456 return args.map(function(arg) {
21457 return serializeArg(arg, win, ctx);
21458 });
21459 };
21460 var isInstanceOfWebGLObject = function(value, win) {
21461 var webGLConstructorNames = [
21462 "WebGLActiveInfo",
21463 "WebGLBuffer",
21464 "WebGLFramebuffer",
21465 "WebGLProgram",
21466 "WebGLRenderbuffer",
21467 "WebGLShader",
21468 "WebGLShaderPrecisionFormat",
21469 "WebGLTexture",
21470 "WebGLUniformLocation",
21471 "WebGLVertexArrayObject",
21472 // In old Chrome versions, value won't be an instanceof WebGLVertexArrayObject.
21473 "WebGLVertexArrayObjectOES"
21474 ];
21475 var supportedWebGLConstructorNames = webGLConstructorNames.filter(function(name) {
21476 return typeof win[name] === "function";
21477 });
21478 return Boolean(supportedWebGLConstructorNames.find(function(name) {
21479 return _instanceof(value, win[name]);
21480 }));
21481 };
21482 function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
21483 var _loop = function() {
21484 var prop = _step.value;
21485 try {
21486 if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
21487 return "continue";
21488 }
21489 var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
21490 return function() {
21491 var _this = this;
21492 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21493 args[_key] = arguments[_key];
21494 }
21495 if (!isBlocked(this.canvas, blockClass, blockSelector, true)) {
21496 setTimeout(function() {
21497 var recordArgs = serializeArgs(args, win, _this);
21498 cb(_this.canvas, {
21499 type: CanvasContext["2D"],
21500 property: prop,
21501 args: recordArgs
21502 });
21503 }, 0);
21504 }
21505 return original.apply(this, args);
21506 };
21507 });
21508 handlers.push(restoreHandler);
21509 } catch (e) {
21510 var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
21511 set: function set(v2) {
21512 cb(this.canvas, {
21513 type: CanvasContext["2D"],
21514 property: prop,
21515 args: [
21516 v2
21517 ],
21518 setter: true
21519 });
21520 }
21521 });
21522 handlers.push(hookHandler);
21523 }
21524 };
21525 var handlers = [];
21526 var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
21527 for(var _iterator = _create_for_of_iterator_helper_loose(props2D), _step; !(_step = _iterator()).done;)_loop();
21528 return function() {
21529 handlers.forEach(function(h) {
21530 return h();
21531 });
21532 };
21533 }
21534 function getNormalizedContextName(contextType) {
21535 return contextType === "experimental-webgl" ? "webgl" : contextType;
21536 }
21537 function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
21538 var handlers = [];
21539 try {
21540 var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
21541 return function(contextType) {
21542 for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
21543 args[_key - 1] = arguments[_key];
21544 }
21545 if (!isBlocked(this, blockClass, blockSelector, true)) {
21546 var ctxName = getNormalizedContextName(contextType);
21547 if (!("__context" in this)) this.__context = ctxName;
21548 if (setPreserveDrawingBufferToTrue && [
21549 "webgl",
21550 "webgl2"
21551 ].includes(ctxName)) {
21552 if (args[0] && _type_of(args[0]) === "object") {
21553 var contextAttributes = args[0];
21554 if (!contextAttributes.preserveDrawingBuffer) {
21555 contextAttributes.preserveDrawingBuffer = true;
21556 }
21557 } else {
21558 args.splice(0, 1, {
21559 preserveDrawingBuffer: true
21560 });
21561 }
21562 }
21563 }
21564 return original.apply(this, [].concat([
21565 contextType
21566 ], args));
21567 };
21568 });
21569 handlers.push(restoreHandler);
21570 } catch (e) {
21571 console.error("failed to patch HTMLCanvasElement.prototype.getContext");
21572 }
21573 return function() {
21574 handlers.forEach(function(h) {
21575 return h();
21576 });
21577 };
21578 }
21579 function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
21580 var _loop = function() {
21581 var prop = _step.value;
21582 if (//prop.startsWith('get') || // e.g. getProgramParameter, but too risky
21583 [
21584 "isContextLost",
21585 "canvas",
21586 "drawingBufferWidth",
21587 "drawingBufferHeight"
21588 ].includes(prop)) {
21589 return "continue";
21590 }
21591 try {
21592 if (typeof prototype[prop] !== "function") {
21593 return "continue";
21594 }
21595 var restoreHandler = patch(prototype, prop, function(original) {
21596 return function() {
21597 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
21598 args[_key] = arguments[_key];
21599 }
21600 var result2 = original.apply(this, args);
21601 saveWebGLVar(result2, win, this);
21602 if ("tagName" in this.canvas && !isBlocked(this.canvas, blockClass, blockSelector, true)) {
21603 var recordArgs = serializeArgs(args, win, this);
21604 var mutation = {
21605 type: type,
21606 property: prop,
21607 args: recordArgs
21608 };
21609 cb(this.canvas, mutation);
21610 }
21611 return result2;
21612 };
21613 });
21614 handlers.push(restoreHandler);
21615 } catch (e) {
21616 var hookHandler = hookSetter(prototype, prop, {
21617 set: function set(v2) {
21618 cb(this.canvas, {
21619 type: type,
21620 property: prop,
21621 args: [
21622 v2
21623 ],
21624 setter: true
21625 });
21626 }
21627 });
21628 handlers.push(hookHandler);
21629 }
21630 };
21631 var handlers = [];
21632 var props = Object.getOwnPropertyNames(prototype);
21633 for(var _iterator = _create_for_of_iterator_helper_loose(props), _step; !(_step = _iterator()).done;)_loop();
21634 return handlers;
21635 }
21636 function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
21637 var _handlers;
21638 var handlers = [];
21639 (_handlers = handlers).push.apply(_handlers, [].concat(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, win)));
21640 if (typeof win.WebGL2RenderingContext !== "undefined") {
21641 var _handlers1;
21642 (_handlers1 = handlers).push.apply(_handlers1, [].concat(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, win)));
21643 }
21644 return function() {
21645 handlers.forEach(function(h) {
21646 return h();
21647 });
21648 };
21649 }
21650 var encodedJs = "KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=";
21651 var decodeBase64 = function(base64) {
21652 return Uint8Array.from(atob(base64), function(c2) {
21653 return c2.charCodeAt(0);
21654 });
21655 };
21656 var blob = typeof window !== "undefined" && window.Blob && new Blob([
21657 decodeBase64(encodedJs)
21658 ], {
21659 type: "text/javascript;charset=utf-8"
21660 });
21661 function WorkerWrapper(options) {
21662 var objURL;
21663 try {
21664 objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
21665 if (!objURL) throw "";
21666 var worker = new Worker(objURL, {
21667 name: options == null ? void 0 : options.name
21668 });
21669 worker.addEventListener("error", function() {
21670 (window.URL || window.webkitURL).revokeObjectURL(objURL);
21671 });
21672 return worker;
21673 } catch (e2) {
21674 return new Worker("data:text/javascript;base64," + encodedJs, {
21675 name: options == null ? void 0 : options.name
21676 });
21677 } finally{
21678 objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
21679 }
21680 }
21681 var CanvasManager = /*#__PURE__*/ function() {
21682 function CanvasManager(options) {
21683 var _this = this;
21684 __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
21685 __publicField(this, "rafStamps", {
21686 latestId: 0,
21687 invokeId: null
21688 });
21689 __publicField(this, "mirror");
21690 __publicField(this, "mutationCb");
21691 __publicField(this, "resetObservers");
21692 __publicField(this, "frozen", false);
21693 __publicField(this, "locked", false);
21694 __publicField(this, "processMutation", function(target, mutation) {
21695 var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
21696 if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
21697 if (!_this.pendingCanvasMutations.has(target)) {
21698 _this.pendingCanvasMutations.set(target, []);
21699 }
21700 _this.pendingCanvasMutations.get(target).push(mutation);
21701 });
21702 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;
21703 this.mutationCb = options.mutationCb;
21704 this.mirror = options.mirror;
21705 if (recordCanvas && sampling === "all") this.initCanvasMutationObserver(win, blockClass, blockSelector);
21706 if (recordCanvas && typeof sampling === "number") this.initCanvasFPSObserver(sampling, win, blockClass, blockSelector, {
21707 dataURLOptions: dataURLOptions
21708 });
21709 }
21710 var _proto = CanvasManager.prototype;
21711 _proto.reset = function reset() {
21712 this.pendingCanvasMutations.clear();
21713 this.resetObservers && this.resetObservers();
21714 };
21715 _proto.freeze = function freeze() {
21716 this.frozen = true;
21717 };
21718 _proto.unfreeze = function unfreeze() {
21719 this.frozen = false;
21720 };
21721 _proto.lock = function lock() {
21722 this.locked = true;
21723 };
21724 _proto.unlock = function unlock() {
21725 this.locked = false;
21726 };
21727 _proto.initCanvasFPSObserver = function initCanvasFPSObserver(fps, win, blockClass, blockSelector, options) {
21728 var _this = this;
21729 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, true);
21730 var snapshotInProgressMap = /* @__PURE__ */ new Map();
21731 var worker = new WorkerWrapper();
21732 worker.onmessage = function(e2) {
21733 var id = e2.data.id;
21734 snapshotInProgressMap.set(id, false);
21735 if (!("base64" in e2.data)) return;
21736 var _e2_data = e2.data, base64 = _e2_data.base64, type = _e2_data.type, width = _e2_data.width, height = _e2_data.height;
21737 _this.mutationCb({
21738 id: id,
21739 type: CanvasContext["2D"],
21740 commands: [
21741 {
21742 property: "clearRect",
21743 // wipe canvas
21744 args: [
21745 0,
21746 0,
21747 width,
21748 height
21749 ]
21750 },
21751 {
21752 property: "drawImage",
21753 // draws (semi-transparent) image
21754 args: [
21755 {
21756 rr_type: "ImageBitmap",
21757 args: [
21758 {
21759 rr_type: "Blob",
21760 data: [
21761 {
21762 rr_type: "ArrayBuffer",
21763 base64: base64
21764 }
21765 ],
21766 type: type
21767 }
21768 ]
21769 },
21770 0,
21771 0
21772 ]
21773 }
21774 ]
21775 });
21776 };
21777 var timeBetweenSnapshots = 1e3 / fps;
21778 var lastSnapshotTime = 0;
21779 var rafId;
21780 var getCanvas = function() {
21781 var matchedCanvas = [];
21782 win.document.querySelectorAll("canvas").forEach(function(canvas) {
21783 if (!isBlocked(canvas, blockClass, blockSelector, true)) {
21784 matchedCanvas.push(canvas);
21785 }
21786 });
21787 return matchedCanvas;
21788 };
21789 var takeCanvasSnapshots = function(timestamp) {
21790 if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
21791 rafId = requestAnimationFrame(takeCanvasSnapshots);
21792 return;
21793 }
21794 lastSnapshotTime = timestamp;
21795 var _this1 = _this;
21796 getCanvas().forEach(/*#__PURE__*/ _async_to_generator(function(canvas) {
21797 var _a2, id, context, bitmap;
21798 return _ts_generator(this, function(_state) {
21799 switch(_state.label){
21800 case 0:
21801 id = _this1.mirror.getId(canvas);
21802 if (snapshotInProgressMap.get(id)) return [
21803 2
21804 ];
21805 if (canvas.width === 0 || canvas.height === 0) return [
21806 2
21807 ];
21808 snapshotInProgressMap.set(id, true);
21809 if ([
21810 "webgl",
21811 "webgl2"
21812 ].includes(canvas.__context)) {
21813 context = canvas.getContext(canvas.__context);
21814 if (((_a2 = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a2.preserveDrawingBuffer) === false) {
21815 context.clear(context.COLOR_BUFFER_BIT);
21816 }
21817 }
21818 return [
21819 4,
21820 createImageBitmap(canvas)
21821 ];
21822 case 1:
21823 bitmap = _state.sent();
21824 worker.postMessage({
21825 id: id,
21826 bitmap: bitmap,
21827 width: canvas.width,
21828 height: canvas.height,
21829 dataURLOptions: options.dataURLOptions
21830 }, [
21831 bitmap
21832 ]);
21833 return [
21834 2
21835 ];
21836 }
21837 });
21838 }));
21839 rafId = requestAnimationFrame(takeCanvasSnapshots);
21840 };
21841 rafId = requestAnimationFrame(takeCanvasSnapshots);
21842 this.resetObservers = function() {
21843 canvasContextReset();
21844 cancelAnimationFrame(rafId);
21845 };
21846 };
21847 _proto.initCanvasMutationObserver = function initCanvasMutationObserver(win, blockClass, blockSelector) {
21848 this.startRAFTimestamping();
21849 this.startPendingCanvasMutationFlusher();
21850 var canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, false);
21851 var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21852 var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector);
21853 this.resetObservers = function() {
21854 canvasContextReset();
21855 canvas2DReset();
21856 canvasWebGL1and2Reset();
21857 };
21858 };
21859 _proto.startPendingCanvasMutationFlusher = function startPendingCanvasMutationFlusher() {
21860 var _this = this;
21861 requestAnimationFrame(function() {
21862 return _this.flushPendingCanvasMutations();
21863 });
21864 };
21865 _proto.startRAFTimestamping = function startRAFTimestamping() {
21866 var _this = this;
21867 var setLatestRAFTimestamp = function(timestamp) {
21868 _this.rafStamps.latestId = timestamp;
21869 requestAnimationFrame(setLatestRAFTimestamp);
21870 };
21871 requestAnimationFrame(setLatestRAFTimestamp);
21872 };
21873 _proto.flushPendingCanvasMutations = function flushPendingCanvasMutations() {
21874 var _this = this;
21875 this.pendingCanvasMutations.forEach(function(_values, canvas) {
21876 var id = _this.mirror.getId(canvas);
21877 _this.flushPendingCanvasMutationFor(canvas, id);
21878 });
21879 requestAnimationFrame(function() {
21880 return _this.flushPendingCanvasMutations();
21881 });
21882 };
21883 _proto.flushPendingCanvasMutationFor = function flushPendingCanvasMutationFor(canvas, id) {
21884 if (this.frozen || this.locked) {
21885 return;
21886 }
21887 var valuesWithType = this.pendingCanvasMutations.get(canvas);
21888 if (!valuesWithType || id === -1) return;
21889 var values = valuesWithType.map(function(value) {
21890 value.type; var rest = _object_without_properties_loose(value, [
21891 "type"
21892 ]);
21893 return rest;
21894 });
21895 var type = valuesWithType[0].type;
21896 this.mutationCb({
21897 id: id,
21898 type: type,
21899 commands: values
21900 });
21901 this.pendingCanvasMutations.delete(canvas);
21902 };
21903 return CanvasManager;
21904 }();
21905 var StylesheetManager = /*#__PURE__*/ function() {
21906 function StylesheetManager(options) {
21907 __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
21908 __publicField(this, "mutationCb");
21909 __publicField(this, "adoptedStyleSheetCb");
21910 __publicField(this, "styleMirror", new StyleSheetMirror());
21911 this.mutationCb = options.mutationCb;
21912 this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
21913 }
21914 var _proto = StylesheetManager.prototype;
21915 _proto.attachLinkElement = function attachLinkElement(linkEl, childSn) {
21916 if ("_cssText" in childSn.attributes) this.mutationCb({
21917 adds: [],
21918 removes: [],
21919 texts: [],
21920 attributes: [
21921 {
21922 id: childSn.id,
21923 attributes: childSn.attributes
21924 }
21925 ]
21926 });
21927 this.trackLinkElement(linkEl);
21928 };
21929 _proto.trackLinkElement = function trackLinkElement(linkEl) {
21930 if (this.trackedLinkElements.has(linkEl)) return;
21931 this.trackedLinkElements.add(linkEl);
21932 this.trackStylesheetInLinkElement(linkEl);
21933 };
21934 _proto.adoptStyleSheets = function adoptStyleSheets(sheets, hostId) {
21935 var _this, _loop = function() {
21936 var sheet = _step.value;
21937 var styleId = void 0;
21938 if (!_this.styleMirror.has(sheet)) {
21939 styleId = _this.styleMirror.add(sheet);
21940 styles.push({
21941 styleId: styleId,
21942 rules: Array.from(sheet.rules || CSSRule, function(r2, index2) {
21943 return {
21944 rule: stringifyRule(r2, sheet.href),
21945 index: index2
21946 };
21947 })
21948 });
21949 } else styleId = _this.styleMirror.getId(sheet);
21950 adoptedStyleSheetData.styleIds.push(styleId);
21951 };
21952 if (sheets.length === 0) return;
21953 var adoptedStyleSheetData = {
21954 id: hostId,
21955 styleIds: []
21956 };
21957 var styles = [];
21958 for(var _iterator = _create_for_of_iterator_helper_loose(sheets), _step; !(_step = _iterator()).done;)_this = this, _loop();
21959 if (styles.length > 0) adoptedStyleSheetData.styles = styles;
21960 this.adoptedStyleSheetCb(adoptedStyleSheetData);
21961 };
21962 _proto.reset = function reset() {
21963 this.styleMirror.reset();
21964 this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
21965 };
21966 // TODO: take snapshot on stylesheet reload by applying event listener
21967 _proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
21968 return StylesheetManager;
21969 }();
21970 var ProcessedNodeManager = /*#__PURE__*/ function() {
21971 function ProcessedNodeManager() {
21972 __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
21973 __publicField(this, "active", false);
21974 }
21975 var _proto = ProcessedNodeManager.prototype;
21976 _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
21977 var buffers = this.nodeMap.get(node2);
21978 return buffers && Array.from(buffers).some(function(buffer) {
21979 return buffer !== thisBuffer;
21980 });
21981 };
21982 _proto.add = function add(node2, buffer) {
21983 var _this = this;
21984 if (!this.active) {
21985 this.active = true;
21986 requestAnimationFrame(function() {
21987 _this.nodeMap = /* @__PURE__ */ new WeakMap();
21988 _this.active = false;
21989 });
21990 }
21991 this.nodeMap.set(node2, (this.nodeMap.get(node2) || /* @__PURE__ */ new Set()).add(buffer));
21992 };
21993 _proto.destroy = function destroy() {};
21994 return ProcessedNodeManager;
21995 }();
21996 var wrappedEmit;
21997 var takeFullSnapshot$1;
21998 var canvasManager;
21999 var recording = false;
22000 try {
22001 if (Array.from([
22002 1
22003 ], function(x2) {
22004 return x2 * 2;
22005 })[0] !== 2) {
22006 var cleanFrame = document.createElement("iframe");
22007 document.body.appendChild(cleanFrame);
22008 Array.from = ((_a = cleanFrame.contentWindow) == null ? void 0 : _a.Array.from) || Array.from;
22009 document.body.removeChild(cleanFrame);
22010 }
22011 } catch (err) {
22012 console.debug("Unable to override Array.from", err);
22013 }
22014 var mirror = createMirror$2();
22015 function record(options) {
22016 if (options === void 0) options = {};
22017 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() {
22018 return false;
22019 } : _options_keepIframeSrcFn, _options_ignoreCSSAttributes = options.ignoreCSSAttributes, ignoreCSSAttributes = _options_ignoreCSSAttributes === void 0 ? /* @__PURE__ */ new Set([]) : _options_ignoreCSSAttributes, errorHandler2 = options.errorHandler;
22020 registerErrorHandler(errorHandler2);
22021 var inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
22022 var passEmitsToParent = false;
22023 if (!inEmittingFrame) {
22024 try {
22025 if (window.parent.document) {
22026 passEmitsToParent = false;
22027 }
22028 } catch (e2) {
22029 passEmitsToParent = true;
22030 }
22031 }
22032 if (inEmittingFrame && !emit) {
22033 throw new Error("emit function is required");
22034 }
22035 if (!inEmittingFrame && !passEmitsToParent) {
22036 return function() {};
22037 }
22038 if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
22039 sampling.mousemove = mousemoveWait;
22040 }
22041 mirror.reset();
22042 var maskInputOptions = maskAllInputs === true ? {
22043 color: true,
22044 date: true,
22045 "datetime-local": true,
22046 email: true,
22047 month: true,
22048 number: true,
22049 range: true,
22050 search: true,
22051 tel: true,
22052 text: true,
22053 time: true,
22054 url: true,
22055 week: true,
22056 textarea: true,
22057 select: true,
22058 password: true,
22059 hidden: true
22060 } : _maskInputOptions !== void 0 ? _maskInputOptions : {
22061 password: true
22062 };
22063 var slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
22064 script: true,
22065 comment: true,
22066 headFavicon: true,
22067 headWhitespace: true,
22068 headMetaSocial: true,
22069 headMetaRobots: true,
22070 headMetaHttpEquiv: true,
22071 headMetaVerification: true,
22072 // the following are off for slimDOMOptions === true,
22073 // as they destroy some (hidden) info:
22074 headMetaAuthorship: _slimDOMOptions === "all",
22075 headMetaDescKeywords: _slimDOMOptions === "all",
22076 headTitleMutations: _slimDOMOptions === "all"
22077 } : _slimDOMOptions ? _slimDOMOptions : {};
22078 polyfill$1();
22079 var lastFullSnapshotEvent;
22080 var incrementalSnapshotCount = 0;
22081 var eventProcessor = function(e2) {
22082 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22083 var plugin3 = _step.value;
22084 if (plugin3.eventProcessor) {
22085 e2 = plugin3.eventProcessor(e2);
22086 }
22087 }
22088 if (packFn && // Disable packing events which will be emitted to parent frames.
22089 !passEmitsToParent) {
22090 e2 = packFn(e2);
22091 }
22092 return e2;
22093 };
22094 wrappedEmit = function(r2, isCheckout) {
22095 var _a2;
22096 var e2 = r2;
22097 e2.timestamp = nowTimestamp();
22098 if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
22099 mutationBuffers.forEach(function(buf) {
22100 return buf.unfreeze();
22101 });
22102 }
22103 if (inEmittingFrame) {
22104 emit == null ? void 0 : emit(eventProcessor(e2), isCheckout);
22105 } else if (passEmitsToParent) {
22106 var message = {
22107 type: "rrweb",
22108 event: eventProcessor(e2),
22109 origin: window.location.origin,
22110 isCheckout: isCheckout
22111 };
22112 window.parent.postMessage(message, "*");
22113 }
22114 if (e2.type === EventType.FullSnapshot) {
22115 lastFullSnapshotEvent = e2;
22116 incrementalSnapshotCount = 0;
22117 } else if (e2.type === EventType.IncrementalSnapshot) {
22118 if (e2.data.source === IncrementalSource.Mutation && e2.data.isAttachIframe) {
22119 return;
22120 }
22121 incrementalSnapshotCount++;
22122 var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
22123 var exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
22124 if (exceedCount || exceedTime) {
22125 takeFullSnapshot$1(true);
22126 }
22127 }
22128 };
22129 var wrappedMutationEmit = function(m) {
22130 wrappedEmit({
22131 type: EventType.IncrementalSnapshot,
22132 data: _extends({
22133 source: IncrementalSource.Mutation
22134 }, m)
22135 });
22136 };
22137 var wrappedScrollEmit = function(p) {
22138 return wrappedEmit({
22139 type: EventType.IncrementalSnapshot,
22140 data: _extends({
22141 source: IncrementalSource.Scroll
22142 }, p)
22143 });
22144 };
22145 var wrappedCanvasMutationEmit = function(p) {
22146 return wrappedEmit({
22147 type: EventType.IncrementalSnapshot,
22148 data: _extends({
22149 source: IncrementalSource.CanvasMutation
22150 }, p)
22151 });
22152 };
22153 var wrappedAdoptedStyleSheetEmit = function(a2) {
22154 return wrappedEmit({
22155 type: EventType.IncrementalSnapshot,
22156 data: _extends({
22157 source: IncrementalSource.AdoptedStyleSheet
22158 }, a2)
22159 });
22160 };
22161 var stylesheetManager = new StylesheetManager({
22162 mutationCb: wrappedMutationEmit,
22163 adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit
22164 });
22165 var iframeManager = new IframeManager({
22166 mirror: mirror,
22167 mutationCb: wrappedMutationEmit,
22168 stylesheetManager: stylesheetManager,
22169 recordCrossOriginIframes: recordCrossOriginIframes,
22170 wrappedEmit: wrappedEmit
22171 });
22172 for(var _iterator = _create_for_of_iterator_helper_loose(plugins || []), _step; !(_step = _iterator()).done;){
22173 var plugin3 = _step.value;
22174 if (plugin3.getMirror) plugin3.getMirror({
22175 nodeMirror: mirror,
22176 crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
22177 crossOriginIframeStyleMirror: iframeManager.crossOriginIframeStyleMirror
22178 });
22179 }
22180 var processedNodeManager = new ProcessedNodeManager();
22181 canvasManager = new CanvasManager({
22182 recordCanvas: recordCanvas,
22183 mutationCb: wrappedCanvasMutationEmit,
22184 win: window,
22185 blockClass: blockClass,
22186 blockSelector: blockSelector,
22187 mirror: mirror,
22188 sampling: sampling.canvas,
22189 dataURLOptions: dataURLOptions
22190 });
22191 var shadowDomManager = new ShadowDomManager({
22192 mutationCb: wrappedMutationEmit,
22193 scrollCb: wrappedScrollEmit,
22194 bypassOptions: {
22195 blockClass: blockClass,
22196 blockSelector: blockSelector,
22197 maskTextClass: maskTextClass,
22198 maskTextSelector: maskTextSelector,
22199 inlineStylesheet: inlineStylesheet,
22200 maskInputOptions: maskInputOptions,
22201 dataURLOptions: dataURLOptions,
22202 maskTextFn: maskTextFn,
22203 maskInputFn: maskInputFn,
22204 recordCanvas: recordCanvas,
22205 inlineImages: inlineImages,
22206 sampling: sampling,
22207 slimDOMOptions: slimDOMOptions,
22208 iframeManager: iframeManager,
22209 stylesheetManager: stylesheetManager,
22210 canvasManager: canvasManager,
22211 keepIframeSrcFn: keepIframeSrcFn,
22212 processedNodeManager: processedNodeManager
22213 },
22214 mirror: mirror
22215 });
22216 takeFullSnapshot$1 = function(isCheckout) {
22217 if (isCheckout === void 0) isCheckout = false;
22218 if (!recordDOM) {
22219 return;
22220 }
22221 wrappedEmit({
22222 type: EventType.Meta,
22223 data: {
22224 href: window.location.href,
22225 width: getWindowWidth(),
22226 height: getWindowHeight()
22227 }
22228 }, isCheckout);
22229 stylesheetManager.reset();
22230 shadowDomManager.init();
22231 mutationBuffers.forEach(function(buf) {
22232 return buf.lock();
22233 });
22234 var node2 = snapshot(document, {
22235 mirror: mirror,
22236 blockClass: blockClass,
22237 blockSelector: blockSelector,
22238 maskTextClass: maskTextClass,
22239 maskTextSelector: maskTextSelector,
22240 inlineStylesheet: inlineStylesheet,
22241 maskAllInputs: maskInputOptions,
22242 maskTextFn: maskTextFn,
22243 maskInputFn: maskInputFn,
22244 slimDOM: slimDOMOptions,
22245 dataURLOptions: dataURLOptions,
22246 recordCanvas: recordCanvas,
22247 inlineImages: inlineImages,
22248 onSerialize: function(n2) {
22249 if (isSerializedIframe(n2, mirror)) {
22250 iframeManager.addIframe(n2);
22251 }
22252 if (isSerializedStylesheet(n2, mirror)) {
22253 stylesheetManager.trackLinkElement(n2);
22254 }
22255 if (hasShadowRoot(n2)) {
22256 shadowDomManager.addShadowRoot(index.shadowRoot(n2), document);
22257 }
22258 },
22259 onIframeLoad: function(iframe, childSn) {
22260 iframeManager.attachIframe(iframe, childSn);
22261 shadowDomManager.observeAttachShadow(iframe);
22262 },
22263 onStylesheetLoad: function(linkEl, childSn) {
22264 stylesheetManager.attachLinkElement(linkEl, childSn);
22265 },
22266 keepIframeSrcFn: keepIframeSrcFn
22267 });
22268 if (!node2) {
22269 return console.warn("Failed to snapshot the document");
22270 }
22271 wrappedEmit({
22272 type: EventType.FullSnapshot,
22273 data: {
22274 node: node2,
22275 initialOffset: getWindowScroll(window)
22276 }
22277 }, isCheckout);
22278 mutationBuffers.forEach(function(buf) {
22279 return buf.unlock();
22280 });
22281 if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0) stylesheetManager.adoptStyleSheets(document.adoptedStyleSheets, mirror.getId(document));
22282 };
22283 try {
22284 var handlers = [];
22285 var observe = function(doc) {
22286 var _a2;
22287 return callbackWrapper(initObservers)({
22288 mutationCb: wrappedMutationEmit,
22289 mousemoveCb: function(positions, source) {
22290 return wrappedEmit({
22291 type: EventType.IncrementalSnapshot,
22292 data: {
22293 source: source,
22294 positions: positions
22295 }
22296 });
22297 },
22298 mouseInteractionCb: function(d) {
22299 return wrappedEmit({
22300 type: EventType.IncrementalSnapshot,
22301 data: _extends({
22302 source: IncrementalSource.MouseInteraction
22303 }, d)
22304 });
22305 },
22306 scrollCb: wrappedScrollEmit,
22307 viewportResizeCb: function(d) {
22308 return wrappedEmit({
22309 type: EventType.IncrementalSnapshot,
22310 data: _extends({
22311 source: IncrementalSource.ViewportResize
22312 }, d)
22313 });
22314 },
22315 inputCb: function(v2) {
22316 return wrappedEmit({
22317 type: EventType.IncrementalSnapshot,
22318 data: _extends({
22319 source: IncrementalSource.Input
22320 }, v2)
22321 });
22322 },
22323 mediaInteractionCb: function(p) {
22324 return wrappedEmit({
22325 type: EventType.IncrementalSnapshot,
22326 data: _extends({
22327 source: IncrementalSource.MediaInteraction
22328 }, p)
22329 });
22330 },
22331 styleSheetRuleCb: function(r2) {
22332 return wrappedEmit({
22333 type: EventType.IncrementalSnapshot,
22334 data: _extends({
22335 source: IncrementalSource.StyleSheetRule
22336 }, r2)
22337 });
22338 },
22339 styleDeclarationCb: function(r2) {
22340 return wrappedEmit({
22341 type: EventType.IncrementalSnapshot,
22342 data: _extends({
22343 source: IncrementalSource.StyleDeclaration
22344 }, r2)
22345 });
22346 },
22347 canvasMutationCb: wrappedCanvasMutationEmit,
22348 fontCb: function(p) {
22349 return wrappedEmit({
22350 type: EventType.IncrementalSnapshot,
22351 data: _extends({
22352 source: IncrementalSource.Font
22353 }, p)
22354 });
22355 },
22356 selectionCb: function(p) {
22357 wrappedEmit({
22358 type: EventType.IncrementalSnapshot,
22359 data: _extends({
22360 source: IncrementalSource.Selection
22361 }, p)
22362 });
22363 },
22364 customElementCb: function(c2) {
22365 wrappedEmit({
22366 type: EventType.IncrementalSnapshot,
22367 data: _extends({
22368 source: IncrementalSource.CustomElement
22369 }, c2)
22370 });
22371 },
22372 blockClass: blockClass,
22373 ignoreClass: ignoreClass,
22374 ignoreSelector: ignoreSelector,
22375 maskTextClass: maskTextClass,
22376 maskTextSelector: maskTextSelector,
22377 maskInputOptions: maskInputOptions,
22378 inlineStylesheet: inlineStylesheet,
22379 sampling: sampling,
22380 recordDOM: recordDOM,
22381 recordCanvas: recordCanvas,
22382 inlineImages: inlineImages,
22383 userTriggeredOnInput: userTriggeredOnInput,
22384 collectFonts: collectFonts,
22385 doc: doc,
22386 maskInputFn: maskInputFn,
22387 maskTextFn: maskTextFn,
22388 keepIframeSrcFn: keepIframeSrcFn,
22389 blockSelector: blockSelector,
22390 slimDOMOptions: slimDOMOptions,
22391 dataURLOptions: dataURLOptions,
22392 mirror: mirror,
22393 iframeManager: iframeManager,
22394 stylesheetManager: stylesheetManager,
22395 shadowDomManager: shadowDomManager,
22396 processedNodeManager: processedNodeManager,
22397 canvasManager: canvasManager,
22398 ignoreCSSAttributes: ignoreCSSAttributes,
22399 plugins: ((_a2 = plugins == null ? void 0 : plugins.filter(function(p) {
22400 return p.observer;
22401 })) == null ? void 0 : _a2.map(function(p) {
22402 return {
22403 observer: p.observer,
22404 options: p.options,
22405 callback: function(payload) {
22406 return wrappedEmit({
22407 type: EventType.Plugin,
22408 data: {
22409 plugin: p.name,
22410 payload: payload
22411 }
22412 });
22413 }
22414 };
22415 })) || []
22416 }, hooks);
22417 };
22418 iframeManager.addLoadListener(function(iframeEl) {
22419 try {
22420 handlers.push(observe(iframeEl.contentDocument));
22421 } catch (error) {
22422 console.warn(error);
22423 }
22424 });
22425 var init = function() {
22426 takeFullSnapshot$1();
22427 handlers.push(observe(document));
22428 recording = true;
22429 };
22430 if (document.readyState === "interactive" || document.readyState === "complete") {
22431 init();
22432 } else {
22433 handlers.push(on("DOMContentLoaded", function() {
22434 wrappedEmit({
22435 type: EventType.DomContentLoaded,
22436 data: {}
22437 });
22438 if (recordAfter === "DOMContentLoaded") init();
22439 }));
22440 handlers.push(on("load", function() {
22441 wrappedEmit({
22442 type: EventType.Load,
22443 data: {}
22444 });
22445 if (recordAfter === "load") init();
22446 }, window));
22447 }
22448 return function() {
22449 handlers.forEach(function(handler) {
22450 try {
22451 handler();
22452 } catch (error) {
22453 var msg = String(error).toLowerCase();
22454 if (!msg.includes("cross-origin")) {
22455 console.warn(error);
22456 }
22457 }
22458 });
22459 processedNodeManager.destroy();
22460 recording = false;
22461 unregisterErrorHandler();
22462 };
22463 } catch (error) {
22464 console.warn(error);
22465 }
22466 }
22467 record.addCustomEvent = function(tag, payload) {
22468 if (!recording) {
22469 throw new Error("please add custom event after start recording");
22470 }
22471 wrappedEmit({
22472 type: EventType.Custom,
22473 data: {
22474 tag: tag,
22475 payload: payload
22476 }
22477 });
22478 };
22479 record.freezePage = function() {
22480 mutationBuffers.forEach(function(buf) {
22481 return buf.freeze();
22482 });
22483 };
22484 record.takeFullSnapshot = function(isCheckout) {
22485 if (!recording) {
22486 throw new Error("please take full snapshot after start recording");
22487 }
22488 takeFullSnapshot$1(isCheckout);
22489 };
22490 record.mirror = mirror;
22491 var n;
22492 !function(t2) {
22493 t2[t2.NotStarted = 0] = "NotStarted", t2[t2.Running = 1] = "Running", t2[t2.Stopped = 2] = "Stopped";
22494 }(n || (n = {}));
22495 record.addCustomEvent;
22496 record.freezePage;
22497 record.takeFullSnapshot;
22498
22499 var setImmediate = win['setImmediate'];
22500 var builtInProp, cycle, schedulingQueue,
22501 ToString = Object.prototype.toString,
22502 timer = (typeof setImmediate !== 'undefined') ?
22503 function timer(fn) { return setImmediate(fn); } :
22504 setTimeout;
22505
22506 // dammit, IE8.
22507 try {
22508 Object.defineProperty({},'x',{});
22509 builtInProp = function builtInProp(obj,name,val,config) {
22510 return Object.defineProperty(obj,name,{
22511 value: val,
22512 writable: true,
22513 configurable: config !== false
22514 });
22515 };
22516 }
22517 catch (err) {
22518 builtInProp = function builtInProp(obj,name,val) {
22519 obj[name] = val;
22520 return obj;
22521 };
22522 }
22523
22524 // Note: using a queue instead of array for efficiency
22525 schedulingQueue = (function Queue() {
22526 var first, last, item;
22527
22528 function Item(fn,self) {
22529 this.fn = fn;
22530 this.self = self;
22531 this.next = void 0;
22532 }
22533
22534 return {
22535 add: function add(fn,self) {
22536 item = new Item(fn,self);
22537 if (last) {
22538 last.next = item;
22539 }
22540 else {
22541 first = item;
22542 }
22543 last = item;
22544 item = void 0;
22545 },
22546 drain: function drain() {
22547 var f = first;
22548 first = last = cycle = void 0;
22549
22550 while (f) {
22551 f.fn.call(f.self);
22552 f = f.next;
22553 }
22554 }
22555 };
22556 })();
22557
22558 function schedule(fn,self) {
22559 schedulingQueue.add(fn,self);
22560 if (!cycle) {
22561 cycle = timer(schedulingQueue.drain);
22562 }
22563 }
22564
22565 // promise duck typing
22566 function isThenable(o) {
22567 var _then, oType = typeof o;
22568
22569 if (o !== null && (oType === 'object' || oType === 'function')) {
22570 _then = o.then;
22571 }
22572 return typeof _then === 'function' ? _then : false;
22573 }
22574
22575 function notify() {
22576 for (var i=0; i<this.chain.length; i++) {
22577 notifyIsolated(
22578 this,
22579 (this.state === 1) ? this.chain[i].success : this.chain[i].failure,
22580 this.chain[i]
22581 );
22582 }
22583 this.chain.length = 0;
22584 }
22585
22586 // NOTE: This is a separate function to isolate
22587 // the `try..catch` so that other code can be
22588 // optimized better
22589 function notifyIsolated(self,cb,chain) {
22590 var ret, _then;
22591 try {
22592 if (cb === false) {
22593 chain.reject(self.msg);
22594 }
22595 else {
22596 if (cb === true) {
22597 ret = self.msg;
22598 }
22599 else {
22600 ret = cb.call(void 0,self.msg);
22601 }
22602
22603 if (ret === chain.promise) {
22604 chain.reject(TypeError('Promise-chain cycle'));
22605 }
22606 // eslint-disable-next-line no-cond-assign
22607 else if (_then = isThenable(ret)) {
22608 _then.call(ret,chain.resolve,chain.reject);
22609 }
22610 else {
22611 chain.resolve(ret);
22612 }
22613 }
22614 }
22615 catch (err) {
22616 chain.reject(err);
22617 }
22618 }
22619
22620 function resolve(msg) {
22621 var _then, self = this;
22622
22623 // already triggered?
22624 if (self.triggered) { return; }
22625
22626 self.triggered = true;
22627
22628 // unwrap
22629 if (self.def) {
22630 self = self.def;
22631 }
22632
22633 try {
22634 // eslint-disable-next-line no-cond-assign
22635 if (_then = isThenable(msg)) {
22636 schedule(function(){
22637 var defWrapper = new MakeDefWrapper(self);
22638 try {
22639 _then.call(msg,
22640 function $resolve$(){ resolve.apply(defWrapper,arguments); },
22641 function $reject$(){ reject.apply(defWrapper,arguments); }
22642 );
22643 }
22644 catch (err) {
22645 reject.call(defWrapper,err);
22646 }
22647 });
22648 }
22649 else {
22650 self.msg = msg;
22651 self.state = 1;
22652 if (self.chain.length > 0) {
22653 schedule(notify,self);
22654 }
22655 }
22656 }
22657 catch (err) {
22658 reject.call(new MakeDefWrapper(self),err);
22659 }
22660 }
22661
22662 function reject(msg) {
22663 var self = this;
22664
22665 // already triggered?
22666 if (self.triggered) { return; }
22667
22668 self.triggered = true;
22669
22670 // unwrap
22671 if (self.def) {
22672 self = self.def;
22673 }
22674
22675 self.msg = msg;
22676 self.state = 2;
22677 if (self.chain.length > 0) {
22678 schedule(notify,self);
22679 }
22680 }
22681
22682 function iteratePromises(Constructor,arr,resolver,rejecter) {
22683 for (var idx=0; idx<arr.length; idx++) {
22684 (function IIFE(idx){
22685 Constructor.resolve(arr[idx])
22686 .then(
22687 function $resolver$(msg){
22688 resolver(idx,msg);
22689 },
22690 rejecter
22691 );
22692 })(idx);
22693 }
22694 }
22695
22696 function MakeDefWrapper(self) {
22697 this.def = self;
22698 this.triggered = false;
22699 }
22700
22701 function MakeDef(self) {
22702 this.promise = self;
22703 this.state = 0;
22704 this.triggered = false;
22705 this.chain = [];
22706 this.msg = void 0;
22707 }
22708
22709 function NpoPromise(executor) {
22710 if (typeof executor !== 'function') {
22711 throw TypeError('Not a function');
22712 }
22713
22714 if (this['__NPO__'] !== 0) {
22715 throw TypeError('Not a promise');
22716 }
22717
22718 // instance shadowing the inherited "brand"
22719 // to signal an already "initialized" promise
22720 this['__NPO__'] = 1;
22721
22722 var def = new MakeDef(this);
22723
22724 this['then'] = function then(success,failure) {
22725 var o = {
22726 success: typeof success === 'function' ? success : true,
22727 failure: typeof failure === 'function' ? failure : false
22728 };
22729 // Note: `then(..)` itself can be borrowed to be used against
22730 // a different promise constructor for making the chained promise,
22731 // by substituting a different `this` binding.
22732 o.promise = new this.constructor(function extractChain(resolve,reject) {
22733 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22734 throw TypeError('Not a function');
22735 }
22736
22737 o.resolve = resolve;
22738 o.reject = reject;
22739 });
22740 def.chain.push(o);
22741
22742 if (def.state !== 0) {
22743 schedule(notify,def);
22744 }
22745
22746 return o.promise;
22747 };
22748 this['catch'] = function $catch$(failure) {
22749 return this.then(void 0,failure);
22750 };
22751
22752 try {
22753 executor.call(
22754 void 0,
22755 function publicResolve(msg){
22756 resolve.call(def,msg);
22757 },
22758 function publicReject(msg) {
22759 reject.call(def,msg);
22760 }
22761 );
22762 }
22763 catch (err) {
22764 reject.call(def,err);
22765 }
22766 }
22767
22768 var PromisePrototype = builtInProp({},'constructor',NpoPromise,
22769 /*configurable=*/false
22770 );
22771
22772 // Note: Android 4 cannot use `Object.defineProperty(..)` here
22773 NpoPromise.prototype = PromisePrototype;
22774
22775 // built-in "brand" to signal an "uninitialized" promise
22776 builtInProp(PromisePrototype,'__NPO__',0,
22777 /*configurable=*/false
22778 );
22779
22780 builtInProp(NpoPromise,'resolve',function Promise$resolve(msg) {
22781 var Constructor = this;
22782
22783 // spec mandated checks
22784 // note: best "isPromise" check that's practical for now
22785 if (msg && typeof msg === 'object' && msg['__NPO__'] === 1) {
22786 return msg;
22787 }
22788
22789 return new Constructor(function executor(resolve,reject){
22790 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22791 throw TypeError('Not a function');
22792 }
22793
22794 resolve(msg);
22795 });
22796 });
22797
22798 builtInProp(NpoPromise,'reject',function Promise$reject(msg) {
22799 return new this(function executor(resolve,reject){
22800 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22801 throw TypeError('Not a function');
22802 }
22803
22804 reject(msg);
22805 });
22806 });
22807
22808 builtInProp(NpoPromise,'all',function Promise$all(arr) {
22809 var Constructor = this;
22810
22811 // spec mandated checks
22812 if (ToString.call(arr) !== '[object Array]') {
22813 return Constructor.reject(TypeError('Not an array'));
22814 }
22815 if (arr.length === 0) {
22816 return Constructor.resolve([]);
22817 }
22818
22819 return new Constructor(function executor(resolve,reject){
22820 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22821 throw TypeError('Not a function');
22822 }
22823
22824 var len = arr.length, msgs = Array(len), count = 0;
22825
22826 iteratePromises(Constructor,arr,function resolver(idx,msg) {
22827 msgs[idx] = msg;
22828 if (++count === len) {
22829 resolve(msgs);
22830 }
22831 },reject);
22832 });
22833 });
22834
22835 builtInProp(NpoPromise,'race',function Promise$race(arr) {
22836 var Constructor = this;
22837
22838 // spec mandated checks
22839 if (ToString.call(arr) !== '[object Array]') {
22840 return Constructor.reject(TypeError('Not an array'));
22841 }
22842
22843 return new Constructor(function executor(resolve,reject){
22844 if (typeof resolve !== 'function' || typeof reject !== 'function') {
22845 throw TypeError('Not a function');
22846 }
22847
22848 iteratePromises(Constructor,arr,function resolver(idx,msg){
22849 resolve(msg);
22850 },reject);
22851 });
22852 });
22853
22854 var PromisePolyfill;
22855 if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]') !== -1) {
22856 PromisePolyfill = Promise;
22857 } else {
22858 PromisePolyfill = NpoPromise;
22859 }
22860
22861 var Config = {
22862 DEBUG: false,
22863 LIB_VERSION: '2.71.1'
22864 };
22865
22866 /* eslint camelcase: "off", eqeqeq: "off" */
22867
22868 // Maximum allowed session recording length
22869 var MAX_RECORDING_MS = 24 * 60 * 60 * 1000; // 24 hours
22870 // Maximum allowed value for minimum session recording length
22871 var MAX_VALUE_FOR_MIN_RECORDING_MS = 8 * 1000; // 8 seconds
22872
22873 /*
22874 * Saved references to long variable names, so that closure compiler can
22875 * minimize file size.
22876 */
22877
22878 var ArrayProto = Array.prototype,
22879 FuncProto = Function.prototype,
22880 ObjProto = Object.prototype,
22881 slice = ArrayProto.slice,
22882 toString = ObjProto.toString,
22883 hasOwnProperty = ObjProto.hasOwnProperty,
22884 windowConsole = win.console,
22885 navigator = win.navigator,
22886 document$1 = win.document,
22887 windowOpera = win.opera,
22888 screen = win.screen,
22889 userAgent = navigator.userAgent;
22890
22891 var nativeBind = FuncProto.bind,
22892 nativeForEach = ArrayProto.forEach,
22893 nativeIndexOf = ArrayProto.indexOf,
22894 nativeMap = ArrayProto.map,
22895 nativeIsArray = Array.isArray,
22896 breaker = {};
22897
22898 var _ = {
22899 trim: function(str) {
22900 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
22901 return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
22902 }
22903 };
22904
22905 // Console override
22906 var console$1 = {
22907 /** @type {function(...*)} */
22908 log: function() {
22909 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22910 try {
22911 windowConsole.log.apply(windowConsole, arguments);
22912 } catch (err) {
22913 _.each(arguments, function(arg) {
22914 windowConsole.log(arg);
22915 });
22916 }
22917 }
22918 },
22919 /** @type {function(...*)} */
22920 warn: function() {
22921 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22922 var args = ['Mixpanel warning:'].concat(_.toArray(arguments));
22923 try {
22924 windowConsole.warn.apply(windowConsole, args);
22925 } catch (err) {
22926 _.each(args, function(arg) {
22927 windowConsole.warn(arg);
22928 });
22929 }
22930 }
22931 },
22932 /** @type {function(...*)} */
22933 error: function() {
22934 if (Config.DEBUG && !_.isUndefined(windowConsole) && windowConsole) {
22935 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22936 try {
22937 windowConsole.error.apply(windowConsole, args);
22938 } catch (err) {
22939 _.each(args, function(arg) {
22940 windowConsole.error(arg);
22941 });
22942 }
22943 }
22944 },
22945 /** @type {function(...*)} */
22946 critical: function() {
22947 if (!_.isUndefined(windowConsole) && windowConsole) {
22948 var args = ['Mixpanel error:'].concat(_.toArray(arguments));
22949 try {
22950 windowConsole.error.apply(windowConsole, args);
22951 } catch (err) {
22952 _.each(args, function(arg) {
22953 windowConsole.error(arg);
22954 });
22955 }
22956 }
22957 }
22958 };
22959
22960 var log_func_with_prefix = function(func, prefix) {
22961 return function() {
22962 arguments[0] = '[' + prefix + '] ' + arguments[0];
22963 return func.apply(console$1, arguments);
22964 };
22965 };
22966 var console_with_prefix = function(prefix) {
22967 return {
22968 log: log_func_with_prefix(console$1.log, prefix),
22969 error: log_func_with_prefix(console$1.error, prefix),
22970 critical: log_func_with_prefix(console$1.critical, prefix)
22971 };
22972 };
22973
22974
22975 var safewrap = function(f) {
22976 return function() {
22977 try {
22978 return f.apply(this, arguments);
22979 } catch (e) {
22980 console$1.critical('Implementation error. Please turn on debug and contact support@mixpanel.com.');
22981 if (Config.DEBUG){
22982 console$1.critical(e);
22983 }
22984 }
22985 };
22986 };
22987
22988 var safewrapClass = function(klass) {
22989 var proto = klass.prototype;
22990 for (var func in proto) {
22991 if (typeof(proto[func]) === 'function') {
22992 proto[func] = safewrap(proto[func]);
22993 }
22994 }
22995 };
22996
22997
22998 // UNDERSCORE
22999 // Embed part of the Underscore Library
23000 _.bind = function(func, context) {
23001 var args, bound;
23002 if (nativeBind && func.bind === nativeBind) {
23003 return nativeBind.apply(func, slice.call(arguments, 1));
23004 }
23005 if (!_.isFunction(func)) {
23006 throw new TypeError();
23007 }
23008 args = slice.call(arguments, 2);
23009 bound = function() {
23010 if (!(this instanceof bound)) {
23011 return func.apply(context, args.concat(slice.call(arguments)));
23012 }
23013 var ctor = {};
23014 ctor.prototype = func.prototype;
23015 var self = new ctor();
23016 ctor.prototype = null;
23017 var result = func.apply(self, args.concat(slice.call(arguments)));
23018 if (Object(result) === result) {
23019 return result;
23020 }
23021 return self;
23022 };
23023 return bound;
23024 };
23025
23026 /**
23027 * @param {*=} obj
23028 * @param {function(...*)=} iterator
23029 * @param {Object=} context
23030 */
23031 _.each = function(obj, iterator, context) {
23032 if (obj === null || obj === undefined) {
23033 return;
23034 }
23035 if (nativeForEach && obj.forEach === nativeForEach) {
23036 obj.forEach(iterator, context);
23037 } else if (obj.length === +obj.length) {
23038 for (var i = 0, l = obj.length; i < l; i++) {
23039 if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) {
23040 return;
23041 }
23042 }
23043 } else {
23044 for (var key in obj) {
23045 if (hasOwnProperty.call(obj, key)) {
23046 if (iterator.call(context, obj[key], key, obj) === breaker) {
23047 return;
23048 }
23049 }
23050 }
23051 }
23052 };
23053
23054 _.extend = function(obj) {
23055 _.each(slice.call(arguments, 1), function(source) {
23056 for (var prop in source) {
23057 if (source[prop] !== void 0) {
23058 obj[prop] = source[prop];
23059 }
23060 }
23061 });
23062 return obj;
23063 };
23064
23065 _.isArray = nativeIsArray || function(obj) {
23066 return toString.call(obj) === '[object Array]';
23067 };
23068
23069 // from a comment on http://dbj.org/dbj/?p=286
23070 // fails on only one very rare and deliberate custom object:
23071 // var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
23072 _.isFunction = function(f) {
23073 try {
23074 return /^\s*\bfunction\b/.test(f);
23075 } catch (x) {
23076 return false;
23077 }
23078 };
23079
23080 _.isArguments = function(obj) {
23081 return !!(obj && hasOwnProperty.call(obj, 'callee'));
23082 };
23083
23084 _.toArray = function(iterable) {
23085 if (!iterable) {
23086 return [];
23087 }
23088 if (iterable.toArray) {
23089 return iterable.toArray();
23090 }
23091 if (_.isArray(iterable)) {
23092 return slice.call(iterable);
23093 }
23094 if (_.isArguments(iterable)) {
23095 return slice.call(iterable);
23096 }
23097 return _.values(iterable);
23098 };
23099
23100 _.map = function(arr, callback, context) {
23101 if (nativeMap && arr.map === nativeMap) {
23102 return arr.map(callback, context);
23103 } else {
23104 var results = [];
23105 _.each(arr, function(item) {
23106 results.push(callback.call(context, item));
23107 });
23108 return results;
23109 }
23110 };
23111
23112 _.keys = function(obj) {
23113 var results = [];
23114 if (obj === null) {
23115 return results;
23116 }
23117 _.each(obj, function(value, key) {
23118 results[results.length] = key;
23119 });
23120 return results;
23121 };
23122
23123 _.values = function(obj) {
23124 var results = [];
23125 if (obj === null) {
23126 return results;
23127 }
23128 _.each(obj, function(value) {
23129 results[results.length] = value;
23130 });
23131 return results;
23132 };
23133
23134 _.include = function(obj, target) {
23135 var found = false;
23136 if (obj === null) {
23137 return found;
23138 }
23139 if (nativeIndexOf && obj.indexOf === nativeIndexOf) {
23140 return obj.indexOf(target) != -1;
23141 }
23142 _.each(obj, function(value) {
23143 if (found || (found = (value === target))) {
23144 return breaker;
23145 }
23146 });
23147 return found;
23148 };
23149
23150 _.includes = function(str, needle) {
23151 return str.indexOf(needle) !== -1;
23152 };
23153
23154 // Underscore Addons
23155 _.inherit = function(subclass, superclass) {
23156 subclass.prototype = new superclass();
23157 subclass.prototype.constructor = subclass;
23158 subclass.superclass = superclass.prototype;
23159 return subclass;
23160 };
23161
23162 _.isObject = function(obj) {
23163 return (obj === Object(obj) && !_.isArray(obj));
23164 };
23165
23166 _.isEmptyObject = function(obj) {
23167 if (_.isObject(obj)) {
23168 for (var key in obj) {
23169 if (hasOwnProperty.call(obj, key)) {
23170 return false;
23171 }
23172 }
23173 return true;
23174 }
23175 return false;
23176 };
23177
23178 _.isUndefined = function(obj) {
23179 return obj === void 0;
23180 };
23181
23182 _.isString = function(obj) {
23183 return toString.call(obj) == '[object String]';
23184 };
23185
23186 _.isDate = function(obj) {
23187 return toString.call(obj) == '[object Date]';
23188 };
23189
23190 _.isNumber = function(obj) {
23191 return toString.call(obj) == '[object Number]';
23192 };
23193
23194 _.isElement = function(obj) {
23195 return !!(obj && obj.nodeType === 1);
23196 };
23197
23198 _.encodeDates = function(obj) {
23199 _.each(obj, function(v, k) {
23200 if (_.isDate(v)) {
23201 obj[k] = _.formatDate(v);
23202 } else if (_.isObject(v)) {
23203 obj[k] = _.encodeDates(v); // recurse
23204 }
23205 });
23206 return obj;
23207 };
23208
23209 _.timestamp = function() {
23210 Date.now = Date.now || function() {
23211 return +new Date;
23212 };
23213 return Date.now();
23214 };
23215
23216 _.formatDate = function(d) {
23217 // YYYY-MM-DDTHH:MM:SS in UTC
23218 function pad(n) {
23219 return n < 10 ? '0' + n : n;
23220 }
23221 return d.getUTCFullYear() + '-' +
23222 pad(d.getUTCMonth() + 1) + '-' +
23223 pad(d.getUTCDate()) + 'T' +
23224 pad(d.getUTCHours()) + ':' +
23225 pad(d.getUTCMinutes()) + ':' +
23226 pad(d.getUTCSeconds());
23227 };
23228
23229 _.strip_empty_properties = function(p) {
23230 var ret = {};
23231 _.each(p, function(v, k) {
23232 if (_.isString(v) && v.length > 0) {
23233 ret[k] = v;
23234 }
23235 });
23236 return ret;
23237 };
23238
23239 /*
23240 * this function returns a copy of object after truncating it. If
23241 * passed an Array or Object it will iterate through obj and
23242 * truncate all the values recursively.
23243 */
23244 _.truncate = function(obj, length) {
23245 var ret;
23246
23247 if (typeof(obj) === 'string') {
23248 ret = obj.slice(0, length);
23249 } else if (_.isArray(obj)) {
23250 ret = [];
23251 _.each(obj, function(val) {
23252 ret.push(_.truncate(val, length));
23253 });
23254 } else if (_.isObject(obj)) {
23255 ret = {};
23256 _.each(obj, function(val, key) {
23257 ret[key] = _.truncate(val, length);
23258 });
23259 } else {
23260 ret = obj;
23261 }
23262
23263 return ret;
23264 };
23265
23266 _.JSONEncode = (function() {
23267 return function(mixed_val) {
23268 var value = mixed_val;
23269 var quote = function(string) {
23270 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
23271 var meta = { // table of character substitutions
23272 '\b': '\\b',
23273 '\t': '\\t',
23274 '\n': '\\n',
23275 '\f': '\\f',
23276 '\r': '\\r',
23277 '"': '\\"',
23278 '\\': '\\\\'
23279 };
23280
23281 escapable.lastIndex = 0;
23282 return escapable.test(string) ?
23283 '"' + string.replace(escapable, function(a) {
23284 var c = meta[a];
23285 return typeof c === 'string' ? c :
23286 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
23287 }) + '"' :
23288 '"' + string + '"';
23289 };
23290
23291 var str = function(key, holder) {
23292 var gap = '';
23293 var indent = ' ';
23294 var i = 0; // The loop counter.
23295 var k = ''; // The member key.
23296 var v = ''; // The member value.
23297 var length = 0;
23298 var mind = gap;
23299 var partial = [];
23300 var value = holder[key];
23301
23302 // If the value has a toJSON method, call it to obtain a replacement value.
23303 if (value && typeof value === 'object' &&
23304 typeof value.toJSON === 'function') {
23305 value = value.toJSON(key);
23306 }
23307
23308 // What happens next depends on the value's type.
23309 switch (typeof value) {
23310 case 'string':
23311 return quote(value);
23312
23313 case 'number':
23314 // JSON numbers must be finite. Encode non-finite numbers as null.
23315 return isFinite(value) ? String(value) : 'null';
23316
23317 case 'boolean':
23318 case 'null':
23319 // If the value is a boolean or null, convert it to a string. Note:
23320 // typeof null does not produce 'null'. The case is included here in
23321 // the remote chance that this gets fixed someday.
23322
23323 return String(value);
23324
23325 case 'object':
23326 // If the type is 'object', we might be dealing with an object or an array or
23327 // null.
23328 // Due to a specification blunder in ECMAScript, typeof null is 'object',
23329 // so watch out for that case.
23330 if (!value) {
23331 return 'null';
23332 }
23333
23334 // Make an array to hold the partial results of stringifying this object value.
23335 gap += indent;
23336 partial = [];
23337
23338 // Is the value an array?
23339 if (toString.apply(value) === '[object Array]') {
23340 // The value is an array. Stringify every element. Use null as a placeholder
23341 // for non-JSON values.
23342
23343 length = value.length;
23344 for (i = 0; i < length; i += 1) {
23345 partial[i] = str(i, value) || 'null';
23346 }
23347
23348 // Join all of the elements together, separated with commas, and wrap them in
23349 // brackets.
23350 v = partial.length === 0 ? '[]' :
23351 gap ? '[\n' + gap +
23352 partial.join(',\n' + gap) + '\n' +
23353 mind + ']' :
23354 '[' + partial.join(',') + ']';
23355 gap = mind;
23356 return v;
23357 }
23358
23359 // Iterate through all of the keys in the object.
23360 for (k in value) {
23361 if (hasOwnProperty.call(value, k)) {
23362 v = str(k, value);
23363 if (v) {
23364 partial.push(quote(k) + (gap ? ': ' : ':') + v);
23365 }
23366 }
23367 }
23368
23369 // Join all of the member texts together, separated with commas,
23370 // and wrap them in braces.
23371 v = partial.length === 0 ? '{}' :
23372 gap ? '{' + partial.join(',') + '' +
23373 mind + '}' : '{' + partial.join(',') + '}';
23374 gap = mind;
23375 return v;
23376 }
23377 };
23378
23379 // Make a fake root object containing our value under the key of ''.
23380 // Return the result of stringifying the value.
23381 return str('', {
23382 '': value
23383 });
23384 };
23385 })();
23386
23387 /**
23388 * From https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
23389 * Slightly modified to throw a real Error rather than a POJO
23390 */
23391 _.JSONDecode = (function() {
23392 var at, // The index of the current character
23393 ch, // The current character
23394 escapee = {
23395 '"': '"',
23396 '\\': '\\',
23397 '/': '/',
23398 'b': '\b',
23399 'f': '\f',
23400 'n': '\n',
23401 'r': '\r',
23402 't': '\t'
23403 },
23404 text,
23405 error = function(m) {
23406 var e = new SyntaxError(m);
23407 e.at = at;
23408 e.text = text;
23409 throw e;
23410 },
23411 next = function(c) {
23412 // If a c parameter is provided, verify that it matches the current character.
23413 if (c && c !== ch) {
23414 error('Expected \'' + c + '\' instead of \'' + ch + '\'');
23415 }
23416 // Get the next character. When there are no more characters,
23417 // return the empty string.
23418 ch = text.charAt(at);
23419 at += 1;
23420 return ch;
23421 },
23422 number = function() {
23423 // Parse a number value.
23424 var number,
23425 string = '';
23426
23427 if (ch === '-') {
23428 string = '-';
23429 next('-');
23430 }
23431 while (ch >= '0' && ch <= '9') {
23432 string += ch;
23433 next();
23434 }
23435 if (ch === '.') {
23436 string += '.';
23437 while (next() && ch >= '0' && ch <= '9') {
23438 string += ch;
23439 }
23440 }
23441 if (ch === 'e' || ch === 'E') {
23442 string += ch;
23443 next();
23444 if (ch === '-' || ch === '+') {
23445 string += ch;
23446 next();
23447 }
23448 while (ch >= '0' && ch <= '9') {
23449 string += ch;
23450 next();
23451 }
23452 }
23453 number = +string;
23454 if (!isFinite(number)) {
23455 error('Bad number');
23456 } else {
23457 return number;
23458 }
23459 },
23460
23461 string = function() {
23462 // Parse a string value.
23463 var hex,
23464 i,
23465 string = '',
23466 uffff;
23467 // When parsing for string values, we must look for " and \ characters.
23468 if (ch === '"') {
23469 while (next()) {
23470 if (ch === '"') {
23471 next();
23472 return string;
23473 }
23474 if (ch === '\\') {
23475 next();
23476 if (ch === 'u') {
23477 uffff = 0;
23478 for (i = 0; i < 4; i += 1) {
23479 hex = parseInt(next(), 16);
23480 if (!isFinite(hex)) {
23481 break;
23482 }
23483 uffff = uffff * 16 + hex;
23484 }
23485 string += String.fromCharCode(uffff);
23486 } else if (typeof escapee[ch] === 'string') {
23487 string += escapee[ch];
23488 } else {
23489 break;
23490 }
23491 } else {
23492 string += ch;
23493 }
23494 }
23495 }
23496 error('Bad string');
23497 },
23498 white = function() {
23499 // Skip whitespace.
23500 while (ch && ch <= ' ') {
23501 next();
23502 }
23503 },
23504 word = function() {
23505 // true, false, or null.
23506 switch (ch) {
23507 case 't':
23508 next('t');
23509 next('r');
23510 next('u');
23511 next('e');
23512 return true;
23513 case 'f':
23514 next('f');
23515 next('a');
23516 next('l');
23517 next('s');
23518 next('e');
23519 return false;
23520 case 'n':
23521 next('n');
23522 next('u');
23523 next('l');
23524 next('l');
23525 return null;
23526 }
23527 error('Unexpected "' + ch + '"');
23528 },
23529 value, // Placeholder for the value function.
23530 array = function() {
23531 // Parse an array value.
23532 var array = [];
23533
23534 if (ch === '[') {
23535 next('[');
23536 white();
23537 if (ch === ']') {
23538 next(']');
23539 return array; // empty array
23540 }
23541 while (ch) {
23542 array.push(value());
23543 white();
23544 if (ch === ']') {
23545 next(']');
23546 return array;
23547 }
23548 next(',');
23549 white();
23550 }
23551 }
23552 error('Bad array');
23553 },
23554 object = function() {
23555 // Parse an object value.
23556 var key,
23557 object = {};
23558
23559 if (ch === '{') {
23560 next('{');
23561 white();
23562 if (ch === '}') {
23563 next('}');
23564 return object; // empty object
23565 }
23566 while (ch) {
23567 key = string();
23568 white();
23569 next(':');
23570 if (Object.hasOwnProperty.call(object, key)) {
23571 error('Duplicate key "' + key + '"');
23572 }
23573 object[key] = value();
23574 white();
23575 if (ch === '}') {
23576 next('}');
23577 return object;
23578 }
23579 next(',');
23580 white();
23581 }
23582 }
23583 error('Bad object');
23584 };
23585
23586 value = function() {
23587 // Parse a JSON value. It could be an object, an array, a string,
23588 // a number, or a word.
23589 white();
23590 switch (ch) {
23591 case '{':
23592 return object();
23593 case '[':
23594 return array();
23595 case '"':
23596 return string();
23597 case '-':
23598 return number();
23599 default:
23600 return ch >= '0' && ch <= '9' ? number() : word();
23601 }
23602 };
23603
23604 // Return the json_parse function. It will have access to all of the
23605 // above functions and variables.
23606 return function(source) {
23607 var result;
23608
23609 text = source;
23610 at = 0;
23611 ch = ' ';
23612 result = value();
23613 white();
23614 if (ch) {
23615 error('Syntax error');
23616 }
23617
23618 return result;
23619 };
23620 })();
23621
23622 _.base64Encode = function(data) {
23623 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
23624 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
23625 ac = 0,
23626 enc = '',
23627 tmp_arr = [];
23628
23629 if (!data) {
23630 return data;
23631 }
23632
23633 data = _.utf8Encode(data);
23634
23635 do { // pack three octets into four hexets
23636 o1 = data.charCodeAt(i++);
23637 o2 = data.charCodeAt(i++);
23638 o3 = data.charCodeAt(i++);
23639
23640 bits = o1 << 16 | o2 << 8 | o3;
23641
23642 h1 = bits >> 18 & 0x3f;
23643 h2 = bits >> 12 & 0x3f;
23644 h3 = bits >> 6 & 0x3f;
23645 h4 = bits & 0x3f;
23646
23647 // use hexets to index into b64, and append result to encoded string
23648 tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
23649 } while (i < data.length);
23650
23651 enc = tmp_arr.join('');
23652
23653 switch (data.length % 3) {
23654 case 1:
23655 enc = enc.slice(0, -2) + '==';
23656 break;
23657 case 2:
23658 enc = enc.slice(0, -1) + '=';
23659 break;
23660 }
23661
23662 return enc;
23663 };
23664
23665 _.utf8Encode = function(string) {
23666 string = (string + '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
23667
23668 var utftext = '',
23669 start,
23670 end;
23671 var stringl = 0,
23672 n;
23673
23674 start = end = 0;
23675 stringl = string.length;
23676
23677 for (n = 0; n < stringl; n++) {
23678 var c1 = string.charCodeAt(n);
23679 var enc = null;
23680
23681 if (c1 < 128) {
23682 end++;
23683 } else if ((c1 > 127) && (c1 < 2048)) {
23684 enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128);
23685 } else {
23686 enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128);
23687 }
23688 if (enc !== null) {
23689 if (end > start) {
23690 utftext += string.substring(start, end);
23691 }
23692 utftext += enc;
23693 start = end = n + 1;
23694 }
23695 }
23696
23697 if (end > start) {
23698 utftext += string.substring(start, string.length);
23699 }
23700
23701 return utftext;
23702 };
23703
23704 _.UUID = function() {
23705 try {
23706 // use native Crypto API when available
23707 return win['crypto']['randomUUID']();
23708 } catch (err) {
23709 // fall back to generating our own UUID
23710 // based on https://gist.github.com/scwood/3bff42cc005cc20ab7ec98f0d8e1d59d
23711 var uuid = new Array(36);
23712 for (var i = 0; i < 36; i++) {
23713 uuid[i] = Math.floor(Math.random() * 16);
23714 }
23715 uuid[14] = 4; // set bits 12-15 of time-high-and-version to 0100
23716 uuid[19] = uuid[19] &= -5; // set bit 6 of clock-seq-and-reserved to zero
23717 uuid[19] = uuid[19] |= (1 << 3); // set bit 7 of clock-seq-and-reserved to one
23718 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
23719
23720 return _.map(uuid, function(x) {
23721 return x.toString(16);
23722 }).join('');
23723 }
23724 };
23725
23726 // _.isBlockedUA()
23727 // This is to block various web spiders from executing our JS and
23728 // sending false tracking data
23729 var BLOCKED_UA_STRS = [
23730 'ahrefsbot',
23731 'ahrefssiteaudit',
23732 'amazonbot',
23733 'baiduspider',
23734 'bingbot',
23735 'bingpreview',
23736 'chrome-lighthouse',
23737 'facebookexternal',
23738 'petalbot',
23739 'pinterest',
23740 'screaming frog',
23741 'yahoo! slurp',
23742 'yandex',
23743
23744 // a whole bunch of goog-specific crawlers
23745 // https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
23746 'adsbot-google',
23747 'apis-google',
23748 'duplexweb-google',
23749 'feedfetcher-google',
23750 'google favicon',
23751 'google web preview',
23752 'google-read-aloud',
23753 'googlebot',
23754 'googleweblight',
23755 'mediapartners-google',
23756 'storebot-google'
23757 ];
23758 _.isBlockedUA = function(ua) {
23759 var i;
23760 ua = ua.toLowerCase();
23761 for (i = 0; i < BLOCKED_UA_STRS.length; i++) {
23762 if (ua.indexOf(BLOCKED_UA_STRS[i]) !== -1) {
23763 return true;
23764 }
23765 }
23766 return false;
23767 };
23768
23769 /**
23770 * @param {Object=} formdata
23771 * @param {string=} arg_separator
23772 */
23773 _.HTTPBuildQuery = function(formdata, arg_separator) {
23774 var use_val, use_key, tmp_arr = [];
23775
23776 if (_.isUndefined(arg_separator)) {
23777 arg_separator = '&';
23778 }
23779
23780 _.each(formdata, function(val, key) {
23781 use_val = encodeURIComponent(val.toString());
23782 use_key = encodeURIComponent(key);
23783 tmp_arr[tmp_arr.length] = use_key + '=' + use_val;
23784 });
23785
23786 return tmp_arr.join(arg_separator);
23787 };
23788
23789 _.getQueryParam = function(url, param) {
23790 // Expects a raw URL
23791
23792 param = param.replace(/[[]/g, '\\[').replace(/[\]]/g, '\\]');
23793 var regexS = '[\\?&]' + param + '=([^&#]*)',
23794 regex = new RegExp(regexS),
23795 results = regex.exec(url);
23796 if (results === null || (results && typeof(results[1]) !== 'string' && results[1].length)) {
23797 return '';
23798 } else {
23799 var result = results[1];
23800 try {
23801 result = decodeURIComponent(result);
23802 } catch(err) {
23803 console$1.error('Skipping decoding for malformed query param: ' + result);
23804 }
23805 return result.replace(/\+/g, ' ');
23806 }
23807 };
23808
23809
23810 // _.cookie
23811 // Methods partially borrowed from quirksmode.org/js/cookies.html
23812 _.cookie = {
23813 get: function(name) {
23814 var nameEQ = name + '=';
23815 var ca = document$1.cookie.split(';');
23816 for (var i = 0; i < ca.length; i++) {
23817 var c = ca[i];
23818 while (c.charAt(0) == ' ') {
23819 c = c.substring(1, c.length);
23820 }
23821 if (c.indexOf(nameEQ) === 0) {
23822 return decodeURIComponent(c.substring(nameEQ.length, c.length));
23823 }
23824 }
23825 return null;
23826 },
23827
23828 parse: function(name) {
23829 var cookie;
23830 try {
23831 cookie = _.JSONDecode(_.cookie.get(name)) || {};
23832 } catch (err) {
23833 // noop
23834 }
23835 return cookie;
23836 },
23837
23838 set_seconds: function(name, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23839 var cdomain = '',
23840 expires = '',
23841 secure = '';
23842
23843 if (domain_override) {
23844 cdomain = '; domain=' + domain_override;
23845 } else if (is_cross_subdomain) {
23846 var domain = extract_domain(document$1.location.hostname);
23847 cdomain = domain ? '; domain=.' + domain : '';
23848 }
23849
23850 if (seconds) {
23851 var date = new Date();
23852 date.setTime(date.getTime() + (seconds * 1000));
23853 expires = '; expires=' + date.toGMTString();
23854 }
23855
23856 if (is_cross_site) {
23857 is_secure = true;
23858 secure = '; SameSite=None';
23859 }
23860 if (is_secure) {
23861 secure += '; secure';
23862 }
23863
23864 document$1.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23865 },
23866
23867 set: function(name, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
23868 var cdomain = '', expires = '', secure = '';
23869
23870 if (domain_override) {
23871 cdomain = '; domain=' + domain_override;
23872 } else if (is_cross_subdomain) {
23873 var domain = extract_domain(document$1.location.hostname);
23874 cdomain = domain ? '; domain=.' + domain : '';
23875 }
23876
23877 if (days) {
23878 var date = new Date();
23879 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23880 expires = '; expires=' + date.toGMTString();
23881 }
23882
23883 if (is_cross_site) {
23884 is_secure = true;
23885 secure = '; SameSite=None';
23886 }
23887 if (is_secure) {
23888 secure += '; secure';
23889 }
23890
23891 var new_cookie_val = name + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
23892 document$1.cookie = new_cookie_val;
23893 return new_cookie_val;
23894 },
23895
23896 remove: function(name, is_cross_subdomain, domain_override) {
23897 _.cookie.set(name, '', -1, is_cross_subdomain, false, false, domain_override);
23898 }
23899 };
23900
23901 var _testStorageSupported = function (storage) {
23902 var supported = true;
23903 try {
23904 var key = '__mplss_' + cheap_guid(8),
23905 val = 'xyz';
23906 storage.setItem(key, val);
23907 if (storage.getItem(key) !== val) {
23908 supported = false;
23909 }
23910 storage.removeItem(key);
23911 } catch (err) {
23912 supported = false;
23913 }
23914 return supported;
23915 };
23916
23917 var _localStorageSupported = null;
23918 var localStorageSupported = function(storage, forceCheck) {
23919 if (_localStorageSupported !== null && !forceCheck) {
23920 return _localStorageSupported;
23921 }
23922 return _localStorageSupported = _testStorageSupported(storage || win.localStorage);
23923 };
23924
23925 var _sessionStorageSupported = null;
23926 var sessionStorageSupported = function(storage, forceCheck) {
23927 if (_sessionStorageSupported !== null && !forceCheck) {
23928 return _sessionStorageSupported;
23929 }
23930 return _sessionStorageSupported = _testStorageSupported(storage || win.sessionStorage);
23931 };
23932
23933 function _storageWrapper(storage, name, is_supported_fn) {
23934 var log_error = function(msg) {
23935 console$1.error(name + ' error: ' + msg);
23936 };
23937
23938 return {
23939 is_supported: function(forceCheck) {
23940 var supported = is_supported_fn(storage, forceCheck);
23941 if (!supported) {
23942 console$1.error(name + ' unsupported');
23943 }
23944 return supported;
23945 },
23946 error: log_error,
23947 get: function(key) {
23948 try {
23949 return storage.getItem(key);
23950 } catch (err) {
23951 log_error(err);
23952 }
23953 return null;
23954 },
23955 parse: function(key) {
23956 try {
23957 return _.JSONDecode(storage.getItem(key)) || {};
23958 } catch (err) {
23959 // noop
23960 }
23961 return null;
23962 },
23963 set: function(key, value) {
23964 try {
23965 storage.setItem(key, value);
23966 } catch (err) {
23967 log_error(err);
23968 }
23969 },
23970 remove: function(key) {
23971 try {
23972 storage.removeItem(key);
23973 } catch (err) {
23974 log_error(err);
23975 }
23976 }
23977 };
23978 }
23979
23980 _.localStorage = _storageWrapper(win.localStorage, 'localStorage', localStorageSupported);
23981 _.sessionStorage = _storageWrapper(win.sessionStorage, 'sessionStorage', sessionStorageSupported);
23982
23983 _.register_event = (function() {
23984 // written by Dean Edwards, 2005
23985 // with input from Tino Zijdel - crisp@xs4all.nl
23986 // with input from Carl Sverre - mail@carlsverre.com
23987 // with input from Mixpanel
23988 // http://dean.edwards.name/weblog/2005/10/add-event/
23989 // https://gist.github.com/1930440
23990
23991 /**
23992 * @param {Object} element
23993 * @param {string} type
23994 * @param {function(...*)} handler
23995 * @param {boolean=} oldSchool
23996 * @param {boolean=} useCapture
23997 */
23998 var register_event = function(element, type, handler, oldSchool, useCapture) {
23999 if (!element) {
24000 console$1.error('No valid element provided to register_event');
24001 return;
24002 }
24003
24004 if (element.addEventListener && !oldSchool) {
24005 element.addEventListener(type, handler, !!useCapture);
24006 } else {
24007 var ontype = 'on' + type;
24008 var old_handler = element[ontype]; // can be undefined
24009 element[ontype] = makeHandler(element, handler, old_handler);
24010 }
24011 };
24012
24013 function makeHandler(element, new_handler, old_handlers) {
24014 var handler = function(event) {
24015 event = event || fixEvent(win.event);
24016
24017 // this basically happens in firefox whenever another script
24018 // overwrites the onload callback and doesn't pass the event
24019 // object to previously defined callbacks. All the browsers
24020 // that don't define window.event implement addEventListener
24021 // so the dom_loaded handler will still be fired as usual.
24022 if (!event) {
24023 return undefined;
24024 }
24025
24026 var ret = true;
24027 var old_result, new_result;
24028
24029 if (_.isFunction(old_handlers)) {
24030 old_result = old_handlers(event);
24031 }
24032 new_result = new_handler.call(element, event);
24033
24034 if ((false === old_result) || (false === new_result)) {
24035 ret = false;
24036 }
24037
24038 return ret;
24039 };
24040
24041 return handler;
24042 }
24043
24044 function fixEvent(event) {
24045 if (event) {
24046 event.preventDefault = fixEvent.preventDefault;
24047 event.stopPropagation = fixEvent.stopPropagation;
24048 }
24049 return event;
24050 }
24051 fixEvent.preventDefault = function() {
24052 this.returnValue = false;
24053 };
24054 fixEvent.stopPropagation = function() {
24055 this.cancelBubble = true;
24056 };
24057
24058 return register_event;
24059 })();
24060
24061
24062 var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
24063
24064 _.dom_query = (function() {
24065 /* document.getElementsBySelector(selector)
24066 - returns an array of element objects from the current document
24067 matching the CSS selector. Selectors can contain element names,
24068 class names and ids and can be nested. For example:
24069
24070 elements = document.getElementsBySelector('div#main p a.external')
24071
24072 Will return an array of all 'a' elements with 'external' in their
24073 class attribute that are contained inside 'p' elements that are
24074 contained inside the 'div' element which has id="main"
24075
24076 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
24077 See http://www.w3.org/TR/css3-selectors/#attribute-selectors
24078
24079 Version 0.4 - Simon Willison, March 25th 2003
24080 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
24081 -- Opera 7 fails
24082
24083 Version 0.5 - Carl Sverre, Jan 7th 2013
24084 -- Now uses jQuery-esque `hasClass` for testing class name
24085 equality. This fixes a bug related to '-' characters being
24086 considered not part of a 'word' in regex.
24087 */
24088
24089 function getAllChildren(e) {
24090 // Returns all children of element. Workaround required for IE5/Windows. Ugh.
24091 return e.all ? e.all : e.getElementsByTagName('*');
24092 }
24093
24094 var bad_whitespace = /[\t\r\n]/g;
24095
24096 function hasClass(elem, selector) {
24097 var className = ' ' + selector + ' ';
24098 return ((' ' + elem.className + ' ').replace(bad_whitespace, ' ').indexOf(className) >= 0);
24099 }
24100
24101 function getElementsBySelector(selector) {
24102 // Attempt to fail gracefully in lesser browsers
24103 if (!document$1.getElementsByTagName) {
24104 return [];
24105 }
24106 // Split selector in to tokens
24107 var tokens = selector.split(' ');
24108 var token, bits, tagName, found, foundCount, i, j, k, elements, currentContextIndex;
24109 var currentContext = [document$1];
24110 for (i = 0; i < tokens.length; i++) {
24111 token = tokens[i].replace(/^\s+/, '').replace(/\s+$/, '');
24112 if (token.indexOf('#') > -1) {
24113 // Token is an ID selector
24114 bits = token.split('#');
24115 tagName = bits[0];
24116 var id = bits[1];
24117 var element = document$1.getElementById(id);
24118 if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) {
24119 // element not found or tag with that ID not found, return false
24120 return [];
24121 }
24122 // Set currentContext to contain just this element
24123 currentContext = [element];
24124 continue; // Skip to next token
24125 }
24126 if (token.indexOf('.') > -1) {
24127 // Token contains a class selector
24128 bits = token.split('.');
24129 tagName = bits[0];
24130 var className = bits[1];
24131 if (!tagName) {
24132 tagName = '*';
24133 }
24134 // Get elements matching tag, filter them for class selector
24135 found = [];
24136 foundCount = 0;
24137 for (j = 0; j < currentContext.length; j++) {
24138 if (tagName == '*') {
24139 elements = getAllChildren(currentContext[j]);
24140 } else {
24141 elements = currentContext[j].getElementsByTagName(tagName);
24142 }
24143 for (k = 0; k < elements.length; k++) {
24144 found[foundCount++] = elements[k];
24145 }
24146 }
24147 currentContext = [];
24148 currentContextIndex = 0;
24149 for (j = 0; j < found.length; j++) {
24150 if (found[j].className &&
24151 _.isString(found[j].className) && // some SVG elements have classNames which are not strings
24152 hasClass(found[j], className)
24153 ) {
24154 currentContext[currentContextIndex++] = found[j];
24155 }
24156 }
24157 continue; // Skip to next token
24158 }
24159 // Code to deal with attribute selectors
24160 var token_match = token.match(TOKEN_MATCH_REGEX);
24161 if (token_match) {
24162 tagName = token_match[1];
24163 var attrName = token_match[2];
24164 var attrOperator = token_match[3];
24165 var attrValue = token_match[4];
24166 if (!tagName) {
24167 tagName = '*';
24168 }
24169 // Grab all of the tagName elements within current context
24170 found = [];
24171 foundCount = 0;
24172 for (j = 0; j < currentContext.length; j++) {
24173 if (tagName == '*') {
24174 elements = getAllChildren(currentContext[j]);
24175 } else {
24176 elements = currentContext[j].getElementsByTagName(tagName);
24177 }
24178 for (k = 0; k < elements.length; k++) {
24179 found[foundCount++] = elements[k];
24180 }
24181 }
24182 currentContext = [];
24183 currentContextIndex = 0;
24184 var checkFunction; // This function will be used to filter the elements
24185 switch (attrOperator) {
24186 case '=': // Equality
24187 checkFunction = function(e) {
24188 return (e.getAttribute(attrName) == attrValue);
24189 };
24190 break;
24191 case '~': // Match one of space seperated words
24192 checkFunction = function(e) {
24193 return (e.getAttribute(attrName).match(new RegExp('\\b' + attrValue + '\\b')));
24194 };
24195 break;
24196 case '|': // Match start with value followed by optional hyphen
24197 checkFunction = function(e) {
24198 return (e.getAttribute(attrName).match(new RegExp('^' + attrValue + '-?')));
24199 };
24200 break;
24201 case '^': // Match starts with value
24202 checkFunction = function(e) {
24203 return (e.getAttribute(attrName).indexOf(attrValue) === 0);
24204 };
24205 break;
24206 case '$': // Match ends with value - fails with "Warning" in Opera 7
24207 checkFunction = function(e) {
24208 return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length);
24209 };
24210 break;
24211 case '*': // Match ends with value
24212 checkFunction = function(e) {
24213 return (e.getAttribute(attrName).indexOf(attrValue) > -1);
24214 };
24215 break;
24216 default:
24217 // Just test for existence of attribute
24218 checkFunction = function(e) {
24219 return e.getAttribute(attrName);
24220 };
24221 }
24222 currentContext = [];
24223 currentContextIndex = 0;
24224 for (j = 0; j < found.length; j++) {
24225 if (checkFunction(found[j])) {
24226 currentContext[currentContextIndex++] = found[j];
24227 }
24228 }
24229 // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
24230 continue; // Skip to next token
24231 }
24232 // If we get here, token is JUST an element (not a class or ID selector)
24233 tagName = token;
24234 found = [];
24235 foundCount = 0;
24236 for (j = 0; j < currentContext.length; j++) {
24237 elements = currentContext[j].getElementsByTagName(tagName);
24238 for (k = 0; k < elements.length; k++) {
24239 found[foundCount++] = elements[k];
24240 }
24241 }
24242 currentContext = found;
24243 }
24244 return currentContext;
24245 }
24246
24247 return function(query) {
24248 if (_.isElement(query)) {
24249 return [query];
24250 } else if (_.isObject(query) && !_.isUndefined(query.length)) {
24251 return query;
24252 } else {
24253 return getElementsBySelector.call(this, query);
24254 }
24255 };
24256 })();
24257
24258 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'];
24259 var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'sccid', 'ttclid', 'twclid', 'wbraid'];
24260
24261 _.info = {
24262 campaignParams: function(default_value) {
24263 var kw = '',
24264 params = {};
24265 _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
24266 kw = _.getQueryParam(document$1.URL, kwkey);
24267 if (kw.length) {
24268 params[kwkey] = kw;
24269 } else if (default_value !== undefined) {
24270 params[kwkey] = default_value;
24271 }
24272 });
24273
24274 return params;
24275 },
24276
24277 clickParams: function() {
24278 var id = '',
24279 params = {};
24280 _.each(CLICK_IDS, function(idkey) {
24281 id = _.getQueryParam(document$1.URL, idkey);
24282 if (id.length) {
24283 params[idkey] = id;
24284 }
24285 });
24286
24287 return params;
24288 },
24289
24290 marketingParams: function() {
24291 return _.extend(_.info.campaignParams(), _.info.clickParams());
24292 },
24293
24294 searchEngine: function(referrer) {
24295 if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
24296 return 'google';
24297 } else if (referrer.search('https?://(.*)bing.com') === 0) {
24298 return 'bing';
24299 } else if (referrer.search('https?://(.*)yahoo.com') === 0) {
24300 return 'yahoo';
24301 } else if (referrer.search('https?://(.*)duckduckgo.com') === 0) {
24302 return 'duckduckgo';
24303 } else {
24304 return null;
24305 }
24306 },
24307
24308 searchInfo: function(referrer) {
24309 var search = _.info.searchEngine(referrer),
24310 param = (search != 'yahoo') ? 'q' : 'p',
24311 ret = {};
24312
24313 if (search !== null) {
24314 ret['$search_engine'] = search;
24315
24316 var keyword = _.getQueryParam(referrer, param);
24317 if (keyword.length) {
24318 ret['mp_keyword'] = keyword;
24319 }
24320 }
24321
24322 return ret;
24323 },
24324
24325 /**
24326 * This function detects which browser is running this script.
24327 * The order of the checks are important since many user agents
24328 * include key words used in later checks.
24329 */
24330 browser: function(user_agent, vendor, opera) {
24331 vendor = vendor || ''; // vendor is undefined for at least IE9
24332 if (opera || _.includes(user_agent, ' OPR/')) {
24333 if (_.includes(user_agent, 'Mini')) {
24334 return 'Opera Mini';
24335 }
24336 return 'Opera';
24337 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24338 return 'BlackBerry';
24339 } else if (_.includes(user_agent, 'IEMobile') || _.includes(user_agent, 'WPDesktop')) {
24340 return 'Internet Explorer Mobile';
24341 } else if (_.includes(user_agent, 'SamsungBrowser/')) {
24342 // https://developer.samsung.com/internet/user-agent-string-format
24343 return 'Samsung Internet';
24344 } else if (_.includes(user_agent, 'Edge') || _.includes(user_agent, 'Edg/')) {
24345 return 'Microsoft Edge';
24346 } else if (_.includes(user_agent, 'FBIOS')) {
24347 return 'Facebook Mobile';
24348 } else if (_.includes(user_agent, 'Whale/')) {
24349 // https://user-agents.net/browsers/whale-browser
24350 return 'Whale Browser';
24351 } else if (_.includes(user_agent, 'Chrome')) {
24352 return 'Chrome';
24353 } else if (_.includes(user_agent, 'CriOS')) {
24354 return 'Chrome iOS';
24355 } else if (_.includes(user_agent, 'UCWEB') || _.includes(user_agent, 'UCBrowser')) {
24356 return 'UC Browser';
24357 } else if (_.includes(user_agent, 'FxiOS')) {
24358 return 'Firefox iOS';
24359 } else if (_.includes(vendor, 'Apple')) {
24360 if (_.includes(user_agent, 'Mobile')) {
24361 return 'Mobile Safari';
24362 }
24363 return 'Safari';
24364 } else if (_.includes(user_agent, 'Android')) {
24365 return 'Android Mobile';
24366 } else if (_.includes(user_agent, 'Konqueror')) {
24367 return 'Konqueror';
24368 } else if (_.includes(user_agent, 'Firefox')) {
24369 return 'Firefox';
24370 } else if (_.includes(user_agent, 'MSIE') || _.includes(user_agent, 'Trident/')) {
24371 return 'Internet Explorer';
24372 } else if (_.includes(user_agent, 'Gecko')) {
24373 return 'Mozilla';
24374 } else {
24375 return '';
24376 }
24377 },
24378
24379 /**
24380 * This function detects which browser version is running this script,
24381 * parsing major and minor version (e.g., 42.1). User agent strings from:
24382 * http://www.useragentstring.com/pages/useragentstring.php
24383 */
24384 browserVersion: function(userAgent, vendor, opera) {
24385 var browser = _.info.browser(userAgent, vendor, opera);
24386 var versionRegexs = {
24387 'Internet Explorer Mobile': /rv:(\d+(\.\d+)?)/,
24388 'Microsoft Edge': /Edge?\/(\d+(\.\d+)?)/,
24389 'Chrome': /Chrome\/(\d+(\.\d+)?)/,
24390 'Chrome iOS': /CriOS\/(\d+(\.\d+)?)/,
24391 'UC Browser' : /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
24392 'Safari': /Version\/(\d+(\.\d+)?)/,
24393 'Mobile Safari': /Version\/(\d+(\.\d+)?)/,
24394 'Opera': /(Opera|OPR)\/(\d+(\.\d+)?)/,
24395 'Firefox': /Firefox\/(\d+(\.\d+)?)/,
24396 'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
24397 'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
24398 'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
24399 'Android Mobile': /android\s(\d+(\.\d+)?)/,
24400 'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
24401 'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
24402 'Mozilla': /rv:(\d+(\.\d+)?)/,
24403 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
24404 };
24405 var regex = versionRegexs[browser];
24406 if (regex === undefined) {
24407 return null;
24408 }
24409 var matches = userAgent.match(regex);
24410 if (!matches) {
24411 return null;
24412 }
24413 return parseFloat(matches[matches.length - 2]);
24414 },
24415
24416 os: function() {
24417 var a = userAgent;
24418 if (/Windows/i.test(a)) {
24419 if (/Phone/.test(a) || /WPDesktop/.test(a)) {
24420 return 'Windows Phone';
24421 }
24422 return 'Windows';
24423 } else if (/(iPhone|iPad|iPod)/.test(a)) {
24424 return 'iOS';
24425 } else if (/Android/.test(a)) {
24426 return 'Android';
24427 } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
24428 return 'BlackBerry';
24429 } else if (/Mac/i.test(a)) {
24430 return 'Mac OS X';
24431 } else if (/Linux/.test(a)) {
24432 return 'Linux';
24433 } else if (/CrOS/.test(a)) {
24434 return 'Chrome OS';
24435 } else {
24436 return '';
24437 }
24438 },
24439
24440 device: function(user_agent) {
24441 if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
24442 return 'Windows Phone';
24443 } else if (/iPad/.test(user_agent)) {
24444 return 'iPad';
24445 } else if (/iPod/.test(user_agent)) {
24446 return 'iPod Touch';
24447 } else if (/iPhone/.test(user_agent)) {
24448 return 'iPhone';
24449 } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
24450 return 'BlackBerry';
24451 } else if (/Android/.test(user_agent)) {
24452 return 'Android';
24453 } else {
24454 return '';
24455 }
24456 },
24457
24458 referringDomain: function(referrer) {
24459 var split = referrer.split('/');
24460 if (split.length >= 3) {
24461 return split[2];
24462 }
24463 return '';
24464 },
24465
24466 currentUrl: function() {
24467 return win.location.href;
24468 },
24469
24470 properties: function(extra_props) {
24471 if (typeof extra_props !== 'object') {
24472 extra_props = {};
24473 }
24474 return _.extend(_.strip_empty_properties({
24475 '$os': _.info.os(),
24476 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
24477 '$referrer': document$1.referrer,
24478 '$referring_domain': _.info.referringDomain(document$1.referrer),
24479 '$device': _.info.device(userAgent)
24480 }), {
24481 '$current_url': _.info.currentUrl(),
24482 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera),
24483 '$screen_height': screen.height,
24484 '$screen_width': screen.width,
24485 'mp_lib': 'web',
24486 '$lib_version': Config.LIB_VERSION,
24487 '$insert_id': cheap_guid(),
24488 'time': _.timestamp() / 1000 // epoch time in seconds
24489 }, _.strip_empty_properties(extra_props));
24490 },
24491
24492 people_properties: function() {
24493 return _.extend(_.strip_empty_properties({
24494 '$os': _.info.os(),
24495 '$browser': _.info.browser(userAgent, navigator.vendor, windowOpera)
24496 }), {
24497 '$browser_version': _.info.browserVersion(userAgent, navigator.vendor, windowOpera)
24498 });
24499 },
24500
24501 mpPageViewProperties: function() {
24502 return _.strip_empty_properties({
24503 'current_page_title': document$1.title,
24504 'current_domain': win.location.hostname,
24505 'current_url_path': win.location.pathname,
24506 'current_url_protocol': win.location.protocol,
24507 'current_url_search': win.location.search
24508 });
24509 }
24510 };
24511
24512 /**
24513 * Returns a throttled function that will only run at most every `waitMs` and returns a promise that resolves with the next invocation.
24514 * Throttled calls will build up a batch of args and invoke the callback with all args since the last invocation.
24515 */
24516 var batchedThrottle = function (fn, waitMs) {
24517 var timeoutPromise = null;
24518 var throttledItems = [];
24519 return function (item) {
24520 var self = this;
24521 throttledItems.push(item);
24522
24523 if (!timeoutPromise) {
24524 timeoutPromise = new PromisePolyfill(function (resolve) {
24525 setTimeout(function () {
24526 var returnValue = fn.apply(self, [throttledItems]);
24527 timeoutPromise = null;
24528 throttledItems = [];
24529 resolve(returnValue);
24530 }, waitMs);
24531 });
24532 }
24533 return timeoutPromise;
24534 };
24535 };
24536
24537 var cheap_guid = function(maxlen) {
24538 var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
24539 return maxlen ? guid.substring(0, maxlen) : guid;
24540 };
24541
24542 /**
24543 * Generates a W3C traceparent header for easy interop with distributed tracing systems i.e Open Telemetry
24544 * https://www.w3.org/TR/trace-context/#traceparent-header
24545 */
24546 var generateTraceparent = function() {
24547 var traceID = _.UUID().replace(/-/g, '');
24548 var parentID = _.UUID().replace(/-/g, '').substring(0, 16);
24549
24550 // Sampled trace
24551 var traceFlags = '01';
24552
24553 return '00-' + traceID + '-' + parentID + '-' + traceFlags;
24554 };
24555
24556 // naive way to extract domain name (example.com) from full hostname (my.sub.example.com)
24557 var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
24558 // this next one attempts to account for some ccSLDs, e.g. extracting oxford.ac.uk from www.oxford.ac.uk
24559 var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
24560 /**
24561 * Attempts to extract main domain name from full hostname, using a few blunt heuristics. For
24562 * common TLDs like .com/.org that always have a simple SLD.TLD structure (example.com), we
24563 * simply extract the last two .-separated parts of the hostname (SIMPLE_DOMAIN_MATCH_REGEX).
24564 * For others, we attempt to account for short ccSLD+TLD combos (.ac.uk) with the legacy
24565 * DOMAIN_MATCH_REGEX (kept to maintain backwards compatibility with existing Mixpanel
24566 * integrations). The only _reliable_ way to extract domain from hostname is with an up-to-date
24567 * list like at https://publicsuffix.org/ so for cases that this helper fails at, the SDK
24568 * offers the 'cookie_domain' config option to set it explicitly.
24569 * @example
24570 * extract_domain('my.sub.example.com')
24571 * // 'example.com'
24572 */
24573 var extract_domain = function(hostname) {
24574 var domain_regex = DOMAIN_MATCH_REGEX;
24575 var parts = hostname.split('.');
24576 var tld = parts[parts.length - 1];
24577 if (tld.length > 4 || tld === 'com' || tld === 'org') {
24578 domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
24579 }
24580 var matches = hostname.match(domain_regex);
24581 return matches ? matches[0] : '';
24582 };
24583
24584 /**
24585 * Check whether we have network connection. default to true for browsers that don't support navigator.onLine (IE)
24586 * @returns {boolean}
24587 */
24588 var isOnline = function() {
24589 var onLine = win.navigator['onLine'];
24590 return _.isUndefined(onLine) || onLine;
24591 };
24592
24593 var NOOP_FUNC = function () {};
24594
24595 var JSONStringify = null, JSONParse = null;
24596 if (typeof JSON !== 'undefined') {
24597 JSONStringify = JSON.stringify;
24598 JSONParse = JSON.parse;
24599 }
24600 JSONStringify = JSONStringify || _.JSONEncode;
24601 JSONParse = JSONParse || _.JSONDecode;
24602
24603 // UNMINIFIED EXPORTS (for closure compiler)
24604 _['info'] = _.info;
24605 _['info']['browser'] = _.info.browser;
24606 _['info']['browserVersion'] = _.info.browserVersion;
24607 _['info']['device'] = _.info.device;
24608 _['info']['properties'] = _.info.properties;
24609 _['isBlockedUA'] = _.isBlockedUA;
24610 _['isEmptyObject'] = _.isEmptyObject;
24611 _['isObject'] = _.isObject;
24612 _['JSONDecode'] = _.JSONDecode;
24613 _['JSONEncode'] = _.JSONEncode;
24614 _['toArray'] = _.toArray;
24615 _['NPO'] = NpoPromise;
24616
24617 var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
24618
24619 var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
24620 var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
24621
24622 // note: increment the version number when adding new object stores
24623 var DB_VERSION = 1;
24624 var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
24625
24626 /**
24627 * @type {import('./wrapper').StorageWrapper}
24628 */
24629 var IDBStorageWrapper = function (storeName) {
24630 /**
24631 * @type {Promise<IDBDatabase>|null}
24632 */
24633 this.dbPromise = null;
24634 this.storeName = storeName;
24635 };
24636
24637 IDBStorageWrapper.prototype._openDb = function () {
24638 return new PromisePolyfill(function (resolve, reject) {
24639 var openRequest = win.indexedDB.open(MIXPANEL_DB_NAME, DB_VERSION);
24640 openRequest['onerror'] = function () {
24641 reject(openRequest.error);
24642 };
24643
24644 openRequest['onsuccess'] = function () {
24645 resolve(openRequest.result);
24646 };
24647
24648 openRequest['onupgradeneeded'] = function (ev) {
24649 var db = ev.target.result;
24650
24651 OBJECT_STORES.forEach(function (storeName) {
24652 db.createObjectStore(storeName);
24653 });
24654 };
24655 });
24656 };
24657
24658 IDBStorageWrapper.prototype.init = function () {
24659 if (!win.indexedDB) {
24660 return PromisePolyfill.reject('indexedDB is not supported in this browser');
24661 }
24662
24663 if (!this.dbPromise) {
24664 this.dbPromise = this._openDb();
24665 }
24666
24667 return this.dbPromise
24668 .then(function (dbOrError) {
24669 if (dbOrError instanceof win['IDBDatabase']) {
24670 return PromisePolyfill.resolve();
24671 } else {
24672 return PromisePolyfill.reject(dbOrError);
24673 }
24674 });
24675 };
24676
24677 IDBStorageWrapper.prototype.isInitialized = function () {
24678 return !!this.dbPromise;
24679 };
24680
24681 /**
24682 * @param {IDBTransactionMode} mode
24683 * @param {function(IDBObjectStore): void} storeCb
24684 */
24685 IDBStorageWrapper.prototype.makeTransaction = function (mode, storeCb) {
24686 var storeName = this.storeName;
24687 var doTransaction = function (db) {
24688 return new PromisePolyfill(function (resolve, reject) {
24689 var transaction = db.transaction(storeName, mode);
24690 transaction.oncomplete = function () {
24691 resolve(transaction);
24692 };
24693 transaction.onabort = transaction.onerror = function () {
24694 reject(transaction.error);
24695 };
24696
24697 storeCb(transaction.objectStore(storeName));
24698 });
24699 };
24700
24701 return this.dbPromise
24702 .then(doTransaction)
24703 .catch(function (err) {
24704 if (err && err['name'] === 'InvalidStateError') {
24705 // try reopening the DB if the connection is closed
24706 this.dbPromise = this._openDb();
24707 return this.dbPromise.then(doTransaction);
24708 } else {
24709 return PromisePolyfill.reject(err);
24710 }
24711 }.bind(this));
24712 };
24713
24714 IDBStorageWrapper.prototype.setItem = function (key, value) {
24715 return this.makeTransaction('readwrite', function (objectStore) {
24716 objectStore.put(value, key);
24717 });
24718 };
24719
24720 IDBStorageWrapper.prototype.getItem = function (key) {
24721 var req;
24722 return this.makeTransaction('readonly', function (objectStore) {
24723 req = objectStore.get(key);
24724 }).then(function () {
24725 return req.result;
24726 });
24727 };
24728
24729 IDBStorageWrapper.prototype.removeItem = function (key) {
24730 return this.makeTransaction('readwrite', function (objectStore) {
24731 objectStore.delete(key);
24732 });
24733 };
24734
24735 IDBStorageWrapper.prototype.getAll = function () {
24736 var req;
24737 return this.makeTransaction('readonly', function (objectStore) {
24738 req = objectStore.getAll();
24739 }).then(function () {
24740 return req.result;
24741 });
24742 };
24743
24744 /**
24745 * GDPR utils
24746 *
24747 * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
24748 * and privacy for all individuals within the European Union. It addresses the export of personal
24749 * data outside the EU. The GDPR aims primarily to give control back to citizens and residents
24750 * over their personal data and to simplify the regulatory environment for international business
24751 * by unifying the regulation within the EU.
24752 *
24753 * This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
24754 * These functions are used internally by the SDK and are not intended to be publicly exposed.
24755 */
24756
24757
24758 /**
24759 * A function used to track a Mixpanel event (e.g. MixpanelLib.track)
24760 * @callback trackFunction
24761 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
24762 * @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.
24763 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
24764 */
24765
24766 /** Public **/
24767
24768 var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
24769
24770 /**
24771 * Opt the user in to data tracking and cookies/localstorage for the given token
24772 * @param {string} token - Mixpanel project tracking token
24773 * @param {Object} [options]
24774 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24775 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24776 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24777 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24778 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24779 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24780 * @param {string} [options.cookieDomain] - custom cookie domain
24781 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24782 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24783 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24784 */
24785 function optIn(token, options) {
24786 _optInOut(true, token, options);
24787 }
24788
24789 /**
24790 * Opt the user out of data tracking and cookies/localstorage for the given token
24791 * @param {string} token - Mixpanel project tracking token
24792 * @param {Object} [options]
24793 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24794 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24795 * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
24796 * @param {string} [options.cookieDomain] - custom cookie domain
24797 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24798 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
24799 * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
24800 */
24801 function optOut(token, options) {
24802 _optInOut(false, token, options);
24803 }
24804
24805 /**
24806 * Check whether the user has opted in to data tracking and cookies/localstorage for the given token
24807 * @param {string} token - Mixpanel project tracking token
24808 * @param {Object} [options]
24809 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24810 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24811 * @returns {boolean} whether the user has opted in to the given opt type
24812 */
24813 function hasOptedIn(token, options) {
24814 return _getStorageValue(token, options) === '1';
24815 }
24816
24817 /**
24818 * Check whether the user has opted out of data tracking and cookies/localstorage for the given token
24819 * @param {string} token - Mixpanel project tracking token
24820 * @param {Object} [options]
24821 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24822 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24823 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24824 * @returns {boolean} whether the user has opted out of the given opt type
24825 */
24826 function hasOptedOut(token, options) {
24827 if (_hasDoNotTrackFlagOn(options)) {
24828 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"');
24829 return true;
24830 }
24831 var optedOut = _getStorageValue(token, options) === '0';
24832 if (optedOut) {
24833 console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
24834 }
24835 return optedOut;
24836 }
24837
24838 /**
24839 * Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24840 * If the user has opted out, return early instead of executing the method.
24841 * If a callback argument was provided, execute it passing the 0 error code.
24842 * @param {function} method - wrapped method to be executed if the user has not opted out
24843 * @returns {*} the result of executing method OR undefined if the user has opted out
24844 */
24845 function addOptOutCheckMixpanelLib(method) {
24846 return _addOptOutCheck(method, function(name) {
24847 return this.get_config(name);
24848 });
24849 }
24850
24851 /**
24852 * Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24853 * If the user has opted out, return early instead of executing the method.
24854 * If a callback argument was provided, execute it passing the 0 error code.
24855 * @param {function} method - wrapped method to be executed if the user has not opted out
24856 * @returns {*} the result of executing method OR undefined if the user has opted out
24857 */
24858 function addOptOutCheckMixpanelPeople(method) {
24859 return _addOptOutCheck(method, function(name) {
24860 return this._get_config(name);
24861 });
24862 }
24863
24864 /**
24865 * Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
24866 * If the user has opted out, return early instead of executing the method.
24867 * If a callback argument was provided, execute it passing the 0 error code.
24868 * @param {function} method - wrapped method to be executed if the user has not opted out
24869 * @returns {*} the result of executing method OR undefined if the user has opted out
24870 */
24871 function addOptOutCheckMixpanelGroup(method) {
24872 return _addOptOutCheck(method, function(name) {
24873 return this._get_config(name);
24874 });
24875 }
24876
24877 /**
24878 * Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
24879 * @param {string} token - Mixpanel project tracking token
24880 * @param {Object} [options]
24881 * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
24882 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24883 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24884 * @param {string} [options.cookieDomain] - custom cookie domain
24885 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24886 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24887 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24888 */
24889 function clearOptInOut(token, options) {
24890 options = options || {};
24891 _getStorage(options).remove(
24892 _getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
24893 );
24894 }
24895
24896 /** Private **/
24897
24898 /**
24899 * Get storage util
24900 * @param {Object} [options]
24901 * @param {string} [options.persistenceType]
24902 * @returns {object} either _.cookie or _.localstorage
24903 */
24904 function _getStorage(options) {
24905 options = options || {};
24906 return options.persistenceType === 'localStorage' ? _.localStorage : _.cookie;
24907 }
24908
24909 /**
24910 * Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
24911 * @param {string} token - Mixpanel project tracking token
24912 * @param {Object} [options]
24913 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24914 * @returns {string} the name of the cookie for the given opt type
24915 */
24916 function _getStorageKey(token, options) {
24917 options = options || {};
24918 return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
24919 }
24920
24921 /**
24922 * Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
24923 * @param {string} token - Mixpanel project tracking token
24924 * @param {Object} [options]
24925 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24926 * @returns {string} the value of the cookie for the given opt type
24927 */
24928 function _getStorageValue(token, options) {
24929 return _getStorage(options).get(_getStorageKey(token, options));
24930 }
24931
24932 /**
24933 * Check whether the user has set the DNT/doNotTrack setting to true in their browser
24934 * @param {Object} [options]
24935 * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
24936 * @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
24937 * @returns {boolean} whether the DNT setting is true
24938 */
24939 function _hasDoNotTrackFlagOn(options) {
24940 if (options && options.ignoreDnt) {
24941 return false;
24942 }
24943 var win$1 = (options && options.window) || win;
24944 var nav = win$1['navigator'] || {};
24945 var hasDntOn = false;
24946
24947 _.each([
24948 nav['doNotTrack'], // standard
24949 nav['msDoNotTrack'],
24950 win$1['doNotTrack']
24951 ], function(dntValue) {
24952 if (_.includes([true, 1, '1', 'yes'], dntValue)) {
24953 hasDntOn = true;
24954 }
24955 });
24956
24957 return hasDntOn;
24958 }
24959
24960 /**
24961 * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
24962 * @param {boolean} optValue - whether to opt the user in or out for the given opt type
24963 * @param {string} token - Mixpanel project tracking token
24964 * @param {Object} [options]
24965 * @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
24966 * @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
24967 * @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
24968 * @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
24969 * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
24970 * @param {string} [options.cookieDomain] - custom cookie domain
24971 * @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
24972 * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
24973 * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
24974 */
24975 function _optInOut(optValue, token, options) {
24976 if (!_.isString(token) || !token.length) {
24977 console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
24978 return;
24979 }
24980
24981 options = options || {};
24982
24983 _getStorage(options).set(
24984 _getStorageKey(token, options),
24985 optValue ? 1 : 0,
24986 _.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
24987 !!options.crossSubdomainCookie,
24988 !!options.secureCookie,
24989 !!options.crossSiteCookie,
24990 options.cookieDomain
24991 );
24992
24993 if (options.track && optValue) { // only track event if opting in (optValue=true)
24994 options.track(options.trackEventName || '$opt_in', options.trackProperties, {
24995 'send_immediately': true
24996 });
24997 }
24998 }
24999
25000 /**
25001 * Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
25002 * If the user has opted out, return early instead of executing the method.
25003 * If a callback argument was provided, execute it passing the 0 error code.
25004 * @param {function} method - wrapped method to be executed if the user has not opted out
25005 * @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
25006 * @returns {*} the result of executing method OR undefined if the user has opted out
25007 */
25008 function _addOptOutCheck(method, getConfigValue) {
25009 return function() {
25010 var optedOut = false;
25011
25012 try {
25013 var token = getConfigValue.call(this, 'token');
25014 var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
25015 var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
25016 var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
25017 var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
25018
25019 if (token) { // if there was an issue getting the token, continue method execution as normal
25020 optedOut = hasOptedOut(token, {
25021 ignoreDnt: ignoreDnt,
25022 persistenceType: persistenceType,
25023 persistencePrefix: persistencePrefix,
25024 window: win
25025 });
25026 }
25027 } catch(err) {
25028 console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
25029 }
25030
25031 if (!optedOut) {
25032 return method.apply(this, arguments);
25033 }
25034
25035 var callback = arguments[arguments.length - 1];
25036 if (typeof(callback) === 'function') {
25037 callback(0);
25038 }
25039
25040 return;
25041 };
25042 }
25043
25044 var logger$6 = console_with_prefix('lock');
25045
25046 /**
25047 * SharedLock: a mutex built on HTML5 localStorage, to ensure that only one browser
25048 * window/tab at a time will be able to access shared resources.
25049 *
25050 * Based on the Alur and Taubenfeld fast lock
25051 * (http://www.cs.rochester.edu/research/synchronization/pseudocode/fastlock.html)
25052 * with an added timeout to ensure there will be eventual progress in the event
25053 * that a window is closed in the middle of the callback.
25054 *
25055 * Implementation based on the original version by David Wolever (https://github.com/wolever)
25056 * at https://gist.github.com/wolever/5fd7573d1ef6166e8f8c4af286a69432.
25057 *
25058 * @example
25059 * const myLock = new SharedLock('some-key');
25060 * myLock.withLock(function() {
25061 * console.log('I hold the mutex!');
25062 * });
25063 *
25064 * @constructor
25065 */
25066 var SharedLock = function(key, options) {
25067 options = options || {};
25068
25069 this.storageKey = key;
25070 this.storage = options.storage || win.localStorage;
25071 this.pollIntervalMS = options.pollIntervalMS || 100;
25072 this.timeoutMS = options.timeoutMS || 2000;
25073
25074 // dependency-inject promise implementation for testing purposes
25075 this.promiseImpl = options.promiseImpl || PromisePolyfill;
25076 };
25077
25078 // pass in a specific pid to test contention scenarios; otherwise
25079 // it is chosen randomly for each acquisition attempt
25080 SharedLock.prototype.withLock = function(lockedCB, pid) {
25081 var Promise = this.promiseImpl;
25082 return new Promise(_.bind(function (resolve, reject) {
25083 var i = pid || (new Date().getTime() + '|' + Math.random());
25084 var startTime = new Date().getTime();
25085 var key = this.storageKey;
25086 var pollIntervalMS = this.pollIntervalMS;
25087 var timeoutMS = this.timeoutMS;
25088 var storage = this.storage;
25089
25090 var keyX = key + ':X';
25091 var keyY = key + ':Y';
25092 var keyZ = key + ':Z';
25093
25094 var delay = function(cb) {
25095 if (new Date().getTime() - startTime > timeoutMS) {
25096 logger$6.error('Timeout waiting for mutex on ' + key + '; clearing lock. [' + i + ']');
25097 storage.removeItem(keyZ);
25098 storage.removeItem(keyY);
25099 loop();
25100 return;
25101 }
25102 setTimeout(function() {
25103 try {
25104 cb();
25105 } catch(err) {
25106 reject(err);
25107 }
25108 }, pollIntervalMS * (Math.random() + 0.1));
25109 };
25110
25111 var waitFor = function(predicate, cb) {
25112 if (predicate()) {
25113 cb();
25114 } else {
25115 delay(function() {
25116 waitFor(predicate, cb);
25117 });
25118 }
25119 };
25120
25121 var getSetY = function() {
25122 var valY = storage.getItem(keyY);
25123 if (valY && valY !== i) { // if Y == i then this process already has the lock (useful for test cases)
25124 return false;
25125 } else {
25126 storage.setItem(keyY, i);
25127 if (storage.getItem(keyY) === i) {
25128 return true;
25129 } else {
25130 if (!localStorageSupported(storage, true)) {
25131 reject(new Error('localStorage support dropped while acquiring lock'));
25132 }
25133 return false;
25134 }
25135 }
25136 };
25137
25138 var loop = function() {
25139 storage.setItem(keyX, i);
25140
25141 waitFor(getSetY, function() {
25142 if (storage.getItem(keyX) === i) {
25143 criticalSection();
25144 return;
25145 }
25146
25147 delay(function() {
25148 if (storage.getItem(keyY) !== i) {
25149 loop();
25150 return;
25151 }
25152 waitFor(function() {
25153 return !storage.getItem(keyZ);
25154 }, criticalSection);
25155 });
25156 });
25157 };
25158
25159 var criticalSection = function() {
25160 storage.setItem(keyZ, '1');
25161 var removeLock = function () {
25162 storage.removeItem(keyZ);
25163 if (storage.getItem(keyY) === i) {
25164 storage.removeItem(keyY);
25165 }
25166 if (storage.getItem(keyX) === i) {
25167 storage.removeItem(keyX);
25168 }
25169 };
25170
25171 lockedCB()
25172 .then(function (ret) {
25173 removeLock();
25174 resolve(ret);
25175 })
25176 .catch(function (err) {
25177 removeLock();
25178 reject(err);
25179 });
25180 };
25181
25182 try {
25183 if (localStorageSupported(storage, true)) {
25184 loop();
25185 } else {
25186 throw new Error('localStorage support check failed');
25187 }
25188 } catch(err) {
25189 reject(err);
25190 }
25191 }, this));
25192 };
25193
25194 /**
25195 * @type {import('./wrapper').StorageWrapper}
25196 */
25197 var LocalStorageWrapper = function (storageOverride) {
25198 this.storage = storageOverride || win.localStorage;
25199 };
25200
25201 LocalStorageWrapper.prototype.init = function () {
25202 return PromisePolyfill.resolve();
25203 };
25204
25205 LocalStorageWrapper.prototype.isInitialized = function () {
25206 return true;
25207 };
25208
25209 LocalStorageWrapper.prototype.setItem = function (key, value) {
25210 return new PromisePolyfill(_.bind(function (resolve, reject) {
25211 try {
25212 this.storage.setItem(key, JSONStringify(value));
25213 } catch (e) {
25214 reject(e);
25215 }
25216 resolve();
25217 }, this));
25218 };
25219
25220 LocalStorageWrapper.prototype.getItem = function (key) {
25221 return new PromisePolyfill(_.bind(function (resolve, reject) {
25222 var item;
25223 try {
25224 item = JSONParse(this.storage.getItem(key));
25225 } catch (e) {
25226 reject(e);
25227 }
25228 resolve(item);
25229 }, this));
25230 };
25231
25232 LocalStorageWrapper.prototype.removeItem = function (key) {
25233 return new PromisePolyfill(_.bind(function (resolve, reject) {
25234 try {
25235 this.storage.removeItem(key);
25236 } catch (e) {
25237 reject(e);
25238 }
25239 resolve();
25240 }, this));
25241 };
25242
25243 var logger$5 = console_with_prefix('batch');
25244
25245 /**
25246 * RequestQueue: queue for batching API requests with localStorage backup for retries.
25247 * Maintains an in-memory queue which represents the source of truth for the current
25248 * page, but also writes all items out to a copy in the browser's localStorage, which
25249 * can be read on subsequent pageloads and retried. For batchability, all the request
25250 * items in the queue should be of the same type (events, people updates, group updates)
25251 * so they can be sent in a single request to the same API endpoint.
25252 *
25253 * LocalStorage keying and locking: In order for reloads and subsequent pageloads of
25254 * the same site to access the same persisted data, they must share the same localStorage
25255 * key (for instance based on project token and queue type). Therefore access to the
25256 * localStorage entry is guarded by an asynchronous mutex (SharedLock) to prevent
25257 * simultaneously open windows/tabs from overwriting each other's data (which would lead
25258 * to data loss in some situations).
25259 * @constructor
25260 */
25261 var RequestQueue = function (storageKey, options) {
25262 options = options || {};
25263 this.storageKey = storageKey;
25264 this.usePersistence = options.usePersistence;
25265 if (this.usePersistence) {
25266 this.queueStorage = options.queueStorage || new LocalStorageWrapper();
25267 this.lock = new SharedLock(storageKey, {
25268 storage: options.sharedLockStorage || win.localStorage,
25269 timeoutMS: options.sharedLockTimeoutMS,
25270 });
25271 }
25272 this.reportError = options.errorReporter || _.bind(logger$5.error, logger$5);
25273
25274 this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
25275
25276 this.memQueue = [];
25277 this.initialized = false;
25278
25279 if (options.enqueueThrottleMs) {
25280 this.enqueuePersisted = batchedThrottle(_.bind(this._enqueuePersisted, this), options.enqueueThrottleMs);
25281 } else {
25282 this.enqueuePersisted = _.bind(function (queueEntry) {
25283 return this._enqueuePersisted([queueEntry]);
25284 }, this);
25285 }
25286 };
25287
25288 RequestQueue.prototype.ensureInit = function () {
25289 if (this.initialized || !this.usePersistence) {
25290 return PromisePolyfill.resolve();
25291 }
25292
25293 return this.queueStorage
25294 .init()
25295 .then(_.bind(function () {
25296 this.initialized = true;
25297 }, this))
25298 .catch(_.bind(function (err) {
25299 this.reportError('Error initializing queue persistence. Disabling persistence', err);
25300 this.initialized = true;
25301 this.usePersistence = false;
25302 }, this));
25303 };
25304
25305 /**
25306 * Add one item to queues (memory and localStorage). The queued entry includes
25307 * the given item along with an auto-generated ID and a "flush-after" timestamp.
25308 * It is expected that the item will be sent over the network and dequeued
25309 * before the flush-after time; if this doesn't happen it is considered orphaned
25310 * (e.g., the original tab where it was enqueued got closed before it could be
25311 * sent) and the item can be sent by any tab that finds it in localStorage.
25312 *
25313 * The final callback param is called with a param indicating success or
25314 * failure of the enqueue operation; it is asynchronous because the localStorage
25315 * lock is asynchronous.
25316 */
25317 RequestQueue.prototype.enqueue = function (item, flushInterval) {
25318 var queueEntry = {
25319 'id': cheap_guid(),
25320 'flushAfter': new Date().getTime() + flushInterval * 2,
25321 'payload': item
25322 };
25323
25324 if (!this.usePersistence) {
25325 this.memQueue.push(queueEntry);
25326 return PromisePolyfill.resolve(true);
25327 } else {
25328 return this.enqueuePersisted(queueEntry);
25329 }
25330 };
25331
25332 RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
25333 var enqueueItem = _.bind(function () {
25334 return this.ensureInit()
25335 .then(_.bind(function () {
25336 return this.readFromStorage();
25337 }, this))
25338 .then(_.bind(function (storedQueue) {
25339 return this.saveToStorage(storedQueue.concat(queueEntries));
25340 }, this))
25341 .then(_.bind(function (succeeded) {
25342 // only add to in-memory queue when storage succeeds
25343 if (succeeded) {
25344 this.memQueue = this.memQueue.concat(queueEntries);
25345 }
25346
25347 return succeeded;
25348 }, this))
25349 .catch(_.bind(function (err) {
25350 this.reportError('Error enqueueing items', err, queueEntries);
25351 return false;
25352 }, this));
25353 }, this);
25354
25355 return this.lock
25356 .withLock(enqueueItem, this.pid)
25357 .catch(_.bind(function (err) {
25358 this.reportError('Error acquiring storage lock', err);
25359 return false;
25360 }, this));
25361 };
25362
25363 /**
25364 * Read out the given number of queue entries. If this.memQueue
25365 * has fewer than batchSize items, then look for "orphaned" items
25366 * in the persisted queue (items where the 'flushAfter' time has
25367 * already passed).
25368 */
25369 RequestQueue.prototype.fillBatch = function (batchSize) {
25370 var batch = this.memQueue.slice(0, batchSize);
25371 if (this.usePersistence && batch.length < batchSize) {
25372 // don't need lock just to read events; localStorage is thread-safe
25373 // and the worst that could happen is a duplicate send of some
25374 // orphaned events, which will be deduplicated on the server side
25375 return this.ensureInit()
25376 .then(_.bind(function () {
25377 return this.readFromStorage();
25378 }, this))
25379 .then(_.bind(function (storedQueue) {
25380 if (storedQueue.length) {
25381 // item IDs already in batch; don't duplicate out of storage
25382 var idsInBatch = {}; // poor man's Set
25383 _.each(batch, function (item) {
25384 idsInBatch[item['id']] = true;
25385 });
25386
25387 for (var i = 0; i < storedQueue.length; i++) {
25388 var item = storedQueue[i];
25389 if (new Date().getTime() > item['flushAfter'] && !idsInBatch[item['id']]) {
25390 item.orphaned = true;
25391 batch.push(item);
25392 if (batch.length >= batchSize) {
25393 break;
25394 }
25395 }
25396 }
25397 }
25398
25399 return batch;
25400 }, this));
25401 } else {
25402 return PromisePolyfill.resolve(batch);
25403 }
25404 };
25405
25406 /**
25407 * Remove items with matching 'id' from array (immutably)
25408 * also remove any item without a valid id (e.g., malformed
25409 * storage entries).
25410 */
25411 var filterOutIDsAndInvalid = function (items, idSet) {
25412 var filteredItems = [];
25413 _.each(items, function (item) {
25414 if (item['id'] && !idSet[item['id']]) {
25415 filteredItems.push(item);
25416 }
25417 });
25418 return filteredItems;
25419 };
25420
25421 /**
25422 * Remove items with matching IDs from both in-memory queue
25423 * and persisted queue
25424 */
25425 RequestQueue.prototype.removeItemsByID = function (ids) {
25426 var idSet = {}; // poor man's Set
25427 _.each(ids, function (id) {
25428 idSet[id] = true;
25429 });
25430
25431 this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
25432 if (!this.usePersistence) {
25433 return PromisePolyfill.resolve(true);
25434 } else {
25435 var removeFromStorage = _.bind(function () {
25436 return this.ensureInit()
25437 .then(_.bind(function () {
25438 return this.readFromStorage();
25439 }, this))
25440 .then(_.bind(function (storedQueue) {
25441 storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
25442 return this.saveToStorage(storedQueue);
25443 }, this))
25444 .then(_.bind(function () {
25445 return this.readFromStorage();
25446 }, this))
25447 .then(_.bind(function (storedQueue) {
25448 // an extra check: did storage report success but somehow
25449 // the items are still there?
25450 for (var i = 0; i < storedQueue.length; i++) {
25451 var item = storedQueue[i];
25452 if (item['id'] && !!idSet[item['id']]) {
25453 throw new Error('Item not removed from storage');
25454 }
25455 }
25456 return true;
25457 }, this))
25458 .catch(_.bind(function (err) {
25459 this.reportError('Error removing items', err, ids);
25460 return false;
25461 }, this));
25462 }, this);
25463
25464 return this.lock
25465 .withLock(removeFromStorage, this.pid)
25466 .catch(_.bind(function (err) {
25467 this.reportError('Error acquiring storage lock', err);
25468 if (!localStorageSupported(this.lock.storage, true)) {
25469 // Looks like localStorage writes have stopped working sometime after
25470 // initialization (probably full), and so nobody can acquire locks
25471 // anymore. Consider it temporarily safe to remove items without the
25472 // lock, since nobody's writing successfully anyway.
25473 return removeFromStorage()
25474 .then(_.bind(function (success) {
25475 if (!success) {
25476 // OK, we couldn't even write out the smaller queue. Try clearing it
25477 // entirely.
25478 return this.queueStorage.removeItem(this.storageKey).then(function () {
25479 return success;
25480 });
25481 }
25482 return success;
25483 }, this))
25484 .catch(_.bind(function (err) {
25485 this.reportError('Error clearing queue', err);
25486 return false;
25487 }, this));
25488 } else {
25489 return false;
25490 }
25491 }, this));
25492 }
25493 };
25494
25495 // internal helper for RequestQueue.updatePayloads
25496 var updatePayloads = function (existingItems, itemsToUpdate) {
25497 var newItems = [];
25498 _.each(existingItems, function (item) {
25499 var id = item['id'];
25500 if (id in itemsToUpdate) {
25501 var newPayload = itemsToUpdate[id];
25502 if (newPayload !== null) {
25503 item['payload'] = newPayload;
25504 newItems.push(item);
25505 }
25506 } else {
25507 // no update
25508 newItems.push(item);
25509 }
25510 });
25511 return newItems;
25512 };
25513
25514 /**
25515 * Update payloads of given items in both in-memory queue and
25516 * persisted queue. Items set to null are removed from queues.
25517 */
25518 RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
25519 this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
25520 if (!this.usePersistence) {
25521 return PromisePolyfill.resolve(true);
25522 } else {
25523 return this.lock
25524 .withLock(_.bind(function lockAcquired() {
25525 return this.ensureInit()
25526 .then(_.bind(function () {
25527 return this.readFromStorage();
25528 }, this))
25529 .then(_.bind(function (storedQueue) {
25530 storedQueue = updatePayloads(storedQueue, itemsToUpdate);
25531 return this.saveToStorage(storedQueue);
25532 }, this))
25533 .catch(_.bind(function (err) {
25534 this.reportError('Error updating items', itemsToUpdate, err);
25535 return false;
25536 }, this));
25537 }, this), this.pid)
25538 .catch(_.bind(function (err) {
25539 this.reportError('Error acquiring storage lock', err);
25540 return false;
25541 }, this));
25542 }
25543 };
25544
25545 /**
25546 * Read and parse items array from localStorage entry, handling
25547 * malformed/missing data if necessary.
25548 */
25549 RequestQueue.prototype.readFromStorage = function () {
25550 return this.ensureInit()
25551 .then(_.bind(function () {
25552 return this.queueStorage.getItem(this.storageKey);
25553 }, this))
25554 .then(_.bind(function (storageEntry) {
25555 if (storageEntry) {
25556 if (!_.isArray(storageEntry)) {
25557 this.reportError('Invalid storage entry:', storageEntry);
25558 storageEntry = null;
25559 }
25560 }
25561 return storageEntry || [];
25562 }, this))
25563 .catch(_.bind(function (err) {
25564 this.reportError('Error retrieving queue', err);
25565 return [];
25566 }, this));
25567 };
25568
25569 /**
25570 * Serialize the given items array to localStorage.
25571 */
25572 RequestQueue.prototype.saveToStorage = function (queue) {
25573 return this.ensureInit()
25574 .then(_.bind(function () {
25575 return this.queueStorage.setItem(this.storageKey, queue);
25576 }, this))
25577 .then(function () {
25578 return true;
25579 })
25580 .catch(_.bind(function (err) {
25581 this.reportError('Error saving queue', err);
25582 return false;
25583 }, this));
25584 };
25585
25586 /**
25587 * Clear out queues (memory and localStorage).
25588 */
25589 RequestQueue.prototype.clear = function () {
25590 this.memQueue = [];
25591
25592 if (this.usePersistence) {
25593 return this.ensureInit()
25594 .then(_.bind(function () {
25595 return this.queueStorage.removeItem(this.storageKey);
25596 }, this));
25597 } else {
25598 return PromisePolyfill.resolve();
25599 }
25600 };
25601
25602 // maximum interval between request retries after exponential backoff
25603 var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1000; // 10 minutes
25604
25605 var logger$4 = console_with_prefix('batch');
25606
25607 /**
25608 * RequestBatcher: manages the queueing, flushing, retry etc of requests of one
25609 * type (events, people, groups).
25610 * Uses RequestQueue to manage the backing store.
25611 * @constructor
25612 */
25613 var RequestBatcher = function(storageKey, options) {
25614 this.errorReporter = options.errorReporter;
25615 this.queue = new RequestQueue(storageKey, {
25616 errorReporter: _.bind(this.reportError, this),
25617 queueStorage: options.queueStorage,
25618 sharedLockStorage: options.sharedLockStorage,
25619 sharedLockTimeoutMS: options.sharedLockTimeoutMS,
25620 usePersistence: options.usePersistence,
25621 enqueueThrottleMs: options.enqueueThrottleMs
25622 });
25623
25624 this.libConfig = options.libConfig;
25625 this.sendRequest = options.sendRequestFunc;
25626 this.beforeSendHook = options.beforeSendHook;
25627 this.stopAllBatching = options.stopAllBatchingFunc;
25628
25629 // seed variable batch size + flush interval with configured values
25630 this.batchSize = this.libConfig['batch_size'];
25631 this.flushInterval = this.libConfig['batch_flush_interval_ms'];
25632
25633 this.stopped = !this.libConfig['batch_autostart'];
25634 this.consecutiveRemovalFailures = 0;
25635
25636 // extra client-side dedupe
25637 this.itemIdsSentSuccessfully = {};
25638
25639 // Make the flush occur at the interval specified by flushIntervalMs, default behavior will attempt consecutive flushes
25640 // as long as the queue is not empty. This is useful for high-frequency events like Session Replay where we might end up
25641 // in a request loop and get ratelimited by the server.
25642 this.flushOnlyOnInterval = options.flushOnlyOnInterval || false;
25643
25644 this._flushPromise = null;
25645 };
25646
25647 /**
25648 * Add one item to queue.
25649 */
25650 RequestBatcher.prototype.enqueue = function(item) {
25651 return this.queue.enqueue(item, this.flushInterval);
25652 };
25653
25654 /**
25655 * Start flushing batches at the configured time interval. Must call
25656 * this method upon SDK init in order to send anything over the network.
25657 */
25658 RequestBatcher.prototype.start = function() {
25659 this.stopped = false;
25660 this.consecutiveRemovalFailures = 0;
25661 return this.flush();
25662 };
25663
25664 /**
25665 * Stop flushing batches. Can be restarted by calling start().
25666 */
25667 RequestBatcher.prototype.stop = function() {
25668 this.stopped = true;
25669 if (this.timeoutID) {
25670 clearTimeout(this.timeoutID);
25671 this.timeoutID = null;
25672 }
25673 };
25674
25675 /**
25676 * Clear out queue.
25677 */
25678 RequestBatcher.prototype.clear = function() {
25679 return this.queue.clear();
25680 };
25681
25682 /**
25683 * Restore batch size configuration to whatever is set in the main SDK.
25684 */
25685 RequestBatcher.prototype.resetBatchSize = function() {
25686 this.batchSize = this.libConfig['batch_size'];
25687 };
25688
25689 /**
25690 * Restore flush interval time configuration to whatever is set in the main SDK.
25691 */
25692 RequestBatcher.prototype.resetFlush = function() {
25693 this.scheduleFlush(this.libConfig['batch_flush_interval_ms']);
25694 };
25695
25696 /**
25697 * Schedule the next flush in the given number of milliseconds.
25698 */
25699 RequestBatcher.prototype.scheduleFlush = function(flushMS) {
25700 this.flushInterval = flushMS;
25701 if (!this.stopped) { // don't schedule anymore if batching has been stopped
25702 this.timeoutID = setTimeout(_.bind(function() {
25703 if (!this.stopped) {
25704 this._flushPromise = this.flush();
25705 }
25706 }, this), this.flushInterval);
25707 }
25708 };
25709
25710 /**
25711 * Send a request using the sendRequest callback, but promisified.
25712 * TODO: sendRequest should be promisified in the first place.
25713 */
25714 RequestBatcher.prototype.sendRequestPromise = function(data, options) {
25715 return new PromisePolyfill(_.bind(function(resolve) {
25716 this.sendRequest(data, options, resolve);
25717 }, this));
25718 };
25719
25720
25721 /**
25722 * Flush one batch to network. Depending on success/failure modes, it will either
25723 * remove the batch from the queue or leave it in for retry, and schedule the next
25724 * flush. In cases of most network or API failures, it will back off exponentially
25725 * when retrying.
25726 * @param {Object} [options]
25727 * @param {boolean} [options.sendBeacon] - whether to send batch with
25728 * navigator.sendBeacon (only useful for sending batches before page unloads, as
25729 * sendBeacon offers no callbacks or status indications)
25730 */
25731 RequestBatcher.prototype.flush = function(options) {
25732 if (this.requestInProgress) {
25733 logger$4.log('Flush: Request already in progress');
25734 return PromisePolyfill.resolve();
25735 }
25736
25737 this.requestInProgress = true;
25738
25739 options = options || {};
25740 var timeoutMS = this.libConfig['batch_request_timeout_ms'];
25741 var startTime = new Date().getTime();
25742 var currentBatchSize = this.batchSize;
25743
25744 return this.queue.fillBatch(currentBatchSize)
25745 .then(_.bind(function(batch) {
25746
25747 // if there's more items in the queue than the batch size, attempt
25748 // to flush again after the current batch is done.
25749 var attemptSecondaryFlush = batch.length === currentBatchSize;
25750 var dataForRequest = [];
25751 var transformedItems = {};
25752 _.each(batch, function(item) {
25753 var payload = item['payload'];
25754 if (this.beforeSendHook && !item.orphaned) {
25755 payload = this.beforeSendHook(payload);
25756 }
25757 if (payload) {
25758 // mp_sent_by_lib_version prop captures which lib version actually
25759 // sends each event (regardless of which version originally queued
25760 // it for sending)
25761 if (payload['event'] && payload['properties']) {
25762 payload['properties'] = _.extend(
25763 {},
25764 payload['properties'],
25765 {'mp_sent_by_lib_version': Config.LIB_VERSION}
25766 );
25767 }
25768 var addPayload = true;
25769 var itemId = item['id'];
25770 if (itemId) {
25771 if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
25772 this.reportError('[dupe] item ID sent too many times, not sending', {
25773 item: item,
25774 batchSize: batch.length,
25775 timesSent: this.itemIdsSentSuccessfully[itemId]
25776 });
25777 addPayload = false;
25778 }
25779 } else {
25780 this.reportError('[dupe] found item with no ID', {item: item});
25781 }
25782
25783 if (addPayload) {
25784 dataForRequest.push(payload);
25785 }
25786 }
25787 transformedItems[item['id']] = payload;
25788 }, this);
25789
25790 if (dataForRequest.length < 1) {
25791 this.requestInProgress = false;
25792 this.resetFlush();
25793 return PromisePolyfill.resolve(); // nothing to do
25794 }
25795
25796 var removeItemsFromQueue = _.bind(function () {
25797 return this.queue
25798 .removeItemsByID(
25799 _.map(batch, function (item) {
25800 return item['id'];
25801 })
25802 )
25803 .then(_.bind(function (succeeded) {
25804 // client-side dedupe
25805 _.each(batch, _.bind(function(item) {
25806 var itemId = item['id'];
25807 if (itemId) {
25808 this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
25809 this.itemIdsSentSuccessfully[itemId]++;
25810 if (this.itemIdsSentSuccessfully[itemId] > 5) {
25811 this.reportError('[dupe] item ID sent too many times', {
25812 item: item,
25813 batchSize: batch.length,
25814 timesSent: this.itemIdsSentSuccessfully[itemId]
25815 });
25816 }
25817 } else {
25818 this.reportError('[dupe] found item with no ID while removing', {item: item});
25819 }
25820 }, this));
25821
25822 if (succeeded) {
25823 this.consecutiveRemovalFailures = 0;
25824 if (this.flushOnlyOnInterval && !attemptSecondaryFlush) {
25825 this.resetFlush(); // schedule next batch with a delay
25826 return PromisePolyfill.resolve();
25827 } else {
25828 return this.flush(); // handle next batch if the queue isn't empty
25829 }
25830 } else {
25831 if (++this.consecutiveRemovalFailures > 5) {
25832 this.reportError('Too many queue failures; disabling batching system.');
25833 this.stopAllBatching();
25834 } else {
25835 this.resetFlush();
25836 }
25837 return PromisePolyfill.resolve();
25838 }
25839 }, this));
25840 }, this);
25841
25842 var batchSendCallback = _.bind(function(res) {
25843 this.requestInProgress = false;
25844
25845 try {
25846
25847 // handle API response in a try-catch to make sure we can reset the
25848 // flush operation if something goes wrong
25849
25850 if (options.unloading) {
25851 // update persisted data to include hook transformations
25852 return this.queue.updatePayloads(transformedItems);
25853 } else if (
25854 _.isObject(res) &&
25855 res.error === 'timeout' &&
25856 new Date().getTime() - startTime >= timeoutMS
25857 ) {
25858 this.reportError('Network timeout; retrying');
25859 return this.flush();
25860 } else if (
25861 _.isObject(res) &&
25862 (
25863 res.httpStatusCode >= 500
25864 || res.httpStatusCode === 429
25865 || (res.httpStatusCode <= 0 && !isOnline())
25866 || res.error === 'timeout'
25867 )
25868 ) {
25869 // network or API error, or 429 Too Many Requests, retry
25870 var retryMS = this.flushInterval * 2;
25871 if (res.retryAfter) {
25872 retryMS = (parseInt(res.retryAfter, 10) * 1000) || retryMS;
25873 }
25874 retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
25875 this.reportError('Error; retry in ' + retryMS + ' ms');
25876 this.scheduleFlush(retryMS);
25877 return PromisePolyfill.resolve();
25878 } else if (_.isObject(res) && res.httpStatusCode === 413) {
25879 // 413 Payload Too Large
25880 if (batch.length > 1) {
25881 var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
25882 this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
25883 this.reportError('413 response; reducing batch size to ' + this.batchSize);
25884 this.resetFlush();
25885 return PromisePolyfill.resolve();
25886 } else {
25887 this.reportError('Single-event request too large; dropping', batch);
25888 this.resetBatchSize();
25889 return removeItemsFromQueue();
25890 }
25891 } else {
25892 // successful network request+response; remove each item in batch from queue
25893 // (even if it was e.g. a 400, in which case retrying won't help)
25894 return removeItemsFromQueue();
25895 }
25896 } catch(err) {
25897 this.reportError('Error handling API response', err);
25898 this.resetFlush();
25899 }
25900 }, this);
25901 var requestOptions = {
25902 method: 'POST',
25903 verbose: true,
25904 ignore_json_errors: true, // eslint-disable-line camelcase
25905 timeout_ms: timeoutMS // eslint-disable-line camelcase
25906 };
25907 if (options.unloading) {
25908 requestOptions.transport = 'sendBeacon';
25909 }
25910 logger$4.log('MIXPANEL REQUEST:', dataForRequest);
25911 return this.sendRequestPromise(dataForRequest, requestOptions).then(batchSendCallback);
25912 }, this))
25913 .catch(_.bind(function(err) {
25914 this.reportError('Error flushing request queue', err);
25915 this.resetFlush();
25916 }, this));
25917 };
25918
25919 /**
25920 * Log error to global logger and optional user-defined logger.
25921 */
25922 RequestBatcher.prototype.reportError = function(msg, err) {
25923 logger$4.error.apply(logger$4.error, arguments);
25924 if (this.errorReporter) {
25925 try {
25926 if (!(err instanceof Error)) {
25927 err = new Error(msg);
25928 }
25929 this.errorReporter(msg, err);
25930 } catch(err) {
25931 logger$4.error(err);
25932 }
25933 }
25934 };
25935
25936 /**
25937 * @param {import('./session-recording').SerializedRecording} serializedRecording
25938 * @returns {boolean}
25939 */
25940 var isRecordingExpired = function(serializedRecording) {
25941 var now = Date.now();
25942 return !serializedRecording || now > serializedRecording['maxExpires'] || now > serializedRecording['idleExpires'];
25943 };
25944
25945 var RECORD_ENQUEUE_THROTTLE_MS = 250;
25946
25947 var logger$3 = console_with_prefix('recorder');
25948 var CompressionStream = win['CompressionStream'];
25949
25950 var RECORDER_BATCHER_LIB_CONFIG = {
25951 'batch_size': 1000,
25952 'batch_flush_interval_ms': 10 * 1000,
25953 'batch_request_timeout_ms': 90 * 1000,
25954 'batch_autostart': true
25955 };
25956
25957 var ACTIVE_SOURCES = new Set([
25958 IncrementalSource.MouseMove,
25959 IncrementalSource.MouseInteraction,
25960 IncrementalSource.Scroll,
25961 IncrementalSource.ViewportResize,
25962 IncrementalSource.Input,
25963 IncrementalSource.TouchMove,
25964 IncrementalSource.MediaInteraction,
25965 IncrementalSource.Drag,
25966 IncrementalSource.Selection,
25967 ]);
25968
25969 function isUserEvent(ev) {
25970 return ev.type === EventType.IncrementalSnapshot && ACTIVE_SOURCES.has(ev.data.source);
25971 }
25972
25973 /**
25974 * @typedef {Object} SerializedRecording
25975 * @property {number} idleExpires
25976 * @property {number} maxExpires
25977 * @property {number} replayStartTime
25978 * @property {number} seqNo
25979 * @property {string} batchStartUrl
25980 * @property {string} replayId
25981 * @property {string} tabId
25982 * @property {string} replayStartUrl
25983 */
25984
25985 /**
25986 * @typedef {Object} SessionRecordingOptions
25987 * @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
25988 * @property {String} [options.replayId] - unique uuid for a single replay
25989 * @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
25990 * @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
25991 * @property {Function} [options.rrwebRecord] - rrweb's `record` function
25992 * @property {Function} [options.onBatchSent] - callback when a batch of events is sent to the server
25993 * @property {Storage} [options.sharedLockStorage] - optional storage for shared lock, used for test dependency injection
25994 * optional properties for deserialization:
25995 * @property {number} idleExpires
25996 * @property {number} maxExpires
25997 * @property {number} replayStartTime
25998 * @property {number} seqNo
25999 * @property {string} batchStartUrl
26000 * @property {string} replayStartUrl
26001 */
26002
26003 /**
26004 * @typedef {Object} UserIdInfo
26005 * @property {string} distinct_id
26006 * @property {string} user_id
26007 * @property {string} device_id
26008 */
26009
26010
26011 /**
26012 * This class encapsulates a single session recording and its lifecycle.
26013 * @param {SessionRecordingOptions} options
26014 */
26015 var SessionRecording = function(options) {
26016 this._mixpanel = options.mixpanelInstance;
26017 this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
26018 this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
26019 this._onBatchSent = options.onBatchSent || NOOP_FUNC;
26020 this._rrwebRecord = options.rrwebRecord || null;
26021
26022 // internal rrweb stopRecording function
26023 this._stopRecording = null;
26024 this.replayId = options.replayId;
26025
26026 this.batchStartUrl = options.batchStartUrl || null;
26027 this.replayStartUrl = options.replayStartUrl || null;
26028 this.idleExpires = options.idleExpires || null;
26029 this.maxExpires = options.maxExpires || null;
26030 this.replayStartTime = options.replayStartTime || null;
26031 this.seqNo = options.seqNo || 0;
26032
26033 this.idleTimeoutId = null;
26034 this.maxTimeoutId = null;
26035
26036 this.recordMaxMs = MAX_RECORDING_MS;
26037 this.recordMinMs = 0;
26038
26039 // disable persistence if localStorage is not supported
26040 // request-queue will automatically disable persistence if indexedDB fails to initialize
26041 var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
26042
26043 // each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
26044 this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
26045 this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
26046 this.batcher = new RequestBatcher(this.batcherKey, {
26047 errorReporter: this.reportError.bind(this),
26048 flushOnlyOnInterval: true,
26049 libConfig: RECORDER_BATCHER_LIB_CONFIG,
26050 sendRequestFunc: this.flushEventsWithOptOut.bind(this),
26051 queueStorage: this.queueStorage,
26052 sharedLockStorage: options.sharedLockStorage,
26053 usePersistence: usePersistence,
26054 stopAllBatchingFunc: this.stopRecording.bind(this),
26055
26056 // increased throttle and shared lock timeout because recording events are very high frequency.
26057 // this will minimize the amount of lock contention between enqueued events.
26058 // for session recordings there is a lock for each tab anyway, so there's no risk of deadlock between tabs.
26059 enqueueThrottleMs: RECORD_ENQUEUE_THROTTLE_MS,
26060 sharedLockTimeoutMS: 10 * 1000,
26061 });
26062 };
26063
26064 /**
26065 * @returns {UserIdInfo}
26066 */
26067 SessionRecording.prototype.getUserIdInfo = function () {
26068 if (this.finalFlushUserIdInfo) {
26069 return this.finalFlushUserIdInfo;
26070 }
26071
26072 var userIdInfo = {
26073 'distinct_id': String(this._mixpanel.get_distinct_id()),
26074 };
26075
26076 // send ID management props if they exist
26077 var deviceId = this._mixpanel.get_property('$device_id');
26078 if (deviceId) {
26079 userIdInfo['$device_id'] = deviceId;
26080 }
26081 var userId = this._mixpanel.get_property('$user_id');
26082 if (userId) {
26083 userIdInfo['$user_id'] = userId;
26084 }
26085 return userIdInfo;
26086 };
26087
26088 SessionRecording.prototype.unloadPersistedData = function () {
26089 this.batcher.stop();
26090 return this.batcher.flush()
26091 .then(function () {
26092 return this.queueStorage.removeItem(this.batcherKey);
26093 }.bind(this));
26094 };
26095
26096 SessionRecording.prototype.getConfig = function(configVar) {
26097 return this._mixpanel.get_config(configVar);
26098 };
26099
26100 // Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
26101 // reaches into this class instance and expects the snake case version of the function.
26102 // eslint-disable-next-line camelcase
26103 SessionRecording.prototype.get_config = function(configVar) {
26104 return this.getConfig(configVar);
26105 };
26106
26107 SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
26108 if (this._rrwebRecord === null) {
26109 this.reportError('rrweb record function not provided. ');
26110 return;
26111 }
26112
26113 if (this._stopRecording !== null) {
26114 logger$3.log('Recording already in progress, skipping startRecording.');
26115 return;
26116 }
26117
26118 this.recordMaxMs = this.getConfig('record_max_ms');
26119 if (this.recordMaxMs > MAX_RECORDING_MS) {
26120 this.recordMaxMs = MAX_RECORDING_MS;
26121 logger$3.critical('record_max_ms cannot be greater than ' + MAX_RECORDING_MS + 'ms. Capping value.');
26122 }
26123
26124 if (!this.maxExpires) {
26125 this.maxExpires = new Date().getTime() + this.recordMaxMs;
26126 }
26127
26128 this.recordMinMs = this.getConfig('record_min_ms');
26129 if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
26130 this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
26131 logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
26132 }
26133
26134 if (!this.replayStartTime) {
26135 this.replayStartTime = new Date().getTime();
26136 this.batchStartUrl = _.info.currentUrl();
26137 this.replayStartUrl = _.info.currentUrl();
26138 }
26139
26140 if (shouldStopBatcher || this.recordMinMs > 0) {
26141 // the primary case for shouldStopBatcher is when we're starting recording after a reset
26142 // and don't want to send anything over the network until there's
26143 // actual user activity
26144 // this also applies if the minimum recording length has not been hit yet
26145 // so that we don't send data until we know the recording will be long enough
26146 this.batcher.stop();
26147 } else {
26148 this.batcher.start();
26149 }
26150
26151 var resetIdleTimeout = function () {
26152 clearTimeout(this.idleTimeoutId);
26153 var idleTimeoutMs = this.getConfig('record_idle_timeout_ms');
26154 this.idleTimeoutId = setTimeout(this._onIdleTimeout, idleTimeoutMs);
26155 this.idleExpires = new Date().getTime() + idleTimeoutMs;
26156 }.bind(this);
26157 resetIdleTimeout();
26158
26159 var blockSelector = this.getConfig('record_block_selector');
26160 if (blockSelector === '' || blockSelector === null) {
26161 blockSelector = undefined;
26162 }
26163
26164 try {
26165 this._stopRecording = this._rrwebRecord({
26166 'emit': function (ev) {
26167 if (this.idleExpires && this.idleExpires < ev.timestamp) {
26168 this._onIdleTimeout();
26169 return;
26170 }
26171 if (isUserEvent(ev)) {
26172 if (this.batcher.stopped && new Date().getTime() - this.replayStartTime >= this.recordMinMs) {
26173 // start flushing again after user activity
26174 this.batcher.start();
26175 }
26176 resetIdleTimeout();
26177 }
26178 // promise only used to await during tests
26179 this.__enqueuePromise = this.batcher.enqueue(ev);
26180 }.bind(this),
26181 'blockClass': this.getConfig('record_block_class'),
26182 'blockSelector': blockSelector,
26183 'collectFonts': this.getConfig('record_collect_fonts'),
26184 'dataURLOptions': { // canvas image options (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL)
26185 'type': 'image/webp',
26186 'quality': 0.6
26187 },
26188 'maskAllInputs': true,
26189 'maskTextClass': this.getConfig('record_mask_text_class'),
26190 'maskTextSelector': this.getConfig('record_mask_text_selector'),
26191 'recordCanvas': this.getConfig('record_canvas'),
26192 'sampling': {
26193 'canvas': 15
26194 }
26195 });
26196 } catch (err) {
26197 this.reportError('Unexpected error when starting rrweb recording.', err);
26198 }
26199
26200 if (typeof this._stopRecording !== 'function') {
26201 this.reportError('rrweb failed to start, skipping this recording.');
26202 this._stopRecording = null;
26203 this.stopRecording(); // stop batcher looping and any timeouts
26204 return;
26205 }
26206
26207 var maxTimeoutMs = this.maxExpires - new Date().getTime();
26208 this.maxTimeoutId = setTimeout(this._onMaxLengthReached.bind(this), maxTimeoutMs);
26209 };
26210
26211 SessionRecording.prototype.stopRecording = function (skipFlush) {
26212 // store the user ID info in case this is getting called in mixpanel.reset()
26213 this.finalFlushUserIdInfo = this.getUserIdInfo();
26214
26215 if (!this.isRrwebStopped()) {
26216 try {
26217 this._stopRecording();
26218 } catch (err) {
26219 this.reportError('Error with rrweb stopRecording', err);
26220 }
26221 this._stopRecording = null;
26222 }
26223
26224 var flushPromise;
26225 if (this.batcher.stopped) {
26226 // never got user activity to flush after reset, so just clear the batcher
26227 flushPromise = this.batcher.clear();
26228 } else if (!skipFlush) {
26229 // flush any remaining events from running batcher
26230 flushPromise = this.batcher.flush();
26231 }
26232 this.batcher.stop();
26233
26234 clearTimeout(this.idleTimeoutId);
26235 clearTimeout(this.maxTimeoutId);
26236 return flushPromise;
26237 };
26238
26239 SessionRecording.prototype.isRrwebStopped = function () {
26240 return this._stopRecording === null;
26241 };
26242
26243
26244 /**
26245 * Flushes the current batch of events to the server, but passes an opt-out callback to make sure
26246 * we stop recording and dump any queued events if the user has opted out.
26247 */
26248 SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
26249 var onOptOut = function (code) {
26250 // addOptOutCheckMixpanelLib invokes this function with code=0 when the user has opted out
26251 if (code === 0) {
26252 this.stopRecording();
26253 cb({error: 'Tracking has been opted out, stopping recording.'});
26254 }
26255 }.bind(this);
26256
26257 this._flushEvents(data, options, cb, onOptOut);
26258 };
26259
26260 /**
26261 * @returns {SerializedRecording}
26262 */
26263 SessionRecording.prototype.serialize = function () {
26264 // don't break if mixpanel instance was destroyed at some point
26265 var tabId;
26266 try {
26267 tabId = this._mixpanel.get_tab_id();
26268 } catch (e) {
26269 this.reportError('Error getting tab ID for serialization ', e);
26270 tabId = null;
26271 }
26272
26273 return {
26274 'replayId': this.replayId,
26275 'seqNo': this.seqNo,
26276 'replayStartTime': this.replayStartTime,
26277 'batchStartUrl': this.batchStartUrl,
26278 'replayStartUrl': this.replayStartUrl,
26279 'idleExpires': this.idleExpires,
26280 'maxExpires': this.maxExpires,
26281 'tabId': tabId,
26282 };
26283 };
26284
26285
26286 /**
26287 * @static
26288 * @param {SerializedRecording} serializedRecording
26289 * @param {SessionRecordingOptions} options
26290 * @returns {SessionRecording}
26291 */
26292 SessionRecording.deserialize = function (serializedRecording, options) {
26293 var recording = new SessionRecording(_.extend({}, options, {
26294 replayId: serializedRecording['replayId'],
26295 batchStartUrl: serializedRecording['batchStartUrl'],
26296 replayStartUrl: serializedRecording['replayStartUrl'],
26297 idleExpires: serializedRecording['idleExpires'],
26298 maxExpires: serializedRecording['maxExpires'],
26299 replayStartTime: serializedRecording['replayStartTime'],
26300 seqNo: serializedRecording['seqNo'],
26301 sharedLockStorage: options.sharedLockStorage,
26302 }));
26303
26304 return recording;
26305 };
26306
26307 SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
26308 var onSuccess = function (response, responseBody) {
26309 // Update batch specific props only if the request was successful to guarantee ordering.
26310 // RequestBatcher will always flush the next batch after the previous one succeeds.
26311 // extra check to see if the replay ID has changed so that we don't increment the seqNo on the wrong replay
26312 if (response.status === 200 && this.replayId === currentReplayId) {
26313 this.seqNo++;
26314 this.batchStartUrl = _.info.currentUrl();
26315 }
26316
26317 this._onBatchSent();
26318 callback({
26319 status: 0,
26320 httpStatusCode: response.status,
26321 responseBody: responseBody,
26322 retryAfter: response.headers.get('Retry-After')
26323 });
26324 }.bind(this);
26325 var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
26326 win['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
26327 'method': 'POST',
26328 'headers': {
26329 'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
26330 'Content-Type': 'application/octet-stream'
26331 },
26332 'body': reqBody,
26333 }).then(function (response) {
26334 response.json().then(function (responseBody) {
26335 onSuccess(response, responseBody);
26336 }).catch(function (error) {
26337 callback({error: error});
26338 });
26339 }).catch(function (error) {
26340 callback({error: error, httpStatusCode: 0});
26341 });
26342 };
26343
26344 SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (data, options, callback) {
26345 var numEvents = data.length;
26346
26347 if (numEvents > 0) {
26348 var replayId = this.replayId;
26349
26350 // each rrweb event has a timestamp - leverage those to get time properties
26351 var batchStartTime = Infinity;
26352 var batchEndTime = -Infinity;
26353 var hasFullSnapshot = false;
26354 for (var i = 0; i < numEvents; i++) {
26355 batchStartTime = Math.min(batchStartTime, data[i].timestamp);
26356 batchEndTime = Math.max(batchEndTime, data[i].timestamp);
26357 if (data[i].type === EventType.FullSnapshot) {
26358 hasFullSnapshot = true;
26359 }
26360 }
26361
26362 if (this.seqNo === 0) {
26363 if (!hasFullSnapshot) {
26364 callback({error: 'First batch does not contain a full snapshot. Aborting recording.'});
26365 this.stopRecording(true);
26366 return;
26367 }
26368 this.replayStartTime = batchStartTime;
26369 } else if (!this.replayStartTime) {
26370 this.reportError('Replay start time not set but seqNo is not 0. Using current batch start time as a fallback.');
26371 this.replayStartTime = batchStartTime;
26372 }
26373
26374 var replayLengthMs = batchEndTime - this.replayStartTime;
26375
26376 var reqParams = {
26377 '$current_url': this.batchStartUrl,
26378 '$lib_version': Config.LIB_VERSION,
26379 'batch_start_time': batchStartTime / 1000,
26380 'mp_lib': 'web',
26381 'replay_id': replayId,
26382 'replay_length_ms': replayLengthMs,
26383 'replay_start_time': this.replayStartTime / 1000,
26384 'replay_start_url': this.replayStartUrl,
26385 'seq': this.seqNo
26386 };
26387 var eventsJson = JSON.stringify(data);
26388 Object.assign(reqParams, this.getUserIdInfo());
26389
26390 if (CompressionStream) {
26391 var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
26392 var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
26393 new Response(gzipStream)
26394 .blob()
26395 .then(function(compressedBlob) {
26396 reqParams['format'] = 'gzip';
26397 this._sendRequest(replayId, reqParams, compressedBlob, callback);
26398 }.bind(this));
26399 } else {
26400 reqParams['format'] = 'body';
26401 this._sendRequest(replayId, reqParams, eventsJson, callback);
26402 }
26403 }
26404 });
26405
26406
26407 SessionRecording.prototype.reportError = function(msg, err) {
26408 logger$3.error.apply(logger$3.error, arguments);
26409 try {
26410 if (!err && !(msg instanceof Error)) {
26411 msg = new Error(msg);
26412 }
26413 this.getConfig('error_reporter')(msg, err);
26414 } catch(err) {
26415 logger$3.error(err);
26416 }
26417 };
26418
26419 /**
26420 * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
26421 * Makes sure that only one tab can be recording at a time.
26422 */
26423 var RecordingRegistry = function (options) {
26424 /** @type {IDBStorageWrapper} */
26425 this.idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
26426 this.errorReporter = options.errorReporter;
26427 this.mixpanelInstance = options.mixpanelInstance;
26428 this.sharedLockStorage = options.sharedLockStorage;
26429 };
26430
26431 RecordingRegistry.prototype.isPersistenceEnabled = function() {
26432 return !this.mixpanelInstance.get_config('disable_persistence');
26433 };
26434
26435 RecordingRegistry.prototype.handleError = function (err) {
26436 this.errorReporter('IndexedDB error: ', err);
26437 };
26438
26439 /**
26440 * @param {import('./session-recording').SerializedRecording} serializedRecording
26441 */
26442 RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
26443 if (!this.isPersistenceEnabled()) {
26444 return PromisePolyfill.resolve();
26445 }
26446
26447 var tabId = serializedRecording['tabId'];
26448 if (!tabId) {
26449 console.warn('No tab ID is set, cannot persist recording metadata.');
26450 return PromisePolyfill.resolve();
26451 }
26452
26453 return this.idb.init()
26454 .then(function () {
26455 return this.idb.setItem(tabId, serializedRecording);
26456 }.bind(this))
26457 .catch(this.handleError.bind(this));
26458 };
26459
26460 /**
26461 * @returns {Promise<import('./session-recording').SerializedRecording>}
26462 */
26463 RecordingRegistry.prototype.getActiveRecording = function () {
26464 if (!this.isPersistenceEnabled()) {
26465 return PromisePolyfill.resolve(null);
26466 }
26467
26468 return this.idb.init()
26469 .then(function () {
26470 return this.idb.getItem(this.mixpanelInstance.get_tab_id());
26471 }.bind(this))
26472 .then(function (serializedRecording) {
26473 return isRecordingExpired(serializedRecording) ? null : serializedRecording;
26474 }.bind(this))
26475 .catch(this.handleError.bind(this));
26476 };
26477
26478 RecordingRegistry.prototype.clearActiveRecording = function () {
26479 if (this.isPersistenceEnabled()) {
26480 // mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
26481 // this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
26482 return this.markActiveRecordingExpired();
26483 } else {
26484 return this.deleteActiveRecording();
26485 }
26486 };
26487
26488 RecordingRegistry.prototype.markActiveRecordingExpired = function () {
26489 return this.getActiveRecording()
26490 .then(function (serializedRecording) {
26491 if (serializedRecording) {
26492 serializedRecording['maxExpires'] = 0;
26493 return this.setActiveRecording(serializedRecording);
26494 }
26495 }.bind(this))
26496 .catch(this.handleError.bind(this));
26497 };
26498
26499 RecordingRegistry.prototype.deleteActiveRecording = function () {
26500 // avoid initializing IDB if this registry instance hasn't already written a recording
26501 if (this.idb.isInitialized()) {
26502 return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
26503 .catch(this.handleError.bind(this));
26504 } else {
26505 return PromisePolyfill.resolve();
26506 }
26507 };
26508
26509 /**
26510 * Flush any inactive recordings from the registry to minimize data loss.
26511 * The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
26512 */
26513 RecordingRegistry.prototype.flushInactiveRecordings = function () {
26514 if (!this.isPersistenceEnabled()) {
26515 return PromisePolyfill.resolve([]);
26516 }
26517
26518 return this.idb.init()
26519 .then(function() {
26520 return this.idb.getAll();
26521 }.bind(this))
26522 .then(function (serializedRecordings) {
26523 // clean up any expired recordings from the registry, non-expired ones may be active in other tabs
26524 var unloadPromises = serializedRecordings
26525 .filter(function (serializedRecording) {
26526 return isRecordingExpired(serializedRecording);
26527 })
26528 .map(function (serializedRecording) {
26529 var sessionRecording = SessionRecording.deserialize(serializedRecording, {
26530 mixpanelInstance: this.mixpanelInstance,
26531 sharedLockStorage: this.sharedLockStorage
26532 });
26533 return sessionRecording.unloadPersistedData()
26534 .then(function () {
26535 // expired recording was successfully flushed, we can clean it up from the registry
26536 return this.idb.removeItem(serializedRecording['tabId']);
26537 }.bind(this))
26538 .catch(this.handleError.bind(this));
26539 }.bind(this));
26540
26541 return PromisePolyfill.all(unloadPromises);
26542 }.bind(this))
26543 .catch(this.handleError.bind(this));
26544 };
26545
26546 var logger$2 = console_with_prefix('recorder');
26547
26548 /**
26549 * Recorder API: bundles rrweb and and exposes methods to start and stop recordings.
26550 * @param {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
26551 */
26552 var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage) {
26553 this.mixpanelInstance = mixpanelInstance;
26554 this.rrwebRecord = rrwebRecord || record;
26555 this.sharedLockStorage = sharedLockStorage;
26556
26557 /**
26558 * @member {import('./registry').RecordingRegistry}
26559 */
26560 this.recordingRegistry = new RecordingRegistry({
26561 mixpanelInstance: this.mixpanelInstance,
26562 errorReporter: logger$2.error,
26563 sharedLockStorage: sharedLockStorage
26564 });
26565 this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
26566
26567 this.activeRecording = null;
26568 this.stopRecordingInProgress = false;
26569 };
26570
26571 MixpanelRecorder.prototype.startRecording = function(options) {
26572 options = options || {};
26573 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26574 logger$2.log('Recording already in progress, skipping startRecording.');
26575 return;
26576 }
26577
26578 var onIdleTimeout = function () {
26579 logger$2.log('Idle timeout reached, restarting recording.');
26580 this.resetRecording();
26581 }.bind(this);
26582
26583 var onMaxLengthReached = function () {
26584 logger$2.log('Max recording length reached, stopping recording.');
26585 this.resetRecording();
26586 }.bind(this);
26587
26588 var onBatchSent = function () {
26589 this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26590 this['__flushPromise'] = this.activeRecording.batcher._flushPromise;
26591 }.bind(this);
26592
26593 /**
26594 * @type {import('./session-recording').SessionRecordingOptions}
26595 */
26596 var sessionRecordingOptions = {
26597 mixpanelInstance: this.mixpanelInstance,
26598 onBatchSent: onBatchSent,
26599 onIdleTimeout: onIdleTimeout,
26600 onMaxLengthReached: onMaxLengthReached,
26601 replayId: _.UUID(),
26602 rrwebRecord: this.rrwebRecord,
26603 sharedLockStorage: this.sharedLockStorage
26604 };
26605
26606 if (options.activeSerializedRecording) {
26607 this.activeRecording = SessionRecording.deserialize(options.activeSerializedRecording, sessionRecordingOptions);
26608 } else {
26609 this.activeRecording = new SessionRecording(sessionRecordingOptions);
26610 }
26611
26612 this.activeRecording.startRecording(options.shouldStopBatcher);
26613 return this.recordingRegistry.setActiveRecording(this.activeRecording.serialize());
26614 };
26615
26616 MixpanelRecorder.prototype.stopRecording = function() {
26617 // Prevents activeSerializedRecording from being reused when stopping the recording.
26618 this.stopRecordingInProgress = true;
26619 return this._stopCurrentRecording(false, true).then(function() {
26620 return this.recordingRegistry.clearActiveRecording();
26621 }.bind(this)).then(function() {
26622 this.stopRecordingInProgress = false;
26623 }.bind(this));
26624 };
26625
26626 MixpanelRecorder.prototype.pauseRecording = function() {
26627 return this._stopCurrentRecording(false);
26628 };
26629
26630 MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
26631 if (this.activeRecording) {
26632 var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
26633 if (disableActiveRecording) {
26634 this.activeRecording = null;
26635 }
26636 return stopRecordingPromise;
26637 }
26638 return PromisePolyfill.resolve();
26639 };
26640
26641 MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
26642 if (this.activeRecording && this.activeRecording.isRrwebStopped()) {
26643 this.activeRecording.startRecording(false);
26644 return PromisePolyfill.resolve(null);
26645 }
26646
26647 return this.recordingRegistry.getActiveRecording()
26648 .then(function (activeSerializedRecording) {
26649 if (activeSerializedRecording && !this.stopRecordingInProgress) {
26650 return this.startRecording({activeSerializedRecording: activeSerializedRecording});
26651 } else if (startNewIfInactive) {
26652 return this.startRecording({shouldStopBatcher: false});
26653 } else {
26654 logger$2.log('No resumable recording found.');
26655 return null;
26656 }
26657 }.bind(this));
26658 };
26659
26660
26661 MixpanelRecorder.prototype.resetRecording = function () {
26662 this.stopRecording();
26663 this.startRecording({shouldStopBatcher: true});
26664 };
26665
26666 MixpanelRecorder.prototype.getActiveReplayId = function () {
26667 if (this.activeRecording && !this.activeRecording.isRrwebStopped()) {
26668 return this.activeRecording.replayId;
26669 } else {
26670 return null;
26671 }
26672 };
26673
26674 // getter so that older mixpanel-core versions can still retrieve the replay ID
26675 // when pulling the latest recorder bundle from the CDN
26676 Object.defineProperty(MixpanelRecorder.prototype, 'replayId', {
26677 get: function () {
26678 return this.getActiveReplayId();
26679 }
26680 });
26681
26682 win['__mp_recorder'] = MixpanelRecorder;
26683
26684 // stateless utils
26685 // mostly from https://github.com/mixpanel/mixpanel-js/blob/989ada50f518edab47b9c4fd9535f9fbd5ec5fc0/src/autotrack-utils.js
26686
26687
26688 var EV_CHANGE = 'change';
26689 var EV_CLICK = 'click';
26690 var EV_HASHCHANGE = 'hashchange';
26691 var EV_INPUT = 'input';
26692 var EV_LOAD = 'load';
26693 var EV_MP_LOCATION_CHANGE = 'mp_locationchange';
26694 var EV_POPSTATE = 'popstate';
26695 // TODO scrollend isn't available in Safari: document or polyfill?
26696 var EV_SCROLLEND = 'scrollend';
26697 var EV_SCROLL = 'scroll';
26698 var EV_SELECT = 'select';
26699 var EV_SUBMIT = 'submit';
26700 var EV_TOGGLE = 'toggle';
26701 var EV_VISIBILITYCHANGE = 'visibilitychange';
26702
26703 var CLICK_EVENT_PROPS = [
26704 'clientX', 'clientY',
26705 'offsetX', 'offsetY',
26706 'pageX', 'pageY',
26707 'screenX', 'screenY',
26708 'x', 'y'
26709 ];
26710 var OPT_IN_CLASSES = ['mp-include'];
26711 var OPT_OUT_CLASSES = ['mp-no-track'];
26712 var SENSITIVE_DATA_CLASSES = OPT_OUT_CLASSES.concat(['mp-sensitive']);
26713 var TRACKED_ATTRS = [
26714 'aria-label', 'aria-labelledby', 'aria-describedby',
26715 'href', 'name', 'role', 'title', 'type'
26716 ];
26717
26718 var INTERACTIVE_ARIA_ROLES = {
26719 'button': true,
26720 'checkbox': true,
26721 'combobox': true,
26722 'grid': true,
26723 'link': true,
26724 'listbox': true,
26725 'menu': true,
26726 'menubar': true,
26727 'menuitem': true,
26728 'menuitemcheckbox': true,
26729 'menuitemradio': true,
26730 'navigation': true,
26731 'option': true,
26732 'radio': true,
26733 'radiogroup': true,
26734 'searchbox': true,
26735 'slider': true,
26736 'spinbutton': true,
26737 'switch': true,
26738 'tab': true,
26739 'tablist': true,
26740 'textbox': true,
26741 'tree': true,
26742 'treegrid': true,
26743 'treeitem': true
26744 };
26745
26746 var ALWAYS_NON_INTERACTIVE_TAGS = {
26747 // Document metadata
26748 'base': true,
26749 'head': true,
26750 'html': true,
26751 'link': true,
26752 'meta': true,
26753 'script': true,
26754 'style': true,
26755 'title': true,
26756 // Text formatting
26757 'br': true,
26758 'hr': true,
26759 'wbr': true,
26760 // Other
26761 'noscript': true,
26762 'picture': true,
26763 'source': true,
26764 'template': true,
26765 'track': true
26766 };
26767
26768 // Common container tags that need additional checks
26769 var TEXT_CONTAINER_TAGS = {
26770 'article': true,
26771 'div': true,
26772 'h1': true,
26773 'h2': true,
26774 'h3': true,
26775 'h4': true,
26776 'h5': true,
26777 'h6': true,
26778 'p': true,
26779 'section': true,
26780 'span': true
26781 };
26782
26783 var EVENT_HANDLER_ATTRIBUTES = [
26784 'onclick', 'onmousedown', 'onmouseup', 'onpointerdown', 'onpointerup', 'ontouchend', 'ontouchstart'
26785 ];
26786
26787 var MAX_DEPTH = 5;
26788
26789 var logger$1 = console_with_prefix('autocapture');
26790
26791
26792 function getClasses(el) {
26793 var classes = {};
26794 var classList = getClassName(el).split(' ');
26795 for (var i = 0; i < classList.length; i++) {
26796 var cls = classList[i];
26797 if (cls) {
26798 classes[cls] = true;
26799 }
26800 }
26801 return classes;
26802 }
26803
26804 /*
26805 * Get the className of an element, accounting for edge cases where element.className is an object
26806 * @param {Element} el - element to get the className of
26807 * @returns {string} the element's class
26808 */
26809 function getClassName(el) {
26810 switch(typeof el.className) {
26811 case 'string':
26812 return el.className;
26813 case 'object': // handle cases where className might be SVGAnimatedString or some other type
26814 return el.className.baseVal || el.getAttribute('class') || '';
26815 default: // future proof
26816 return '';
26817 }
26818 }
26819
26820 function getPreviousElementSibling(el) {
26821 if (el.previousElementSibling) {
26822 return el.previousElementSibling;
26823 } else {
26824 do {
26825 el = el.previousSibling;
26826 } while (el && !isElementNode(el));
26827 return el;
26828 }
26829 }
26830
26831 function getPropertiesFromElement(el, ev, blockAttrsSet, extraAttrs, allowElementCallback, allowSelectors) {
26832 var props = {
26833 '$classes': getClassName(el).split(' '),
26834 '$tag_name': el.tagName.toLowerCase()
26835 };
26836 var elId = el.id;
26837 if (elId) {
26838 props['$id'] = elId;
26839 }
26840
26841 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors)) {
26842 _.each(TRACKED_ATTRS.concat(extraAttrs), function(attr) {
26843 if (el.hasAttribute(attr) && !blockAttrsSet[attr]) {
26844 var attrVal = el.getAttribute(attr);
26845 if (shouldTrackValue(attrVal)) {
26846 props['$attr-' + attr] = attrVal;
26847 }
26848 }
26849 });
26850 }
26851
26852 var nthChild = 1;
26853 var nthOfType = 1;
26854 var currentElem = el;
26855 while (currentElem = getPreviousElementSibling(currentElem)) { // eslint-disable-line no-cond-assign
26856 nthChild++;
26857 if (currentElem.tagName === el.tagName) {
26858 nthOfType++;
26859 }
26860 }
26861 props['$nth_child'] = nthChild;
26862 props['$nth_of_type'] = nthOfType;
26863
26864 return props;
26865 }
26866
26867 function getPropsForDOMEvent(ev, config) {
26868 var allowElementCallback = config.allowElementCallback;
26869 var allowSelectors = config.allowSelectors || [];
26870 var blockAttrs = config.blockAttrs || [];
26871 var blockElementCallback = config.blockElementCallback;
26872 var blockSelectors = config.blockSelectors || [];
26873 var captureTextContent = config.captureTextContent || false;
26874 var captureExtraAttrs = config.captureExtraAttrs || [];
26875 var capturedForHeatMap = config.capturedForHeatMap || false;
26876
26877 // convert array to set every time, as the config may have changed
26878 var blockAttrsSet = {};
26879 _.each(blockAttrs, function(attr) {
26880 blockAttrsSet[attr] = true;
26881 });
26882
26883 var props = null;
26884
26885 var target = typeof ev.target === 'undefined' ? ev.srcElement : ev.target;
26886 if (isTextNode(target)) { // defeat Safari bug (see: http://www.quirksmode.org/js/events_properties.html)
26887 target = target.parentNode;
26888 }
26889
26890 if (
26891 shouldTrackDomEvent(target, ev) &&
26892 isElementAllowed(target, ev, allowElementCallback, allowSelectors) &&
26893 !isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26894 ) {
26895 var targetElementList = [target];
26896 var curEl = target;
26897 while (curEl.parentNode && !isTag(curEl, 'body')) {
26898 targetElementList.push(curEl.parentNode);
26899 curEl = curEl.parentNode;
26900 }
26901
26902 var elementsJson = [];
26903 var href, explicitNoTrack = false;
26904 _.each(targetElementList, function(el) {
26905 var shouldTrackDetails = shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors);
26906
26907 // if the element or a parent element is an anchor tag
26908 // include the href as a property
26909 if (!blockAttrsSet['href'] && el.tagName.toLowerCase() === 'a') {
26910 href = el.getAttribute('href');
26911 href = shouldTrackDetails && shouldTrackValue(href) && href;
26912 }
26913
26914 if (isElementBlocked(el, ev, blockElementCallback, blockSelectors)) {
26915 explicitNoTrack = true;
26916 }
26917
26918 elementsJson.push(getPropertiesFromElement(el, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors));
26919 }, this);
26920
26921 if (!explicitNoTrack) {
26922 var docElement = document$1['documentElement'];
26923 props = {
26924 '$event_type': ev.type,
26925 '$host': win.location.host,
26926 '$pathname': win.location.pathname,
26927 '$elements': elementsJson,
26928 '$el_attr__href': href,
26929 '$viewportHeight': Math.max(docElement['clientHeight'], win['innerHeight'] || 0),
26930 '$viewportWidth': Math.max(docElement['clientWidth'], win['innerWidth'] || 0),
26931 '$pageHeight': document$1['body']['offsetHeight'] || 0,
26932 '$pageWidth': document$1['body']['offsetWidth'] || 0,
26933 };
26934 _.each(captureExtraAttrs, function(attr) {
26935 if (!blockAttrsSet[attr] && target.hasAttribute(attr)) {
26936 var attrVal = target.getAttribute(attr);
26937 if (shouldTrackValue(attrVal)) {
26938 props['$el_attr__' + attr] = attrVal;
26939 }
26940 }
26941 });
26942
26943 if (captureTextContent) {
26944 elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26945 if (elementText && elementText.length) {
26946 props['$el_text'] = elementText;
26947 }
26948 }
26949
26950 if (ev.type === EV_CLICK) {
26951 _.each(CLICK_EVENT_PROPS, function(prop) {
26952 if (prop in ev) {
26953 props['$' + prop] = ev[prop];
26954 }
26955 });
26956 if (capturedForHeatMap) {
26957 props['$captured_for_heatmap'] = true;
26958 }
26959 target = guessRealClickTarget(ev);
26960 }
26961 // prioritize text content from "real" click target if different from original target
26962 if (captureTextContent) {
26963 var elementText = getSafeText(target, ev, allowElementCallback, allowSelectors);
26964 if (elementText && elementText.length) {
26965 props['$el_text'] = elementText;
26966 }
26967 }
26968
26969 if (target) {
26970 // target may have been recalculated; check allowlists and blocklists again
26971 if (
26972 !isElementAllowed(target, ev, allowElementCallback, allowSelectors) ||
26973 isElementBlocked(target, ev, blockElementCallback, blockSelectors)
26974 ) {
26975 return null;
26976 }
26977
26978 var targetProps = getPropertiesFromElement(target, ev, blockAttrsSet, captureExtraAttrs, allowElementCallback, allowSelectors);
26979 props['$target'] = targetProps;
26980 // pull up more props onto main event props
26981 props['$el_classes'] = targetProps['$classes'];
26982 _.extend(props, _.strip_empty_properties({
26983 '$el_id': targetProps['$id'],
26984 '$el_tag_name': targetProps['$tag_name']
26985 }));
26986 }
26987 }
26988 }
26989
26990 return props;
26991 }
26992
26993
26994 /**
26995 * Get the direct text content of an element, protecting against sensitive data collection.
26996 * Concats textContent of each of the element's text node children; this avoids potential
26997 * collection of sensitive data that could happen if we used element.textContent and the
26998 * element had sensitive child elements, since element.textContent includes child content.
26999 * Scrubs values that look like they could be sensitive (i.e. cc or ssn number).
27000 * @param {Element} el - element to get the text of
27001 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27002 * @returns {string} the element's direct text content
27003 */
27004 function getSafeText(el, ev, allowElementCallback, allowSelectors) {
27005 var elText = '';
27006
27007 if (shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) && el.childNodes && el.childNodes.length) {
27008 _.each(el.childNodes, function(child) {
27009 if (isTextNode(child) && child.textContent) {
27010 elText += _.trim(child.textContent)
27011 // scrub potentially sensitive values
27012 .split(/(\s+)/).filter(shouldTrackValue).join('')
27013 // normalize whitespace
27014 .replace(/[\r\n]/g, ' ').replace(/[ ]+/g, ' ')
27015 // truncate
27016 .substring(0, 255);
27017 }
27018 });
27019 }
27020
27021 return _.trim(elText);
27022 }
27023
27024 function guessRealClickTarget(ev) {
27025 var target = ev.target;
27026 var composedPath = ev['composedPath']();
27027 for (var i = 0; i < composedPath.length; i++) {
27028 var node = composedPath[i];
27029 if (
27030 isTag(node, 'a') ||
27031 isTag(node, 'button') ||
27032 isTag(node, 'input') ||
27033 isTag(node, 'select') ||
27034 (node.getAttribute && node.getAttribute('role') === 'button')
27035 ) {
27036 target = node;
27037 break;
27038 }
27039 if (node === target) {
27040 break;
27041 }
27042 }
27043 return target;
27044 }
27045
27046 function isElementAllowed(el, ev, allowElementCallback, allowSelectors) {
27047 if (allowElementCallback) {
27048 try {
27049 if (!allowElementCallback(el, ev)) {
27050 return false;
27051 }
27052 } catch (err) {
27053 logger$1.critical('Error while checking element in allowElementCallback', err);
27054 return false;
27055 }
27056 }
27057
27058 if (!allowSelectors.length) {
27059 // no allowlist; all elements are fair game
27060 return true;
27061 }
27062
27063 for (var i = 0; i < allowSelectors.length; i++) {
27064 var sel = allowSelectors[i];
27065 try {
27066 if (el['matches'](sel)) {
27067 return true;
27068 }
27069 } catch (err) {
27070 logger$1.critical('Error while checking selector: ' + sel, err);
27071 }
27072 }
27073 return false;
27074 }
27075
27076 function isElementBlocked(el, ev, blockElementCallback, blockSelectors) {
27077 var i;
27078
27079 if (blockElementCallback) {
27080 try {
27081 if (blockElementCallback(el, ev)) {
27082 return true;
27083 }
27084 } catch (err) {
27085 logger$1.critical('Error while checking element in blockElementCallback', err);
27086 return true;
27087 }
27088 }
27089
27090 if (blockSelectors && blockSelectors.length) {
27091 // programmatically prevent tracking of elements that match CSS selectors
27092 for (i = 0; i < blockSelectors.length; i++) {
27093 var sel = blockSelectors[i];
27094 try {
27095 if (el['matches'](sel)) {
27096 return true;
27097 }
27098 } catch (err) {
27099 logger$1.critical('Error while checking selector: ' + sel, err);
27100 }
27101 }
27102 }
27103
27104 // allow users to programmatically prevent tracking of elements by adding default classes such as 'mp-no-track'
27105 var classes = getClasses(el);
27106 for (i = 0; i < OPT_OUT_CLASSES.length; i++) {
27107 if (classes[OPT_OUT_CLASSES[i]]) {
27108 return true;
27109 }
27110 }
27111
27112 return false;
27113 }
27114
27115 /*
27116 * Check whether a DOM node has nodeType Node.ELEMENT_NODE
27117 * @param {Node} node - node to check
27118 * @returns {boolean} whether node is of the correct nodeType
27119 */
27120 function isElementNode(node) {
27121 return node && node.nodeType === 1; // Node.ELEMENT_NODE - use integer constant for browser portability
27122 }
27123
27124 /*
27125 * Check whether an element is of a given tag type.
27126 * Due to potential reference discrepancies (such as the webcomponents.js polyfill),
27127 * we want to match tagNames instead of specific references because something like
27128 * element === document.body won't always work because element might not be a native
27129 * element.
27130 * @param {Element} el - element to check
27131 * @param {string} tag - tag name (e.g., "div")
27132 * @returns {boolean} whether el is of the given tag type
27133 */
27134 function isTag(el, tag) {
27135 return el && el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
27136 }
27137
27138 /*
27139 * Check whether a DOM node is a TEXT_NODE
27140 * @param {Node} node - node to check
27141 * @returns {boolean} whether node is of type Node.TEXT_NODE
27142 */
27143 function isTextNode(node) {
27144 return node && node.nodeType === 3; // Node.TEXT_NODE - use integer constant for browser portability
27145 }
27146
27147 function minDOMApisSupported() {
27148 try {
27149 var testEl = document$1.createElement('div');
27150 return !!testEl['matches'];
27151 } catch (err) {
27152 return false;
27153 }
27154 }
27155
27156 function weakSetSupported() {
27157 return typeof WeakSet !== 'undefined';
27158 }
27159
27160 /*
27161 * Check whether a DOM event should be "tracked" or if it may contain sensitive data
27162 * using a variety of heuristics.
27163 * @param {Element} el - element to check
27164 * @param {Event} ev - event to check
27165 * @returns {boolean} whether the event should be tracked
27166 */
27167 function shouldTrackDomEvent(el, ev) {
27168 if (!el || isTag(el, 'html') || !isElementNode(el)) {
27169 return false;
27170 }
27171 var tag = el.tagName.toLowerCase();
27172 switch (tag) {
27173 case 'form':
27174 return ev.type === EV_SUBMIT;
27175 case 'input':
27176 if (['button', 'submit'].indexOf(el.getAttribute('type')) === -1) {
27177 return ev.type === EV_CHANGE;
27178 } else {
27179 return ev.type === EV_CLICK;
27180 }
27181 case 'select':
27182 case 'textarea':
27183 return ev.type === EV_CHANGE;
27184 default:
27185 return ev.type === EV_CLICK;
27186 }
27187 }
27188
27189 /*
27190 * Check whether a DOM element should be "tracked" or if it may contain sensitive data
27191 * using a variety of heuristics.
27192 * @param {Element} el - element to check
27193 * @param {Array<string>} allowSelectors - CSS selectors for elements that should be included
27194 * @returns {boolean} whether the element should be tracked
27195 */
27196 function shouldTrackElementDetails(el, ev, allowElementCallback, allowSelectors) {
27197 var i;
27198
27199 if (!isElementAllowed(el, ev, allowElementCallback, allowSelectors)) {
27200 return false;
27201 }
27202
27203 for (var curEl = el; curEl.parentNode && !isTag(curEl, 'body'); curEl = curEl.parentNode) {
27204 var classes = getClasses(curEl);
27205 for (i = 0; i < SENSITIVE_DATA_CLASSES.length; i++) {
27206 if (classes[SENSITIVE_DATA_CLASSES[i]]) {
27207 return false;
27208 }
27209 }
27210 }
27211
27212 var elClasses = getClasses(el);
27213 for (i = 0; i < OPT_IN_CLASSES.length; i++) {
27214 if (elClasses[OPT_IN_CLASSES[i]]) {
27215 return true;
27216 }
27217 }
27218
27219 // don't send data from inputs or similar elements since there will always be
27220 // a risk of clientside javascript placing sensitive data in attributes
27221 if (
27222 isTag(el, 'input') ||
27223 isTag(el, 'select') ||
27224 isTag(el, 'textarea') ||
27225 el.getAttribute('contenteditable') === 'true'
27226 ) {
27227 return false;
27228 }
27229
27230 // don't include hidden or password fields
27231 var type = el.type || '';
27232 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"]
27233 switch(type.toLowerCase()) {
27234 case 'hidden':
27235 return false;
27236 case 'password':
27237 return false;
27238 }
27239 }
27240
27241 // filter out data from fields that look like sensitive fields
27242 var name = el.name || el.id || '';
27243 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"]
27244 var sensitiveNameRegex = /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i;
27245 if (sensitiveNameRegex.test(name.replace(/[^a-zA-Z0-9]/g, ''))) {
27246 return false;
27247 }
27248 }
27249
27250 return true;
27251 }
27252
27253
27254 /*
27255 * Check whether a string value should be "tracked" or if it may contain sensitive data
27256 * using a variety of heuristics.
27257 * @param {string} value - string value to check
27258 * @returns {boolean} whether the element should be tracked
27259 */
27260 function shouldTrackValue(value) {
27261 if (value === null || _.isUndefined(value)) {
27262 return false;
27263 }
27264
27265 if (typeof value === 'string') {
27266 value = _.trim(value);
27267
27268 // check to see if input value looks like a credit card number
27269 // see: https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch04s20.html
27270 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}))$/;
27271 if (ccRegex.test((value || '').replace(/[- ]/g, ''))) {
27272 return false;
27273 }
27274
27275 // check to see if input value looks like a social security number
27276 var ssnRegex = /(^\d{3}-?\d{2}-?\d{4}$)/;
27277 if (ssnRegex.test(value)) {
27278 return false;
27279 }
27280 }
27281
27282 return true;
27283 }
27284
27285 /**
27286 * Creates a cross-browser compatible scroll end function with appropriate event listener.
27287 * For browsers that support scrollend, returns the original function with scrollend event.
27288 * For browsers without scrollend support, returns a debounced function that triggers
27289 * 100ms after the last scroll event to simulate scrollend behavior.
27290 * @param {Function} originalFunction - The function to call when scrolling ends
27291 * @returns {Object} Object containing listener function and eventType string
27292 * @returns {Function} returns.listener - The wrapped function to use as event listener
27293 * @returns {string} returns.eventType - The event type to listen for ('scrollend' or 'scroll')
27294 */
27295 function getPolyfillScrollEndFunction(originalFunction) {
27296 var supportsScrollEnd = 'onscrollend' in win;
27297 var polyfillFunction = safewrap(originalFunction);
27298 var polyfillEvent = EV_SCROLLEND;
27299 if (!supportsScrollEnd) {
27300 // Polyfill for browsers without scrollend support: wait 100ms after the last scroll event
27301 // https://developer.chrome.com/blog/scrollend-a-new-javascript-event
27302 var scrollTimer = null;
27303 var scrollDelayMs = 100;
27304
27305 polyfillFunction = safewrap(function() {
27306 clearTimeout(scrollTimer);
27307 scrollTimer = setTimeout(originalFunction, scrollDelayMs);
27308 });
27309
27310 polyfillEvent = EV_SCROLL;
27311 }
27312
27313 return {
27314 listener: polyfillFunction,
27315 eventType: polyfillEvent
27316 };
27317 }
27318
27319 function hasInlineEventHandlers(element) {
27320 for (var i = 0; i < EVENT_HANDLER_ATTRIBUTES.length; i++) {
27321 if (element.hasAttribute(EVENT_HANDLER_ATTRIBUTES[i])) {
27322 return true;
27323 }
27324 }
27325 return false;
27326 }
27327
27328 function hasInteractiveAriaRole(element) {
27329 var role = element.getAttribute('role');
27330 if (!role) return false;
27331
27332 // Handle invalid markup where multiple roles might be specified
27333 // Only the first token is recognized per ARIA spec
27334 var primaryRole = role.trim().split(/\s+/)[0].toLowerCase();
27335
27336 return INTERACTIVE_ARIA_ROLES[primaryRole];
27337 }
27338
27339 function hasAnyInteractivityIndicators(element) {
27340 var tagName = element.tagName.toLowerCase();
27341
27342 // Check for interactive HTML elements
27343 if (tagName === 'button' ||
27344 tagName === 'input' ||
27345 tagName === 'select' ||
27346 tagName === 'textarea' ||
27347 tagName === 'details' ||
27348 tagName === 'dialog') {
27349 return true;
27350 }
27351
27352 if (element.isContentEditable) {
27353 return true;
27354 }
27355
27356 if (element.onclick || element.onmousedown || element.onmouseup || element.ontouchstart || element.ontouchend) {
27357 return true;
27358 }
27359
27360 if (hasInlineEventHandlers(element)) {
27361 return true;
27362 }
27363
27364 if (hasInteractiveAriaRole(element)) {
27365 return true;
27366 }
27367
27368 if (tagName === 'a' && element.hasAttribute('href')) {
27369 return true;
27370 }
27371
27372 if (element.hasAttribute('tabindex')) {
27373 return true;
27374 }
27375
27376 return false;
27377 }
27378
27379
27380 function isDefinitelyNonInteractive(element) {
27381 if (!element || !element.tagName) {
27382 return true;
27383 }
27384
27385 var tagName = element.tagName.toLowerCase();
27386
27387 // These tags are definitely non-interactive
27388 if (ALWAYS_NON_INTERACTIVE_TAGS[tagName]) {
27389 return true;
27390 }
27391
27392 // For all other elements, we can only be certain they're non-interactive if they lack ALL indicators of interactivity
27393 // Check for any signs of interactivity
27394 if (hasAnyInteractivityIndicators(element)) {
27395 return false;
27396 }
27397
27398 // Check parent chain for interactive context
27399 var parent = element.parentElement;
27400 var depth = 0;
27401
27402 while (parent && depth < MAX_DEPTH) {
27403 if (hasAnyInteractivityIndicators(parent)) {
27404 return false; // Element is inside an interactive parent
27405 }
27406
27407 if (parent.getRootNode && parent.getRootNode() !== document$1) {
27408 var root = parent.getRootNode();
27409 if (root.host && hasAnyInteractivityIndicators(root.host)) {
27410 return false; // Inside an interactive shadow host
27411 }
27412 }
27413
27414 parent = parent.parentElement;
27415 depth++;
27416 }
27417
27418 // Pure text containers without any interactive context
27419 if (TEXT_CONTAINER_TAGS[tagName]) {
27420 // These are non-interactive ONLY if they have no interactive indicators (already checked as part of hasAnyInteractivityIndicators)
27421 return true;
27422 }
27423
27424 // Default: we can't be certain it's non-interactive
27425 return false;
27426 }
27427
27428 /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
27429 /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
27430 /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
27431
27432 function RageClickTracker() {
27433 this.clicks = [];
27434 }
27435
27436 RageClickTracker.prototype.isRageClick = function(x, y, options) {
27437 options = options || {};
27438 var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
27439 var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
27440 var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
27441 var timestamp = Date.now();
27442
27443 var lastClick = this.clicks[this.clicks.length - 1];
27444 if (
27445 lastClick &&
27446 timestamp - lastClick.timestamp < timeoutMs &&
27447 Math.sqrt(Math.pow(x - lastClick.x, 2) + Math.pow(y - lastClick.y, 2)) < thresholdPx
27448 ) {
27449 this.clicks.push({ x: x, y: y, timestamp: timestamp });
27450 if (this.clicks.length >= clickCount) {
27451 this.clicks = [];
27452 return true;
27453 }
27454 } else {
27455 this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27456 }
27457 return false;
27458 };
27459
27460 function ShadowDOMObserver(changeCallback, observerConfig) {
27461 this.changeCallback = changeCallback || function() {};
27462 this.observerConfig = observerConfig;
27463
27464 this.observedShadowRoots = null;
27465 this.shadowObservers = [];
27466 }
27467
27468 ShadowDOMObserver.prototype.getEventTarget = function(event) {
27469 if (!this.observedShadowRoots) {
27470 return;
27471 }
27472 var path = this.getComposedPath(event);
27473 if (path && path.length) {
27474 return path[0];
27475 }
27476
27477 return event['target'] || event['srcElement'];
27478 };
27479
27480
27481 ShadowDOMObserver.prototype.getComposedPath = function(event) {
27482 if ('composedPath' in event) {
27483 return event['composedPath']();
27484 }
27485
27486 return [];
27487 };
27488 ShadowDOMObserver.prototype.observeFromEvent = function(event) {
27489 if (!this.observedShadowRoots) {
27490 return;
27491 }
27492
27493 var path = this.getComposedPath(event);
27494
27495 // Check each element in path for shadow roots
27496 for (var i = 0; i < path.length; i++) {
27497 var element = path[i];
27498
27499 if (element && element.shadowRoot) {
27500 this.observeShadowRoot(element.shadowRoot);
27501 }
27502 }
27503 };
27504
27505
27506 ShadowDOMObserver.prototype.observeShadowRoot = function(shadowRoot) {
27507 if (!this.observedShadowRoots || this.observedShadowRoots.has(shadowRoot)) {
27508 return;
27509 }
27510
27511 var self = this;
27512
27513 try {
27514 this.observedShadowRoots.add(shadowRoot);
27515
27516 var observer = new window.MutationObserver(function() {
27517 self.changeCallback();
27518 });
27519
27520 observer.observe(shadowRoot, this.observerConfig);
27521 this.shadowObservers.push(observer);
27522 } catch (e) {
27523 logger$1.critical('Error while observing shadow root', e);
27524 }
27525 };
27526
27527
27528 ShadowDOMObserver.prototype.start = function() {
27529 if (this.observedShadowRoots) {
27530 return;
27531 }
27532
27533 if (!weakSetSupported()) {
27534 logger$1.critical('Shadow DOM observation unavailable: WeakSet not supported');
27535 return;
27536 }
27537
27538 this.observedShadowRoots = new WeakSet();
27539 };
27540
27541 ShadowDOMObserver.prototype.stop = function() {
27542 if (!this.observedShadowRoots) {
27543 return;
27544 }
27545
27546 for (var i = 0; i < this.shadowObservers.length; i++) {
27547 try {
27548 this.shadowObservers[i].disconnect();
27549 } catch (e) {
27550 logger$1.critical('Error while disconnecting shadow DOM observer', e);
27551 }
27552 }
27553 this.shadowObservers = [];
27554 this.observedShadowRoots = null;
27555 };
27556
27557 /** @const */ var DEFAULT_DEAD_CLICK_TIMEOUT_MS = 500;
27558 /** @const */ var INTERACTION_EVENTS = [EV_CHANGE, EV_INPUT, EV_SUBMIT, EV_SELECT, EV_TOGGLE];
27559 /** @const */ var LAYOUT_EVENTS = [EV_SCROLLEND];
27560 /** @const */ var NAVIGATION_EVENTS = [EV_HASHCHANGE];
27561 /** @const */ var MUTATION_OBSERVER_CONFIG = {
27562 characterData: true,
27563 childList: true,
27564 subtree: true,
27565 attributes: true,
27566 attributeFilter: ['style', 'class', 'hidden', 'checked', 'selected', 'value', 'display', 'visibility']
27567 };
27568
27569
27570 function DeadClickTracker(onDeadClickCallback) {
27571 this.eventListeners = [];
27572 this.mutationObserver = null;
27573 this.shadowDOMObserver = null;
27574
27575 this.isTracking = false;
27576 this.lastChangeEventTimestamp = 0;
27577 this.pendingClicks = [];
27578 this.onDeadClickCallback = onDeadClickCallback;
27579 this.processingActive = false;
27580 this.processingTimeout = null;
27581 }
27582
27583
27584 DeadClickTracker.prototype.addClick = function(event) {
27585 var element = this.shadowDOMObserver && this.shadowDOMObserver.getEventTarget(event);
27586
27587 if (!element) {
27588 element = event['target'] || event['srcElement'];
27589 }
27590
27591 if (!element || isDefinitelyNonInteractive(element)) {
27592 return false;
27593 }
27594
27595 if (this.shadowDOMObserver) {
27596 this.shadowDOMObserver.observeFromEvent(event);
27597 }
27598 this.pendingClicks.push({
27599 element: element,
27600 event: event,
27601 timestamp: Date.now()
27602 });
27603 return true;
27604 };
27605
27606 DeadClickTracker.prototype.trackClick = function(event, config) {
27607 if (!this.isTracking) {
27608 return false;
27609 }
27610
27611 var added = this.addClick(event);
27612 if (added) {
27613 this.triggerProcessing(config);
27614 }
27615 return added;
27616 };
27617
27618 DeadClickTracker.prototype.getDeadClicks = function(config) {
27619 if (this.pendingClicks.length === 0) {
27620 return [];
27621 }
27622
27623 var timeoutMs = config['timeout_ms'];
27624 var now = Date.now();
27625 var clicksToEvaluate = this.pendingClicks.slice(); // Copy array
27626 this.pendingClicks = []; // Clear original
27627
27628 var deadClicks = [];
27629
27630 for (var i = 0; i < clicksToEvaluate.length; i++) {
27631 var click = clicksToEvaluate[i];
27632
27633 if (now - click.timestamp >= timeoutMs) {
27634 // Click has exceeded timeout, check if it's dead by looking for changes after this specific click
27635 if (!this.hasChangesAfter(click.timestamp)) {
27636 deadClicks.push(click);
27637 }
27638 } else {
27639 // Still pending - add back
27640 this.pendingClicks.push(click);
27641 }
27642 }
27643
27644 return deadClicks;
27645 };
27646
27647 DeadClickTracker.prototype.hasChangesAfter = function(timestamp) {
27648 // 100ms tolerance for race condition between when we record the click and the change event
27649 return this.lastChangeEventTimestamp >= (timestamp - 100);
27650 };
27651
27652 DeadClickTracker.prototype.recordChangeEvent = function() {
27653 this.lastChangeEventTimestamp = Date.now();
27654 };
27655
27656 DeadClickTracker.prototype.triggerProcessing = function(config) {
27657 // Prevent multiple concurrent processing chains
27658 if (this.processingActive) {
27659 return;
27660 }
27661 this.processingActive = true;
27662 this.processRecursively(config);
27663 };
27664
27665 DeadClickTracker.prototype.processRecursively = function(config) {
27666 if (!this.isTracking || !this.onDeadClickCallback) {
27667 this.processingActive = false;
27668 return;
27669 }
27670
27671 var timeoutMs = config['timeout_ms'];
27672 var self = this;
27673
27674 this.processingTimeout = setTimeout(function() {
27675 if (!self.processingActive) {
27676 return;
27677 }
27678
27679 var deadClicks = self.getDeadClicks(config);
27680
27681 for (var i = 0; i < deadClicks.length; i++) {
27682 self.onDeadClickCallback(deadClicks[i].event);
27683 }
27684
27685 if (self.pendingClicks.length > 0) {
27686 self.processRecursively(config);
27687 } else {
27688 self.processingActive = false;
27689 }
27690 }, timeoutMs);
27691 };
27692
27693 DeadClickTracker.prototype.startTracking = function() {
27694 if (this.isTracking) {
27695 return;
27696 }
27697
27698 this.isTracking = true;
27699
27700 var self = this;
27701
27702 INTERACTION_EVENTS.forEach(function(event) {
27703 var handler = function() {
27704 self.recordChangeEvent();
27705 };
27706 document.addEventListener(event, handler, { capture: true, passive: true });
27707 self.eventListeners.push({ target: document, event: event, handler: handler, options: { capture: true, passive: true } });
27708 });
27709 NAVIGATION_EVENTS.forEach(function(event) {
27710 var handler = function() {
27711 self.recordChangeEvent();
27712 };
27713 window.addEventListener(event, handler);
27714 self.eventListeners.push({ target: window, event: event, handler: handler });
27715 });
27716 LAYOUT_EVENTS.forEach(function(event) {
27717 var handler = function() {
27718 self.recordChangeEvent();
27719 };
27720 window.addEventListener(event, handler, { passive: true });
27721 self.eventListeners.push({ target: window, event: event, handler: handler, options: { passive: true } });
27722 });
27723 var selectionHandler = function() {
27724 self.recordChangeEvent();
27725 };
27726 document.addEventListener('selectionchange', selectionHandler);
27727 self.eventListeners.push({ target: document, event: 'selectionchange', handler: selectionHandler });
27728
27729 // Set up MutationObserver
27730 if (window.MutationObserver) {
27731 try {
27732 this.mutationObserver = new window.MutationObserver(function() {
27733 self.recordChangeEvent();
27734 });
27735
27736 this.mutationObserver.observe(document.body || document.documentElement, MUTATION_OBSERVER_CONFIG);
27737 } catch (e) {
27738 logger$1.critical('Error while setting up mutation observer', e);
27739 }
27740 }
27741
27742 // Set up Shadow DOM observer
27743 if (window.customElements) {
27744 try {
27745 this.shadowDOMObserver = new ShadowDOMObserver(
27746 function() {
27747 self.recordChangeEvent();
27748 },
27749 MUTATION_OBSERVER_CONFIG
27750 );
27751 this.shadowDOMObserver.start();
27752 } catch (e) {
27753 logger$1.critical('Error while setting up shadow DOM observer', e);
27754 this.shadowDOMObserver = null;
27755 }
27756 }
27757 };
27758
27759 DeadClickTracker.prototype.stopTracking = function() {
27760 if (!this.isTracking) {
27761 return;
27762 }
27763
27764 this.isTracking = false;
27765 this.pendingClicks = [];
27766 this.lastChangeEventTimestamp = 0;
27767 this.processingActive = false;
27768
27769 if (this.processingTimeout) {
27770 clearTimeout(this.processingTimeout);
27771 this.processingTimeout = null;
27772 }
27773
27774 // Remove all event listeners
27775 for (var i = 0; i < this.eventListeners.length; i++) {
27776 var listener = this.eventListeners[i];
27777 try {
27778 listener.target.removeEventListener(listener.event, listener.handler, listener.options);
27779 } catch (e) {
27780 logger$1.critical('Error while removing event listener', e);
27781 }
27782 }
27783 this.eventListeners = [];
27784
27785 if (this.mutationObserver) {
27786 try {
27787 this.mutationObserver.disconnect();
27788 } catch (e) {
27789 logger$1.critical('Error while disconnecting mutation observer', e);
27790 }
27791 this.mutationObserver = null;
27792 }
27793
27794 if (this.shadowDOMObserver) {
27795 try {
27796 this.shadowDOMObserver.stop();
27797 } catch (e) {
27798 logger$1.critical('Error while stopping shadow DOM observer', e);
27799 }
27800 this.shadowDOMObserver = null;
27801 }
27802 };
27803
27804 var AUTOCAPTURE_CONFIG_KEY = 'autocapture';
27805 var LEGACY_PAGEVIEW_CONFIG_KEY = 'track_pageview';
27806
27807 var PAGEVIEW_OPTION_FULL_URL = 'full-url';
27808 var PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING = 'url-with-path-and-query-string';
27809 var PAGEVIEW_OPTION_URL_WITH_PATH = 'url-with-path';
27810
27811 var CONFIG_ALLOW_ELEMENT_CALLBACK = 'allow_element_callback';
27812 var CONFIG_ALLOW_SELECTORS = 'allow_selectors';
27813 var CONFIG_ALLOW_URL_REGEXES = 'allow_url_regexes';
27814 var CONFIG_BLOCK_ATTRS = 'block_attrs';
27815 var CONFIG_BLOCK_ELEMENT_CALLBACK = 'block_element_callback';
27816 var CONFIG_BLOCK_SELECTORS = 'block_selectors';
27817 var CONFIG_BLOCK_URL_REGEXES = 'block_url_regexes';
27818 var CONFIG_CAPTURE_EXTRA_ATTRS = 'capture_extra_attrs';
27819 var CONFIG_CAPTURE_TEXT_CONTENT = 'capture_text_content';
27820 var CONFIG_SCROLL_CAPTURE_ALL = 'scroll_capture_all';
27821 var CONFIG_SCROLL_CHECKPOINTS = 'scroll_depth_percent_checkpoints';
27822 var CONFIG_TRACK_CLICK = 'click';
27823 var CONFIG_TRACK_DEAD_CLICK = 'dead_click';
27824 var CONFIG_TRACK_INPUT = 'input';
27825 var CONFIG_TRACK_PAGEVIEW = 'pageview';
27826 var CONFIG_TRACK_RAGE_CLICK = 'rage_click';
27827 var CONFIG_TRACK_SCROLL = 'scroll';
27828 var CONFIG_TRACK_PAGE_LEAVE = 'page_leave';
27829 var CONFIG_TRACK_SUBMIT = 'submit';
27830
27831 var CONFIG_DEFAULTS$1 = {};
27832 CONFIG_DEFAULTS$1[CONFIG_ALLOW_SELECTORS] = [];
27833 CONFIG_DEFAULTS$1[CONFIG_ALLOW_URL_REGEXES] = [];
27834 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ATTRS] = [];
27835 CONFIG_DEFAULTS$1[CONFIG_BLOCK_ELEMENT_CALLBACK] = null;
27836 CONFIG_DEFAULTS$1[CONFIG_BLOCK_SELECTORS] = [];
27837 CONFIG_DEFAULTS$1[CONFIG_BLOCK_URL_REGEXES] = [];
27838 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_EXTRA_ATTRS] = [];
27839 CONFIG_DEFAULTS$1[CONFIG_CAPTURE_TEXT_CONTENT] = false;
27840 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CAPTURE_ALL] = false;
27841 CONFIG_DEFAULTS$1[CONFIG_SCROLL_CHECKPOINTS] = [25, 50, 75, 100];
27842 CONFIG_DEFAULTS$1[CONFIG_TRACK_CLICK] = true;
27843 CONFIG_DEFAULTS$1[CONFIG_TRACK_DEAD_CLICK] = true;
27844 CONFIG_DEFAULTS$1[CONFIG_TRACK_INPUT] = true;
27845 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGEVIEW] = PAGEVIEW_OPTION_FULL_URL;
27846 CONFIG_DEFAULTS$1[CONFIG_TRACK_RAGE_CLICK] = true;
27847 CONFIG_DEFAULTS$1[CONFIG_TRACK_SCROLL] = true;
27848 CONFIG_DEFAULTS$1[CONFIG_TRACK_PAGE_LEAVE] = false;
27849 CONFIG_DEFAULTS$1[CONFIG_TRACK_SUBMIT] = true;
27850
27851 var DEFAULT_PROPS = {
27852 '$mp_autocapture': true
27853 };
27854
27855 var MP_EV_CLICK = '$mp_click';
27856 var MP_EV_DEAD_CLICK = '$mp_dead_click';
27857 var MP_EV_INPUT = '$mp_input_change';
27858 var MP_EV_RAGE_CLICK = '$mp_rage_click';
27859 var MP_EV_SCROLL = '$mp_scroll';
27860 var MP_EV_SUBMIT = '$mp_submit';
27861 var MP_EV_PAGE_LEAVE = '$mp_page_leave';
27862
27863 /**
27864 * Autocapture: manages automatic event tracking
27865 * @constructor
27866 */
27867 var Autocapture = function(mp) {
27868 this.mp = mp;
27869 this.maxScrollViewDepth = 0;
27870 this.hasTrackedScrollSession = false;
27871 this.previousScrollHeight = 0;
27872 };
27873
27874 Autocapture.prototype.init = function() {
27875 if (!minDOMApisSupported()) {
27876 logger$1.critical('Autocapture unavailable: missing required DOM APIs');
27877 return;
27878 }
27879 this.initPageListeners();
27880 this.initPageviewTracking();
27881 this.initClickTracking();
27882 this.initDeadClickTracking();
27883 this.initInputTracking();
27884 this.initScrollTracking();
27885 this.initSubmitTracking();
27886 this.initRageClickTracking();
27887 this.initPageLeaveTracking();
27888 };
27889
27890 Autocapture.prototype.getFullConfig = function() {
27891 var autocaptureConfig = this.mp.get_config(AUTOCAPTURE_CONFIG_KEY);
27892 if (!autocaptureConfig) {
27893 // Autocapture is completely off
27894 return {};
27895 } else if (_.isObject(autocaptureConfig)) {
27896 return _.extend({}, CONFIG_DEFAULTS$1, autocaptureConfig);
27897 } else {
27898 // Autocapture config is non-object truthy value, return default
27899 return CONFIG_DEFAULTS$1;
27900 }
27901 };
27902
27903 Autocapture.prototype.getConfig = function(key) {
27904 return this.getFullConfig()[key];
27905 };
27906
27907 Autocapture.prototype.currentUrlBlocked = function() {
27908 var i;
27909 var currentUrl = _.info.currentUrl();
27910
27911 var allowUrlRegexes = this.getConfig(CONFIG_ALLOW_URL_REGEXES) || [];
27912 if (allowUrlRegexes.length) {
27913 // we're using an allowlist, only track if current URL matches
27914 var allowed = false;
27915 for (i = 0; i < allowUrlRegexes.length; i++) {
27916 var allowRegex = allowUrlRegexes[i];
27917 try {
27918 if (currentUrl.match(allowRegex)) {
27919 allowed = true;
27920 break;
27921 }
27922 } catch (err) {
27923 logger$1.critical('Error while checking block URL regex: ' + allowRegex, err);
27924 return true;
27925 }
27926 }
27927 if (!allowed) {
27928 // wasn't allowed by any regex
27929 return true;
27930 }
27931 }
27932
27933 var blockUrlRegexes = this.getConfig(CONFIG_BLOCK_URL_REGEXES) || [];
27934 if (!blockUrlRegexes || !blockUrlRegexes.length) {
27935 return false;
27936 }
27937
27938 for (i = 0; i < blockUrlRegexes.length; i++) {
27939 try {
27940 if (currentUrl.match(blockUrlRegexes[i])) {
27941 return true;
27942 }
27943 } catch (err) {
27944 logger$1.critical('Error while checking block URL regex: ' + blockUrlRegexes[i], err);
27945 return true;
27946 }
27947 }
27948 return false;
27949 };
27950
27951 Autocapture.prototype.pageviewTrackingConfig = function() {
27952 // supports both autocapture config and old track_pageview config
27953 if (this.mp.get_config(AUTOCAPTURE_CONFIG_KEY)) {
27954 return this.getConfig(CONFIG_TRACK_PAGEVIEW);
27955 } else {
27956 return this.mp.get_config(LEGACY_PAGEVIEW_CONFIG_KEY);
27957 }
27958 };
27959
27960 // helper for event handlers
27961 Autocapture.prototype.trackDomEvent = function(ev, mpEventName) {
27962 if (this.currentUrlBlocked()) {
27963 return;
27964 }
27965
27966 var isCapturedForHeatMap = this.mp.is_recording_heatmap_data() && (
27967 (mpEventName === MP_EV_CLICK && !this.getConfig(CONFIG_TRACK_CLICK)) ||
27968 (mpEventName === MP_EV_RAGE_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK)) ||
27969 (mpEventName === MP_EV_DEAD_CLICK && !this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK))
27970 );
27971
27972 var props = getPropsForDOMEvent(ev, {
27973 allowElementCallback: this.getConfig(CONFIG_ALLOW_ELEMENT_CALLBACK),
27974 allowSelectors: this.getConfig(CONFIG_ALLOW_SELECTORS),
27975 blockAttrs: this.getConfig(CONFIG_BLOCK_ATTRS),
27976 blockElementCallback: this.getConfig(CONFIG_BLOCK_ELEMENT_CALLBACK),
27977 blockSelectors: this.getConfig(CONFIG_BLOCK_SELECTORS),
27978 captureExtraAttrs: this.getConfig(CONFIG_CAPTURE_EXTRA_ATTRS),
27979 captureTextContent: this.getConfig(CONFIG_CAPTURE_TEXT_CONTENT),
27980 capturedForHeatMap: isCapturedForHeatMap,
27981 });
27982 if (props) {
27983 _.extend(props, DEFAULT_PROPS);
27984 this.mp.track(mpEventName, props);
27985 }
27986 };
27987
27988 Autocapture.prototype.initPageListeners = function() {
27989 win.removeEventListener(EV_POPSTATE, this.listenerPopstate);
27990 win.removeEventListener(EV_HASHCHANGE, this.listenerHashchange);
27991
27992 if (!this.pageviewTrackingConfig() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
27993 // These are all the configs that use these listeners
27994 return;
27995 }
27996
27997 this.listenerPopstate = function() {
27998 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
27999 };
28000 this.listenerHashchange = function() {
28001 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28002 };
28003
28004 win.addEventListener(EV_POPSTATE, this.listenerPopstate);
28005 win.addEventListener(EV_HASHCHANGE, this.listenerHashchange);
28006 var nativePushState = win.history.pushState;
28007 if (typeof nativePushState === 'function') {
28008 win.history.pushState = function(state, unused, url) {
28009 nativePushState.call(win.history, state, unused, url);
28010 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28011 };
28012 }
28013 var nativeReplaceState = win.history.replaceState;
28014 if (typeof nativeReplaceState === 'function') {
28015 win.history.replaceState = function(state, unused, url) {
28016 nativeReplaceState.call(win.history, state, unused, url);
28017 win.dispatchEvent(new Event(EV_MP_LOCATION_CHANGE));
28018 };
28019 }
28020 };
28021
28022 Autocapture.prototype._getClickTrackingConfig = function(configKey) {
28023 var config = this.getConfig(configKey);
28024
28025 if (!config) {
28026 return null; // click tracking disabled
28027 }
28028
28029 if (config === true) {
28030 return {}; // use defaults
28031 }
28032
28033 if (typeof config === 'object') {
28034 return config; // use custom configuration
28035 }
28036
28037 return {}; // fallback to defaults for any other truthy value
28038 };
28039
28040 Autocapture.prototype._trackPageLeave = function(ev, currentUrl, currentScrollHeight) {
28041 if (this.hasTrackedScrollSession) {
28042 // User has navigated away already ending their impression.
28043 return;
28044 }
28045
28046 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
28047 return;
28048 }
28049
28050 this.hasTrackedScrollSession = true;
28051 var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28052 var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
28053 var foldLinePercentage = Math.round((viewportHeight / currentScrollHeight) * 100);
28054 if (currentScrollHeight <= viewportHeight) {
28055 // If the content fits within the viewport, consider it fully scrolled
28056 scrollPercentage = 100;
28057 foldLinePercentage = 100;
28058 }
28059
28060 var props = _.extend({
28061 '$max_scroll_view_depth': this.maxScrollViewDepth,
28062 '$max_scroll_percentage': scrollPercentage,
28063 '$fold_line_percentage': foldLinePercentage,
28064 '$scroll_height': currentScrollHeight,
28065 '$event_type': ev.type,
28066 '$current_url': currentUrl || _.info.currentUrl(),
28067 '$viewportHeight': viewportHeight, // This is the fold line
28068 '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
28069 '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
28070 }, DEFAULT_PROPS);
28071
28072 // Send with beacon transport to ensure event is sent before unload
28073 this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
28074 };
28075
28076 Autocapture.prototype._initScrollDepthTracking = function() {
28077 win.removeEventListener(EV_SCROLL, this.listenerScrollDepth);
28078 win.removeEventListener(EV_SCROLLEND, this.listenerScrollDepth);
28079
28080 if (!this.mp.get_config('record_heatmap_data')) {
28081 return;
28082 }
28083
28084 logger$1.log('Initializing scroll depth tracking');
28085
28086 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28087
28088 var updateScrollDepth = function() {
28089 if (this.currentUrlBlocked()) {
28090 return;
28091 }
28092 var scrollViewHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0) + win.scrollY;
28093 if (scrollViewHeight > this.maxScrollViewDepth) {
28094 this.maxScrollViewDepth = scrollViewHeight;
28095 }
28096 this.previousScrollHeight = document$1.body.scrollHeight;
28097 }.bind(this);
28098
28099 var scrollEndPolyfill = getPolyfillScrollEndFunction(updateScrollDepth);
28100 this.listenerScrollDepth = scrollEndPolyfill.listener;
28101 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScrollDepth);
28102 };
28103
28104 Autocapture.prototype.initClickTracking = function() {
28105 win.removeEventListener(EV_CLICK, this.listenerClick);
28106
28107 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.get_config('record_heatmap_data')) {
28108 return;
28109 }
28110 logger$1.log('Initializing click tracking');
28111
28112 this.listenerClick = function(ev) {
28113 if (!this.getConfig(CONFIG_TRACK_CLICK) && !this.mp.is_recording_heatmap_data()) {
28114 return;
28115 }
28116 this.trackDomEvent(ev, MP_EV_CLICK);
28117 }.bind(this);
28118 win.addEventListener(EV_CLICK, this.listenerClick);
28119 };
28120
28121 Autocapture.prototype.initDeadClickTracking = function() {
28122 var deadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28123
28124 if (!deadClickConfig && !this.mp.get_config('record_heatmap_data')) {
28125 this.stopDeadClickTracking();
28126 return;
28127 }
28128
28129 logger$1.log('Initializing dead click tracking');
28130 if (!this._deadClickTracker) {
28131 this._deadClickTracker = new DeadClickTracker(function(deadClickEvent) {
28132 this.trackDomEvent(deadClickEvent, MP_EV_DEAD_CLICK);
28133 }.bind(this));
28134 this._deadClickTracker.startTracking();
28135 }
28136
28137 if (!this.listenerDeadClick) {
28138 this.listenerDeadClick = function(ev) {
28139 var currentDeadClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_DEAD_CLICK);
28140 if (!currentDeadClickConfig && !this.mp.is_recording_heatmap_data()) {
28141 return;
28142 }
28143 if (this.currentUrlBlocked()) {
28144 return;
28145 }
28146 // Normalize config to ensure timeout_ms is always set
28147 var normalizedConfig = currentDeadClickConfig || {};
28148 if (!normalizedConfig['timeout_ms']) {
28149 normalizedConfig['timeout_ms'] = DEFAULT_DEAD_CLICK_TIMEOUT_MS;
28150 }
28151 this._deadClickTracker.trackClick(ev, normalizedConfig);
28152 }.bind(this);
28153 win.addEventListener(EV_CLICK, this.listenerDeadClick);
28154 }
28155 };
28156
28157 Autocapture.prototype.initInputTracking = function() {
28158 win.removeEventListener(EV_CHANGE, this.listenerChange);
28159
28160 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28161 return;
28162 }
28163 logger$1.log('Initializing input tracking');
28164
28165 this.listenerChange = function(ev) {
28166 if (!this.getConfig(CONFIG_TRACK_INPUT)) {
28167 return;
28168 }
28169 this.trackDomEvent(ev, MP_EV_INPUT);
28170 }.bind(this);
28171 win.addEventListener(EV_CHANGE, this.listenerChange);
28172 };
28173
28174 Autocapture.prototype.initPageviewTracking = function() {
28175 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28176
28177 if (!this.pageviewTrackingConfig()) {
28178 return;
28179 }
28180 logger$1.log('Initializing pageview tracking');
28181
28182 var previousTrackedUrl = '';
28183 var tracked = false;
28184 if (!this.currentUrlBlocked()) {
28185 tracked = this.mp.track_pageview(DEFAULT_PROPS);
28186 }
28187 if (tracked) {
28188 previousTrackedUrl = _.info.currentUrl();
28189 }
28190
28191 this.listenerLocationchange = safewrap(function() {
28192 if (this.currentUrlBlocked()) {
28193 return;
28194 }
28195
28196 var currentUrl = _.info.currentUrl();
28197 var shouldTrack = false;
28198 var didPathChange = currentUrl.split('#')[0].split('?')[0] !== previousTrackedUrl.split('#')[0].split('?')[0];
28199 var trackPageviewOption = this.pageviewTrackingConfig();
28200 if (trackPageviewOption === PAGEVIEW_OPTION_FULL_URL) {
28201 shouldTrack = currentUrl !== previousTrackedUrl;
28202 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH_AND_QUERY_STRING) {
28203 shouldTrack = currentUrl.split('#')[0] !== previousTrackedUrl.split('#')[0];
28204 } else if (trackPageviewOption === PAGEVIEW_OPTION_URL_WITH_PATH) {
28205 shouldTrack = didPathChange;
28206 }
28207
28208 if (shouldTrack) {
28209 var tracked = this.mp.track_pageview(DEFAULT_PROPS);
28210 if (tracked) {
28211 previousTrackedUrl = currentUrl;
28212 }
28213 if (didPathChange) {
28214 this.lastScrollCheckpoint = 0;
28215 logger$1.log('Path change: re-initializing scroll depth checkpoints');
28216 }
28217 }
28218 }.bind(this));
28219 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerLocationchange);
28220 };
28221
28222 Autocapture.prototype.initRageClickTracking = function() {
28223 win.removeEventListener(EV_CLICK, this.listenerRageClick);
28224
28225 var rageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28226 if (!rageClickConfig && !this.mp.get_config('record_heatmap_data')) {
28227 return;
28228 }
28229
28230 logger$1.log('Initializing rage click tracking');
28231 if (!this._rageClickTracker) {
28232 this._rageClickTracker = new RageClickTracker();
28233 }
28234
28235 this.listenerRageClick = function(ev) {
28236 var currentRageClickConfig = this._getClickTrackingConfig(CONFIG_TRACK_RAGE_CLICK);
28237 if (!currentRageClickConfig && !this.mp.is_recording_heatmap_data()) {
28238 return;
28239 }
28240
28241 if (this.currentUrlBlocked()) {
28242 return;
28243 }
28244
28245 if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
28246 this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
28247 }
28248 }.bind(this);
28249 win.addEventListener(EV_CLICK, this.listenerRageClick);
28250 };
28251
28252 Autocapture.prototype.initScrollTracking = function() {
28253 win.removeEventListener(EV_SCROLLEND, this.listenerScroll);
28254 win.removeEventListener(EV_SCROLL, this.listenerScroll);
28255
28256
28257 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28258 return;
28259 }
28260 logger$1.log('Initializing scroll tracking');
28261 this.lastScrollCheckpoint = 0;
28262
28263 var scrollTrackFunction = function() {
28264 if (!this.getConfig(CONFIG_TRACK_SCROLL)) {
28265 return;
28266 }
28267 if (this.currentUrlBlocked()) {
28268 return;
28269 }
28270
28271 var shouldTrack = this.getConfig(CONFIG_SCROLL_CAPTURE_ALL);
28272 var scrollCheckpoints = (this.getConfig(CONFIG_SCROLL_CHECKPOINTS) || [])
28273 .slice()
28274 .sort(function(a, b) { return a - b; });
28275
28276 var scrollTop = win.scrollY;
28277 var props = _.extend({'$scroll_top': scrollTop}, DEFAULT_PROPS);
28278 try {
28279 var scrollHeight = document$1.body.scrollHeight;
28280 var scrollPercentage = Math.round((scrollTop / (scrollHeight - win.innerHeight)) * 100);
28281 props['$scroll_height'] = scrollHeight;
28282 props['$scroll_percentage'] = scrollPercentage;
28283 if (scrollPercentage > this.lastScrollCheckpoint) {
28284 for (var i = 0; i < scrollCheckpoints.length; i++) {
28285 var checkpoint = scrollCheckpoints[i];
28286 if (
28287 scrollPercentage >= checkpoint &&
28288 this.lastScrollCheckpoint < checkpoint
28289 ) {
28290 props['$scroll_checkpoint'] = checkpoint;
28291 this.lastScrollCheckpoint = checkpoint;
28292 shouldTrack = true;
28293 }
28294 }
28295 }
28296 } catch (err) {
28297 logger$1.critical('Error while calculating scroll percentage', err);
28298 }
28299 if (shouldTrack) {
28300 this.mp.track(MP_EV_SCROLL, props);
28301 }
28302 }.bind(this);
28303
28304 var scrollEndPolyfill = getPolyfillScrollEndFunction(scrollTrackFunction);
28305 this.listenerScroll = scrollEndPolyfill.listener;
28306 win.addEventListener(scrollEndPolyfill.eventType, this.listenerScroll);
28307 };
28308
28309 Autocapture.prototype.initSubmitTracking = function() {
28310 win.removeEventListener(EV_SUBMIT, this.listenerSubmit);
28311
28312 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28313 return;
28314 }
28315 logger$1.log('Initializing submit tracking');
28316
28317 this.listenerSubmit = function(ev) {
28318 if (!this.getConfig(CONFIG_TRACK_SUBMIT)) {
28319 return;
28320 }
28321 this.trackDomEvent(ev, MP_EV_SUBMIT);
28322 }.bind(this);
28323 win.addEventListener(EV_SUBMIT, this.listenerSubmit);
28324 };
28325
28326 Autocapture.prototype.initPageLeaveTracking = function() {
28327 // Capture page_leave both when the user navigates away from the page (visibilitychange) as well
28328 // as when they navigate to a different page within the SPA (popstate/pushstate/hashchange).
28329 document$1.removeEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28330 win.removeEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28331 win.removeEventListener(EV_LOAD, this.listenerPageLoad);
28332
28333 if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.get_config('record_heatmap_data')) {
28334 return;
28335 }
28336
28337 logger$1.log('Initializing page visibility tracking.');
28338 this._initScrollDepthTracking();
28339 var previousTrackedUrl = _.info.currentUrl();
28340
28341 // Initialize previousScrollHeight on `load` which handles async loading
28342 // https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
28343 this.listenerPageLoad = function() {
28344 this.previousScrollHeight = document$1.body.scrollHeight;
28345 }.bind(this);
28346 win.addEventListener(EV_LOAD, this.listenerPageLoad);
28347
28348 // Track page navigation events similar to how initPageviewTracking does it
28349 this.listenerPageLeaveLocationchange = safewrap(function(ev) {
28350 if (this.currentUrlBlocked()) {
28351 return;
28352 }
28353
28354 var currentUrl = _.info.currentUrl();
28355 // Track all URL changes including query string or fragment changes as separate scroll sessions
28356 var shouldTrack = currentUrl !== previousTrackedUrl;
28357
28358 if (shouldTrack) {
28359 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28360 previousTrackedUrl = currentUrl;
28361 // Fragment navigation should call scroll(end) and trigger listener, don't add window.scrollY here.
28362 this.maxScrollViewDepth = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
28363 this.previousScrollHeight = document$1.body.scrollHeight;
28364 this.hasTrackedScrollSession = false;
28365 }
28366 }.bind(this));
28367 win.addEventListener(EV_MP_LOCATION_CHANGE, this.listenerPageLeaveLocationchange);
28368
28369 this.listenerPageLeaveVisibilitychange = function(ev) {
28370 if (document$1.hidden) {
28371 this._trackPageLeave(ev, previousTrackedUrl, this.previousScrollHeight);
28372 }
28373 }.bind(this);
28374 document$1.addEventListener(EV_VISIBILITYCHANGE, this.listenerPageLeaveVisibilitychange);
28375 };
28376
28377 Autocapture.prototype.stopDeadClickTracking = function() {
28378 if (this.listenerDeadClick) {
28379 win.removeEventListener(EV_CLICK, this.listenerDeadClick);
28380 this.listenerDeadClick = null;
28381 }
28382
28383 if (this._deadClickTracker) {
28384 this._deadClickTracker.stopTracking();
28385 this._deadClickTracker = null;
28386 }
28387 };
28388
28389 // TODO integrate error_reporter from mixpanel instance
28390 safewrapClass(Autocapture);
28391
28392 var logger = console_with_prefix('flags');
28393
28394 var FLAGS_CONFIG_KEY = 'flags';
28395
28396 var CONFIG_CONTEXT = 'context';
28397 var CONFIG_DEFAULTS = {};
28398 CONFIG_DEFAULTS[CONFIG_CONTEXT] = {};
28399
28400 /**
28401 * FeatureFlagManager: support for Mixpanel's feature flagging product
28402 * @constructor
28403 */
28404 var FeatureFlagManager = function(initOptions) {
28405 this.fetch = win['fetch'];
28406 this.getFullApiRoute = initOptions.getFullApiRoute;
28407 this.getMpConfig = initOptions.getConfigFunc;
28408 this.setMpConfig = initOptions.setConfigFunc;
28409 this.getMpProperty = initOptions.getPropertyFunc;
28410 this.track = initOptions.trackingFunc;
28411 };
28412
28413 FeatureFlagManager.prototype.init = function() {
28414 if (!this.minApisSupported()) {
28415 logger.critical('Feature Flags unavailable: missing minimum required APIs');
28416 return;
28417 }
28418
28419 this.flags = null;
28420 this.fetchFlags();
28421
28422 this.trackedFeatures = new Set();
28423 };
28424
28425 FeatureFlagManager.prototype.getFullConfig = function() {
28426 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28427 if (!ffConfig) {
28428 // flags are completely off
28429 return {};
28430 } else if (_.isObject(ffConfig)) {
28431 return _.extend({}, CONFIG_DEFAULTS, ffConfig);
28432 } else {
28433 // config is non-object truthy value, return default
28434 return CONFIG_DEFAULTS;
28435 }
28436 };
28437
28438 FeatureFlagManager.prototype.getConfig = function(key) {
28439 return this.getFullConfig()[key];
28440 };
28441
28442 FeatureFlagManager.prototype.isSystemEnabled = function() {
28443 return !!this.getMpConfig(FLAGS_CONFIG_KEY);
28444 };
28445
28446 FeatureFlagManager.prototype.updateContext = function(newContext, options) {
28447 if (!this.isSystemEnabled()) {
28448 logger.critical('Feature Flags not enabled, cannot update context');
28449 return Promise.resolve();
28450 }
28451
28452 var ffConfig = this.getMpConfig(FLAGS_CONFIG_KEY);
28453 if (!_.isObject(ffConfig)) {
28454 ffConfig = {};
28455 }
28456 var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
28457 ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
28458
28459 this.setMpConfig(FLAGS_CONFIG_KEY, ffConfig);
28460 return this.fetchFlags();
28461 };
28462
28463 FeatureFlagManager.prototype.areFlagsReady = function() {
28464 if (!this.isSystemEnabled()) {
28465 logger.error('Feature Flags not enabled');
28466 }
28467 return !!this.flags;
28468 };
28469
28470 FeatureFlagManager.prototype.fetchFlags = function() {
28471 if (!this.isSystemEnabled()) {
28472 return Promise.resolve();
28473 }
28474
28475 var distinctId = this.getMpProperty('distinct_id');
28476 var deviceId = this.getMpProperty('$device_id');
28477 var traceparent = generateTraceparent();
28478 logger.log('Fetching flags for distinct ID: ' + distinctId);
28479
28480 var context = _.extend({'distinct_id': distinctId, 'device_id': deviceId}, this.getConfig(CONFIG_CONTEXT));
28481 var searchParams = new URLSearchParams();
28482 searchParams.set('context', JSON.stringify(context));
28483 searchParams.set('token', this.getMpConfig('token'));
28484 searchParams.set('mp_lib', 'web');
28485 searchParams.set('$lib_version', Config.LIB_VERSION);
28486 var url = this.getFullApiRoute() + '?' + searchParams.toString();
28487
28488 this._fetchInProgressStartTime = Date.now();
28489 this.fetchPromise = this.fetch.call(win, url, {
28490 'method': 'GET',
28491 'headers': {
28492 'Authorization': 'Basic ' + btoa(this.getMpConfig('token') + ':'),
28493 'traceparent': traceparent
28494 }
28495 }).then(function(response) {
28496 this.markFetchComplete();
28497 return response.json().then(function(responseBody) {
28498 var responseFlags = responseBody['flags'];
28499 if (!responseFlags) {
28500 throw new Error('No flags in API response');
28501 }
28502 var flags = new Map();
28503 _.each(responseFlags, function(data, key) {
28504 flags.set(key, {
28505 'key': data['variant_key'],
28506 'value': data['variant_value'],
28507 'experiment_id': data['experiment_id'],
28508 'is_experiment_active': data['is_experiment_active'],
28509 'is_qa_tester': data['is_qa_tester']
28510 });
28511 });
28512 this.flags = flags;
28513 this._traceparent = traceparent;
28514 }.bind(this)).catch(function(error) {
28515 this.markFetchComplete();
28516 logger.error(error);
28517 }.bind(this));
28518 }.bind(this)).catch(function(error) {
28519 this.markFetchComplete();
28520 logger.error(error);
28521 }.bind(this));
28522
28523 return this.fetchPromise;
28524 };
28525
28526 FeatureFlagManager.prototype.markFetchComplete = function() {
28527 if (!this._fetchInProgressStartTime) {
28528 logger.error('Fetch in progress started time not set, cannot mark fetch complete');
28529 return;
28530 }
28531 this._fetchStartTime = this._fetchInProgressStartTime;
28532 this._fetchCompleteTime = Date.now();
28533 this._fetchLatency = this._fetchCompleteTime - this._fetchStartTime;
28534 this._fetchInProgressStartTime = null;
28535 };
28536
28537 FeatureFlagManager.prototype.getVariant = function(featureName, fallback) {
28538 if (!this.fetchPromise) {
28539 return new Promise(function(resolve) {
28540 logger.critical('Feature Flags not initialized');
28541 resolve(fallback);
28542 });
28543 }
28544
28545 return this.fetchPromise.then(function() {
28546 return this.getVariantSync(featureName, fallback);
28547 }.bind(this)).catch(function(error) {
28548 logger.error(error);
28549 return fallback;
28550 });
28551 };
28552
28553 FeatureFlagManager.prototype.getVariantSync = function(featureName, fallback) {
28554 if (!this.areFlagsReady()) {
28555 logger.log('Flags not loaded yet');
28556 return fallback;
28557 }
28558 var feature = this.flags.get(featureName);
28559 if (!feature) {
28560 logger.log('No flag found: "' + featureName + '"');
28561 return fallback;
28562 }
28563 this.trackFeatureCheck(featureName, feature);
28564 return feature;
28565 };
28566
28567 FeatureFlagManager.prototype.getVariantValue = function(featureName, fallbackValue) {
28568 return this.getVariant(featureName, {'value': fallbackValue}).then(function(feature) {
28569 return feature['value'];
28570 }).catch(function(error) {
28571 logger.error(error);
28572 return fallbackValue;
28573 });
28574 };
28575
28576 // TODO remove deprecated method
28577 FeatureFlagManager.prototype.getFeatureData = function(featureName, fallbackValue) {
28578 logger.critical('mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead.');
28579 return this.getVariantValue(featureName, fallbackValue);
28580 };
28581
28582 FeatureFlagManager.prototype.getVariantValueSync = function(featureName, fallbackValue) {
28583 return this.getVariantSync(featureName, {'value': fallbackValue})['value'];
28584 };
28585
28586 FeatureFlagManager.prototype.isEnabled = function(featureName, fallbackValue) {
28587 return this.getVariantValue(featureName).then(function() {
28588 return this.isEnabledSync(featureName, fallbackValue);
28589 }.bind(this)).catch(function(error) {
28590 logger.error(error);
28591 return fallbackValue;
28592 });
28593 };
28594
28595 FeatureFlagManager.prototype.isEnabledSync = function(featureName, fallbackValue) {
28596 fallbackValue = fallbackValue || false;
28597 var val = this.getVariantValueSync(featureName, fallbackValue);
28598 if (val !== true && val !== false) {
28599 logger.error('Feature flag "' + featureName + '" value: ' + val + ' is not a boolean; returning fallback value: ' + fallbackValue);
28600 val = fallbackValue;
28601 }
28602 return val;
28603 };
28604
28605 FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature) {
28606 if (this.trackedFeatures.has(featureName)) {
28607 return;
28608 }
28609 this.trackedFeatures.add(featureName);
28610
28611 var trackingProperties = {
28612 'Experiment name': featureName,
28613 'Variant name': feature['key'],
28614 '$experiment_type': 'feature_flag',
28615 'Variant fetch start time': new Date(this._fetchStartTime).toISOString(),
28616 'Variant fetch complete time': new Date(this._fetchCompleteTime).toISOString(),
28617 'Variant fetch latency (ms)': this._fetchLatency,
28618 'Variant fetch traceparent': this._traceparent,
28619 };
28620
28621 if (feature['experiment_id'] !== 'undefined') {
28622 trackingProperties['$experiment_id'] = feature['experiment_id'];
28623 }
28624 if (feature['is_experiment_active'] !== 'undefined') {
28625 trackingProperties['$is_experiment_active'] = feature['is_experiment_active'];
28626 }
28627 if (feature['is_qa_tester'] !== 'undefined') {
28628 trackingProperties['$is_qa_tester'] = feature['is_qa_tester'];
28629 }
28630
28631 this.track('$experiment_started', trackingProperties);
28632 };
28633
28634 FeatureFlagManager.prototype.minApisSupported = function() {
28635 return !!this.fetch &&
28636 typeof Promise !== 'undefined' &&
28637 typeof Map !== 'undefined' &&
28638 typeof Set !== 'undefined';
28639 };
28640
28641 safewrapClass(FeatureFlagManager);
28642
28643 FeatureFlagManager.prototype['are_flags_ready'] = FeatureFlagManager.prototype.areFlagsReady;
28644 FeatureFlagManager.prototype['get_variant'] = FeatureFlagManager.prototype.getVariant;
28645 FeatureFlagManager.prototype['get_variant_sync'] = FeatureFlagManager.prototype.getVariantSync;
28646 FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype.getVariantValue;
28647 FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
28648 FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
28649 FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
28650 FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
28651
28652 // Deprecated method
28653 FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
28654
28655 /* eslint camelcase: "off" */
28656
28657
28658 /**
28659 * DomTracker Object
28660 * @constructor
28661 */
28662 var DomTracker = function() {};
28663
28664
28665 // interface
28666 DomTracker.prototype.create_properties = function() {};
28667 DomTracker.prototype.event_handler = function() {};
28668 DomTracker.prototype.after_track_handler = function() {};
28669
28670 DomTracker.prototype.init = function(mixpanel_instance) {
28671 this.mp = mixpanel_instance;
28672 return this;
28673 };
28674
28675 /**
28676 * @param {Object|string} query
28677 * @param {string} event_name
28678 * @param {Object=} properties
28679 * @param {function=} user_callback
28680 */
28681 DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
28682 var that = this;
28683 var elements = _.dom_query(query);
28684
28685 if (elements.length === 0) {
28686 console$1.error('The DOM query (' + query + ') returned 0 elements');
28687 return;
28688 }
28689
28690 _.each(elements, function(element) {
28691 _.register_event(element, this.override_event, function(e) {
28692 var options = {};
28693 var props = that.create_properties(properties, this);
28694 var timeout = that.mp.get_config('track_links_timeout');
28695
28696 that.event_handler(e, this, options);
28697
28698 // in case the mixpanel servers don't get back to us in time
28699 window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
28700
28701 // fire the tracking event
28702 that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
28703 });
28704 }, this);
28705
28706 return true;
28707 };
28708
28709 /**
28710 * @param {function} user_callback
28711 * @param {Object} props
28712 * @param {boolean=} timeout_occured
28713 */
28714 DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
28715 timeout_occured = timeout_occured || false;
28716 var that = this;
28717
28718 return function() {
28719 // options is referenced from both callbacks, so we can have
28720 // a 'lock' of sorts to ensure only one fires
28721 if (options.callback_fired) { return; }
28722 options.callback_fired = true;
28723
28724 if (user_callback && user_callback(timeout_occured, props) === false) {
28725 // user can prevent the default functionality by
28726 // returning false from their callback
28727 return;
28728 }
28729
28730 that.after_track_handler(props, options, timeout_occured);
28731 };
28732 };
28733
28734 DomTracker.prototype.create_properties = function(properties, element) {
28735 var props;
28736
28737 if (typeof(properties) === 'function') {
28738 props = properties(element);
28739 } else {
28740 props = _.extend({}, properties);
28741 }
28742
28743 return props;
28744 };
28745
28746 /**
28747 * LinkTracker Object
28748 * @constructor
28749 * @extends DomTracker
28750 */
28751 var LinkTracker = function() {
28752 this.override_event = 'click';
28753 };
28754 _.inherit(LinkTracker, DomTracker);
28755
28756 LinkTracker.prototype.create_properties = function(properties, element) {
28757 var props = LinkTracker.superclass.create_properties.apply(this, arguments);
28758
28759 if (element.href) { props['url'] = element.href; }
28760
28761 return props;
28762 };
28763
28764 LinkTracker.prototype.event_handler = function(evt, element, options) {
28765 options.new_tab = (
28766 evt.which === 2 ||
28767 evt.metaKey ||
28768 evt.ctrlKey ||
28769 element.target === '_blank'
28770 );
28771 options.href = element.href;
28772
28773 if (!options.new_tab) {
28774 evt.preventDefault();
28775 }
28776 };
28777
28778 LinkTracker.prototype.after_track_handler = function(props, options) {
28779 if (options.new_tab) { return; }
28780
28781 setTimeout(function() {
28782 window.location = options.href;
28783 }, 0);
28784 };
28785
28786 /**
28787 * FormTracker Object
28788 * @constructor
28789 * @extends DomTracker
28790 */
28791 var FormTracker = function() {
28792 this.override_event = 'submit';
28793 };
28794 _.inherit(FormTracker, DomTracker);
28795
28796 FormTracker.prototype.event_handler = function(evt, element, options) {
28797 options.element = element;
28798 evt.preventDefault();
28799 };
28800
28801 FormTracker.prototype.after_track_handler = function(props, options) {
28802 setTimeout(function() {
28803 options.element.submit();
28804 }, 0);
28805 };
28806
28807 /* eslint camelcase: "off" */
28808
28809
28810 /** @const */ var SET_ACTION = '$set';
28811 /** @const */ var SET_ONCE_ACTION = '$set_once';
28812 /** @const */ var UNSET_ACTION = '$unset';
28813 /** @const */ var ADD_ACTION = '$add';
28814 /** @const */ var APPEND_ACTION = '$append';
28815 /** @const */ var UNION_ACTION = '$union';
28816 /** @const */ var REMOVE_ACTION = '$remove';
28817 /** @const */ var DELETE_ACTION = '$delete';
28818
28819 // Common internal methods for mixpanel.people and mixpanel.group APIs.
28820 // These methods shouldn't involve network I/O.
28821 var apiActions = {
28822 set_action: function(prop, to) {
28823 var data = {};
28824 var $set = {};
28825 if (_.isObject(prop)) {
28826 _.each(prop, function(v, k) {
28827 if (!this._is_reserved_property(k)) {
28828 $set[k] = v;
28829 }
28830 }, this);
28831 } else {
28832 $set[prop] = to;
28833 }
28834
28835 data[SET_ACTION] = $set;
28836 return data;
28837 },
28838
28839 unset_action: function(prop) {
28840 var data = {};
28841 var $unset = [];
28842 if (!_.isArray(prop)) {
28843 prop = [prop];
28844 }
28845
28846 _.each(prop, function(k) {
28847 if (!this._is_reserved_property(k)) {
28848 $unset.push(k);
28849 }
28850 }, this);
28851
28852 data[UNSET_ACTION] = $unset;
28853 return data;
28854 },
28855
28856 set_once_action: function(prop, to) {
28857 var data = {};
28858 var $set_once = {};
28859 if (_.isObject(prop)) {
28860 _.each(prop, function(v, k) {
28861 if (!this._is_reserved_property(k)) {
28862 $set_once[k] = v;
28863 }
28864 }, this);
28865 } else {
28866 $set_once[prop] = to;
28867 }
28868 data[SET_ONCE_ACTION] = $set_once;
28869 return data;
28870 },
28871
28872 union_action: function(list_name, values) {
28873 var data = {};
28874 var $union = {};
28875 if (_.isObject(list_name)) {
28876 _.each(list_name, function(v, k) {
28877 if (!this._is_reserved_property(k)) {
28878 $union[k] = _.isArray(v) ? v : [v];
28879 }
28880 }, this);
28881 } else {
28882 $union[list_name] = _.isArray(values) ? values : [values];
28883 }
28884 data[UNION_ACTION] = $union;
28885 return data;
28886 },
28887
28888 append_action: function(list_name, value) {
28889 var data = {};
28890 var $append = {};
28891 if (_.isObject(list_name)) {
28892 _.each(list_name, function(v, k) {
28893 if (!this._is_reserved_property(k)) {
28894 $append[k] = v;
28895 }
28896 }, this);
28897 } else {
28898 $append[list_name] = value;
28899 }
28900 data[APPEND_ACTION] = $append;
28901 return data;
28902 },
28903
28904 remove_action: function(list_name, value) {
28905 var data = {};
28906 var $remove = {};
28907 if (_.isObject(list_name)) {
28908 _.each(list_name, function(v, k) {
28909 if (!this._is_reserved_property(k)) {
28910 $remove[k] = v;
28911 }
28912 }, this);
28913 } else {
28914 $remove[list_name] = value;
28915 }
28916 data[REMOVE_ACTION] = $remove;
28917 return data;
28918 },
28919
28920 delete_action: function() {
28921 var data = {};
28922 data[DELETE_ACTION] = '';
28923 return data;
28924 }
28925 };
28926
28927 /* eslint camelcase: "off" */
28928
28929 /**
28930 * Mixpanel Group Object
28931 * @constructor
28932 */
28933 var MixpanelGroup = function() {};
28934
28935 _.extend(MixpanelGroup.prototype, apiActions);
28936
28937 MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
28938 this._mixpanel = mixpanel_instance;
28939 this._group_key = group_key;
28940 this._group_id = group_id;
28941 };
28942
28943 /**
28944 * Set properties on a group.
28945 *
28946 * ### Usage:
28947 *
28948 * mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
28949 *
28950 * // or set multiple properties at once
28951 * mixpanel.get_group('company', 'mixpanel').set({
28952 * 'Location': '405 Howard',
28953 * 'Founded' : 2009,
28954 * });
28955 * // properties can be strings, integers, dates, or lists
28956 *
28957 * @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.
28958 * @param {*} [to] A value to set on the given property name
28959 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28960 */
28961 MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28962 var data = this.set_action(prop, to);
28963 if (_.isObject(prop)) {
28964 callback = to;
28965 }
28966 return this._send_request(data, callback);
28967 });
28968
28969 /**
28970 * Set properties on a group, only if they do not yet exist.
28971 * This will not overwrite previous group property values, unlike
28972 * group.set().
28973 *
28974 * ### Usage:
28975 *
28976 * mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
28977 *
28978 * // or set multiple properties at once
28979 * mixpanel.get_group('company', 'mixpanel').set_once({
28980 * 'Location': '405 Howard',
28981 * 'Founded' : 2009,
28982 * });
28983 * // properties can be strings, integers, lists or dates
28984 *
28985 * @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.
28986 * @param {*} [to] A value to set on the given property name
28987 * @param {Function} [callback] If provided, the callback will be called after the tracking event
28988 */
28989 MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
28990 var data = this.set_once_action(prop, to);
28991 if (_.isObject(prop)) {
28992 callback = to;
28993 }
28994 return this._send_request(data, callback);
28995 });
28996
28997 /**
28998 * Unset properties on a group permanently.
28999 *
29000 * ### Usage:
29001 *
29002 * mixpanel.get_group('company', 'mixpanel').unset('Founded');
29003 *
29004 * @param {String} prop The name of the property.
29005 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29006 */
29007 MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
29008 var data = this.unset_action(prop);
29009 return this._send_request(data, callback);
29010 });
29011
29012 /**
29013 * Merge a given list with a list-valued group property, excluding duplicate values.
29014 *
29015 * ### Usage:
29016 *
29017 * // merge a value to a list, creating it if needed
29018 * mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
29019 *
29020 * @param {String} list_name Name of the property.
29021 * @param {Array} values Values to merge with the given property
29022 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29023 */
29024 MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values, callback) {
29025 if (_.isObject(list_name)) {
29026 callback = values;
29027 }
29028 var data = this.union_action(list_name, values);
29029 return this._send_request(data, callback);
29030 });
29031
29032 /**
29033 * Permanently delete a group.
29034 *
29035 * ### Usage:
29036 *
29037 * mixpanel.get_group('company', 'mixpanel').delete();
29038 *
29039 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29040 */
29041 MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {
29042 // bracket notation above prevents a minification error related to reserved words
29043 var data = this.delete_action();
29044 return this._send_request(data, callback);
29045 });
29046
29047 /**
29048 * Remove a property from a group. The value will be ignored if doesn't exist.
29049 *
29050 * ### Usage:
29051 *
29052 * mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
29053 *
29054 * @param {String} list_name Name of the property.
29055 * @param {Object} value Value to remove from the given group property
29056 * @param {Function} [callback] If provided, the callback will be called after the tracking event
29057 */
29058 MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
29059 var data = this.remove_action(list_name, value);
29060 return this._send_request(data, callback);
29061 });
29062
29063 MixpanelGroup.prototype._send_request = function(data, callback) {
29064 data['$group_key'] = this._group_key;
29065 data['$group_id'] = this._group_id;
29066 data['$token'] = this._get_config('token');
29067
29068 var date_encoded_data = _.encodeDates(data);
29069 return this._mixpanel._track_or_batch({
29070 type: 'groups',
29071 data: date_encoded_data,
29072 endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
29073 batcher: this._mixpanel.request_batchers.groups
29074 }, callback);
29075 };
29076
29077 MixpanelGroup.prototype._is_reserved_property = function(prop) {
29078 return prop === '$group_key' || prop === '$group_id';
29079 };
29080
29081 MixpanelGroup.prototype._get_config = function(conf) {
29082 return this._mixpanel.get_config(conf);
29083 };
29084
29085 MixpanelGroup.prototype.toString = function() {
29086 return this._mixpanel.toString() + '.group.' + this._group_key + '.' + this._group_id;
29087 };
29088
29089 // MixpanelGroup Exports
29090 MixpanelGroup.prototype['remove'] = MixpanelGroup.prototype.remove;
29091 MixpanelGroup.prototype['set'] = MixpanelGroup.prototype.set;
29092 MixpanelGroup.prototype['set_once'] = MixpanelGroup.prototype.set_once;
29093 MixpanelGroup.prototype['union'] = MixpanelGroup.prototype.union;
29094 MixpanelGroup.prototype['unset'] = MixpanelGroup.prototype.unset;
29095 MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
29096
29097 /* eslint camelcase: "off" */
29098
29099 /**
29100 * Mixpanel People Object
29101 * @constructor
29102 */
29103 var MixpanelPeople = function() {};
29104
29105 _.extend(MixpanelPeople.prototype, apiActions);
29106
29107 MixpanelPeople.prototype._init = function(mixpanel_instance) {
29108 this._mixpanel = mixpanel_instance;
29109 };
29110
29111 /*
29112 * Set properties on a user record.
29113 *
29114 * ### Usage:
29115 *
29116 * mixpanel.people.set('gender', 'm');
29117 *
29118 * // or set multiple properties at once
29119 * mixpanel.people.set({
29120 * 'Company': 'Acme',
29121 * 'Plan': 'Premium',
29122 * 'Upgrade date': new Date()
29123 * });
29124 * // properties can be strings, integers, dates, or lists
29125 *
29126 * @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.
29127 * @param {*} [to] A value to set on the given property name
29128 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29129 */
29130 MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29131 var data = this.set_action(prop, to);
29132 if (_.isObject(prop)) {
29133 callback = to;
29134 }
29135 // make sure that the referrer info has been updated and saved
29136 if (this._get_config('save_referrer')) {
29137 this._mixpanel['persistence'].update_referrer_info(document.referrer);
29138 }
29139
29140 // update $set object with default people properties
29141 data[SET_ACTION] = _.extend(
29142 {},
29143 _.info.people_properties(),
29144 data[SET_ACTION]
29145 );
29146 return this._send_request(data, callback);
29147 });
29148
29149 /*
29150 * Set properties on a user record, only if they do not yet exist.
29151 * This will not overwrite previous people property values, unlike
29152 * people.set().
29153 *
29154 * ### Usage:
29155 *
29156 * mixpanel.people.set_once('First Login Date', new Date());
29157 *
29158 * // or set multiple properties at once
29159 * mixpanel.people.set_once({
29160 * 'First Login Date': new Date(),
29161 * 'Starting Plan': 'Premium'
29162 * });
29163 *
29164 * // properties can be strings, integers or dates
29165 *
29166 * @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.
29167 * @param {*} [to] A value to set on the given property name
29168 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29169 */
29170 MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
29171 var data = this.set_once_action(prop, to);
29172 if (_.isObject(prop)) {
29173 callback = to;
29174 }
29175 return this._send_request(data, callback);
29176 });
29177
29178 /*
29179 * Unset properties on a user record (permanently removes the properties and their values from a profile).
29180 *
29181 * ### Usage:
29182 *
29183 * mixpanel.people.unset('gender');
29184 *
29185 * // or unset multiple properties at once
29186 * mixpanel.people.unset(['gender', 'Company']);
29187 *
29188 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
29189 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29190 */
29191 MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
29192 var data = this.unset_action(prop);
29193 return this._send_request(data, callback);
29194 });
29195
29196 /*
29197 * Increment/decrement numeric people analytics properties.
29198 *
29199 * ### Usage:
29200 *
29201 * mixpanel.people.increment('page_views', 1);
29202 *
29203 * // or, for convenience, if you're just incrementing a counter by
29204 * // 1, you can simply do
29205 * mixpanel.people.increment('page_views');
29206 *
29207 * // to decrement a counter, pass a negative number
29208 * mixpanel.people.increment('credits_left', -1);
29209 *
29210 * // like mixpanel.people.set(), you can increment multiple
29211 * // properties at once:
29212 * mixpanel.people.increment({
29213 * counter1: 1,
29214 * counter2: 6
29215 * });
29216 *
29217 * @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.
29218 * @param {Number} [by] An amount to increment the given property
29219 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29220 */
29221 MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
29222 var data = {};
29223 var $add = {};
29224 if (_.isObject(prop)) {
29225 _.each(prop, function(v, k) {
29226 if (!this._is_reserved_property(k)) {
29227 if (isNaN(parseFloat(v))) {
29228 console$1.error('Invalid increment value passed to mixpanel.people.increment - must be a number');
29229 return;
29230 } else {
29231 $add[k] = v;
29232 }
29233 }
29234 }, this);
29235 callback = by;
29236 } else {
29237 // convenience: mixpanel.people.increment('property'); will
29238 // increment 'property' by 1
29239 if (_.isUndefined(by)) {
29240 by = 1;
29241 }
29242 $add[prop] = by;
29243 }
29244 data[ADD_ACTION] = $add;
29245
29246 return this._send_request(data, callback);
29247 });
29248
29249 /*
29250 * Append a value to a list-valued people analytics property.
29251 *
29252 * ### Usage:
29253 *
29254 * // append a value to a list, creating it if needed
29255 * mixpanel.people.append('pages_visited', 'homepage');
29256 *
29257 * // like mixpanel.people.set(), you can append multiple
29258 * // properties at once:
29259 * mixpanel.people.append({
29260 * list1: 'bob',
29261 * list2: 123
29262 * });
29263 *
29264 * @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.
29265 * @param {*} [value] value An item to append to the list
29266 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29267 */
29268 MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29269 if (_.isObject(list_name)) {
29270 callback = value;
29271 }
29272 var data = this.append_action(list_name, value);
29273 return this._send_request(data, callback);
29274 });
29275
29276 /*
29277 * Remove a value from a list-valued people analytics property.
29278 *
29279 * ### Usage:
29280 *
29281 * mixpanel.people.remove('School', 'UCB');
29282 *
29283 * @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.
29284 * @param {*} [value] value Item to remove from the list
29285 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29286 */
29287 MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
29288 if (_.isObject(list_name)) {
29289 callback = value;
29290 }
29291 var data = this.remove_action(list_name, value);
29292 return this._send_request(data, callback);
29293 });
29294
29295 /*
29296 * Merge a given list with a list-valued people analytics property,
29297 * excluding duplicate values.
29298 *
29299 * ### Usage:
29300 *
29301 * // merge a value to a list, creating it if needed
29302 * mixpanel.people.union('pages_visited', 'homepage');
29303 *
29304 * // like mixpanel.people.set(), you can append multiple
29305 * // properties at once:
29306 * mixpanel.people.union({
29307 * list1: 'bob',
29308 * list2: 123
29309 * });
29310 *
29311 * // like mixpanel.people.append(), you can append multiple
29312 * // values to the same list:
29313 * mixpanel.people.union({
29314 * list1: ['bob', 'billy']
29315 * });
29316 *
29317 * @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.
29318 * @param {*} [value] Value / values to merge with the given property
29319 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29320 */
29321 MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values, callback) {
29322 if (_.isObject(list_name)) {
29323 callback = values;
29324 }
29325 var data = this.union_action(list_name, values);
29326 return this._send_request(data, callback);
29327 });
29328
29329 /*
29330 * Record that you have charged the current user a certain amount
29331 * of money. Charges recorded with track_charge() will appear in the
29332 * Mixpanel revenue report.
29333 *
29334 * ### Usage:
29335 *
29336 * // charge a user $50
29337 * mixpanel.people.track_charge(50);
29338 *
29339 * // charge a user $30.50 on the 2nd of january
29340 * mixpanel.people.track_charge(30.50, {
29341 * '$time': new Date('jan 1 2012')
29342 * });
29343 *
29344 * @param {Number} amount The amount of money charged to the current user
29345 * @param {Object} [properties] An associative array of properties associated with the charge
29346 * @param {Function} [callback] If provided, the callback will be called when the server responds
29347 * @deprecated
29348 */
29349 MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
29350 console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
29351 });
29352
29353 /*
29354 * Permanently clear all revenue report transactions from the
29355 * current user's people analytics profile.
29356 *
29357 * ### Usage:
29358 *
29359 * mixpanel.people.clear_charges();
29360 *
29361 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
29362 * @deprecated
29363 */
29364 MixpanelPeople.prototype.clear_charges = function(callback) {
29365 return this.set('$transactions', [], callback);
29366 };
29367
29368 /*
29369 * Permanently deletes the current people analytics profile from
29370 * Mixpanel (using the current distinct_id).
29371 *
29372 * ### Usage:
29373 *
29374 * // remove the all data you have stored about the current user
29375 * mixpanel.people.delete_user();
29376 *
29377 */
29378 MixpanelPeople.prototype.delete_user = function() {
29379 if (!this._identify_called()) {
29380 console$1.error('mixpanel.people.delete_user() requires you to call identify() first');
29381 return;
29382 }
29383 var data = {'$delete': this._mixpanel.get_distinct_id()};
29384 return this._send_request(data);
29385 };
29386
29387 MixpanelPeople.prototype.toString = function() {
29388 return this._mixpanel.toString() + '.people';
29389 };
29390
29391 MixpanelPeople.prototype._send_request = function(data, callback) {
29392 data['$token'] = this._get_config('token');
29393 data['$distinct_id'] = this._mixpanel.get_distinct_id();
29394 var device_id = this._mixpanel.get_property('$device_id');
29395 var user_id = this._mixpanel.get_property('$user_id');
29396 var had_persisted_distinct_id = this._mixpanel.get_property('$had_persisted_distinct_id');
29397 if (device_id) {
29398 data['$device_id'] = device_id;
29399 }
29400 if (user_id) {
29401 data['$user_id'] = user_id;
29402 }
29403 if (had_persisted_distinct_id) {
29404 data['$had_persisted_distinct_id'] = had_persisted_distinct_id;
29405 }
29406
29407 var date_encoded_data = _.encodeDates(data);
29408
29409 if (!this._identify_called()) {
29410 this._enqueue(data);
29411 if (!_.isUndefined(callback)) {
29412 if (this._get_config('verbose')) {
29413 callback({status: -1, error: null});
29414 } else {
29415 callback(-1);
29416 }
29417 }
29418 return _.truncate(date_encoded_data, 255);
29419 }
29420
29421 return this._mixpanel._track_or_batch({
29422 type: 'people',
29423 data: date_encoded_data,
29424 endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
29425 batcher: this._mixpanel.request_batchers.people
29426 }, callback);
29427 };
29428
29429 MixpanelPeople.prototype._get_config = function(conf_var) {
29430 return this._mixpanel.get_config(conf_var);
29431 };
29432
29433 MixpanelPeople.prototype._identify_called = function() {
29434 return this._mixpanel._flags.identify_called === true;
29435 };
29436
29437 // Queue up engage operations if identify hasn't been called yet.
29438 MixpanelPeople.prototype._enqueue = function(data) {
29439 if (SET_ACTION in data) {
29440 this._mixpanel['persistence']._add_to_people_queue(SET_ACTION, data);
29441 } else if (SET_ONCE_ACTION in data) {
29442 this._mixpanel['persistence']._add_to_people_queue(SET_ONCE_ACTION, data);
29443 } else if (UNSET_ACTION in data) {
29444 this._mixpanel['persistence']._add_to_people_queue(UNSET_ACTION, data);
29445 } else if (ADD_ACTION in data) {
29446 this._mixpanel['persistence']._add_to_people_queue(ADD_ACTION, data);
29447 } else if (APPEND_ACTION in data) {
29448 this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, data);
29449 } else if (REMOVE_ACTION in data) {
29450 this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, data);
29451 } else if (UNION_ACTION in data) {
29452 this._mixpanel['persistence']._add_to_people_queue(UNION_ACTION, data);
29453 } else {
29454 console$1.error('Invalid call to _enqueue():', data);
29455 }
29456 };
29457
29458 MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
29459 var _this = this;
29460 var queued_data = _.extend({}, this._mixpanel['persistence'].load_queue(action));
29461 var action_params = queued_data;
29462
29463 if (!_.isUndefined(queued_data) && _.isObject(queued_data) && !_.isEmptyObject(queued_data)) {
29464 _this._mixpanel['persistence']._pop_from_people_queue(action, queued_data);
29465 _this._mixpanel['persistence'].save();
29466 if (queue_to_params_fn) {
29467 action_params = queue_to_params_fn(queued_data);
29468 }
29469 action_method.call(_this, action_params, function(response, data) {
29470 // on bad response, we want to add it back to the queue
29471 if (response === 0) {
29472 _this._mixpanel['persistence']._add_to_people_queue(action, queued_data);
29473 }
29474 if (!_.isUndefined(callback)) {
29475 callback(response, data);
29476 }
29477 });
29478 }
29479 };
29480
29481 // Flush queued engage operations - order does not matter,
29482 // and there are network level race conditions anyway
29483 MixpanelPeople.prototype._flush = function(
29484 _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
29485 ) {
29486 var _this = this;
29487
29488 this._flush_one_queue(SET_ACTION, this.set, _set_callback);
29489 this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
29490 this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) { return _.keys(queue); });
29491 this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
29492 this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
29493
29494 // we have to fire off each $append individually since there is
29495 // no concat method server side
29496 var $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29497 if (!_.isUndefined($append_queue) && _.isArray($append_queue) && $append_queue.length) {
29498 var $append_item;
29499 var append_callback = function(response, data) {
29500 if (response === 0) {
29501 _this._mixpanel['persistence']._add_to_people_queue(APPEND_ACTION, $append_item);
29502 }
29503 if (!_.isUndefined(_append_callback)) {
29504 _append_callback(response, data);
29505 }
29506 };
29507 for (var i = $append_queue.length - 1; i >= 0; i--) {
29508 $append_queue = this._mixpanel['persistence'].load_queue(APPEND_ACTION);
29509 $append_item = $append_queue.pop();
29510 _this._mixpanel['persistence'].save();
29511 if (!_.isEmptyObject($append_item)) {
29512 _this.append($append_item, append_callback);
29513 }
29514 }
29515 }
29516
29517 // same for $remove
29518 var $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29519 if (!_.isUndefined($remove_queue) && _.isArray($remove_queue) && $remove_queue.length) {
29520 var $remove_item;
29521 var remove_callback = function(response, data) {
29522 if (response === 0) {
29523 _this._mixpanel['persistence']._add_to_people_queue(REMOVE_ACTION, $remove_item);
29524 }
29525 if (!_.isUndefined(_remove_callback)) {
29526 _remove_callback(response, data);
29527 }
29528 };
29529 for (var j = $remove_queue.length - 1; j >= 0; j--) {
29530 $remove_queue = this._mixpanel['persistence'].load_queue(REMOVE_ACTION);
29531 $remove_item = $remove_queue.pop();
29532 _this._mixpanel['persistence'].save();
29533 if (!_.isEmptyObject($remove_item)) {
29534 _this.remove($remove_item, remove_callback);
29535 }
29536 }
29537 }
29538 };
29539
29540 MixpanelPeople.prototype._is_reserved_property = function(prop) {
29541 return prop === '$distinct_id' || prop === '$token' || prop === '$device_id' || prop === '$user_id' || prop === '$had_persisted_distinct_id';
29542 };
29543
29544 // MixpanelPeople Exports
29545 MixpanelPeople.prototype['set'] = MixpanelPeople.prototype.set;
29546 MixpanelPeople.prototype['set_once'] = MixpanelPeople.prototype.set_once;
29547 MixpanelPeople.prototype['unset'] = MixpanelPeople.prototype.unset;
29548 MixpanelPeople.prototype['increment'] = MixpanelPeople.prototype.increment;
29549 MixpanelPeople.prototype['append'] = MixpanelPeople.prototype.append;
29550 MixpanelPeople.prototype['remove'] = MixpanelPeople.prototype.remove;
29551 MixpanelPeople.prototype['union'] = MixpanelPeople.prototype.union;
29552 MixpanelPeople.prototype['track_charge'] = MixpanelPeople.prototype.track_charge;
29553 MixpanelPeople.prototype['clear_charges'] = MixpanelPeople.prototype.clear_charges;
29554 MixpanelPeople.prototype['delete_user'] = MixpanelPeople.prototype.delete_user;
29555 MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
29556
29557 /* eslint camelcase: "off" */
29558
29559
29560 /*
29561 * Constants
29562 */
29563 /** @const */ var SET_QUEUE_KEY = '__mps';
29564 /** @const */ var SET_ONCE_QUEUE_KEY = '__mpso';
29565 /** @const */ var UNSET_QUEUE_KEY = '__mpus';
29566 /** @const */ var ADD_QUEUE_KEY = '__mpa';
29567 /** @const */ var APPEND_QUEUE_KEY = '__mpap';
29568 /** @const */ var REMOVE_QUEUE_KEY = '__mpr';
29569 /** @const */ var UNION_QUEUE_KEY = '__mpu';
29570 // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
29571 /** @const */ var PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
29572 /** @const */ var ALIAS_ID_KEY = '__alias';
29573 /** @const */ var EVENT_TIMERS_KEY = '__timers';
29574 /** @const */ var RESERVED_PROPERTIES = [
29575 SET_QUEUE_KEY,
29576 SET_ONCE_QUEUE_KEY,
29577 UNSET_QUEUE_KEY,
29578 ADD_QUEUE_KEY,
29579 APPEND_QUEUE_KEY,
29580 REMOVE_QUEUE_KEY,
29581 UNION_QUEUE_KEY,
29582 PEOPLE_DISTINCT_ID_KEY,
29583 ALIAS_ID_KEY,
29584 EVENT_TIMERS_KEY
29585 ];
29586
29587 /**
29588 * Mixpanel Persistence Object
29589 * @constructor
29590 */
29591 var MixpanelPersistence = function(config) {
29592 this['props'] = {};
29593 this.campaign_params_saved = false;
29594
29595 if (config['persistence_name']) {
29596 this.name = 'mp_' + config['persistence_name'];
29597 } else {
29598 this.name = 'mp_' + config['token'] + '_mixpanel';
29599 }
29600
29601 var storage_type = config['persistence'];
29602 if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
29603 console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
29604 storage_type = config['persistence'] = 'cookie';
29605 }
29606
29607 if (storage_type === 'localStorage' && _.localStorage.is_supported()) {
29608 this.storage = _.localStorage;
29609 } else {
29610 this.storage = _.cookie;
29611 }
29612
29613 this.load();
29614 this.update_config(config);
29615 this.upgrade();
29616 this.save();
29617 };
29618
29619 MixpanelPersistence.prototype.properties = function() {
29620 var p = {};
29621
29622 this.load();
29623
29624 // Filter out reserved properties
29625 _.each(this['props'], function(v, k) {
29626 if (!_.include(RESERVED_PROPERTIES, k)) {
29627 p[k] = v;
29628 }
29629 });
29630 return p;
29631 };
29632
29633 MixpanelPersistence.prototype.load = function() {
29634 if (this.disabled) { return; }
29635
29636 var entry = this.storage.parse(this.name);
29637
29638 if (entry) {
29639 this['props'] = _.extend({}, entry);
29640 }
29641 };
29642
29643 MixpanelPersistence.prototype.upgrade = function() {
29644 var old_cookie,
29645 old_localstorage;
29646
29647 // if transferring from cookie to localStorage or vice-versa, copy existing
29648 // super properties over to new storage mode
29649 if (this.storage === _.localStorage) {
29650 old_cookie = _.cookie.parse(this.name);
29651
29652 _.cookie.remove(this.name);
29653 _.cookie.remove(this.name, true);
29654
29655 if (old_cookie) {
29656 this.register_once(old_cookie);
29657 }
29658 } else if (this.storage === _.cookie) {
29659 old_localstorage = _.localStorage.parse(this.name);
29660
29661 _.localStorage.remove(this.name);
29662
29663 if (old_localstorage) {
29664 this.register_once(old_localstorage);
29665 }
29666 }
29667 };
29668
29669 MixpanelPersistence.prototype.save = function() {
29670 if (this.disabled) { return; }
29671
29672 this.storage.set(
29673 this.name,
29674 JSONStringify(this['props']),
29675 this.expire_days,
29676 this.cross_subdomain,
29677 this.secure,
29678 this.cross_site,
29679 this.cookie_domain
29680 );
29681 };
29682
29683 MixpanelPersistence.prototype.load_prop = function(key) {
29684 this.load();
29685 return this['props'][key];
29686 };
29687
29688 MixpanelPersistence.prototype.remove = function() {
29689 // remove both domain and subdomain cookies
29690 this.storage.remove(this.name, false, this.cookie_domain);
29691 this.storage.remove(this.name, true, this.cookie_domain);
29692 };
29693
29694 // removes the storage entry and deletes all loaded data
29695 // forced name for tests
29696 MixpanelPersistence.prototype.clear = function() {
29697 this.remove();
29698 this['props'] = {};
29699 };
29700
29701 /**
29702 * @param {Object} props
29703 * @param {*=} default_value
29704 * @param {number=} days
29705 */
29706 MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
29707 if (_.isObject(props)) {
29708 if (typeof(default_value) === 'undefined') { default_value = 'None'; }
29709 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29710
29711 this.load();
29712
29713 _.each(props, function(val, prop) {
29714 if (!this['props'].hasOwnProperty(prop) || this['props'][prop] === default_value) {
29715 this['props'][prop] = val;
29716 }
29717 }, this);
29718
29719 this.save();
29720
29721 return true;
29722 }
29723 return false;
29724 };
29725
29726 /**
29727 * @param {Object} props
29728 * @param {number=} days
29729 */
29730 MixpanelPersistence.prototype.register = function(props, days) {
29731 if (_.isObject(props)) {
29732 this.expire_days = (typeof(days) === 'undefined') ? this.default_expiry : days;
29733
29734 this.load();
29735 _.extend(this['props'], props);
29736 this.save();
29737
29738 return true;
29739 }
29740 return false;
29741 };
29742
29743 MixpanelPersistence.prototype.unregister = function(prop) {
29744 this.load();
29745 if (prop in this['props']) {
29746 delete this['props'][prop];
29747 this.save();
29748 }
29749 };
29750
29751 MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
29752 this.register(_.info.searchInfo(referrer));
29753 };
29754
29755 // EXPORTED METHOD, we test this directly.
29756 MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
29757 // If referrer doesn't exist, we want to note the fact that it was type-in traffic.
29758 this.register_once({
29759 '$initial_referrer': referrer || '$direct',
29760 '$initial_referring_domain': _.info.referringDomain(referrer) || '$direct'
29761 }, '');
29762 };
29763
29764 MixpanelPersistence.prototype.get_referrer_info = function() {
29765 return _.strip_empty_properties({
29766 '$initial_referrer': this['props']['$initial_referrer'],
29767 '$initial_referring_domain': this['props']['$initial_referring_domain']
29768 });
29769 };
29770
29771 MixpanelPersistence.prototype.update_config = function(config) {
29772 this.default_expiry = this.expire_days = config['cookie_expiration'];
29773 this.set_disabled(config['disable_persistence']);
29774 this.set_cookie_domain(config['cookie_domain']);
29775 this.set_cross_site(config['cross_site_cookie']);
29776 this.set_cross_subdomain(config['cross_subdomain_cookie']);
29777 this.set_secure(config['secure_cookie']);
29778 };
29779
29780 MixpanelPersistence.prototype.set_disabled = function(disabled) {
29781 this.disabled = disabled;
29782 if (this.disabled) {
29783 this.remove();
29784 } else {
29785 this.save();
29786 }
29787 };
29788
29789 MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
29790 if (cookie_domain !== this.cookie_domain) {
29791 this.remove();
29792 this.cookie_domain = cookie_domain;
29793 this.save();
29794 }
29795 };
29796
29797 MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
29798 if (cross_site !== this.cross_site) {
29799 this.cross_site = cross_site;
29800 this.remove();
29801 this.save();
29802 }
29803 };
29804
29805 MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
29806 if (cross_subdomain !== this.cross_subdomain) {
29807 this.cross_subdomain = cross_subdomain;
29808 this.remove();
29809 this.save();
29810 }
29811 };
29812
29813 MixpanelPersistence.prototype.get_cross_subdomain = function() {
29814 return this.cross_subdomain;
29815 };
29816
29817 MixpanelPersistence.prototype.set_secure = function(secure) {
29818 if (secure !== this.secure) {
29819 this.secure = secure ? true : false;
29820 this.remove();
29821 this.save();
29822 }
29823 };
29824
29825 MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
29826 var q_key = this._get_queue_key(queue),
29827 q_data = data[queue],
29828 set_q = this._get_or_create_queue(SET_ACTION),
29829 set_once_q = this._get_or_create_queue(SET_ONCE_ACTION),
29830 unset_q = this._get_or_create_queue(UNSET_ACTION),
29831 add_q = this._get_or_create_queue(ADD_ACTION),
29832 union_q = this._get_or_create_queue(UNION_ACTION),
29833 remove_q = this._get_or_create_queue(REMOVE_ACTION, []),
29834 append_q = this._get_or_create_queue(APPEND_ACTION, []);
29835
29836 if (q_key === SET_QUEUE_KEY) {
29837 // Update the set queue - we can override any existing values
29838 _.extend(set_q, q_data);
29839 // if there was a pending increment, override it
29840 // with the set.
29841 this._pop_from_people_queue(ADD_ACTION, q_data);
29842 // if there was a pending union, override it
29843 // with the set.
29844 this._pop_from_people_queue(UNION_ACTION, q_data);
29845 this._pop_from_people_queue(UNSET_ACTION, q_data);
29846 } else if (q_key === SET_ONCE_QUEUE_KEY) {
29847 // only queue the data if there is not already a set_once call for it.
29848 _.each(q_data, function(v, k) {
29849 if (!(k in set_once_q)) {
29850 set_once_q[k] = v;
29851 }
29852 });
29853 this._pop_from_people_queue(UNSET_ACTION, q_data);
29854 } else if (q_key === UNSET_QUEUE_KEY) {
29855 _.each(q_data, function(prop) {
29856
29857 // undo previously-queued actions on this key
29858 _.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
29859 if (prop in enqueued_obj) {
29860 delete enqueued_obj[prop];
29861 }
29862 });
29863 _.each(append_q, function(append_obj) {
29864 if (prop in append_obj) {
29865 delete append_obj[prop];
29866 }
29867 });
29868
29869 unset_q[prop] = true;
29870
29871 });
29872 } else if (q_key === ADD_QUEUE_KEY) {
29873 _.each(q_data, function(v, k) {
29874 // If it exists in the set queue, increment
29875 // the value
29876 if (k in set_q) {
29877 set_q[k] += v;
29878 } else {
29879 // If it doesn't exist, update the add
29880 // queue
29881 if (!(k in add_q)) {
29882 add_q[k] = 0;
29883 }
29884 add_q[k] += v;
29885 }
29886 }, this);
29887 this._pop_from_people_queue(UNSET_ACTION, q_data);
29888 } else if (q_key === UNION_QUEUE_KEY) {
29889 _.each(q_data, function(v, k) {
29890 if (_.isArray(v)) {
29891 if (!(k in union_q)) {
29892 union_q[k] = [];
29893 }
29894 // Prevent duplicate values
29895 _.each(v, function(item) {
29896 if (!_.include(union_q[k], item)) {
29897 union_q[k].push(item);
29898 }
29899 });
29900 }
29901 });
29902 this._pop_from_people_queue(UNSET_ACTION, q_data);
29903 } else if (q_key === REMOVE_QUEUE_KEY) {
29904 remove_q.push(q_data);
29905 this._pop_from_people_queue(APPEND_ACTION, q_data);
29906 } else if (q_key === APPEND_QUEUE_KEY) {
29907 append_q.push(q_data);
29908 this._pop_from_people_queue(UNSET_ACTION, q_data);
29909 }
29910
29911 console$1.log('MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):');
29912 console$1.log(data);
29913
29914 this.save();
29915 };
29916
29917 MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
29918 var q = this['props'][this._get_queue_key(queue)];
29919 if (!_.isUndefined(q)) {
29920 _.each(data, function(v, k) {
29921 if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
29922 // list actions: only remove if both k+v match
29923 // e.g. remove should not override append in a case like
29924 // append({foo: 'bar'}); remove({foo: 'qux'})
29925 _.each(q, function(queued_action) {
29926 if (queued_action[k] === v) {
29927 delete queued_action[k];
29928 }
29929 });
29930 } else {
29931 delete q[k];
29932 }
29933 }, this);
29934 }
29935 };
29936
29937 MixpanelPersistence.prototype.load_queue = function(queue) {
29938 return this.load_prop(this._get_queue_key(queue));
29939 };
29940
29941 MixpanelPersistence.prototype._get_queue_key = function(queue) {
29942 if (queue === SET_ACTION) {
29943 return SET_QUEUE_KEY;
29944 } else if (queue === SET_ONCE_ACTION) {
29945 return SET_ONCE_QUEUE_KEY;
29946 } else if (queue === UNSET_ACTION) {
29947 return UNSET_QUEUE_KEY;
29948 } else if (queue === ADD_ACTION) {
29949 return ADD_QUEUE_KEY;
29950 } else if (queue === APPEND_ACTION) {
29951 return APPEND_QUEUE_KEY;
29952 } else if (queue === REMOVE_ACTION) {
29953 return REMOVE_QUEUE_KEY;
29954 } else if (queue === UNION_ACTION) {
29955 return UNION_QUEUE_KEY;
29956 } else {
29957 console$1.error('Invalid queue:', queue);
29958 }
29959 };
29960
29961 MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
29962 var key = this._get_queue_key(queue);
29963 default_val = _.isUndefined(default_val) ? {} : default_val;
29964 return this['props'][key] || (this['props'][key] = default_val);
29965 };
29966
29967 MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
29968 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29969 timers[event_name] = timestamp;
29970 this['props'][EVENT_TIMERS_KEY] = timers;
29971 this.save();
29972 };
29973
29974 MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
29975 var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
29976 var timestamp = timers[event_name];
29977 if (!_.isUndefined(timestamp)) {
29978 delete this['props'][EVENT_TIMERS_KEY][event_name];
29979 this.save();
29980 }
29981 return timestamp;
29982 };
29983
29984 /* eslint camelcase: "off" */
29985
29986 /*
29987 * Mixpanel JS Library
29988 *
29989 * Copyright 2012, Mixpanel, Inc. All Rights Reserved
29990 * http://mixpanel.com/
29991 *
29992 * Includes portions of Underscore.js
29993 * http://documentcloud.github.com/underscore/
29994 * (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
29995 * Released under the MIT License.
29996 */
29997
29998 /*
29999 SIMPLE STYLE GUIDE:
30000
30001 this.x === public function
30002 this._x === internal - only use within this file
30003 this.__x === private - only use within the class
30004
30005 Globals should be all caps
30006 */
30007
30008 var init_type; // MODULE or SNIPPET loader
30009 // allow bundlers to specify how extra code (recorder bundle) should be loaded
30010 // eslint-disable-next-line no-unused-vars
30011 var load_extra_bundle = function(src, _onload) {
30012 throw new Error(src + ' not available in this build.');
30013 };
30014
30015 var mixpanel_master; // main mixpanel instance / object
30016 var INIT_MODULE = 0;
30017 var INIT_SNIPPET = 1;
30018
30019 var IDENTITY_FUNC = function(x) {return x;};
30020
30021 /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
30022 /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
30023 /** @const */ var PAYLOAD_TYPE_JSON = 'json';
30024 /** @const */ var DEVICE_ID_PREFIX = '$device:';
30025
30026
30027 /*
30028 * Dynamic... constants? Is that an oxymoron?
30029 */
30030 // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
30031 // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
30032 var USE_XHR = (win.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest());
30033
30034 // IE<10 does not support cross-origin XHR's but script tags
30035 // with defer won't block window.onload; ENQUEUE_REQUESTS
30036 // should only be true for Opera<12
30037 var ENQUEUE_REQUESTS = !USE_XHR && (userAgent.indexOf('MSIE') === -1) && (userAgent.indexOf('Mozilla') === -1);
30038
30039 // save reference to navigator.sendBeacon so it can be minified
30040 var sendBeacon = null;
30041 if (navigator['sendBeacon']) {
30042 sendBeacon = function() {
30043 // late reference to navigator.sendBeacon to allow patching/spying
30044 return navigator['sendBeacon'].apply(navigator, arguments);
30045 };
30046 }
30047
30048 var DEFAULT_API_ROUTES = {
30049 'track': 'track/',
30050 'engage': 'engage/',
30051 'groups': 'groups/',
30052 'record': 'record/',
30053 'flags': 'flags/'
30054 };
30055
30056 /*
30057 * Module-level globals
30058 */
30059 var DEFAULT_CONFIG = {
30060 'api_host': 'https://api-js.mixpanel.com',
30061 'api_hosts': {},
30062 'api_routes': DEFAULT_API_ROUTES,
30063 'api_extra_query_params': {},
30064 'api_method': 'POST',
30065 'api_transport': 'XHR',
30066 'api_payload_format': PAYLOAD_TYPE_BASE64,
30067 'app_host': 'https://mixpanel.com',
30068 'autocapture': false,
30069 'cdn': 'https://cdn.mxpnl.com',
30070 'cross_site_cookie': false,
30071 'cross_subdomain_cookie': true,
30072 'error_reporter': NOOP_FUNC,
30073 'flags': false,
30074 'persistence': 'cookie',
30075 'persistence_name': '',
30076 'cookie_domain': '',
30077 'cookie_name': '',
30078 'loaded': NOOP_FUNC,
30079 'mp_loader': null,
30080 'track_marketing': true,
30081 'track_pageview': false,
30082 'skip_first_touch_marketing': false,
30083 'store_google': true,
30084 'stop_utm_persistence': false,
30085 'save_referrer': true,
30086 'test': false,
30087 'verbose': false,
30088 'img': false,
30089 'debug': false,
30090 'track_links_timeout': 300,
30091 'cookie_expiration': 365,
30092 'upgrade': false,
30093 'disable_persistence': false,
30094 'disable_cookie': false,
30095 'secure_cookie': false,
30096 'ip': true,
30097 'opt_out_tracking_by_default': false,
30098 'opt_out_persistence_by_default': false,
30099 'opt_out_tracking_persistence_type': 'localStorage',
30100 'opt_out_tracking_cookie_prefix': null,
30101 'property_blacklist': [],
30102 'xhr_headers': {}, // { header: value, header2: value }
30103 'ignore_dnt': false,
30104 'batch_requests': true,
30105 'batch_size': 50,
30106 'batch_flush_interval_ms': 5000,
30107 'batch_request_timeout_ms': 90000,
30108 'batch_autostart': true,
30109 'hooks': {},
30110 'record_block_class': new RegExp('^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$'),
30111 'record_block_selector': 'img, video, audio',
30112 'record_canvas': false,
30113 'record_collect_fonts': false,
30114 'record_heatmap_data': false,
30115 'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
30116 'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
30117 'record_mask_text_selector': '*',
30118 'record_max_ms': MAX_RECORDING_MS,
30119 'record_min_ms': 0,
30120 'record_sessions_percent': 0,
30121 'recorder_src': 'https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js'
30122 };
30123
30124 var DOM_LOADED = false;
30125
30126 /**
30127 * Mixpanel Library Object
30128 * @constructor
30129 */
30130 var MixpanelLib = function() {};
30131
30132
30133 /**
30134 * create_mplib(token:string, config:object, name:string)
30135 *
30136 * This function is used by the init method of MixpanelLib objects
30137 * as well as the main initializer at the end of the JSLib (that
30138 * initializes document.mixpanel as well as any additional instances
30139 * declared before this file has loaded).
30140 */
30141 var create_mplib = function(token, config, name) {
30142 var instance,
30143 target = (name === PRIMARY_INSTANCE_NAME) ? mixpanel_master : mixpanel_master[name];
30144
30145 if (target && init_type === INIT_MODULE) {
30146 instance = target;
30147 } else {
30148 if (target && !_.isArray(target)) {
30149 console$1.error('You have already initialized ' + name);
30150 return;
30151 }
30152 instance = new MixpanelLib();
30153 }
30154
30155 instance._cached_groups = {}; // cache groups in a pool
30156
30157 instance._init(token, config, name);
30158
30159 instance['people'] = new MixpanelPeople();
30160 instance['people']._init(instance);
30161
30162 if (!instance.get_config('skip_first_touch_marketing')) {
30163 // We need null UTM params in the object because
30164 // UTM parameters act as a tuple. If any UTM param
30165 // is present, then we set all UTM params including
30166 // empty ones together
30167 var utm_params = _.info.campaignParams(null);
30168 var initial_utm_params = {};
30169 var has_utm = false;
30170 _.each(utm_params, function(utm_value, utm_key) {
30171 initial_utm_params['initial_' + utm_key] = utm_value;
30172 if (utm_value) {
30173 has_utm = true;
30174 }
30175 });
30176 if (has_utm) {
30177 instance['people'].set_once(initial_utm_params);
30178 }
30179 }
30180
30181 // if any instance on the page has debug = true, we set the
30182 // global debug to be true
30183 Config.DEBUG = Config.DEBUG || instance.get_config('debug');
30184
30185 // if target is not defined, we called init after the lib already
30186 // loaded, so there won't be an array of things to execute
30187 if (!_.isUndefined(target) && _.isArray(target)) {
30188 // Crunch through the people queue first - we queue this data up &
30189 // flush on identify, so it's better to do all these operations first
30190 instance._execute_array.call(instance['people'], target['people']);
30191 instance._execute_array(target);
30192 }
30193
30194 return instance;
30195 };
30196
30197 // Initialization methods
30198
30199 /**
30200 * This function initializes a new instance of the Mixpanel tracking object.
30201 * All new instances are added to the main mixpanel object as sub properties (such as
30202 * mixpanel.library_name) and also returned by this function. To define a
30203 * second instance on the page, you would call:
30204 *
30205 * mixpanel.init('new token', { your: 'config' }, 'library_name');
30206 *
30207 * and use it like so:
30208 *
30209 * mixpanel.library_name.track(...);
30210 *
30211 * @param {String} token Your Mixpanel API token
30212 * @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>.
30213 * @param {String} [name] The name for the new mixpanel instance that you want created
30214 */
30215 MixpanelLib.prototype.init = function (token, config, name) {
30216 if (_.isUndefined(name)) {
30217 this.report_error('You must name your new library: init(token, config, name)');
30218 return;
30219 }
30220 if (name === PRIMARY_INSTANCE_NAME) {
30221 this.report_error('You must initialize the main mixpanel object right after you include the Mixpanel js snippet');
30222 return;
30223 }
30224
30225 var instance = create_mplib(token, config, name);
30226 mixpanel_master[name] = instance;
30227 instance._loaded();
30228
30229 return instance;
30230 };
30231
30232 // mixpanel._init(token:string, config:object, name:string)
30233 //
30234 // This function sets up the current instance of the mixpanel
30235 // library. The difference between this method and the init(...)
30236 // method is this one initializes the actual instance, whereas the
30237 // init(...) method sets up a new library and calls _init on it.
30238 //
30239 MixpanelLib.prototype._init = function(token, config, name) {
30240 config = config || {};
30241
30242 this['__loaded'] = true;
30243 this['config'] = {};
30244
30245 var variable_features = {};
30246
30247 // default to JSON payload for standard mixpanel.com API hosts
30248 if (!('api_payload_format' in config)) {
30249 var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
30250 if (api_host.match(/\.mixpanel\.com/)) {
30251 variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
30252 }
30253 }
30254
30255 this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
30256 'name': name,
30257 'token': token,
30258 'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
30259 }));
30260
30261 this['_jsc'] = NOOP_FUNC;
30262
30263 this.__dom_loaded_queue = [];
30264 this.__request_queue = [];
30265 this.__disabled_events = [];
30266 this._flags = {
30267 'disable_all_events': false,
30268 'identify_called': false
30269 };
30270
30271 // set up request queueing/batching
30272 this.request_batchers = {};
30273 this._batch_requests = this.get_config('batch_requests');
30274 if (this._batch_requests) {
30275 if (!_.localStorage.is_supported(true) || !USE_XHR) {
30276 this._batch_requests = false;
30277 console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
30278 _.each(this.get_batcher_configs(), function(batcher_config) {
30279 console$1.log('Clearing batch queue ' + batcher_config.queue_key);
30280 _.localStorage.remove(batcher_config.queue_key);
30281 });
30282 } else {
30283 this.init_batchers();
30284 if (sendBeacon && win.addEventListener) {
30285 // Before page closes or hides (user tabs away etc), attempt to flush any events
30286 // queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
30287 // events will not be removed from the persistent store; if the site is loaded again,
30288 // the events will be flushed again on startup and deduplicated on the Mixpanel server
30289 // side.
30290 // There is no reliable way to capture only page close events, so we lean on the
30291 // visibilitychange and pagehide events as recommended at
30292 // https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
30293 // These events fire when the user clicks away from the current page/tab, so will occur
30294 // more frequently than page unload, but are the only mechanism currently for capturing
30295 // this scenario somewhat reliably.
30296 var flush_on_unload = _.bind(function() {
30297 if (!this.request_batchers.events.stopped) {
30298 this.request_batchers.events.flush({unloading: true});
30299 }
30300 }, this);
30301 win.addEventListener('pagehide', function(ev) {
30302 if (ev['persisted']) {
30303 flush_on_unload();
30304 }
30305 });
30306 win.addEventListener('visibilitychange', function() {
30307 if (document$1['visibilityState'] === 'hidden') {
30308 flush_on_unload();
30309 }
30310 });
30311 }
30312 }
30313 }
30314
30315 this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
30316 this.unpersisted_superprops = {};
30317 this._gdpr_init();
30318
30319 var uuid = _.UUID();
30320 if (!this.get_distinct_id()) {
30321 // There is no need to set the distinct id
30322 // or the device id if something was already stored
30323 // in the persitence
30324 this.register_once({
30325 'distinct_id': DEVICE_ID_PREFIX + uuid,
30326 '$device_id': uuid
30327 }, '');
30328 }
30329
30330 this.flags = new FeatureFlagManager({
30331 getFullApiRoute: _.bind(function() {
30332 return this.get_api_host('flags') + '/' + this.get_config('api_routes')['flags'];
30333 }, this),
30334 getConfigFunc: _.bind(this.get_config, this),
30335 setConfigFunc: _.bind(this.set_config, this),
30336 getPropertyFunc: _.bind(this.get_property, this),
30337 trackingFunc: _.bind(this.track, this)
30338 });
30339 this.flags.init();
30340 this['flags'] = this.flags;
30341
30342 this.autocapture = new Autocapture(this);
30343 this.autocapture.init();
30344
30345 this._init_tab_id();
30346 this._check_and_start_session_recording();
30347 };
30348
30349 /**
30350 * Assigns a unique UUID to this tab / window by leveraging sessionStorage.
30351 * This is primarily used for session recording, where data must be isolated to the current tab.
30352 */
30353 MixpanelLib.prototype._init_tab_id = function() {
30354 if (this.get_config('disable_persistence')) {
30355 console$1.log('Tab ID initialization skipped due to disable_persistence config');
30356 } else if (_.sessionStorage.is_supported()) {
30357 try {
30358 var key_suffix = this.get_config('name') + '_' + this.get_config('token');
30359 var tab_id_key = 'mp_tab_id_' + key_suffix;
30360
30361 // A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
30362 // This enforces a unique ID in the cases like duplicated tab, window.open(...)
30363 var should_generate_new_tab_id_key = 'mp_gen_new_tab_id_' + key_suffix;
30364 if (_.sessionStorage.get(should_generate_new_tab_id_key) || !_.sessionStorage.get(tab_id_key)) {
30365 _.sessionStorage.set(tab_id_key, '$tab-' + _.UUID());
30366 }
30367
30368 _.sessionStorage.set(should_generate_new_tab_id_key, '1');
30369 this.tab_id = _.sessionStorage.get(tab_id_key);
30370
30371 // 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,
30372 // but reliable in cases where the user remains in the tab e.g. a refresh or href navigation.
30373 // If the flag is absent, this indicates to the next SDK instance that we can reuse the stored tab_id.
30374 win.addEventListener('beforeunload', function () {
30375 _.sessionStorage.remove(should_generate_new_tab_id_key);
30376 });
30377 } catch(err) {
30378 this.report_error('Error initializing tab id', err);
30379 }
30380 } else {
30381 this.report_error('Session storage is not supported, cannot keep track of unique tab ID.');
30382 }
30383 };
30384
30385 MixpanelLib.prototype.get_tab_id = function () {
30386 return this.tab_id || null;
30387 };
30388
30389 MixpanelLib.prototype._should_load_recorder = function () {
30390 if (this.get_config('disable_persistence')) {
30391 console$1.log('Load recorder check skipped due to disable_persistence config');
30392 return Promise.resolve(false);
30393 }
30394
30395 var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
30396 var tab_id = this.get_tab_id();
30397 return recording_registry_idb.init()
30398 .then(function () {
30399 return recording_registry_idb.getAll();
30400 })
30401 .then(function (recordings) {
30402 for (var i = 0; i < recordings.length; i++) {
30403 // if there are expired recordings in the registry, we should load the recorder to flush them
30404 // if there's a recording for this tab id, we should load the recorder to continue the recording
30405 if (isRecordingExpired(recordings[i]) || recordings[i]['tabId'] === tab_id) {
30406 return true;
30407 }
30408 }
30409 return false;
30410 })
30411 .catch(_.bind(function (err) {
30412 this.report_error('Error checking recording registry', err);
30413 }, this));
30414 };
30415
30416 MixpanelLib.prototype._check_and_start_session_recording = addOptOutCheckMixpanelLib(function(force_start) {
30417 if (!win['MutationObserver']) {
30418 console$1.critical('Browser does not support MutationObserver; skipping session recording');
30419 return;
30420 }
30421
30422 var loadRecorder = _.bind(function(startNewIfInactive) {
30423 var handleLoadedRecorder = _.bind(function() {
30424 this._recorder = this._recorder || new win['__mp_recorder'](this);
30425 this._recorder['resumeRecording'](startNewIfInactive);
30426 }, this);
30427
30428 if (_.isUndefined(win['__mp_recorder'])) {
30429 load_extra_bundle(this.get_config('recorder_src'), handleLoadedRecorder);
30430 } else {
30431 handleLoadedRecorder();
30432 }
30433 }, this);
30434
30435 /**
30436 * If the user is sampled or start_session_recording is called, we always load the recorder since it's guaranteed a recording should start.
30437 * 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.
30438 */
30439 var is_sampled = this.get_config('record_sessions_percent') > 0 && Math.random() * 100 <= this.get_config('record_sessions_percent');
30440 if (force_start || is_sampled) {
30441 loadRecorder(true);
30442 } else {
30443 this._should_load_recorder()
30444 .then(function (shouldLoad) {
30445 if (shouldLoad) {
30446 loadRecorder(false);
30447 }
30448 });
30449 }
30450 });
30451
30452 MixpanelLib.prototype.start_session_recording = function () {
30453 this._check_and_start_session_recording(true);
30454 };
30455
30456 MixpanelLib.prototype.stop_session_recording = function () {
30457 if (this._recorder) {
30458 return this._recorder['stopRecording']();
30459 }
30460 return Promise.resolve();
30461 };
30462
30463 MixpanelLib.prototype.pause_session_recording = function () {
30464 if (this._recorder) {
30465 return this._recorder['pauseRecording']();
30466 }
30467 return Promise.resolve();
30468 };
30469
30470 MixpanelLib.prototype.resume_session_recording = function () {
30471 if (this._recorder) {
30472 return this._recorder['resumeRecording']();
30473 }
30474 return Promise.resolve();
30475 };
30476
30477 MixpanelLib.prototype.is_recording_heatmap_data = function () {
30478 return this._get_session_replay_id() && this.get_config('record_heatmap_data');
30479 };
30480
30481 MixpanelLib.prototype.get_session_recording_properties = function () {
30482 var props = {};
30483 var replay_id = this._get_session_replay_id();
30484 if (replay_id) {
30485 props['$mp_replay_id'] = replay_id;
30486 }
30487 return props;
30488 };
30489
30490 MixpanelLib.prototype.get_session_replay_url = function () {
30491 var replay_url = null;
30492 var replay_id = this._get_session_replay_id();
30493 if (replay_id) {
30494 var query_params = _.HTTPBuildQuery({
30495 'replay_id': replay_id,
30496 'distinct_id': this.get_distinct_id(),
30497 'token': this.get_config('token')
30498 });
30499 replay_url = 'https://mixpanel.com/projects/replay-redirect?' + query_params;
30500 }
30501 return replay_url;
30502 };
30503
30504 MixpanelLib.prototype._get_session_replay_id = function () {
30505 var replay_id = null;
30506 if (this._recorder) {
30507 replay_id = this._recorder['replayId'];
30508 }
30509 return replay_id || null;
30510 };
30511
30512 // "private" public method to reach into the recorder in test cases
30513 MixpanelLib.prototype.__get_recorder = function () {
30514 return this._recorder;
30515 };
30516
30517 // Private methods
30518
30519 MixpanelLib.prototype._loaded = function() {
30520 this.get_config('loaded')(this);
30521 this._set_default_superprops();
30522 this['people'].set_once(this['persistence'].get_referrer_info());
30523
30524 // `store_google` is now deprecated and previously stored UTM parameters are cleared
30525 // from persistence by default.
30526 if (this.get_config('store_google') && this.get_config('stop_utm_persistence')) {
30527 var utm_params = _.info.campaignParams(null);
30528 _.each(utm_params, function(_utm_value, utm_key) {
30529 // We need to unregister persisted UTM parameters so old values
30530 // are not mixed with the new UTM parameters
30531 this.unregister(utm_key);
30532 }.bind(this));
30533 }
30534 };
30535
30536 // update persistence with info on referrer, UTM params, etc
30537 MixpanelLib.prototype._set_default_superprops = function() {
30538 this['persistence'].update_search_keyword(document$1.referrer);
30539 // Registering super properties for UTM persistence by 'store_google' is deprecated.
30540 if (this.get_config('store_google') && !this.get_config('stop_utm_persistence')) {
30541 this.register(_.info.campaignParams());
30542 }
30543 if (this.get_config('save_referrer')) {
30544 this['persistence'].update_referrer_info(document$1.referrer);
30545 }
30546 };
30547
30548 MixpanelLib.prototype._dom_loaded = function() {
30549 _.each(this.__dom_loaded_queue, function(item) {
30550 this._track_dom.apply(this, item);
30551 }, this);
30552
30553 if (!this.has_opted_out_tracking()) {
30554 _.each(this.__request_queue, function(item) {
30555 this._send_request.apply(this, item);
30556 }, this);
30557 }
30558
30559 delete this.__dom_loaded_queue;
30560 delete this.__request_queue;
30561 };
30562
30563 MixpanelLib.prototype._track_dom = function(DomClass, args) {
30564 if (this.get_config('img')) {
30565 this.report_error('You can\'t use DOM tracking functions with img = true.');
30566 return false;
30567 }
30568
30569 if (!DOM_LOADED) {
30570 this.__dom_loaded_queue.push([DomClass, args]);
30571 return false;
30572 }
30573
30574 var dt = new DomClass().init(this);
30575 return dt.track.apply(dt, args);
30576 };
30577
30578 /**
30579 * _prepare_callback() should be called by callers of _send_request for use
30580 * as the callback argument.
30581 *
30582 * If there is no callback, this returns null.
30583 * If we are going to make XHR/XDR requests, this returns a function.
30584 * If we are going to use script tags, this returns a string to use as the
30585 * callback GET param.
30586 */
30587 MixpanelLib.prototype._prepare_callback = function(callback, data) {
30588 if (_.isUndefined(callback)) {
30589 return null;
30590 }
30591
30592 if (USE_XHR) {
30593 var callback_function = function(response) {
30594 callback(response, data);
30595 };
30596 return callback_function;
30597 } else {
30598 // if the user gives us a callback, we store as a random
30599 // property on this instances jsc function and update our
30600 // callback string to reflect that.
30601 var jsc = this['_jsc'];
30602 var randomized_cb = '' + Math.floor(Math.random() * 100000000);
30603 var callback_string = this.get_config('callback_fn') + '[' + randomized_cb + ']';
30604 jsc[randomized_cb] = function(response) {
30605 delete jsc[randomized_cb];
30606 callback(response, data);
30607 };
30608 return callback_string;
30609 }
30610 };
30611
30612 MixpanelLib.prototype._send_request = function(url, data, options, callback) {
30613 var succeeded = true;
30614
30615 if (ENQUEUE_REQUESTS) {
30616 this.__request_queue.push(arguments);
30617 return succeeded;
30618 }
30619
30620 var DEFAULT_OPTIONS = {
30621 method: this.get_config('api_method'),
30622 transport: this.get_config('api_transport'),
30623 verbose: this.get_config('verbose')
30624 };
30625 var body_data = null;
30626
30627 if (!callback && (_.isFunction(options) || typeof options === 'string')) {
30628 callback = options;
30629 options = null;
30630 }
30631 options = _.extend(DEFAULT_OPTIONS, options || {});
30632 if (!USE_XHR) {
30633 options.method = 'GET';
30634 }
30635 var use_post = options.method === 'POST';
30636 var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === 'sendbeacon';
30637
30638 // needed to correctly format responses
30639 var verbose_mode = options.verbose;
30640 if (data['verbose']) { verbose_mode = true; }
30641
30642 if (this.get_config('test')) { data['test'] = 1; }
30643 if (verbose_mode) { data['verbose'] = 1; }
30644 if (this.get_config('img')) { data['img'] = 1; }
30645 if (!USE_XHR) {
30646 if (callback) {
30647 data['callback'] = callback;
30648 } else if (verbose_mode || this.get_config('test')) {
30649 // Verbose output (from verbose mode, or an error in test mode) is a json blob,
30650 // which by itself is not valid javascript. Without a callback, this verbose output will
30651 // cause an error when returned via jsonp, so we force a no-op callback param.
30652 // See the ECMA script spec: http://www.ecma-international.org/ecma-262/5.1/#sec-12.4
30653 data['callback'] = '(function(){})';
30654 }
30655 }
30656
30657 data['ip'] = this.get_config('ip')?1:0;
30658 data['_'] = new Date().getTime().toString();
30659
30660 if (use_post) {
30661 body_data = 'data=' + encodeURIComponent(data['data']);
30662 delete data['data'];
30663 }
30664
30665 _.extend(data, this.get_config('api_extra_query_params'));
30666
30667 url += '?' + _.HTTPBuildQuery(data);
30668
30669 var lib = this;
30670 if ('img' in data) {
30671 var img = document$1.createElement('img');
30672 img.src = url;
30673 document$1.body.appendChild(img);
30674 } else if (use_sendBeacon) {
30675 try {
30676 succeeded = sendBeacon(url, body_data);
30677 } catch (e) {
30678 lib.report_error(e);
30679 succeeded = false;
30680 }
30681 try {
30682 if (callback) {
30683 callback(succeeded ? 1 : 0);
30684 }
30685 } catch (e) {
30686 lib.report_error(e);
30687 }
30688 } else if (USE_XHR) {
30689 try {
30690 var req = new XMLHttpRequest();
30691 req.open(options.method, url, true);
30692
30693 var headers = this.get_config('xhr_headers');
30694 if (use_post) {
30695 headers['Content-Type'] = 'application/x-www-form-urlencoded';
30696 }
30697 _.each(headers, function(headerValue, headerName) {
30698 req.setRequestHeader(headerName, headerValue);
30699 });
30700
30701 if (options.timeout_ms && typeof req.timeout !== 'undefined') {
30702 req.timeout = options.timeout_ms;
30703 var start_time = new Date().getTime();
30704 }
30705
30706 // send the mp_optout cookie
30707 // withCredentials cannot be modified until after calling .open on Android and Mobile Safari
30708 req.withCredentials = true;
30709 req.onreadystatechange = function () {
30710 if (req.readyState === 4) { // XMLHttpRequest.DONE == 4, except in safari 4
30711 if (req.status === 200) {
30712 if (callback) {
30713 if (verbose_mode) {
30714 var response;
30715 try {
30716 response = _.JSONDecode(req.responseText);
30717 } catch (e) {
30718 lib.report_error(e);
30719 if (options.ignore_json_errors) {
30720 response = req.responseText;
30721 } else {
30722 return;
30723 }
30724 }
30725 callback(response);
30726 } else {
30727 callback(Number(req.responseText));
30728 }
30729 }
30730 } else {
30731 var error;
30732 if (
30733 req.timeout &&
30734 !req.status &&
30735 new Date().getTime() - start_time >= req.timeout
30736 ) {
30737 error = 'timeout';
30738 } else {
30739 error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
30740 }
30741 lib.report_error(error);
30742 if (callback) {
30743 if (verbose_mode) {
30744 var response_headers = req['responseHeaders'] || {};
30745 callback({status: 0, httpStatusCode: req['status'], error: error, retryAfter: response_headers['Retry-After']});
30746 } else {
30747 callback(0);
30748 }
30749 }
30750 }
30751 }
30752 };
30753 req.send(body_data);
30754 } catch (e) {
30755 lib.report_error(e);
30756 succeeded = false;
30757 }
30758 } else {
30759 var script = document$1.createElement('script');
30760 script.type = 'text/javascript';
30761 script.async = true;
30762 script.defer = true;
30763 script.src = url;
30764 var s = document$1.getElementsByTagName('script')[0];
30765 s.parentNode.insertBefore(script, s);
30766 }
30767
30768 return succeeded;
30769 };
30770
30771 /**
30772 * _execute_array() deals with processing any mixpanel function
30773 * calls that were called before the Mixpanel library were loaded
30774 * (and are thus stored in an array so they can be called later)
30775 *
30776 * Note: we fire off all the mixpanel function calls && user defined
30777 * functions BEFORE we fire off mixpanel tracking calls. This is so
30778 * identify/register/set_config calls can properly modify early
30779 * tracking calls.
30780 *
30781 * @param {Array} array
30782 */
30783 MixpanelLib.prototype._execute_array = function(array) {
30784 var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
30785 _.each(array, function(item) {
30786 if (item) {
30787 fn_name = item[0];
30788 if (_.isArray(fn_name)) {
30789 tracking_calls.push(item); // chained call e.g. mixpanel.get_group().set()
30790 } else if (typeof(item) === 'function') {
30791 item.call(this);
30792 } else if (_.isArray(item) && fn_name === 'alias') {
30793 alias_calls.push(item);
30794 } else if (_.isArray(item) && fn_name.indexOf('track') !== -1 && typeof(this[fn_name]) === 'function') {
30795 tracking_calls.push(item);
30796 } else {
30797 other_calls.push(item);
30798 }
30799 }
30800 }, this);
30801
30802 var execute = function(calls, context) {
30803 _.each(calls, function(item) {
30804 if (_.isArray(item[0])) {
30805 // chained call
30806 var caller = context;
30807 _.each(item, function(call) {
30808 caller = caller[call[0]].apply(caller, call.slice(1));
30809 });
30810 } else {
30811 this[item[0]].apply(this, item.slice(1));
30812 }
30813 }, context);
30814 };
30815
30816 execute(alias_calls, this);
30817 execute(other_calls, this);
30818 execute(tracking_calls, this);
30819 };
30820
30821 // request queueing utils
30822
30823 MixpanelLib.prototype.are_batchers_initialized = function() {
30824 return !!this.request_batchers.events;
30825 };
30826
30827 MixpanelLib.prototype.get_batcher_configs = function() {
30828 var queue_prefix = '__mpq_' + this.get_config('token');
30829 this._batcher_configs = this._batcher_configs || {
30830 events: {type: 'events', api_name: 'track', queue_key: queue_prefix + '_ev'},
30831 people: {type: 'people', api_name: 'engage', queue_key: queue_prefix + '_pp'},
30832 groups: {type: 'groups', api_name: 'groups', queue_key: queue_prefix + '_gr'}
30833 };
30834 return this._batcher_configs;
30835 };
30836
30837 MixpanelLib.prototype.init_batchers = function() {
30838 if (!this.are_batchers_initialized()) {
30839 var batcher_for = _.bind(function(attrs) {
30840 return new RequestBatcher(
30841 attrs.queue_key,
30842 {
30843 libConfig: this['config'],
30844 errorReporter: this.get_config('error_reporter'),
30845 sendRequestFunc: _.bind(function(data, options, cb) {
30846 var api_routes = this.get_config('api_routes');
30847 this._send_request(
30848 this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
30849 this._encode_data_for_request(data),
30850 options,
30851 this._prepare_callback(cb, data)
30852 );
30853 }, this),
30854 beforeSendHook: _.bind(function(item) {
30855 return this._run_hook('before_send_' + attrs.type, item);
30856 }, this),
30857 stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
30858 usePersistence: true,
30859 }
30860 );
30861 }, this);
30862 var batcher_configs = this.get_batcher_configs();
30863 this.request_batchers = {
30864 events: batcher_for(batcher_configs.events),
30865 people: batcher_for(batcher_configs.people),
30866 groups: batcher_for(batcher_configs.groups)
30867 };
30868 }
30869 if (this.get_config('batch_autostart')) {
30870 this.start_batch_senders();
30871 }
30872 };
30873
30874 MixpanelLib.prototype.start_batch_senders = function() {
30875 this._batchers_were_started = true;
30876 if (this.are_batchers_initialized()) {
30877 this._batch_requests = true;
30878 _.each(this.request_batchers, function(batcher) {
30879 batcher.start();
30880 });
30881 }
30882 };
30883
30884 MixpanelLib.prototype.stop_batch_senders = function() {
30885 this._batch_requests = false;
30886 _.each(this.request_batchers, function(batcher) {
30887 batcher.stop();
30888 batcher.clear();
30889 });
30890 };
30891
30892 /**
30893 * push() keeps the standard async-array-push
30894 * behavior around after the lib is loaded.
30895 * This is only useful for external integrations that
30896 * do not wish to rely on our convenience methods
30897 * (created in the snippet).
30898 *
30899 * ### Usage:
30900 * mixpanel.push(['register', { a: 'b' }]);
30901 *
30902 * @param {Array} item A [function_name, args...] array to be executed
30903 */
30904 MixpanelLib.prototype.push = function(item) {
30905 this._execute_array([item]);
30906 };
30907
30908 /**
30909 * Disable events on the Mixpanel object. If passed no arguments,
30910 * this function disables tracking of any event. If passed an
30911 * array of event names, those events will be disabled, but other
30912 * events will continue to be tracked.
30913 *
30914 * Note: this function does not stop other mixpanel functions from
30915 * firing, such as register() or people.set().
30916 *
30917 * @param {Array} [events] An array of event names to disable
30918 */
30919 MixpanelLib.prototype.disable = function(events) {
30920 if (typeof(events) === 'undefined') {
30921 this._flags.disable_all_events = true;
30922 } else {
30923 this.__disabled_events = this.__disabled_events.concat(events);
30924 }
30925 };
30926
30927 MixpanelLib.prototype._encode_data_for_request = function(data) {
30928 var encoded_data = JSONStringify(data);
30929 if (this.get_config('api_payload_format') === PAYLOAD_TYPE_BASE64) {
30930 encoded_data = _.base64Encode(encoded_data);
30931 }
30932 return {'data': encoded_data};
30933 };
30934
30935 // internal method for handling track vs batch-enqueue logic
30936 MixpanelLib.prototype._track_or_batch = function(options, callback) {
30937 var truncated_data = _.truncate(options.data, 255);
30938 var endpoint = options.endpoint;
30939 var batcher = options.batcher;
30940 var should_send_immediately = options.should_send_immediately;
30941 var send_request_options = options.send_request_options || {};
30942 callback = callback || NOOP_FUNC;
30943
30944 var request_enqueued_or_initiated = true;
30945 var send_request_immediately = _.bind(function() {
30946 if (!send_request_options.skip_hooks) {
30947 truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
30948 }
30949 if (truncated_data) {
30950 console$1.log('MIXPANEL REQUEST:');
30951 console$1.log(truncated_data);
30952 return this._send_request(
30953 endpoint,
30954 this._encode_data_for_request(truncated_data),
30955 send_request_options,
30956 this._prepare_callback(callback, truncated_data)
30957 );
30958 } else {
30959 return null;
30960 }
30961 }, this);
30962
30963 if (this._batch_requests && !should_send_immediately) {
30964 batcher.enqueue(truncated_data).then(function(succeeded) {
30965 if (succeeded) {
30966 callback(1, truncated_data);
30967 } else {
30968 send_request_immediately();
30969 }
30970 });
30971 } else {
30972 request_enqueued_or_initiated = send_request_immediately();
30973 }
30974
30975 return request_enqueued_or_initiated && truncated_data;
30976 };
30977
30978 /**
30979 * Track an event. This is the most important and
30980 * frequently used Mixpanel function.
30981 *
30982 * ### Usage:
30983 *
30984 * // track an event named 'Registered'
30985 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
30986 *
30987 * // track an event using navigator.sendBeacon
30988 * mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
30989 *
30990 * To track link clicks or form submissions, see track_links() or track_forms().
30991 *
30992 * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
30993 * @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.
30994 * @param {Object} [options] Optional configuration for this track request.
30995 * @param {String} [options.transport] Transport method for network request ('xhr' or 'sendBeacon').
30996 * @param {Boolean} [options.send_immediately] Whether to bypass batching/queueing and send track request immediately.
30997 * @param {Function} [callback] If provided, the callback function will be called after tracking the event.
30998 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
30999 * with the tracking payload sent to the API server is returned; otherwise false.
31000 */
31001 MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
31002 if (!callback && typeof options === 'function') {
31003 callback = options;
31004 options = null;
31005 }
31006 options = options || {};
31007 var transport = options['transport']; // external API, don't minify 'transport' prop
31008 if (transport) {
31009 options.transport = transport; // 'transport' prop name can be minified internally
31010 }
31011 var should_send_immediately = options['send_immediately'];
31012 if (typeof callback !== 'function') {
31013 callback = NOOP_FUNC;
31014 }
31015
31016 if (_.isUndefined(event_name)) {
31017 this.report_error('No event name provided to mixpanel.track');
31018 return;
31019 }
31020
31021 if (this._event_is_disabled(event_name)) {
31022 callback(0);
31023 return;
31024 }
31025
31026 // set defaults
31027 properties = _.extend({}, properties);
31028 properties['token'] = this.get_config('token');
31029
31030 // set $duration if time_event was previously called for this event
31031 var start_timestamp = this['persistence'].remove_event_timer(event_name);
31032 if (!_.isUndefined(start_timestamp)) {
31033 var duration_in_ms = new Date().getTime() - start_timestamp;
31034 properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
31035 }
31036
31037 this._set_default_superprops();
31038
31039 var marketing_properties = this.get_config('track_marketing')
31040 ? _.info.marketingParams()
31041 : {};
31042
31043 // note: extend writes to the first object, so lets make sure we
31044 // don't write to the persistence properties object and info
31045 // properties object by passing in a new object
31046
31047 // update properties with pageview info and super-properties
31048 properties = _.extend(
31049 {},
31050 _.info.properties({'mp_loader': this.get_config('mp_loader')}),
31051 marketing_properties,
31052 this['persistence'].properties(),
31053 this.unpersisted_superprops,
31054 this.get_session_recording_properties(),
31055 properties
31056 );
31057
31058 var property_blacklist = this.get_config('property_blacklist');
31059 if (_.isArray(property_blacklist)) {
31060 _.each(property_blacklist, function(blacklisted_prop) {
31061 delete properties[blacklisted_prop];
31062 });
31063 } else {
31064 this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
31065 }
31066
31067 var data = {
31068 'event': event_name,
31069 'properties': properties
31070 };
31071 var ret = this._track_or_batch({
31072 type: 'events',
31073 data: data,
31074 endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
31075 batcher: this.request_batchers.events,
31076 should_send_immediately: should_send_immediately,
31077 send_request_options: options
31078 }, callback);
31079
31080 return ret;
31081 });
31082
31083 /**
31084 * Register the current user into one/many groups.
31085 *
31086 * ### Usage:
31087 *
31088 * mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
31089 * mixpanel.set_group('company', 'mixpanel')
31090 * mixpanel.set_group('company', 128746312)
31091 *
31092 * @param {String} group_key Group key
31093 * @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
31094 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31095 *
31096 */
31097 MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
31098 if (!_.isArray(group_ids)) {
31099 group_ids = [group_ids];
31100 }
31101 var prop = {};
31102 prop[group_key] = group_ids;
31103 this.register(prop);
31104 return this['people'].set(group_key, group_ids, callback);
31105 });
31106
31107 /**
31108 * Add a new group for this user.
31109 *
31110 * ### Usage:
31111 *
31112 * mixpanel.add_group('company', 'mixpanel')
31113 *
31114 * @param {String} group_key Group key
31115 * @param {*} group_id A valid Mixpanel property type
31116 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31117 */
31118 MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31119 var old_values = this.get_property(group_key);
31120 var prop = {};
31121 if (old_values === undefined) {
31122 prop[group_key] = [group_id];
31123 this.register(prop);
31124 } else {
31125 if (old_values.indexOf(group_id) === -1) {
31126 old_values.push(group_id);
31127 prop[group_key] = old_values;
31128 this.register(prop);
31129 }
31130 }
31131 return this['people'].union(group_key, group_id, callback);
31132 });
31133
31134 /**
31135 * Remove a group from this user.
31136 *
31137 * ### Usage:
31138 *
31139 * mixpanel.remove_group('company', 'mixpanel')
31140 *
31141 * @param {String} group_key Group key
31142 * @param {*} group_id A valid Mixpanel property type
31143 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31144 */
31145 MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
31146 var old_value = this.get_property(group_key);
31147 // if the value doesn't exist, the persistent store is unchanged
31148 if (old_value !== undefined) {
31149 var idx = old_value.indexOf(group_id);
31150 if (idx > -1) {
31151 old_value.splice(idx, 1);
31152 this.register({group_key: old_value});
31153 }
31154 if (old_value.length === 0) {
31155 this.unregister(group_key);
31156 }
31157 }
31158 return this['people'].remove(group_key, group_id, callback);
31159 });
31160
31161 /**
31162 * Track an event with specific groups.
31163 *
31164 * ### Usage:
31165 *
31166 * mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
31167 *
31168 * @param {String} event_name The name of the event (see `mixpanel.track()`)
31169 * @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
31170 * @param {Object=} groups An object mapping group name keys to one or more values
31171 * @param {Function} [callback] If provided, the callback will be called after tracking the event.
31172 */
31173 MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
31174 var tracking_props = _.extend({}, properties || {});
31175 _.each(groups, function(v, k) {
31176 if (v !== null && v !== undefined) {
31177 tracking_props[k] = v;
31178 }
31179 });
31180 return this.track(event_name, tracking_props, callback);
31181 });
31182
31183 MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
31184 return group_key + '_' + JSON.stringify(group_id);
31185 };
31186
31187 MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id) {
31188 delete this._cached_groups[this._create_map_key(group_key, group_id)];
31189 };
31190
31191 /**
31192 * Look up reference to a Mixpanel group
31193 *
31194 * ### Usage:
31195 *
31196 * mixpanel.get_group(group_key, group_id)
31197 *
31198 * @param {String} group_key Group key
31199 * @param {Object} group_id A valid Mixpanel property type
31200 * @returns {Object} A MixpanelGroup identifier
31201 */
31202 MixpanelLib.prototype.get_group = function (group_key, group_id) {
31203 var map_key = this._create_map_key(group_key, group_id);
31204 var group = this._cached_groups[map_key];
31205 if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
31206 group = new MixpanelGroup();
31207 group._init(this, group_key, group_id);
31208 this._cached_groups[map_key] = group;
31209 }
31210 return group;
31211 };
31212
31213 /**
31214 * Track a default Mixpanel page view event, which includes extra default event properties to
31215 * improve page view data.
31216 *
31217 * ### Usage:
31218 *
31219 * // track a default $mp_web_page_view event
31220 * mixpanel.track_pageview();
31221 *
31222 * // track a page view event with additional event properties
31223 * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
31224 *
31225 * // example approach to track page views on different page types as event properties
31226 * mixpanel.track_pageview({'page': 'pricing'});
31227 * mixpanel.track_pageview({'page': 'homepage'});
31228 *
31229 * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
31230 * // individual pages on the same site or product. Use cases for custom event_name may be page
31231 * // views on different products or internal applications that are considered completely separate
31232 * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
31233 *
31234 * ### Notes:
31235 *
31236 * The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
31237 * may be turned on for tracking page loads automatically.
31238 *
31239 * // track only page loads
31240 * mixpanel.init(PROJECT_TOKEN, {track_pageview: true});
31241 *
31242 * // track when the URL changes in any manner
31243 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'full-url'});
31244 *
31245 * // track when the URL changes, ignoring any changes in the hash part
31246 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path-and-query-string'});
31247 *
31248 * // track when the path changes, ignoring any query parameter or hash changes
31249 * mixpanel.init(PROJECT_TOKEN, {track_pageview: 'url-with-path'});
31250 *
31251 * @param {Object} [properties] An optional set of additional properties to send with the page view event
31252 * @param {Object} [options] Page view tracking options
31253 * @param {String} [options.event_name] - Alternate name for the tracking event
31254 * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
31255 * with the tracking payload sent to the API server is returned; otherwise false.
31256 */
31257 MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
31258 if (typeof properties !== 'object') {
31259 properties = {};
31260 }
31261 options = options || {};
31262 var event_name = options['event_name'] || '$mp_web_page_view';
31263
31264 var default_page_properties = _.extend(
31265 _.info.mpPageViewProperties(),
31266 _.info.campaignParams(),
31267 _.info.clickParams()
31268 );
31269
31270 var event_properties = _.extend(
31271 {},
31272 default_page_properties,
31273 properties
31274 );
31275
31276 return this.track(event_name, event_properties);
31277 });
31278
31279 /**
31280 * Track clicks on a set of document elements. Selector must be a
31281 * valid query. Elements must exist on the page at the time track_links is called.
31282 *
31283 * ### Usage:
31284 *
31285 * // track click for link id #nav
31286 * mixpanel.track_links('#nav', 'Clicked Nav Link');
31287 *
31288 * ### Notes:
31289 *
31290 * This function will wait up to 300 ms for the Mixpanel
31291 * servers to respond. If they have not responded by that time
31292 * it will head to the link without ensuring that your event
31293 * has been tracked. To configure this timeout please see the
31294 * set_config() documentation below.
31295 *
31296 * If you pass a function in as the properties argument, the
31297 * function will receive the DOMElement that triggered the
31298 * event as an argument. You are expected to return an object
31299 * from the function; any properties defined on this object
31300 * will be sent to mixpanel as event properties.
31301 *
31302 * @type {Function}
31303 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31304 * @param {String} event_name The name of the event to track
31305 * @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
31306 */
31307 MixpanelLib.prototype.track_links = function() {
31308 return this._track_dom.call(this, LinkTracker, arguments);
31309 };
31310
31311 /**
31312 * Track form submissions. Selector must be a valid query.
31313 *
31314 * ### Usage:
31315 *
31316 * // track submission for form id 'register'
31317 * mixpanel.track_forms('#register', 'Created Account');
31318 *
31319 * ### Notes:
31320 *
31321 * This function will wait up to 300 ms for the mixpanel
31322 * servers to respond, if they have not responded by that time
31323 * it will head to the link without ensuring that your event
31324 * has been tracked. To configure this timeout please see the
31325 * set_config() documentation below.
31326 *
31327 * If you pass a function in as the properties argument, the
31328 * function will receive the DOMElement that triggered the
31329 * event as an argument. You are expected to return an object
31330 * from the function; any properties defined on this object
31331 * will be sent to mixpanel as event properties.
31332 *
31333 * @type {Function}
31334 * @param {Object|String} query A valid DOM query, element or jQuery-esque list
31335 * @param {String} event_name The name of the event to track
31336 * @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
31337 */
31338 MixpanelLib.prototype.track_forms = function() {
31339 return this._track_dom.call(this, FormTracker, arguments);
31340 };
31341
31342 /**
31343 * Time an event by including the time between this call and a
31344 * later 'track' call for the same event in the properties sent
31345 * with the event.
31346 *
31347 * ### Usage:
31348 *
31349 * // time an event named 'Registered'
31350 * mixpanel.time_event('Registered');
31351 * mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
31352 *
31353 * When called for a particular event name, the next track call for that event
31354 * name will include the elapsed time between the 'time_event' and 'track'
31355 * calls. This value is stored as seconds in the '$duration' property.
31356 *
31357 * @param {String} event_name The name of the event.
31358 */
31359 MixpanelLib.prototype.time_event = function(event_name) {
31360 if (_.isUndefined(event_name)) {
31361 this.report_error('No event name provided to mixpanel.time_event');
31362 return;
31363 }
31364
31365 if (this._event_is_disabled(event_name)) {
31366 return;
31367 }
31368
31369 this['persistence'].set_event_timer(event_name, new Date().getTime());
31370 };
31371
31372 var REGISTER_DEFAULTS = {
31373 'persistent': true
31374 };
31375 /**
31376 * Helper to parse options param for register methods, maintaining
31377 * legacy support for plain "days" param instead of options object
31378 * @param {Number|Object} [days_or_options] 'days' option (Number), or Options object for register methods
31379 * @returns {Object} options object
31380 */
31381 var options_for_register = function(days_or_options) {
31382 var options;
31383 if (_.isObject(days_or_options)) {
31384 options = days_or_options;
31385 } else if (!_.isUndefined(days_or_options)) {
31386 options = {'days': days_or_options};
31387 } else {
31388 options = {};
31389 }
31390 return _.extend({}, REGISTER_DEFAULTS, options);
31391 };
31392
31393 /**
31394 * Register a set of super properties, which are included with all
31395 * events. This will overwrite previous super property values.
31396 *
31397 * ### Usage:
31398 *
31399 * // register 'Gender' as a super property
31400 * mixpanel.register({'Gender': 'Female'});
31401 *
31402 * // register several super properties when a user signs up
31403 * mixpanel.register({
31404 * 'Email': 'jdoe@example.com',
31405 * 'Account Type': 'Free'
31406 * });
31407 *
31408 * // register only for the current pageload
31409 * mixpanel.register({'Name': 'Pat'}, {persistent: false});
31410 *
31411 * @param {Object} properties An associative array of properties to store about the user
31412 * @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)
31413 * @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)
31414 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31415 */
31416 MixpanelLib.prototype.register = function(props, days_or_options) {
31417 var options = options_for_register(days_or_options);
31418 if (options['persistent']) {
31419 this['persistence'].register(props, options['days']);
31420 } else {
31421 _.extend(this.unpersisted_superprops, props);
31422 }
31423 };
31424
31425 /**
31426 * Register a set of super properties only once. This will not
31427 * overwrite previous super property values, unlike register().
31428 *
31429 * ### Usage:
31430 *
31431 * // register a super property for the first time only
31432 * mixpanel.register_once({
31433 * 'First Login Date': new Date().toISOString()
31434 * });
31435 *
31436 * // register once, only for the current pageload
31437 * mixpanel.register_once({
31438 * 'First interaction time': new Date().toISOString()
31439 * }, 'None', {persistent: false});
31440 *
31441 * ### Notes:
31442 *
31443 * If default_value is specified, current super properties
31444 * with that value will be overwritten.
31445 *
31446 * @param {Object} properties An associative array of properties to store about the user
31447 * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
31448 * @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)
31449 * @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)
31450 * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
31451 */
31452 MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
31453 var options = options_for_register(days_or_options);
31454 if (options['persistent']) {
31455 this['persistence'].register_once(props, default_value, options['days']);
31456 } else {
31457 if (typeof(default_value) === 'undefined') {
31458 default_value = 'None';
31459 }
31460 _.each(props, function(val, prop) {
31461 if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
31462 this.unpersisted_superprops[prop] = val;
31463 }
31464 }, this);
31465 }
31466 };
31467
31468 /**
31469 * Delete a super property stored with the current user.
31470 *
31471 * @param {String} property The name of the super property to remove
31472 * @param {Object} [options]
31473 * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
31474 */
31475 MixpanelLib.prototype.unregister = function(property, options) {
31476 options = options_for_register(options);
31477 if (options['persistent']) {
31478 this['persistence'].unregister(property);
31479 } else {
31480 delete this.unpersisted_superprops[property];
31481 }
31482 };
31483
31484 MixpanelLib.prototype._register_single = function(prop, value) {
31485 var props = {};
31486 props[prop] = value;
31487 this.register(props);
31488 };
31489
31490 /**
31491 * Identify a user with a unique ID to track user activity across
31492 * devices, tie a user to their events, and create a user profile.
31493 * If you never call this method, unique visitors are tracked using
31494 * a UUID generated the first time they visit the site.
31495 *
31496 * Call identify when you know the identity of the current user,
31497 * typically after login or signup. We recommend against using
31498 * identify for anonymous visitors to your site.
31499 *
31500 * ### Notes:
31501 * If your project has
31502 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31503 * enabled, the identify method will connect pre- and
31504 * post-authentication events when appropriate.
31505 *
31506 * If your project does not have ID Merge enabled, identify will
31507 * change the user's local distinct_id to the unique ID you pass.
31508 * Events tracked prior to authentication will not be connected
31509 * to the same user identity. If ID Merge is disabled, alias can
31510 * be used to connect pre- and post-registration events.
31511 *
31512 * @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.
31513 */
31514 MixpanelLib.prototype.identify = function(
31515 new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
31516 ) {
31517 // Optional Parameters
31518 // _set_callback:function A callback to be run if and when the People set queue is flushed
31519 // _add_callback:function A callback to be run if and when the People add queue is flushed
31520 // _append_callback:function A callback to be run if and when the People append queue is flushed
31521 // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
31522 // _union_callback:function A callback to be run if and when the People union queue is flushed
31523 // _unset_callback:function A callback to be run if and when the People unset queue is flushed
31524
31525 var previous_distinct_id = this.get_distinct_id();
31526 if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
31527 // we allow the following condition if previous distinct_id is same as new_distinct_id
31528 // so that you can force flush people updates for anonymous profiles.
31529 if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
31530 this.report_error('distinct_id cannot have $device: prefix');
31531 return -1;
31532 }
31533 this.register({'$user_id': new_distinct_id});
31534 }
31535
31536 if (!this.get_property('$device_id')) {
31537 // The persisted distinct id might not actually be a device id at all
31538 // it might be a distinct id of the user from before
31539 var device_id = previous_distinct_id;
31540 this.register_once({
31541 '$had_persisted_distinct_id': true,
31542 '$device_id': device_id
31543 }, '');
31544 }
31545
31546 // identify only changes the distinct id if it doesn't match either the existing or the alias;
31547 // if it's new, blow away the alias as well.
31548 if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
31549 this.unregister(ALIAS_ID_KEY);
31550 this.register({'distinct_id': new_distinct_id});
31551 }
31552 this._flags.identify_called = true;
31553 // Flush any queued up people requests
31554 this['people']._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
31555
31556 // send an $identify event any time the distinct_id is changing - logic on the server
31557 // will determine whether or not to do anything with it.
31558 if (new_distinct_id !== previous_distinct_id) {
31559 this.track('$identify', {
31560 'distinct_id': new_distinct_id,
31561 '$anon_distinct_id': previous_distinct_id
31562 }, {skip_hooks: true});
31563 }
31564
31565 // check feature flags again if distinct id has changed
31566 if (new_distinct_id !== previous_distinct_id) {
31567 this.flags.fetchFlags();
31568 }
31569 };
31570
31571 /**
31572 * Clears super properties and generates a new random distinct_id for this instance.
31573 * Useful for clearing data when a user logs out.
31574 */
31575 MixpanelLib.prototype.reset = function() {
31576 this.stop_session_recording();
31577 this['persistence'].clear();
31578 this._flags.identify_called = false;
31579 var uuid = _.UUID();
31580 this.register_once({
31581 'distinct_id': DEVICE_ID_PREFIX + uuid,
31582 '$device_id': uuid
31583 }, '');
31584 this._check_and_start_session_recording();
31585 };
31586
31587 /**
31588 * Returns the current distinct id of the user. This is either the id automatically
31589 * generated by the library or the id that has been passed by a call to identify().
31590 *
31591 * ### Notes:
31592 *
31593 * get_distinct_id() can only be called after the Mixpanel library has finished loading.
31594 * init() has a loaded function available to handle this automatically. For example:
31595 *
31596 * // set distinct_id after the mixpanel library has loaded
31597 * mixpanel.init('YOUR PROJECT TOKEN', {
31598 * loaded: function(mixpanel) {
31599 * distinct_id = mixpanel.get_distinct_id();
31600 * }
31601 * });
31602 */
31603 MixpanelLib.prototype.get_distinct_id = function() {
31604 return this.get_property('distinct_id');
31605 };
31606
31607 /**
31608 * The alias method creates an alias which Mixpanel will use to
31609 * remap one id to another. Multiple aliases can point to the
31610 * same identifier.
31611 *
31612 * The following is a valid use of alias:
31613 *
31614 * mixpanel.alias('new_id', 'existing_id');
31615 * // You can add multiple id aliases to the existing ID
31616 * mixpanel.alias('newer_id', 'existing_id');
31617 *
31618 * Aliases can also be chained - the following is a valid example:
31619 *
31620 * mixpanel.alias('new_id', 'existing_id');
31621 * // chain newer_id - new_id - existing_id
31622 * mixpanel.alias('newer_id', 'new_id');
31623 *
31624 * Aliases cannot point to multiple identifiers - the following
31625 * example will not work:
31626 *
31627 * mixpanel.alias('new_id', 'existing_id');
31628 * // this is invalid as 'new_id' already points to 'existing_id'
31629 * mixpanel.alias('new_id', 'newer_id');
31630 *
31631 * ### Notes:
31632 *
31633 * If your project does not have
31634 * <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
31635 * enabled, the best practice is to call alias once when a unique
31636 * ID is first created for a user (e.g., when a user first registers
31637 * for an account). Do not use alias multiple times for a single
31638 * user without ID Merge enabled.
31639 *
31640 * @param {String} alias A unique identifier that you want to use for this user in the future.
31641 * @param {String} [original] The current identifier being used for this user.
31642 */
31643 MixpanelLib.prototype.alias = function(alias, original) {
31644 // If the $people_distinct_id key exists in persistence, there has been a previous
31645 // mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
31646 // this ID, as it will duplicate users.
31647 if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
31648 this.report_error('Attempting to create alias for existing People user - aborting.');
31649 return -2;
31650 }
31651
31652 var _this = this;
31653 if (_.isUndefined(original)) {
31654 original = this.get_distinct_id();
31655 }
31656 if (alias !== original) {
31657 this._register_single(ALIAS_ID_KEY, alias);
31658 return this.track('$create_alias', {
31659 'alias': alias,
31660 'distinct_id': original
31661 }, {
31662 skip_hooks: true
31663 }, function() {
31664 // Flush the people queue
31665 _this.identify(alias);
31666 });
31667 } else {
31668 this.report_error('alias matches current distinct_id - skipping api call.');
31669 this.identify(alias);
31670 return -1;
31671 }
31672 };
31673
31674 /**
31675 * Provide a string to recognize the user by. The string passed to
31676 * this method will appear in the Mixpanel Streams product rather
31677 * than an automatically generated name. Name tags do not have to
31678 * be unique.
31679 *
31680 * This value will only be included in Streams data.
31681 *
31682 * @param {String} name_tag A human readable name for the user
31683 * @deprecated
31684 */
31685 MixpanelLib.prototype.name_tag = function(name_tag) {
31686 this._register_single('mp_name_tag', name_tag);
31687 };
31688
31689 /**
31690 * Update the configuration of a mixpanel library instance.
31691 *
31692 * The default config is:
31693 *
31694 * {
31695 * // host for requests (customizable for e.g. a local proxy)
31696 * api_host: 'https://api-js.mixpanel.com',
31697 *
31698 * // endpoints for different types of requests
31699 * api_routes: {
31700 * track: 'track/',
31701 * engage: 'engage/',
31702 * groups: 'groups/',
31703 * }
31704 *
31705 * // HTTP method for tracking requests
31706 * api_method: 'POST'
31707 *
31708 * // transport for sending requests ('XHR' or 'sendBeacon')
31709 * // NB: sendBeacon should only be used for scenarios such as
31710 * // page unload where a "best-effort" attempt to send is
31711 * // acceptable; the sendBeacon API does not support callbacks
31712 * // or any way to know the result of the request. Mixpanel
31713 * // tracking via sendBeacon will not support any event-
31714 * // batching or retry mechanisms.
31715 * api_transport: 'XHR'
31716 *
31717 * // request-batching/queueing/retry
31718 * batch_requests: true,
31719 *
31720 * // maximum number of events/updates to send in a single
31721 * // network request
31722 * batch_size: 50,
31723 *
31724 * // milliseconds to wait between sending batch requests
31725 * batch_flush_interval_ms: 5000,
31726 *
31727 * // milliseconds to wait for network responses to batch requests
31728 * // before they are considered timed-out and retried
31729 * batch_request_timeout_ms: 90000,
31730 *
31731 * // override value for cookie domain, only useful for ensuring
31732 * // correct cross-subdomain cookies on unusual domains like
31733 * // subdomain.mainsite.avocat.fr; NB this cannot be used to
31734 * // set cookies on a different domain than the current origin
31735 * cookie_domain: ''
31736 *
31737 * // super properties cookie expiration (in days)
31738 * cookie_expiration: 365
31739 *
31740 * // if true, cookie will be set with SameSite=None; Secure
31741 * // this is only useful in special situations, like embedded
31742 * // 3rd-party iframes that set up a Mixpanel instance
31743 * cross_site_cookie: false
31744 *
31745 * // super properties span subdomains
31746 * cross_subdomain_cookie: true
31747 *
31748 * // debug mode
31749 * debug: false
31750 *
31751 * // if this is true, the mixpanel cookie or localStorage entry
31752 * // will be deleted, and no user persistence will take place
31753 * disable_persistence: false
31754 *
31755 * // if this is true, Mixpanel will automatically determine
31756 * // City, Region and Country data using the IP address of
31757 * //the client
31758 * ip: true
31759 *
31760 * // opt users out of tracking by this Mixpanel instance by default
31761 * opt_out_tracking_by_default: false
31762 *
31763 * // opt users out of browser data storage by this Mixpanel instance by default
31764 * opt_out_persistence_by_default: false
31765 *
31766 * // persistence mechanism used by opt-in/opt-out methods - cookie
31767 * // or localStorage - falls back to cookie if localStorage is unavailable
31768 * opt_out_tracking_persistence_type: 'localStorage'
31769 *
31770 * // customize the name of cookie/localStorage set by opt-in/opt-out methods
31771 * opt_out_tracking_cookie_prefix: null
31772 *
31773 * // type of persistent store for super properties (cookie/
31774 * // localStorage) if set to 'localStorage', any existing
31775 * // mixpanel cookie value with the same persistence_name
31776 * // will be transferred to localStorage and deleted
31777 * persistence: 'cookie'
31778 *
31779 * // name for super properties persistent store
31780 * persistence_name: ''
31781 *
31782 * // names of properties/superproperties which should never
31783 * // be sent with track() calls
31784 * property_blacklist: []
31785 *
31786 * // if this is true, mixpanel cookies will be marked as
31787 * // secure, meaning they will only be transmitted over https
31788 * secure_cookie: false
31789 *
31790 * // disables enriching user profiles with first touch marketing data
31791 * skip_first_touch_marketing: false
31792 *
31793 * // the amount of time track_links will
31794 * // wait for Mixpanel's servers to respond
31795 * track_links_timeout: 300
31796 *
31797 * // adds any UTM parameters and click IDs present on the page to any events fired
31798 * track_marketing: true
31799 *
31800 * // enables automatic page view tracking using default page view events through
31801 * // the track_pageview() method
31802 * track_pageview: false
31803 *
31804 * // if you set upgrade to be true, the library will check for
31805 * // a cookie from our old js library and import super
31806 * // properties from it, then the old cookie is deleted
31807 * // The upgrade config option only works in the initialization,
31808 * // so make sure you set it when you create the library.
31809 * upgrade: false
31810 *
31811 * // extra HTTP request headers to set for each API request, in
31812 * // the format {'Header-Name': value}
31813 * xhr_headers: {}
31814 *
31815 * // whether to ignore or respect the web browser's Do Not Track setting
31816 * ignore_dnt: false
31817 * }
31818 *
31819 *
31820 * @param {Object} config A dictionary of new configuration values to update
31821 */
31822 MixpanelLib.prototype.set_config = function(config) {
31823 if (_.isObject(config)) {
31824 _.extend(this['config'], config);
31825
31826 var new_batch_size = config['batch_size'];
31827 if (new_batch_size) {
31828 _.each(this.request_batchers, function(batcher) {
31829 batcher.resetBatchSize();
31830 });
31831 }
31832
31833 if (!this.get_config('persistence_name')) {
31834 this['config']['persistence_name'] = this['config']['cookie_name'];
31835 }
31836 if (!this.get_config('disable_persistence')) {
31837 this['config']['disable_persistence'] = this['config']['disable_cookie'];
31838 }
31839
31840 if (this['persistence']) {
31841 this['persistence'].update_config(this['config']);
31842 }
31843 Config.DEBUG = Config.DEBUG || this.get_config('debug');
31844
31845 if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
31846 this.autocapture.init();
31847 }
31848 }
31849 };
31850
31851 /**
31852 * returns the current config object for the library.
31853 */
31854 MixpanelLib.prototype.get_config = function(prop_name) {
31855 return this['config'][prop_name];
31856 };
31857
31858 /**
31859 * Fetch a hook function from config, with safe default, and run it
31860 * against the given arguments
31861 * @param {string} hook_name which hook to retrieve
31862 * @returns {any|null} return value of user-provided hook, or null if nothing was returned
31863 */
31864 MixpanelLib.prototype._run_hook = function(hook_name) {
31865 var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
31866 if (typeof ret === 'undefined') {
31867 this.report_error(hook_name + ' hook did not return a value');
31868 ret = null;
31869 }
31870 return ret;
31871 };
31872
31873 /**
31874 * Returns the value of the super property named property_name. If no such
31875 * property is set, get_property() will return the undefined value.
31876 *
31877 * ### Notes:
31878 *
31879 * get_property() can only be called after the Mixpanel library has finished loading.
31880 * init() has a loaded function available to handle this automatically. For example:
31881 *
31882 * // grab value for 'user_id' after the mixpanel library has loaded
31883 * mixpanel.init('YOUR PROJECT TOKEN', {
31884 * loaded: function(mixpanel) {
31885 * user_id = mixpanel.get_property('user_id');
31886 * }
31887 * });
31888 *
31889 * @param {String} property_name The name of the super property you want to retrieve
31890 */
31891 MixpanelLib.prototype.get_property = function(property_name) {
31892 return this['persistence'].load_prop([property_name]);
31893 };
31894
31895 /**
31896 * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
31897 *
31898 * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
31899 * @returns {String} The API host to use for this endpoint
31900 */
31901 MixpanelLib.prototype.get_api_host = function(endpoint_type) {
31902 return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
31903 };
31904
31905 MixpanelLib.prototype.toString = function() {
31906 var name = this.get_config('name');
31907 if (name !== PRIMARY_INSTANCE_NAME) {
31908 name = PRIMARY_INSTANCE_NAME + '.' + name;
31909 }
31910 return name;
31911 };
31912
31913 MixpanelLib.prototype._event_is_disabled = function(event_name) {
31914 return _.isBlockedUA(userAgent) ||
31915 this._flags.disable_all_events ||
31916 _.include(this.__disabled_events, event_name);
31917 };
31918
31919 // perform some housekeeping around GDPR opt-in/out state
31920 MixpanelLib.prototype._gdpr_init = function() {
31921 var is_localStorage_requested = this.get_config('opt_out_tracking_persistence_type') === 'localStorage';
31922
31923 // try to convert opt-in/out cookies to localStorage if possible
31924 if (is_localStorage_requested && _.localStorage.is_supported()) {
31925 if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({'persistence_type': 'cookie'})) {
31926 this.opt_in_tracking({'enable_persistence': false});
31927 }
31928 if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
31929 this.opt_out_tracking({'clear_persistence': false});
31930 }
31931 this.clear_opt_in_out_tracking({
31932 'persistence_type': 'cookie',
31933 'enable_persistence': false
31934 });
31935 }
31936
31937 // check whether the user has already opted out - if so, clear & disable persistence
31938 if (this.has_opted_out_tracking()) {
31939 this._gdpr_update_persistence({'clear_persistence': true});
31940
31941 // check whether we should opt out by default
31942 // note: we don't clear persistence here by default since opt-out default state is often
31943 // used as an initial state while GDPR information is being collected
31944 } else if (!this.has_opted_in_tracking() && (
31945 this.get_config('opt_out_tracking_by_default') || _.cookie.get('mp_optout')
31946 )) {
31947 _.cookie.remove('mp_optout');
31948 this.opt_out_tracking({
31949 'clear_persistence': this.get_config('opt_out_persistence_by_default')
31950 });
31951 }
31952 };
31953
31954 /**
31955 * Enable or disable persistence based on options
31956 * only enable/disable if persistence is not already in this state
31957 * @param {boolean} [options.clear_persistence] If true, will delete all data stored by the sdk in persistence and disable it
31958 * @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
31959 */
31960 MixpanelLib.prototype._gdpr_update_persistence = function(options) {
31961 var disabled;
31962 if (options && options['clear_persistence']) {
31963 disabled = true;
31964 } else if (options && options['enable_persistence']) {
31965 disabled = false;
31966 } else {
31967 return;
31968 }
31969
31970 if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
31971 this['persistence'].set_disabled(disabled);
31972 }
31973
31974 if (disabled) {
31975 this.stop_batch_senders();
31976 this.stop_session_recording();
31977 } else {
31978 // only start batchers after opt-in if they have previously been started
31979 // in order to avoid unintentionally starting up batching for the first time
31980 if (this._batchers_were_started) {
31981 this.start_batch_senders();
31982 }
31983 }
31984 };
31985
31986 // call a base gdpr function after constructing the appropriate token and options args
31987 MixpanelLib.prototype._gdpr_call_func = function(func, options) {
31988 options = _.extend({
31989 'track': _.bind(this.track, this),
31990 'persistence_type': this.get_config('opt_out_tracking_persistence_type'),
31991 'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
31992 'cookie_expiration': this.get_config('cookie_expiration'),
31993 'cross_site_cookie': this.get_config('cross_site_cookie'),
31994 'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
31995 'cookie_domain': this.get_config('cookie_domain'),
31996 'secure_cookie': this.get_config('secure_cookie'),
31997 'ignore_dnt': this.get_config('ignore_dnt')
31998 }, options);
31999
32000 // check if localStorage can be used for recording opt out status, fall back to cookie if not
32001 if (!_.localStorage.is_supported()) {
32002 options['persistence_type'] = 'cookie';
32003 }
32004
32005 return func(this.get_config('token'), {
32006 track: options['track'],
32007 trackEventName: options['track_event_name'],
32008 trackProperties: options['track_properties'],
32009 persistenceType: options['persistence_type'],
32010 persistencePrefix: options['cookie_prefix'],
32011 cookieDomain: options['cookie_domain'],
32012 cookieExpiration: options['cookie_expiration'],
32013 crossSiteCookie: options['cross_site_cookie'],
32014 crossSubdomainCookie: options['cross_subdomain_cookie'],
32015 secureCookie: options['secure_cookie'],
32016 ignoreDnt: options['ignore_dnt']
32017 });
32018 };
32019
32020 /**
32021 * Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
32022 *
32023 * ### Usage:
32024 *
32025 * // opt user in
32026 * mixpanel.opt_in_tracking();
32027 *
32028 * // opt user in with specific event name, properties, cookie configuration
32029 * mixpanel.opt_in_tracking({
32030 * track_event_name: 'User opted in',
32031 * track_event_properties: {
32032 * 'Email': 'jdoe@example.com'
32033 * },
32034 * cookie_expiration: 30,
32035 * secure_cookie: true
32036 * });
32037 *
32038 * @param {Object} [options] A dictionary of config options to override
32039 * @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)
32040 * @param {string} [options.track_event_name=$opt_in] Event name to be used for tracking the opt-in action
32041 * @param {Object} [options.track_properties] Set of properties to be tracked along with the opt-in action
32042 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32043 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32044 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32045 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32046 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32047 * @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)
32048 * @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)
32049 * @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)
32050 */
32051 MixpanelLib.prototype.opt_in_tracking = function(options) {
32052 options = _.extend({
32053 'enable_persistence': true
32054 }, options);
32055
32056 this._gdpr_call_func(optIn, options);
32057 this._gdpr_update_persistence(options);
32058 };
32059
32060 /**
32061 * Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
32062 *
32063 * ### Usage:
32064 *
32065 * // opt user out
32066 * mixpanel.opt_out_tracking();
32067 *
32068 * // opt user out with different cookie configuration from Mixpanel instance
32069 * mixpanel.opt_out_tracking({
32070 * cookie_expiration: 30,
32071 * secure_cookie: true
32072 * });
32073 *
32074 * @param {Object} [options] A dictionary of config options to override
32075 * @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
32076 * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
32077 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32078 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32079 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32080 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32081 * @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)
32082 * @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)
32083 * @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)
32084 */
32085 MixpanelLib.prototype.opt_out_tracking = function(options) {
32086 options = _.extend({
32087 'clear_persistence': true,
32088 'delete_user': true
32089 }, options);
32090
32091 // delete user and clear charges since these methods may be disabled by opt-out
32092 if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
32093 this['people'].delete_user();
32094 this['people'].clear_charges();
32095 }
32096
32097 this._gdpr_call_func(optOut, options);
32098 this._gdpr_update_persistence(options);
32099 };
32100
32101 /**
32102 * Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
32103 *
32104 * ### Usage:
32105 *
32106 * var has_opted_in = mixpanel.has_opted_in_tracking();
32107 * // use has_opted_in value
32108 *
32109 * @param {Object} [options] A dictionary of config options to override
32110 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32111 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32112 * @returns {boolean} current opt-in status
32113 */
32114 MixpanelLib.prototype.has_opted_in_tracking = function(options) {
32115 return this._gdpr_call_func(hasOptedIn, options);
32116 };
32117
32118 /**
32119 * Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
32120 *
32121 * ### Usage:
32122 *
32123 * var has_opted_out = mixpanel.has_opted_out_tracking();
32124 * // use has_opted_out value
32125 *
32126 * @param {Object} [options] A dictionary of config options to override
32127 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32128 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32129 * @returns {boolean} current opt-out status
32130 */
32131 MixpanelLib.prototype.has_opted_out_tracking = function(options) {
32132 return this._gdpr_call_func(hasOptedOut, options);
32133 };
32134
32135 /**
32136 * Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
32137 *
32138 * ### Usage:
32139 *
32140 * // clear user's opt-in/out status
32141 * mixpanel.clear_opt_in_out_tracking();
32142 *
32143 * // clear user's opt-in/out status with specific cookie configuration - should match
32144 * // configuration used when opt_in_tracking/opt_out_tracking methods were called.
32145 * mixpanel.clear_opt_in_out_tracking({
32146 * cookie_expiration: 30,
32147 * secure_cookie: true
32148 * });
32149 *
32150 * @param {Object} [options] A dictionary of config options to override
32151 * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
32152 * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
32153 * @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
32154 * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this Mixpanel instance's config)
32155 * @param {string} [options.cookie_domain] Custom cookie domain (overrides value specified in this Mixpanel instance's config)
32156 * @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)
32157 * @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)
32158 * @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)
32159 */
32160 MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
32161 options = _.extend({
32162 'enable_persistence': true
32163 }, options);
32164
32165 this._gdpr_call_func(clearOptInOut, options);
32166 this._gdpr_update_persistence(options);
32167 };
32168
32169 MixpanelLib.prototype.report_error = function(msg, err) {
32170 console$1.error.apply(console$1.error, arguments);
32171 try {
32172 if (!err && !(msg instanceof Error)) {
32173 msg = new Error(msg);
32174 }
32175 this.get_config('error_reporter')(msg, err);
32176 } catch(err) {
32177 console$1.error(err);
32178 }
32179 };
32180
32181 // EXPORTS (for closure compiler)
32182
32183 // MixpanelLib Exports
32184 MixpanelLib.prototype['init'] = MixpanelLib.prototype.init;
32185 MixpanelLib.prototype['reset'] = MixpanelLib.prototype.reset;
32186 MixpanelLib.prototype['disable'] = MixpanelLib.prototype.disable;
32187 MixpanelLib.prototype['time_event'] = MixpanelLib.prototype.time_event;
32188 MixpanelLib.prototype['track'] = MixpanelLib.prototype.track;
32189 MixpanelLib.prototype['track_links'] = MixpanelLib.prototype.track_links;
32190 MixpanelLib.prototype['track_forms'] = MixpanelLib.prototype.track_forms;
32191 MixpanelLib.prototype['track_pageview'] = MixpanelLib.prototype.track_pageview;
32192 MixpanelLib.prototype['register'] = MixpanelLib.prototype.register;
32193 MixpanelLib.prototype['register_once'] = MixpanelLib.prototype.register_once;
32194 MixpanelLib.prototype['unregister'] = MixpanelLib.prototype.unregister;
32195 MixpanelLib.prototype['identify'] = MixpanelLib.prototype.identify;
32196 MixpanelLib.prototype['alias'] = MixpanelLib.prototype.alias;
32197 MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
32198 MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
32199 MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
32200 MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
32201 MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
32202 MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
32203 MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
32204 MixpanelLib.prototype['opt_out_tracking'] = MixpanelLib.prototype.opt_out_tracking;
32205 MixpanelLib.prototype['opt_in_tracking'] = MixpanelLib.prototype.opt_in_tracking;
32206 MixpanelLib.prototype['has_opted_out_tracking'] = MixpanelLib.prototype.has_opted_out_tracking;
32207 MixpanelLib.prototype['has_opted_in_tracking'] = MixpanelLib.prototype.has_opted_in_tracking;
32208 MixpanelLib.prototype['clear_opt_in_out_tracking'] = MixpanelLib.prototype.clear_opt_in_out_tracking;
32209 MixpanelLib.prototype['get_group'] = MixpanelLib.prototype.get_group;
32210 MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
32211 MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
32212 MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
32213 MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
32214 MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
32215 MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
32216 MixpanelLib.prototype['start_session_recording'] = MixpanelLib.prototype.start_session_recording;
32217 MixpanelLib.prototype['stop_session_recording'] = MixpanelLib.prototype.stop_session_recording;
32218 MixpanelLib.prototype['pause_session_recording'] = MixpanelLib.prototype.pause_session_recording;
32219 MixpanelLib.prototype['resume_session_recording'] = MixpanelLib.prototype.resume_session_recording;
32220 MixpanelLib.prototype['get_session_recording_properties'] = MixpanelLib.prototype.get_session_recording_properties;
32221 MixpanelLib.prototype['get_session_replay_url'] = MixpanelLib.prototype.get_session_replay_url;
32222 MixpanelLib.prototype['get_tab_id'] = MixpanelLib.prototype.get_tab_id;
32223 MixpanelLib.prototype['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
32224
32225 // Exports intended only for testing
32226 MixpanelLib.prototype['__get_recorder'] = MixpanelLib.prototype.__get_recorder;
32227
32228 // MixpanelPersistence Exports
32229 MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
32230 MixpanelPersistence.prototype['update_search_keyword'] = MixpanelPersistence.prototype.update_search_keyword;
32231 MixpanelPersistence.prototype['update_referrer_info'] = MixpanelPersistence.prototype.update_referrer_info;
32232 MixpanelPersistence.prototype['get_cross_subdomain'] = MixpanelPersistence.prototype.get_cross_subdomain;
32233 MixpanelPersistence.prototype['clear'] = MixpanelPersistence.prototype.clear;
32234
32235
32236 var instances = {};
32237 var extend_mp = function() {
32238 // add all the sub mixpanel instances
32239 _.each(instances, function(instance, name) {
32240 if (name !== PRIMARY_INSTANCE_NAME) { mixpanel_master[name] = instance; }
32241 });
32242
32243 // add private functions as _
32244 mixpanel_master['_'] = _;
32245 };
32246
32247 var override_mp_init_func = function() {
32248 // we override the snippets init function to handle the case where a
32249 // user initializes the mixpanel library after the script loads & runs
32250 mixpanel_master['init'] = function(token, config, name) {
32251 if (name) {
32252 // initialize a sub library
32253 if (!mixpanel_master[name]) {
32254 mixpanel_master[name] = instances[name] = create_mplib(token, config, name);
32255 mixpanel_master[name]._loaded();
32256 }
32257 return mixpanel_master[name];
32258 } else {
32259 var instance = mixpanel_master;
32260
32261 if (instances[PRIMARY_INSTANCE_NAME]) {
32262 // main mixpanel lib already initialized
32263 instance = instances[PRIMARY_INSTANCE_NAME];
32264 } else if (token) {
32265 // intialize the main mixpanel lib
32266 instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
32267 instance._loaded();
32268 instances[PRIMARY_INSTANCE_NAME] = instance;
32269 }
32270
32271 mixpanel_master = instance;
32272 if (init_type === INIT_SNIPPET) {
32273 win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
32274 }
32275 extend_mp();
32276 }
32277 };
32278 };
32279
32280 var add_dom_loaded_handler = function() {
32281 // Cross browser DOM Loaded support
32282 function dom_loaded_handler() {
32283 // function flag since we only want to execute this once
32284 if (dom_loaded_handler.done) { return; }
32285 dom_loaded_handler.done = true;
32286
32287 DOM_LOADED = true;
32288 ENQUEUE_REQUESTS = false;
32289
32290 _.each(instances, function(inst) {
32291 inst._dom_loaded();
32292 });
32293 }
32294
32295 function do_scroll_check() {
32296 try {
32297 document$1.documentElement.doScroll('left');
32298 } catch(e) {
32299 setTimeout(do_scroll_check, 1);
32300 return;
32301 }
32302
32303 dom_loaded_handler();
32304 }
32305
32306 if (document$1.addEventListener) {
32307 if (document$1.readyState === 'complete') {
32308 // safari 4 can fire the DOMContentLoaded event before loading all
32309 // external JS (including this file). you will see some copypasta
32310 // on the internet that checks for 'complete' and 'loaded', but
32311 // 'loaded' is an IE thing
32312 dom_loaded_handler();
32313 } else {
32314 document$1.addEventListener('DOMContentLoaded', dom_loaded_handler, false);
32315 }
32316 } else if (document$1.attachEvent) {
32317 // IE
32318 document$1.attachEvent('onreadystatechange', dom_loaded_handler);
32319
32320 // check to make sure we arn't in a frame
32321 var toplevel = false;
32322 try {
32323 toplevel = win.frameElement === null;
32324 } catch(e) {
32325 // noop
32326 }
32327
32328 if (document$1.documentElement.doScroll && toplevel) {
32329 do_scroll_check();
32330 }
32331 }
32332
32333 // fallback handler, always will work
32334 _.register_event(win, 'load', dom_loaded_handler, true);
32335 };
32336
32337 function init_as_module(bundle_loader) {
32338 load_extra_bundle = bundle_loader;
32339 init_type = INIT_MODULE;
32340 mixpanel_master = new MixpanelLib();
32341
32342 override_mp_init_func();
32343 mixpanel_master['init']();
32344 add_dom_loaded_handler();
32345
32346 return mixpanel_master;
32347 }
32348
32349 // For loading separate bundles asynchronously via script tag
32350 // so that we don't load them until they are needed at runtime.
32351
32352 // For builds that have everything in one bundle, no extra work.
32353 function loadNoop (_src, onload) {
32354 onload();
32355 }
32356
32357 /* eslint camelcase: "off" */
32358
32359 var mixpanel = init_as_module(loadNoop);
32360
32361
32362
32363
32364 /***/ }),
32365
32366 /***/ "../node_modules/redux-thunk/es/index.js":
32367 /*!***********************************************!*\
32368 !*** ../node_modules/redux-thunk/es/index.js ***!
32369 \***********************************************/
32370 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32371
32372 "use strict";
32373 __webpack_require__.r(__webpack_exports__);
32374 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32375 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
32376 /* harmony export */ });
32377 /** A function that accepts a potential "extra argument" value to be injected later,
32378 * and returns an instance of the thunk middleware that uses that value
32379 */
32380 function createThunkMiddleware(extraArgument) {
32381 // Standard Redux middleware definition pattern:
32382 // See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
32383 var middleware = function middleware(_ref) {
32384 var dispatch = _ref.dispatch,
32385 getState = _ref.getState;
32386 return function (next) {
32387 return function (action) {
32388 // The thunk middleware looks for any functions that were passed to `store.dispatch`.
32389 // If this "action" is really a function, call it and return the result.
32390 if (typeof action === 'function') {
32391 // Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
32392 return action(dispatch, getState, extraArgument);
32393 } // Otherwise, pass the action down the middleware chain as usual
32394
32395
32396 return next(action);
32397 };
32398 };
32399 };
32400
32401 return middleware;
32402 }
32403
32404 var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
32405 // with whatever "extra arg" they want to inject into their thunks
32406
32407 thunk.withExtraArgument = createThunkMiddleware;
32408 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (thunk);
32409
32410 /***/ }),
32411
32412 /***/ "../node_modules/redux/es/redux.js":
32413 /*!*****************************************!*\
32414 !*** ../node_modules/redux/es/redux.js ***!
32415 \*****************************************/
32416 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
32417
32418 "use strict";
32419 __webpack_require__.r(__webpack_exports__);
32420 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32421 /* harmony export */ __DO_NOT_USE__ActionTypes: () => (/* binding */ ActionTypes),
32422 /* harmony export */ applyMiddleware: () => (/* binding */ applyMiddleware),
32423 /* harmony export */ bindActionCreators: () => (/* binding */ bindActionCreators),
32424 /* harmony export */ combineReducers: () => (/* binding */ combineReducers),
32425 /* harmony export */ compose: () => (/* binding */ compose),
32426 /* harmony export */ createStore: () => (/* binding */ createStore),
32427 /* harmony export */ legacy_createStore: () => (/* binding */ legacy_createStore)
32428 /* harmony export */ });
32429 /* 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");
32430
32431
32432 /**
32433 * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
32434 *
32435 * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
32436 * during build.
32437 * @param {number} code
32438 */
32439 function formatProdErrorMessage(code) {
32440 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. ';
32441 }
32442
32443 // Inlined version of the `symbol-observable` polyfill
32444 var $$observable = (function () {
32445 return typeof Symbol === 'function' && Symbol.observable || '@@observable';
32446 })();
32447
32448 /**
32449 * These are private action types reserved by Redux.
32450 * For any unknown actions, you must return the current state.
32451 * If the current state is undefined, you must return the initial state.
32452 * Do not reference these action types directly in your code.
32453 */
32454 var randomString = function randomString() {
32455 return Math.random().toString(36).substring(7).split('').join('.');
32456 };
32457
32458 var ActionTypes = {
32459 INIT: "@@redux/INIT" + randomString(),
32460 REPLACE: "@@redux/REPLACE" + randomString(),
32461 PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
32462 return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
32463 }
32464 };
32465
32466 /**
32467 * @param {any} obj The object to inspect.
32468 * @returns {boolean} True if the argument appears to be a plain object.
32469 */
32470 function isPlainObject(obj) {
32471 if (typeof obj !== 'object' || obj === null) return false;
32472 var proto = obj;
32473
32474 while (Object.getPrototypeOf(proto) !== null) {
32475 proto = Object.getPrototypeOf(proto);
32476 }
32477
32478 return Object.getPrototypeOf(obj) === proto;
32479 }
32480
32481 // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
32482 function miniKindOf(val) {
32483 if (val === void 0) return 'undefined';
32484 if (val === null) return 'null';
32485 var type = typeof val;
32486
32487 switch (type) {
32488 case 'boolean':
32489 case 'string':
32490 case 'number':
32491 case 'symbol':
32492 case 'function':
32493 {
32494 return type;
32495 }
32496 }
32497
32498 if (Array.isArray(val)) return 'array';
32499 if (isDate(val)) return 'date';
32500 if (isError(val)) return 'error';
32501 var constructorName = ctorName(val);
32502
32503 switch (constructorName) {
32504 case 'Symbol':
32505 case 'Promise':
32506 case 'WeakMap':
32507 case 'WeakSet':
32508 case 'Map':
32509 case 'Set':
32510 return constructorName;
32511 } // other
32512
32513
32514 return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
32515 }
32516
32517 function ctorName(val) {
32518 return typeof val.constructor === 'function' ? val.constructor.name : null;
32519 }
32520
32521 function isError(val) {
32522 return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
32523 }
32524
32525 function isDate(val) {
32526 if (val instanceof Date) return true;
32527 return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
32528 }
32529
32530 function kindOf(val) {
32531 var typeOfVal = typeof val;
32532
32533 if (true) {
32534 typeOfVal = miniKindOf(val);
32535 }
32536
32537 return typeOfVal;
32538 }
32539
32540 /**
32541 * @deprecated
32542 *
32543 * **We recommend using the `configureStore` method
32544 * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
32545 *
32546 * Redux Toolkit is our recommended approach for writing Redux logic today,
32547 * including store setup, reducers, data fetching, and more.
32548 *
32549 * **For more details, please read this Redux docs page:**
32550 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32551 *
32552 * `configureStore` from Redux Toolkit is an improved version of `createStore` that
32553 * simplifies setup and helps avoid common bugs.
32554 *
32555 * You should not be using the `redux` core package by itself today, except for learning purposes.
32556 * The `createStore` method from the core `redux` package will not be removed, but we encourage
32557 * all users to migrate to using Redux Toolkit for all Redux code.
32558 *
32559 * If you want to use `createStore` without this visual deprecation warning, use
32560 * the `legacy_createStore` import instead:
32561 *
32562 * `import { legacy_createStore as createStore} from 'redux'`
32563 *
32564 */
32565
32566 function createStore(reducer, preloadedState, enhancer) {
32567 var _ref2;
32568
32569 if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
32570 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.');
32571 }
32572
32573 if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
32574 enhancer = preloadedState;
32575 preloadedState = undefined;
32576 }
32577
32578 if (typeof enhancer !== 'undefined') {
32579 if (typeof enhancer !== 'function') {
32580 throw new Error( false ? 0 : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
32581 }
32582
32583 return enhancer(createStore)(reducer, preloadedState);
32584 }
32585
32586 if (typeof reducer !== 'function') {
32587 throw new Error( false ? 0 : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
32588 }
32589
32590 var currentReducer = reducer;
32591 var currentState = preloadedState;
32592 var currentListeners = [];
32593 var nextListeners = currentListeners;
32594 var isDispatching = false;
32595 /**
32596 * This makes a shallow copy of currentListeners so we can use
32597 * nextListeners as a temporary list while dispatching.
32598 *
32599 * This prevents any bugs around consumers calling
32600 * subscribe/unsubscribe in the middle of a dispatch.
32601 */
32602
32603 function ensureCanMutateNextListeners() {
32604 if (nextListeners === currentListeners) {
32605 nextListeners = currentListeners.slice();
32606 }
32607 }
32608 /**
32609 * Reads the state tree managed by the store.
32610 *
32611 * @returns {any} The current state tree of your application.
32612 */
32613
32614
32615 function getState() {
32616 if (isDispatching) {
32617 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.');
32618 }
32619
32620 return currentState;
32621 }
32622 /**
32623 * Adds a change listener. It will be called any time an action is dispatched,
32624 * and some part of the state tree may potentially have changed. You may then
32625 * call `getState()` to read the current state tree inside the callback.
32626 *
32627 * You may call `dispatch()` from a change listener, with the following
32628 * caveats:
32629 *
32630 * 1. The subscriptions are snapshotted just before every `dispatch()` call.
32631 * If you subscribe or unsubscribe while the listeners are being invoked, this
32632 * will not have any effect on the `dispatch()` that is currently in progress.
32633 * However, the next `dispatch()` call, whether nested or not, will use a more
32634 * recent snapshot of the subscription list.
32635 *
32636 * 2. The listener should not expect to see all state changes, as the state
32637 * might have been updated multiple times during a nested `dispatch()` before
32638 * the listener is called. It is, however, guaranteed that all subscribers
32639 * registered before the `dispatch()` started will be called with the latest
32640 * state by the time it exits.
32641 *
32642 * @param {Function} listener A callback to be invoked on every dispatch.
32643 * @returns {Function} A function to remove this change listener.
32644 */
32645
32646
32647 function subscribe(listener) {
32648 if (typeof listener !== 'function') {
32649 throw new Error( false ? 0 : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
32650 }
32651
32652 if (isDispatching) {
32653 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.');
32654 }
32655
32656 var isSubscribed = true;
32657 ensureCanMutateNextListeners();
32658 nextListeners.push(listener);
32659 return function unsubscribe() {
32660 if (!isSubscribed) {
32661 return;
32662 }
32663
32664 if (isDispatching) {
32665 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.');
32666 }
32667
32668 isSubscribed = false;
32669 ensureCanMutateNextListeners();
32670 var index = nextListeners.indexOf(listener);
32671 nextListeners.splice(index, 1);
32672 currentListeners = null;
32673 };
32674 }
32675 /**
32676 * Dispatches an action. It is the only way to trigger a state change.
32677 *
32678 * The `reducer` function, used to create the store, will be called with the
32679 * current state tree and the given `action`. Its return value will
32680 * be considered the **next** state of the tree, and the change listeners
32681 * will be notified.
32682 *
32683 * The base implementation only supports plain object actions. If you want to
32684 * dispatch a Promise, an Observable, a thunk, or something else, you need to
32685 * wrap your store creating function into the corresponding middleware. For
32686 * example, see the documentation for the `redux-thunk` package. Even the
32687 * middleware will eventually dispatch plain object actions using this method.
32688 *
32689 * @param {Object} action A plain object representing “what changed”. It is
32690 * a good idea to keep actions serializable so you can record and replay user
32691 * sessions, or use the time travelling `redux-devtools`. An action must have
32692 * a `type` property which may not be `undefined`. It is a good idea to use
32693 * string constants for action types.
32694 *
32695 * @returns {Object} For convenience, the same action object you dispatched.
32696 *
32697 * Note that, if you use a custom middleware, it may wrap `dispatch()` to
32698 * return something else (for example, a Promise you can await).
32699 */
32700
32701
32702 function dispatch(action) {
32703 if (!isPlainObject(action)) {
32704 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.");
32705 }
32706
32707 if (typeof action.type === 'undefined') {
32708 throw new Error( false ? 0 : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
32709 }
32710
32711 if (isDispatching) {
32712 throw new Error( false ? 0 : 'Reducers may not dispatch actions.');
32713 }
32714
32715 try {
32716 isDispatching = true;
32717 currentState = currentReducer(currentState, action);
32718 } finally {
32719 isDispatching = false;
32720 }
32721
32722 var listeners = currentListeners = nextListeners;
32723
32724 for (var i = 0; i < listeners.length; i++) {
32725 var listener = listeners[i];
32726 listener();
32727 }
32728
32729 return action;
32730 }
32731 /**
32732 * Replaces the reducer currently used by the store to calculate the state.
32733 *
32734 * You might need this if your app implements code splitting and you want to
32735 * load some of the reducers dynamically. You might also need this if you
32736 * implement a hot reloading mechanism for Redux.
32737 *
32738 * @param {Function} nextReducer The reducer for the store to use instead.
32739 * @returns {void}
32740 */
32741
32742
32743 function replaceReducer(nextReducer) {
32744 if (typeof nextReducer !== 'function') {
32745 throw new Error( false ? 0 : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
32746 }
32747
32748 currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
32749 // Any reducers that existed in both the new and old rootReducer
32750 // will receive the previous state. This effectively populates
32751 // the new state tree with any relevant data from the old one.
32752
32753 dispatch({
32754 type: ActionTypes.REPLACE
32755 });
32756 }
32757 /**
32758 * Interoperability point for observable/reactive libraries.
32759 * @returns {observable} A minimal observable of state changes.
32760 * For more information, see the observable proposal:
32761 * https://github.com/tc39/proposal-observable
32762 */
32763
32764
32765 function observable() {
32766 var _ref;
32767
32768 var outerSubscribe = subscribe;
32769 return _ref = {
32770 /**
32771 * The minimal observable subscription method.
32772 * @param {Object} observer Any object that can be used as an observer.
32773 * The observer object should have a `next` method.
32774 * @returns {subscription} An object with an `unsubscribe` method that can
32775 * be used to unsubscribe the observable from the store, and prevent further
32776 * emission of values from the observable.
32777 */
32778 subscribe: function subscribe(observer) {
32779 if (typeof observer !== 'object' || observer === null) {
32780 throw new Error( false ? 0 : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
32781 }
32782
32783 function observeState() {
32784 if (observer.next) {
32785 observer.next(getState());
32786 }
32787 }
32788
32789 observeState();
32790 var unsubscribe = outerSubscribe(observeState);
32791 return {
32792 unsubscribe: unsubscribe
32793 };
32794 }
32795 }, _ref[$$observable] = function () {
32796 return this;
32797 }, _ref;
32798 } // When a store is created, an "INIT" action is dispatched so that every
32799 // reducer returns their initial state. This effectively populates
32800 // the initial state tree.
32801
32802
32803 dispatch({
32804 type: ActionTypes.INIT
32805 });
32806 return _ref2 = {
32807 dispatch: dispatch,
32808 subscribe: subscribe,
32809 getState: getState,
32810 replaceReducer: replaceReducer
32811 }, _ref2[$$observable] = observable, _ref2;
32812 }
32813 /**
32814 * Creates a Redux store that holds the state tree.
32815 *
32816 * **We recommend using `configureStore` from the
32817 * `@reduxjs/toolkit` package**, which replaces `createStore`:
32818 * **https://redux.js.org/introduction/why-rtk-is-redux-today**
32819 *
32820 * The only way to change the data in the store is to call `dispatch()` on it.
32821 *
32822 * There should only be a single store in your app. To specify how different
32823 * parts of the state tree respond to actions, you may combine several reducers
32824 * into a single reducer function by using `combineReducers`.
32825 *
32826 * @param {Function} reducer A function that returns the next state tree, given
32827 * the current state tree and the action to handle.
32828 *
32829 * @param {any} [preloadedState] The initial state. You may optionally specify it
32830 * to hydrate the state from the server in universal apps, or to restore a
32831 * previously serialized user session.
32832 * If you use `combineReducers` to produce the root reducer function, this must be
32833 * an object with the same shape as `combineReducers` keys.
32834 *
32835 * @param {Function} [enhancer] The store enhancer. You may optionally specify it
32836 * to enhance the store with third-party capabilities such as middleware,
32837 * time travel, persistence, etc. The only store enhancer that ships with Redux
32838 * is `applyMiddleware()`.
32839 *
32840 * @returns {Store} A Redux store that lets you read the state, dispatch actions
32841 * and subscribe to changes.
32842 */
32843
32844 var legacy_createStore = createStore;
32845
32846 /**
32847 * Prints a warning in the console if it exists.
32848 *
32849 * @param {String} message The warning message.
32850 * @returns {void}
32851 */
32852 function warning(message) {
32853 /* eslint-disable no-console */
32854 if (typeof console !== 'undefined' && typeof console.error === 'function') {
32855 console.error(message);
32856 }
32857 /* eslint-enable no-console */
32858
32859
32860 try {
32861 // This error was thrown as a convenience so that if you enable
32862 // "break on all exceptions" in your console,
32863 // it would pause the execution at this line.
32864 throw new Error(message);
32865 } catch (e) {} // eslint-disable-line no-empty
32866
32867 }
32868
32869 function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
32870 var reducerKeys = Object.keys(reducers);
32871 var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
32872
32873 if (reducerKeys.length === 0) {
32874 return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
32875 }
32876
32877 if (!isPlainObject(inputState)) {
32878 return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
32879 }
32880
32881 var unexpectedKeys = Object.keys(inputState).filter(function (key) {
32882 return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
32883 });
32884 unexpectedKeys.forEach(function (key) {
32885 unexpectedKeyCache[key] = true;
32886 });
32887 if (action && action.type === ActionTypes.REPLACE) return;
32888
32889 if (unexpectedKeys.length > 0) {
32890 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.");
32891 }
32892 }
32893
32894 function assertReducerShape(reducers) {
32895 Object.keys(reducers).forEach(function (key) {
32896 var reducer = reducers[key];
32897 var initialState = reducer(undefined, {
32898 type: ActionTypes.INIT
32899 });
32900
32901 if (typeof initialState === 'undefined') {
32902 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.");
32903 }
32904
32905 if (typeof reducer(undefined, {
32906 type: ActionTypes.PROBE_UNKNOWN_ACTION()
32907 }) === 'undefined') {
32908 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.");
32909 }
32910 });
32911 }
32912 /**
32913 * Turns an object whose values are different reducer functions, into a single
32914 * reducer function. It will call every child reducer, and gather their results
32915 * into a single state object, whose keys correspond to the keys of the passed
32916 * reducer functions.
32917 *
32918 * @param {Object} reducers An object whose values correspond to different
32919 * reducer functions that need to be combined into one. One handy way to obtain
32920 * it is to use ES6 `import * as reducers` syntax. The reducers may never return
32921 * undefined for any action. Instead, they should return their initial state
32922 * if the state passed to them was undefined, and the current state for any
32923 * unrecognized action.
32924 *
32925 * @returns {Function} A reducer function that invokes every reducer inside the
32926 * passed object, and builds a state object with the same shape.
32927 */
32928
32929
32930 function combineReducers(reducers) {
32931 var reducerKeys = Object.keys(reducers);
32932 var finalReducers = {};
32933
32934 for (var i = 0; i < reducerKeys.length; i++) {
32935 var key = reducerKeys[i];
32936
32937 if (true) {
32938 if (typeof reducers[key] === 'undefined') {
32939 warning("No reducer provided for key \"" + key + "\"");
32940 }
32941 }
32942
32943 if (typeof reducers[key] === 'function') {
32944 finalReducers[key] = reducers[key];
32945 }
32946 }
32947
32948 var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
32949 // keys multiple times.
32950
32951 var unexpectedKeyCache;
32952
32953 if (true) {
32954 unexpectedKeyCache = {};
32955 }
32956
32957 var shapeAssertionError;
32958
32959 try {
32960 assertReducerShape(finalReducers);
32961 } catch (e) {
32962 shapeAssertionError = e;
32963 }
32964
32965 return function combination(state, action) {
32966 if (state === void 0) {
32967 state = {};
32968 }
32969
32970 if (shapeAssertionError) {
32971 throw shapeAssertionError;
32972 }
32973
32974 if (true) {
32975 var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
32976
32977 if (warningMessage) {
32978 warning(warningMessage);
32979 }
32980 }
32981
32982 var hasChanged = false;
32983 var nextState = {};
32984
32985 for (var _i = 0; _i < finalReducerKeys.length; _i++) {
32986 var _key = finalReducerKeys[_i];
32987 var reducer = finalReducers[_key];
32988 var previousStateForKey = state[_key];
32989 var nextStateForKey = reducer(previousStateForKey, action);
32990
32991 if (typeof nextStateForKey === 'undefined') {
32992 var actionType = action && action.type;
32993 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.");
32994 }
32995
32996 nextState[_key] = nextStateForKey;
32997 hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
32998 }
32999
33000 hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
33001 return hasChanged ? nextState : state;
33002 };
33003 }
33004
33005 function bindActionCreator(actionCreator, dispatch) {
33006 return function () {
33007 return dispatch(actionCreator.apply(this, arguments));
33008 };
33009 }
33010 /**
33011 * Turns an object whose values are action creators, into an object with the
33012 * same keys, but with every function wrapped into a `dispatch` call so they
33013 * may be invoked directly. This is just a convenience method, as you can call
33014 * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
33015 *
33016 * For convenience, you can also pass an action creator as the first argument,
33017 * and get a dispatch wrapped function in return.
33018 *
33019 * @param {Function|Object} actionCreators An object whose values are action
33020 * creator functions. One handy way to obtain it is to use ES6 `import * as`
33021 * syntax. You may also pass a single function.
33022 *
33023 * @param {Function} dispatch The `dispatch` function available on your Redux
33024 * store.
33025 *
33026 * @returns {Function|Object} The object mimicking the original object, but with
33027 * every action creator wrapped into the `dispatch` call. If you passed a
33028 * function as `actionCreators`, the return value will also be a single
33029 * function.
33030 */
33031
33032
33033 function bindActionCreators(actionCreators, dispatch) {
33034 if (typeof actionCreators === 'function') {
33035 return bindActionCreator(actionCreators, dispatch);
33036 }
33037
33038 if (typeof actionCreators !== 'object' || actionCreators === null) {
33039 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\"?");
33040 }
33041
33042 var boundActionCreators = {};
33043
33044 for (var key in actionCreators) {
33045 var actionCreator = actionCreators[key];
33046
33047 if (typeof actionCreator === 'function') {
33048 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
33049 }
33050 }
33051
33052 return boundActionCreators;
33053 }
33054
33055 /**
33056 * Composes single-argument functions from right to left. The rightmost
33057 * function can take multiple arguments as it provides the signature for
33058 * the resulting composite function.
33059 *
33060 * @param {...Function} funcs The functions to compose.
33061 * @returns {Function} A function obtained by composing the argument functions
33062 * from right to left. For example, compose(f, g, h) is identical to doing
33063 * (...args) => f(g(h(...args))).
33064 */
33065 function compose() {
33066 for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
33067 funcs[_key] = arguments[_key];
33068 }
33069
33070 if (funcs.length === 0) {
33071 return function (arg) {
33072 return arg;
33073 };
33074 }
33075
33076 if (funcs.length === 1) {
33077 return funcs[0];
33078 }
33079
33080 return funcs.reduce(function (a, b) {
33081 return function () {
33082 return a(b.apply(void 0, arguments));
33083 };
33084 });
33085 }
33086
33087 /**
33088 * Creates a store enhancer that applies middleware to the dispatch method
33089 * of the Redux store. This is handy for a variety of tasks, such as expressing
33090 * asynchronous actions in a concise manner, or logging every action payload.
33091 *
33092 * See `redux-thunk` package as an example of the Redux middleware.
33093 *
33094 * Because middleware is potentially asynchronous, this should be the first
33095 * store enhancer in the composition chain.
33096 *
33097 * Note that each middleware will be given the `dispatch` and `getState` functions
33098 * as named arguments.
33099 *
33100 * @param {...Function} middlewares The middleware chain to be applied.
33101 * @returns {Function} A store enhancer applying the middleware.
33102 */
33103
33104 function applyMiddleware() {
33105 for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
33106 middlewares[_key] = arguments[_key];
33107 }
33108
33109 return function (createStore) {
33110 return function () {
33111 var store = createStore.apply(void 0, arguments);
33112
33113 var _dispatch = function dispatch() {
33114 throw new Error( false ? 0 : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
33115 };
33116
33117 var middlewareAPI = {
33118 getState: store.getState,
33119 dispatch: function dispatch() {
33120 return _dispatch.apply(void 0, arguments);
33121 }
33122 };
33123 var chain = middlewares.map(function (middleware) {
33124 return middleware(middlewareAPI);
33125 });
33126 _dispatch = compose.apply(void 0, chain)(store.dispatch);
33127 return (0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_babel_runtime_helpers_esm_objectSpread2__WEBPACK_IMPORTED_MODULE_0__["default"])({}, store), {}, {
33128 dispatch: _dispatch
33129 });
33130 };
33131 };
33132 }
33133
33134
33135
33136
33137 /***/ }),
33138
33139 /***/ "../node_modules/reselect/es/defaultMemoize.js":
33140 /*!*****************************************************!*\
33141 !*** ../node_modules/reselect/es/defaultMemoize.js ***!
33142 \*****************************************************/
33143 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33144
33145 "use strict";
33146 __webpack_require__.r(__webpack_exports__);
33147 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33148 /* harmony export */ createCacheKeyComparator: () => (/* binding */ createCacheKeyComparator),
33149 /* harmony export */ defaultEqualityCheck: () => (/* binding */ defaultEqualityCheck),
33150 /* harmony export */ defaultMemoize: () => (/* binding */ defaultMemoize)
33151 /* harmony export */ });
33152 // Cache implementation based on Erik Rasmussen's `lru-memoize`:
33153 // https://github.com/erikras/lru-memoize
33154 var NOT_FOUND = 'NOT_FOUND';
33155
33156 function createSingletonCache(equals) {
33157 var entry;
33158 return {
33159 get: function get(key) {
33160 if (entry && equals(entry.key, key)) {
33161 return entry.value;
33162 }
33163
33164 return NOT_FOUND;
33165 },
33166 put: function put(key, value) {
33167 entry = {
33168 key: key,
33169 value: value
33170 };
33171 },
33172 getEntries: function getEntries() {
33173 return entry ? [entry] : [];
33174 },
33175 clear: function clear() {
33176 entry = undefined;
33177 }
33178 };
33179 }
33180
33181 function createLruCache(maxSize, equals) {
33182 var entries = [];
33183
33184 function get(key) {
33185 var cacheIndex = entries.findIndex(function (entry) {
33186 return equals(key, entry.key);
33187 }); // We found a cached entry
33188
33189 if (cacheIndex > -1) {
33190 var entry = entries[cacheIndex]; // Cached entry not at top of cache, move it to the top
33191
33192 if (cacheIndex > 0) {
33193 entries.splice(cacheIndex, 1);
33194 entries.unshift(entry);
33195 }
33196
33197 return entry.value;
33198 } // No entry found in cache, return sentinel
33199
33200
33201 return NOT_FOUND;
33202 }
33203
33204 function put(key, value) {
33205 if (get(key) === NOT_FOUND) {
33206 // TODO Is unshift slow?
33207 entries.unshift({
33208 key: key,
33209 value: value
33210 });
33211
33212 if (entries.length > maxSize) {
33213 entries.pop();
33214 }
33215 }
33216 }
33217
33218 function getEntries() {
33219 return entries;
33220 }
33221
33222 function clear() {
33223 entries = [];
33224 }
33225
33226 return {
33227 get: get,
33228 put: put,
33229 getEntries: getEntries,
33230 clear: clear
33231 };
33232 }
33233
33234 var defaultEqualityCheck = function defaultEqualityCheck(a, b) {
33235 return a === b;
33236 };
33237 function createCacheKeyComparator(equalityCheck) {
33238 return function areArgumentsShallowlyEqual(prev, next) {
33239 if (prev === null || next === null || prev.length !== next.length) {
33240 return false;
33241 } // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.
33242
33243
33244 var length = prev.length;
33245
33246 for (var i = 0; i < length; i++) {
33247 if (!equalityCheck(prev[i], next[i])) {
33248 return false;
33249 }
33250 }
33251
33252 return true;
33253 };
33254 }
33255 // defaultMemoize now supports a configurable cache size with LRU behavior,
33256 // and optional comparison of the result value with existing values
33257 function defaultMemoize(func, equalityCheckOrOptions) {
33258 var providedOptions = typeof equalityCheckOrOptions === 'object' ? equalityCheckOrOptions : {
33259 equalityCheck: equalityCheckOrOptions
33260 };
33261 var _providedOptions$equa = providedOptions.equalityCheck,
33262 equalityCheck = _providedOptions$equa === void 0 ? defaultEqualityCheck : _providedOptions$equa,
33263 _providedOptions$maxS = providedOptions.maxSize,
33264 maxSize = _providedOptions$maxS === void 0 ? 1 : _providedOptions$maxS,
33265 resultEqualityCheck = providedOptions.resultEqualityCheck;
33266 var comparator = createCacheKeyComparator(equalityCheck);
33267 var cache = maxSize === 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator); // we reference arguments instead of spreading them for performance reasons
33268
33269 function memoized() {
33270 var value = cache.get(arguments);
33271
33272 if (value === NOT_FOUND) {
33273 // @ts-ignore
33274 value = func.apply(null, arguments);
33275
33276 if (resultEqualityCheck) {
33277 var entries = cache.getEntries();
33278 var matchingEntry = entries.find(function (entry) {
33279 return resultEqualityCheck(entry.value, value);
33280 });
33281
33282 if (matchingEntry) {
33283 value = matchingEntry.value;
33284 }
33285 }
33286
33287 cache.put(arguments, value);
33288 }
33289
33290 return value;
33291 }
33292
33293 memoized.clearCache = function () {
33294 return cache.clear();
33295 };
33296
33297 return memoized;
33298 }
33299
33300 /***/ }),
33301
33302 /***/ "../node_modules/reselect/es/index.js":
33303 /*!********************************************!*\
33304 !*** ../node_modules/reselect/es/index.js ***!
33305 \********************************************/
33306 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33307
33308 "use strict";
33309 __webpack_require__.r(__webpack_exports__);
33310 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33311 /* harmony export */ createSelector: () => (/* binding */ createSelector),
33312 /* harmony export */ createSelectorCreator: () => (/* binding */ createSelectorCreator),
33313 /* harmony export */ createStructuredSelector: () => (/* binding */ createStructuredSelector),
33314 /* harmony export */ defaultEqualityCheck: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultEqualityCheck),
33315 /* harmony export */ defaultMemoize: () => (/* reexport safe */ _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize)
33316 /* harmony export */ });
33317 /* harmony import */ var _defaultMemoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultMemoize */ "../node_modules/reselect/es/defaultMemoize.js");
33318
33319
33320
33321 function getDependencies(funcs) {
33322 var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs;
33323
33324 if (!dependencies.every(function (dep) {
33325 return typeof dep === 'function';
33326 })) {
33327 var dependencyTypes = dependencies.map(function (dep) {
33328 return typeof dep === 'function' ? "function " + (dep.name || 'unnamed') + "()" : typeof dep;
33329 }).join(', ');
33330 throw new Error("createSelector expects all input-selectors to be functions, but received the following types: [" + dependencyTypes + "]");
33331 }
33332
33333 return dependencies;
33334 }
33335
33336 function createSelectorCreator(memoize) {
33337 for (var _len = arguments.length, memoizeOptionsFromArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
33338 memoizeOptionsFromArgs[_key - 1] = arguments[_key];
33339 }
33340
33341 var createSelector = function createSelector() {
33342 for (var _len2 = arguments.length, funcs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
33343 funcs[_key2] = arguments[_key2];
33344 }
33345
33346 var _recomputations = 0;
33347
33348 var _lastResult; // Due to the intricacies of rest params, we can't do an optional arg after `...funcs`.
33349 // So, start by declaring the default value here.
33350 // (And yes, the words 'memoize' and 'options' appear too many times in this next sequence.)
33351
33352
33353 var directlyPassedOptions = {
33354 memoizeOptions: undefined
33355 }; // Normally, the result func or "output selector" is the last arg
33356
33357 var resultFunc = funcs.pop(); // If the result func is actually an _object_, assume it's our options object
33358
33359 if (typeof resultFunc === 'object') {
33360 directlyPassedOptions = resultFunc; // and pop the real result func off
33361
33362 resultFunc = funcs.pop();
33363 }
33364
33365 if (typeof resultFunc !== 'function') {
33366 throw new Error("createSelector expects an output function after the inputs, but received: [" + typeof resultFunc + "]");
33367 } // Determine which set of options we're using. Prefer options passed directly,
33368 // but fall back to options given to createSelectorCreator.
33369
33370
33371 var _directlyPassedOption = directlyPassedOptions,
33372 _directlyPassedOption2 = _directlyPassedOption.memoizeOptions,
33373 memoizeOptions = _directlyPassedOption2 === void 0 ? memoizeOptionsFromArgs : _directlyPassedOption2; // Simplifying assumption: it's unlikely that the first options arg of the provided memoizer
33374 // is an array. In most libs I've looked at, it's an equality function or options object.
33375 // Based on that, if `memoizeOptions` _is_ an array, we assume it's a full
33376 // user-provided array of options. Otherwise, it must be just the _first_ arg, and so
33377 // we wrap it in an array so we can apply it.
33378
33379 var finalMemoizeOptions = Array.isArray(memoizeOptions) ? memoizeOptions : [memoizeOptions];
33380 var dependencies = getDependencies(funcs);
33381 var memoizedResultFunc = memoize.apply(void 0, [function recomputationWrapper() {
33382 _recomputations++; // apply arguments instead of spreading for performance.
33383
33384 return resultFunc.apply(null, arguments);
33385 }].concat(finalMemoizeOptions)); // If a selector is called with the exact same arguments we don't need to traverse our dependencies again.
33386
33387 var selector = memoize(function dependenciesChecker() {
33388 var params = [];
33389 var length = dependencies.length;
33390
33391 for (var i = 0; i < length; i++) {
33392 // apply arguments instead of spreading and mutate a local list of params for performance.
33393 // @ts-ignore
33394 params.push(dependencies[i].apply(null, arguments));
33395 } // apply arguments instead of spreading for performance.
33396
33397
33398 _lastResult = memoizedResultFunc.apply(null, params);
33399 return _lastResult;
33400 });
33401 Object.assign(selector, {
33402 resultFunc: resultFunc,
33403 memoizedResultFunc: memoizedResultFunc,
33404 dependencies: dependencies,
33405 lastResult: function lastResult() {
33406 return _lastResult;
33407 },
33408 recomputations: function recomputations() {
33409 return _recomputations;
33410 },
33411 resetRecomputations: function resetRecomputations() {
33412 return _recomputations = 0;
33413 }
33414 });
33415 return selector;
33416 }; // @ts-ignore
33417
33418
33419 return createSelector;
33420 }
33421 var createSelector = /* #__PURE__ */createSelectorCreator(_defaultMemoize__WEBPACK_IMPORTED_MODULE_0__.defaultMemoize);
33422 // Manual definition of state and output arguments
33423 var createStructuredSelector = function createStructuredSelector(selectors, selectorCreator) {
33424 if (selectorCreator === void 0) {
33425 selectorCreator = createSelector;
33426 }
33427
33428 if (typeof selectors !== 'object') {
33429 throw new Error('createStructuredSelector expects first argument to be an object ' + ("where each property is a selector, instead received a " + typeof selectors));
33430 }
33431
33432 var objectKeys = Object.keys(selectors);
33433 var resultSelector = selectorCreator( // @ts-ignore
33434 objectKeys.map(function (key) {
33435 return selectors[key];
33436 }), function () {
33437 for (var _len3 = arguments.length, values = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
33438 values[_key3] = arguments[_key3];
33439 }
33440
33441 return values.reduce(function (composition, value, index) {
33442 composition[objectKeys[index]] = value;
33443 return composition;
33444 }, {});
33445 });
33446 return resultSelector;
33447 };
33448
33449 /***/ }),
33450
33451 /***/ "@wordpress/i18n":
33452 /*!**************************!*\
33453 !*** external "wp.i18n" ***!
33454 \**************************/
33455 /***/ ((module) => {
33456
33457 "use strict";
33458 module.exports = wp.i18n;
33459
33460 /***/ })
33461
33462 /******/ });
33463 /************************************************************************/
33464 /******/ // The module cache
33465 /******/ var __webpack_module_cache__ = {};
33466 /******/
33467 /******/ // The require function
33468 /******/ function __webpack_require__(moduleId) {
33469 /******/ // Check if module is in cache
33470 /******/ var cachedModule = __webpack_module_cache__[moduleId];
33471 /******/ if (cachedModule !== undefined) {
33472 /******/ return cachedModule.exports;
33473 /******/ }
33474 /******/ // Create a new module (and put it into the cache)
33475 /******/ var module = __webpack_module_cache__[moduleId] = {
33476 /******/ // no module.id needed
33477 /******/ // no module.loaded needed
33478 /******/ exports: {}
33479 /******/ };
33480 /******/
33481 /******/ // Execute the module function
33482 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33483 /******/
33484 /******/ // Return the exports of the module
33485 /******/ return module.exports;
33486 /******/ }
33487 /******/
33488 /************************************************************************/
33489 /******/ /* webpack/runtime/define property getters */
33490 /******/ (() => {
33491 /******/ // define getter functions for harmony exports
33492 /******/ __webpack_require__.d = (exports, definition) => {
33493 /******/ for(var key in definition) {
33494 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
33495 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
33496 /******/ }
33497 /******/ }
33498 /******/ };
33499 /******/ })();
33500 /******/
33501 /******/ /* webpack/runtime/global */
33502 /******/ (() => {
33503 /******/ __webpack_require__.g = (function() {
33504 /******/ if (typeof globalThis === 'object') return globalThis;
33505 /******/ try {
33506 /******/ return this || new Function('return this')();
33507 /******/ } catch (e) {
33508 /******/ if (typeof window === 'object') return window;
33509 /******/ }
33510 /******/ })();
33511 /******/ })();
33512 /******/
33513 /******/ /* webpack/runtime/hasOwnProperty shorthand */
33514 /******/ (() => {
33515 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
33516 /******/ })();
33517 /******/
33518 /******/ /* webpack/runtime/make namespace object */
33519 /******/ (() => {
33520 /******/ // define __esModule on exports
33521 /******/ __webpack_require__.r = (exports) => {
33522 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
33523 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33524 /******/ }
33525 /******/ Object.defineProperty(exports, '__esModule', { value: true });
33526 /******/ };
33527 /******/ })();
33528 /******/
33529 /************************************************************************/
33530 var __webpack_exports__ = {};
33531 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
33532 (() => {
33533 "use strict";
33534 /*!******************************************!*\
33535 !*** ../core/common/assets/js/common.js ***!
33536 \******************************************/
33537
33538
33539 var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "../node_modules/@babel/runtime/helpers/interopRequireDefault.js");
33540 var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "../node_modules/@babel/runtime/helpers/classCallCheck.js"));
33541 var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "../node_modules/@babel/runtime/helpers/createClass.js"));
33542 var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"));
33543 var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "../node_modules/@babel/runtime/helpers/getPrototypeOf.js"));
33544 var _get2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/get */ "../node_modules/@babel/runtime/helpers/get.js"));
33545 var _inherits2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inherits */ "../node_modules/@babel/runtime/helpers/inherits.js"));
33546 var _helpers = _interopRequireDefault(__webpack_require__(/*! ./utils/helpers */ "../core/common/assets/js/utils/helpers.js"));
33547 var _storage = _interopRequireDefault(__webpack_require__(/*! ./utils/storage */ "../core/common/assets/js/utils/storage.js"));
33548 var _debug = _interopRequireDefault(__webpack_require__(/*! ./utils/debug */ "../core/common/assets/js/utils/debug.js"));
33549 var _ajax = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/ajax/assets/js/ajax */ "../core/common/modules/ajax/assets/js/ajax.js"));
33550 var _finder = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/finder/assets/js/finder */ "../core/common/modules/finder/assets/js/finder.js"));
33551 var _connect = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/connect/assets/js/connect */ "../core/common/modules/connect/assets/js/connect.js"));
33552 var _component = _interopRequireDefault(__webpack_require__(/*! ./components/wordpress/component */ "../core/common/assets/js/components/wordpress/component.js"));
33553 var _component2 = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/data/component */ "../core/common/modules/event-tracker/assets/js/data/component.js"));
33554 var _events = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/event-tracker/assets/js/events */ "../core/common/modules/event-tracker/assets/js/events.js"));
33555 var _module = _interopRequireDefault(__webpack_require__(/*! elementor-common-modules/events-manager/assets/js/module */ "../core/common/modules/events-manager/assets/js/module.js"));
33556 var _notifications = _interopRequireDefault(__webpack_require__(/*! elementor-utils/notifications */ "../assets/dev/js/utils/notifications.js"));
33557 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)); }
33558 function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
33559 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; }
33560 var ElementorCommonApp = /*#__PURE__*/function (_elementorModules$Vie) {
33561 function ElementorCommonApp() {
33562 (0, _classCallCheck2.default)(this, ElementorCommonApp);
33563 return _callSuper(this, ElementorCommonApp, arguments);
33564 }
33565 (0, _inherits2.default)(ElementorCommonApp, _elementorModules$Vie);
33566 return (0, _createClass2.default)(ElementorCommonApp, [{
33567 key: "setMarionetteTemplateCompiler",
33568 value: function setMarionetteTemplateCompiler() {
33569 Marionette.TemplateCache.prototype.compileTemplate = function (rawTemplate, options) {
33570 options = {
33571 evaluate: /<#([\s\S]+?)#>/g,
33572 interpolate: /{{{([\s\S]+?)}}}/g,
33573 escape: /{{([^}]+?)}}(?!})/g
33574 };
33575 return _.template(rawTemplate, options);
33576 };
33577 }
33578 }, {
33579 key: "getDefaultElements",
33580 value: function getDefaultElements() {
33581 return {
33582 $window: jQuery(window),
33583 $document: jQuery(document),
33584 $body: jQuery(document.body)
33585 };
33586 }
33587 }, {
33588 key: "initComponents",
33589 value: function initComponents() {
33590 this.events = new _events.default();
33591 this.eventsManager = new _module.default();
33592 this.debug = new _debug.default();
33593 this.helpers = new _helpers.default();
33594 this.storage = new _storage.default();
33595 this.dialogsManager = new DialogsManager.Instance();
33596 this.notifications = new _notifications.default();
33597 this.api = window.$e;
33598 $e.components.register(new _component2.default());
33599 elementorCommon.elements.$window.on('elementor:init-components', function () {
33600 $e.components.register(new _component.default());
33601 });
33602 this.initModules();
33603 }
33604 }, {
33605 key: "initModules",
33606 value: function initModules() {
33607 var _this = this;
33608 var activeModules = this.config.activeModules;
33609 var modules = {
33610 ajax: _ajax.default,
33611 finder: _finder.default,
33612 connect: _connect.default
33613 };
33614 activeModules.forEach(function (name) {
33615 if (modules[name]) {
33616 _this[name] = new modules[name](_this.config[name]);
33617 }
33618 });
33619 }
33620 }, {
33621 key: "compileArrayTemplateArgs",
33622 value: function compileArrayTemplateArgs(template, templateArgs) {
33623 return template.replace(/%(?:(\d+)\$)?s/g, function (match, number) {
33624 if (!number) {
33625 number = 1;
33626 }
33627 number--;
33628 return undefined !== templateArgs[number] ? templateArgs[number] : match;
33629 });
33630 }
33631 }, {
33632 key: "compileObjectTemplateArgs",
33633 value: function compileObjectTemplateArgs(template, templateArgs) {
33634 return template.replace(/{{(?:([ \w]+))}}/g, function (match, name) {
33635 return templateArgs[name] ? templateArgs[name] : match;
33636 });
33637 }
33638 }, {
33639 key: "compileTemplate",
33640 value: function compileTemplate(template, templateArgs) {
33641 return jQuery.isPlainObject(templateArgs) ? this.compileObjectTemplateArgs(template, templateArgs) : this.compileArrayTemplateArgs(template, templateArgs);
33642 }
33643 }, {
33644 key: "translate",
33645 value: function translate(stringKey, context, templateArgs, i18nStack) {
33646 if (context) {
33647 i18nStack = this.config[context].i18n;
33648 }
33649 if (!i18nStack) {
33650 i18nStack = this.config.i18n;
33651 }
33652 var string = i18nStack[stringKey];
33653 if (undefined === string) {
33654 string = stringKey;
33655 }
33656 if (templateArgs) {
33657 string = this.compileTemplate(string, templateArgs);
33658 }
33659 return string;
33660 }
33661 }, {
33662 key: "onInit",
33663 value: function onInit() {
33664 _superPropGet(ElementorCommonApp, "onInit", this, 3)([]);
33665 this.config = elementorCommonConfig;
33666 this.setMarionetteTemplateCompiler();
33667 }
33668 }]);
33669 }(elementorModules.ViewModule);
33670 window.elementorCommon = new ElementorCommonApp();
33671 elementorCommon.initComponents();
33672 })();
33673
33674 /******/ })()
33675 ;
33676 //# sourceMappingURL=common.js.map