PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
learnpress / assets / js / dist / admin / addons.js

addons.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.9, at assets/js/dist/admin/addons.js

2,058 lines 68.9 KB
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/src/js/lpToastify.js"
5 /*!*************************************!*\
6 !*** ./assets/src/js/lpToastify.js ***!
7 \*************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ show: () => (/* binding */ show)
14 /* harmony export */ });
15 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
16 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
17 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
18 /**
19 * Utils functions
20 *
21 * @param url
22 * @param data
23 * @param functions
24 * @since 4.3.0
25 * @version 1.0.0
26 */
27
28
29 const argsToastify = {
30 text: '',
31 gravity: lpData.toast.gravity,
32 // `top` or `bottom`
33 position: lpData.toast.position,
34 // `left`, `center` or `right`
35 className: `${lpData.toast.classPrefix}`,
36 close: lpData.toast.close == 1,
37 stopOnFocus: lpData.toast.stopOnFocus == 1,
38 duration: lpData.toast.duration
39 };
40 const show = (message, status = 'success', argsCustom) => {
41 let args = argsToastify;
42 if (argsCustom) {
43 args = {
44 ...args,
45 ...argsCustom
46 };
47 }
48 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
49 ...args,
50 text: message,
51 className: `${lpData.toast.classPrefix} ${status}`
52 });
53 toastify.showToast();
54 };
55
56 /***/ },
57
58 /***/ "./assets/src/js/utils.js"
59 /*!********************************!*\
60 !*** ./assets/src/js/utils.js ***!
61 \********************************/
62 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
63
64 "use strict";
65 __webpack_require__.r(__webpack_exports__);
66 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
67 /* harmony export */ debounce: () => (/* binding */ debounce),
68 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
69 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
70 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
71 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
72 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
73 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
74 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
75 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
76 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
77 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
78 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
79 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
80 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
81 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
82 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
83 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
84 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
85 /* harmony export */ });
86 /**
87 * Utils functions
88 *
89 * @param url
90 * @param data
91 * @param functions
92 * @since 4.2.5.1
93 * @version 1.0.7
94 */
95 const lpClassName = {
96 hidden: 'lp-hidden',
97 loading: 'loading',
98 elCollapse: 'lp-collapse',
99 elSectionToggle: '.lp-section-toggle',
100 elTriggerToggle: '.lp-trigger-toggle',
101 elBtnFullScreen: '.lp-btn-full-screen-view',
102 elFullScreen: 'lp-full-screen-view',
103 elBtnFullScreenClose: 'lp-full-screen-view__close'
104 };
105 const lpFetchAPI = (url, data = {}, functions = {}) => {
106 if ('function' === typeof functions.before) {
107 functions.before();
108 }
109 fetch(url, {
110 method: 'GET',
111 ...data
112 }).then(response => response.json()).then(response => {
113 if ('function' === typeof functions.success) {
114 functions.success(response);
115 }
116 }).catch(err => {
117 if ('function' === typeof functions.error) {
118 functions.error(err);
119 }
120 }).finally(() => {
121 if ('function' === typeof functions.completed) {
122 functions.completed();
123 }
124 });
125 };
126
127 /**
128 * Get current URL without params.
129 *
130 * @since 4.2.5.1
131 */
132 const lpGetCurrentURLNoParam = () => {
133 let currentUrl = window.location.href;
134 const hasParams = currentUrl.includes('?');
135 if (hasParams) {
136 currentUrl = currentUrl.split('?')[0];
137 }
138 return currentUrl;
139 };
140 const lpAddQueryArgs = (endpoint, args) => {
141 const url = new URL(endpoint);
142 Object.keys(args).forEach(arg => {
143 url.searchParams.set(arg, args[arg]);
144 });
145 return url;
146 };
147
148 /**
149 * Listen element viewed.
150 *
151 * @param el
152 * @param callback
153 * @since 4.2.5.8
154 */
155 const listenElementViewed = (el, callback) => {
156 const observerSeeItem = new IntersectionObserver(function (entries) {
157 for (const entry of entries) {
158 if (entry.isIntersecting) {
159 callback(entry);
160 }
161 }
162 });
163 observerSeeItem.observe(el);
164 };
165
166 /**
167 * Listen element created.
168 *
169 * @param callback
170 * @since 4.2.5.8
171 */
172 const listenElementCreated = callback => {
173 const observerCreateItem = new MutationObserver(function (mutations) {
174 mutations.forEach(function (mutation) {
175 if (mutation.addedNodes) {
176 mutation.addedNodes.forEach(function (node) {
177 if (node.nodeType === 1) {
178 callback(node);
179 }
180 });
181 }
182 });
183 });
184 observerCreateItem.observe(document, {
185 childList: true,
186 subtree: true
187 });
188 // End.
189 };
190
191 /**
192 * Listen element created.
193 *
194 * @param selector
195 * @param callback
196 * @since 4.2.7.1
197 */
198 const lpOnElementReady = (selector, callback) => {
199 const element = document.querySelector(selector);
200 if (element) {
201 callback(element);
202 return;
203 }
204 const observer = new MutationObserver((mutations, obs) => {
205 const element = document.querySelector(selector);
206 if (element) {
207 obs.disconnect();
208 callback(element);
209 }
210 });
211 observer.observe(document.documentElement, {
212 childList: true,
213 subtree: true
214 });
215 };
216
217 // Parse JSON from string with content include LP_AJAX_START.
218 const lpAjaxParseJsonOld = data => {
219 if (typeof data !== 'string') {
220 return data;
221 }
222 const m = String.raw({
223 raw: data
224 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
225 try {
226 if (m) {
227 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
228 } else {
229 data = JSON.parse(data);
230 }
231 } catch (e) {
232 data = {};
233 }
234 return data;
235 };
236
237 // status 0: hide, 1: show
238 const lpShowHideEl = (el, status = 0) => {
239 if (!el) {
240 return;
241 }
242 if (!status) {
243 el.classList.add(lpClassName.hidden);
244 } else {
245 el.classList.remove(lpClassName.hidden);
246 }
247 };
248
249 // status 0: hide, 1: show
250 const lpSetLoadingEl = (el, status) => {
251 if (!el) {
252 return;
253 }
254 if (!status) {
255 el.classList.remove(lpClassName.loading);
256 } else {
257 el.classList.add(lpClassName.loading);
258 }
259 };
260
261 // Toggle collapse section
262 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
263 if (!elTriggerClassName) {
264 elTriggerClassName = lpClassName.elTriggerToggle;
265 }
266
267 // Exclude elements, which should not trigger the collapse toggle
268 if (elsExclude && elsExclude.length > 0) {
269 for (const elExclude of elsExclude) {
270 if (target.closest(elExclude)) {
271 return;
272 }
273 }
274 }
275 const elTrigger = target.closest(elTriggerClassName);
276 if (!elTrigger) {
277 return;
278 }
279
280 //console.log( 'elTrigger', elTrigger );
281
282 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
283 if (!elSectionToggle) {
284 return;
285 }
286 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
287 if ('function' === typeof callback) {
288 callback(elSectionToggle);
289 }
290 };
291
292 // Get data of form
293 const getDataOfForm = form => {
294 const dataSend = {};
295 const formData = new FormData(form);
296 for (const pair of formData.entries()) {
297 const key = pair[0];
298 const value = formData.getAll(key);
299 if (!dataSend.hasOwnProperty(key)) {
300 // Convert value array to string.
301 dataSend[key] = value.join(',');
302 }
303 }
304 return dataSend;
305 };
306
307 // Get field keys of form
308 const getFieldKeysOfForm = form => {
309 const keys = [];
310 const elements = form.elements;
311 for (let i = 0; i < elements.length; i++) {
312 const name = elements[i].name;
313 if (name && !keys.includes(name)) {
314 keys.push(name);
315 }
316 }
317 return keys;
318 };
319
320 // Merge data handle with data form.
321 const mergeDataWithDatForm = (elForm, dataHandle) => {
322 const dataForm = getDataOfForm(elForm);
323 const keys = getFieldKeysOfForm(elForm);
324 keys.forEach(key => {
325 if (!dataForm.hasOwnProperty(key)) {
326 delete dataHandle[key];
327 } else if (dataForm[key][0] === '') {
328 delete dataForm[key];
329 delete dataHandle[key];
330 }
331 });
332 dataHandle = {
333 ...dataHandle,
334 ...dataForm
335 };
336 return dataHandle;
337 };
338
339 /**
340 * Event trigger
341 * For each list of event handlers, listen event on document.
342 *
343 * eventName: 'click', 'change', ...
344 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
345 *
346 * @param eventName
347 * @param eventHandlers
348 */
349 const eventHandlers = (eventName, eventHandlers) => {
350 document.addEventListener(eventName, e => {
351 const target = e.target;
352 let args = {
353 e,
354 target
355 };
356 eventHandlers.forEach(eventHandler => {
357 args = {
358 ...args,
359 ...eventHandler
360 };
361
362 //console.log( args );
363
364 // Check condition before call back
365 if (eventHandler.conditionBeforeCallBack) {
366 if (eventHandler.conditionBeforeCallBack(args) !== true) {
367 return;
368 }
369 }
370
371 // Special check for keydown event with checkIsEventEnter = true
372 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
373 if (e.key !== 'Enter') {
374 return;
375 }
376 }
377 if (target.closest(eventHandler.selector)) {
378 if (eventHandler.class) {
379 // Call method of class, function callBack will understand exactly {this} is class object.
380 eventHandler.class[eventHandler.callBack](args);
381 } else {
382 // For send args is objected, {this} is eventHandler object, not class object.
383 eventHandler.callBack(args);
384 }
385 }
386 });
387 });
388 };
389
390 /**
391 * Debounce - delays function execution until after `wait` ms of inactivity.
392 *
393 * Each call resets the timer. Only the last call in a burst executes.
394 *
395 * USE CASES:
396 * - Search inputs, form validation, window resize
397 * - Multiple elements need independent timers
398 * - When you need to call with different arguments
399 *
400 * EXAMPLES:
401 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
402 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
403 *
404 * const debouncedResize = debounce( recalculateLayout, 250 );
405 * window.addEventListener('resize', debouncedResize);
406 *
407 * ⚠️ Create ONCE outside event handlers, not inside.
408 *
409 * @param {Function} func - Function to debounce (can be anonymous)
410 * @param {number} wait - Milliseconds to wait (default: 500)
411 * @return {Function} Debounced wrapper function
412 * @since 4.3.7
413 * @version 1.0.0
414 */
415 const debounce = (func, wait = 500) => {
416 let timer;
417 return args => {
418 clearTimeout(timer);
419 timer = setTimeout(() => func(args), wait);
420 };
421 };
422
423 /**
424 * Initialize lp-toggle-enable components.
425 *
426 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
427 * Reads initial state from `data-enabled` attribute ("true"/"false").
428 * Calls `data-on-toggle` callback (if provided via options) on state change.
429 *
430 * HTML structure:
431 * <label class="lp-toggle-enable" data-enabled="true">
432 * <input type="checkbox" class="lp-toggle-enable__input" />
433 * <span class="lp-toggle-enable__track"></span>
434 * </label>
435 *
436 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
437 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
438 * @since 4.4.5
439 * @version 1.0.0
440 */
441 window.lpToggleEnableInit = 0;
442 const toggleEnable = (onToggle = null) => {
443 if (window.lpToggleEnableInit) {
444 return;
445 }
446 window.lpToggleEnableInit = 1;
447 const selector = '.lp-toggle-enable';
448 const updateUI = (toggle, isEnabled) => {
449 toggle.classList.toggle('is-enabled', isEnabled);
450 const input = toggle.querySelector('.lp-toggle-enable__input');
451 if (input) {
452 input.checked = isEnabled;
453 input.value = isEnabled ? '1' : '0';
454 }
455 };
456
457 // Delegate click handling via eventHandlers.
458 eventHandlers('click', [{
459 selector,
460 callBack: args => {
461 const {
462 e,
463 target
464 } = args;
465 const toggle = target.closest(selector);
466 if (!toggle || toggle.classList.contains('is-disabled')) {
467 return;
468 }
469 e.preventDefault();
470 const isEnabled = !toggle.classList.contains('is-enabled');
471 updateUI(toggle, isEnabled);
472 if ('function' === typeof onToggle) {
473 onToggle(toggle, isEnabled);
474 }
475 }
476 }]);
477 };
478
479 /**
480 * Initialize custom fullscreen view buttons.
481 *
482 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
483 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
484 * target element. Falls back to the button's parent element when
485 * `data-target` is not provided.
486 *
487 * @since 4.4.5
488 * @version 1.0.0
489 */
490 window.lpFullScreenViewInit = 0;
491 const fullScreenView = () => {
492 if (window.lpFullScreenViewInit) {
493 return;
494 }
495 window.lpFullScreenViewInit = 1;
496 let lastScrollY = 0;
497 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
498 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
499 if (isFullscreen) {
500 elTarget.classList.remove(lpClassName.elFullScreen);
501 document.documentElement.classList.remove('lp-full-screen-active');
502 window.scrollTo(0, lastScrollY);
503 } else {
504 lastScrollY = window.scrollY;
505 elTarget.classList.add(lpClassName.elFullScreen);
506 document.documentElement.classList.add('lp-full-screen-active');
507 }
508 if (!isFullscreen) {
509 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
510 const closeButton = document.createElement('button');
511 closeButton.type = 'button';
512 closeButton.className = lpClassName.elBtnFullScreenClose;
513 closeButton.setAttribute('aria-label', 'Close');
514 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
515 closeButton.addEventListener('click', e => {
516 e.preventDefault();
517 lpToggleFullscreenView(elTarget);
518 });
519 elTarget.appendChild(closeButton);
520 }
521 } else {
522 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
523 if (closeButton) {
524 closeButton.remove();
525 }
526 }
527 };
528 eventHandlers('click', [{
529 selector: lpClassName.elBtnFullScreen,
530 callBack: args => {
531 const {
532 e,
533 target
534 } = args;
535 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
536 if (!elBtnFullScreen) {
537 console.log('No full screen button found');
538 return;
539 }
540 e.preventDefault();
541 let elTarget = null;
542 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
543 console.log(targetSelector);
544 if (targetSelector) {
545 elTarget = document.querySelector(targetSelector);
546 }
547 if (!elTarget) {
548 console.log('No target element found');
549 return;
550 }
551 lpToggleFullscreenView(elTarget, elBtnFullScreen);
552 }
553 }]);
554 };
555
556 /***/ },
557
558 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
559 /*!*****************************************************************************************!*\
560 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
561 \*****************************************************************************************/
562 (module, __webpack_exports__, __webpack_require__) {
563
564 "use strict";
565 __webpack_require__.r(__webpack_exports__);
566 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
567 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
568 /* harmony export */ });
569 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
570 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
571 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
572 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
573 // Imports
574
575
576 var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
577 // Module
578 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
579 * Toastify js 1.12.0
580 * https://github.com/apvarun/toastify-js
581 * @license MIT licensed
582 *
583 * Copyright (C) 2018 Varun A P
584 */
585
586 .toastify {
587 padding: 12px 20px;
588 color: #ffffff;
589 display: inline-block;
590 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
591 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
592 background: linear-gradient(135deg, #73a5ff, #5477f5);
593 position: fixed;
594 opacity: 0;
595 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
596 border-radius: 2px;
597 cursor: pointer;
598 text-decoration: none;
599 max-width: calc(50% - 20px);
600 z-index: 2147483647;
601 }
602
603 .toastify.on {
604 opacity: 1;
605 }
606
607 .toast-close {
608 background: transparent;
609 border: 0;
610 color: white;
611 cursor: pointer;
612 font-family: inherit;
613 font-size: 1em;
614 opacity: 0.4;
615 padding: 0 5px;
616 }
617
618 .toastify-right {
619 right: 15px;
620 }
621
622 .toastify-left {
623 left: 15px;
624 }
625
626 .toastify-top {
627 top: -150px;
628 }
629
630 .toastify-bottom {
631 bottom: -150px;
632 }
633
634 .toastify-rounded {
635 border-radius: 25px;
636 }
637
638 .toastify-avatar {
639 width: 1.5em;
640 height: 1.5em;
641 margin: -7px 5px;
642 border-radius: 2px;
643 }
644
645 .toastify-center {
646 margin-left: auto;
647 margin-right: auto;
648 left: 0;
649 right: 0;
650 max-width: fit-content;
651 max-width: -moz-fit-content;
652 }
653
654 @media only screen and (max-width: 360px) {
655 .toastify-right, .toastify-left {
656 margin-left: auto;
657 margin-right: auto;
658 left: 0;
659 right: 0;
660 max-width: fit-content;
661 }
662 }
663 `, "",{"version":3,"sources":["webpack://./node_modules/toastify-js/src/toastify.css"],"names":[],"mappings":"AAAA;;;;;;EAME;;AAEF;IACI,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,uFAAuF;IACvF,6DAA6D;IAC7D,qDAAqD;IACrD,eAAe;IACf,UAAU;IACV,wDAAwD;IACxD,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,2BAA2B;IAC3B,mBAAmB;AACvB;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,uBAAuB;IACvB,SAAS;IACT,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,cAAc;AAClB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,sBAAsB;IACtB,2BAA2B;AAC/B;;AAEA;IACI;QACI,iBAAiB;QACjB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,sBAAsB;IAC1B;AACJ","sourcesContent":["/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n"],"sourceRoot":""}]);
664 // Exports
665 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
666
667
668 /***/ },
669
670 /***/ "./node_modules/css-loader/dist/runtime/api.js"
671 /*!*****************************************************!*\
672 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
673 \*****************************************************/
674 (module) {
675
676 "use strict";
677
678
679 /*
680 MIT License http://www.opensource.org/licenses/mit-license.php
681 Author Tobias Koppers @sokra
682 */
683 module.exports = function (cssWithMappingToString) {
684 var list = [];
685
686 // return the list of modules as css string
687 list.toString = function toString() {
688 return this.map(function (item) {
689 var content = "";
690 var needLayer = typeof item[5] !== "undefined";
691 if (item[4]) {
692 content += "@supports (".concat(item[4], ") {");
693 }
694 if (item[2]) {
695 content += "@media ".concat(item[2], " {");
696 }
697 if (needLayer) {
698 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
699 }
700 content += cssWithMappingToString(item);
701 if (needLayer) {
702 content += "}";
703 }
704 if (item[2]) {
705 content += "}";
706 }
707 if (item[4]) {
708 content += "}";
709 }
710 return content;
711 }).join("");
712 };
713
714 // import a list of modules into the list
715 list.i = function i(modules, media, dedupe, supports, layer) {
716 if (typeof modules === "string") {
717 modules = [[null, modules, undefined]];
718 }
719 var alreadyImportedModules = {};
720 if (dedupe) {
721 for (var k = 0; k < this.length; k++) {
722 var id = this[k][0];
723 if (id != null) {
724 alreadyImportedModules[id] = true;
725 }
726 }
727 }
728 for (var _k = 0; _k < modules.length; _k++) {
729 var item = [].concat(modules[_k]);
730 if (dedupe && alreadyImportedModules[item[0]]) {
731 continue;
732 }
733 if (typeof layer !== "undefined") {
734 if (typeof item[5] === "undefined") {
735 item[5] = layer;
736 } else {
737 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
738 item[5] = layer;
739 }
740 }
741 if (media) {
742 if (!item[2]) {
743 item[2] = media;
744 } else {
745 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
746 item[2] = media;
747 }
748 }
749 if (supports) {
750 if (!item[4]) {
751 item[4] = "".concat(supports);
752 } else {
753 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
754 item[4] = supports;
755 }
756 }
757 list.push(item);
758 }
759 };
760 return list;
761 };
762
763 /***/ },
764
765 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
766 /*!************************************************************!*\
767 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
768 \************************************************************/
769 (module) {
770
771 "use strict";
772
773
774 module.exports = function (item) {
775 var content = item[1];
776 var cssMapping = item[3];
777 if (!cssMapping) {
778 return content;
779 }
780 if (typeof btoa === "function") {
781 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
782 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
783 var sourceMapping = "/*# ".concat(data, " */");
784 return [content].concat([sourceMapping]).join("\n");
785 }
786 return [content].join("\n");
787 };
788
789 /***/ },
790
791 /***/ "./node_modules/toastify-js/src/toastify.css"
792 /*!***************************************************!*\
793 !*** ./node_modules/toastify-js/src/toastify.css ***!
794 \***************************************************/
795 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
796
797 "use strict";
798 __webpack_require__.r(__webpack_exports__);
799 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
800 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
801 /* harmony export */ });
802 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
803 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
804 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");
805 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);
806 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");
807 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);
808 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");
809 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);
810 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");
811 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);
812 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");
813 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);
814 /* harmony import */ var _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./toastify.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css");
815
816
817
818
819
820
821
822
823
824
825
826 var options = {};
827
828 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
829 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
830
831 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
832
833 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
834 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
835
836 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
837
838
839
840
841 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
842
843
844 /***/ },
845
846 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
847 /*!****************************************************************************!*\
848 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
849 \****************************************************************************/
850 (module) {
851
852 "use strict";
853
854
855 var stylesInDOM = [];
856 function getIndexByIdentifier(identifier) {
857 var result = -1;
858 for (var i = 0; i < stylesInDOM.length; i++) {
859 if (stylesInDOM[i].identifier === identifier) {
860 result = i;
861 break;
862 }
863 }
864 return result;
865 }
866 function modulesToDom(list, options) {
867 var idCountMap = {};
868 var identifiers = [];
869 for (var i = 0; i < list.length; i++) {
870 var item = list[i];
871 var id = options.base ? item[0] + options.base : item[0];
872 var count = idCountMap[id] || 0;
873 var identifier = "".concat(id, " ").concat(count);
874 idCountMap[id] = count + 1;
875 var indexByIdentifier = getIndexByIdentifier(identifier);
876 var obj = {
877 css: item[1],
878 media: item[2],
879 sourceMap: item[3],
880 supports: item[4],
881 layer: item[5]
882 };
883 if (indexByIdentifier !== -1) {
884 stylesInDOM[indexByIdentifier].references++;
885 stylesInDOM[indexByIdentifier].updater(obj);
886 } else {
887 var updater = addElementStyle(obj, options);
888 options.byIndex = i;
889 stylesInDOM.splice(i, 0, {
890 identifier: identifier,
891 updater: updater,
892 references: 1
893 });
894 }
895 identifiers.push(identifier);
896 }
897 return identifiers;
898 }
899 function addElementStyle(obj, options) {
900 var api = options.domAPI(options);
901 api.update(obj);
902 var updater = function updater(newObj) {
903 if (newObj) {
904 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
905 return;
906 }
907 api.update(obj = newObj);
908 } else {
909 api.remove();
910 }
911 };
912 return updater;
913 }
914 module.exports = function (list, options) {
915 options = options || {};
916 list = list || [];
917 var lastIdentifiers = modulesToDom(list, options);
918 return function update(newList) {
919 newList = newList || [];
920 for (var i = 0; i < lastIdentifiers.length; i++) {
921 var identifier = lastIdentifiers[i];
922 var index = getIndexByIdentifier(identifier);
923 stylesInDOM[index].references--;
924 }
925 var newLastIdentifiers = modulesToDom(newList, options);
926 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
927 var _identifier = lastIdentifiers[_i];
928 var _index = getIndexByIdentifier(_identifier);
929 if (stylesInDOM[_index].references === 0) {
930 stylesInDOM[_index].updater();
931 stylesInDOM.splice(_index, 1);
932 }
933 }
934 lastIdentifiers = newLastIdentifiers;
935 };
936 };
937
938 /***/ },
939
940 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
941 /*!********************************************************************!*\
942 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
943 \********************************************************************/
944 (module) {
945
946 "use strict";
947
948
949 var memo = {};
950
951 /* istanbul ignore next */
952 function getTarget(target) {
953 if (typeof memo[target] === "undefined") {
954 var styleTarget = document.querySelector(target);
955
956 // Special case to return head of iframe instead of iframe itself
957 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
958 try {
959 // This will throw an exception if access to iframe is blocked
960 // due to cross-origin restrictions
961 styleTarget = styleTarget.contentDocument.head;
962 } catch (e) {
963 // istanbul ignore next
964 styleTarget = null;
965 }
966 }
967 memo[target] = styleTarget;
968 }
969 return memo[target];
970 }
971
972 /* istanbul ignore next */
973 function insertBySelector(insert, style) {
974 var target = getTarget(insert);
975 if (!target) {
976 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
977 }
978 target.appendChild(style);
979 }
980 module.exports = insertBySelector;
981
982 /***/ },
983
984 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
985 /*!**********************************************************************!*\
986 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
987 \**********************************************************************/
988 (module) {
989
990 "use strict";
991
992
993 /* istanbul ignore next */
994 function insertStyleElement(options) {
995 var element = document.createElement("style");
996 options.setAttributes(element, options.attributes);
997 options.insert(element, options.options);
998 return element;
999 }
1000 module.exports = insertStyleElement;
1001
1002 /***/ },
1003
1004 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1005 /*!**********************************************************************************!*\
1006 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1007 \**********************************************************************************/
1008 (module, __unused_webpack_exports, __webpack_require__) {
1009
1010 "use strict";
1011
1012
1013 /* istanbul ignore next */
1014 function setAttributesWithoutAttributes(styleElement) {
1015 var nonce = true ? __webpack_require__.nc : 0;
1016 if (nonce) {
1017 styleElement.setAttribute("nonce", nonce);
1018 }
1019 }
1020 module.exports = setAttributesWithoutAttributes;
1021
1022 /***/ },
1023
1024 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1025 /*!***************************************************************!*\
1026 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1027 \***************************************************************/
1028 (module) {
1029
1030 "use strict";
1031
1032
1033 /* istanbul ignore next */
1034 function apply(styleElement, options, obj) {
1035 var css = "";
1036 if (obj.supports) {
1037 css += "@supports (".concat(obj.supports, ") {");
1038 }
1039 if (obj.media) {
1040 css += "@media ".concat(obj.media, " {");
1041 }
1042 var needLayer = typeof obj.layer !== "undefined";
1043 if (needLayer) {
1044 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1045 }
1046 css += obj.css;
1047 if (needLayer) {
1048 css += "}";
1049 }
1050 if (obj.media) {
1051 css += "}";
1052 }
1053 if (obj.supports) {
1054 css += "}";
1055 }
1056 var sourceMap = obj.sourceMap;
1057 if (sourceMap && typeof btoa !== "undefined") {
1058 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1059 }
1060
1061 // For old IE
1062 /* istanbul ignore if */
1063 options.styleTagTransform(css, styleElement, options.options);
1064 }
1065 function removeStyleElement(styleElement) {
1066 // istanbul ignore if
1067 if (styleElement.parentNode === null) {
1068 return false;
1069 }
1070 styleElement.parentNode.removeChild(styleElement);
1071 }
1072
1073 /* istanbul ignore next */
1074 function domAPI(options) {
1075 if (typeof document === "undefined") {
1076 return {
1077 update: function update() {},
1078 remove: function remove() {}
1079 };
1080 }
1081 var styleElement = options.insertStyleElement(options);
1082 return {
1083 update: function update(obj) {
1084 apply(styleElement, options, obj);
1085 },
1086 remove: function remove() {
1087 removeStyleElement(styleElement);
1088 }
1089 };
1090 }
1091 module.exports = domAPI;
1092
1093 /***/ },
1094
1095 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1096 /*!*********************************************************************!*\
1097 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1098 \*********************************************************************/
1099 (module) {
1100
1101 "use strict";
1102
1103
1104 /* istanbul ignore next */
1105 function styleTagTransform(css, styleElement) {
1106 if (styleElement.styleSheet) {
1107 styleElement.styleSheet.cssText = css;
1108 } else {
1109 while (styleElement.firstChild) {
1110 styleElement.removeChild(styleElement.firstChild);
1111 }
1112 styleElement.appendChild(document.createTextNode(css));
1113 }
1114 }
1115 module.exports = styleTagTransform;
1116
1117 /***/ },
1118
1119 /***/ "./node_modules/toastify-js/src/toastify.js"
1120 /*!**************************************************!*\
1121 !*** ./node_modules/toastify-js/src/toastify.js ***!
1122 \**************************************************/
1123 (module) {
1124
1125 /*!
1126 * Toastify js 1.12.0
1127 * https://github.com/apvarun/toastify-js
1128 * @license MIT licensed
1129 *
1130 * Copyright (C) 2018 Varun A P
1131 */
1132 (function(root, factory) {
1133 if ( true && module.exports) {
1134 module.exports = factory();
1135 } else {
1136 root.Toastify = factory();
1137 }
1138 })(this, function(global) {
1139 // Object initialization
1140 var Toastify = function(options) {
1141 // Returning a new init object
1142 return new Toastify.lib.init(options);
1143 },
1144 // Library version
1145 version = "1.12.0";
1146
1147 // Set the default global options
1148 Toastify.defaults = {
1149 oldestFirst: true,
1150 text: "Toastify is awesome!",
1151 node: undefined,
1152 duration: 3000,
1153 selector: undefined,
1154 callback: function () {
1155 },
1156 destination: undefined,
1157 newWindow: false,
1158 close: false,
1159 gravity: "toastify-top",
1160 positionLeft: false,
1161 position: '',
1162 backgroundColor: '',
1163 avatar: "",
1164 className: "",
1165 stopOnFocus: true,
1166 onClick: function () {
1167 },
1168 offset: {x: 0, y: 0},
1169 escapeMarkup: true,
1170 ariaLive: 'polite',
1171 style: {background: ''}
1172 };
1173
1174 // Defining the prototype of the object
1175 Toastify.lib = Toastify.prototype = {
1176 toastify: version,
1177
1178 constructor: Toastify,
1179
1180 // Initializing the object with required parameters
1181 init: function(options) {
1182 // Verifying and validating the input object
1183 if (!options) {
1184 options = {};
1185 }
1186
1187 // Creating the options object
1188 this.options = {};
1189
1190 this.toastElement = null;
1191
1192 // Validating the options
1193 this.options.text = options.text || Toastify.defaults.text; // Display message
1194 this.options.node = options.node || Toastify.defaults.node; // Display content as node
1195 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
1196 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
1197 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
1198 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
1199 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
1200 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
1201 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
1202 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
1203 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
1204 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
1205 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
1206 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
1207 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
1208 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
1209 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
1210 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
1211 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
1212 this.options.style = options.style || Toastify.defaults.style;
1213 if(options.backgroundColor) {
1214 this.options.style.background = options.backgroundColor;
1215 }
1216
1217 // Returning the current object for chaining functions
1218 return this;
1219 },
1220
1221 // Building the DOM element
1222 buildToast: function() {
1223 // Validating if the options are defined
1224 if (!this.options) {
1225 throw "Toastify is not initialized";
1226 }
1227
1228 // Creating the DOM object
1229 var divElement = document.createElement("div");
1230 divElement.className = "toastify on " + this.options.className;
1231
1232 // Positioning toast to left or right or center
1233 if (!!this.options.position) {
1234 divElement.className += " toastify-" + this.options.position;
1235 } else {
1236 // To be depreciated in further versions
1237 if (this.options.positionLeft === true) {
1238 divElement.className += " toastify-left";
1239 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
1240 } else {
1241 // Default position
1242 divElement.className += " toastify-right";
1243 }
1244 }
1245
1246 // Assigning gravity of element
1247 divElement.className += " " + this.options.gravity;
1248
1249 if (this.options.backgroundColor) {
1250 // This is being deprecated in favor of using the style HTML DOM property
1251 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
1252 }
1253
1254 // Loop through our style object and apply styles to divElement
1255 for (var property in this.options.style) {
1256 divElement.style[property] = this.options.style[property];
1257 }
1258
1259 // Announce the toast to screen readers
1260 if (this.options.ariaLive) {
1261 divElement.setAttribute('aria-live', this.options.ariaLive)
1262 }
1263
1264 // Adding the toast message/node
1265 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
1266 // If we have a valid node, we insert it
1267 divElement.appendChild(this.options.node)
1268 } else {
1269 if (this.options.escapeMarkup) {
1270 divElement.innerText = this.options.text;
1271 } else {
1272 divElement.innerHTML = this.options.text;
1273 }
1274
1275 if (this.options.avatar !== "") {
1276 var avatarElement = document.createElement("img");
1277 avatarElement.src = this.options.avatar;
1278
1279 avatarElement.className = "toastify-avatar";
1280
1281 if (this.options.position == "left" || this.options.positionLeft === true) {
1282 // Adding close icon on the left of content
1283 divElement.appendChild(avatarElement);
1284 } else {
1285 // Adding close icon on the right of content
1286 divElement.insertAdjacentElement("afterbegin", avatarElement);
1287 }
1288 }
1289 }
1290
1291 // Adding a close icon to the toast
1292 if (this.options.close === true) {
1293 // Create a span for close element
1294 var closeElement = document.createElement("button");
1295 closeElement.type = "button";
1296 closeElement.setAttribute("aria-label", "Close");
1297 closeElement.className = "toast-close";
1298 closeElement.innerHTML = "&#10006;";
1299
1300 // Triggering the removal of toast from DOM on close click
1301 closeElement.addEventListener(
1302 "click",
1303 function(event) {
1304 event.stopPropagation();
1305 this.removeElement(this.toastElement);
1306 window.clearTimeout(this.toastElement.timeOutValue);
1307 }.bind(this)
1308 );
1309
1310 //Calculating screen width
1311 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
1312
1313 // Adding the close icon to the toast element
1314 // Display on the right if screen width is less than or equal to 360px
1315 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
1316 // Adding close icon on the left of content
1317 divElement.insertAdjacentElement("afterbegin", closeElement);
1318 } else {
1319 // Adding close icon on the right of content
1320 divElement.appendChild(closeElement);
1321 }
1322 }
1323
1324 // Clear timeout while toast is focused
1325 if (this.options.stopOnFocus && this.options.duration > 0) {
1326 var self = this;
1327 // stop countdown
1328 divElement.addEventListener(
1329 "mouseover",
1330 function(event) {
1331 window.clearTimeout(divElement.timeOutValue);
1332 }
1333 )
1334 // add back the timeout
1335 divElement.addEventListener(
1336 "mouseleave",
1337 function() {
1338 divElement.timeOutValue = window.setTimeout(
1339 function() {
1340 // Remove the toast from DOM
1341 self.removeElement(divElement);
1342 },
1343 self.options.duration
1344 )
1345 }
1346 )
1347 }
1348
1349 // Adding an on-click destination path
1350 if (typeof this.options.destination !== "undefined") {
1351 divElement.addEventListener(
1352 "click",
1353 function(event) {
1354 event.stopPropagation();
1355 if (this.options.newWindow === true) {
1356 window.open(this.options.destination, "_blank");
1357 } else {
1358 window.location = this.options.destination;
1359 }
1360 }.bind(this)
1361 );
1362 }
1363
1364 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
1365 divElement.addEventListener(
1366 "click",
1367 function(event) {
1368 event.stopPropagation();
1369 this.options.onClick();
1370 }.bind(this)
1371 );
1372 }
1373
1374 // Adding offset
1375 if(typeof this.options.offset === "object") {
1376
1377 var x = getAxisOffsetAValue("x", this.options);
1378 var y = getAxisOffsetAValue("y", this.options);
1379
1380 var xOffset = this.options.position == "left" ? x : "-" + x;
1381 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
1382
1383 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
1384
1385 }
1386
1387 // Returning the generated element
1388 return divElement;
1389 },
1390
1391 // Displaying the toast
1392 showToast: function() {
1393 // Creating the DOM object for the toast
1394 this.toastElement = this.buildToast();
1395
1396 // Getting the root element to with the toast needs to be added
1397 var rootElement;
1398 if (typeof this.options.selector === "string") {
1399 rootElement = document.getElementById(this.options.selector);
1400 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
1401 rootElement = this.options.selector;
1402 } else {
1403 rootElement = document.body;
1404 }
1405
1406 // Validating if root element is present in DOM
1407 if (!rootElement) {
1408 throw "Root element is not defined";
1409 }
1410
1411 // Adding the DOM element
1412 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
1413 rootElement.insertBefore(this.toastElement, elementToInsert);
1414
1415 // Repositioning the toasts in case multiple toasts are present
1416 Toastify.reposition();
1417
1418 if (this.options.duration > 0) {
1419 this.toastElement.timeOutValue = window.setTimeout(
1420 function() {
1421 // Remove the toast from DOM
1422 this.removeElement(this.toastElement);
1423 }.bind(this),
1424 this.options.duration
1425 ); // Binding `this` for function invocation
1426 }
1427
1428 // Supporting function chaining
1429 return this;
1430 },
1431
1432 hideToast: function() {
1433 if (this.toastElement.timeOutValue) {
1434 clearTimeout(this.toastElement.timeOutValue);
1435 }
1436 this.removeElement(this.toastElement);
1437 },
1438
1439 // Removing the element from the DOM
1440 removeElement: function(toastElement) {
1441 // Hiding the element
1442 // toastElement.classList.remove("on");
1443 toastElement.className = toastElement.className.replace(" on", "");
1444
1445 // Removing the element from DOM after transition end
1446 window.setTimeout(
1447 function() {
1448 // remove options node if any
1449 if (this.options.node && this.options.node.parentNode) {
1450 this.options.node.parentNode.removeChild(this.options.node);
1451 }
1452
1453 // Remove the element from the DOM, only when the parent node was not removed before.
1454 if (toastElement.parentNode) {
1455 toastElement.parentNode.removeChild(toastElement);
1456 }
1457
1458 // Calling the callback function
1459 this.options.callback.call(toastElement);
1460
1461 // Repositioning the toasts again
1462 Toastify.reposition();
1463 }.bind(this),
1464 400
1465 ); // Binding `this` for function invocation
1466 },
1467 };
1468
1469 // Positioning the toasts on the DOM
1470 Toastify.reposition = function() {
1471
1472 // Top margins with gravity
1473 var topLeftOffsetSize = {
1474 top: 15,
1475 bottom: 15,
1476 };
1477 var topRightOffsetSize = {
1478 top: 15,
1479 bottom: 15,
1480 };
1481 var offsetSize = {
1482 top: 15,
1483 bottom: 15,
1484 };
1485
1486 // Get all toast messages on the DOM
1487 var allToasts = document.getElementsByClassName("toastify");
1488
1489 var classUsed;
1490
1491 // Modifying the position of each toast element
1492 for (var i = 0; i < allToasts.length; i++) {
1493 // Getting the applied gravity
1494 if (containsClass(allToasts[i], "toastify-top") === true) {
1495 classUsed = "toastify-top";
1496 } else {
1497 classUsed = "toastify-bottom";
1498 }
1499
1500 var height = allToasts[i].offsetHeight;
1501 classUsed = classUsed.substr(9, classUsed.length-1)
1502 // Spacing between toasts
1503 var offset = 15;
1504
1505 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
1506
1507 // Show toast in center if screen with less than or equal to 360px
1508 if (width <= 360) {
1509 // Setting the position
1510 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
1511
1512 offsetSize[classUsed] += height + offset;
1513 } else {
1514 if (containsClass(allToasts[i], "toastify-left") === true) {
1515 // Setting the position
1516 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
1517
1518 topLeftOffsetSize[classUsed] += height + offset;
1519 } else {
1520 // Setting the position
1521 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
1522
1523 topRightOffsetSize[classUsed] += height + offset;
1524 }
1525 }
1526 }
1527
1528 // Supporting function chaining
1529 return this;
1530 };
1531
1532 // Helper function to get offset.
1533 function getAxisOffsetAValue(axis, options) {
1534
1535 if(options.offset[axis]) {
1536 if(isNaN(options.offset[axis])) {
1537 return options.offset[axis];
1538 }
1539 else {
1540 return options.offset[axis] + 'px';
1541 }
1542 }
1543
1544 return '0px';
1545
1546 }
1547
1548 function containsClass(elem, yourClass) {
1549 if (!elem || typeof yourClass !== "string") {
1550 return false;
1551 } else if (
1552 elem.className &&
1553 elem.className
1554 .trim()
1555 .split(/\s+/gi)
1556 .indexOf(yourClass) > -1
1557 ) {
1558 return true;
1559 } else {
1560 return false;
1561 }
1562 }
1563
1564 // Setting up the prototype for the init object
1565 Toastify.lib.init.prototype = Toastify.lib;
1566
1567 // Returning the Toastify function to be assigned to the window object/module
1568 return Toastify;
1569 });
1570
1571
1572 /***/ }
1573
1574 /******/ });
1575 /************************************************************************/
1576 /******/ // The module cache
1577 /******/ var __webpack_module_cache__ = {};
1578 /******/
1579 /******/ // The require function
1580 /******/ function __webpack_require__(moduleId) {
1581 /******/ // Check if module is in cache
1582 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1583 /******/ if (cachedModule !== undefined) {
1584 /******/ return cachedModule.exports;
1585 /******/ }
1586 /******/ // Create a new module (and put it into the cache)
1587 /******/ var module = __webpack_module_cache__[moduleId] = {
1588 /******/ id: moduleId,
1589 /******/ // no module.loaded needed
1590 /******/ exports: {}
1591 /******/ };
1592 /******/
1593 /******/ // Execute the module function
1594 /******/ if (!(moduleId in __webpack_modules__)) {
1595 /******/ delete __webpack_module_cache__[moduleId];
1596 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
1597 /******/ e.code = 'MODULE_NOT_FOUND';
1598 /******/ throw e;
1599 /******/ }
1600 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
1601 /******/
1602 /******/ // Return the exports of the module
1603 /******/ return module.exports;
1604 /******/ }
1605 /******/
1606 /************************************************************************/
1607 /******/ /* webpack/runtime/compat get default export */
1608 /******/ (() => {
1609 /******/ // getDefaultExport function for compatibility with non-harmony modules
1610 /******/ __webpack_require__.n = (module) => {
1611 /******/ var getter = module && module.__esModule ?
1612 /******/ () => (module['default']) :
1613 /******/ () => (module);
1614 /******/ __webpack_require__.d(getter, { a: getter });
1615 /******/ return getter;
1616 /******/ };
1617 /******/ })();
1618 /******/
1619 /******/ /* webpack/runtime/define property getters */
1620 /******/ (() => {
1621 /******/ // define getter functions for harmony exports
1622 /******/ __webpack_require__.d = (exports, definition) => {
1623 /******/ for(var key in definition) {
1624 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1625 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1626 /******/ }
1627 /******/ }
1628 /******/ };
1629 /******/ })();
1630 /******/
1631 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1632 /******/ (() => {
1633 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1634 /******/ })();
1635 /******/
1636 /******/ /* webpack/runtime/make namespace object */
1637 /******/ (() => {
1638 /******/ // define __esModule on exports
1639 /******/ __webpack_require__.r = (exports) => {
1640 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1641 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1642 /******/ }
1643 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1644 /******/ };
1645 /******/ })();
1646 /******/
1647 /******/ /* webpack/runtime/nonce */
1648 /******/ (() => {
1649 /******/ __webpack_require__.nc = undefined;
1650 /******/ })();
1651 /******/
1652 /************************************************************************/
1653 var __webpack_exports__ = {};
1654 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1655 (() => {
1656 "use strict";
1657 /*!***************************************!*\
1658 !*** ./assets/src/js/admin/addons.js ***!
1659 \***************************************/
1660 __webpack_require__.r(__webpack_exports__);
1661 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1662 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1663 /* harmony export */ });
1664 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
1665 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
1666 /**
1667 * Admin Add-ons page JS handler as a class.
1668 *
1669 * Add-ons list is rendered server-side via AdminAddonsPage::render_addons()
1670 * through TemplateAJAX::load_content_via_ajax(). This class only handles
1671 * UI interactions and addon actions via window.lpAJAXG.
1672 *
1673 * @since 4.4.7
1674 * @version 1.0.0
1675 */
1676
1677
1678 class AdminAddons {
1679 constructor() {
1680 this.elAddonsPage = null;
1681 this.urlParams = new URLSearchParams(window.location.search);
1682 }
1683 static selectors = {
1684 elAddonsPage: '.lp-addons-page',
1685 elLPAddons: '#lp-addons',
1686 elAddonItem: '.lp-addon-item',
1687 elBtnAction: '.btn-addon-action',
1688 elNavTab: '.nav-tab',
1689 elNavTabActive: '.nav-tab.nav-tab-active',
1690 elCategory: '.lp-addons-category',
1691 elCategoryActive: '.lp-addons-category.active',
1692 elSearchInput: '#lp-search-addons__input',
1693 elItemPurchase: '.lp-addon-item__purchase',
1694 elPurchaseInstall: '.purchase-install',
1695 elPurchaseCode: '.enter-purchase-code',
1696 elLicense: '.lp-addon-license'
1697 };
1698 init() {
1699 // Content is injected via AJAX into .lp-target, wait for #lp-addons.
1700 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpOnElementReady(AdminAddons.selectors.elLPAddons, () => {
1701 this.elAddonsPage = document.querySelector(AdminAddons.selectors.elAddonsPage);
1702 if (!this.elAddonsPage) {
1703 return;
1704 }
1705 this.filterAddons();
1706 this.events();
1707 });
1708 }
1709
1710 /**
1711 * Register events.
1712 *
1713 * @return void
1714 */
1715 events() {
1716 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('click', [{
1717 selector: AdminAddons.selectors.elBtnAction,
1718 class: this,
1719 callBack: this.handleBtnAction.name
1720 }, {
1721 selector: AdminAddons.selectors.elNavTab,
1722 class: this,
1723 callBack: this.handleTabClick.name
1724 }, {
1725 selector: AdminAddons.selectors.elCategory,
1726 class: this,
1727 callBack: this.handleCategoryClick.name
1728 }, {
1729 selector: AdminAddons.selectors.elPurchaseCode,
1730 class: this,
1731 callBack: this.handlePurchaseCodeClick.name
1732 }]);
1733 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('input', [{
1734 selector: AdminAddons.selectors.elSearchInput,
1735 class: this,
1736 callBack: this.handleSearchInput.name
1737 }, {
1738 selector: AdminAddons.selectors.elPurchaseCode,
1739 class: this,
1740 callBack: this.handlePurchaseCodeInput.name
1741 }]);
1742 }
1743
1744 /**
1745 * Get addon data embedded on the item element.
1746 *
1747 * @param {Element} elAddonItem Addon item element.
1748 * @return {Object|null}
1749 */
1750 getAddonData(elAddonItem) {
1751 try {
1752 return JSON.parse(elAddonItem.dataset.addon);
1753 } catch (e) {
1754 return null;
1755 }
1756 }
1757
1758 /**
1759 * Send addon action to server via lpAJAXG.
1760 *
1761 * @param {Object} data { action, addon, purchase_code, el, elAddonItem }.
1762 * @return void
1763 */
1764 addonsAction(data) {
1765 const {
1766 action,
1767 addon,
1768 el,
1769 elAddonItem
1770 } = data;
1771 const selectors = AdminAddons.selectors;
1772 const params = {
1773 action: 'addon_action',
1774 action_type: action,
1775 addon,
1776 purchase_code: data.purchase_code || '',
1777 id_url: 'addon-action'
1778 };
1779 window.lpAJAXG.fetchAJAX(params, {
1780 success: response => {
1781 const {
1782 status,
1783 message,
1784 data: resData
1785 } = response;
1786 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_0__.show(message, status);
1787 if (status === 'success' && resData?.html) {
1788 elAddonItem.outerHTML = resData.html;
1789 } else if ('install' === action || 'update-purchase' === action) {
1790 const elPurchasePanel = el.closest(selectors.elPurchaseInstall);
1791 const elPurchaseCode = elPurchasePanel ? elPurchasePanel.querySelector(selectors.elPurchaseCode) : null;
1792 if (elPurchaseCode) {
1793 elPurchaseCode.classList.add('is-error');
1794 elPurchaseCode.setAttribute('aria-invalid', 'true');
1795 }
1796 }
1797
1798 //this.filterAddons();
1799 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(el, 0);
1800 },
1801 error: error => {
1802 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(el, 0);
1803 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_0__.show(`error js: ${error}`, 'error');
1804 }
1805 });
1806 }
1807
1808 /**
1809 * Filter add-ons by status, category, and search query.
1810 *
1811 * @return void
1812 */
1813 filterAddons() {
1814 const selectors = AdminAddons.selectors;
1815 const elAddonItems = this.elAddonsPage.querySelectorAll(selectors.elAddonItem);
1816
1817 // Count items for each tab
1818 this.updateTabCounts(elAddonItems);
1819 const elActiveTab = this.elAddonsPage.querySelector(selectors.elNavTabActive);
1820 const elActiveCategory = this.elAddonsPage.querySelector(selectors.elCategoryActive);
1821 const elSearch = this.elAddonsPage.querySelector(selectors.elSearchInput);
1822 const tabName = elActiveTab ? elActiveTab.dataset.tab : 'all';
1823 const category = elActiveCategory ? elActiveCategory.dataset.category : 'all';
1824 const keyword = elSearch ? elSearch.value.trim().toLowerCase() : '';
1825 const searchTerms = keyword.split(/\s+/).filter(Boolean);
1826
1827 // Count items for category by tab
1828 this.updateCategoryCounts(elAddonItems, tabName);
1829 elAddonItems.forEach(elAddonItem => {
1830 const addonInfo = JSON.parse(elAddonItem.dataset.addon);
1831 const addonName = elAddonItem.querySelector('a').textContent.toLowerCase();
1832 const textCompare = addonName + addonInfo.description;
1833 const addonCategories = (elAddonItem.dataset.category || '').split(/\s+/).filter(Boolean);
1834 const matchesTab = 'all' === tabName || elAddonItem.classList.contains(tabName);
1835 const matchesCategory = 'all' === category || addonCategories.includes(category);
1836 const matchesSearch = searchTerms.every(term => textCompare.includes(term));
1837 const isVisible = matchesTab && matchesCategory && matchesSearch;
1838 elAddonItem.classList.toggle('hide', !matchesTab);
1839 elAddonItem.classList.toggle('search-not-found', !isVisible);
1840 });
1841 }
1842 updateCategoryCounts(elAddonItems, tabName) {
1843 const categoryCounts = {
1844 all: 0
1845 };
1846 elAddonItems.forEach(elAddonItem => {
1847 const matchesTab = 'all' === tabName || elAddonItem.classList.contains(tabName);
1848 if (!matchesTab) {
1849 return;
1850 }
1851 categoryCounts.all++;
1852 (elAddonItem.dataset.category || '').split(/\s+/).filter(Boolean).forEach(addonCategory => {
1853 categoryCounts[addonCategory] = (categoryCounts[addonCategory] || 0) + 1;
1854 });
1855 });
1856 this.elAddonsPage.querySelectorAll(AdminAddons.selectors.elCategory).forEach(elCategory => {
1857 const count = categoryCounts[elCategory.dataset.category] || 0;
1858 const elCount = elCategory.querySelector('.lp-addons-category__count');
1859 if (elCount) {
1860 elCount.textContent = `(${count})`;
1861 }
1862 elCategory.hidden = 'all' !== elCategory.dataset.category && 0 === count;
1863 });
1864 }
1865 updateTabCounts(elAddonItems) {
1866 this.elAddonsPage.querySelectorAll(AdminAddons.selectors.elNavTab).forEach(elNavTab => {
1867 const tabName = elNavTab.dataset.tab;
1868 const count = Array.from(elAddonItems).filter(elAddonItem => 'all' === tabName || elAddonItem.classList.contains(tabName)).length;
1869 const elCount = elNavTab.querySelector('span');
1870 if (elCount) {
1871 elCount.textContent = count;
1872 }
1873 });
1874 }
1875
1876 /**
1877 * Handle click events.
1878 *
1879 * @param {Object} args Click event arguments.
1880 * @return void
1881 */
1882 handlePurchaseCodeClick(args) {
1883 const {
1884 target: el
1885 } = args;
1886 if (!el.value.startsWith('***')) {
1887 return;
1888 }
1889 el.value = '';
1890 const elItemPurchase = el.closest(AdminAddons.selectors.elItemPurchase);
1891 if (elItemPurchase) {
1892 elItemPurchase.querySelector('input[name=purchase-code]').value = '';
1893 }
1894 }
1895
1896 /**
1897 * Handle addon action button click.
1898 *
1899 * @param {Object} args Click event arguments.
1900 * @return void
1901 */
1902 handleBtnAction(args) {
1903 const {
1904 e,
1905 target
1906 } = args;
1907 const selectors = AdminAddons.selectors;
1908 const el = target.closest(selectors.elBtnAction);
1909
1910 // Ignore button type link
1911 if ('A' === el.tagName) {
1912 return;
1913 }
1914 e.preventDefault();
1915 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(el, 1);
1916 let purchaseCode = '';
1917 const elAddonItem = el.closest(selectors.elAddonItem);
1918 const addon = this.getAddonData(elAddonItem);
1919 const action = el.dataset.action;
1920 const elItemPurchase = elAddonItem.querySelector(selectors.elItemPurchase);
1921 if (!addon) {
1922 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(el, 0);
1923 return;
1924 }
1925 if (action === 'purchase' || action === 'update-purchase-code') {
1926 const elPurchaseInstall = elItemPurchase.querySelector(selectors.elPurchaseInstall);
1927 const elPurchaseCode = elPurchaseInstall.querySelector(selectors.elPurchaseCode);
1928 const elPurchaseSubmit = elPurchaseInstall.querySelector('.lp-addon-purchase__submit');
1929 if (action === 'update-purchase-code') {
1930 const elLicense = elAddonItem.querySelector(selectors.elLicense);
1931 elPurchaseCode.value = elLicense ? elLicense.dataset.purchaseCodeMasked || '' : '';
1932 elPurchaseSubmit.dataset.action = 'update-purchase';
1933 } else {
1934 elPurchaseCode.value = '';
1935 elPurchaseSubmit.dataset.action = 'install';
1936 }
1937 elPurchaseCode.classList.remove('is-error');
1938 elPurchaseCode.removeAttribute('aria-invalid');
1939 elItemPurchase.querySelector('input[name=purchase-code]').value = '';
1940 elPurchaseInstall.style.display = 'flex';
1941 elItemPurchase.style.display = 'block';
1942 elPurchaseCode.focus();
1943 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(el, 0);
1944 return;
1945 } else if (action === 'cancel') {
1946 elItemPurchase.style.display = 'none';
1947 elItemPurchase.querySelector(selectors.elPurchaseInstall).style.display = 'none';
1948 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(el, 0);
1949 return;
1950 }
1951
1952 // Send request to server.
1953 if (elItemPurchase) {
1954 purchaseCode = elItemPurchase.querySelector('input[name=purchase-code]').value;
1955 }
1956 this.addonsAction({
1957 purchase_code: purchaseCode,
1958 action,
1959 addon,
1960 el,
1961 elAddonItem
1962 });
1963 }
1964
1965 /**
1966 * Handle tab click.
1967 *
1968 * @param {Object} args Click event arguments.
1969 * @return void
1970 */
1971 handleTabClick(args) {
1972 const {
1973 e,
1974 target
1975 } = args;
1976 const selectors = AdminAddons.selectors;
1977 const el = target.closest(selectors.elNavTab);
1978 e.preventDefault();
1979 const elTabs = this.elAddonsPage.querySelectorAll(selectors.elNavTab);
1980 elTabs.forEach(elTab => {
1981 elTab.classList.remove('nav-tab-active');
1982 elTab.setAttribute('aria-pressed', 'false');
1983 });
1984 el.classList.add('nav-tab-active');
1985 el.setAttribute('aria-pressed', 'true');
1986 const tabName = el.dataset.tab;
1987 const elSearch = this.elAddonsPage.querySelector(selectors.elSearchInput);
1988 elSearch.value = '';
1989 this.elAddonsPage.querySelectorAll(selectors.elCategory).forEach(elCategory => {
1990 const isActive = 'all' === elCategory.dataset.category;
1991 elCategory.classList.toggle('active', isActive);
1992 elCategory.setAttribute('aria-pressed', isActive ? 'true' : 'false');
1993 });
1994 this.urlParams.set('tab', tabName);
1995 window.history.pushState({}, '', `${window.location.pathname}?${this.urlParams.toString()}`);
1996 this.filterAddons();
1997 }
1998
1999 /**
2000 * Handle category click.
2001 *
2002 * @param {Object} args Click event arguments.
2003 * @return void
2004 */
2005 handleCategoryClick(args) {
2006 const {
2007 e,
2008 target
2009 } = args;
2010 const elCategory = target.closest(AdminAddons.selectors.elCategory);
2011 e.preventDefault();
2012 this.elAddonsPage.querySelectorAll(AdminAddons.selectors.elCategory).forEach(item => {
2013 const isActive = item === elCategory;
2014 item.classList.toggle('active', isActive);
2015 item.setAttribute('aria-pressed', isActive ? 'true' : 'false');
2016 });
2017 this.filterAddons();
2018 }
2019
2020 /**
2021 * Handle search input.
2022 *
2023 * @return void
2024 */
2025 handleSearchInput() {
2026 this.filterAddons();
2027 }
2028
2029 /**
2030 * Handle purchase code input.
2031 *
2032 * @param {Object} args Input event arguments.
2033 * @return void
2034 */
2035 handlePurchaseCodeInput(args) {
2036 const {
2037 e,
2038 target: el
2039 } = args;
2040 e.preventDefault();
2041 el.classList.remove('is-error');
2042 el.removeAttribute('aria-invalid');
2043 const purchaseCode = el.value;
2044 const elItemPurchase = el.closest(AdminAddons.selectors.elItemPurchase);
2045 if (elItemPurchase) {
2046 const input = elItemPurchase.querySelector('input[name=purchase-code]');
2047 input.value = purchaseCode;
2048 }
2049 }
2050 }
2051 const adminAddons = new AdminAddons();
2052 adminAddons.init();
2053 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (AdminAddons);
2054 })();
2055
2056 /******/ })()
2057 ;
2058 //# sourceMappingURL=addons.js.map