PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.3.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.3.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 4.2.0 All 139 releases
learnpress / assets / dist / js / admin / edit-question.js

edit-question.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.9, at assets/dist/js/admin/edit-question.js

10,963 lines 391.8 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 */ getDataOfForm: () => (/* binding */ getDataOfForm),
70 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
71 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
72 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
73 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
74 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
75 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
76 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
77 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
78 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
79 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
80 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
81 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
82 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
83 /* harmony export */ });
84 /**
85 * Utils functions
86 *
87 * @param url
88 * @param data
89 * @param functions
90 * @since 4.2.5.1
91 * @version 1.0.6
92 */
93 const lpClassName = {
94 hidden: 'lp-hidden',
95 loading: 'loading',
96 elCollapse: 'lp-collapse',
97 elSectionToggle: '.lp-section-toggle',
98 elTriggerToggle: '.lp-trigger-toggle'
99 };
100 const lpFetchAPI = (url, data = {}, functions = {}) => {
101 if ('function' === typeof functions.before) {
102 functions.before();
103 }
104 fetch(url, {
105 method: 'GET',
106 ...data
107 }).then(response => response.json()).then(response => {
108 if ('function' === typeof functions.success) {
109 functions.success(response);
110 }
111 }).catch(err => {
112 if ('function' === typeof functions.error) {
113 functions.error(err);
114 }
115 }).finally(() => {
116 if ('function' === typeof functions.completed) {
117 functions.completed();
118 }
119 });
120 };
121
122 /**
123 * Get current URL without params.
124 *
125 * @since 4.2.5.1
126 */
127 const lpGetCurrentURLNoParam = () => {
128 let currentUrl = window.location.href;
129 const hasParams = currentUrl.includes('?');
130 if (hasParams) {
131 currentUrl = currentUrl.split('?')[0];
132 }
133 return currentUrl;
134 };
135 const lpAddQueryArgs = (endpoint, args) => {
136 const url = new URL(endpoint);
137 Object.keys(args).forEach(arg => {
138 url.searchParams.set(arg, args[arg]);
139 });
140 return url;
141 };
142
143 /**
144 * Listen element viewed.
145 *
146 * @param el
147 * @param callback
148 * @since 4.2.5.8
149 */
150 const listenElementViewed = (el, callback) => {
151 const observerSeeItem = new IntersectionObserver(function (entries) {
152 for (const entry of entries) {
153 if (entry.isIntersecting) {
154 callback(entry);
155 }
156 }
157 });
158 observerSeeItem.observe(el);
159 };
160
161 /**
162 * Listen element created.
163 *
164 * @param callback
165 * @since 4.2.5.8
166 */
167 const listenElementCreated = callback => {
168 const observerCreateItem = new MutationObserver(function (mutations) {
169 mutations.forEach(function (mutation) {
170 if (mutation.addedNodes) {
171 mutation.addedNodes.forEach(function (node) {
172 if (node.nodeType === 1) {
173 callback(node);
174 }
175 });
176 }
177 });
178 });
179 observerCreateItem.observe(document, {
180 childList: true,
181 subtree: true
182 });
183 // End.
184 };
185
186 /**
187 * Listen element created.
188 *
189 * @param selector
190 * @param callback
191 * @since 4.2.7.1
192 */
193 const lpOnElementReady = (selector, callback) => {
194 const element = document.querySelector(selector);
195 if (element) {
196 callback(element);
197 return;
198 }
199 const observer = new MutationObserver((mutations, obs) => {
200 const element = document.querySelector(selector);
201 if (element) {
202 obs.disconnect();
203 callback(element);
204 }
205 });
206 observer.observe(document.documentElement, {
207 childList: true,
208 subtree: true
209 });
210 };
211
212 // Parse JSON from string with content include LP_AJAX_START.
213 const lpAjaxParseJsonOld = data => {
214 if (typeof data !== 'string') {
215 return data;
216 }
217 const m = String.raw({
218 raw: data
219 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
220 try {
221 if (m) {
222 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
223 } else {
224 data = JSON.parse(data);
225 }
226 } catch (e) {
227 data = {};
228 }
229 return data;
230 };
231
232 // status 0: hide, 1: show
233 const lpShowHideEl = (el, status = 0) => {
234 if (!el) {
235 return;
236 }
237 if (!status) {
238 el.classList.add(lpClassName.hidden);
239 } else {
240 el.classList.remove(lpClassName.hidden);
241 }
242 };
243
244 // status 0: hide, 1: show
245 const lpSetLoadingEl = (el, status) => {
246 if (!el) {
247 return;
248 }
249 if (!status) {
250 el.classList.remove(lpClassName.loading);
251 } else {
252 el.classList.add(lpClassName.loading);
253 }
254 };
255
256 // Toggle collapse section
257 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
258 if (!elTriggerClassName) {
259 elTriggerClassName = lpClassName.elTriggerToggle;
260 }
261
262 // Exclude elements, which should not trigger the collapse toggle
263 if (elsExclude && elsExclude.length > 0) {
264 for (const elExclude of elsExclude) {
265 if (target.closest(elExclude)) {
266 return;
267 }
268 }
269 }
270 const elTrigger = target.closest(elTriggerClassName);
271 if (!elTrigger) {
272 return;
273 }
274
275 //console.log( 'elTrigger', elTrigger );
276
277 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
278 if (!elSectionToggle) {
279 return;
280 }
281 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
282 if ('function' === typeof callback) {
283 callback(elSectionToggle);
284 }
285 };
286
287 // Get data of form
288 const getDataOfForm = form => {
289 const dataSend = {};
290 const formData = new FormData(form);
291 for (const pair of formData.entries()) {
292 const key = pair[0];
293 const value = formData.getAll(key);
294 if (!dataSend.hasOwnProperty(key)) {
295 // Convert value array to string.
296 dataSend[key] = value.join(',');
297 }
298 }
299 return dataSend;
300 };
301
302 // Get field keys of form
303 const getFieldKeysOfForm = form => {
304 const keys = [];
305 const elements = form.elements;
306 for (let i = 0; i < elements.length; i++) {
307 const name = elements[i].name;
308 if (name && !keys.includes(name)) {
309 keys.push(name);
310 }
311 }
312 return keys;
313 };
314
315 // Merge data handle with data form.
316 const mergeDataWithDatForm = (elForm, dataHandle) => {
317 const dataForm = getDataOfForm(elForm);
318 const keys = getFieldKeysOfForm(elForm);
319 keys.forEach(key => {
320 if (!dataForm.hasOwnProperty(key)) {
321 delete dataHandle[key];
322 } else if (dataForm[key][0] === '') {
323 delete dataForm[key];
324 delete dataHandle[key];
325 }
326 });
327 dataHandle = {
328 ...dataHandle,
329 ...dataForm
330 };
331 return dataHandle;
332 };
333
334 /**
335 * Event trigger
336 * For each list of event handlers, listen event on document.
337 *
338 * eventName: 'click', 'change', ...
339 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
340 *
341 * @param eventName
342 * @param eventHandlers
343 */
344 const eventHandlers = (eventName, eventHandlers) => {
345 document.addEventListener(eventName, e => {
346 const target = e.target;
347 let args = {
348 e,
349 target
350 };
351 eventHandlers.forEach(eventHandler => {
352 args = {
353 ...args,
354 ...eventHandler
355 };
356
357 //console.log( args );
358
359 // Check condition before call back
360 if (eventHandler.conditionBeforeCallBack) {
361 if (eventHandler.conditionBeforeCallBack(args) !== true) {
362 return;
363 }
364 }
365
366 // Special check for keydown event with checkIsEventEnter = true
367 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
368 if (e.key !== 'Enter') {
369 return;
370 }
371 }
372 if (target.closest(eventHandler.selector)) {
373 if (eventHandler.class) {
374 // Call method of class, function callBack will understand exactly {this} is class object.
375 eventHandler.class[eventHandler.callBack](args);
376 } else {
377 // For send args is objected, {this} is eventHandler object, not class object.
378 eventHandler.callBack(args);
379 }
380 }
381 });
382 });
383 };
384
385 /**
386 * Debounce - delays function execution until after `wait` ms of inactivity.
387 *
388 * Each call resets the timer. Only the last call in a burst executes.
389 *
390 * USE CASES:
391 * - Search inputs, form validation, window resize
392 * - Multiple elements need independent timers
393 * - When you need to call with different arguments
394 *
395 * EXAMPLES:
396 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
397 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
398 *
399 * const debouncedResize = debounce( recalculateLayout, 250 );
400 * window.addEventListener('resize', debouncedResize);
401 *
402 * ⚠️ Create ONCE outside event handlers, not inside.
403 *
404 * @param {Function} func - Function to debounce (can be anonymous)
405 * @param {number} wait - Milliseconds to wait (default: 500)
406 * @return {Function} Debounced wrapper function
407 * @since 4.3.7
408 * @version 1.0.0
409 */
410 const debounce = (func, wait = 500) => {
411 let timer;
412 return args => {
413 clearTimeout(timer);
414 timer = setTimeout(() => func(args), wait);
415 };
416 };
417
418 /***/ },
419
420 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
421 /*!*****************************************************************************************!*\
422 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
423 \*****************************************************************************************/
424 (module, __webpack_exports__, __webpack_require__) {
425
426 "use strict";
427 __webpack_require__.r(__webpack_exports__);
428 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
429 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
430 /* harmony export */ });
431 /* 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");
432 /* 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__);
433 /* 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");
434 /* 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__);
435 // Imports
436
437
438 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()));
439 // Module
440 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
441 * Toastify js 1.12.0
442 * https://github.com/apvarun/toastify-js
443 * @license MIT licensed
444 *
445 * Copyright (C) 2018 Varun A P
446 */
447
448 .toastify {
449 padding: 12px 20px;
450 color: #ffffff;
451 display: inline-block;
452 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
453 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
454 background: linear-gradient(135deg, #73a5ff, #5477f5);
455 position: fixed;
456 opacity: 0;
457 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
458 border-radius: 2px;
459 cursor: pointer;
460 text-decoration: none;
461 max-width: calc(50% - 20px);
462 z-index: 2147483647;
463 }
464
465 .toastify.on {
466 opacity: 1;
467 }
468
469 .toast-close {
470 background: transparent;
471 border: 0;
472 color: white;
473 cursor: pointer;
474 font-family: inherit;
475 font-size: 1em;
476 opacity: 0.4;
477 padding: 0 5px;
478 }
479
480 .toastify-right {
481 right: 15px;
482 }
483
484 .toastify-left {
485 left: 15px;
486 }
487
488 .toastify-top {
489 top: -150px;
490 }
491
492 .toastify-bottom {
493 bottom: -150px;
494 }
495
496 .toastify-rounded {
497 border-radius: 25px;
498 }
499
500 .toastify-avatar {
501 width: 1.5em;
502 height: 1.5em;
503 margin: -7px 5px;
504 border-radius: 2px;
505 }
506
507 .toastify-center {
508 margin-left: auto;
509 margin-right: auto;
510 left: 0;
511 right: 0;
512 max-width: fit-content;
513 max-width: -moz-fit-content;
514 }
515
516 @media only screen and (max-width: 360px) {
517 .toastify-right, .toastify-left {
518 margin-left: auto;
519 margin-right: auto;
520 left: 0;
521 right: 0;
522 max-width: fit-content;
523 }
524 }
525 `, "",{"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":""}]);
526 // Exports
527 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
528
529
530 /***/ },
531
532 /***/ "./node_modules/css-loader/dist/runtime/api.js"
533 /*!*****************************************************!*\
534 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
535 \*****************************************************/
536 (module) {
537
538 "use strict";
539
540
541 /*
542 MIT License http://www.opensource.org/licenses/mit-license.php
543 Author Tobias Koppers @sokra
544 */
545 module.exports = function (cssWithMappingToString) {
546 var list = [];
547
548 // return the list of modules as css string
549 list.toString = function toString() {
550 return this.map(function (item) {
551 var content = "";
552 var needLayer = typeof item[5] !== "undefined";
553 if (item[4]) {
554 content += "@supports (".concat(item[4], ") {");
555 }
556 if (item[2]) {
557 content += "@media ".concat(item[2], " {");
558 }
559 if (needLayer) {
560 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
561 }
562 content += cssWithMappingToString(item);
563 if (needLayer) {
564 content += "}";
565 }
566 if (item[2]) {
567 content += "}";
568 }
569 if (item[4]) {
570 content += "}";
571 }
572 return content;
573 }).join("");
574 };
575
576 // import a list of modules into the list
577 list.i = function i(modules, media, dedupe, supports, layer) {
578 if (typeof modules === "string") {
579 modules = [[null, modules, undefined]];
580 }
581 var alreadyImportedModules = {};
582 if (dedupe) {
583 for (var k = 0; k < this.length; k++) {
584 var id = this[k][0];
585 if (id != null) {
586 alreadyImportedModules[id] = true;
587 }
588 }
589 }
590 for (var _k = 0; _k < modules.length; _k++) {
591 var item = [].concat(modules[_k]);
592 if (dedupe && alreadyImportedModules[item[0]]) {
593 continue;
594 }
595 if (typeof layer !== "undefined") {
596 if (typeof item[5] === "undefined") {
597 item[5] = layer;
598 } else {
599 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
600 item[5] = layer;
601 }
602 }
603 if (media) {
604 if (!item[2]) {
605 item[2] = media;
606 } else {
607 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
608 item[2] = media;
609 }
610 }
611 if (supports) {
612 if (!item[4]) {
613 item[4] = "".concat(supports);
614 } else {
615 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
616 item[4] = supports;
617 }
618 }
619 list.push(item);
620 }
621 };
622 return list;
623 };
624
625 /***/ },
626
627 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
628 /*!************************************************************!*\
629 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
630 \************************************************************/
631 (module) {
632
633 "use strict";
634
635
636 module.exports = function (item) {
637 var content = item[1];
638 var cssMapping = item[3];
639 if (!cssMapping) {
640 return content;
641 }
642 if (typeof btoa === "function") {
643 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
644 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
645 var sourceMapping = "/*# ".concat(data, " */");
646 return [content].concat([sourceMapping]).join("\n");
647 }
648 return [content].join("\n");
649 };
650
651 /***/ },
652
653 /***/ "./node_modules/sortablejs/modular/sortable.esm.js"
654 /*!*********************************************************!*\
655 !*** ./node_modules/sortablejs/modular/sortable.esm.js ***!
656 \*********************************************************/
657 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
658
659 "use strict";
660 __webpack_require__.r(__webpack_exports__);
661 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
662 /* harmony export */ MultiDrag: () => (/* binding */ MultiDragPlugin),
663 /* harmony export */ Sortable: () => (/* binding */ Sortable),
664 /* harmony export */ Swap: () => (/* binding */ SwapPlugin),
665 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
666 /* harmony export */ });
667 /**!
668 * Sortable 1.15.7
669 * @author RubaXa <trash@rubaxa.org>
670 * @author owenm <owen23355@gmail.com>
671 * @license MIT
672 */
673 function _arrayLikeToArray(r, a) {
674 (null == a || a > r.length) && (a = r.length);
675 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
676 return n;
677 }
678 function _arrayWithoutHoles(r) {
679 if (Array.isArray(r)) return _arrayLikeToArray(r);
680 }
681 function _defineProperty(e, r, t) {
682 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
683 value: t,
684 enumerable: !0,
685 configurable: !0,
686 writable: !0
687 }) : e[r] = t, e;
688 }
689 function _extends() {
690 return _extends = Object.assign ? Object.assign.bind() : function (n) {
691 for (var e = 1; e < arguments.length; e++) {
692 var t = arguments[e];
693 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
694 }
695 return n;
696 }, _extends.apply(null, arguments);
697 }
698 function _iterableToArray(r) {
699 if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
700 }
701 function _nonIterableSpread() {
702 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
703 }
704 function ownKeys(e, r) {
705 var t = Object.keys(e);
706 if (Object.getOwnPropertySymbols) {
707 var o = Object.getOwnPropertySymbols(e);
708 r && (o = o.filter(function (r) {
709 return Object.getOwnPropertyDescriptor(e, r).enumerable;
710 })), t.push.apply(t, o);
711 }
712 return t;
713 }
714 function _objectSpread2(e) {
715 for (var r = 1; r < arguments.length; r++) {
716 var t = null != arguments[r] ? arguments[r] : {};
717 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
718 _defineProperty(e, r, t[r]);
719 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
720 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
721 });
722 }
723 return e;
724 }
725 function _objectWithoutProperties(e, t) {
726 if (null == e) return {};
727 var o,
728 r,
729 i = _objectWithoutPropertiesLoose(e, t);
730 if (Object.getOwnPropertySymbols) {
731 var n = Object.getOwnPropertySymbols(e);
732 for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
733 }
734 return i;
735 }
736 function _objectWithoutPropertiesLoose(r, e) {
737 if (null == r) return {};
738 var t = {};
739 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
740 if (-1 !== e.indexOf(n)) continue;
741 t[n] = r[n];
742 }
743 return t;
744 }
745 function _toConsumableArray(r) {
746 return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
747 }
748 function _toPrimitive(t, r) {
749 if ("object" != typeof t || !t) return t;
750 var e = t[Symbol.toPrimitive];
751 if (void 0 !== e) {
752 var i = e.call(t, r || "default");
753 if ("object" != typeof i) return i;
754 throw new TypeError("@@toPrimitive must return a primitive value.");
755 }
756 return ("string" === r ? String : Number)(t);
757 }
758 function _toPropertyKey(t) {
759 var i = _toPrimitive(t, "string");
760 return "symbol" == typeof i ? i : i + "";
761 }
762 function _typeof(o) {
763 "@babel/helpers - typeof";
764
765 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
766 return typeof o;
767 } : function (o) {
768 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
769 }, _typeof(o);
770 }
771 function _unsupportedIterableToArray(r, a) {
772 if (r) {
773 if ("string" == typeof r) return _arrayLikeToArray(r, a);
774 var t = {}.toString.call(r).slice(8, -1);
775 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;
776 }
777 }
778
779 var version = "1.15.7";
780
781 function userAgent(pattern) {
782 if (typeof window !== 'undefined' && window.navigator) {
783 return !! /*@__PURE__*/navigator.userAgent.match(pattern);
784 }
785 }
786 var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
787 var Edge = userAgent(/Edge/i);
788 var FireFox = userAgent(/firefox/i);
789 var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
790 var IOS = userAgent(/iP(ad|od|hone)/i);
791 var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
792
793 var captureMode = {
794 capture: false,
795 passive: false
796 };
797 function on(el, event, fn) {
798 el.addEventListener(event, fn, !IE11OrLess && captureMode);
799 }
800 function off(el, event, fn) {
801 el.removeEventListener(event, fn, !IE11OrLess && captureMode);
802 }
803 function matches( /**HTMLElement*/el, /**String*/selector) {
804 if (!selector) return;
805 selector[0] === '>' && (selector = selector.substring(1));
806 if (el) {
807 try {
808 if (el.matches) {
809 return el.matches(selector);
810 } else if (el.msMatchesSelector) {
811 return el.msMatchesSelector(selector);
812 } else if (el.webkitMatchesSelector) {
813 return el.webkitMatchesSelector(selector);
814 }
815 } catch (_) {
816 return false;
817 }
818 }
819 return false;
820 }
821 function getParentOrHost(el) {
822 return el.host && el !== document && el.host.nodeType && el.host !== el ? el.host : el.parentNode;
823 }
824 function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
825 if (el) {
826 ctx = ctx || document;
827 do {
828 if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
829 return el;
830 }
831 if (el === ctx) break;
832 /* jshint boss:true */
833 } while (el = getParentOrHost(el));
834 }
835 return null;
836 }
837 var R_SPACE = /\s+/g;
838 function toggleClass(el, name, state) {
839 if (el && name) {
840 if (el.classList) {
841 el.classList[state ? 'add' : 'remove'](name);
842 } else {
843 var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
844 el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
845 }
846 }
847 }
848 function css(el, prop, val) {
849 var style = el && el.style;
850 if (style) {
851 if (val === void 0) {
852 if (document.defaultView && document.defaultView.getComputedStyle) {
853 val = document.defaultView.getComputedStyle(el, '');
854 } else if (el.currentStyle) {
855 val = el.currentStyle;
856 }
857 return prop === void 0 ? val : val[prop];
858 } else {
859 if (!(prop in style) && prop.indexOf('webkit') === -1) {
860 prop = '-webkit-' + prop;
861 }
862 style[prop] = val + (typeof val === 'string' ? '' : 'px');
863 }
864 }
865 }
866 function matrix(el, selfOnly) {
867 var appliedTransforms = '';
868 if (typeof el === 'string') {
869 appliedTransforms = el;
870 } else {
871 do {
872 var transform = css(el, 'transform');
873 if (transform && transform !== 'none') {
874 appliedTransforms = transform + ' ' + appliedTransforms;
875 }
876 /* jshint boss:true */
877 } while (!selfOnly && (el = el.parentNode));
878 }
879 var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
880 /*jshint -W056 */
881 return matrixFn && new matrixFn(appliedTransforms);
882 }
883 function find(ctx, tagName, iterator) {
884 if (ctx) {
885 var list = ctx.getElementsByTagName(tagName),
886 i = 0,
887 n = list.length;
888 if (iterator) {
889 for (; i < n; i++) {
890 iterator(list[i], i);
891 }
892 }
893 return list;
894 }
895 return [];
896 }
897 function getWindowScrollingElement() {
898 var scrollingElement = document.scrollingElement;
899 if (scrollingElement) {
900 return scrollingElement;
901 } else {
902 return document.documentElement;
903 }
904 }
905
906 /**
907 * Returns the "bounding client rect" of given element
908 * @param {HTMLElement} el The element whose boundingClientRect is wanted
909 * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
910 * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
911 * @param {[Boolean]} undoScale Whether the container's scale() should be undone
912 * @param {[HTMLElement]} container The parent the element will be placed in
913 * @return {Object} The boundingClientRect of el, with specified adjustments
914 */
915 function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
916 if (!el.getBoundingClientRect && el !== window) return;
917 var elRect, top, left, bottom, right, height, width;
918 if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
919 elRect = el.getBoundingClientRect();
920 top = elRect.top;
921 left = elRect.left;
922 bottom = elRect.bottom;
923 right = elRect.right;
924 height = elRect.height;
925 width = elRect.width;
926 } else {
927 top = 0;
928 left = 0;
929 bottom = window.innerHeight;
930 right = window.innerWidth;
931 height = window.innerHeight;
932 width = window.innerWidth;
933 }
934 if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
935 // Adjust for translate()
936 container = container || el.parentNode;
937
938 // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
939 // Not needed on <= IE11
940 if (!IE11OrLess) {
941 do {
942 if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
943 var containerRect = container.getBoundingClientRect();
944
945 // Set relative to edges of padding box of container
946 top -= containerRect.top + parseInt(css(container, 'border-top-width'));
947 left -= containerRect.left + parseInt(css(container, 'border-left-width'));
948 bottom = top + elRect.height;
949 right = left + elRect.width;
950 break;
951 }
952 /* jshint boss:true */
953 } while (container = container.parentNode);
954 }
955 }
956 if (undoScale && el !== window) {
957 // Adjust for scale()
958 var elMatrix = matrix(container || el),
959 scaleX = elMatrix && elMatrix.a,
960 scaleY = elMatrix && elMatrix.d;
961 if (elMatrix) {
962 top /= scaleY;
963 left /= scaleX;
964 width /= scaleX;
965 height /= scaleY;
966 bottom = top + height;
967 right = left + width;
968 }
969 }
970 return {
971 top: top,
972 left: left,
973 bottom: bottom,
974 right: right,
975 width: width,
976 height: height
977 };
978 }
979
980 /**
981 * Checks if a side of an element is scrolled past a side of its parents
982 * @param {HTMLElement} el The element who's side being scrolled out of view is in question
983 * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
984 * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
985 * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
986 */
987 function isScrolledPast(el, elSide, parentSide) {
988 var parent = getParentAutoScrollElement(el, true),
989 elSideVal = getRect(el)[elSide];
990
991 /* jshint boss:true */
992 while (parent) {
993 var parentSideVal = getRect(parent)[parentSide],
994 visible = void 0;
995 if (parentSide === 'top' || parentSide === 'left') {
996 visible = elSideVal >= parentSideVal;
997 } else {
998 visible = elSideVal <= parentSideVal;
999 }
1000 if (!visible) return parent;
1001 if (parent === getWindowScrollingElement()) break;
1002 parent = getParentAutoScrollElement(parent, false);
1003 }
1004 return false;
1005 }
1006
1007 /**
1008 * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
1009 * and non-draggable elements
1010 * @param {HTMLElement} el The parent element
1011 * @param {Number} childNum The index of the child
1012 * @param {Object} options Parent Sortable's options
1013 * @return {HTMLElement} The child at index childNum, or null if not found
1014 */
1015 function getChild(el, childNum, options, includeDragEl) {
1016 var currentChild = 0,
1017 i = 0,
1018 children = el.children;
1019 while (i < children.length) {
1020 if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
1021 if (currentChild === childNum) {
1022 return children[i];
1023 }
1024 currentChild++;
1025 }
1026 i++;
1027 }
1028 return null;
1029 }
1030
1031 /**
1032 * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
1033 * @param {HTMLElement} el Parent element
1034 * @param {selector} selector Any other elements that should be ignored
1035 * @return {HTMLElement} The last child, ignoring ghostEl
1036 */
1037 function lastChild(el, selector) {
1038 var last = el.lastElementChild;
1039 while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
1040 last = last.previousElementSibling;
1041 }
1042 return last || null;
1043 }
1044
1045 /**
1046 * Returns the index of an element within its parent for a selected set of
1047 * elements
1048 * @param {HTMLElement} el
1049 * @param {selector} selector
1050 * @return {number}
1051 */
1052 function index(el, selector) {
1053 var index = 0;
1054 if (!el || !el.parentNode) {
1055 return -1;
1056 }
1057
1058 /* jshint boss:true */
1059 while (el = el.previousElementSibling) {
1060 if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
1061 index++;
1062 }
1063 }
1064 return index;
1065 }
1066
1067 /**
1068 * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
1069 * The value is returned in real pixels.
1070 * @param {HTMLElement} el
1071 * @return {Array} Offsets in the format of [left, top]
1072 */
1073 function getRelativeScrollOffset(el) {
1074 var offsetLeft = 0,
1075 offsetTop = 0,
1076 winScroller = getWindowScrollingElement();
1077 if (el) {
1078 do {
1079 var elMatrix = matrix(el),
1080 scaleX = elMatrix.a,
1081 scaleY = elMatrix.d;
1082 offsetLeft += el.scrollLeft * scaleX;
1083 offsetTop += el.scrollTop * scaleY;
1084 } while (el !== winScroller && (el = el.parentNode));
1085 }
1086 return [offsetLeft, offsetTop];
1087 }
1088
1089 /**
1090 * Returns the index of the object within the given array
1091 * @param {Array} arr Array that may or may not hold the object
1092 * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
1093 * @return {Number} The index of the object in the array, or -1
1094 */
1095 function indexOfObject(arr, obj) {
1096 for (var i in arr) {
1097 if (!arr.hasOwnProperty(i)) continue;
1098 for (var key in obj) {
1099 if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
1100 }
1101 }
1102 return -1;
1103 }
1104 function getParentAutoScrollElement(el, includeSelf) {
1105 // skip to window
1106 if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
1107 var elem = el;
1108 var gotSelf = false;
1109 do {
1110 // we don't need to get elem css if it isn't even overflowing in the first place (performance)
1111 if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
1112 var elemCSS = css(elem);
1113 if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
1114 if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
1115 if (gotSelf || includeSelf) return elem;
1116 gotSelf = true;
1117 }
1118 }
1119 /* jshint boss:true */
1120 } while (elem = elem.parentNode);
1121 return getWindowScrollingElement();
1122 }
1123 function extend(dst, src) {
1124 if (dst && src) {
1125 for (var key in src) {
1126 if (src.hasOwnProperty(key)) {
1127 dst[key] = src[key];
1128 }
1129 }
1130 }
1131 return dst;
1132 }
1133 function isRectEqual(rect1, rect2) {
1134 return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
1135 }
1136 var _throttleTimeout;
1137 function throttle(callback, ms) {
1138 return function () {
1139 if (!_throttleTimeout) {
1140 var args = arguments,
1141 _this = this;
1142 if (args.length === 1) {
1143 callback.call(_this, args[0]);
1144 } else {
1145 callback.apply(_this, args);
1146 }
1147 _throttleTimeout = setTimeout(function () {
1148 _throttleTimeout = void 0;
1149 }, ms);
1150 }
1151 };
1152 }
1153 function cancelThrottle() {
1154 clearTimeout(_throttleTimeout);
1155 _throttleTimeout = void 0;
1156 }
1157 function scrollBy(el, x, y) {
1158 el.scrollLeft += x;
1159 el.scrollTop += y;
1160 }
1161 function clone(el) {
1162 var Polymer = window.Polymer;
1163 var $ = window.jQuery || window.Zepto;
1164 if (Polymer && Polymer.dom) {
1165 return Polymer.dom(el).cloneNode(true);
1166 } else if ($) {
1167 return $(el).clone(true)[0];
1168 } else {
1169 return el.cloneNode(true);
1170 }
1171 }
1172 function setRect(el, rect) {
1173 css(el, 'position', 'absolute');
1174 css(el, 'top', rect.top);
1175 css(el, 'left', rect.left);
1176 css(el, 'width', rect.width);
1177 css(el, 'height', rect.height);
1178 }
1179 function unsetRect(el) {
1180 css(el, 'position', '');
1181 css(el, 'top', '');
1182 css(el, 'left', '');
1183 css(el, 'width', '');
1184 css(el, 'height', '');
1185 }
1186 function getChildContainingRectFromElement(container, options, ghostEl) {
1187 var rect = {};
1188 Array.from(container.children).forEach(function (child) {
1189 var _rect$left, _rect$top, _rect$right, _rect$bottom;
1190 if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
1191 var childRect = getRect(child);
1192 rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
1193 rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
1194 rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
1195 rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
1196 });
1197 rect.width = rect.right - rect.left;
1198 rect.height = rect.bottom - rect.top;
1199 rect.x = rect.left;
1200 rect.y = rect.top;
1201 return rect;
1202 }
1203 var expando = 'Sortable' + new Date().getTime();
1204
1205 function AnimationStateManager() {
1206 var animationStates = [],
1207 animationCallbackId;
1208 return {
1209 captureAnimationState: function captureAnimationState() {
1210 animationStates = [];
1211 if (!this.options.animation) return;
1212 var children = [].slice.call(this.el.children);
1213 children.forEach(function (child) {
1214 if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
1215 animationStates.push({
1216 target: child,
1217 rect: getRect(child)
1218 });
1219 var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
1220
1221 // If animating: compensate for current animation
1222 if (child.thisAnimationDuration) {
1223 var childMatrix = matrix(child, true);
1224 if (childMatrix) {
1225 fromRect.top -= childMatrix.f;
1226 fromRect.left -= childMatrix.e;
1227 }
1228 }
1229 child.fromRect = fromRect;
1230 });
1231 },
1232 addAnimationState: function addAnimationState(state) {
1233 animationStates.push(state);
1234 },
1235 removeAnimationState: function removeAnimationState(target) {
1236 animationStates.splice(indexOfObject(animationStates, {
1237 target: target
1238 }), 1);
1239 },
1240 animateAll: function animateAll(callback) {
1241 var _this = this;
1242 if (!this.options.animation) {
1243 clearTimeout(animationCallbackId);
1244 if (typeof callback === 'function') callback();
1245 return;
1246 }
1247 var animating = false,
1248 animationTime = 0;
1249 animationStates.forEach(function (state) {
1250 var time = 0,
1251 target = state.target,
1252 fromRect = target.fromRect,
1253 toRect = getRect(target),
1254 prevFromRect = target.prevFromRect,
1255 prevToRect = target.prevToRect,
1256 animatingRect = state.rect,
1257 targetMatrix = matrix(target, true);
1258 if (targetMatrix) {
1259 // Compensate for current animation
1260 toRect.top -= targetMatrix.f;
1261 toRect.left -= targetMatrix.e;
1262 }
1263 target.toRect = toRect;
1264 if (target.thisAnimationDuration) {
1265 // Could also check if animatingRect is between fromRect and toRect
1266 if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
1267 // Make sure animatingRect is on line between toRect & fromRect
1268 (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
1269 // If returning to same place as started from animation and on same axis
1270 time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
1271 }
1272 }
1273
1274 // if fromRect != toRect: animate
1275 if (!isRectEqual(toRect, fromRect)) {
1276 target.prevFromRect = fromRect;
1277 target.prevToRect = toRect;
1278 if (!time) {
1279 time = _this.options.animation;
1280 }
1281 _this.animate(target, animatingRect, toRect, time);
1282 }
1283 if (time) {
1284 animating = true;
1285 animationTime = Math.max(animationTime, time);
1286 clearTimeout(target.animationResetTimer);
1287 target.animationResetTimer = setTimeout(function () {
1288 target.animationTime = 0;
1289 target.prevFromRect = null;
1290 target.fromRect = null;
1291 target.prevToRect = null;
1292 target.thisAnimationDuration = null;
1293 }, time);
1294 target.thisAnimationDuration = time;
1295 }
1296 });
1297 clearTimeout(animationCallbackId);
1298 if (!animating) {
1299 if (typeof callback === 'function') callback();
1300 } else {
1301 animationCallbackId = setTimeout(function () {
1302 if (typeof callback === 'function') callback();
1303 }, animationTime);
1304 }
1305 animationStates = [];
1306 },
1307 animate: function animate(target, currentRect, toRect, duration) {
1308 if (duration) {
1309 css(target, 'transition', '');
1310 css(target, 'transform', '');
1311 var elMatrix = matrix(this.el),
1312 scaleX = elMatrix && elMatrix.a,
1313 scaleY = elMatrix && elMatrix.d,
1314 translateX = (currentRect.left - toRect.left) / (scaleX || 1),
1315 translateY = (currentRect.top - toRect.top) / (scaleY || 1);
1316 target.animatingX = !!translateX;
1317 target.animatingY = !!translateY;
1318 css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
1319 this.forRepaintDummy = repaint(target); // repaint
1320
1321 css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
1322 css(target, 'transform', 'translate3d(0,0,0)');
1323 typeof target.animated === 'number' && clearTimeout(target.animated);
1324 target.animated = setTimeout(function () {
1325 css(target, 'transition', '');
1326 css(target, 'transform', '');
1327 target.animated = false;
1328 target.animatingX = false;
1329 target.animatingY = false;
1330 }, duration);
1331 }
1332 }
1333 };
1334 }
1335 function repaint(target) {
1336 return target.offsetWidth;
1337 }
1338 function calculateRealTime(animatingRect, fromRect, toRect, options) {
1339 return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
1340 }
1341
1342 var plugins = [];
1343 var defaults = {
1344 initializeByDefault: true
1345 };
1346 var PluginManager = {
1347 mount: function mount(plugin) {
1348 // Set default static properties
1349 for (var option in defaults) {
1350 if (defaults.hasOwnProperty(option) && !(option in plugin)) {
1351 plugin[option] = defaults[option];
1352 }
1353 }
1354 plugins.forEach(function (p) {
1355 if (p.pluginName === plugin.pluginName) {
1356 throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
1357 }
1358 });
1359 plugins.push(plugin);
1360 },
1361 pluginEvent: function pluginEvent(eventName, sortable, evt) {
1362 var _this = this;
1363 this.eventCanceled = false;
1364 evt.cancel = function () {
1365 _this.eventCanceled = true;
1366 };
1367 var eventNameGlobal = eventName + 'Global';
1368 plugins.forEach(function (plugin) {
1369 if (!sortable[plugin.pluginName]) return;
1370 // Fire global events if it exists in this sortable
1371 if (sortable[plugin.pluginName][eventNameGlobal]) {
1372 sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
1373 sortable: sortable
1374 }, evt));
1375 }
1376
1377 // Only fire plugin event if plugin is enabled in this sortable,
1378 // and plugin has event defined
1379 if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
1380 sortable[plugin.pluginName][eventName](_objectSpread2({
1381 sortable: sortable
1382 }, evt));
1383 }
1384 });
1385 },
1386 initializePlugins: function initializePlugins(sortable, el, defaults, options) {
1387 plugins.forEach(function (plugin) {
1388 var pluginName = plugin.pluginName;
1389 if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
1390 var initialized = new plugin(sortable, el, sortable.options);
1391 initialized.sortable = sortable;
1392 initialized.options = sortable.options;
1393 sortable[pluginName] = initialized;
1394
1395 // Add default options from plugin
1396 _extends(defaults, initialized.defaults);
1397 });
1398 for (var option in sortable.options) {
1399 if (!sortable.options.hasOwnProperty(option)) continue;
1400 var modified = this.modifyOption(sortable, option, sortable.options[option]);
1401 if (typeof modified !== 'undefined') {
1402 sortable.options[option] = modified;
1403 }
1404 }
1405 },
1406 getEventProperties: function getEventProperties(name, sortable) {
1407 var eventProperties = {};
1408 plugins.forEach(function (plugin) {
1409 if (typeof plugin.eventProperties !== 'function') return;
1410 _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
1411 });
1412 return eventProperties;
1413 },
1414 modifyOption: function modifyOption(sortable, name, value) {
1415 var modifiedValue;
1416 plugins.forEach(function (plugin) {
1417 // Plugin must exist on the Sortable
1418 if (!sortable[plugin.pluginName]) return;
1419
1420 // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
1421 if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
1422 modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
1423 }
1424 });
1425 return modifiedValue;
1426 }
1427 };
1428
1429 function dispatchEvent(_ref) {
1430 var sortable = _ref.sortable,
1431 rootEl = _ref.rootEl,
1432 name = _ref.name,
1433 targetEl = _ref.targetEl,
1434 cloneEl = _ref.cloneEl,
1435 toEl = _ref.toEl,
1436 fromEl = _ref.fromEl,
1437 oldIndex = _ref.oldIndex,
1438 newIndex = _ref.newIndex,
1439 oldDraggableIndex = _ref.oldDraggableIndex,
1440 newDraggableIndex = _ref.newDraggableIndex,
1441 originalEvent = _ref.originalEvent,
1442 putSortable = _ref.putSortable,
1443 extraEventProperties = _ref.extraEventProperties;
1444 sortable = sortable || rootEl && rootEl[expando];
1445 if (!sortable) return;
1446 var evt,
1447 options = sortable.options,
1448 onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
1449 // Support for new CustomEvent feature
1450 if (window.CustomEvent && !IE11OrLess && !Edge) {
1451 evt = new CustomEvent(name, {
1452 bubbles: true,
1453 cancelable: true
1454 });
1455 } else {
1456 evt = document.createEvent('Event');
1457 evt.initEvent(name, true, true);
1458 }
1459 evt.to = toEl || rootEl;
1460 evt.from = fromEl || rootEl;
1461 evt.item = targetEl || rootEl;
1462 evt.clone = cloneEl;
1463 evt.oldIndex = oldIndex;
1464 evt.newIndex = newIndex;
1465 evt.oldDraggableIndex = oldDraggableIndex;
1466 evt.newDraggableIndex = newDraggableIndex;
1467 evt.originalEvent = originalEvent;
1468 evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
1469 var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
1470 for (var option in allEventProperties) {
1471 evt[option] = allEventProperties[option];
1472 }
1473 if (rootEl) {
1474 rootEl.dispatchEvent(evt);
1475 }
1476 if (options[onName]) {
1477 options[onName].call(sortable, evt);
1478 }
1479 }
1480
1481 var _excluded = ["evt"];
1482 var pluginEvent = function pluginEvent(eventName, sortable) {
1483 var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
1484 originalEvent = _ref.evt,
1485 data = _objectWithoutProperties(_ref, _excluded);
1486 PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
1487 dragEl: dragEl,
1488 parentEl: parentEl,
1489 ghostEl: ghostEl,
1490 rootEl: rootEl,
1491 nextEl: nextEl,
1492 lastDownEl: lastDownEl,
1493 cloneEl: cloneEl,
1494 cloneHidden: cloneHidden,
1495 dragStarted: moved,
1496 putSortable: putSortable,
1497 activeSortable: Sortable.active,
1498 originalEvent: originalEvent,
1499 oldIndex: oldIndex,
1500 oldDraggableIndex: oldDraggableIndex,
1501 newIndex: newIndex,
1502 newDraggableIndex: newDraggableIndex,
1503 hideGhostForTarget: _hideGhostForTarget,
1504 unhideGhostForTarget: _unhideGhostForTarget,
1505 cloneNowHidden: function cloneNowHidden() {
1506 cloneHidden = true;
1507 },
1508 cloneNowShown: function cloneNowShown() {
1509 cloneHidden = false;
1510 },
1511 dispatchSortableEvent: function dispatchSortableEvent(name) {
1512 _dispatchEvent({
1513 sortable: sortable,
1514 name: name,
1515 originalEvent: originalEvent
1516 });
1517 }
1518 }, data));
1519 };
1520 function _dispatchEvent(info) {
1521 dispatchEvent(_objectSpread2({
1522 putSortable: putSortable,
1523 cloneEl: cloneEl,
1524 targetEl: dragEl,
1525 rootEl: rootEl,
1526 oldIndex: oldIndex,
1527 oldDraggableIndex: oldDraggableIndex,
1528 newIndex: newIndex,
1529 newDraggableIndex: newDraggableIndex
1530 }, info));
1531 }
1532 var dragEl,
1533 parentEl,
1534 ghostEl,
1535 rootEl,
1536 nextEl,
1537 lastDownEl,
1538 cloneEl,
1539 cloneHidden,
1540 oldIndex,
1541 newIndex,
1542 oldDraggableIndex,
1543 newDraggableIndex,
1544 activeGroup,
1545 putSortable,
1546 awaitingDragStarted = false,
1547 ignoreNextClick = false,
1548 sortables = [],
1549 tapEvt,
1550 touchEvt,
1551 lastDx,
1552 lastDy,
1553 tapDistanceLeft,
1554 tapDistanceTop,
1555 moved,
1556 lastTarget,
1557 lastDirection,
1558 pastFirstInvertThresh = false,
1559 isCircumstantialInvert = false,
1560 targetMoveDistance,
1561 // For positioning ghost absolutely
1562 ghostRelativeParent,
1563 ghostRelativeParentInitialScroll = [],
1564 // (left, top)
1565
1566 _silent = false,
1567 savedInputChecked = [];
1568
1569 /** @const */
1570 var documentExists = typeof document !== 'undefined',
1571 PositionGhostAbsolutely = IOS,
1572 CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
1573 // This will not pass for IE9, because IE9 DnD only works on anchors
1574 supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
1575 supportCssPointerEvents = function () {
1576 if (!documentExists) return;
1577 // false when <= IE11
1578 if (IE11OrLess) {
1579 return false;
1580 }
1581 var el = document.createElement('x');
1582 el.style.cssText = 'pointer-events:auto';
1583 return el.style.pointerEvents === 'auto';
1584 }(),
1585 _detectDirection = function _detectDirection(el, options) {
1586 var elCSS = css(el),
1587 elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
1588 child1 = getChild(el, 0, options),
1589 child2 = getChild(el, 1, options),
1590 firstChildCSS = child1 && css(child1),
1591 secondChildCSS = child2 && css(child2),
1592 firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
1593 secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
1594 if (elCSS.display === 'flex') {
1595 return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
1596 }
1597 if (elCSS.display === 'grid') {
1598 return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
1599 }
1600 if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
1601 var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
1602 return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
1603 }
1604 return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
1605 },
1606 _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
1607 var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
1608 dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
1609 dragElOppLength = vertical ? dragRect.width : dragRect.height,
1610 targetS1Opp = vertical ? targetRect.left : targetRect.top,
1611 targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
1612 targetOppLength = vertical ? targetRect.width : targetRect.height;
1613 return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
1614 },
1615 /**
1616 * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
1617 * @param {Number} x X position
1618 * @param {Number} y Y position
1619 * @return {HTMLElement} Element of the first found nearest Sortable
1620 */
1621 _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
1622 var ret;
1623 sortables.some(function (sortable) {
1624 var threshold = sortable[expando].options.emptyInsertThreshold;
1625 if (!threshold || lastChild(sortable)) return;
1626 var rect = getRect(sortable),
1627 insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
1628 insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
1629 if (insideHorizontally && insideVertically) {
1630 return ret = sortable;
1631 }
1632 });
1633 return ret;
1634 },
1635 _prepareGroup = function _prepareGroup(options) {
1636 function toFn(value, pull) {
1637 return function (to, from, dragEl, evt) {
1638 var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
1639 if (value == null && (pull || sameGroup)) {
1640 // Default pull value
1641 // Default pull and put value if same group
1642 return true;
1643 } else if (value == null || value === false) {
1644 return false;
1645 } else if (pull && value === 'clone') {
1646 return value;
1647 } else if (typeof value === 'function') {
1648 return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
1649 } else {
1650 var otherGroup = (pull ? to : from).options.group.name;
1651 return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
1652 }
1653 };
1654 }
1655 var group = {};
1656 var originalGroup = options.group;
1657 if (!originalGroup || _typeof(originalGroup) != 'object') {
1658 originalGroup = {
1659 name: originalGroup
1660 };
1661 }
1662 group.name = originalGroup.name;
1663 group.checkPull = toFn(originalGroup.pull, true);
1664 group.checkPut = toFn(originalGroup.put);
1665 group.revertClone = originalGroup.revertClone;
1666 options.group = group;
1667 },
1668 _hideGhostForTarget = function _hideGhostForTarget() {
1669 if (!supportCssPointerEvents && ghostEl) {
1670 css(ghostEl, 'display', 'none');
1671 }
1672 },
1673 _unhideGhostForTarget = function _unhideGhostForTarget() {
1674 if (!supportCssPointerEvents && ghostEl) {
1675 css(ghostEl, 'display', '');
1676 }
1677 };
1678
1679 // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1680 if (documentExists && !ChromeForAndroid) {
1681 document.addEventListener('click', function (evt) {
1682 if (ignoreNextClick) {
1683 evt.preventDefault();
1684 evt.stopPropagation && evt.stopPropagation();
1685 evt.stopImmediatePropagation && evt.stopImmediatePropagation();
1686 ignoreNextClick = false;
1687 return false;
1688 }
1689 }, true);
1690 }
1691 var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1692 if (dragEl) {
1693 evt = evt.touches ? evt.touches[0] : evt;
1694 var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1695 if (nearest) {
1696 // Create imitation event
1697 var event = {};
1698 for (var i in evt) {
1699 if (evt.hasOwnProperty(i)) {
1700 event[i] = evt[i];
1701 }
1702 }
1703 event.target = event.rootEl = nearest;
1704 event.preventDefault = void 0;
1705 event.stopPropagation = void 0;
1706 nearest[expando]._onDragOver(event);
1707 }
1708 }
1709 };
1710 var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1711 if (dragEl) {
1712 dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1713 }
1714 };
1715
1716 /**
1717 * @class Sortable
1718 * @param {HTMLElement} el
1719 * @param {Object} [options]
1720 */
1721 function Sortable(el, options) {
1722 if (!(el && el.nodeType && el.nodeType === 1)) {
1723 throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1724 }
1725 this.el = el; // root element
1726 this.options = options = _extends({}, options);
1727
1728 // Export instance
1729 el[expando] = this;
1730 var defaults = {
1731 group: null,
1732 sort: true,
1733 disabled: false,
1734 store: null,
1735 handle: null,
1736 draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1737 swapThreshold: 1,
1738 // percentage; 0 <= x <= 1
1739 invertSwap: false,
1740 // invert always
1741 invertedSwapThreshold: null,
1742 // will be set to same as swapThreshold if default
1743 removeCloneOnHide: true,
1744 direction: function direction() {
1745 return _detectDirection(el, this.options);
1746 },
1747 ghostClass: 'sortable-ghost',
1748 chosenClass: 'sortable-chosen',
1749 dragClass: 'sortable-drag',
1750 ignore: 'a, img',
1751 filter: null,
1752 preventOnFilter: true,
1753 animation: 0,
1754 easing: null,
1755 setData: function setData(dataTransfer, dragEl) {
1756 dataTransfer.setData('Text', dragEl.textContent);
1757 },
1758 dropBubble: false,
1759 dragoverBubble: false,
1760 dataIdAttr: 'data-id',
1761 delay: 0,
1762 delayOnTouchOnly: false,
1763 touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1764 forceFallback: false,
1765 fallbackClass: 'sortable-fallback',
1766 fallbackOnBody: false,
1767 fallbackTolerance: 0,
1768 fallbackOffset: {
1769 x: 0,
1770 y: 0
1771 },
1772 // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
1773 supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
1774 emptyInsertThreshold: 5
1775 };
1776 PluginManager.initializePlugins(this, el, defaults);
1777
1778 // Set default options
1779 for (var name in defaults) {
1780 !(name in options) && (options[name] = defaults[name]);
1781 }
1782 _prepareGroup(options);
1783
1784 // Bind all private methods
1785 for (var fn in this) {
1786 if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1787 this[fn] = this[fn].bind(this);
1788 }
1789 }
1790
1791 // Setup drag mode
1792 this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1793 if (this.nativeDraggable) {
1794 // Touch start threshold cannot be greater than the native dragstart threshold
1795 this.options.touchStartThreshold = 1;
1796 }
1797
1798 // Bind events
1799 if (options.supportPointer) {
1800 on(el, 'pointerdown', this._onTapStart);
1801 } else {
1802 on(el, 'mousedown', this._onTapStart);
1803 on(el, 'touchstart', this._onTapStart);
1804 }
1805 if (this.nativeDraggable) {
1806 on(el, 'dragover', this);
1807 on(el, 'dragenter', this);
1808 }
1809 sortables.push(this.el);
1810
1811 // Restore sorting
1812 options.store && options.store.get && this.sort(options.store.get(this) || []);
1813
1814 // Add animation state manager
1815 _extends(this, AnimationStateManager());
1816 }
1817 Sortable.prototype = /** @lends Sortable.prototype */{
1818 constructor: Sortable,
1819 _isOutsideThisEl: function _isOutsideThisEl(target) {
1820 if (!this.el.contains(target) && target !== this.el) {
1821 lastTarget = null;
1822 }
1823 },
1824 _getDirection: function _getDirection(evt, target) {
1825 return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1826 },
1827 _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
1828 if (!evt.cancelable) return;
1829 var _this = this,
1830 el = this.el,
1831 options = this.options,
1832 preventOnFilter = options.preventOnFilter,
1833 type = evt.type,
1834 touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1835 target = (touch || evt).target,
1836 originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1837 filter = options.filter;
1838 _saveInputCheckedState(el);
1839
1840 // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1841 if (dragEl) {
1842 return;
1843 }
1844 if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1845 return; // only left button and enabled
1846 }
1847
1848 // cancel dnd if original target is content editable
1849 if (originalTarget.isContentEditable) {
1850 return;
1851 }
1852
1853 // Safari ignores further event handling after mousedown
1854 if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1855 return;
1856 }
1857 target = closest(target, options.draggable, el, false);
1858 if (target && target.animated) {
1859 return;
1860 }
1861 if (lastDownEl === target) {
1862 // Ignoring duplicate `down`
1863 return;
1864 }
1865
1866 // Get the index of the dragged element within its parent
1867 oldIndex = index(target);
1868 oldDraggableIndex = index(target, options.draggable);
1869
1870 // Check filter
1871 if (typeof filter === 'function') {
1872 if (filter.call(this, evt, target, this)) {
1873 _dispatchEvent({
1874 sortable: _this,
1875 rootEl: originalTarget,
1876 name: 'filter',
1877 targetEl: target,
1878 toEl: el,
1879 fromEl: el
1880 });
1881 pluginEvent('filter', _this, {
1882 evt: evt
1883 });
1884 preventOnFilter && evt.preventDefault();
1885 return; // cancel dnd
1886 }
1887 } else if (filter) {
1888 filter = filter.split(',').some(function (criteria) {
1889 criteria = closest(originalTarget, criteria.trim(), el, false);
1890 if (criteria) {
1891 _dispatchEvent({
1892 sortable: _this,
1893 rootEl: criteria,
1894 name: 'filter',
1895 targetEl: target,
1896 fromEl: el,
1897 toEl: el
1898 });
1899 pluginEvent('filter', _this, {
1900 evt: evt
1901 });
1902 return true;
1903 }
1904 });
1905 if (filter) {
1906 preventOnFilter && evt.preventDefault();
1907 return; // cancel dnd
1908 }
1909 }
1910 if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1911 return;
1912 }
1913
1914 // Prepare `dragstart`
1915 this._prepareDragStart(evt, touch, target);
1916 },
1917 _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
1918 var _this = this,
1919 el = _this.el,
1920 options = _this.options,
1921 ownerDocument = el.ownerDocument,
1922 dragStartFn;
1923 if (target && !dragEl && target.parentNode === el) {
1924 var dragRect = getRect(target);
1925 rootEl = el;
1926 dragEl = target;
1927 parentEl = dragEl.parentNode;
1928 nextEl = dragEl.nextSibling;
1929 lastDownEl = target;
1930 activeGroup = options.group;
1931 Sortable.dragged = dragEl;
1932 tapEvt = {
1933 target: dragEl,
1934 clientX: (touch || evt).clientX,
1935 clientY: (touch || evt).clientY
1936 };
1937 tapDistanceLeft = tapEvt.clientX - dragRect.left;
1938 tapDistanceTop = tapEvt.clientY - dragRect.top;
1939 this._lastX = (touch || evt).clientX;
1940 this._lastY = (touch || evt).clientY;
1941 dragEl.style['will-change'] = 'all';
1942 dragStartFn = function dragStartFn() {
1943 pluginEvent('delayEnded', _this, {
1944 evt: evt
1945 });
1946 if (Sortable.eventCanceled) {
1947 _this._onDrop();
1948 return;
1949 }
1950 // Delayed drag has been triggered
1951 // we can re-enable the events: touchmove/mousemove
1952 _this._disableDelayedDragEvents();
1953 if (!FireFox && _this.nativeDraggable) {
1954 dragEl.draggable = true;
1955 }
1956
1957 // Bind the events: dragstart/dragend
1958 _this._triggerDragStart(evt, touch);
1959
1960 // Drag start event
1961 _dispatchEvent({
1962 sortable: _this,
1963 name: 'choose',
1964 originalEvent: evt
1965 });
1966
1967 // Chosen item
1968 toggleClass(dragEl, options.chosenClass, true);
1969 };
1970
1971 // Disable "draggable"
1972 options.ignore.split(',').forEach(function (criteria) {
1973 find(dragEl, criteria.trim(), _disableDraggable);
1974 });
1975 on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1976 on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1977 on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1978 if (options.supportPointer) {
1979 on(ownerDocument, 'pointerup', _this._onDrop);
1980 // Native D&D triggers pointercancel
1981 !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1982 } else {
1983 on(ownerDocument, 'mouseup', _this._onDrop);
1984 on(ownerDocument, 'touchend', _this._onDrop);
1985 on(ownerDocument, 'touchcancel', _this._onDrop);
1986 }
1987
1988 // Make dragEl draggable (must be before delay for FireFox)
1989 if (FireFox && this.nativeDraggable) {
1990 this.options.touchStartThreshold = 4;
1991 dragEl.draggable = true;
1992 }
1993 pluginEvent('delayStart', this, {
1994 evt: evt
1995 });
1996
1997 // Delay is impossible for native DnD in Edge or IE
1998 if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1999 if (Sortable.eventCanceled) {
2000 this._onDrop();
2001 return;
2002 }
2003 // If the user moves the pointer or let go the click or touch
2004 // before the delay has been reached:
2005 // disable the delayed drag
2006 if (options.supportPointer) {
2007 on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
2008 on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
2009 } else {
2010 on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
2011 on(ownerDocument, 'touchend', _this._disableDelayedDrag);
2012 on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
2013 }
2014 on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
2015 on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
2016 options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
2017 _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
2018 } else {
2019 dragStartFn();
2020 }
2021 }
2022 },
2023 _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
2024 var touch = e.touches ? e.touches[0] : e;
2025 if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
2026 this._disableDelayedDrag();
2027 }
2028 },
2029 _disableDelayedDrag: function _disableDelayedDrag() {
2030 dragEl && _disableDraggable(dragEl);
2031 clearTimeout(this._dragStartTimer);
2032 this._disableDelayedDragEvents();
2033 },
2034 _disableDelayedDragEvents: function _disableDelayedDragEvents() {
2035 var ownerDocument = this.el.ownerDocument;
2036 off(ownerDocument, 'mouseup', this._disableDelayedDrag);
2037 off(ownerDocument, 'touchend', this._disableDelayedDrag);
2038 off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
2039 off(ownerDocument, 'pointerup', this._disableDelayedDrag);
2040 off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
2041 off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
2042 off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
2043 off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
2044 },
2045 _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
2046 touch = touch || evt.pointerType == 'touch' && evt;
2047 if (!this.nativeDraggable || touch) {
2048 if (this.options.supportPointer) {
2049 on(document, 'pointermove', this._onTouchMove);
2050 } else if (touch) {
2051 on(document, 'touchmove', this._onTouchMove);
2052 } else {
2053 on(document, 'mousemove', this._onTouchMove);
2054 }
2055 } else {
2056 on(dragEl, 'dragend', this);
2057 on(rootEl, 'dragstart', this._onDragStart);
2058 }
2059 try {
2060 if (document.selection) {
2061 _nextTick(function () {
2062 document.selection.empty();
2063 });
2064 } else {
2065 window.getSelection().removeAllRanges();
2066 }
2067 } catch (err) {}
2068 },
2069 _dragStarted: function _dragStarted(fallback, evt) {
2070 awaitingDragStarted = false;
2071 if (rootEl && dragEl) {
2072 pluginEvent('dragStarted', this, {
2073 evt: evt
2074 });
2075 if (this.nativeDraggable) {
2076 on(document, 'dragover', _checkOutsideTargetEl);
2077 }
2078 var options = this.options;
2079
2080 // Apply effect
2081 !fallback && toggleClass(dragEl, options.dragClass, false);
2082 toggleClass(dragEl, options.ghostClass, true);
2083 Sortable.active = this;
2084 fallback && this._appendGhost();
2085
2086 // Drag start event
2087 _dispatchEvent({
2088 sortable: this,
2089 name: 'start',
2090 originalEvent: evt
2091 });
2092 } else {
2093 this._nulling();
2094 }
2095 },
2096 _emulateDragOver: function _emulateDragOver() {
2097 if (touchEvt) {
2098 this._lastX = touchEvt.clientX;
2099 this._lastY = touchEvt.clientY;
2100 _hideGhostForTarget();
2101 var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
2102 var parent = target;
2103 while (target && target.shadowRoot) {
2104 target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
2105 if (target === parent) break;
2106 parent = target;
2107 }
2108 dragEl.parentNode[expando]._isOutsideThisEl(target);
2109 if (parent) {
2110 do {
2111 if (parent[expando]) {
2112 var inserted = void 0;
2113 inserted = parent[expando]._onDragOver({
2114 clientX: touchEvt.clientX,
2115 clientY: touchEvt.clientY,
2116 target: target,
2117 rootEl: parent
2118 });
2119 if (inserted && !this.options.dragoverBubble) {
2120 break;
2121 }
2122 }
2123 target = parent; // store last element
2124 }
2125 /* jshint boss:true */ while (parent = getParentOrHost(parent));
2126 }
2127 _unhideGhostForTarget();
2128 }
2129 },
2130 _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
2131 if (tapEvt) {
2132 var options = this.options,
2133 fallbackTolerance = options.fallbackTolerance,
2134 fallbackOffset = options.fallbackOffset,
2135 touch = evt.touches ? evt.touches[0] : evt,
2136 ghostMatrix = ghostEl && matrix(ghostEl, true),
2137 scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
2138 scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
2139 relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
2140 dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
2141 dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
2142
2143 // only set the status to dragging, when we are actually dragging
2144 if (!Sortable.active && !awaitingDragStarted) {
2145 if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
2146 return;
2147 }
2148 this._onDragStart(evt, true);
2149 }
2150 if (ghostEl) {
2151 if (ghostMatrix) {
2152 ghostMatrix.e += dx - (lastDx || 0);
2153 ghostMatrix.f += dy - (lastDy || 0);
2154 } else {
2155 ghostMatrix = {
2156 a: 1,
2157 b: 0,
2158 c: 0,
2159 d: 1,
2160 e: dx,
2161 f: dy
2162 };
2163 }
2164 var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
2165 css(ghostEl, 'webkitTransform', cssMatrix);
2166 css(ghostEl, 'mozTransform', cssMatrix);
2167 css(ghostEl, 'msTransform', cssMatrix);
2168 css(ghostEl, 'transform', cssMatrix);
2169 lastDx = dx;
2170 lastDy = dy;
2171 touchEvt = touch;
2172 }
2173 evt.cancelable && evt.preventDefault();
2174 }
2175 },
2176 _appendGhost: function _appendGhost() {
2177 // Bug if using scale(): https://stackoverflow.com/questions/2637058
2178 // Not being adjusted for
2179 if (!ghostEl) {
2180 var container = this.options.fallbackOnBody ? document.body : rootEl,
2181 rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
2182 options = this.options;
2183
2184 // Position absolutely
2185 if (PositionGhostAbsolutely) {
2186 // Get relatively positioned parent
2187 ghostRelativeParent = container;
2188 while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
2189 ghostRelativeParent = ghostRelativeParent.parentNode;
2190 }
2191 if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
2192 if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
2193 rect.top += ghostRelativeParent.scrollTop;
2194 rect.left += ghostRelativeParent.scrollLeft;
2195 } else {
2196 ghostRelativeParent = getWindowScrollingElement();
2197 }
2198 ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
2199 }
2200 ghostEl = dragEl.cloneNode(true);
2201 toggleClass(ghostEl, options.ghostClass, false);
2202 toggleClass(ghostEl, options.fallbackClass, true);
2203 toggleClass(ghostEl, options.dragClass, true);
2204 css(ghostEl, 'transition', '');
2205 css(ghostEl, 'transform', '');
2206 css(ghostEl, 'box-sizing', 'border-box');
2207 css(ghostEl, 'margin', 0);
2208 css(ghostEl, 'top', rect.top);
2209 css(ghostEl, 'left', rect.left);
2210 css(ghostEl, 'width', rect.width);
2211 css(ghostEl, 'height', rect.height);
2212 css(ghostEl, 'opacity', '0.8');
2213 css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
2214 css(ghostEl, 'zIndex', '100000');
2215 css(ghostEl, 'pointerEvents', 'none');
2216 Sortable.ghost = ghostEl;
2217 container.appendChild(ghostEl);
2218
2219 // Set transform-origin
2220 css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
2221 }
2222 },
2223 _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
2224 var _this = this;
2225 var dataTransfer = evt.dataTransfer;
2226 var options = _this.options;
2227 pluginEvent('dragStart', this, {
2228 evt: evt
2229 });
2230 if (Sortable.eventCanceled) {
2231 this._onDrop();
2232 return;
2233 }
2234 pluginEvent('setupClone', this);
2235 if (!Sortable.eventCanceled) {
2236 cloneEl = clone(dragEl);
2237 cloneEl.removeAttribute("id");
2238 cloneEl.draggable = false;
2239 cloneEl.style['will-change'] = '';
2240 this._hideClone();
2241 toggleClass(cloneEl, this.options.chosenClass, false);
2242 Sortable.clone = cloneEl;
2243 }
2244
2245 // #1143: IFrame support workaround
2246 _this.cloneId = _nextTick(function () {
2247 pluginEvent('clone', _this);
2248 if (Sortable.eventCanceled) return;
2249 if (!_this.options.removeCloneOnHide) {
2250 rootEl.insertBefore(cloneEl, dragEl);
2251 }
2252 _this._hideClone();
2253 _dispatchEvent({
2254 sortable: _this,
2255 name: 'clone'
2256 });
2257 });
2258 !fallback && toggleClass(dragEl, options.dragClass, true);
2259
2260 // Set proper drop events
2261 if (fallback) {
2262 ignoreNextClick = true;
2263 _this._loopId = setInterval(_this._emulateDragOver, 50);
2264 } else {
2265 // Undo what was set in _prepareDragStart before drag started
2266 off(document, 'mouseup', _this._onDrop);
2267 off(document, 'touchend', _this._onDrop);
2268 off(document, 'touchcancel', _this._onDrop);
2269 if (dataTransfer) {
2270 dataTransfer.effectAllowed = 'move';
2271 options.setData && options.setData.call(_this, dataTransfer, dragEl);
2272 }
2273 on(document, 'drop', _this);
2274
2275 // #1276 fix:
2276 css(dragEl, 'transform', 'translateZ(0)');
2277 }
2278 awaitingDragStarted = true;
2279 _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
2280 on(document, 'selectstart', _this);
2281 moved = true;
2282 window.getSelection().removeAllRanges();
2283 if (Safari) {
2284 css(document.body, 'user-select', 'none');
2285 }
2286 },
2287 // Returns true - if no further action is needed (either inserted or another condition)
2288 _onDragOver: function _onDragOver( /**Event*/evt) {
2289 var el = this.el,
2290 target = evt.target,
2291 dragRect,
2292 targetRect,
2293 revert,
2294 options = this.options,
2295 group = options.group,
2296 activeSortable = Sortable.active,
2297 isOwner = activeGroup === group,
2298 canSort = options.sort,
2299 fromSortable = putSortable || activeSortable,
2300 vertical,
2301 _this = this,
2302 completedFired = false;
2303 if (_silent) return;
2304 function dragOverEvent(name, extra) {
2305 pluginEvent(name, _this, _objectSpread2({
2306 evt: evt,
2307 isOwner: isOwner,
2308 axis: vertical ? 'vertical' : 'horizontal',
2309 revert: revert,
2310 dragRect: dragRect,
2311 targetRect: targetRect,
2312 canSort: canSort,
2313 fromSortable: fromSortable,
2314 target: target,
2315 completed: completed,
2316 onMove: function onMove(target, after) {
2317 return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
2318 },
2319 changed: changed
2320 }, extra));
2321 }
2322
2323 // Capture animation state
2324 function capture() {
2325 dragOverEvent('dragOverAnimationCapture');
2326 _this.captureAnimationState();
2327 if (_this !== fromSortable) {
2328 fromSortable.captureAnimationState();
2329 }
2330 }
2331
2332 // Return invocation when dragEl is inserted (or completed)
2333 function completed(insertion) {
2334 dragOverEvent('dragOverCompleted', {
2335 insertion: insertion
2336 });
2337 if (insertion) {
2338 // Clones must be hidden before folding animation to capture dragRectAbsolute properly
2339 if (isOwner) {
2340 activeSortable._hideClone();
2341 } else {
2342 activeSortable._showClone(_this);
2343 }
2344 if (_this !== fromSortable) {
2345 // Set ghost class to new sortable's ghost class
2346 toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
2347 toggleClass(dragEl, options.ghostClass, true);
2348 }
2349 if (putSortable !== _this && _this !== Sortable.active) {
2350 putSortable = _this;
2351 } else if (_this === Sortable.active && putSortable) {
2352 putSortable = null;
2353 }
2354
2355 // Animation
2356 if (fromSortable === _this) {
2357 _this._ignoreWhileAnimating = target;
2358 }
2359 _this.animateAll(function () {
2360 dragOverEvent('dragOverAnimationComplete');
2361 _this._ignoreWhileAnimating = null;
2362 });
2363 if (_this !== fromSortable) {
2364 fromSortable.animateAll();
2365 fromSortable._ignoreWhileAnimating = null;
2366 }
2367 }
2368
2369 // Null lastTarget if it is not inside a previously swapped element
2370 if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
2371 lastTarget = null;
2372 }
2373
2374 // no bubbling and not fallback
2375 if (!options.dragoverBubble && !evt.rootEl && target !== document) {
2376 dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
2377
2378 // Do not detect for empty insert if already inserted
2379 !insertion && nearestEmptyInsertDetectEvent(evt);
2380 }
2381 !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
2382 return completedFired = true;
2383 }
2384
2385 // Call when dragEl has been inserted
2386 function changed() {
2387 newIndex = index(dragEl);
2388 newDraggableIndex = index(dragEl, options.draggable);
2389 _dispatchEvent({
2390 sortable: _this,
2391 name: 'change',
2392 toEl: el,
2393 newIndex: newIndex,
2394 newDraggableIndex: newDraggableIndex,
2395 originalEvent: evt
2396 });
2397 }
2398 if (evt.preventDefault !== void 0) {
2399 evt.cancelable && evt.preventDefault();
2400 }
2401 target = closest(target, options.draggable, el, true);
2402 dragOverEvent('dragOver');
2403 if (Sortable.eventCanceled) return completedFired;
2404 if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
2405 return completed(false);
2406 }
2407 ignoreNextClick = false;
2408 if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
2409 : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
2410 vertical = this._getDirection(evt, target) === 'vertical';
2411 dragRect = getRect(dragEl);
2412 dragOverEvent('dragOverValid');
2413 if (Sortable.eventCanceled) return completedFired;
2414 if (revert) {
2415 parentEl = rootEl; // actualization
2416 capture();
2417 this._hideClone();
2418 dragOverEvent('revert');
2419 if (!Sortable.eventCanceled) {
2420 if (nextEl) {
2421 rootEl.insertBefore(dragEl, nextEl);
2422 } else {
2423 rootEl.appendChild(dragEl);
2424 }
2425 }
2426 return completed(true);
2427 }
2428 var elLastChild = lastChild(el, options.draggable);
2429 if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
2430 // Insert to end of list
2431
2432 // If already at end of list: Do not insert
2433 if (elLastChild === dragEl) {
2434 return completed(false);
2435 }
2436
2437 // if there is a last element, it is the target
2438 if (elLastChild && el === evt.target) {
2439 target = elLastChild;
2440 }
2441 if (target) {
2442 targetRect = getRect(target);
2443 }
2444 if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
2445 capture();
2446 if (elLastChild && elLastChild.nextSibling) {
2447 // the last draggable element is not the last node
2448 el.insertBefore(dragEl, elLastChild.nextSibling);
2449 } else {
2450 el.appendChild(dragEl);
2451 }
2452 parentEl = el; // actualization
2453
2454 changed();
2455 return completed(true);
2456 }
2457 } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
2458 // Insert to start of list
2459 var firstChild = getChild(el, 0, options, true);
2460 if (firstChild === dragEl) {
2461 return completed(false);
2462 }
2463 target = firstChild;
2464 targetRect = getRect(target);
2465 if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
2466 capture();
2467 el.insertBefore(dragEl, firstChild);
2468 parentEl = el; // actualization
2469
2470 changed();
2471 return completed(true);
2472 }
2473 } else if (target.parentNode === el) {
2474 targetRect = getRect(target);
2475 var direction = 0,
2476 targetBeforeFirstSwap,
2477 differentLevel = dragEl.parentNode !== el,
2478 differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
2479 side1 = vertical ? 'top' : 'left',
2480 scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
2481 scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
2482 if (lastTarget !== target) {
2483 targetBeforeFirstSwap = targetRect[side1];
2484 pastFirstInvertThresh = false;
2485 isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
2486 }
2487 direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
2488 var sibling;
2489 if (direction !== 0) {
2490 // Check if target is beside dragEl in respective direction (ignoring hidden elements)
2491 var dragIndex = index(dragEl);
2492 do {
2493 dragIndex -= direction;
2494 sibling = parentEl.children[dragIndex];
2495 } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
2496 }
2497 // If dragEl is already beside target: Do not insert
2498 if (direction === 0 || sibling === target) {
2499 return completed(false);
2500 }
2501 lastTarget = target;
2502 lastDirection = direction;
2503 var nextSibling = target.nextElementSibling,
2504 after = false;
2505 after = direction === 1;
2506 var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
2507 if (moveVector !== false) {
2508 if (moveVector === 1 || moveVector === -1) {
2509 after = moveVector === 1;
2510 }
2511 _silent = true;
2512 setTimeout(_unsilent, 30);
2513 capture();
2514 if (after && !nextSibling) {
2515 el.appendChild(dragEl);
2516 } else {
2517 target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
2518 }
2519
2520 // Undo chrome's scroll adjustment (has no effect on other browsers)
2521 if (scrolledPastTop) {
2522 scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
2523 }
2524 parentEl = dragEl.parentNode; // actualization
2525
2526 // must be done before animation
2527 if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
2528 targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
2529 }
2530 changed();
2531 return completed(true);
2532 }
2533 }
2534 if (el.contains(dragEl)) {
2535 return completed(false);
2536 }
2537 }
2538 return false;
2539 },
2540 _ignoreWhileAnimating: null,
2541 _offMoveEvents: function _offMoveEvents() {
2542 off(document, 'mousemove', this._onTouchMove);
2543 off(document, 'touchmove', this._onTouchMove);
2544 off(document, 'pointermove', this._onTouchMove);
2545 off(document, 'dragover', nearestEmptyInsertDetectEvent);
2546 off(document, 'mousemove', nearestEmptyInsertDetectEvent);
2547 off(document, 'touchmove', nearestEmptyInsertDetectEvent);
2548 },
2549 _offUpEvents: function _offUpEvents() {
2550 var ownerDocument = this.el.ownerDocument;
2551 off(ownerDocument, 'mouseup', this._onDrop);
2552 off(ownerDocument, 'touchend', this._onDrop);
2553 off(ownerDocument, 'pointerup', this._onDrop);
2554 off(ownerDocument, 'pointercancel', this._onDrop);
2555 off(ownerDocument, 'touchcancel', this._onDrop);
2556 off(document, 'selectstart', this);
2557 },
2558 _onDrop: function _onDrop( /**Event*/evt) {
2559 var el = this.el,
2560 options = this.options;
2561
2562 // Get the index of the dragged element within its parent
2563 newIndex = index(dragEl);
2564 newDraggableIndex = index(dragEl, options.draggable);
2565 pluginEvent('drop', this, {
2566 evt: evt
2567 });
2568 parentEl = dragEl && dragEl.parentNode;
2569
2570 // Get again after plugin event
2571 newIndex = index(dragEl);
2572 newDraggableIndex = index(dragEl, options.draggable);
2573 if (Sortable.eventCanceled) {
2574 this._nulling();
2575 return;
2576 }
2577 awaitingDragStarted = false;
2578 isCircumstantialInvert = false;
2579 pastFirstInvertThresh = false;
2580 clearInterval(this._loopId);
2581 clearTimeout(this._dragStartTimer);
2582 _cancelNextTick(this.cloneId);
2583 _cancelNextTick(this._dragStartId);
2584
2585 // Unbind events
2586 if (this.nativeDraggable) {
2587 off(document, 'drop', this);
2588 off(el, 'dragstart', this._onDragStart);
2589 }
2590 this._offMoveEvents();
2591 this._offUpEvents();
2592 if (Safari) {
2593 css(document.body, 'user-select', '');
2594 }
2595 css(dragEl, 'transform', '');
2596 if (evt) {
2597 if (moved) {
2598 evt.cancelable && evt.preventDefault();
2599 !options.dropBubble && evt.stopPropagation();
2600 }
2601 ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
2602 if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
2603 // Remove clone(s)
2604 cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
2605 }
2606 if (dragEl) {
2607 if (this.nativeDraggable) {
2608 off(dragEl, 'dragend', this);
2609 }
2610 _disableDraggable(dragEl);
2611 dragEl.style['will-change'] = '';
2612
2613 // Remove classes
2614 // ghostClass is added in dragStarted
2615 if (moved && !awaitingDragStarted) {
2616 toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
2617 }
2618 toggleClass(dragEl, this.options.chosenClass, false);
2619
2620 // Drag stop event
2621 _dispatchEvent({
2622 sortable: this,
2623 name: 'unchoose',
2624 toEl: parentEl,
2625 newIndex: null,
2626 newDraggableIndex: null,
2627 originalEvent: evt
2628 });
2629 if (rootEl !== parentEl) {
2630 if (newIndex >= 0) {
2631 // Add event
2632 _dispatchEvent({
2633 rootEl: parentEl,
2634 name: 'add',
2635 toEl: parentEl,
2636 fromEl: rootEl,
2637 originalEvent: evt
2638 });
2639
2640 // Remove event
2641 _dispatchEvent({
2642 sortable: this,
2643 name: 'remove',
2644 toEl: parentEl,
2645 originalEvent: evt
2646 });
2647
2648 // drag from one list and drop into another
2649 _dispatchEvent({
2650 rootEl: parentEl,
2651 name: 'sort',
2652 toEl: parentEl,
2653 fromEl: rootEl,
2654 originalEvent: evt
2655 });
2656 _dispatchEvent({
2657 sortable: this,
2658 name: 'sort',
2659 toEl: parentEl,
2660 originalEvent: evt
2661 });
2662 }
2663 putSortable && putSortable.save();
2664 } else {
2665 if (newIndex !== oldIndex) {
2666 if (newIndex >= 0) {
2667 // drag & drop within the same list
2668 _dispatchEvent({
2669 sortable: this,
2670 name: 'update',
2671 toEl: parentEl,
2672 originalEvent: evt
2673 });
2674 _dispatchEvent({
2675 sortable: this,
2676 name: 'sort',
2677 toEl: parentEl,
2678 originalEvent: evt
2679 });
2680 }
2681 }
2682 }
2683 if (Sortable.active) {
2684 /* jshint eqnull:true */
2685 if (newIndex == null || newIndex === -1) {
2686 newIndex = oldIndex;
2687 newDraggableIndex = oldDraggableIndex;
2688 }
2689 _dispatchEvent({
2690 sortable: this,
2691 name: 'end',
2692 toEl: parentEl,
2693 originalEvent: evt
2694 });
2695
2696 // Save sorting
2697 this.save();
2698 }
2699 }
2700 }
2701 this._nulling();
2702 },
2703 _nulling: function _nulling() {
2704 pluginEvent('nulling', this);
2705 rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
2706 var el = this.el;
2707 savedInputChecked.forEach(function (checkEl) {
2708 if (el.contains(checkEl)) {
2709 checkEl.checked = true;
2710 }
2711 });
2712 savedInputChecked.length = lastDx = lastDy = 0;
2713 },
2714 handleEvent: function handleEvent( /**Event*/evt) {
2715 switch (evt.type) {
2716 case 'drop':
2717 case 'dragend':
2718 this._onDrop(evt);
2719 break;
2720 case 'dragenter':
2721 case 'dragover':
2722 if (dragEl) {
2723 this._onDragOver(evt);
2724 _globalDragOver(evt);
2725 }
2726 break;
2727 case 'selectstart':
2728 evt.preventDefault();
2729 break;
2730 }
2731 },
2732 /**
2733 * Serializes the item into an array of string.
2734 * @returns {String[]}
2735 */
2736 toArray: function toArray() {
2737 var order = [],
2738 el,
2739 children = this.el.children,
2740 i = 0,
2741 n = children.length,
2742 options = this.options;
2743 for (; i < n; i++) {
2744 el = children[i];
2745 if (closest(el, options.draggable, this.el, false)) {
2746 order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2747 }
2748 }
2749 return order;
2750 },
2751 /**
2752 * Sorts the elements according to the array.
2753 * @param {String[]} order order of the items
2754 */
2755 sort: function sort(order, useAnimation) {
2756 var items = {},
2757 rootEl = this.el;
2758 this.toArray().forEach(function (id, i) {
2759 var el = rootEl.children[i];
2760 if (closest(el, this.options.draggable, rootEl, false)) {
2761 items[id] = el;
2762 }
2763 }, this);
2764 useAnimation && this.captureAnimationState();
2765 order.forEach(function (id) {
2766 if (items[id]) {
2767 rootEl.removeChild(items[id]);
2768 rootEl.appendChild(items[id]);
2769 }
2770 });
2771 useAnimation && this.animateAll();
2772 },
2773 /**
2774 * Save the current sorting
2775 */
2776 save: function save() {
2777 var store = this.options.store;
2778 store && store.set && store.set(this);
2779 },
2780 /**
2781 * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
2782 * @param {HTMLElement} el
2783 * @param {String} [selector] default: `options.draggable`
2784 * @returns {HTMLElement|null}
2785 */
2786 closest: function closest$1(el, selector) {
2787 return closest(el, selector || this.options.draggable, this.el, false);
2788 },
2789 /**
2790 * Set/get option
2791 * @param {string} name
2792 * @param {*} [value]
2793 * @returns {*}
2794 */
2795 option: function option(name, value) {
2796 var options = this.options;
2797 if (value === void 0) {
2798 return options[name];
2799 } else {
2800 var modifiedValue = PluginManager.modifyOption(this, name, value);
2801 if (typeof modifiedValue !== 'undefined') {
2802 options[name] = modifiedValue;
2803 } else {
2804 options[name] = value;
2805 }
2806 if (name === 'group') {
2807 _prepareGroup(options);
2808 }
2809 }
2810 },
2811 /**
2812 * Destroy
2813 */
2814 destroy: function destroy() {
2815 pluginEvent('destroy', this);
2816 var el = this.el;
2817 el[expando] = null;
2818 off(el, 'mousedown', this._onTapStart);
2819 off(el, 'touchstart', this._onTapStart);
2820 off(el, 'pointerdown', this._onTapStart);
2821 if (this.nativeDraggable) {
2822 off(el, 'dragover', this);
2823 off(el, 'dragenter', this);
2824 }
2825 // Remove draggable attributes
2826 Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2827 el.removeAttribute('draggable');
2828 });
2829 this._onDrop();
2830 this._disableDelayedDragEvents();
2831 sortables.splice(sortables.indexOf(this.el), 1);
2832 this.el = el = null;
2833 },
2834 _hideClone: function _hideClone() {
2835 if (!cloneHidden) {
2836 pluginEvent('hideClone', this);
2837 if (Sortable.eventCanceled) return;
2838 css(cloneEl, 'display', 'none');
2839 if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2840 cloneEl.parentNode.removeChild(cloneEl);
2841 }
2842 cloneHidden = true;
2843 }
2844 },
2845 _showClone: function _showClone(putSortable) {
2846 if (putSortable.lastPutMode !== 'clone') {
2847 this._hideClone();
2848 return;
2849 }
2850 if (cloneHidden) {
2851 pluginEvent('showClone', this);
2852 if (Sortable.eventCanceled) return;
2853
2854 // show clone at dragEl or original position
2855 if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2856 rootEl.insertBefore(cloneEl, dragEl);
2857 } else if (nextEl) {
2858 rootEl.insertBefore(cloneEl, nextEl);
2859 } else {
2860 rootEl.appendChild(cloneEl);
2861 }
2862 if (this.options.group.revertClone) {
2863 this.animate(dragEl, cloneEl);
2864 }
2865 css(cloneEl, 'display', '');
2866 cloneHidden = false;
2867 }
2868 }
2869 };
2870 function _globalDragOver( /**Event*/evt) {
2871 if (evt.dataTransfer) {
2872 evt.dataTransfer.dropEffect = 'move';
2873 }
2874 evt.cancelable && evt.preventDefault();
2875 }
2876 function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2877 var evt,
2878 sortable = fromEl[expando],
2879 onMoveFn = sortable.options.onMove,
2880 retVal;
2881 // Support for new CustomEvent feature
2882 if (window.CustomEvent && !IE11OrLess && !Edge) {
2883 evt = new CustomEvent('move', {
2884 bubbles: true,
2885 cancelable: true
2886 });
2887 } else {
2888 evt = document.createEvent('Event');
2889 evt.initEvent('move', true, true);
2890 }
2891 evt.to = toEl;
2892 evt.from = fromEl;
2893 evt.dragged = dragEl;
2894 evt.draggedRect = dragRect;
2895 evt.related = targetEl || toEl;
2896 evt.relatedRect = targetRect || getRect(toEl);
2897 evt.willInsertAfter = willInsertAfter;
2898 evt.originalEvent = originalEvent;
2899 fromEl.dispatchEvent(evt);
2900 if (onMoveFn) {
2901 retVal = onMoveFn.call(sortable, evt, originalEvent);
2902 }
2903 return retVal;
2904 }
2905 function _disableDraggable(el) {
2906 el.draggable = false;
2907 }
2908 function _unsilent() {
2909 _silent = false;
2910 }
2911 function _ghostIsFirst(evt, vertical, sortable) {
2912 var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2913 var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2914 var spacer = 10;
2915 return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2916 }
2917 function _ghostIsLast(evt, vertical, sortable) {
2918 var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2919 var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2920 var spacer = 10;
2921 return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2922 }
2923 function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2924 var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2925 targetLength = vertical ? targetRect.height : targetRect.width,
2926 targetS1 = vertical ? targetRect.top : targetRect.left,
2927 targetS2 = vertical ? targetRect.bottom : targetRect.right,
2928 invert = false;
2929 if (!invertSwap) {
2930 // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2931 if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2932 // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2933 // check if past first invert threshold on side opposite of lastDirection
2934 if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2935 // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2936 pastFirstInvertThresh = true;
2937 }
2938 if (!pastFirstInvertThresh) {
2939 // dragEl shadow (target move distance shadow)
2940 if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2941 : mouseOnAxis > targetS2 - targetMoveDistance) {
2942 return -lastDirection;
2943 }
2944 } else {
2945 invert = true;
2946 }
2947 } else {
2948 // Regular
2949 if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2950 return _getInsertDirection(target);
2951 }
2952 }
2953 }
2954 invert = invert || invertSwap;
2955 if (invert) {
2956 // Invert of regular
2957 if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2958 return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2959 }
2960 }
2961 return 0;
2962 }
2963
2964 /**
2965 * Gets the direction dragEl must be swapped relative to target in order to make it
2966 * seem that dragEl has been "inserted" into that element's position
2967 * @param {HTMLElement} target The target whose position dragEl is being inserted at
2968 * @return {Number} Direction dragEl must be swapped
2969 */
2970 function _getInsertDirection(target) {
2971 if (index(dragEl) < index(target)) {
2972 return 1;
2973 } else {
2974 return -1;
2975 }
2976 }
2977
2978 /**
2979 * Generate id
2980 * @param {HTMLElement} el
2981 * @returns {String}
2982 * @private
2983 */
2984 function _generateId(el) {
2985 var str = el.tagName + el.className + el.src + el.href + el.textContent,
2986 i = str.length,
2987 sum = 0;
2988 while (i--) {
2989 sum += str.charCodeAt(i);
2990 }
2991 return sum.toString(36);
2992 }
2993 function _saveInputCheckedState(root) {
2994 savedInputChecked.length = 0;
2995 var inputs = root.getElementsByTagName('input');
2996 var idx = inputs.length;
2997 while (idx--) {
2998 var el = inputs[idx];
2999 el.checked && savedInputChecked.push(el);
3000 }
3001 }
3002 function _nextTick(fn) {
3003 return setTimeout(fn, 0);
3004 }
3005 function _cancelNextTick(id) {
3006 return clearTimeout(id);
3007 }
3008
3009 // Fixed #973:
3010 if (documentExists) {
3011 on(document, 'touchmove', function (evt) {
3012 if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
3013 evt.preventDefault();
3014 }
3015 });
3016 }
3017
3018 // Export utils
3019 Sortable.utils = {
3020 on: on,
3021 off: off,
3022 css: css,
3023 find: find,
3024 is: function is(el, selector) {
3025 return !!closest(el, selector, el, false);
3026 },
3027 extend: extend,
3028 throttle: throttle,
3029 closest: closest,
3030 toggleClass: toggleClass,
3031 clone: clone,
3032 index: index,
3033 nextTick: _nextTick,
3034 cancelNextTick: _cancelNextTick,
3035 detectDirection: _detectDirection,
3036 getChild: getChild,
3037 expando: expando
3038 };
3039
3040 /**
3041 * Get the Sortable instance of an element
3042 * @param {HTMLElement} element The element
3043 * @return {Sortable|undefined} The instance of Sortable
3044 */
3045 Sortable.get = function (element) {
3046 return element[expando];
3047 };
3048
3049 /**
3050 * Mount a plugin to Sortable
3051 * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
3052 */
3053 Sortable.mount = function () {
3054 for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
3055 plugins[_key] = arguments[_key];
3056 }
3057 if (plugins[0].constructor === Array) plugins = plugins[0];
3058 plugins.forEach(function (plugin) {
3059 if (!plugin.prototype || !plugin.prototype.constructor) {
3060 throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
3061 }
3062 if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
3063 PluginManager.mount(plugin);
3064 });
3065 };
3066
3067 /**
3068 * Create sortable instance
3069 * @param {HTMLElement} el
3070 * @param {Object} [options]
3071 */
3072 Sortable.create = function (el, options) {
3073 return new Sortable(el, options);
3074 };
3075
3076 // Export
3077 Sortable.version = version;
3078
3079 var autoScrolls = [],
3080 scrollEl,
3081 scrollRootEl,
3082 scrolling = false,
3083 lastAutoScrollX,
3084 lastAutoScrollY,
3085 touchEvt$1,
3086 pointerElemChangedInterval;
3087 function AutoScrollPlugin() {
3088 function AutoScroll() {
3089 this.defaults = {
3090 scroll: true,
3091 forceAutoScrollFallback: false,
3092 scrollSensitivity: 30,
3093 scrollSpeed: 10,
3094 bubbleScroll: true
3095 };
3096
3097 // Bind all private methods
3098 for (var fn in this) {
3099 if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
3100 this[fn] = this[fn].bind(this);
3101 }
3102 }
3103 }
3104 AutoScroll.prototype = {
3105 dragStarted: function dragStarted(_ref) {
3106 var originalEvent = _ref.originalEvent;
3107 if (this.sortable.nativeDraggable) {
3108 on(document, 'dragover', this._handleAutoScroll);
3109 } else {
3110 if (this.options.supportPointer) {
3111 on(document, 'pointermove', this._handleFallbackAutoScroll);
3112 } else if (originalEvent.touches) {
3113 on(document, 'touchmove', this._handleFallbackAutoScroll);
3114 } else {
3115 on(document, 'mousemove', this._handleFallbackAutoScroll);
3116 }
3117 }
3118 },
3119 dragOverCompleted: function dragOverCompleted(_ref2) {
3120 var originalEvent = _ref2.originalEvent;
3121 // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
3122 if (!this.options.dragOverBubble && !originalEvent.rootEl) {
3123 this._handleAutoScroll(originalEvent);
3124 }
3125 },
3126 drop: function drop() {
3127 if (this.sortable.nativeDraggable) {
3128 off(document, 'dragover', this._handleAutoScroll);
3129 } else {
3130 off(document, 'pointermove', this._handleFallbackAutoScroll);
3131 off(document, 'touchmove', this._handleFallbackAutoScroll);
3132 off(document, 'mousemove', this._handleFallbackAutoScroll);
3133 }
3134 clearPointerElemChangedInterval();
3135 clearAutoScrolls();
3136 cancelThrottle();
3137 },
3138 nulling: function nulling() {
3139 touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
3140 autoScrolls.length = 0;
3141 },
3142 _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
3143 this._handleAutoScroll(evt, true);
3144 },
3145 _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
3146 var _this = this;
3147 var x = (evt.touches ? evt.touches[0] : evt).clientX,
3148 y = (evt.touches ? evt.touches[0] : evt).clientY,
3149 elem = document.elementFromPoint(x, y);
3150 touchEvt$1 = evt;
3151
3152 // IE does not seem to have native autoscroll,
3153 // Edge's autoscroll seems too conditional,
3154 // MACOS Safari does not have autoscroll,
3155 // Firefox and Chrome are good
3156 if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
3157 autoScroll(evt, this.options, elem, fallback);
3158
3159 // Listener for pointer element change
3160 var ogElemScroller = getParentAutoScrollElement(elem, true);
3161 if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
3162 pointerElemChangedInterval && clearPointerElemChangedInterval();
3163 // Detect for pointer elem change, emulating native DnD behaviour
3164 pointerElemChangedInterval = setInterval(function () {
3165 var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
3166 if (newElem !== ogElemScroller) {
3167 ogElemScroller = newElem;
3168 clearAutoScrolls();
3169 }
3170 autoScroll(evt, _this.options, newElem, fallback);
3171 }, 10);
3172 lastAutoScrollX = x;
3173 lastAutoScrollY = y;
3174 }
3175 } else {
3176 // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
3177 if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
3178 clearAutoScrolls();
3179 return;
3180 }
3181 autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
3182 }
3183 }
3184 };
3185 return _extends(AutoScroll, {
3186 pluginName: 'scroll',
3187 initializeByDefault: true
3188 });
3189 }
3190 function clearAutoScrolls() {
3191 autoScrolls.forEach(function (autoScroll) {
3192 clearInterval(autoScroll.pid);
3193 });
3194 autoScrolls = [];
3195 }
3196 function clearPointerElemChangedInterval() {
3197 clearInterval(pointerElemChangedInterval);
3198 }
3199 var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
3200 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
3201 if (!options.scroll) return;
3202 var x = (evt.touches ? evt.touches[0] : evt).clientX,
3203 y = (evt.touches ? evt.touches[0] : evt).clientY,
3204 sens = options.scrollSensitivity,
3205 speed = options.scrollSpeed,
3206 winScroller = getWindowScrollingElement();
3207 var scrollThisInstance = false,
3208 scrollCustomFn;
3209
3210 // New scroll root, set scrollEl
3211 if (scrollRootEl !== rootEl) {
3212 scrollRootEl = rootEl;
3213 clearAutoScrolls();
3214 scrollEl = options.scroll;
3215 scrollCustomFn = options.scrollFn;
3216 if (scrollEl === true) {
3217 scrollEl = getParentAutoScrollElement(rootEl, true);
3218 }
3219 }
3220 var layersOut = 0;
3221 var currentParent = scrollEl;
3222 do {
3223 var el = currentParent,
3224 rect = getRect(el),
3225 top = rect.top,
3226 bottom = rect.bottom,
3227 left = rect.left,
3228 right = rect.right,
3229 width = rect.width,
3230 height = rect.height,
3231 canScrollX = void 0,
3232 canScrollY = void 0,
3233 scrollWidth = el.scrollWidth,
3234 scrollHeight = el.scrollHeight,
3235 elCSS = css(el),
3236 scrollPosX = el.scrollLeft,
3237 scrollPosY = el.scrollTop;
3238 if (el === winScroller) {
3239 canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
3240 canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
3241 } else {
3242 canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
3243 canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
3244 }
3245 var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
3246 var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
3247 if (!autoScrolls[layersOut]) {
3248 for (var i = 0; i <= layersOut; i++) {
3249 if (!autoScrolls[i]) {
3250 autoScrolls[i] = {};
3251 }
3252 }
3253 }
3254 if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
3255 autoScrolls[layersOut].el = el;
3256 autoScrolls[layersOut].vx = vx;
3257 autoScrolls[layersOut].vy = vy;
3258 clearInterval(autoScrolls[layersOut].pid);
3259 if (vx != 0 || vy != 0) {
3260 scrollThisInstance = true;
3261 /* jshint loopfunc:true */
3262 autoScrolls[layersOut].pid = setInterval(function () {
3263 // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
3264 if (isFallback && this.layer === 0) {
3265 Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
3266 }
3267 var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
3268 var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
3269 if (typeof scrollCustomFn === 'function') {
3270 if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
3271 return;
3272 }
3273 }
3274 scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
3275 }.bind({
3276 layer: layersOut
3277 }), 24);
3278 }
3279 }
3280 layersOut++;
3281 } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
3282 scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
3283 }, 30);
3284
3285 var drop = function drop(_ref) {
3286 var originalEvent = _ref.originalEvent,
3287 putSortable = _ref.putSortable,
3288 dragEl = _ref.dragEl,
3289 activeSortable = _ref.activeSortable,
3290 dispatchSortableEvent = _ref.dispatchSortableEvent,
3291 hideGhostForTarget = _ref.hideGhostForTarget,
3292 unhideGhostForTarget = _ref.unhideGhostForTarget;
3293 if (!originalEvent) return;
3294 var toSortable = putSortable || activeSortable;
3295 hideGhostForTarget();
3296 var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
3297 var target = document.elementFromPoint(touch.clientX, touch.clientY);
3298 unhideGhostForTarget();
3299 if (toSortable && !toSortable.el.contains(target)) {
3300 dispatchSortableEvent('spill');
3301 this.onSpill({
3302 dragEl: dragEl,
3303 putSortable: putSortable
3304 });
3305 }
3306 };
3307 function Revert() {}
3308 Revert.prototype = {
3309 startIndex: null,
3310 dragStart: function dragStart(_ref2) {
3311 var oldDraggableIndex = _ref2.oldDraggableIndex;
3312 this.startIndex = oldDraggableIndex;
3313 },
3314 onSpill: function onSpill(_ref3) {
3315 var dragEl = _ref3.dragEl,
3316 putSortable = _ref3.putSortable;
3317 this.sortable.captureAnimationState();
3318 if (putSortable) {
3319 putSortable.captureAnimationState();
3320 }
3321 var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
3322 if (nextSibling) {
3323 this.sortable.el.insertBefore(dragEl, nextSibling);
3324 } else {
3325 this.sortable.el.appendChild(dragEl);
3326 }
3327 this.sortable.animateAll();
3328 if (putSortable) {
3329 putSortable.animateAll();
3330 }
3331 },
3332 drop: drop
3333 };
3334 _extends(Revert, {
3335 pluginName: 'revertOnSpill'
3336 });
3337 function Remove() {}
3338 Remove.prototype = {
3339 onSpill: function onSpill(_ref4) {
3340 var dragEl = _ref4.dragEl,
3341 putSortable = _ref4.putSortable;
3342 var parentSortable = putSortable || this.sortable;
3343 parentSortable.captureAnimationState();
3344 dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
3345 parentSortable.animateAll();
3346 },
3347 drop: drop
3348 };
3349 _extends(Remove, {
3350 pluginName: 'removeOnSpill'
3351 });
3352
3353 var lastSwapEl;
3354 function SwapPlugin() {
3355 function Swap() {
3356 this.defaults = {
3357 swapClass: 'sortable-swap-highlight'
3358 };
3359 }
3360 Swap.prototype = {
3361 dragStart: function dragStart(_ref) {
3362 var dragEl = _ref.dragEl;
3363 lastSwapEl = dragEl;
3364 },
3365 dragOverValid: function dragOverValid(_ref2) {
3366 var completed = _ref2.completed,
3367 target = _ref2.target,
3368 onMove = _ref2.onMove,
3369 activeSortable = _ref2.activeSortable,
3370 changed = _ref2.changed,
3371 cancel = _ref2.cancel;
3372 if (!activeSortable.options.swap) return;
3373 var el = this.sortable.el,
3374 options = this.options;
3375 if (target && target !== el) {
3376 var prevSwapEl = lastSwapEl;
3377 if (onMove(target) !== false) {
3378 toggleClass(target, options.swapClass, true);
3379 lastSwapEl = target;
3380 } else {
3381 lastSwapEl = null;
3382 }
3383 if (prevSwapEl && prevSwapEl !== lastSwapEl) {
3384 toggleClass(prevSwapEl, options.swapClass, false);
3385 }
3386 }
3387 changed();
3388 completed(true);
3389 cancel();
3390 },
3391 drop: function drop(_ref3) {
3392 var activeSortable = _ref3.activeSortable,
3393 putSortable = _ref3.putSortable,
3394 dragEl = _ref3.dragEl;
3395 var toSortable = putSortable || this.sortable;
3396 var options = this.options;
3397 lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
3398 if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
3399 if (dragEl !== lastSwapEl) {
3400 toSortable.captureAnimationState();
3401 if (toSortable !== activeSortable) activeSortable.captureAnimationState();
3402 swapNodes(dragEl, lastSwapEl);
3403 toSortable.animateAll();
3404 if (toSortable !== activeSortable) activeSortable.animateAll();
3405 }
3406 }
3407 },
3408 nulling: function nulling() {
3409 lastSwapEl = null;
3410 }
3411 };
3412 return _extends(Swap, {
3413 pluginName: 'swap',
3414 eventProperties: function eventProperties() {
3415 return {
3416 swapItem: lastSwapEl
3417 };
3418 }
3419 });
3420 }
3421 function swapNodes(n1, n2) {
3422 var p1 = n1.parentNode,
3423 p2 = n2.parentNode,
3424 i1,
3425 i2;
3426 if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
3427 i1 = index(n1);
3428 i2 = index(n2);
3429 if (p1.isEqualNode(p2) && i1 < i2) {
3430 i2++;
3431 }
3432 p1.insertBefore(n2, p1.children[i1]);
3433 p2.insertBefore(n1, p2.children[i2]);
3434 }
3435
3436 var multiDragElements = [],
3437 multiDragClones = [],
3438 lastMultiDragSelect,
3439 // for selection with modifier key down (SHIFT)
3440 multiDragSortable,
3441 initialFolding = false,
3442 // Initial multi-drag fold when drag started
3443 folding = false,
3444 // Folding any other time
3445 dragStarted = false,
3446 dragEl$1,
3447 clonesFromRect,
3448 clonesHidden;
3449 function MultiDragPlugin() {
3450 function MultiDrag(sortable) {
3451 // Bind all private methods
3452 for (var fn in this) {
3453 if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
3454 this[fn] = this[fn].bind(this);
3455 }
3456 }
3457 if (!sortable.options.avoidImplicitDeselect) {
3458 if (sortable.options.supportPointer) {
3459 on(document, 'pointerup', this._deselectMultiDrag);
3460 } else {
3461 on(document, 'mouseup', this._deselectMultiDrag);
3462 on(document, 'touchend', this._deselectMultiDrag);
3463 }
3464 }
3465 on(document, 'keydown', this._checkKeyDown);
3466 on(document, 'keyup', this._checkKeyUp);
3467 this.defaults = {
3468 selectedClass: 'sortable-selected',
3469 multiDragKey: null,
3470 avoidImplicitDeselect: false,
3471 setData: function setData(dataTransfer, dragEl) {
3472 var data = '';
3473 if (multiDragElements.length && multiDragSortable === sortable) {
3474 multiDragElements.forEach(function (multiDragElement, i) {
3475 data += (!i ? '' : ', ') + multiDragElement.textContent;
3476 });
3477 } else {
3478 data = dragEl.textContent;
3479 }
3480 dataTransfer.setData('Text', data);
3481 }
3482 };
3483 }
3484 MultiDrag.prototype = {
3485 multiDragKeyDown: false,
3486 isMultiDrag: false,
3487 delayStartGlobal: function delayStartGlobal(_ref) {
3488 var dragged = _ref.dragEl;
3489 dragEl$1 = dragged;
3490 },
3491 delayEnded: function delayEnded() {
3492 this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
3493 },
3494 setupClone: function setupClone(_ref2) {
3495 var sortable = _ref2.sortable,
3496 cancel = _ref2.cancel;
3497 if (!this.isMultiDrag) return;
3498 for (var i = 0; i < multiDragElements.length; i++) {
3499 multiDragClones.push(clone(multiDragElements[i]));
3500 multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
3501 multiDragClones[i].draggable = false;
3502 multiDragClones[i].style['will-change'] = '';
3503 toggleClass(multiDragClones[i], this.options.selectedClass, false);
3504 multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
3505 }
3506 sortable._hideClone();
3507 cancel();
3508 },
3509 clone: function clone(_ref3) {
3510 var sortable = _ref3.sortable,
3511 rootEl = _ref3.rootEl,
3512 dispatchSortableEvent = _ref3.dispatchSortableEvent,
3513 cancel = _ref3.cancel;
3514 if (!this.isMultiDrag) return;
3515 if (!this.options.removeCloneOnHide) {
3516 if (multiDragElements.length && multiDragSortable === sortable) {
3517 insertMultiDragClones(true, rootEl);
3518 dispatchSortableEvent('clone');
3519 cancel();
3520 }
3521 }
3522 },
3523 showClone: function showClone(_ref4) {
3524 var cloneNowShown = _ref4.cloneNowShown,
3525 rootEl = _ref4.rootEl,
3526 cancel = _ref4.cancel;
3527 if (!this.isMultiDrag) return;
3528 insertMultiDragClones(false, rootEl);
3529 multiDragClones.forEach(function (clone) {
3530 css(clone, 'display', '');
3531 });
3532 cloneNowShown();
3533 clonesHidden = false;
3534 cancel();
3535 },
3536 hideClone: function hideClone(_ref5) {
3537 var _this = this;
3538 var sortable = _ref5.sortable,
3539 cloneNowHidden = _ref5.cloneNowHidden,
3540 cancel = _ref5.cancel;
3541 if (!this.isMultiDrag) return;
3542 multiDragClones.forEach(function (clone) {
3543 css(clone, 'display', 'none');
3544 if (_this.options.removeCloneOnHide && clone.parentNode) {
3545 clone.parentNode.removeChild(clone);
3546 }
3547 });
3548 cloneNowHidden();
3549 clonesHidden = true;
3550 cancel();
3551 },
3552 dragStartGlobal: function dragStartGlobal(_ref6) {
3553 var sortable = _ref6.sortable;
3554 if (!this.isMultiDrag && multiDragSortable) {
3555 multiDragSortable.multiDrag._deselectMultiDrag();
3556 }
3557 multiDragElements.forEach(function (multiDragElement) {
3558 multiDragElement.sortableIndex = index(multiDragElement);
3559 });
3560
3561 // Sort multi-drag elements
3562 multiDragElements = multiDragElements.sort(function (a, b) {
3563 return a.sortableIndex - b.sortableIndex;
3564 });
3565 dragStarted = true;
3566 },
3567 dragStarted: function dragStarted(_ref7) {
3568 var _this2 = this;
3569 var sortable = _ref7.sortable;
3570 if (!this.isMultiDrag) return;
3571 if (this.options.sort) {
3572 // Capture rects,
3573 // hide multi drag elements (by positioning them absolute),
3574 // set multi drag elements rects to dragRect,
3575 // show multi drag elements,
3576 // animate to rects,
3577 // unset rects & remove from DOM
3578
3579 sortable.captureAnimationState();
3580 if (this.options.animation) {
3581 multiDragElements.forEach(function (multiDragElement) {
3582 if (multiDragElement === dragEl$1) return;
3583 css(multiDragElement, 'position', 'absolute');
3584 });
3585 var dragRect = getRect(dragEl$1, false, true, true);
3586 multiDragElements.forEach(function (multiDragElement) {
3587 if (multiDragElement === dragEl$1) return;
3588 setRect(multiDragElement, dragRect);
3589 });
3590 folding = true;
3591 initialFolding = true;
3592 }
3593 }
3594 sortable.animateAll(function () {
3595 folding = false;
3596 initialFolding = false;
3597 if (_this2.options.animation) {
3598 multiDragElements.forEach(function (multiDragElement) {
3599 unsetRect(multiDragElement);
3600 });
3601 }
3602
3603 // Remove all auxiliary multidrag items from el, if sorting enabled
3604 if (_this2.options.sort) {
3605 removeMultiDragElements();
3606 }
3607 });
3608 },
3609 dragOver: function dragOver(_ref8) {
3610 var target = _ref8.target,
3611 completed = _ref8.completed,
3612 cancel = _ref8.cancel;
3613 if (folding && ~multiDragElements.indexOf(target)) {
3614 completed(false);
3615 cancel();
3616 }
3617 },
3618 revert: function revert(_ref9) {
3619 var fromSortable = _ref9.fromSortable,
3620 rootEl = _ref9.rootEl,
3621 sortable = _ref9.sortable,
3622 dragRect = _ref9.dragRect;
3623 if (multiDragElements.length > 1) {
3624 // Setup unfold animation
3625 multiDragElements.forEach(function (multiDragElement) {
3626 sortable.addAnimationState({
3627 target: multiDragElement,
3628 rect: folding ? getRect(multiDragElement) : dragRect
3629 });
3630 unsetRect(multiDragElement);
3631 multiDragElement.fromRect = dragRect;
3632 fromSortable.removeAnimationState(multiDragElement);
3633 });
3634 folding = false;
3635 insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
3636 }
3637 },
3638 dragOverCompleted: function dragOverCompleted(_ref10) {
3639 var sortable = _ref10.sortable,
3640 isOwner = _ref10.isOwner,
3641 insertion = _ref10.insertion,
3642 activeSortable = _ref10.activeSortable,
3643 parentEl = _ref10.parentEl,
3644 putSortable = _ref10.putSortable;
3645 var options = this.options;
3646 if (insertion) {
3647 // Clones must be hidden before folding animation to capture dragRectAbsolute properly
3648 if (isOwner) {
3649 activeSortable._hideClone();
3650 }
3651 initialFolding = false;
3652 // If leaving sort:false root, or already folding - Fold to new location
3653 if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
3654 // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
3655 var dragRectAbsolute = getRect(dragEl$1, false, true, true);
3656 multiDragElements.forEach(function (multiDragElement) {
3657 if (multiDragElement === dragEl$1) return;
3658 setRect(multiDragElement, dragRectAbsolute);
3659
3660 // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
3661 // while folding, and so that we can capture them again because old sortable will no longer be fromSortable
3662 parentEl.appendChild(multiDragElement);
3663 });
3664 folding = true;
3665 }
3666
3667 // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
3668 if (!isOwner) {
3669 // Only remove if not folding (folding will remove them anyways)
3670 if (!folding) {
3671 removeMultiDragElements();
3672 }
3673 if (multiDragElements.length > 1) {
3674 var clonesHiddenBefore = clonesHidden;
3675 activeSortable._showClone(sortable);
3676
3677 // Unfold animation for clones if showing from hidden
3678 if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
3679 multiDragClones.forEach(function (clone) {
3680 activeSortable.addAnimationState({
3681 target: clone,
3682 rect: clonesFromRect
3683 });
3684 clone.fromRect = clonesFromRect;
3685 clone.thisAnimationDuration = null;
3686 });
3687 }
3688 } else {
3689 activeSortable._showClone(sortable);
3690 }
3691 }
3692 }
3693 },
3694 dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
3695 var dragRect = _ref11.dragRect,
3696 isOwner = _ref11.isOwner,
3697 activeSortable = _ref11.activeSortable;
3698 multiDragElements.forEach(function (multiDragElement) {
3699 multiDragElement.thisAnimationDuration = null;
3700 });
3701 if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
3702 clonesFromRect = _extends({}, dragRect);
3703 var dragMatrix = matrix(dragEl$1, true);
3704 clonesFromRect.top -= dragMatrix.f;
3705 clonesFromRect.left -= dragMatrix.e;
3706 }
3707 },
3708 dragOverAnimationComplete: function dragOverAnimationComplete() {
3709 if (folding) {
3710 folding = false;
3711 removeMultiDragElements();
3712 }
3713 },
3714 drop: function drop(_ref12) {
3715 var evt = _ref12.originalEvent,
3716 rootEl = _ref12.rootEl,
3717 parentEl = _ref12.parentEl,
3718 sortable = _ref12.sortable,
3719 dispatchSortableEvent = _ref12.dispatchSortableEvent,
3720 oldIndex = _ref12.oldIndex,
3721 putSortable = _ref12.putSortable;
3722 var toSortable = putSortable || this.sortable;
3723 if (!evt) return;
3724 var options = this.options,
3725 children = parentEl.children;
3726
3727 // Multi-drag selection
3728 if (!dragStarted) {
3729 if (options.multiDragKey && !this.multiDragKeyDown) {
3730 this._deselectMultiDrag();
3731 }
3732 toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
3733 if (!~multiDragElements.indexOf(dragEl$1)) {
3734 multiDragElements.push(dragEl$1);
3735 dispatchEvent({
3736 sortable: sortable,
3737 rootEl: rootEl,
3738 name: 'select',
3739 targetEl: dragEl$1,
3740 originalEvent: evt
3741 });
3742
3743 // Modifier activated, select from last to dragEl
3744 if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
3745 var lastIndex = index(lastMultiDragSelect),
3746 currentIndex = index(dragEl$1);
3747 if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3748 (function () {
3749 // Must include lastMultiDragSelect (select it), in case modified selection from no selection
3750 // (but previous selection existed)
3751 var n, i;
3752 if (currentIndex > lastIndex) {
3753 i = lastIndex;
3754 n = currentIndex;
3755 } else {
3756 i = currentIndex;
3757 n = lastIndex + 1;
3758 }
3759 var filter = options.filter;
3760 for (; i < n; i++) {
3761 if (~multiDragElements.indexOf(children[i])) continue;
3762 // Check if element is draggable
3763 if (!closest(children[i], options.draggable, parentEl, false)) continue;
3764 // Check if element is filtered
3765 var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
3766 return closest(children[i], criteria.trim(), parentEl, false);
3767 }));
3768 if (filtered) continue;
3769 toggleClass(children[i], options.selectedClass, true);
3770 multiDragElements.push(children[i]);
3771 dispatchEvent({
3772 sortable: sortable,
3773 rootEl: rootEl,
3774 name: 'select',
3775 targetEl: children[i],
3776 originalEvent: evt
3777 });
3778 }
3779 })();
3780 }
3781 } else {
3782 lastMultiDragSelect = dragEl$1;
3783 }
3784 multiDragSortable = toSortable;
3785 } else {
3786 multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
3787 lastMultiDragSelect = null;
3788 dispatchEvent({
3789 sortable: sortable,
3790 rootEl: rootEl,
3791 name: 'deselect',
3792 targetEl: dragEl$1,
3793 originalEvent: evt
3794 });
3795 }
3796 }
3797
3798 // Multi-drag drop
3799 if (dragStarted && this.isMultiDrag) {
3800 folding = false;
3801 // Do not "unfold" after around dragEl if reverted
3802 if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
3803 var dragRect = getRect(dragEl$1),
3804 multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
3805 if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
3806 toSortable.captureAnimationState();
3807 if (!initialFolding) {
3808 if (options.animation) {
3809 dragEl$1.fromRect = dragRect;
3810 multiDragElements.forEach(function (multiDragElement) {
3811 multiDragElement.thisAnimationDuration = null;
3812 if (multiDragElement !== dragEl$1) {
3813 var rect = folding ? getRect(multiDragElement) : dragRect;
3814 multiDragElement.fromRect = rect;
3815
3816 // Prepare unfold animation
3817 toSortable.addAnimationState({
3818 target: multiDragElement,
3819 rect: rect
3820 });
3821 }
3822 });
3823 }
3824
3825 // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
3826 // properly they must all be removed
3827 removeMultiDragElements();
3828 multiDragElements.forEach(function (multiDragElement) {
3829 if (children[multiDragIndex]) {
3830 parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
3831 } else {
3832 parentEl.appendChild(multiDragElement);
3833 }
3834 multiDragIndex++;
3835 });
3836
3837 // If initial folding is done, the elements may have changed position because they are now
3838 // unfolding around dragEl, even though dragEl may not have his index changed, so update event
3839 // must be fired here as Sortable will not.
3840 if (oldIndex === index(dragEl$1)) {
3841 var update = false;
3842 multiDragElements.forEach(function (multiDragElement) {
3843 if (multiDragElement.sortableIndex !== index(multiDragElement)) {
3844 update = true;
3845 return;
3846 }
3847 });
3848 if (update) {
3849 dispatchSortableEvent('update');
3850 dispatchSortableEvent('sort');
3851 }
3852 }
3853 }
3854
3855 // Must be done after capturing individual rects (scroll bar)
3856 multiDragElements.forEach(function (multiDragElement) {
3857 unsetRect(multiDragElement);
3858 });
3859 toSortable.animateAll();
3860 }
3861 multiDragSortable = toSortable;
3862 }
3863
3864 // Remove clones if necessary
3865 if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
3866 multiDragClones.forEach(function (clone) {
3867 clone.parentNode && clone.parentNode.removeChild(clone);
3868 });
3869 }
3870 },
3871 nullingGlobal: function nullingGlobal() {
3872 this.isMultiDrag = dragStarted = false;
3873 multiDragClones.length = 0;
3874 },
3875 destroyGlobal: function destroyGlobal() {
3876 this._deselectMultiDrag();
3877 off(document, 'pointerup', this._deselectMultiDrag);
3878 off(document, 'mouseup', this._deselectMultiDrag);
3879 off(document, 'touchend', this._deselectMultiDrag);
3880 off(document, 'keydown', this._checkKeyDown);
3881 off(document, 'keyup', this._checkKeyUp);
3882 },
3883 _deselectMultiDrag: function _deselectMultiDrag(evt) {
3884 if (typeof dragStarted !== "undefined" && dragStarted) return;
3885
3886 // Only deselect if selection is in this sortable
3887 if (multiDragSortable !== this.sortable) return;
3888
3889 // Only deselect if target is not item in this sortable
3890 if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
3891
3892 // Only deselect if left click
3893 if (evt && evt.button !== 0) return;
3894 while (multiDragElements.length) {
3895 var el = multiDragElements[0];
3896 toggleClass(el, this.options.selectedClass, false);
3897 multiDragElements.shift();
3898 dispatchEvent({
3899 sortable: this.sortable,
3900 rootEl: this.sortable.el,
3901 name: 'deselect',
3902 targetEl: el,
3903 originalEvent: evt
3904 });
3905 }
3906 },
3907 _checkKeyDown: function _checkKeyDown(evt) {
3908 if (evt.key === this.options.multiDragKey) {
3909 this.multiDragKeyDown = true;
3910 }
3911 },
3912 _checkKeyUp: function _checkKeyUp(evt) {
3913 if (evt.key === this.options.multiDragKey) {
3914 this.multiDragKeyDown = false;
3915 }
3916 }
3917 };
3918 return _extends(MultiDrag, {
3919 // Static methods & properties
3920 pluginName: 'multiDrag',
3921 utils: {
3922 /**
3923 * Selects the provided multi-drag item
3924 * @param {HTMLElement} el The element to be selected
3925 */
3926 select: function select(el) {
3927 var sortable = el.parentNode[expando];
3928 if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
3929 if (multiDragSortable && multiDragSortable !== sortable) {
3930 multiDragSortable.multiDrag._deselectMultiDrag();
3931 multiDragSortable = sortable;
3932 }
3933 toggleClass(el, sortable.options.selectedClass, true);
3934 multiDragElements.push(el);
3935 },
3936 /**
3937 * Deselects the provided multi-drag item
3938 * @param {HTMLElement} el The element to be deselected
3939 */
3940 deselect: function deselect(el) {
3941 var sortable = el.parentNode[expando],
3942 index = multiDragElements.indexOf(el);
3943 if (!sortable || !sortable.options.multiDrag || !~index) return;
3944 toggleClass(el, sortable.options.selectedClass, false);
3945 multiDragElements.splice(index, 1);
3946 }
3947 },
3948 eventProperties: function eventProperties() {
3949 var _this3 = this;
3950 var oldIndicies = [],
3951 newIndicies = [];
3952 multiDragElements.forEach(function (multiDragElement) {
3953 oldIndicies.push({
3954 multiDragElement: multiDragElement,
3955 index: multiDragElement.sortableIndex
3956 });
3957
3958 // multiDragElements will already be sorted if folding
3959 var newIndex;
3960 if (folding && multiDragElement !== dragEl$1) {
3961 newIndex = -1;
3962 } else if (folding) {
3963 newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
3964 } else {
3965 newIndex = index(multiDragElement);
3966 }
3967 newIndicies.push({
3968 multiDragElement: multiDragElement,
3969 index: newIndex
3970 });
3971 });
3972 return {
3973 items: _toConsumableArray(multiDragElements),
3974 clones: [].concat(multiDragClones),
3975 oldIndicies: oldIndicies,
3976 newIndicies: newIndicies
3977 };
3978 },
3979 optionListeners: {
3980 multiDragKey: function multiDragKey(key) {
3981 key = key.toLowerCase();
3982 if (key === 'ctrl') {
3983 key = 'Control';
3984 } else if (key.length > 1) {
3985 key = key.charAt(0).toUpperCase() + key.substr(1);
3986 }
3987 return key;
3988 }
3989 }
3990 });
3991 }
3992 function insertMultiDragElements(clonesInserted, rootEl) {
3993 multiDragElements.forEach(function (multiDragElement, i) {
3994 var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
3995 if (target) {
3996 rootEl.insertBefore(multiDragElement, target);
3997 } else {
3998 rootEl.appendChild(multiDragElement);
3999 }
4000 });
4001 }
4002
4003 /**
4004 * Insert multi-drag clones
4005 * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
4006 * @param {HTMLElement} rootEl
4007 */
4008 function insertMultiDragClones(elementsInserted, rootEl) {
4009 multiDragClones.forEach(function (clone, i) {
4010 var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
4011 if (target) {
4012 rootEl.insertBefore(clone, target);
4013 } else {
4014 rootEl.appendChild(clone);
4015 }
4016 });
4017 }
4018 function removeMultiDragElements() {
4019 multiDragElements.forEach(function (multiDragElement) {
4020 if (multiDragElement === dragEl$1) return;
4021 multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
4022 });
4023 }
4024
4025 Sortable.mount(new AutoScrollPlugin());
4026 Sortable.mount(Remove, Revert);
4027
4028 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Sortable);
4029
4030
4031
4032 /***/ },
4033
4034 /***/ "./node_modules/toastify-js/src/toastify.css"
4035 /*!***************************************************!*\
4036 !*** ./node_modules/toastify-js/src/toastify.css ***!
4037 \***************************************************/
4038 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4039
4040 "use strict";
4041 __webpack_require__.r(__webpack_exports__);
4042 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4043 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
4044 /* harmony export */ });
4045 /* 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");
4046 /* 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__);
4047 /* 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");
4048 /* 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__);
4049 /* 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");
4050 /* 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__);
4051 /* 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");
4052 /* 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__);
4053 /* 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");
4054 /* 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__);
4055 /* 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");
4056 /* 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__);
4057 /* 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");
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069 var options = {};
4070
4071 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
4072 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
4073
4074 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
4075
4076 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
4077 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
4078
4079 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);
4080
4081
4082
4083
4084 /* 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);
4085
4086
4087 /***/ },
4088
4089 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
4090 /*!****************************************************************************!*\
4091 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
4092 \****************************************************************************/
4093 (module) {
4094
4095 "use strict";
4096
4097
4098 var stylesInDOM = [];
4099 function getIndexByIdentifier(identifier) {
4100 var result = -1;
4101 for (var i = 0; i < stylesInDOM.length; i++) {
4102 if (stylesInDOM[i].identifier === identifier) {
4103 result = i;
4104 break;
4105 }
4106 }
4107 return result;
4108 }
4109 function modulesToDom(list, options) {
4110 var idCountMap = {};
4111 var identifiers = [];
4112 for (var i = 0; i < list.length; i++) {
4113 var item = list[i];
4114 var id = options.base ? item[0] + options.base : item[0];
4115 var count = idCountMap[id] || 0;
4116 var identifier = "".concat(id, " ").concat(count);
4117 idCountMap[id] = count + 1;
4118 var indexByIdentifier = getIndexByIdentifier(identifier);
4119 var obj = {
4120 css: item[1],
4121 media: item[2],
4122 sourceMap: item[3],
4123 supports: item[4],
4124 layer: item[5]
4125 };
4126 if (indexByIdentifier !== -1) {
4127 stylesInDOM[indexByIdentifier].references++;
4128 stylesInDOM[indexByIdentifier].updater(obj);
4129 } else {
4130 var updater = addElementStyle(obj, options);
4131 options.byIndex = i;
4132 stylesInDOM.splice(i, 0, {
4133 identifier: identifier,
4134 updater: updater,
4135 references: 1
4136 });
4137 }
4138 identifiers.push(identifier);
4139 }
4140 return identifiers;
4141 }
4142 function addElementStyle(obj, options) {
4143 var api = options.domAPI(options);
4144 api.update(obj);
4145 var updater = function updater(newObj) {
4146 if (newObj) {
4147 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
4148 return;
4149 }
4150 api.update(obj = newObj);
4151 } else {
4152 api.remove();
4153 }
4154 };
4155 return updater;
4156 }
4157 module.exports = function (list, options) {
4158 options = options || {};
4159 list = list || [];
4160 var lastIdentifiers = modulesToDom(list, options);
4161 return function update(newList) {
4162 newList = newList || [];
4163 for (var i = 0; i < lastIdentifiers.length; i++) {
4164 var identifier = lastIdentifiers[i];
4165 var index = getIndexByIdentifier(identifier);
4166 stylesInDOM[index].references--;
4167 }
4168 var newLastIdentifiers = modulesToDom(newList, options);
4169 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
4170 var _identifier = lastIdentifiers[_i];
4171 var _index = getIndexByIdentifier(_identifier);
4172 if (stylesInDOM[_index].references === 0) {
4173 stylesInDOM[_index].updater();
4174 stylesInDOM.splice(_index, 1);
4175 }
4176 }
4177 lastIdentifiers = newLastIdentifiers;
4178 };
4179 };
4180
4181 /***/ },
4182
4183 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
4184 /*!********************************************************************!*\
4185 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
4186 \********************************************************************/
4187 (module) {
4188
4189 "use strict";
4190
4191
4192 var memo = {};
4193
4194 /* istanbul ignore next */
4195 function getTarget(target) {
4196 if (typeof memo[target] === "undefined") {
4197 var styleTarget = document.querySelector(target);
4198
4199 // Special case to return head of iframe instead of iframe itself
4200 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
4201 try {
4202 // This will throw an exception if access to iframe is blocked
4203 // due to cross-origin restrictions
4204 styleTarget = styleTarget.contentDocument.head;
4205 } catch (e) {
4206 // istanbul ignore next
4207 styleTarget = null;
4208 }
4209 }
4210 memo[target] = styleTarget;
4211 }
4212 return memo[target];
4213 }
4214
4215 /* istanbul ignore next */
4216 function insertBySelector(insert, style) {
4217 var target = getTarget(insert);
4218 if (!target) {
4219 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
4220 }
4221 target.appendChild(style);
4222 }
4223 module.exports = insertBySelector;
4224
4225 /***/ },
4226
4227 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
4228 /*!**********************************************************************!*\
4229 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
4230 \**********************************************************************/
4231 (module) {
4232
4233 "use strict";
4234
4235
4236 /* istanbul ignore next */
4237 function insertStyleElement(options) {
4238 var element = document.createElement("style");
4239 options.setAttributes(element, options.attributes);
4240 options.insert(element, options.options);
4241 return element;
4242 }
4243 module.exports = insertStyleElement;
4244
4245 /***/ },
4246
4247 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
4248 /*!**********************************************************************************!*\
4249 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
4250 \**********************************************************************************/
4251 (module, __unused_webpack_exports, __webpack_require__) {
4252
4253 "use strict";
4254
4255
4256 /* istanbul ignore next */
4257 function setAttributesWithoutAttributes(styleElement) {
4258 var nonce = true ? __webpack_require__.nc : 0;
4259 if (nonce) {
4260 styleElement.setAttribute("nonce", nonce);
4261 }
4262 }
4263 module.exports = setAttributesWithoutAttributes;
4264
4265 /***/ },
4266
4267 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
4268 /*!***************************************************************!*\
4269 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
4270 \***************************************************************/
4271 (module) {
4272
4273 "use strict";
4274
4275
4276 /* istanbul ignore next */
4277 function apply(styleElement, options, obj) {
4278 var css = "";
4279 if (obj.supports) {
4280 css += "@supports (".concat(obj.supports, ") {");
4281 }
4282 if (obj.media) {
4283 css += "@media ".concat(obj.media, " {");
4284 }
4285 var needLayer = typeof obj.layer !== "undefined";
4286 if (needLayer) {
4287 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
4288 }
4289 css += obj.css;
4290 if (needLayer) {
4291 css += "}";
4292 }
4293 if (obj.media) {
4294 css += "}";
4295 }
4296 if (obj.supports) {
4297 css += "}";
4298 }
4299 var sourceMap = obj.sourceMap;
4300 if (sourceMap && typeof btoa !== "undefined") {
4301 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
4302 }
4303
4304 // For old IE
4305 /* istanbul ignore if */
4306 options.styleTagTransform(css, styleElement, options.options);
4307 }
4308 function removeStyleElement(styleElement) {
4309 // istanbul ignore if
4310 if (styleElement.parentNode === null) {
4311 return false;
4312 }
4313 styleElement.parentNode.removeChild(styleElement);
4314 }
4315
4316 /* istanbul ignore next */
4317 function domAPI(options) {
4318 if (typeof document === "undefined") {
4319 return {
4320 update: function update() {},
4321 remove: function remove() {}
4322 };
4323 }
4324 var styleElement = options.insertStyleElement(options);
4325 return {
4326 update: function update(obj) {
4327 apply(styleElement, options, obj);
4328 },
4329 remove: function remove() {
4330 removeStyleElement(styleElement);
4331 }
4332 };
4333 }
4334 module.exports = domAPI;
4335
4336 /***/ },
4337
4338 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
4339 /*!*********************************************************************!*\
4340 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
4341 \*********************************************************************/
4342 (module) {
4343
4344 "use strict";
4345
4346
4347 /* istanbul ignore next */
4348 function styleTagTransform(css, styleElement) {
4349 if (styleElement.styleSheet) {
4350 styleElement.styleSheet.cssText = css;
4351 } else {
4352 while (styleElement.firstChild) {
4353 styleElement.removeChild(styleElement.firstChild);
4354 }
4355 styleElement.appendChild(document.createTextNode(css));
4356 }
4357 }
4358 module.exports = styleTagTransform;
4359
4360 /***/ },
4361
4362 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
4363 /*!**********************************************************!*\
4364 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
4365 \**********************************************************/
4366 (module) {
4367
4368 /*!
4369 * sweetalert2 v11.26.17
4370 * Released under the MIT License.
4371 */
4372 (function (global, factory) {
4373 true ? module.exports = factory() :
4374 0;
4375 })(this, (function () { 'use strict';
4376
4377 function _assertClassBrand(e, t, n) {
4378 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
4379 throw new TypeError("Private element is not present on this object");
4380 }
4381 function _checkPrivateRedeclaration(e, t) {
4382 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
4383 }
4384 function _classPrivateFieldGet2(s, a) {
4385 return s.get(_assertClassBrand(s, a));
4386 }
4387 function _classPrivateFieldInitSpec(e, t, a) {
4388 _checkPrivateRedeclaration(e, t), t.set(e, a);
4389 }
4390 function _classPrivateFieldSet2(s, a, r) {
4391 return s.set(_assertClassBrand(s, a), r), r;
4392 }
4393
4394 const RESTORE_FOCUS_TIMEOUT = 100;
4395
4396 /** @type {GlobalState} */
4397 const globalState = {};
4398 const focusPreviousActiveElement = () => {
4399 if (globalState.previousActiveElement instanceof HTMLElement) {
4400 globalState.previousActiveElement.focus();
4401 globalState.previousActiveElement = null;
4402 } else if (document.body) {
4403 document.body.focus();
4404 }
4405 };
4406
4407 /**
4408 * Restore previous active (focused) element
4409 *
4410 * @param {boolean} returnFocus
4411 * @returns {Promise<void>}
4412 */
4413 const restoreActiveElement = returnFocus => {
4414 return new Promise(resolve => {
4415 if (!returnFocus) {
4416 return resolve();
4417 }
4418 const x = window.scrollX;
4419 const y = window.scrollY;
4420 globalState.restoreFocusTimeout = setTimeout(() => {
4421 focusPreviousActiveElement();
4422 resolve();
4423 }, RESTORE_FOCUS_TIMEOUT); // issues/900
4424
4425 window.scrollTo(x, y);
4426 });
4427 };
4428
4429 const swalPrefix = 'swal2-';
4430
4431 /**
4432 * @typedef {Record<SwalClass, string>} SwalClasses
4433 */
4434
4435 /**
4436 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
4437 * @typedef {Record<SwalIcon, string>} SwalIcons
4438 */
4439
4440 /** @type {SwalClass[]} */
4441 const classNames = ['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error', 'draggable', 'dragging'];
4442 const swalClasses = classNames.reduce((acc, className) => {
4443 acc[className] = swalPrefix + className;
4444 return acc;
4445 }, /** @type {SwalClasses} */{});
4446
4447 /** @type {SwalIcon[]} */
4448 const icons = ['success', 'warning', 'info', 'question', 'error'];
4449 const iconTypes = icons.reduce((acc, icon) => {
4450 acc[icon] = swalPrefix + icon;
4451 return acc;
4452 }, /** @type {SwalIcons} */{});
4453
4454 const consolePrefix = 'SweetAlert2:';
4455
4456 /**
4457 * Capitalize the first letter of a string
4458 *
4459 * @param {string} str
4460 * @returns {string}
4461 */
4462 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
4463
4464 /**
4465 * Standardize console warnings
4466 *
4467 * @param {string | string[]} message
4468 */
4469 const warn = message => {
4470 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
4471 };
4472
4473 /**
4474 * Standardize console errors
4475 *
4476 * @param {string} message
4477 */
4478 const error = message => {
4479 console.error(`${consolePrefix} ${message}`);
4480 };
4481
4482 /**
4483 * Private global state for `warnOnce`
4484 *
4485 * @type {string[]}
4486 * @private
4487 */
4488 const previousWarnOnceMessages = [];
4489
4490 /**
4491 * Show a console warning, but only if it hasn't already been shown
4492 *
4493 * @param {string} message
4494 */
4495 const warnOnce = message => {
4496 if (!previousWarnOnceMessages.includes(message)) {
4497 previousWarnOnceMessages.push(message);
4498 warn(message);
4499 }
4500 };
4501
4502 /**
4503 * Show a one-time console warning about deprecated params/methods
4504 *
4505 * @param {string} deprecatedParam
4506 * @param {string?} useInstead
4507 */
4508 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
4509 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
4510 };
4511
4512 /**
4513 * If `arg` is a function, call it (with no arguments or context) and return the result.
4514 * Otherwise, just pass the value through
4515 *
4516 * @param {(() => *) | *} arg
4517 * @returns {*}
4518 */
4519 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
4520
4521 /**
4522 * @param {*} arg
4523 * @returns {boolean}
4524 */
4525 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
4526
4527 /**
4528 * @param {*} arg
4529 * @returns {Promise<*>}
4530 */
4531 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
4532
4533 /**
4534 * @param {*} arg
4535 * @returns {boolean}
4536 */
4537 const isPromise = arg => arg && Promise.resolve(arg) === arg;
4538
4539 /**
4540 * Gets the popup container which contains the backdrop and the popup itself.
4541 *
4542 * @returns {HTMLElement | null}
4543 */
4544 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
4545
4546 /**
4547 * @param {string} selectorString
4548 * @returns {HTMLElement | null}
4549 */
4550 const elementBySelector = selectorString => {
4551 const container = getContainer();
4552 return container ? container.querySelector(selectorString) : null;
4553 };
4554
4555 /**
4556 * @param {string} className
4557 * @returns {HTMLElement | null}
4558 */
4559 const elementByClass = className => {
4560 return elementBySelector(`.${className}`);
4561 };
4562
4563 /**
4564 * @returns {HTMLElement | null}
4565 */
4566 const getPopup = () => elementByClass(swalClasses.popup);
4567
4568 /**
4569 * @returns {HTMLElement | null}
4570 */
4571 const getIcon = () => elementByClass(swalClasses.icon);
4572
4573 /**
4574 * @returns {HTMLElement | null}
4575 */
4576 const getIconContent = () => elementByClass(swalClasses['icon-content']);
4577
4578 /**
4579 * @returns {HTMLElement | null}
4580 */
4581 const getTitle = () => elementByClass(swalClasses.title);
4582
4583 /**
4584 * @returns {HTMLElement | null}
4585 */
4586 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
4587
4588 /**
4589 * @returns {HTMLElement | null}
4590 */
4591 const getImage = () => elementByClass(swalClasses.image);
4592
4593 /**
4594 * @returns {HTMLElement | null}
4595 */
4596 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
4597
4598 /**
4599 * @returns {HTMLElement | null}
4600 */
4601 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
4602
4603 /**
4604 * @returns {HTMLButtonElement | null}
4605 */
4606 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
4607
4608 /**
4609 * @returns {HTMLButtonElement | null}
4610 */
4611 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
4612
4613 /**
4614 * @returns {HTMLButtonElement | null}
4615 */
4616 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
4617
4618 /**
4619 * @returns {HTMLElement | null}
4620 */
4621 const getInputLabel = () => elementByClass(swalClasses['input-label']);
4622
4623 /**
4624 * @returns {HTMLElement | null}
4625 */
4626 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
4627
4628 /**
4629 * @returns {HTMLElement | null}
4630 */
4631 const getActions = () => elementByClass(swalClasses.actions);
4632
4633 /**
4634 * @returns {HTMLElement | null}
4635 */
4636 const getFooter = () => elementByClass(swalClasses.footer);
4637
4638 /**
4639 * @returns {HTMLElement | null}
4640 */
4641 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
4642
4643 /**
4644 * @returns {HTMLElement | null}
4645 */
4646 const getCloseButton = () => elementByClass(swalClasses.close);
4647
4648 // https://github.com/jkup/focusable/blob/master/index.js
4649 const focusable = `
4650 a[href],
4651 area[href],
4652 input:not([disabled]),
4653 select:not([disabled]),
4654 textarea:not([disabled]),
4655 button:not([disabled]),
4656 iframe,
4657 object,
4658 embed,
4659 [tabindex="0"],
4660 [contenteditable],
4661 audio[controls],
4662 video[controls],
4663 summary
4664 `;
4665 /**
4666 * @returns {HTMLElement[]}
4667 */
4668 const getFocusableElements = () => {
4669 const popup = getPopup();
4670 if (!popup) {
4671 return [];
4672 }
4673 /** @type {NodeListOf<HTMLElement>} */
4674 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
4675 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
4676 // sort according to tabindex
4677 .sort((a, b) => {
4678 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
4679 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
4680 if (tabindexA > tabindexB) {
4681 return 1;
4682 } else if (tabindexA < tabindexB) {
4683 return -1;
4684 }
4685 return 0;
4686 });
4687
4688 /** @type {NodeListOf<HTMLElement>} */
4689 const otherFocusableElements = popup.querySelectorAll(focusable);
4690 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
4691 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
4692 };
4693
4694 /**
4695 * @returns {boolean}
4696 */
4697 const isModal = () => {
4698 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
4699 };
4700
4701 /**
4702 * @returns {boolean}
4703 */
4704 const isToast = () => {
4705 const popup = getPopup();
4706 if (!popup) {
4707 return false;
4708 }
4709 return hasClass(popup, swalClasses.toast);
4710 };
4711
4712 /**
4713 * @returns {boolean}
4714 */
4715 const isLoading = () => {
4716 const popup = getPopup();
4717 if (!popup) {
4718 return false;
4719 }
4720 return popup.hasAttribute('data-loading');
4721 };
4722
4723 /**
4724 * Securely set innerHTML of an element
4725 * https://github.com/sweetalert2/sweetalert2/issues/1926
4726 *
4727 * @param {HTMLElement} elem
4728 * @param {string} html
4729 */
4730 const setInnerHtml = (elem, html) => {
4731 elem.textContent = '';
4732 if (html) {
4733 const parser = new DOMParser();
4734 const parsed = parser.parseFromString(html, `text/html`);
4735 const head = parsed.querySelector('head');
4736 if (head) {
4737 Array.from(head.childNodes).forEach(child => {
4738 elem.appendChild(child);
4739 });
4740 }
4741 const body = parsed.querySelector('body');
4742 if (body) {
4743 Array.from(body.childNodes).forEach(child => {
4744 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
4745 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
4746 } else {
4747 elem.appendChild(child);
4748 }
4749 });
4750 }
4751 }
4752 };
4753
4754 /**
4755 * @param {HTMLElement} elem
4756 * @param {string} className
4757 * @returns {boolean}
4758 */
4759 const hasClass = (elem, className) => {
4760 if (!className) {
4761 return false;
4762 }
4763 const classList = className.split(/\s+/);
4764 for (let i = 0; i < classList.length; i++) {
4765 if (!elem.classList.contains(classList[i])) {
4766 return false;
4767 }
4768 }
4769 return true;
4770 };
4771
4772 /**
4773 * @param {HTMLElement} elem
4774 * @param {SweetAlertOptions} params
4775 */
4776 const removeCustomClasses = (elem, params) => {
4777 Array.from(elem.classList).forEach(className => {
4778 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
4779 elem.classList.remove(className);
4780 }
4781 });
4782 };
4783
4784 /**
4785 * @param {HTMLElement} elem
4786 * @param {SweetAlertOptions} params
4787 * @param {string} className
4788 */
4789 const applyCustomClass = (elem, params, className) => {
4790 removeCustomClasses(elem, params);
4791 if (!params.customClass) {
4792 return;
4793 }
4794 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
4795 if (!customClass) {
4796 return;
4797 }
4798 if (typeof customClass !== 'string' && !customClass.forEach) {
4799 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
4800 return;
4801 }
4802 addClass(elem, customClass);
4803 };
4804
4805 /**
4806 * @param {HTMLElement} popup
4807 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
4808 * @returns {HTMLInputElement | null}
4809 */
4810 const getInput$1 = (popup, inputClass) => {
4811 if (!inputClass) {
4812 return null;
4813 }
4814 switch (inputClass) {
4815 case 'select':
4816 case 'textarea':
4817 case 'file':
4818 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
4819 case 'checkbox':
4820 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
4821 case 'radio':
4822 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
4823 case 'range':
4824 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
4825 default:
4826 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
4827 }
4828 };
4829
4830 /**
4831 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
4832 */
4833 const focusInput = input => {
4834 input.focus();
4835
4836 // place cursor at end of text in text input
4837 if (input.type !== 'file') {
4838 // http://stackoverflow.com/a/2345915
4839 const val = input.value;
4840 input.value = '';
4841 input.value = val;
4842 }
4843 };
4844
4845 /**
4846 * @param {HTMLElement | HTMLElement[] | null} target
4847 * @param {string | string[] | readonly string[] | undefined} classList
4848 * @param {boolean} condition
4849 */
4850 const toggleClass = (target, classList, condition) => {
4851 if (!target || !classList) {
4852 return;
4853 }
4854 if (typeof classList === 'string') {
4855 classList = classList.split(/\s+/).filter(Boolean);
4856 }
4857 classList.forEach(className => {
4858 if (Array.isArray(target)) {
4859 target.forEach(elem => {
4860 if (condition) {
4861 elem.classList.add(className);
4862 } else {
4863 elem.classList.remove(className);
4864 }
4865 });
4866 } else {
4867 if (condition) {
4868 target.classList.add(className);
4869 } else {
4870 target.classList.remove(className);
4871 }
4872 }
4873 });
4874 };
4875
4876 /**
4877 * @param {HTMLElement | HTMLElement[] | null} target
4878 * @param {string | string[] | readonly string[] | undefined} classList
4879 */
4880 const addClass = (target, classList) => {
4881 toggleClass(target, classList, true);
4882 };
4883
4884 /**
4885 * @param {HTMLElement | HTMLElement[] | null} target
4886 * @param {string | string[] | readonly string[] | undefined} classList
4887 */
4888 const removeClass = (target, classList) => {
4889 toggleClass(target, classList, false);
4890 };
4891
4892 /**
4893 * Get direct child of an element by class name
4894 *
4895 * @param {HTMLElement} elem
4896 * @param {string} className
4897 * @returns {HTMLElement | undefined}
4898 */
4899 const getDirectChildByClass = (elem, className) => {
4900 const children = Array.from(elem.children);
4901 for (let i = 0; i < children.length; i++) {
4902 const child = children[i];
4903 if (child instanceof HTMLElement && hasClass(child, className)) {
4904 return child;
4905 }
4906 }
4907 };
4908
4909 /**
4910 * @param {HTMLElement} elem
4911 * @param {string} property
4912 * @param {string | number | null | undefined} value
4913 */
4914 const applyNumericalStyle = (elem, property, value) => {
4915 if (value === `${parseInt(`${value}`)}`) {
4916 value = parseInt(value);
4917 }
4918 if (value || parseInt(`${value}`) === 0) {
4919 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
4920 } else {
4921 elem.style.removeProperty(property);
4922 }
4923 };
4924
4925 /**
4926 * @param {HTMLElement | null} elem
4927 * @param {string} display
4928 */
4929 const show = (elem, display = 'flex') => {
4930 if (!elem) {
4931 return;
4932 }
4933 elem.style.display = display;
4934 };
4935
4936 /**
4937 * @param {HTMLElement | null} elem
4938 */
4939 const hide = elem => {
4940 if (!elem) {
4941 return;
4942 }
4943 elem.style.display = 'none';
4944 };
4945
4946 /**
4947 * @param {HTMLElement | null} elem
4948 * @param {string} display
4949 */
4950 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
4951 if (!elem) {
4952 return;
4953 }
4954 new MutationObserver(() => {
4955 toggle(elem, elem.innerHTML, display);
4956 }).observe(elem, {
4957 childList: true,
4958 subtree: true
4959 });
4960 };
4961
4962 /**
4963 * @param {HTMLElement} parent
4964 * @param {string} selector
4965 * @param {string} property
4966 * @param {string} value
4967 */
4968 const setStyle = (parent, selector, property, value) => {
4969 /** @type {HTMLElement | null} */
4970 const el = parent.querySelector(selector);
4971 if (el) {
4972 el.style.setProperty(property, value);
4973 }
4974 };
4975
4976 /**
4977 * @param {HTMLElement} elem
4978 * @param {boolean | string | null | undefined} condition
4979 * @param {string} display
4980 */
4981 const toggle = (elem, condition, display = 'flex') => {
4982 if (condition) {
4983 show(elem, display);
4984 } else {
4985 hide(elem);
4986 }
4987 };
4988
4989 /**
4990 * borrowed from jquery $(elem).is(':visible') implementation
4991 *
4992 * @param {HTMLElement | null} elem
4993 * @returns {boolean}
4994 */
4995 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
4996
4997 /**
4998 * @returns {boolean}
4999 */
5000 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
5001
5002 /**
5003 * @param {HTMLElement} elem
5004 * @returns {boolean}
5005 */
5006 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
5007
5008 /**
5009 * @param {HTMLElement} element
5010 * @param {HTMLElement} stopElement
5011 * @returns {boolean}
5012 */
5013 const selfOrParentIsScrollable = (element, stopElement) => {
5014 let parent = /** @type {HTMLElement | null} */element;
5015 while (parent && parent !== stopElement) {
5016 if (isScrollable(parent)) {
5017 return true;
5018 }
5019 parent = parent.parentElement;
5020 }
5021 return false;
5022 };
5023
5024 /**
5025 * borrowed from https://stackoverflow.com/a/46352119
5026 *
5027 * @param {HTMLElement} elem
5028 * @returns {boolean}
5029 */
5030 const hasCssAnimation = elem => {
5031 const style = window.getComputedStyle(elem);
5032 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
5033 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
5034 return animDuration > 0 || transDuration > 0;
5035 };
5036
5037 /**
5038 * @param {number} timer
5039 * @param {boolean} reset
5040 */
5041 const animateTimerProgressBar = (timer, reset = false) => {
5042 const timerProgressBar = getTimerProgressBar();
5043 if (!timerProgressBar) {
5044 return;
5045 }
5046 if (isVisible$1(timerProgressBar)) {
5047 if (reset) {
5048 timerProgressBar.style.transition = 'none';
5049 timerProgressBar.style.width = '100%';
5050 }
5051 setTimeout(() => {
5052 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
5053 timerProgressBar.style.width = '0%';
5054 }, 10);
5055 }
5056 };
5057 const stopTimerProgressBar = () => {
5058 const timerProgressBar = getTimerProgressBar();
5059 if (!timerProgressBar) {
5060 return;
5061 }
5062 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
5063 timerProgressBar.style.removeProperty('transition');
5064 timerProgressBar.style.width = '100%';
5065 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
5066 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
5067 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
5068 };
5069
5070 /**
5071 * Detect Node env
5072 *
5073 * @returns {boolean}
5074 */
5075 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
5076
5077 const sweetHTML = `
5078 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
5079 <button type="button" class="${swalClasses.close}"></button>
5080 <ul class="${swalClasses['progress-steps']}"></ul>
5081 <div class="${swalClasses.icon}"></div>
5082 <img class="${swalClasses.image}" />
5083 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
5084 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
5085 <input class="${swalClasses.input}" id="${swalClasses.input}" />
5086 <input type="file" class="${swalClasses.file}" />
5087 <div class="${swalClasses.range}">
5088 <input type="range" />
5089 <output></output>
5090 </div>
5091 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
5092 <div class="${swalClasses.radio}"></div>
5093 <label class="${swalClasses.checkbox}">
5094 <input type="checkbox" id="${swalClasses.checkbox}" />
5095 <span class="${swalClasses.label}"></span>
5096 </label>
5097 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
5098 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
5099 <div class="${swalClasses.actions}">
5100 <div class="${swalClasses.loader}"></div>
5101 <button type="button" class="${swalClasses.confirm}"></button>
5102 <button type="button" class="${swalClasses.deny}"></button>
5103 <button type="button" class="${swalClasses.cancel}"></button>
5104 </div>
5105 <div class="${swalClasses.footer}"></div>
5106 <div class="${swalClasses['timer-progress-bar-container']}">
5107 <div class="${swalClasses['timer-progress-bar']}"></div>
5108 </div>
5109 </div>
5110 `.replace(/(^|\n)\s*/g, '');
5111
5112 /**
5113 * @returns {boolean}
5114 */
5115 const resetOldContainer = () => {
5116 const oldContainer = getContainer();
5117 if (!oldContainer) {
5118 return false;
5119 }
5120 oldContainer.remove();
5121 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
5122 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
5123 swalClasses['has-column']]);
5124 return true;
5125 };
5126 const resetValidationMessage$1 = () => {
5127 if (globalState.currentInstance) {
5128 globalState.currentInstance.resetValidationMessage();
5129 }
5130 };
5131 const addInputChangeListeners = () => {
5132 const popup = getPopup();
5133 if (!popup) {
5134 return;
5135 }
5136 const input = getDirectChildByClass(popup, swalClasses.input);
5137 const file = getDirectChildByClass(popup, swalClasses.file);
5138 /** @type {HTMLInputElement | null} */
5139 const range = popup.querySelector(`.${swalClasses.range} input`);
5140 /** @type {HTMLOutputElement | null} */
5141 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
5142 const select = getDirectChildByClass(popup, swalClasses.select);
5143 /** @type {HTMLInputElement | null} */
5144 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
5145 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
5146 if (input) {
5147 input.oninput = resetValidationMessage$1;
5148 }
5149 if (file) {
5150 file.onchange = resetValidationMessage$1;
5151 }
5152 if (select) {
5153 select.onchange = resetValidationMessage$1;
5154 }
5155 if (checkbox) {
5156 checkbox.onchange = resetValidationMessage$1;
5157 }
5158 if (textarea) {
5159 textarea.oninput = resetValidationMessage$1;
5160 }
5161 if (range && rangeOutput) {
5162 range.oninput = () => {
5163 resetValidationMessage$1();
5164 rangeOutput.value = range.value;
5165 };
5166 range.onchange = () => {
5167 resetValidationMessage$1();
5168 rangeOutput.value = range.value;
5169 };
5170 }
5171 };
5172
5173 /**
5174 * @param {string | HTMLElement} target
5175 * @returns {HTMLElement}
5176 */
5177 const getTarget = target => {
5178 if (typeof target === 'string') {
5179 const element = document.querySelector(target);
5180 if (!element) {
5181 throw new Error(`Target element "${target}" not found`);
5182 }
5183 return /** @type {HTMLElement} */element;
5184 }
5185 return target;
5186 };
5187
5188 /**
5189 * @param {SweetAlertOptions} params
5190 */
5191 const setupAccessibility = params => {
5192 const popup = getPopup();
5193 if (!popup) {
5194 return;
5195 }
5196 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
5197 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
5198 if (!params.toast) {
5199 popup.setAttribute('aria-modal', 'true');
5200 }
5201 };
5202
5203 /**
5204 * @param {HTMLElement} targetElement
5205 */
5206 const setupRTL = targetElement => {
5207 if (window.getComputedStyle(targetElement).direction === 'rtl') {
5208 addClass(getContainer(), swalClasses.rtl);
5209 globalState.isRTL = true;
5210 }
5211 };
5212
5213 /**
5214 * Add modal + backdrop to DOM
5215 *
5216 * @param {SweetAlertOptions} params
5217 */
5218 const init = params => {
5219 // Clean up the old popup container if it exists
5220 const oldContainerExisted = resetOldContainer();
5221 if (isNodeEnv()) {
5222 error('SweetAlert2 requires document to initialize');
5223 return;
5224 }
5225 const container = document.createElement('div');
5226 container.className = swalClasses.container;
5227 if (oldContainerExisted) {
5228 addClass(container, swalClasses['no-transition']);
5229 }
5230 setInnerHtml(container, sweetHTML);
5231 container.dataset['swal2Theme'] = params.theme;
5232 const targetElement = getTarget(params.target || 'body');
5233 targetElement.appendChild(container);
5234 if (params.topLayer) {
5235 container.setAttribute('popover', '');
5236 container.showPopover();
5237 }
5238 setupAccessibility(params);
5239 setupRTL(targetElement);
5240 addInputChangeListeners();
5241 };
5242
5243 /**
5244 * @param {HTMLElement | object | string} param
5245 * @param {HTMLElement} target
5246 */
5247 const parseHtmlToContainer = (param, target) => {
5248 // DOM element
5249 if (param instanceof HTMLElement) {
5250 target.appendChild(param);
5251 }
5252
5253 // Object
5254 else if (typeof param === 'object') {
5255 handleObject(param, target);
5256 }
5257
5258 // Plain string
5259 else if (param) {
5260 setInnerHtml(target, param);
5261 }
5262 };
5263
5264 /**
5265 * @param {object} param
5266 * @param {HTMLElement} target
5267 */
5268 const handleObject = (param, target) => {
5269 // JQuery element(s)
5270 if ('jquery' in param) {
5271 handleJqueryElem(target, param);
5272 }
5273
5274 // For other objects use their string representation
5275 else {
5276 setInnerHtml(target, param.toString());
5277 }
5278 };
5279
5280 /**
5281 * @param {HTMLElement} target
5282 * @param {any} elem
5283 */
5284 const handleJqueryElem = (target, elem) => {
5285 target.textContent = '';
5286 if (0 in elem) {
5287 for (let i = 0; i in elem; i++) {
5288 target.appendChild(elem[i].cloneNode(true));
5289 }
5290 } else {
5291 target.appendChild(elem.cloneNode(true));
5292 }
5293 };
5294
5295 /**
5296 * @param {SweetAlert} instance
5297 * @param {SweetAlertOptions} params
5298 */
5299 const renderActions = (instance, params) => {
5300 const actions = getActions();
5301 const loader = getLoader();
5302 if (!actions || !loader) {
5303 return;
5304 }
5305
5306 // Actions (buttons) wrapper
5307 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
5308 hide(actions);
5309 } else {
5310 show(actions);
5311 }
5312
5313 // Custom class
5314 applyCustomClass(actions, params, 'actions');
5315
5316 // Render all the buttons
5317 renderButtons(actions, loader, params);
5318
5319 // Loader
5320 setInnerHtml(loader, params.loaderHtml || '');
5321 applyCustomClass(loader, params, 'loader');
5322 };
5323
5324 /**
5325 * @param {HTMLElement} actions
5326 * @param {HTMLElement} loader
5327 * @param {SweetAlertOptions} params
5328 */
5329 function renderButtons(actions, loader, params) {
5330 const confirmButton = getConfirmButton();
5331 const denyButton = getDenyButton();
5332 const cancelButton = getCancelButton();
5333 if (!confirmButton || !denyButton || !cancelButton) {
5334 return;
5335 }
5336
5337 // Render buttons
5338 renderButton(confirmButton, 'confirm', params);
5339 renderButton(denyButton, 'deny', params);
5340 renderButton(cancelButton, 'cancel', params);
5341 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
5342 if (params.reverseButtons) {
5343 if (params.toast) {
5344 actions.insertBefore(cancelButton, confirmButton);
5345 actions.insertBefore(denyButton, confirmButton);
5346 } else {
5347 actions.insertBefore(cancelButton, loader);
5348 actions.insertBefore(denyButton, loader);
5349 actions.insertBefore(confirmButton, loader);
5350 }
5351 }
5352 }
5353
5354 /**
5355 * @param {HTMLElement} confirmButton
5356 * @param {HTMLElement} denyButton
5357 * @param {HTMLElement} cancelButton
5358 * @param {SweetAlertOptions} params
5359 */
5360 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
5361 if (!params.buttonsStyling) {
5362 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
5363 return;
5364 }
5365 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
5366
5367 // Apply custom background colors to action buttons
5368 if (params.confirmButtonColor) {
5369 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
5370 }
5371 if (params.denyButtonColor) {
5372 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
5373 }
5374 if (params.cancelButtonColor) {
5375 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
5376 }
5377
5378 // Apply the outline color to action buttons
5379 applyOutlineColor(confirmButton);
5380 applyOutlineColor(denyButton);
5381 applyOutlineColor(cancelButton);
5382 }
5383
5384 /**
5385 * @param {HTMLElement} button
5386 */
5387 function applyOutlineColor(button) {
5388 const buttonStyle = window.getComputedStyle(button);
5389 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
5390 // If the button already has a custom outline color, no need to change it
5391 return;
5392 }
5393 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
5394 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
5395 }
5396
5397 /**
5398 * @param {HTMLElement} button
5399 * @param {'confirm' | 'deny' | 'cancel'} buttonType
5400 * @param {SweetAlertOptions} params
5401 */
5402 function renderButton(button, buttonType, params) {
5403 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
5404 toggle(button, params[`show${buttonName}Button`], 'inline-block');
5405 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
5406 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
5407
5408 // Add buttons custom classes
5409 button.className = swalClasses[buttonType];
5410 applyCustomClass(button, params, `${buttonType}Button`);
5411 }
5412
5413 /**
5414 * @param {SweetAlert} instance
5415 * @param {SweetAlertOptions} params
5416 */
5417 const renderCloseButton = (instance, params) => {
5418 const closeButton = getCloseButton();
5419 if (!closeButton) {
5420 return;
5421 }
5422 setInnerHtml(closeButton, params.closeButtonHtml || '');
5423
5424 // Custom class
5425 applyCustomClass(closeButton, params, 'closeButton');
5426 toggle(closeButton, params.showCloseButton);
5427 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
5428 };
5429
5430 /**
5431 * @param {SweetAlert} instance
5432 * @param {SweetAlertOptions} params
5433 */
5434 const renderContainer = (instance, params) => {
5435 const container = getContainer();
5436 if (!container) {
5437 return;
5438 }
5439 handleBackdropParam(container, params.backdrop);
5440 handlePositionParam(container, params.position);
5441 handleGrowParam(container, params.grow);
5442
5443 // Custom class
5444 applyCustomClass(container, params, 'container');
5445 };
5446
5447 /**
5448 * @param {HTMLElement} container
5449 * @param {SweetAlertOptions['backdrop']} backdrop
5450 */
5451 function handleBackdropParam(container, backdrop) {
5452 if (typeof backdrop === 'string') {
5453 container.style.background = backdrop;
5454 } else if (!backdrop) {
5455 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
5456 }
5457 }
5458
5459 /**
5460 * @param {HTMLElement} container
5461 * @param {SweetAlertOptions['position']} position
5462 */
5463 function handlePositionParam(container, position) {
5464 if (!position) {
5465 return;
5466 }
5467 if (position in swalClasses) {
5468 addClass(container, swalClasses[position]);
5469 } else {
5470 warn('The "position" parameter is not valid, defaulting to "center"');
5471 addClass(container, swalClasses.center);
5472 }
5473 }
5474
5475 /**
5476 * @param {HTMLElement} container
5477 * @param {SweetAlertOptions['grow']} grow
5478 */
5479 function handleGrowParam(container, grow) {
5480 if (!grow) {
5481 return;
5482 }
5483 addClass(container, swalClasses[`grow-${grow}`]);
5484 }
5485
5486 /**
5487 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
5488 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
5489 * This is the approach that Babel will probably take to implement private methods/fields
5490 * https://github.com/tc39/proposal-private-methods
5491 * https://github.com/babel/babel/pull/7555
5492 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
5493 * then we can use that language feature.
5494 */
5495
5496 var privateProps = {
5497 innerParams: new WeakMap(),
5498 domCache: new WeakMap()
5499 };
5500
5501 /// <reference path="../../../../sweetalert2.d.ts"/>
5502
5503
5504 /** @type {InputClass[]} */
5505 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
5506
5507 /**
5508 * @param {SweetAlert} instance
5509 * @param {SweetAlertOptions} params
5510 */
5511 const renderInput = (instance, params) => {
5512 const popup = getPopup();
5513 if (!popup) {
5514 return;
5515 }
5516 const innerParams = privateProps.innerParams.get(instance);
5517 const rerender = !innerParams || params.input !== innerParams.input;
5518 inputClasses.forEach(inputClass => {
5519 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
5520 if (!inputContainer) {
5521 return;
5522 }
5523
5524 // set attributes
5525 setAttributes(inputClass, params.inputAttributes);
5526
5527 // set class
5528 inputContainer.className = swalClasses[inputClass];
5529 if (rerender) {
5530 hide(inputContainer);
5531 }
5532 });
5533 if (params.input) {
5534 if (rerender) {
5535 showInput(params);
5536 }
5537 // set custom class
5538 setCustomClass(params);
5539 }
5540 };
5541
5542 /**
5543 * @param {SweetAlertOptions} params
5544 */
5545 const showInput = params => {
5546 if (!params.input) {
5547 return;
5548 }
5549 if (!renderInputType[params.input]) {
5550 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
5551 return;
5552 }
5553 const inputContainer = getInputContainer(params.input);
5554 if (!inputContainer) {
5555 return;
5556 }
5557 const input = renderInputType[params.input](inputContainer, params);
5558 show(inputContainer);
5559
5560 // input autofocus
5561 if (params.inputAutoFocus) {
5562 setTimeout(() => {
5563 focusInput(input);
5564 });
5565 }
5566 };
5567
5568 /**
5569 * @param {HTMLInputElement} input
5570 */
5571 const removeAttributes = input => {
5572 for (let i = 0; i < input.attributes.length; i++) {
5573 const attrName = input.attributes[i].name;
5574 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
5575 input.removeAttribute(attrName);
5576 }
5577 }
5578 };
5579
5580 /**
5581 * @param {InputClass} inputClass
5582 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
5583 */
5584 const setAttributes = (inputClass, inputAttributes) => {
5585 const popup = getPopup();
5586 if (!popup) {
5587 return;
5588 }
5589 const input = getInput$1(popup, inputClass);
5590 if (!input) {
5591 return;
5592 }
5593 removeAttributes(input);
5594 for (const attr in inputAttributes) {
5595 input.setAttribute(attr, inputAttributes[attr]);
5596 }
5597 };
5598
5599 /**
5600 * @param {SweetAlertOptions} params
5601 */
5602 const setCustomClass = params => {
5603 if (!params.input) {
5604 return;
5605 }
5606 const inputContainer = getInputContainer(params.input);
5607 if (inputContainer) {
5608 applyCustomClass(inputContainer, params, 'input');
5609 }
5610 };
5611
5612 /**
5613 * @param {HTMLInputElement | HTMLTextAreaElement} input
5614 * @param {SweetAlertOptions} params
5615 */
5616 const setInputPlaceholder = (input, params) => {
5617 if (!input.placeholder && params.inputPlaceholder) {
5618 input.placeholder = params.inputPlaceholder;
5619 }
5620 };
5621
5622 /**
5623 * @param {Input} input
5624 * @param {Input} prependTo
5625 * @param {SweetAlertOptions} params
5626 */
5627 const setInputLabel = (input, prependTo, params) => {
5628 if (params.inputLabel) {
5629 const label = document.createElement('label');
5630 const labelClass = swalClasses['input-label'];
5631 label.setAttribute('for', input.id);
5632 label.className = labelClass;
5633 if (typeof params.customClass === 'object') {
5634 addClass(label, params.customClass.inputLabel);
5635 }
5636 label.innerText = params.inputLabel;
5637 prependTo.insertAdjacentElement('beforebegin', label);
5638 }
5639 };
5640
5641 /**
5642 * @param {SweetAlertInput} inputType
5643 * @returns {HTMLElement | undefined}
5644 */
5645 const getInputContainer = inputType => {
5646 const popup = getPopup();
5647 if (!popup) {
5648 return;
5649 }
5650 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
5651 };
5652
5653 /**
5654 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
5655 * @param {SweetAlertOptions['inputValue']} inputValue
5656 */
5657 const checkAndSetInputValue = (input, inputValue) => {
5658 if (['string', 'number'].includes(typeof inputValue)) {
5659 input.value = `${inputValue}`;
5660 } else if (!isPromise(inputValue)) {
5661 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
5662 }
5663 };
5664
5665 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
5666 const renderInputType = {};
5667
5668 /**
5669 * @param {Input | HTMLElement} input
5670 * @param {SweetAlertOptions} params
5671 * @returns {Input}
5672 */
5673 renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType['datetime-local'] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
5674 (input, params) => {
5675 const inputElement = /** @type {HTMLInputElement} */input;
5676 checkAndSetInputValue(inputElement, params.inputValue);
5677 setInputLabel(inputElement, inputElement, params);
5678 setInputPlaceholder(inputElement, params);
5679 inputElement.type = /** @type {string} */params.input;
5680 return inputElement;
5681 };
5682
5683 /**
5684 * @param {Input | HTMLElement} input
5685 * @param {SweetAlertOptions} params
5686 * @returns {Input}
5687 */
5688 renderInputType.file = (input, params) => {
5689 const inputElement = /** @type {HTMLInputElement} */input;
5690 setInputLabel(inputElement, inputElement, params);
5691 setInputPlaceholder(inputElement, params);
5692 return inputElement;
5693 };
5694
5695 /**
5696 * @param {Input | HTMLElement} range
5697 * @param {SweetAlertOptions} params
5698 * @returns {Input}
5699 */
5700 renderInputType.range = (range, params) => {
5701 const rangeContainer = /** @type {HTMLElement} */range;
5702 const rangeInput = rangeContainer.querySelector('input');
5703 const rangeOutput = rangeContainer.querySelector('output');
5704 if (rangeInput) {
5705 checkAndSetInputValue(rangeInput, params.inputValue);
5706 rangeInput.type = /** @type {string} */params.input;
5707 setInputLabel(rangeInput, /** @type {Input} */range, params);
5708 }
5709 if (rangeOutput) {
5710 checkAndSetInputValue(rangeOutput, params.inputValue);
5711 }
5712 return /** @type {Input} */range;
5713 };
5714
5715 /**
5716 * @param {Input | HTMLElement} select
5717 * @param {SweetAlertOptions} params
5718 * @returns {Input}
5719 */
5720 renderInputType.select = (select, params) => {
5721 const selectElement = /** @type {HTMLSelectElement} */select;
5722 selectElement.textContent = '';
5723 if (params.inputPlaceholder) {
5724 const placeholder = document.createElement('option');
5725 setInnerHtml(placeholder, params.inputPlaceholder);
5726 placeholder.value = '';
5727 placeholder.disabled = true;
5728 placeholder.selected = true;
5729 selectElement.appendChild(placeholder);
5730 }
5731 setInputLabel(selectElement, selectElement, params);
5732 return selectElement;
5733 };
5734
5735 /**
5736 * @param {Input | HTMLElement} radio
5737 * @returns {Input}
5738 */
5739 renderInputType.radio = radio => {
5740 const radioElement = /** @type {HTMLElement} */radio;
5741 radioElement.textContent = '';
5742 return /** @type {Input} */radio;
5743 };
5744
5745 /**
5746 * @param {Input | HTMLElement} checkboxContainer
5747 * @param {SweetAlertOptions} params
5748 * @returns {Input}
5749 */
5750 renderInputType.checkbox = (checkboxContainer, params) => {
5751 const popup = getPopup();
5752 if (!popup) {
5753 throw new Error('Popup not found');
5754 }
5755 const checkbox = getInput$1(popup, 'checkbox');
5756 if (!checkbox) {
5757 throw new Error('Checkbox input not found');
5758 }
5759 checkbox.value = '1';
5760 checkbox.checked = Boolean(params.inputValue);
5761 const containerElement = /** @type {HTMLElement} */checkboxContainer;
5762 const label = containerElement.querySelector('span');
5763 if (label) {
5764 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
5765 if (placeholderOrLabel) {
5766 setInnerHtml(label, placeholderOrLabel);
5767 }
5768 }
5769 return checkbox;
5770 };
5771
5772 /**
5773 * @param {Input | HTMLElement} textarea
5774 * @param {SweetAlertOptions} params
5775 * @returns {Input}
5776 */
5777 renderInputType.textarea = (textarea, params) => {
5778 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
5779 checkAndSetInputValue(textareaElement, params.inputValue);
5780 setInputPlaceholder(textareaElement, params);
5781 setInputLabel(textareaElement, textareaElement, params);
5782
5783 /**
5784 * @param {HTMLElement} el
5785 * @returns {number}
5786 */
5787 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
5788
5789 // https://github.com/sweetalert2/sweetalert2/issues/2291
5790 setTimeout(() => {
5791 // https://github.com/sweetalert2/sweetalert2/issues/1699
5792 if ('MutationObserver' in window) {
5793 const popup = getPopup();
5794 if (!popup) {
5795 return;
5796 }
5797 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
5798 const textareaResizeHandler = () => {
5799 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
5800 if (!document.body.contains(textareaElement)) {
5801 return;
5802 }
5803 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
5804 const popupElement = getPopup();
5805 if (popupElement) {
5806 if (textareaWidth > initialPopupWidth) {
5807 popupElement.style.width = `${textareaWidth}px`;
5808 } else {
5809 applyNumericalStyle(popupElement, 'width', params.width);
5810 }
5811 }
5812 };
5813 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
5814 attributes: true,
5815 attributeFilter: ['style']
5816 });
5817 }
5818 });
5819 return textareaElement;
5820 };
5821
5822 /**
5823 * @param {SweetAlert} instance
5824 * @param {SweetAlertOptions} params
5825 */
5826 const renderContent = (instance, params) => {
5827 const htmlContainer = getHtmlContainer();
5828 if (!htmlContainer) {
5829 return;
5830 }
5831 showWhenInnerHtmlPresent(htmlContainer);
5832 applyCustomClass(htmlContainer, params, 'htmlContainer');
5833
5834 // Content as HTML
5835 if (params.html) {
5836 parseHtmlToContainer(params.html, htmlContainer);
5837 show(htmlContainer, 'block');
5838 }
5839
5840 // Content as plain text
5841 else if (params.text) {
5842 htmlContainer.textContent = params.text;
5843 show(htmlContainer, 'block');
5844 }
5845
5846 // No content
5847 else {
5848 hide(htmlContainer);
5849 }
5850 renderInput(instance, params);
5851 };
5852
5853 /**
5854 * @param {SweetAlert} instance
5855 * @param {SweetAlertOptions} params
5856 */
5857 const renderFooter = (instance, params) => {
5858 const footer = getFooter();
5859 if (!footer) {
5860 return;
5861 }
5862 showWhenInnerHtmlPresent(footer);
5863 toggle(footer, Boolean(params.footer), 'block');
5864 if (params.footer) {
5865 parseHtmlToContainer(params.footer, footer);
5866 }
5867
5868 // Custom class
5869 applyCustomClass(footer, params, 'footer');
5870 };
5871
5872 /**
5873 * @param {SweetAlert} instance
5874 * @param {SweetAlertOptions} params
5875 */
5876 const renderIcon = (instance, params) => {
5877 const innerParams = privateProps.innerParams.get(instance);
5878 const icon = getIcon();
5879 if (!icon) {
5880 return;
5881 }
5882
5883 // if the given icon already rendered, apply the styling without re-rendering the icon
5884 if (innerParams && params.icon === innerParams.icon) {
5885 // Custom or default content
5886 setContent(icon, params);
5887 applyStyles(icon, params);
5888 return;
5889 }
5890 if (!params.icon && !params.iconHtml) {
5891 hide(icon);
5892 return;
5893 }
5894 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
5895 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
5896 hide(icon);
5897 return;
5898 }
5899 show(icon);
5900
5901 // Custom or default content
5902 setContent(icon, params);
5903 applyStyles(icon, params);
5904
5905 // Animate icon
5906 addClass(icon, params.showClass && params.showClass.icon);
5907
5908 // Re-adjust the success icon on system theme change
5909 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
5910 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
5911 };
5912
5913 /**
5914 * @param {HTMLElement} icon
5915 * @param {SweetAlertOptions} params
5916 */
5917 const applyStyles = (icon, params) => {
5918 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
5919 if (params.icon !== iconType) {
5920 removeClass(icon, iconClassName);
5921 }
5922 }
5923 addClass(icon, params.icon && iconTypes[params.icon]);
5924
5925 // Icon color
5926 setColor(icon, params);
5927
5928 // Success icon background color
5929 adjustSuccessIconBackgroundColor();
5930
5931 // Custom class
5932 applyCustomClass(icon, params, 'icon');
5933 };
5934
5935 // Adjust success icon background color to match the popup background color
5936 const adjustSuccessIconBackgroundColor = () => {
5937 const popup = getPopup();
5938 if (!popup) {
5939 return;
5940 }
5941 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
5942 /** @type {NodeListOf<HTMLElement>} */
5943 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
5944 for (let i = 0; i < successIconParts.length; i++) {
5945 successIconParts[i].style.backgroundColor = popupBackgroundColor;
5946 }
5947 };
5948
5949 /**
5950 *
5951 * @param {SweetAlertOptions} params
5952 * @returns {string}
5953 */
5954 const successIconHtml = params => `
5955 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
5956 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
5957 <div class="swal2-success-ring"></div>
5958 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
5959 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
5960 `;
5961 const errorIconHtml = `
5962 <span class="swal2-x-mark">
5963 <span class="swal2-x-mark-line-left"></span>
5964 <span class="swal2-x-mark-line-right"></span>
5965 </span>
5966 `;
5967
5968 /**
5969 * @param {HTMLElement} icon
5970 * @param {SweetAlertOptions} params
5971 */
5972 const setContent = (icon, params) => {
5973 if (!params.icon && !params.iconHtml) {
5974 return;
5975 }
5976 let oldContent = icon.innerHTML;
5977 let newContent = '';
5978 if (params.iconHtml) {
5979 newContent = iconContent(params.iconHtml);
5980 } else if (params.icon === 'success') {
5981 newContent = successIconHtml(params);
5982 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
5983 } else if (params.icon === 'error') {
5984 newContent = errorIconHtml;
5985 } else if (params.icon) {
5986 const defaultIconHtml = {
5987 question: '?',
5988 warning: '!',
5989 info: 'i'
5990 };
5991 newContent = iconContent(defaultIconHtml[params.icon]);
5992 }
5993 if (oldContent.trim() !== newContent.trim()) {
5994 setInnerHtml(icon, newContent);
5995 }
5996 };
5997
5998 /**
5999 * @param {HTMLElement} icon
6000 * @param {SweetAlertOptions} params
6001 */
6002 const setColor = (icon, params) => {
6003 if (!params.iconColor) {
6004 return;
6005 }
6006 icon.style.color = params.iconColor;
6007 icon.style.borderColor = params.iconColor;
6008 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
6009 setStyle(icon, sel, 'background-color', params.iconColor);
6010 }
6011 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
6012 };
6013
6014 /**
6015 * @param {string} content
6016 * @returns {string}
6017 */
6018 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
6019
6020 /**
6021 * @param {SweetAlert} instance
6022 * @param {SweetAlertOptions} params
6023 */
6024 const renderImage = (instance, params) => {
6025 const image = getImage();
6026 if (!image) {
6027 return;
6028 }
6029 if (!params.imageUrl) {
6030 hide(image);
6031 return;
6032 }
6033 show(image, '');
6034
6035 // Src, alt
6036 image.setAttribute('src', params.imageUrl);
6037 image.setAttribute('alt', params.imageAlt || '');
6038
6039 // Width, height
6040 applyNumericalStyle(image, 'width', params.imageWidth);
6041 applyNumericalStyle(image, 'height', params.imageHeight);
6042
6043 // Class
6044 image.className = swalClasses.image;
6045 applyCustomClass(image, params, 'image');
6046 };
6047
6048 let dragging = false;
6049 let mousedownX = 0;
6050 let mousedownY = 0;
6051 let initialX = 0;
6052 let initialY = 0;
6053
6054 /**
6055 * @param {HTMLElement} popup
6056 */
6057 const addDraggableListeners = popup => {
6058 popup.addEventListener('mousedown', down);
6059 document.body.addEventListener('mousemove', move);
6060 popup.addEventListener('mouseup', up);
6061 popup.addEventListener('touchstart', down);
6062 document.body.addEventListener('touchmove', move);
6063 popup.addEventListener('touchend', up);
6064 };
6065
6066 /**
6067 * @param {HTMLElement} popup
6068 */
6069 const removeDraggableListeners = popup => {
6070 popup.removeEventListener('mousedown', down);
6071 document.body.removeEventListener('mousemove', move);
6072 popup.removeEventListener('mouseup', up);
6073 popup.removeEventListener('touchstart', down);
6074 document.body.removeEventListener('touchmove', move);
6075 popup.removeEventListener('touchend', up);
6076 };
6077
6078 /**
6079 * @param {MouseEvent | TouchEvent} event
6080 */
6081 const down = event => {
6082 const popup = getPopup();
6083 if (!popup) {
6084 return;
6085 }
6086 const icon = getIcon();
6087 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
6088 dragging = true;
6089 const clientXY = getClientXY(event);
6090 mousedownX = clientXY.clientX;
6091 mousedownY = clientXY.clientY;
6092 initialX = parseInt(popup.style.insetInlineStart) || 0;
6093 initialY = parseInt(popup.style.insetBlockStart) || 0;
6094 addClass(popup, 'swal2-dragging');
6095 }
6096 };
6097
6098 /**
6099 * @param {MouseEvent | TouchEvent} event
6100 */
6101 const move = event => {
6102 const popup = getPopup();
6103 if (!popup) {
6104 return;
6105 }
6106 if (dragging) {
6107 let {
6108 clientX,
6109 clientY
6110 } = getClientXY(event);
6111 const deltaX = clientX - mousedownX;
6112 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
6113 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
6114 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
6115 }
6116 };
6117 const up = () => {
6118 const popup = getPopup();
6119 dragging = false;
6120 removeClass(popup, 'swal2-dragging');
6121 };
6122
6123 /**
6124 * @param {MouseEvent | TouchEvent} event
6125 * @returns {{ clientX: number, clientY: number }}
6126 */
6127 const getClientXY = event => {
6128 let clientX = 0,
6129 clientY = 0;
6130 if (event.type.startsWith('mouse')) {
6131 clientX = /** @type {MouseEvent} */event.clientX;
6132 clientY = /** @type {MouseEvent} */event.clientY;
6133 } else if (event.type.startsWith('touch')) {
6134 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
6135 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
6136 }
6137 return {
6138 clientX,
6139 clientY
6140 };
6141 };
6142
6143 /**
6144 * @param {SweetAlert} instance
6145 * @param {SweetAlertOptions} params
6146 */
6147 const renderPopup = (instance, params) => {
6148 const container = getContainer();
6149 const popup = getPopup();
6150 if (!container || !popup) {
6151 return;
6152 }
6153
6154 // Width
6155 // https://github.com/sweetalert2/sweetalert2/issues/2170
6156 if (params.toast) {
6157 applyNumericalStyle(container, 'width', params.width);
6158 popup.style.width = '100%';
6159 const loader = getLoader();
6160 if (loader) {
6161 popup.insertBefore(loader, getIcon());
6162 }
6163 } else {
6164 applyNumericalStyle(popup, 'width', params.width);
6165 }
6166
6167 // Padding
6168 applyNumericalStyle(popup, 'padding', params.padding);
6169
6170 // Color
6171 if (params.color) {
6172 popup.style.color = params.color;
6173 }
6174
6175 // Background
6176 if (params.background) {
6177 popup.style.background = params.background;
6178 }
6179 hide(getValidationMessage());
6180
6181 // Classes
6182 addClasses$1(popup, params);
6183 if (params.draggable && !params.toast) {
6184 addClass(popup, swalClasses.draggable);
6185 addDraggableListeners(popup);
6186 } else {
6187 removeClass(popup, swalClasses.draggable);
6188 removeDraggableListeners(popup);
6189 }
6190 };
6191
6192 /**
6193 * @param {HTMLElement} popup
6194 * @param {SweetAlertOptions} params
6195 */
6196 const addClasses$1 = (popup, params) => {
6197 const showClass = params.showClass || {};
6198 // Default Class + showClass when updating Swal.update({})
6199 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
6200 if (params.toast) {
6201 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
6202 addClass(popup, swalClasses.toast);
6203 } else {
6204 addClass(popup, swalClasses.modal);
6205 }
6206
6207 // Custom class
6208 applyCustomClass(popup, params, 'popup');
6209 // TODO: remove in the next major
6210 if (typeof params.customClass === 'string') {
6211 addClass(popup, params.customClass);
6212 }
6213
6214 // Icon class (#1842)
6215 if (params.icon) {
6216 addClass(popup, swalClasses[`icon-${params.icon}`]);
6217 }
6218 };
6219
6220 /**
6221 * @param {SweetAlert} instance
6222 * @param {SweetAlertOptions} params
6223 */
6224 const renderProgressSteps = (instance, params) => {
6225 const progressStepsContainer = getProgressSteps();
6226 if (!progressStepsContainer) {
6227 return;
6228 }
6229 const {
6230 progressSteps,
6231 currentProgressStep
6232 } = params;
6233 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
6234 hide(progressStepsContainer);
6235 return;
6236 }
6237 show(progressStepsContainer);
6238 progressStepsContainer.textContent = '';
6239 if (currentProgressStep >= progressSteps.length) {
6240 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
6241 }
6242 progressSteps.forEach((step, index) => {
6243 const stepEl = createStepElement(step);
6244 progressStepsContainer.appendChild(stepEl);
6245 if (index === currentProgressStep) {
6246 addClass(stepEl, swalClasses['active-progress-step']);
6247 }
6248 if (index !== progressSteps.length - 1) {
6249 const lineEl = createLineElement(params);
6250 progressStepsContainer.appendChild(lineEl);
6251 }
6252 });
6253 };
6254
6255 /**
6256 * @param {string} step
6257 * @returns {HTMLLIElement}
6258 */
6259 const createStepElement = step => {
6260 const stepEl = document.createElement('li');
6261 addClass(stepEl, swalClasses['progress-step']);
6262 setInnerHtml(stepEl, step);
6263 return stepEl;
6264 };
6265
6266 /**
6267 * @param {SweetAlertOptions} params
6268 * @returns {HTMLLIElement}
6269 */
6270 const createLineElement = params => {
6271 const lineEl = document.createElement('li');
6272 addClass(lineEl, swalClasses['progress-step-line']);
6273 if (params.progressStepsDistance) {
6274 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
6275 }
6276 return lineEl;
6277 };
6278
6279 /**
6280 * @param {SweetAlert} instance
6281 * @param {SweetAlertOptions} params
6282 */
6283 const renderTitle = (instance, params) => {
6284 const title = getTitle();
6285 if (!title) {
6286 return;
6287 }
6288 showWhenInnerHtmlPresent(title);
6289 toggle(title, Boolean(params.title || params.titleText), 'block');
6290 if (params.title) {
6291 parseHtmlToContainer(params.title, title);
6292 }
6293 if (params.titleText) {
6294 title.innerText = params.titleText;
6295 }
6296
6297 // Custom class
6298 applyCustomClass(title, params, 'title');
6299 };
6300
6301 /**
6302 * @param {SweetAlert} instance
6303 * @param {SweetAlertOptions} params
6304 */
6305 const render = (instance, params) => {
6306 var _globalState$eventEmi;
6307 renderPopup(instance, params);
6308 renderContainer(instance, params);
6309 renderProgressSteps(instance, params);
6310 renderIcon(instance, params);
6311 renderImage(instance, params);
6312 renderTitle(instance, params);
6313 renderCloseButton(instance, params);
6314 renderContent(instance, params);
6315 renderActions(instance, params);
6316 renderFooter(instance, params);
6317 const popup = getPopup();
6318 if (typeof params.didRender === 'function' && popup) {
6319 params.didRender(popup);
6320 }
6321 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
6322 };
6323
6324 /*
6325 * Global function to determine if SweetAlert2 popup is shown
6326 */
6327 const isVisible = () => {
6328 return isVisible$1(getPopup());
6329 };
6330
6331 /*
6332 * Global function to click 'Confirm' button
6333 */
6334 const clickConfirm = () => {
6335 var _dom$getConfirmButton;
6336 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
6337 };
6338
6339 /*
6340 * Global function to click 'Deny' button
6341 */
6342 const clickDeny = () => {
6343 var _dom$getDenyButton;
6344 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
6345 };
6346
6347 /*
6348 * Global function to click 'Cancel' button
6349 */
6350 const clickCancel = () => {
6351 var _dom$getCancelButton;
6352 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
6353 };
6354
6355 /** @type {Record<DismissReason, DismissReason>} */
6356 const DismissReason = Object.freeze({
6357 cancel: 'cancel',
6358 backdrop: 'backdrop',
6359 close: 'close',
6360 esc: 'esc',
6361 timer: 'timer'
6362 });
6363
6364 /**
6365 * @param {GlobalState} globalState
6366 */
6367 const removeKeydownHandler = globalState => {
6368 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
6369 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
6370 globalState.keydownTarget.removeEventListener('keydown', handler, {
6371 capture: globalState.keydownListenerCapture
6372 });
6373 globalState.keydownHandlerAdded = false;
6374 }
6375 };
6376
6377 /**
6378 * @param {GlobalState} globalState
6379 * @param {SweetAlertOptions} innerParams
6380 * @param {(dismiss: DismissReason) => void} dismissWith
6381 */
6382 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
6383 removeKeydownHandler(globalState);
6384 if (!innerParams.toast) {
6385 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
6386 const handler = e => keydownHandler(innerParams, e, dismissWith);
6387 globalState.keydownHandler = handler;
6388 const target = innerParams.keydownListenerCapture ? window : getPopup();
6389 if (target) {
6390 globalState.keydownTarget = target;
6391 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
6392 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
6393 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
6394 capture: globalState.keydownListenerCapture
6395 });
6396 globalState.keydownHandlerAdded = true;
6397 }
6398 }
6399 };
6400
6401 /**
6402 * @param {number} index
6403 * @param {number} increment
6404 */
6405 const setFocus = (index, increment) => {
6406 var _dom$getPopup;
6407 const focusableElements = getFocusableElements();
6408 // search for visible elements and select the next possible match
6409 if (focusableElements.length) {
6410 index = index + increment;
6411
6412 // shift + tab when .swal2-popup is focused
6413 if (index === -2) {
6414 index = focusableElements.length - 1;
6415 }
6416
6417 // rollover to first item
6418 if (index === focusableElements.length) {
6419 index = 0;
6420
6421 // go to last item
6422 } else if (index === -1) {
6423 index = focusableElements.length - 1;
6424 }
6425 focusableElements[index].focus();
6426 return;
6427 }
6428 // no visible focusable elements, focus the popup
6429 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
6430 };
6431 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
6432 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
6433
6434 /**
6435 * @param {SweetAlertOptions} innerParams
6436 * @param {KeyboardEvent} event
6437 * @param {(dismiss: DismissReason) => void} dismissWith
6438 */
6439 const keydownHandler = (innerParams, event, dismissWith) => {
6440 if (!innerParams) {
6441 return; // This instance has already been destroyed
6442 }
6443
6444 // Ignore keydown during IME composition
6445 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
6446 // https://github.com/sweetalert2/sweetalert2/issues/720
6447 // https://github.com/sweetalert2/sweetalert2/issues/2406
6448 if (event.isComposing || event.keyCode === 229) {
6449 return;
6450 }
6451 if (innerParams.stopKeydownPropagation) {
6452 event.stopPropagation();
6453 }
6454
6455 // ENTER
6456 if (event.key === 'Enter') {
6457 handleEnter(event, innerParams);
6458 }
6459
6460 // TAB
6461 else if (event.key === 'Tab') {
6462 handleTab(event);
6463 }
6464
6465 // ARROWS - switch focus between buttons
6466 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
6467 handleArrows(event.key);
6468 }
6469
6470 // ESC
6471 else if (event.key === 'Escape') {
6472 handleEsc(event, innerParams, dismissWith);
6473 }
6474 };
6475
6476 /**
6477 * @param {KeyboardEvent} event
6478 * @param {SweetAlertOptions} innerParams
6479 */
6480 const handleEnter = (event, innerParams) => {
6481 // https://github.com/sweetalert2/sweetalert2/issues/2386
6482 if (!callIfFunction(innerParams.allowEnterKey)) {
6483 return;
6484 }
6485 const popup = getPopup();
6486 if (!popup || !innerParams.input) {
6487 return;
6488 }
6489 const input = getInput$1(popup, innerParams.input);
6490 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
6491 if (['textarea', 'file'].includes(innerParams.input)) {
6492 return; // do not submit
6493 }
6494 clickConfirm();
6495 event.preventDefault();
6496 }
6497 };
6498
6499 /**
6500 * @param {KeyboardEvent} event
6501 */
6502 const handleTab = event => {
6503 const targetElement = event.target;
6504 const focusableElements = getFocusableElements();
6505 let btnIndex = -1;
6506 for (let i = 0; i < focusableElements.length; i++) {
6507 if (targetElement === focusableElements[i]) {
6508 btnIndex = i;
6509 break;
6510 }
6511 }
6512
6513 // Cycle to the next button
6514 if (!event.shiftKey) {
6515 setFocus(btnIndex, 1);
6516 }
6517
6518 // Cycle to the prev button
6519 else {
6520 setFocus(btnIndex, -1);
6521 }
6522 event.stopPropagation();
6523 event.preventDefault();
6524 };
6525
6526 /**
6527 * @param {string} key
6528 */
6529 const handleArrows = key => {
6530 const actions = getActions();
6531 const confirmButton = getConfirmButton();
6532 const denyButton = getDenyButton();
6533 const cancelButton = getCancelButton();
6534 if (!actions || !confirmButton || !denyButton || !cancelButton) {
6535 return;
6536 }
6537 /** @type HTMLElement[] */
6538 const buttons = [confirmButton, denyButton, cancelButton];
6539 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
6540 return;
6541 }
6542 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
6543 let buttonToFocus = document.activeElement;
6544 if (!buttonToFocus) {
6545 return;
6546 }
6547 for (let i = 0; i < actions.children.length; i++) {
6548 buttonToFocus = buttonToFocus[sibling];
6549 if (!buttonToFocus) {
6550 return;
6551 }
6552 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
6553 break;
6554 }
6555 }
6556 if (buttonToFocus instanceof HTMLButtonElement) {
6557 buttonToFocus.focus();
6558 }
6559 };
6560
6561 /**
6562 * @param {KeyboardEvent} event
6563 * @param {SweetAlertOptions} innerParams
6564 * @param {(dismiss: DismissReason) => void} dismissWith
6565 */
6566 const handleEsc = (event, innerParams, dismissWith) => {
6567 event.preventDefault();
6568 if (callIfFunction(innerParams.allowEscapeKey)) {
6569 dismissWith(DismissReason.esc);
6570 }
6571 };
6572
6573 /**
6574 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
6575 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
6576 * This is the approach that Babel will probably take to implement private methods/fields
6577 * https://github.com/tc39/proposal-private-methods
6578 * https://github.com/babel/babel/pull/7555
6579 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
6580 * then we can use that language feature.
6581 */
6582
6583 var privateMethods = {
6584 swalPromiseResolve: new WeakMap(),
6585 swalPromiseReject: new WeakMap()
6586 };
6587
6588 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
6589 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
6590 // elements not within the active modal dialog will not be surfaced if a user opens a screen
6591 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
6592
6593 const setAriaHidden = () => {
6594 const container = getContainer();
6595 const bodyChildren = Array.from(document.body.children);
6596 bodyChildren.forEach(el => {
6597 if (el.contains(container)) {
6598 return;
6599 }
6600 if (el.hasAttribute('aria-hidden')) {
6601 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
6602 }
6603 el.setAttribute('aria-hidden', 'true');
6604 });
6605 };
6606 const unsetAriaHidden = () => {
6607 const bodyChildren = Array.from(document.body.children);
6608 bodyChildren.forEach(el => {
6609 if (el.hasAttribute('data-previous-aria-hidden')) {
6610 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
6611 el.removeAttribute('data-previous-aria-hidden');
6612 } else {
6613 el.removeAttribute('aria-hidden');
6614 }
6615 });
6616 };
6617
6618 // @ts-ignore
6619 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
6620
6621 /**
6622 * Fix iOS scrolling
6623 * http://stackoverflow.com/q/39626302
6624 */
6625 const iOSfix = () => {
6626 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
6627 const offset = document.body.scrollTop;
6628 document.body.style.top = `${offset * -1}px`;
6629 addClass(document.body, swalClasses.iosfix);
6630 lockBodyScroll();
6631 }
6632 };
6633
6634 /**
6635 * https://github.com/sweetalert2/sweetalert2/issues/1246
6636 */
6637 const lockBodyScroll = () => {
6638 const container = getContainer();
6639 if (!container) {
6640 return;
6641 }
6642 /** @type {boolean} */
6643 let preventTouchMove;
6644 /**
6645 * @param {TouchEvent} event
6646 */
6647 container.ontouchstart = event => {
6648 preventTouchMove = shouldPreventTouchMove(event);
6649 };
6650 /**
6651 * @param {TouchEvent} event
6652 */
6653 container.ontouchmove = event => {
6654 if (preventTouchMove) {
6655 event.preventDefault();
6656 event.stopPropagation();
6657 }
6658 };
6659 };
6660
6661 /**
6662 * @param {TouchEvent} event
6663 * @returns {boolean}
6664 */
6665 const shouldPreventTouchMove = event => {
6666 const target = event.target;
6667 const container = getContainer();
6668 const htmlContainer = getHtmlContainer();
6669 if (!container || !htmlContainer) {
6670 return false;
6671 }
6672 if (isStylus(event) || isZoom(event)) {
6673 return false;
6674 }
6675 if (target === container) {
6676 return true;
6677 }
6678 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
6679 // #2823
6680 target.tagName !== 'INPUT' &&
6681 // #1603
6682 target.tagName !== 'TEXTAREA' &&
6683 // #2266
6684 !(isScrollable(htmlContainer) &&
6685 // #1944
6686 htmlContainer.contains(target))) {
6687 return true;
6688 }
6689 return false;
6690 };
6691
6692 /**
6693 * https://github.com/sweetalert2/sweetalert2/issues/1786
6694 *
6695 * @param {TouchEvent} event
6696 * @returns {boolean}
6697 */
6698 const isStylus = event => {
6699 return Boolean(event.touches && event.touches.length &&
6700 // @ts-ignore - touchType is not a standard property
6701 event.touches[0].touchType === 'stylus');
6702 };
6703
6704 /**
6705 * https://github.com/sweetalert2/sweetalert2/issues/1891
6706 *
6707 * @param {TouchEvent} event
6708 * @returns {boolean}
6709 */
6710 const isZoom = event => {
6711 return event.touches && event.touches.length > 1;
6712 };
6713 const undoIOSfix = () => {
6714 if (hasClass(document.body, swalClasses.iosfix)) {
6715 const offset = parseInt(document.body.style.top, 10);
6716 removeClass(document.body, swalClasses.iosfix);
6717 document.body.style.top = '';
6718 document.body.scrollTop = offset * -1;
6719 }
6720 };
6721
6722 /**
6723 * Measure scrollbar width for padding body during modal show/hide
6724 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
6725 *
6726 * @returns {number}
6727 */
6728 const measureScrollbar = () => {
6729 const scrollDiv = document.createElement('div');
6730 scrollDiv.className = swalClasses['scrollbar-measure'];
6731 document.body.appendChild(scrollDiv);
6732 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
6733 document.body.removeChild(scrollDiv);
6734 return scrollbarWidth;
6735 };
6736
6737 /**
6738 * Remember state in cases where opening and handling a modal will fiddle with it.
6739 * @type {number | null}
6740 */
6741 let previousBodyPadding = null;
6742
6743 /**
6744 * @param {string} initialBodyOverflow
6745 */
6746 const replaceScrollbarWithPadding = initialBodyOverflow => {
6747 // for queues, do not do this more than once
6748 if (previousBodyPadding !== null) {
6749 return;
6750 }
6751 // if the body has overflow
6752 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
6753 ) {
6754 // add padding so the content doesn't shift after removal of scrollbar
6755 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
6756 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
6757 }
6758 };
6759 const undoReplaceScrollbarWithPadding = () => {
6760 if (previousBodyPadding !== null) {
6761 document.body.style.paddingRight = `${previousBodyPadding}px`;
6762 previousBodyPadding = null;
6763 }
6764 };
6765
6766 /**
6767 * @param {SweetAlert} instance
6768 * @param {HTMLElement} container
6769 * @param {boolean} returnFocus
6770 * @param {(() => void) | undefined} didClose
6771 */
6772 function removePopupAndResetState(instance, container, returnFocus, didClose) {
6773 if (isToast()) {
6774 triggerDidCloseAndDispose(instance, didClose);
6775 } else {
6776 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
6777 removeKeydownHandler(globalState);
6778 }
6779
6780 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
6781 // for some reason removing the container in Safari will scroll the document to bottom
6782 if (isSafariOrIOS) {
6783 container.setAttribute('style', 'display:none !important');
6784 container.removeAttribute('class');
6785 container.innerHTML = '';
6786 } else {
6787 container.remove();
6788 }
6789 if (isModal()) {
6790 undoReplaceScrollbarWithPadding();
6791 undoIOSfix();
6792 unsetAriaHidden();
6793 }
6794 removeBodyClasses();
6795 }
6796
6797 /**
6798 * Remove SweetAlert2 classes from body
6799 */
6800 function removeBodyClasses() {
6801 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
6802 }
6803
6804 /**
6805 * Instance method to close sweetAlert
6806 *
6807 * @param {SweetAlertResult | undefined} resolveValue
6808 * @this {SweetAlert}
6809 */
6810 function close(resolveValue) {
6811 resolveValue = prepareResolveValue(resolveValue);
6812 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
6813 const didClose = triggerClosePopup(this);
6814 if (this.isAwaitingPromise) {
6815 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
6816 if (!resolveValue.isDismissed) {
6817 handleAwaitingPromise(this);
6818 swalPromiseResolve(resolveValue);
6819 }
6820 } else if (didClose) {
6821 // Resolve Swal promise
6822 swalPromiseResolve(resolveValue);
6823 }
6824 }
6825
6826 /**
6827 * @param {SweetAlert} instance
6828 * @returns {boolean}
6829 */
6830 const triggerClosePopup = instance => {
6831 const popup = getPopup();
6832 if (!popup) {
6833 return false;
6834 }
6835 const innerParams = privateProps.innerParams.get(instance);
6836 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
6837 return false;
6838 }
6839 removeClass(popup, innerParams.showClass.popup);
6840 addClass(popup, innerParams.hideClass.popup);
6841 const backdrop = getContainer();
6842 removeClass(backdrop, innerParams.showClass.backdrop);
6843 addClass(backdrop, innerParams.hideClass.backdrop);
6844 handlePopupAnimation(instance, popup, innerParams);
6845 return true;
6846 };
6847
6848 /**
6849 * @param {Error | string} error
6850 * @this {SweetAlert}
6851 */
6852 function rejectPromise(error) {
6853 const rejectPromise = privateMethods.swalPromiseReject.get(this);
6854 handleAwaitingPromise(this);
6855 if (rejectPromise) {
6856 // Reject Swal promise
6857 rejectPromise(error);
6858 }
6859 }
6860
6861 /**
6862 * @param {SweetAlert} instance
6863 */
6864 const handleAwaitingPromise = instance => {
6865 if (instance.isAwaitingPromise) {
6866 // @ts-ignore
6867 delete instance.isAwaitingPromise;
6868 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
6869 if (!privateProps.innerParams.get(instance)) {
6870 instance._destroy();
6871 }
6872 }
6873 };
6874
6875 /**
6876 * @param {SweetAlertResult | undefined} resolveValue
6877 * @returns {SweetAlertResult}
6878 */
6879 const prepareResolveValue = resolveValue => {
6880 // When user calls Swal.close()
6881 if (typeof resolveValue === 'undefined') {
6882 return {
6883 isConfirmed: false,
6884 isDenied: false,
6885 isDismissed: true
6886 };
6887 }
6888 return Object.assign({
6889 isConfirmed: false,
6890 isDenied: false,
6891 isDismissed: false
6892 }, resolveValue);
6893 };
6894
6895 /**
6896 * @param {SweetAlert} instance
6897 * @param {HTMLElement} popup
6898 * @param {SweetAlertOptions} innerParams
6899 */
6900 const handlePopupAnimation = (instance, popup, innerParams) => {
6901 var _globalState$eventEmi;
6902 const container = getContainer();
6903 // If animation is supported, animate
6904 const animationIsSupported = hasCssAnimation(popup);
6905 if (typeof innerParams.willClose === 'function') {
6906 innerParams.willClose(popup);
6907 }
6908 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
6909 if (animationIsSupported && container) {
6910 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
6911 } else if (container) {
6912 // Otherwise, remove immediately
6913 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
6914 }
6915 };
6916
6917 /**
6918 * @param {SweetAlert} instance
6919 * @param {HTMLElement} popup
6920 * @param {HTMLElement} container
6921 * @param {boolean} returnFocus
6922 * @param {(() => void) | undefined} didClose
6923 */
6924 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
6925 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
6926 /**
6927 * @param {AnimationEvent | TransitionEvent} e
6928 */
6929 const swalCloseAnimationFinished = function (e) {
6930 if (e.target === popup) {
6931 var _globalState$swalClos;
6932 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
6933 delete globalState.swalCloseEventFinishedCallback;
6934 popup.removeEventListener('animationend', swalCloseAnimationFinished);
6935 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
6936 }
6937 };
6938 popup.addEventListener('animationend', swalCloseAnimationFinished);
6939 popup.addEventListener('transitionend', swalCloseAnimationFinished);
6940 };
6941
6942 /**
6943 * @param {SweetAlert} instance
6944 * @param {(() => void) | undefined} didClose
6945 */
6946 const triggerDidCloseAndDispose = (instance, didClose) => {
6947 setTimeout(() => {
6948 var _globalState$eventEmi2;
6949 if (typeof didClose === 'function') {
6950 didClose.bind(instance.params)();
6951 }
6952 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
6953 // instance might have been destroyed already
6954 if (instance._destroy) {
6955 instance._destroy();
6956 }
6957 });
6958 };
6959
6960 /**
6961 * Shows loader (spinner), this is useful with AJAX requests.
6962 * By default the loader be shown instead of the "Confirm" button.
6963 *
6964 * @param {HTMLButtonElement | null} [buttonToReplace]
6965 */
6966 const showLoading = buttonToReplace => {
6967 let popup = getPopup();
6968 if (!popup) {
6969 new Swal();
6970 }
6971 popup = getPopup();
6972 if (!popup) {
6973 return;
6974 }
6975 const loader = getLoader();
6976 if (isToast()) {
6977 hide(getIcon());
6978 } else {
6979 replaceButton(popup, buttonToReplace);
6980 }
6981 show(loader);
6982 popup.setAttribute('data-loading', 'true');
6983 popup.setAttribute('aria-busy', 'true');
6984 popup.focus();
6985 };
6986
6987 /**
6988 * @param {HTMLElement} popup
6989 * @param {HTMLButtonElement | null} [buttonToReplace]
6990 */
6991 const replaceButton = (popup, buttonToReplace) => {
6992 const actions = getActions();
6993 const loader = getLoader();
6994 if (!actions || !loader) {
6995 return;
6996 }
6997 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
6998 buttonToReplace = getConfirmButton();
6999 }
7000 show(actions);
7001 if (buttonToReplace) {
7002 hide(buttonToReplace);
7003 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
7004 actions.insertBefore(loader, buttonToReplace);
7005 }
7006 addClass([popup, actions], swalClasses.loading);
7007 };
7008
7009 /**
7010 * @param {SweetAlert} instance
7011 * @param {SweetAlertOptions} params
7012 */
7013 const handleInputOptionsAndValue = (instance, params) => {
7014 if (params.input === 'select' || params.input === 'radio') {
7015 handleInputOptions(instance, params);
7016 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
7017 showLoading(getConfirmButton());
7018 handleInputValue(instance, params);
7019 }
7020 };
7021
7022 /**
7023 * @param {SweetAlert} instance
7024 * @param {SweetAlertOptions} innerParams
7025 * @returns {SweetAlertInputValue}
7026 */
7027 const getInputValue = (instance, innerParams) => {
7028 const input = instance.getInput();
7029 if (!input) {
7030 return null;
7031 }
7032 switch (innerParams.input) {
7033 case 'checkbox':
7034 return getCheckboxValue(input);
7035 case 'radio':
7036 return getRadioValue(input);
7037 case 'file':
7038 return getFileValue(input);
7039 default:
7040 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
7041 }
7042 };
7043
7044 /**
7045 * @param {HTMLInputElement} input
7046 * @returns {number}
7047 */
7048 const getCheckboxValue = input => input.checked ? 1 : 0;
7049
7050 /**
7051 * @param {HTMLInputElement} input
7052 * @returns {string | null}
7053 */
7054 const getRadioValue = input => input.checked ? input.value : null;
7055
7056 /**
7057 * @param {HTMLInputElement} input
7058 * @returns {FileList | File | null}
7059 */
7060 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
7061
7062 /**
7063 * @param {SweetAlert} instance
7064 * @param {SweetAlertOptions} params
7065 */
7066 const handleInputOptions = (instance, params) => {
7067 const popup = getPopup();
7068 if (!popup) {
7069 return;
7070 }
7071 /**
7072 * @param {*} inputOptions
7073 */
7074 const processInputOptions = inputOptions => {
7075 if (params.input === 'select') {
7076 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
7077 } else if (params.input === 'radio') {
7078 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
7079 }
7080 };
7081 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
7082 showLoading(getConfirmButton());
7083 asPromise(params.inputOptions).then(inputOptions => {
7084 instance.hideLoading();
7085 processInputOptions(inputOptions);
7086 });
7087 } else if (typeof params.inputOptions === 'object') {
7088 processInputOptions(params.inputOptions);
7089 } else {
7090 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
7091 }
7092 };
7093
7094 /**
7095 * @param {SweetAlert} instance
7096 * @param {SweetAlertOptions} params
7097 */
7098 const handleInputValue = (instance, params) => {
7099 const input = instance.getInput();
7100 if (!input) {
7101 return;
7102 }
7103 hide(input);
7104 asPromise(params.inputValue).then(inputValue => {
7105 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
7106 show(input);
7107 input.focus();
7108 instance.hideLoading();
7109 }).catch(err => {
7110 error(`Error in inputValue promise: ${err}`);
7111 input.value = '';
7112 show(input);
7113 input.focus();
7114 instance.hideLoading();
7115 });
7116 };
7117
7118 /**
7119 * @param {HTMLElement} popup
7120 * @param {InputOptionFlattened[]} inputOptions
7121 * @param {SweetAlertOptions} params
7122 */
7123 function populateSelectOptions(popup, inputOptions, params) {
7124 const select = getDirectChildByClass(popup, swalClasses.select);
7125 if (!select) {
7126 return;
7127 }
7128 /**
7129 * @param {HTMLElement} parent
7130 * @param {string} optionLabel
7131 * @param {string} optionValue
7132 */
7133 const renderOption = (parent, optionLabel, optionValue) => {
7134 const option = document.createElement('option');
7135 option.value = optionValue;
7136 setInnerHtml(option, optionLabel);
7137 option.selected = isSelected(optionValue, params.inputValue);
7138 parent.appendChild(option);
7139 };
7140 inputOptions.forEach(inputOption => {
7141 const optionValue = inputOption[0];
7142 const optionLabel = inputOption[1];
7143 // <optgroup> spec:
7144 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
7145 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
7146 // check whether this is a <optgroup>
7147 if (Array.isArray(optionLabel)) {
7148 // if it is an array, then it is an <optgroup>
7149 const optgroup = document.createElement('optgroup');
7150 optgroup.label = optionValue;
7151 optgroup.disabled = false; // not configurable for now
7152 select.appendChild(optgroup);
7153 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
7154 } else {
7155 // case of <option>
7156 renderOption(select, optionLabel, optionValue);
7157 }
7158 });
7159 select.focus();
7160 }
7161
7162 /**
7163 * @param {HTMLElement} popup
7164 * @param {InputOptionFlattened[]} inputOptions
7165 * @param {SweetAlertOptions} params
7166 */
7167 function populateRadioOptions(popup, inputOptions, params) {
7168 const radio = getDirectChildByClass(popup, swalClasses.radio);
7169 if (!radio) {
7170 return;
7171 }
7172 inputOptions.forEach(inputOption => {
7173 const radioValue = inputOption[0];
7174 const radioLabel = inputOption[1];
7175 const radioInput = document.createElement('input');
7176 const radioLabelElement = document.createElement('label');
7177 radioInput.type = 'radio';
7178 radioInput.name = swalClasses.radio;
7179 radioInput.value = radioValue;
7180 if (isSelected(radioValue, params.inputValue)) {
7181 radioInput.checked = true;
7182 }
7183 const label = document.createElement('span');
7184 setInnerHtml(label, radioLabel);
7185 label.className = swalClasses.label;
7186 radioLabelElement.appendChild(radioInput);
7187 radioLabelElement.appendChild(label);
7188 radio.appendChild(radioLabelElement);
7189 });
7190 const radios = radio.querySelectorAll('input');
7191 if (radios.length) {
7192 radios[0].focus();
7193 }
7194 }
7195
7196 /**
7197 * Converts `inputOptions` into an array of `[value, label]`s
7198 *
7199 * @param {*} inputOptions
7200 * @typedef {string[]} InputOptionFlattened
7201 * @returns {InputOptionFlattened[]}
7202 */
7203 const formatInputOptions = inputOptions => {
7204 /** @type {InputOptionFlattened[]} */
7205 const result = [];
7206 if (inputOptions instanceof Map) {
7207 inputOptions.forEach((value, key) => {
7208 let valueFormatted = value;
7209 if (typeof valueFormatted === 'object') {
7210 // case of <optgroup>
7211 valueFormatted = formatInputOptions(valueFormatted);
7212 }
7213 result.push([key, valueFormatted]);
7214 });
7215 } else {
7216 Object.keys(inputOptions).forEach(key => {
7217 let valueFormatted = inputOptions[key];
7218 if (typeof valueFormatted === 'object') {
7219 // case of <optgroup>
7220 valueFormatted = formatInputOptions(valueFormatted);
7221 }
7222 result.push([key, valueFormatted]);
7223 });
7224 }
7225 return result;
7226 };
7227
7228 /**
7229 * @param {string} optionValue
7230 * @param {SweetAlertInputValue} inputValue
7231 * @returns {boolean}
7232 */
7233 const isSelected = (optionValue, inputValue) => {
7234 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
7235 };
7236
7237 /**
7238 * @param {SweetAlert} instance
7239 */
7240 const handleConfirmButtonClick = instance => {
7241 const innerParams = privateProps.innerParams.get(instance);
7242 instance.disableButtons();
7243 if (innerParams.input) {
7244 handleConfirmOrDenyWithInput(instance, 'confirm');
7245 } else {
7246 confirm(instance, true);
7247 }
7248 };
7249
7250 /**
7251 * @param {SweetAlert} instance
7252 */
7253 const handleDenyButtonClick = instance => {
7254 const innerParams = privateProps.innerParams.get(instance);
7255 instance.disableButtons();
7256 if (innerParams.returnInputValueOnDeny) {
7257 handleConfirmOrDenyWithInput(instance, 'deny');
7258 } else {
7259 deny(instance, false);
7260 }
7261 };
7262
7263 /**
7264 * @param {SweetAlert} instance
7265 * @param {(dismiss: DismissReason) => void} dismissWith
7266 */
7267 const handleCancelButtonClick = (instance, dismissWith) => {
7268 instance.disableButtons();
7269 dismissWith(DismissReason.cancel);
7270 };
7271
7272 /**
7273 * @param {SweetAlert} instance
7274 * @param {'confirm' | 'deny'} type
7275 */
7276 const handleConfirmOrDenyWithInput = (instance, type) => {
7277 const innerParams = privateProps.innerParams.get(instance);
7278 if (!innerParams.input) {
7279 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
7280 return;
7281 }
7282 const input = instance.getInput();
7283 const inputValue = getInputValue(instance, innerParams);
7284 if (innerParams.inputValidator) {
7285 handleInputValidator(instance, inputValue, type);
7286 } else if (input && !input.checkValidity()) {
7287 instance.enableButtons();
7288 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
7289 } else if (type === 'deny') {
7290 deny(instance, inputValue);
7291 } else {
7292 confirm(instance, inputValue);
7293 }
7294 };
7295
7296 /**
7297 * @param {SweetAlert} instance
7298 * @param {SweetAlertInputValue} inputValue
7299 * @param {'confirm' | 'deny'} type
7300 */
7301 const handleInputValidator = (instance, inputValue, type) => {
7302 const innerParams = privateProps.innerParams.get(instance);
7303 instance.disableInput();
7304 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
7305 validationPromise.then(validationMessage => {
7306 instance.enableButtons();
7307 instance.enableInput();
7308 if (validationMessage) {
7309 instance.showValidationMessage(validationMessage);
7310 } else if (type === 'deny') {
7311 deny(instance, inputValue);
7312 } else {
7313 confirm(instance, inputValue);
7314 }
7315 });
7316 };
7317
7318 /**
7319 * @param {SweetAlert} instance
7320 * @param {*} value
7321 */
7322 const deny = (instance, value) => {
7323 const innerParams = privateProps.innerParams.get(instance);
7324 if (innerParams.showLoaderOnDeny) {
7325 showLoading(getDenyButton());
7326 }
7327 if (innerParams.preDeny) {
7328 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
7329 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
7330 preDenyPromise.then(preDenyValue => {
7331 if (preDenyValue === false) {
7332 instance.hideLoading();
7333 handleAwaitingPromise(instance);
7334 } else {
7335 instance.close(/** @type SweetAlertResult */{
7336 isDenied: true,
7337 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
7338 });
7339 }
7340 }).catch(error => rejectWith(instance, error));
7341 } else {
7342 instance.close(/** @type SweetAlertResult */{
7343 isDenied: true,
7344 value
7345 });
7346 }
7347 };
7348
7349 /**
7350 * @param {SweetAlert} instance
7351 * @param {*} value
7352 */
7353 const succeedWith = (instance, value) => {
7354 instance.close(/** @type SweetAlertResult */{
7355 isConfirmed: true,
7356 value
7357 });
7358 };
7359
7360 /**
7361 *
7362 * @param {SweetAlert} instance
7363 * @param {string} error
7364 */
7365 const rejectWith = (instance, error) => {
7366 instance.rejectPromise(error);
7367 };
7368
7369 /**
7370 *
7371 * @param {SweetAlert} instance
7372 * @param {*} value
7373 */
7374 const confirm = (instance, value) => {
7375 const innerParams = privateProps.innerParams.get(instance);
7376 if (innerParams.showLoaderOnConfirm) {
7377 showLoading();
7378 }
7379 if (innerParams.preConfirm) {
7380 instance.resetValidationMessage();
7381 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
7382 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
7383 preConfirmPromise.then(preConfirmValue => {
7384 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
7385 instance.hideLoading();
7386 handleAwaitingPromise(instance);
7387 } else {
7388 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
7389 }
7390 }).catch(error => rejectWith(instance, error));
7391 } else {
7392 succeedWith(instance, value);
7393 }
7394 };
7395
7396 /**
7397 * Hides loader and shows back the button which was hidden by .showLoading()
7398 * @this {SweetAlert}
7399 */
7400 function hideLoading() {
7401 // do nothing if popup is closed
7402 const innerParams = privateProps.innerParams.get(this);
7403 if (!innerParams) {
7404 return;
7405 }
7406 const domCache = privateProps.domCache.get(this);
7407 hide(domCache.loader);
7408 if (isToast()) {
7409 if (innerParams.icon) {
7410 show(getIcon());
7411 }
7412 } else {
7413 showRelatedButton(domCache);
7414 }
7415 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
7416 domCache.popup.removeAttribute('aria-busy');
7417 domCache.popup.removeAttribute('data-loading');
7418 domCache.confirmButton.disabled = false;
7419 domCache.denyButton.disabled = false;
7420 domCache.cancelButton.disabled = false;
7421 }
7422
7423 /**
7424 * @param {DomCache} domCache
7425 */
7426 const showRelatedButton = domCache => {
7427 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
7428 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
7429 if (buttonToReplace.length) {
7430 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
7431 } else if (allButtonsAreHidden()) {
7432 hide(domCache.actions);
7433 }
7434 };
7435
7436 /**
7437 * Gets the input DOM node, this method works with input parameter.
7438 *
7439 * @returns {HTMLInputElement | null}
7440 * @this {SweetAlert}
7441 */
7442 function getInput() {
7443 const innerParams = privateProps.innerParams.get(this);
7444 const domCache = privateProps.domCache.get(this);
7445 if (!domCache) {
7446 return null;
7447 }
7448 return getInput$1(domCache.popup, innerParams.input);
7449 }
7450
7451 /**
7452 * @param {SweetAlert} instance
7453 * @param {string[]} buttons
7454 * @param {boolean} disabled
7455 */
7456 function setButtonsDisabled(instance, buttons, disabled) {
7457 const domCache = privateProps.domCache.get(instance);
7458 buttons.forEach(button => {
7459 domCache[button].disabled = disabled;
7460 });
7461 }
7462
7463 /**
7464 * @param {HTMLInputElement | null} input
7465 * @param {boolean} disabled
7466 */
7467 function setInputDisabled(input, disabled) {
7468 const popup = getPopup();
7469 if (!popup || !input) {
7470 return;
7471 }
7472 if (input.type === 'radio') {
7473 /** @type {NodeListOf<HTMLInputElement>} */
7474 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
7475 for (let i = 0; i < radios.length; i++) {
7476 radios[i].disabled = disabled;
7477 }
7478 } else {
7479 input.disabled = disabled;
7480 }
7481 }
7482
7483 /**
7484 * Enable all the buttons
7485 * @this {SweetAlert}
7486 */
7487 function enableButtons() {
7488 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
7489 }
7490
7491 /**
7492 * Disable all the buttons
7493 * @this {SweetAlert}
7494 */
7495 function disableButtons() {
7496 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
7497 }
7498
7499 /**
7500 * Enable the input field
7501 * @this {SweetAlert}
7502 */
7503 function enableInput() {
7504 setInputDisabled(this.getInput(), false);
7505 }
7506
7507 /**
7508 * Disable the input field
7509 * @this {SweetAlert}
7510 */
7511 function disableInput() {
7512 setInputDisabled(this.getInput(), true);
7513 }
7514
7515 /**
7516 * Show block with validation message
7517 *
7518 * @param {string} error
7519 * @this {SweetAlert}
7520 */
7521 function showValidationMessage(error) {
7522 const domCache = privateProps.domCache.get(this);
7523 const params = privateProps.innerParams.get(this);
7524 setInnerHtml(domCache.validationMessage, error);
7525 domCache.validationMessage.className = swalClasses['validation-message'];
7526 if (params.customClass && params.customClass.validationMessage) {
7527 addClass(domCache.validationMessage, params.customClass.validationMessage);
7528 }
7529 show(domCache.validationMessage);
7530 const input = this.getInput();
7531 if (input) {
7532 input.setAttribute('aria-invalid', 'true');
7533 input.setAttribute('aria-describedby', swalClasses['validation-message']);
7534 focusInput(input);
7535 addClass(input, swalClasses.inputerror);
7536 }
7537 }
7538
7539 /**
7540 * Hide block with validation message
7541 *
7542 * @this {SweetAlert}
7543 */
7544 function resetValidationMessage() {
7545 const domCache = privateProps.domCache.get(this);
7546 if (domCache.validationMessage) {
7547 hide(domCache.validationMessage);
7548 }
7549 const input = this.getInput();
7550 if (input) {
7551 input.removeAttribute('aria-invalid');
7552 input.removeAttribute('aria-describedby');
7553 removeClass(input, swalClasses.inputerror);
7554 }
7555 }
7556
7557 const defaultParams = {
7558 title: '',
7559 titleText: '',
7560 text: '',
7561 html: '',
7562 footer: '',
7563 icon: undefined,
7564 iconColor: undefined,
7565 iconHtml: undefined,
7566 template: undefined,
7567 toast: false,
7568 draggable: false,
7569 animation: true,
7570 theme: 'light',
7571 showClass: {
7572 popup: 'swal2-show',
7573 backdrop: 'swal2-backdrop-show',
7574 icon: 'swal2-icon-show'
7575 },
7576 hideClass: {
7577 popup: 'swal2-hide',
7578 backdrop: 'swal2-backdrop-hide',
7579 icon: 'swal2-icon-hide'
7580 },
7581 customClass: {},
7582 target: 'body',
7583 color: undefined,
7584 backdrop: true,
7585 heightAuto: true,
7586 allowOutsideClick: true,
7587 allowEscapeKey: true,
7588 allowEnterKey: true,
7589 stopKeydownPropagation: true,
7590 keydownListenerCapture: false,
7591 showConfirmButton: true,
7592 showDenyButton: false,
7593 showCancelButton: false,
7594 preConfirm: undefined,
7595 preDeny: undefined,
7596 confirmButtonText: 'OK',
7597 confirmButtonAriaLabel: '',
7598 confirmButtonColor: undefined,
7599 denyButtonText: 'No',
7600 denyButtonAriaLabel: '',
7601 denyButtonColor: undefined,
7602 cancelButtonText: 'Cancel',
7603 cancelButtonAriaLabel: '',
7604 cancelButtonColor: undefined,
7605 buttonsStyling: true,
7606 reverseButtons: false,
7607 focusConfirm: true,
7608 focusDeny: false,
7609 focusCancel: false,
7610 returnFocus: true,
7611 showCloseButton: false,
7612 closeButtonHtml: '&times;',
7613 closeButtonAriaLabel: 'Close this dialog',
7614 loaderHtml: '',
7615 showLoaderOnConfirm: false,
7616 showLoaderOnDeny: false,
7617 imageUrl: undefined,
7618 imageWidth: undefined,
7619 imageHeight: undefined,
7620 imageAlt: '',
7621 timer: undefined,
7622 timerProgressBar: false,
7623 width: undefined,
7624 padding: undefined,
7625 background: undefined,
7626 input: undefined,
7627 inputPlaceholder: '',
7628 inputLabel: '',
7629 inputValue: '',
7630 inputOptions: {},
7631 inputAutoFocus: true,
7632 inputAutoTrim: true,
7633 inputAttributes: {},
7634 inputValidator: undefined,
7635 returnInputValueOnDeny: false,
7636 validationMessage: undefined,
7637 grow: false,
7638 position: 'center',
7639 progressSteps: [],
7640 currentProgressStep: undefined,
7641 progressStepsDistance: undefined,
7642 willOpen: undefined,
7643 didOpen: undefined,
7644 didRender: undefined,
7645 willClose: undefined,
7646 didClose: undefined,
7647 didDestroy: undefined,
7648 scrollbarPadding: true,
7649 topLayer: false
7650 };
7651 const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'draggable', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'theme', 'willClose'];
7652
7653 /** @type {Record<string, string | undefined>} */
7654 const deprecatedParams = {
7655 allowEnterKey: undefined
7656 };
7657 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
7658
7659 /**
7660 * Is valid parameter
7661 *
7662 * @param {string} paramName
7663 * @returns {boolean}
7664 */
7665 const isValidParameter = paramName => {
7666 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
7667 };
7668
7669 /**
7670 * Is valid parameter for Swal.update() method
7671 *
7672 * @param {string} paramName
7673 * @returns {boolean}
7674 */
7675 const isUpdatableParameter = paramName => {
7676 return updatableParams.indexOf(paramName) !== -1;
7677 };
7678
7679 /**
7680 * Is deprecated parameter
7681 *
7682 * @param {string} paramName
7683 * @returns {string | undefined}
7684 */
7685 const isDeprecatedParameter = paramName => {
7686 return deprecatedParams[paramName];
7687 };
7688
7689 /**
7690 * @param {string} param
7691 */
7692 const checkIfParamIsValid = param => {
7693 if (!isValidParameter(param)) {
7694 warn(`Unknown parameter "${param}"`);
7695 }
7696 };
7697
7698 /**
7699 * @param {string} param
7700 */
7701 const checkIfToastParamIsValid = param => {
7702 if (toastIncompatibleParams.includes(param)) {
7703 warn(`The parameter "${param}" is incompatible with toasts`);
7704 }
7705 };
7706
7707 /**
7708 * @param {string} param
7709 */
7710 const checkIfParamIsDeprecated = param => {
7711 const isDeprecated = isDeprecatedParameter(param);
7712 if (isDeprecated) {
7713 warnAboutDeprecation(param, isDeprecated);
7714 }
7715 };
7716
7717 /**
7718 * Show relevant warnings for given params
7719 *
7720 * @param {SweetAlertOptions} params
7721 */
7722 const showWarningsForParams = params => {
7723 if (params.backdrop === false && params.allowOutsideClick) {
7724 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
7725 }
7726 if (params.theme && !['light', 'dark', 'auto', 'minimal', 'borderless', 'bootstrap-4', 'bootstrap-4-light', 'bootstrap-4-dark', 'bootstrap-5', 'bootstrap-5-light', 'bootstrap-5-dark', 'material-ui', 'material-ui-light', 'material-ui-dark', 'embed-iframe', 'bulma', 'bulma-light', 'bulma-dark'].includes(params.theme)) {
7727 warn(`Invalid theme "${params.theme}"`);
7728 }
7729 for (const param in params) {
7730 checkIfParamIsValid(param);
7731 if (params.toast) {
7732 checkIfToastParamIsValid(param);
7733 }
7734 checkIfParamIsDeprecated(param);
7735 }
7736 };
7737
7738 /**
7739 * Updates popup parameters.
7740 *
7741 * @this {any}
7742 * @param {SweetAlertOptions} params
7743 */
7744 function update(params) {
7745 const container = getContainer();
7746 const popup = getPopup();
7747 const innerParams = privateProps.innerParams.get(this);
7748 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
7749 warn(`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`);
7750 return;
7751 }
7752 const validUpdatableParams = filterValidParams(params);
7753 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
7754 showWarningsForParams(updatedParams);
7755 if (container) {
7756 container.dataset['swal2Theme'] = updatedParams.theme;
7757 }
7758 render(this, updatedParams);
7759 privateProps.innerParams.set(this, updatedParams);
7760 Object.defineProperties(this, {
7761 params: {
7762 value: Object.assign({}, this.params, params),
7763 writable: false,
7764 enumerable: true
7765 }
7766 });
7767 }
7768
7769 /**
7770 * @param {SweetAlertOptions} params
7771 * @returns {SweetAlertOptions}
7772 */
7773 const filterValidParams = params => {
7774 /** @type {Record<string, any>} */
7775 const validUpdatableParams = {};
7776 Object.keys(params).forEach(param => {
7777 if (isUpdatableParameter(param)) {
7778 const typedParams = /** @type {Record<string, any>} */params;
7779 validUpdatableParams[param] = typedParams[param];
7780 } else {
7781 warn(`Invalid parameter to update: ${param}`);
7782 }
7783 });
7784 return validUpdatableParams;
7785 };
7786
7787 /**
7788 * Dispose the current SweetAlert2 instance
7789 * @this {SweetAlert}
7790 */
7791 function _destroy() {
7792 var _globalState$eventEmi;
7793 const domCache = privateProps.domCache.get(this);
7794 const innerParams = privateProps.innerParams.get(this);
7795 if (!innerParams) {
7796 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
7797 return; // This instance has already been destroyed
7798 }
7799
7800 // Check if there is another Swal closing
7801 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
7802 globalState.swalCloseEventFinishedCallback();
7803 delete globalState.swalCloseEventFinishedCallback;
7804 }
7805 if (typeof innerParams.didDestroy === 'function') {
7806 innerParams.didDestroy();
7807 }
7808 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
7809 disposeSwal(this);
7810 }
7811
7812 /**
7813 * @param {SweetAlert} instance
7814 */
7815 const disposeSwal = instance => {
7816 disposeWeakMaps(instance);
7817 // Unset this.params so GC will dispose it (#1569)
7818 // @ts-ignore
7819 delete instance.params;
7820 // Unset globalState props so GC will dispose globalState (#1569)
7821 delete globalState.keydownHandler;
7822 delete globalState.keydownTarget;
7823 // Unset currentInstance
7824 delete globalState.currentInstance;
7825 };
7826
7827 /**
7828 * @param {SweetAlert} instance
7829 */
7830 const disposeWeakMaps = instance => {
7831 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
7832 if (instance.isAwaitingPromise) {
7833 unsetWeakMaps(privateProps, instance);
7834 instance.isAwaitingPromise = true;
7835 } else {
7836 unsetWeakMaps(privateMethods, instance);
7837 unsetWeakMaps(privateProps, instance);
7838
7839 // @ts-ignore
7840 delete instance.isAwaitingPromise;
7841 // Unset instance methods
7842 // @ts-ignore
7843 delete instance.disableButtons;
7844 // @ts-ignore
7845 delete instance.enableButtons;
7846 // @ts-ignore
7847 delete instance.getInput;
7848 // @ts-ignore
7849 delete instance.disableInput;
7850 // @ts-ignore
7851 delete instance.enableInput;
7852 // @ts-ignore
7853 delete instance.hideLoading;
7854 // @ts-ignore
7855 delete instance.disableLoading;
7856 // @ts-ignore
7857 delete instance.showValidationMessage;
7858 // @ts-ignore
7859 delete instance.resetValidationMessage;
7860 // @ts-ignore
7861 delete instance.close;
7862 // @ts-ignore
7863 delete instance.closePopup;
7864 // @ts-ignore
7865 delete instance.closeModal;
7866 // @ts-ignore
7867 delete instance.closeToast;
7868 // @ts-ignore
7869 delete instance.rejectPromise;
7870 // @ts-ignore
7871 delete instance.update;
7872 // @ts-ignore
7873 delete instance._destroy;
7874 }
7875 };
7876
7877 /**
7878 * @param {Record<string, WeakMap<any, any>>} obj
7879 * @param {SweetAlert} instance
7880 */
7881 const unsetWeakMaps = (obj, instance) => {
7882 for (const i in obj) {
7883 obj[i].delete(instance);
7884 }
7885 };
7886
7887 var instanceMethods = /*#__PURE__*/Object.freeze({
7888 __proto__: null,
7889 _destroy: _destroy,
7890 close: close,
7891 closeModal: close,
7892 closePopup: close,
7893 closeToast: close,
7894 disableButtons: disableButtons,
7895 disableInput: disableInput,
7896 disableLoading: hideLoading,
7897 enableButtons: enableButtons,
7898 enableInput: enableInput,
7899 getInput: getInput,
7900 handleAwaitingPromise: handleAwaitingPromise,
7901 hideLoading: hideLoading,
7902 rejectPromise: rejectPromise,
7903 resetValidationMessage: resetValidationMessage,
7904 showValidationMessage: showValidationMessage,
7905 update: update
7906 });
7907
7908 /**
7909 * @param {SweetAlertOptions} innerParams
7910 * @param {DomCache} domCache
7911 * @param {(dismiss: DismissReason) => void} dismissWith
7912 */
7913 const handlePopupClick = (innerParams, domCache, dismissWith) => {
7914 if (innerParams.toast) {
7915 handleToastClick(innerParams, domCache, dismissWith);
7916 } else {
7917 // Ignore click events that had mousedown on the popup but mouseup on the container
7918 // This can happen when the user drags a slider
7919 handleModalMousedown(domCache);
7920
7921 // Ignore click events that had mousedown on the container but mouseup on the popup
7922 handleContainerMousedown(domCache);
7923 handleModalClick(innerParams, domCache, dismissWith);
7924 }
7925 };
7926
7927 /**
7928 * @param {SweetAlertOptions} innerParams
7929 * @param {DomCache} domCache
7930 * @param {(dismiss: DismissReason) => void} dismissWith
7931 */
7932 const handleToastClick = (innerParams, domCache, dismissWith) => {
7933 // Closing toast by internal click
7934 domCache.popup.onclick = () => {
7935 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
7936 return;
7937 }
7938 dismissWith(DismissReason.close);
7939 };
7940 };
7941
7942 /**
7943 * @param {SweetAlertOptions} innerParams
7944 * @returns {boolean}
7945 */
7946 const isAnyButtonShown = innerParams => {
7947 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
7948 };
7949 let ignoreOutsideClick = false;
7950
7951 /**
7952 * @param {DomCache} domCache
7953 */
7954 const handleModalMousedown = domCache => {
7955 domCache.popup.onmousedown = () => {
7956 domCache.container.onmouseup = function (e) {
7957 domCache.container.onmouseup = () => {};
7958 // We only check if the mouseup target is the container because usually it doesn't
7959 // have any other direct children aside of the popup
7960 if (e.target === domCache.container) {
7961 ignoreOutsideClick = true;
7962 }
7963 };
7964 };
7965 };
7966
7967 /**
7968 * @param {DomCache} domCache
7969 */
7970 const handleContainerMousedown = domCache => {
7971 domCache.container.onmousedown = e => {
7972 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
7973 if (e.target === domCache.container) {
7974 e.preventDefault();
7975 }
7976 domCache.popup.onmouseup = function (e) {
7977 domCache.popup.onmouseup = () => {};
7978 // We also need to check if the mouseup target is a child of the popup
7979 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
7980 ignoreOutsideClick = true;
7981 }
7982 };
7983 };
7984 };
7985
7986 /**
7987 * @param {SweetAlertOptions} innerParams
7988 * @param {DomCache} domCache
7989 * @param {(dismiss: DismissReason) => void} dismissWith
7990 */
7991 const handleModalClick = (innerParams, domCache, dismissWith) => {
7992 domCache.container.onclick = e => {
7993 if (ignoreOutsideClick) {
7994 ignoreOutsideClick = false;
7995 return;
7996 }
7997 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
7998 dismissWith(DismissReason.backdrop);
7999 }
8000 };
8001 };
8002
8003 /**
8004 * @param {any} elem
8005 * @returns {boolean}
8006 */
8007 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
8008
8009 /**
8010 * @param {any} elem
8011 * @returns {boolean}
8012 */
8013 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
8014
8015 /**
8016 * @param {any[]} args
8017 * @returns {SweetAlertOptions}
8018 */
8019 const argsToParams = args => {
8020 /** @type {Record<string, any>} */
8021 const params = {};
8022 if (typeof args[0] === 'object' && !isElement(args[0])) {
8023 Object.assign(params, args[0]);
8024 } else {
8025 ['title', 'html', 'icon'].forEach((name, index) => {
8026 const arg = args[index];
8027 if (typeof arg === 'string' || isElement(arg)) {
8028 params[name] = arg;
8029 } else if (arg !== undefined) {
8030 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
8031 }
8032 });
8033 }
8034 return params;
8035 };
8036
8037 /**
8038 * Main method to create a new SweetAlert2 popup
8039 *
8040 * @this {new (...args: any[]) => any}
8041 * @param {...SweetAlertOptions} args
8042 * @returns {Promise<SweetAlertResult>}
8043 */
8044 function fire(...args) {
8045 return new this(...args);
8046 }
8047
8048 /**
8049 * Returns an extended version of `Swal` containing `params` as defaults.
8050 * Useful for reusing Swal configuration.
8051 *
8052 * For example:
8053 *
8054 * Before:
8055 * const textPromptOptions = { input: 'text', showCancelButton: true }
8056 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
8057 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
8058 *
8059 * After:
8060 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
8061 * const {value: firstName} = await TextPrompt('What is your first name?')
8062 * const {value: lastName} = await TextPrompt('What is your last name?')
8063 *
8064 * @param {SweetAlertOptions} mixinParams
8065 * @returns {SweetAlert}
8066 * @this {typeof import('../SweetAlert.js').SweetAlert}
8067 */
8068 function mixin(mixinParams) {
8069 // @ts-ignore: 'this' refers to the SweetAlert constructor
8070 class MixinSwal extends this {
8071 /**
8072 * @param {any} params
8073 * @param {any} priorityMixinParams
8074 */
8075 _main(params, priorityMixinParams) {
8076 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
8077 }
8078 }
8079 // @ts-ignore
8080 return MixinSwal;
8081 }
8082
8083 /**
8084 * If `timer` parameter is set, returns number of milliseconds of timer remained.
8085 * Otherwise, returns undefined.
8086 *
8087 * @returns {number | undefined}
8088 */
8089 const getTimerLeft = () => {
8090 return globalState.timeout && globalState.timeout.getTimerLeft();
8091 };
8092
8093 /**
8094 * Stop timer. Returns number of milliseconds of timer remained.
8095 * If `timer` parameter isn't set, returns undefined.
8096 *
8097 * @returns {number | undefined}
8098 */
8099 const stopTimer = () => {
8100 if (globalState.timeout) {
8101 stopTimerProgressBar();
8102 return globalState.timeout.stop();
8103 }
8104 };
8105
8106 /**
8107 * Resume timer. Returns number of milliseconds of timer remained.
8108 * If `timer` parameter isn't set, returns undefined.
8109 *
8110 * @returns {number | undefined}
8111 */
8112 const resumeTimer = () => {
8113 if (globalState.timeout) {
8114 const remaining = globalState.timeout.start();
8115 animateTimerProgressBar(remaining);
8116 return remaining;
8117 }
8118 };
8119
8120 /**
8121 * Resume timer. Returns number of milliseconds of timer remained.
8122 * If `timer` parameter isn't set, returns undefined.
8123 *
8124 * @returns {number | undefined}
8125 */
8126 const toggleTimer = () => {
8127 const timer = globalState.timeout;
8128 return timer && (timer.running ? stopTimer() : resumeTimer());
8129 };
8130
8131 /**
8132 * Increase timer. Returns number of milliseconds of an updated timer.
8133 * If `timer` parameter isn't set, returns undefined.
8134 *
8135 * @param {number} ms
8136 * @returns {number | undefined}
8137 */
8138 const increaseTimer = ms => {
8139 if (globalState.timeout) {
8140 const remaining = globalState.timeout.increase(ms);
8141 animateTimerProgressBar(remaining, true);
8142 return remaining;
8143 }
8144 };
8145
8146 /**
8147 * Check if timer is running. Returns true if timer is running
8148 * or false if timer is paused or stopped.
8149 * If `timer` parameter isn't set, returns undefined
8150 *
8151 * @returns {boolean}
8152 */
8153 const isTimerRunning = () => {
8154 return Boolean(globalState.timeout && globalState.timeout.isRunning());
8155 };
8156
8157 let bodyClickListenerAdded = false;
8158 /** @type {Record<string, any>} */
8159 const clickHandlers = {};
8160
8161 /**
8162 * @this {any}
8163 * @param {string} attr
8164 */
8165 function bindClickHandler(attr = 'data-swal-template') {
8166 clickHandlers[attr] = this;
8167 if (!bodyClickListenerAdded) {
8168 document.body.addEventListener('click', bodyClickListener);
8169 bodyClickListenerAdded = true;
8170 }
8171 }
8172
8173 /**
8174 * @param {MouseEvent} event
8175 */
8176 const bodyClickListener = event => {
8177 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
8178 for (const attr in clickHandlers) {
8179 const template = el.getAttribute && el.getAttribute(attr);
8180 if (template) {
8181 clickHandlers[attr].fire({
8182 template
8183 });
8184 return;
8185 }
8186 }
8187 }
8188 };
8189
8190 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
8191
8192 class EventEmitter {
8193 constructor() {
8194 /** @type {Events} */
8195 this.events = {};
8196 }
8197
8198 /**
8199 * @param {string} eventName
8200 * @returns {EventHandlers}
8201 */
8202 _getHandlersByEventName(eventName) {
8203 if (typeof this.events[eventName] === 'undefined') {
8204 // not Set because we need to keep the FIFO order
8205 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
8206 this.events[eventName] = [];
8207 }
8208 return this.events[eventName];
8209 }
8210
8211 /**
8212 * @param {string} eventName
8213 * @param {EventHandler} eventHandler
8214 */
8215 on(eventName, eventHandler) {
8216 const currentHandlers = this._getHandlersByEventName(eventName);
8217 if (!currentHandlers.includes(eventHandler)) {
8218 currentHandlers.push(eventHandler);
8219 }
8220 }
8221
8222 /**
8223 * @param {string} eventName
8224 * @param {EventHandler} eventHandler
8225 */
8226 once(eventName, eventHandler) {
8227 /**
8228 * @param {...any} args
8229 */
8230 const onceFn = (...args) => {
8231 this.removeListener(eventName, onceFn);
8232 // @ts-ignore
8233 eventHandler.apply(this, args);
8234 };
8235 this.on(eventName, onceFn);
8236 }
8237
8238 /**
8239 * @param {string} eventName
8240 * @param {...any} args
8241 */
8242 emit(eventName, ...args) {
8243 this._getHandlersByEventName(eventName).forEach(
8244 /**
8245 * @param {EventHandler} eventHandler
8246 */
8247 eventHandler => {
8248 try {
8249 // @ts-ignore
8250 eventHandler.apply(this, args);
8251 } catch (error) {
8252 console.error(error);
8253 }
8254 });
8255 }
8256
8257 /**
8258 * @param {string} eventName
8259 * @param {EventHandler} eventHandler
8260 */
8261 removeListener(eventName, eventHandler) {
8262 const currentHandlers = this._getHandlersByEventName(eventName);
8263 const index = currentHandlers.indexOf(eventHandler);
8264 if (index > -1) {
8265 currentHandlers.splice(index, 1);
8266 }
8267 }
8268
8269 /**
8270 * @param {string} eventName
8271 */
8272 removeAllListeners(eventName) {
8273 if (this.events[eventName] !== undefined) {
8274 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
8275 this.events[eventName].length = 0;
8276 }
8277 }
8278 reset() {
8279 this.events = {};
8280 }
8281 }
8282
8283 globalState.eventEmitter = new EventEmitter();
8284
8285 /**
8286 * @param {string} eventName
8287 * @param {EventHandler} eventHandler
8288 */
8289 const on = (eventName, eventHandler) => {
8290 if (globalState.eventEmitter) {
8291 globalState.eventEmitter.on(eventName, eventHandler);
8292 }
8293 };
8294
8295 /**
8296 * @param {string} eventName
8297 * @param {EventHandler} eventHandler
8298 */
8299 const once = (eventName, eventHandler) => {
8300 if (globalState.eventEmitter) {
8301 globalState.eventEmitter.once(eventName, eventHandler);
8302 }
8303 };
8304
8305 /**
8306 * @param {string} [eventName]
8307 * @param {EventHandler} [eventHandler]
8308 */
8309 const off = (eventName, eventHandler) => {
8310 if (!globalState.eventEmitter) {
8311 return;
8312 }
8313
8314 // Remove all handlers for all events
8315 if (!eventName) {
8316 globalState.eventEmitter.reset();
8317 return;
8318 }
8319 if (eventHandler) {
8320 // Remove a specific handler
8321 globalState.eventEmitter.removeListener(eventName, eventHandler);
8322 } else {
8323 // Remove all handlers for a specific event
8324 globalState.eventEmitter.removeAllListeners(eventName);
8325 }
8326 };
8327
8328 var staticMethods = /*#__PURE__*/Object.freeze({
8329 __proto__: null,
8330 argsToParams: argsToParams,
8331 bindClickHandler: bindClickHandler,
8332 clickCancel: clickCancel,
8333 clickConfirm: clickConfirm,
8334 clickDeny: clickDeny,
8335 enableLoading: showLoading,
8336 fire: fire,
8337 getActions: getActions,
8338 getCancelButton: getCancelButton,
8339 getCloseButton: getCloseButton,
8340 getConfirmButton: getConfirmButton,
8341 getContainer: getContainer,
8342 getDenyButton: getDenyButton,
8343 getFocusableElements: getFocusableElements,
8344 getFooter: getFooter,
8345 getHtmlContainer: getHtmlContainer,
8346 getIcon: getIcon,
8347 getIconContent: getIconContent,
8348 getImage: getImage,
8349 getInputLabel: getInputLabel,
8350 getLoader: getLoader,
8351 getPopup: getPopup,
8352 getProgressSteps: getProgressSteps,
8353 getTimerLeft: getTimerLeft,
8354 getTimerProgressBar: getTimerProgressBar,
8355 getTitle: getTitle,
8356 getValidationMessage: getValidationMessage,
8357 increaseTimer: increaseTimer,
8358 isDeprecatedParameter: isDeprecatedParameter,
8359 isLoading: isLoading,
8360 isTimerRunning: isTimerRunning,
8361 isUpdatableParameter: isUpdatableParameter,
8362 isValidParameter: isValidParameter,
8363 isVisible: isVisible,
8364 mixin: mixin,
8365 off: off,
8366 on: on,
8367 once: once,
8368 resumeTimer: resumeTimer,
8369 showLoading: showLoading,
8370 stopTimer: stopTimer,
8371 toggleTimer: toggleTimer
8372 });
8373
8374 class Timer {
8375 /**
8376 * @param {() => void} callback
8377 * @param {number} delay
8378 */
8379 constructor(callback, delay) {
8380 this.callback = callback;
8381 this.remaining = delay;
8382 this.running = false;
8383 this.start();
8384 }
8385
8386 /**
8387 * @returns {number}
8388 */
8389 start() {
8390 if (!this.running) {
8391 this.running = true;
8392 this.started = new Date();
8393 this.id = setTimeout(this.callback, this.remaining);
8394 }
8395 return this.remaining;
8396 }
8397
8398 /**
8399 * @returns {number}
8400 */
8401 stop() {
8402 if (this.started && this.running) {
8403 this.running = false;
8404 clearTimeout(this.id);
8405 this.remaining -= new Date().getTime() - this.started.getTime();
8406 }
8407 return this.remaining;
8408 }
8409
8410 /**
8411 * @param {number} n
8412 * @returns {number}
8413 */
8414 increase(n) {
8415 const running = this.running;
8416 if (running) {
8417 this.stop();
8418 }
8419 this.remaining += n;
8420 if (running) {
8421 this.start();
8422 }
8423 return this.remaining;
8424 }
8425
8426 /**
8427 * @returns {number}
8428 */
8429 getTimerLeft() {
8430 if (this.running) {
8431 this.stop();
8432 this.start();
8433 }
8434 return this.remaining;
8435 }
8436
8437 /**
8438 * @returns {boolean}
8439 */
8440 isRunning() {
8441 return this.running;
8442 }
8443 }
8444
8445 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
8446
8447 /**
8448 * @param {SweetAlertOptions} params
8449 * @returns {SweetAlertOptions}
8450 */
8451 const getTemplateParams = params => {
8452 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
8453 if (!template) {
8454 return {};
8455 }
8456 /** @type {DocumentFragment} */
8457 const templateContent = template.content;
8458 showWarningsForElements(templateContent);
8459 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
8460 return result;
8461 };
8462
8463 /**
8464 * @param {DocumentFragment} templateContent
8465 * @returns {Record<string, string | boolean | number>}
8466 */
8467 const getSwalParams = templateContent => {
8468 /** @type {Record<string, string | boolean | number>} */
8469 const result = {};
8470 /** @type {HTMLElement[]} */
8471 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
8472 swalParams.forEach(param => {
8473 showWarningsForAttributes(param, ['name', 'value']);
8474 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
8475 const value = param.getAttribute('value');
8476 if (!paramName || !value) {
8477 return;
8478 }
8479 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
8480 result[paramName] = value !== 'false';
8481 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
8482 result[paramName] = JSON.parse(value);
8483 } else {
8484 result[paramName] = value;
8485 }
8486 });
8487 return result;
8488 };
8489
8490 /**
8491 * @param {DocumentFragment} templateContent
8492 * @returns {Record<string, () => void>}
8493 */
8494 const getSwalFunctionParams = templateContent => {
8495 /** @type {Record<string, () => void>} */
8496 const result = {};
8497 /** @type {HTMLElement[]} */
8498 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
8499 swalFunctions.forEach(param => {
8500 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
8501 const value = param.getAttribute('value');
8502 if (!paramName || !value) {
8503 return;
8504 }
8505 result[paramName] = new Function(`return ${value}`)();
8506 });
8507 return result;
8508 };
8509
8510 /**
8511 * @param {DocumentFragment} templateContent
8512 * @returns {Record<string, string | boolean>}
8513 */
8514 const getSwalButtons = templateContent => {
8515 /** @type {Record<string, string | boolean>} */
8516 const result = {};
8517 /** @type {HTMLElement[]} */
8518 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
8519 swalButtons.forEach(button => {
8520 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
8521 const type = button.getAttribute('type');
8522 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
8523 return;
8524 }
8525 result[`${type}ButtonText`] = button.innerHTML;
8526 result[`show${capitalizeFirstLetter(type)}Button`] = true;
8527 if (button.hasAttribute('color')) {
8528 const color = button.getAttribute('color');
8529 if (color !== null) {
8530 result[`${type}ButtonColor`] = color;
8531 }
8532 }
8533 if (button.hasAttribute('aria-label')) {
8534 const ariaLabel = button.getAttribute('aria-label');
8535 if (ariaLabel !== null) {
8536 result[`${type}ButtonAriaLabel`] = ariaLabel;
8537 }
8538 }
8539 });
8540 return result;
8541 };
8542
8543 /**
8544 * @param {DocumentFragment} templateContent
8545 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
8546 */
8547 const getSwalImage = templateContent => {
8548 const result = {};
8549 /** @type {HTMLElement | null} */
8550 const image = templateContent.querySelector('swal-image');
8551 if (image) {
8552 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
8553 if (image.hasAttribute('src')) {
8554 result.imageUrl = image.getAttribute('src') || undefined;
8555 }
8556 if (image.hasAttribute('width')) {
8557 result.imageWidth = image.getAttribute('width') || undefined;
8558 }
8559 if (image.hasAttribute('height')) {
8560 result.imageHeight = image.getAttribute('height') || undefined;
8561 }
8562 if (image.hasAttribute('alt')) {
8563 result.imageAlt = image.getAttribute('alt') || undefined;
8564 }
8565 }
8566 return result;
8567 };
8568
8569 /**
8570 * @param {DocumentFragment} templateContent
8571 * @returns {object}
8572 */
8573 const getSwalIcon = templateContent => {
8574 const result = {};
8575 /** @type {HTMLElement | null} */
8576 const icon = templateContent.querySelector('swal-icon');
8577 if (icon) {
8578 showWarningsForAttributes(icon, ['type', 'color']);
8579 if (icon.hasAttribute('type')) {
8580 result.icon = icon.getAttribute('type');
8581 }
8582 if (icon.hasAttribute('color')) {
8583 result.iconColor = icon.getAttribute('color');
8584 }
8585 result.iconHtml = icon.innerHTML;
8586 }
8587 return result;
8588 };
8589
8590 /**
8591 * @param {DocumentFragment} templateContent
8592 * @returns {object}
8593 */
8594 const getSwalInput = templateContent => {
8595 /** @type {Record<string, any>} */
8596 const result = {};
8597 /** @type {HTMLElement | null} */
8598 const input = templateContent.querySelector('swal-input');
8599 if (input) {
8600 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
8601 result.input = input.getAttribute('type') || 'text';
8602 if (input.hasAttribute('label')) {
8603 result.inputLabel = input.getAttribute('label');
8604 }
8605 if (input.hasAttribute('placeholder')) {
8606 result.inputPlaceholder = input.getAttribute('placeholder');
8607 }
8608 if (input.hasAttribute('value')) {
8609 result.inputValue = input.getAttribute('value');
8610 }
8611 }
8612 /** @type {HTMLElement[]} */
8613 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
8614 if (inputOptions.length) {
8615 result.inputOptions = {};
8616 inputOptions.forEach(option => {
8617 showWarningsForAttributes(option, ['value']);
8618 const optionValue = option.getAttribute('value');
8619 if (!optionValue) {
8620 return;
8621 }
8622 const optionName = option.innerHTML;
8623 result.inputOptions[optionValue] = optionName;
8624 });
8625 }
8626 return result;
8627 };
8628
8629 /**
8630 * @param {DocumentFragment} templateContent
8631 * @param {string[]} paramNames
8632 * @returns {Record<string, string>}
8633 */
8634 const getSwalStringParams = (templateContent, paramNames) => {
8635 /** @type {Record<string, string>} */
8636 const result = {};
8637 for (const i in paramNames) {
8638 const paramName = paramNames[i];
8639 /** @type {HTMLElement | null} */
8640 const tag = templateContent.querySelector(paramName);
8641 if (tag) {
8642 showWarningsForAttributes(tag, []);
8643 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
8644 }
8645 }
8646 return result;
8647 };
8648
8649 /**
8650 * @param {DocumentFragment} templateContent
8651 */
8652 const showWarningsForElements = templateContent => {
8653 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
8654 Array.from(templateContent.children).forEach(el => {
8655 const tagName = el.tagName.toLowerCase();
8656 if (!allowedElements.includes(tagName)) {
8657 warn(`Unrecognized element <${tagName}>`);
8658 }
8659 });
8660 };
8661
8662 /**
8663 * @param {HTMLElement} el
8664 * @param {string[]} allowedAttributes
8665 */
8666 const showWarningsForAttributes = (el, allowedAttributes) => {
8667 Array.from(el.attributes).forEach(attribute => {
8668 if (allowedAttributes.indexOf(attribute.name) === -1) {
8669 warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(', ')}` : 'To set the value, use HTML within the element.'}`]);
8670 }
8671 });
8672 };
8673
8674 const SHOW_CLASS_TIMEOUT = 10;
8675
8676 /**
8677 * Open popup, add necessary classes and styles, fix scrollbar
8678 *
8679 * @param {SweetAlertOptions} params
8680 */
8681 const openPopup = params => {
8682 var _globalState$eventEmi, _globalState$eventEmi2;
8683 const container = getContainer();
8684 const popup = getPopup();
8685 if (!container || !popup) {
8686 return;
8687 }
8688 if (typeof params.willOpen === 'function') {
8689 params.willOpen(popup);
8690 }
8691 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
8692 const bodyStyles = window.getComputedStyle(document.body);
8693 const initialBodyOverflow = bodyStyles.overflowY;
8694 addClasses(container, popup, params);
8695
8696 // scrolling is 'hidden' until animation is done, after that 'auto'
8697 setTimeout(() => {
8698 setScrollingVisibility(container, popup);
8699 }, SHOW_CLASS_TIMEOUT);
8700 if (isModal()) {
8701 // Using ternary instead of ?? operator for Webpack 4 compatibility
8702 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
8703 setAriaHidden();
8704 }
8705 if (!isToast() && !globalState.previousActiveElement) {
8706 globalState.previousActiveElement = document.activeElement;
8707 }
8708 if (typeof params.didOpen === 'function') {
8709 const didOpen = params.didOpen;
8710 setTimeout(() => didOpen(popup));
8711 }
8712 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
8713 };
8714
8715 /**
8716 * @param {Event} event
8717 */
8718 const swalOpenAnimationFinished = event => {
8719 const popup = getPopup();
8720 if (!popup || event.target !== popup) {
8721 return;
8722 }
8723 const container = getContainer();
8724 if (!container) {
8725 return;
8726 }
8727 popup.removeEventListener('animationend', swalOpenAnimationFinished);
8728 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
8729 container.style.overflowY = 'auto';
8730
8731 // no-transition is added in init() in case one swal is opened right after another
8732 removeClass(container, swalClasses['no-transition']);
8733 };
8734
8735 /**
8736 * @param {HTMLElement} container
8737 * @param {HTMLElement} popup
8738 */
8739 const setScrollingVisibility = (container, popup) => {
8740 if (hasCssAnimation(popup)) {
8741 container.style.overflowY = 'hidden';
8742 popup.addEventListener('animationend', swalOpenAnimationFinished);
8743 popup.addEventListener('transitionend', swalOpenAnimationFinished);
8744 } else {
8745 container.style.overflowY = 'auto';
8746 }
8747 };
8748
8749 /**
8750 * @param {HTMLElement} container
8751 * @param {boolean} scrollbarPadding
8752 * @param {string} initialBodyOverflow
8753 */
8754 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
8755 iOSfix();
8756 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
8757 replaceScrollbarWithPadding(initialBodyOverflow);
8758 }
8759
8760 // sweetalert2/issues/1247
8761 setTimeout(() => {
8762 container.scrollTop = 0;
8763 });
8764 };
8765
8766 /**
8767 * @param {HTMLElement} container
8768 * @param {HTMLElement} popup
8769 * @param {SweetAlertOptions} params
8770 */
8771 const addClasses = (container, popup, params) => {
8772 var _params$showClass;
8773 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
8774 addClass(container, params.showClass.backdrop);
8775 }
8776 if (params.animation) {
8777 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
8778 popup.style.setProperty('opacity', '0', 'important');
8779 show(popup, 'grid');
8780 setTimeout(() => {
8781 var _params$showClass2;
8782 // Animate popup right after showing it
8783 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
8784 addClass(popup, params.showClass.popup);
8785 }
8786 // and remove the opacity workaround
8787 popup.style.removeProperty('opacity');
8788 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
8789 } else {
8790 show(popup, 'grid');
8791 }
8792 addClass([document.documentElement, document.body], swalClasses.shown);
8793 if (params.heightAuto && params.backdrop && !params.toast) {
8794 addClass([document.documentElement, document.body], swalClasses['height-auto']);
8795 }
8796 };
8797
8798 var defaultInputValidators = {
8799 /**
8800 * @param {string} string
8801 * @param {string} [validationMessage]
8802 * @returns {Promise<string | void>}
8803 */
8804 email: (string, validationMessage) => {
8805 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
8806 },
8807 /**
8808 * @param {string} string
8809 * @param {string} [validationMessage]
8810 * @returns {Promise<string | void>}
8811 */
8812 url: (string, validationMessage) => {
8813 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
8814 return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL');
8815 }
8816 };
8817
8818 /**
8819 * @param {SweetAlertOptions} params
8820 */
8821 function setDefaultInputValidators(params) {
8822 // Use default `inputValidator` for supported input types if not provided
8823 if (params.inputValidator) {
8824 return;
8825 }
8826 if (params.input === 'email') {
8827 params.inputValidator = defaultInputValidators['email'];
8828 }
8829 if (params.input === 'url') {
8830 params.inputValidator = defaultInputValidators['url'];
8831 }
8832 }
8833
8834 /**
8835 * @param {SweetAlertOptions} params
8836 */
8837 function validateCustomTargetElement(params) {
8838 // Determine if the custom target element is valid
8839 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
8840 warn('Target parameter is not valid, defaulting to "body"');
8841 params.target = 'body';
8842 }
8843 }
8844
8845 /**
8846 * Set type, text and actions on popup
8847 *
8848 * @param {SweetAlertOptions} params
8849 */
8850 function setParameters(params) {
8851 setDefaultInputValidators(params);
8852
8853 // showLoaderOnConfirm && preConfirm
8854 if (params.showLoaderOnConfirm && !params.preConfirm) {
8855 warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request');
8856 }
8857 validateCustomTargetElement(params);
8858
8859 // Replace newlines with <br> in title
8860 if (typeof params.title === 'string') {
8861 params.title = params.title.split('\n').join('<br />');
8862 }
8863 init(params);
8864 }
8865
8866 /** @type {SweetAlert} */
8867 let currentInstance;
8868 var _promise = /*#__PURE__*/new WeakMap();
8869 class SweetAlert {
8870 /**
8871 * @param {...(SweetAlertOptions | string)} args
8872 * @this {SweetAlert}
8873 */
8874 constructor(...args) {
8875 /**
8876 * @type {Promise<SweetAlertResult>}
8877 */
8878 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
8879 isConfirmed: false,
8880 isDenied: false,
8881 isDismissed: true
8882 }));
8883 // Prevent run in Node env
8884 if (typeof window === 'undefined') {
8885 return;
8886 }
8887 currentInstance = this;
8888
8889 // @ts-ignore
8890 const outerParams = Object.freeze(this.constructor.argsToParams(args));
8891
8892 /** @type {Readonly<SweetAlertOptions>} */
8893 this.params = outerParams;
8894
8895 /** @type {boolean} */
8896 this.isAwaitingPromise = false;
8897 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
8898 }
8899
8900 /**
8901 * @param {any} userParams
8902 * @param {any} mixinParams
8903 */
8904 _main(userParams, mixinParams = {}) {
8905 showWarningsForParams(Object.assign({}, mixinParams, userParams));
8906 if (globalState.currentInstance) {
8907 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
8908 const {
8909 isAwaitingPromise
8910 } = globalState.currentInstance;
8911 globalState.currentInstance._destroy();
8912 if (!isAwaitingPromise) {
8913 swalPromiseResolve({
8914 isDismissed: true
8915 });
8916 }
8917 if (isModal()) {
8918 unsetAriaHidden();
8919 }
8920 }
8921 globalState.currentInstance = currentInstance;
8922 const innerParams = prepareParams(userParams, mixinParams);
8923 setParameters(innerParams);
8924 Object.freeze(innerParams);
8925
8926 // clear the previous timer
8927 if (globalState.timeout) {
8928 globalState.timeout.stop();
8929 delete globalState.timeout;
8930 }
8931
8932 // clear the restore focus timeout
8933 clearTimeout(globalState.restoreFocusTimeout);
8934 const domCache = populateDomCache(currentInstance);
8935 render(currentInstance, innerParams);
8936 privateProps.innerParams.set(currentInstance, innerParams);
8937 return swalPromise(currentInstance, domCache, innerParams);
8938 }
8939
8940 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
8941 /**
8942 * @param {any} onFulfilled
8943 */
8944 then(onFulfilled) {
8945 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
8946 }
8947
8948 /**
8949 * @param {any} onFinally
8950 */
8951 finally(onFinally) {
8952 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
8953 }
8954 }
8955
8956 /**
8957 * @param {SweetAlert} instance
8958 * @param {DomCache} domCache
8959 * @param {SweetAlertOptions} innerParams
8960 * @returns {Promise<SweetAlertResult>}
8961 */
8962 const swalPromise = (instance, domCache, innerParams) => {
8963 return new Promise((resolve, reject) => {
8964 // functions to handle all closings/dismissals
8965 /**
8966 * @param {DismissReason} dismiss
8967 */
8968 const dismissWith = dismiss => {
8969 instance.close({
8970 isDismissed: true,
8971 dismiss,
8972 isConfirmed: false,
8973 isDenied: false
8974 });
8975 };
8976 privateMethods.swalPromiseResolve.set(instance, resolve);
8977 privateMethods.swalPromiseReject.set(instance, reject);
8978 domCache.confirmButton.onclick = () => {
8979 handleConfirmButtonClick(instance);
8980 };
8981 domCache.denyButton.onclick = () => {
8982 handleDenyButtonClick(instance);
8983 };
8984 domCache.cancelButton.onclick = () => {
8985 handleCancelButtonClick(instance, dismissWith);
8986 };
8987 domCache.closeButton.onclick = () => {
8988 dismissWith(DismissReason.close);
8989 };
8990 handlePopupClick(innerParams, domCache, dismissWith);
8991 addKeydownHandler(globalState, innerParams, dismissWith);
8992 handleInputOptionsAndValue(instance, innerParams);
8993 openPopup(innerParams);
8994 setupTimer(globalState, innerParams, dismissWith);
8995 initFocus(domCache, innerParams);
8996
8997 // Scroll container to top on open (#1247, #1946)
8998 setTimeout(() => {
8999 domCache.container.scrollTop = 0;
9000 });
9001 });
9002 };
9003
9004 /**
9005 * @param {SweetAlertOptions} userParams
9006 * @param {SweetAlertOptions} mixinParams
9007 * @returns {SweetAlertOptions}
9008 */
9009 const prepareParams = (userParams, mixinParams) => {
9010 const templateParams = getTemplateParams(userParams);
9011 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
9012 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
9013 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
9014 if (params.animation === false) {
9015 params.showClass = {
9016 backdrop: 'swal2-noanimation'
9017 };
9018 params.hideClass = {};
9019 }
9020 return params;
9021 };
9022
9023 /**
9024 * @param {SweetAlert} instance
9025 * @returns {DomCache}
9026 */
9027 const populateDomCache = instance => {
9028 const domCache = /** @type {DomCache} */{
9029 popup: (/** @type {HTMLElement} */getPopup()),
9030 container: (/** @type {HTMLElement} */getContainer()),
9031 actions: (/** @type {HTMLElement} */getActions()),
9032 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
9033 denyButton: (/** @type {HTMLElement} */getDenyButton()),
9034 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
9035 loader: (/** @type {HTMLElement} */getLoader()),
9036 closeButton: (/** @type {HTMLElement} */getCloseButton()),
9037 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
9038 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
9039 };
9040 privateProps.domCache.set(instance, domCache);
9041 return domCache;
9042 };
9043
9044 /**
9045 * @param {GlobalState} globalState
9046 * @param {SweetAlertOptions} innerParams
9047 * @param {(dismiss: DismissReason) => void} dismissWith
9048 */
9049 const setupTimer = (globalState, innerParams, dismissWith) => {
9050 const timerProgressBar = getTimerProgressBar();
9051 hide(timerProgressBar);
9052 if (innerParams.timer) {
9053 globalState.timeout = new Timer(() => {
9054 dismissWith('timer');
9055 delete globalState.timeout;
9056 }, innerParams.timer);
9057 if (innerParams.timerProgressBar && timerProgressBar) {
9058 show(timerProgressBar);
9059 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
9060 setTimeout(() => {
9061 if (globalState.timeout && globalState.timeout.running) {
9062 // timer can be already stopped or unset at this point
9063 animateTimerProgressBar(/** @type {number} */innerParams.timer);
9064 }
9065 });
9066 }
9067 }
9068 };
9069
9070 /**
9071 * Initialize focus in the popup:
9072 *
9073 * 1. If `toast` is `true`, don't steal focus from the document.
9074 * 2. Else if there is an [autofocus] element, focus it.
9075 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
9076 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
9077 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
9078 * 6. Else focus the first focusable element in a popup (if any).
9079 *
9080 * @param {DomCache} domCache
9081 * @param {SweetAlertOptions} innerParams
9082 */
9083 const initFocus = (domCache, innerParams) => {
9084 if (innerParams.toast) {
9085 return;
9086 }
9087 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
9088 if (!callIfFunction(innerParams.allowEnterKey)) {
9089 warnAboutDeprecation('allowEnterKey');
9090 blurActiveElement();
9091 return;
9092 }
9093 if (focusAutofocus(domCache)) {
9094 return;
9095 }
9096 if (focusButton(domCache, innerParams)) {
9097 return;
9098 }
9099 setFocus(-1, 1);
9100 };
9101
9102 /**
9103 * @param {DomCache} domCache
9104 * @returns {boolean}
9105 */
9106 const focusAutofocus = domCache => {
9107 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
9108 for (const autofocusElement of autofocusElements) {
9109 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
9110 autofocusElement.focus();
9111 return true;
9112 }
9113 }
9114 return false;
9115 };
9116
9117 /**
9118 * @param {DomCache} domCache
9119 * @param {SweetAlertOptions} innerParams
9120 * @returns {boolean}
9121 */
9122 const focusButton = (domCache, innerParams) => {
9123 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
9124 domCache.denyButton.focus();
9125 return true;
9126 }
9127 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
9128 domCache.cancelButton.focus();
9129 return true;
9130 }
9131 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
9132 domCache.confirmButton.focus();
9133 return true;
9134 }
9135 return false;
9136 };
9137 const blurActiveElement = () => {
9138 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
9139 document.activeElement.blur();
9140 }
9141 };
9142
9143 // Assign instance methods from src/instanceMethods/*.js to prototype
9144 SweetAlert.prototype.disableButtons = disableButtons;
9145 SweetAlert.prototype.enableButtons = enableButtons;
9146 SweetAlert.prototype.getInput = getInput;
9147 SweetAlert.prototype.disableInput = disableInput;
9148 SweetAlert.prototype.enableInput = enableInput;
9149 SweetAlert.prototype.hideLoading = hideLoading;
9150 SweetAlert.prototype.disableLoading = hideLoading;
9151 SweetAlert.prototype.showValidationMessage = showValidationMessage;
9152 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
9153 SweetAlert.prototype.close = close;
9154 SweetAlert.prototype.closePopup = close;
9155 SweetAlert.prototype.closeModal = close;
9156 SweetAlert.prototype.closeToast = close;
9157 SweetAlert.prototype.rejectPromise = rejectPromise;
9158 SweetAlert.prototype.update = update;
9159 SweetAlert.prototype._destroy = _destroy;
9160
9161 // Assign static methods from src/staticMethods/*.js to constructor
9162 Object.assign(SweetAlert, staticMethods);
9163
9164 // Proxy to instance methods to constructor, for now, for backwards compatibility
9165 Object.keys(instanceMethods).forEach(key => {
9166 /**
9167 * @param {...(SweetAlertOptions | string | undefined)} args
9168 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
9169 */
9170 // @ts-ignore: Dynamic property assignment for backwards compatibility
9171 SweetAlert[key] = function (...args) {
9172 // @ts-ignore
9173 if (currentInstance && currentInstance[key]) {
9174 // @ts-ignore
9175 return currentInstance[key](...args);
9176 }
9177 return undefined;
9178 };
9179 });
9180 SweetAlert.DismissReason = DismissReason;
9181 SweetAlert.version = '11.26.17';
9182
9183 const Swal = SweetAlert;
9184 // @ts-ignore
9185 Swal.default = Swal;
9186
9187 return Swal;
9188
9189 }));
9190 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
9191 "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}");
9192
9193 /***/ },
9194
9195 /***/ "./node_modules/toastify-js/src/toastify.js"
9196 /*!**************************************************!*\
9197 !*** ./node_modules/toastify-js/src/toastify.js ***!
9198 \**************************************************/
9199 (module) {
9200
9201 /*!
9202 * Toastify js 1.12.0
9203 * https://github.com/apvarun/toastify-js
9204 * @license MIT licensed
9205 *
9206 * Copyright (C) 2018 Varun A P
9207 */
9208 (function(root, factory) {
9209 if ( true && module.exports) {
9210 module.exports = factory();
9211 } else {
9212 root.Toastify = factory();
9213 }
9214 })(this, function(global) {
9215 // Object initialization
9216 var Toastify = function(options) {
9217 // Returning a new init object
9218 return new Toastify.lib.init(options);
9219 },
9220 // Library version
9221 version = "1.12.0";
9222
9223 // Set the default global options
9224 Toastify.defaults = {
9225 oldestFirst: true,
9226 text: "Toastify is awesome!",
9227 node: undefined,
9228 duration: 3000,
9229 selector: undefined,
9230 callback: function () {
9231 },
9232 destination: undefined,
9233 newWindow: false,
9234 close: false,
9235 gravity: "toastify-top",
9236 positionLeft: false,
9237 position: '',
9238 backgroundColor: '',
9239 avatar: "",
9240 className: "",
9241 stopOnFocus: true,
9242 onClick: function () {
9243 },
9244 offset: {x: 0, y: 0},
9245 escapeMarkup: true,
9246 ariaLive: 'polite',
9247 style: {background: ''}
9248 };
9249
9250 // Defining the prototype of the object
9251 Toastify.lib = Toastify.prototype = {
9252 toastify: version,
9253
9254 constructor: Toastify,
9255
9256 // Initializing the object with required parameters
9257 init: function(options) {
9258 // Verifying and validating the input object
9259 if (!options) {
9260 options = {};
9261 }
9262
9263 // Creating the options object
9264 this.options = {};
9265
9266 this.toastElement = null;
9267
9268 // Validating the options
9269 this.options.text = options.text || Toastify.defaults.text; // Display message
9270 this.options.node = options.node || Toastify.defaults.node; // Display content as node
9271 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
9272 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
9273 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
9274 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
9275 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
9276 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
9277 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
9278 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
9279 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
9280 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
9281 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
9282 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
9283 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
9284 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
9285 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
9286 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
9287 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
9288 this.options.style = options.style || Toastify.defaults.style;
9289 if(options.backgroundColor) {
9290 this.options.style.background = options.backgroundColor;
9291 }
9292
9293 // Returning the current object for chaining functions
9294 return this;
9295 },
9296
9297 // Building the DOM element
9298 buildToast: function() {
9299 // Validating if the options are defined
9300 if (!this.options) {
9301 throw "Toastify is not initialized";
9302 }
9303
9304 // Creating the DOM object
9305 var divElement = document.createElement("div");
9306 divElement.className = "toastify on " + this.options.className;
9307
9308 // Positioning toast to left or right or center
9309 if (!!this.options.position) {
9310 divElement.className += " toastify-" + this.options.position;
9311 } else {
9312 // To be depreciated in further versions
9313 if (this.options.positionLeft === true) {
9314 divElement.className += " toastify-left";
9315 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
9316 } else {
9317 // Default position
9318 divElement.className += " toastify-right";
9319 }
9320 }
9321
9322 // Assigning gravity of element
9323 divElement.className += " " + this.options.gravity;
9324
9325 if (this.options.backgroundColor) {
9326 // This is being deprecated in favor of using the style HTML DOM property
9327 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
9328 }
9329
9330 // Loop through our style object and apply styles to divElement
9331 for (var property in this.options.style) {
9332 divElement.style[property] = this.options.style[property];
9333 }
9334
9335 // Announce the toast to screen readers
9336 if (this.options.ariaLive) {
9337 divElement.setAttribute('aria-live', this.options.ariaLive)
9338 }
9339
9340 // Adding the toast message/node
9341 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
9342 // If we have a valid node, we insert it
9343 divElement.appendChild(this.options.node)
9344 } else {
9345 if (this.options.escapeMarkup) {
9346 divElement.innerText = this.options.text;
9347 } else {
9348 divElement.innerHTML = this.options.text;
9349 }
9350
9351 if (this.options.avatar !== "") {
9352 var avatarElement = document.createElement("img");
9353 avatarElement.src = this.options.avatar;
9354
9355 avatarElement.className = "toastify-avatar";
9356
9357 if (this.options.position == "left" || this.options.positionLeft === true) {
9358 // Adding close icon on the left of content
9359 divElement.appendChild(avatarElement);
9360 } else {
9361 // Adding close icon on the right of content
9362 divElement.insertAdjacentElement("afterbegin", avatarElement);
9363 }
9364 }
9365 }
9366
9367 // Adding a close icon to the toast
9368 if (this.options.close === true) {
9369 // Create a span for close element
9370 var closeElement = document.createElement("button");
9371 closeElement.type = "button";
9372 closeElement.setAttribute("aria-label", "Close");
9373 closeElement.className = "toast-close";
9374 closeElement.innerHTML = "&#10006;";
9375
9376 // Triggering the removal of toast from DOM on close click
9377 closeElement.addEventListener(
9378 "click",
9379 function(event) {
9380 event.stopPropagation();
9381 this.removeElement(this.toastElement);
9382 window.clearTimeout(this.toastElement.timeOutValue);
9383 }.bind(this)
9384 );
9385
9386 //Calculating screen width
9387 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
9388
9389 // Adding the close icon to the toast element
9390 // Display on the right if screen width is less than or equal to 360px
9391 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
9392 // Adding close icon on the left of content
9393 divElement.insertAdjacentElement("afterbegin", closeElement);
9394 } else {
9395 // Adding close icon on the right of content
9396 divElement.appendChild(closeElement);
9397 }
9398 }
9399
9400 // Clear timeout while toast is focused
9401 if (this.options.stopOnFocus && this.options.duration > 0) {
9402 var self = this;
9403 // stop countdown
9404 divElement.addEventListener(
9405 "mouseover",
9406 function(event) {
9407 window.clearTimeout(divElement.timeOutValue);
9408 }
9409 )
9410 // add back the timeout
9411 divElement.addEventListener(
9412 "mouseleave",
9413 function() {
9414 divElement.timeOutValue = window.setTimeout(
9415 function() {
9416 // Remove the toast from DOM
9417 self.removeElement(divElement);
9418 },
9419 self.options.duration
9420 )
9421 }
9422 )
9423 }
9424
9425 // Adding an on-click destination path
9426 if (typeof this.options.destination !== "undefined") {
9427 divElement.addEventListener(
9428 "click",
9429 function(event) {
9430 event.stopPropagation();
9431 if (this.options.newWindow === true) {
9432 window.open(this.options.destination, "_blank");
9433 } else {
9434 window.location = this.options.destination;
9435 }
9436 }.bind(this)
9437 );
9438 }
9439
9440 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
9441 divElement.addEventListener(
9442 "click",
9443 function(event) {
9444 event.stopPropagation();
9445 this.options.onClick();
9446 }.bind(this)
9447 );
9448 }
9449
9450 // Adding offset
9451 if(typeof this.options.offset === "object") {
9452
9453 var x = getAxisOffsetAValue("x", this.options);
9454 var y = getAxisOffsetAValue("y", this.options);
9455
9456 var xOffset = this.options.position == "left" ? x : "-" + x;
9457 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
9458
9459 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
9460
9461 }
9462
9463 // Returning the generated element
9464 return divElement;
9465 },
9466
9467 // Displaying the toast
9468 showToast: function() {
9469 // Creating the DOM object for the toast
9470 this.toastElement = this.buildToast();
9471
9472 // Getting the root element to with the toast needs to be added
9473 var rootElement;
9474 if (typeof this.options.selector === "string") {
9475 rootElement = document.getElementById(this.options.selector);
9476 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
9477 rootElement = this.options.selector;
9478 } else {
9479 rootElement = document.body;
9480 }
9481
9482 // Validating if root element is present in DOM
9483 if (!rootElement) {
9484 throw "Root element is not defined";
9485 }
9486
9487 // Adding the DOM element
9488 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
9489 rootElement.insertBefore(this.toastElement, elementToInsert);
9490
9491 // Repositioning the toasts in case multiple toasts are present
9492 Toastify.reposition();
9493
9494 if (this.options.duration > 0) {
9495 this.toastElement.timeOutValue = window.setTimeout(
9496 function() {
9497 // Remove the toast from DOM
9498 this.removeElement(this.toastElement);
9499 }.bind(this),
9500 this.options.duration
9501 ); // Binding `this` for function invocation
9502 }
9503
9504 // Supporting function chaining
9505 return this;
9506 },
9507
9508 hideToast: function() {
9509 if (this.toastElement.timeOutValue) {
9510 clearTimeout(this.toastElement.timeOutValue);
9511 }
9512 this.removeElement(this.toastElement);
9513 },
9514
9515 // Removing the element from the DOM
9516 removeElement: function(toastElement) {
9517 // Hiding the element
9518 // toastElement.classList.remove("on");
9519 toastElement.className = toastElement.className.replace(" on", "");
9520
9521 // Removing the element from DOM after transition end
9522 window.setTimeout(
9523 function() {
9524 // remove options node if any
9525 if (this.options.node && this.options.node.parentNode) {
9526 this.options.node.parentNode.removeChild(this.options.node);
9527 }
9528
9529 // Remove the element from the DOM, only when the parent node was not removed before.
9530 if (toastElement.parentNode) {
9531 toastElement.parentNode.removeChild(toastElement);
9532 }
9533
9534 // Calling the callback function
9535 this.options.callback.call(toastElement);
9536
9537 // Repositioning the toasts again
9538 Toastify.reposition();
9539 }.bind(this),
9540 400
9541 ); // Binding `this` for function invocation
9542 },
9543 };
9544
9545 // Positioning the toasts on the DOM
9546 Toastify.reposition = function() {
9547
9548 // Top margins with gravity
9549 var topLeftOffsetSize = {
9550 top: 15,
9551 bottom: 15,
9552 };
9553 var topRightOffsetSize = {
9554 top: 15,
9555 bottom: 15,
9556 };
9557 var offsetSize = {
9558 top: 15,
9559 bottom: 15,
9560 };
9561
9562 // Get all toast messages on the DOM
9563 var allToasts = document.getElementsByClassName("toastify");
9564
9565 var classUsed;
9566
9567 // Modifying the position of each toast element
9568 for (var i = 0; i < allToasts.length; i++) {
9569 // Getting the applied gravity
9570 if (containsClass(allToasts[i], "toastify-top") === true) {
9571 classUsed = "toastify-top";
9572 } else {
9573 classUsed = "toastify-bottom";
9574 }
9575
9576 var height = allToasts[i].offsetHeight;
9577 classUsed = classUsed.substr(9, classUsed.length-1)
9578 // Spacing between toasts
9579 var offset = 15;
9580
9581 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
9582
9583 // Show toast in center if screen with less than or equal to 360px
9584 if (width <= 360) {
9585 // Setting the position
9586 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
9587
9588 offsetSize[classUsed] += height + offset;
9589 } else {
9590 if (containsClass(allToasts[i], "toastify-left") === true) {
9591 // Setting the position
9592 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
9593
9594 topLeftOffsetSize[classUsed] += height + offset;
9595 } else {
9596 // Setting the position
9597 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
9598
9599 topRightOffsetSize[classUsed] += height + offset;
9600 }
9601 }
9602 }
9603
9604 // Supporting function chaining
9605 return this;
9606 };
9607
9608 // Helper function to get offset.
9609 function getAxisOffsetAValue(axis, options) {
9610
9611 if(options.offset[axis]) {
9612 if(isNaN(options.offset[axis])) {
9613 return options.offset[axis];
9614 }
9615 else {
9616 return options.offset[axis] + 'px';
9617 }
9618 }
9619
9620 return '0px';
9621
9622 }
9623
9624 function containsClass(elem, yourClass) {
9625 if (!elem || typeof yourClass !== "string") {
9626 return false;
9627 } else if (
9628 elem.className &&
9629 elem.className
9630 .trim()
9631 .split(/\s+/gi)
9632 .indexOf(yourClass) > -1
9633 ) {
9634 return true;
9635 } else {
9636 return false;
9637 }
9638 }
9639
9640 // Setting up the prototype for the init object
9641 Toastify.lib.init.prototype = Toastify.lib;
9642
9643 // Returning the Toastify function to be assigned to the window object/module
9644 return Toastify;
9645 });
9646
9647
9648 /***/ }
9649
9650 /******/ });
9651 /************************************************************************/
9652 /******/ // The module cache
9653 /******/ var __webpack_module_cache__ = {};
9654 /******/
9655 /******/ // The require function
9656 /******/ function __webpack_require__(moduleId) {
9657 /******/ // Check if module is in cache
9658 /******/ var cachedModule = __webpack_module_cache__[moduleId];
9659 /******/ if (cachedModule !== undefined) {
9660 /******/ return cachedModule.exports;
9661 /******/ }
9662 /******/ // Create a new module (and put it into the cache)
9663 /******/ var module = __webpack_module_cache__[moduleId] = {
9664 /******/ id: moduleId,
9665 /******/ // no module.loaded needed
9666 /******/ exports: {}
9667 /******/ };
9668 /******/
9669 /******/ // Execute the module function
9670 /******/ if (!(moduleId in __webpack_modules__)) {
9671 /******/ delete __webpack_module_cache__[moduleId];
9672 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
9673 /******/ e.code = 'MODULE_NOT_FOUND';
9674 /******/ throw e;
9675 /******/ }
9676 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
9677 /******/
9678 /******/ // Return the exports of the module
9679 /******/ return module.exports;
9680 /******/ }
9681 /******/
9682 /************************************************************************/
9683 /******/ /* webpack/runtime/compat get default export */
9684 /******/ (() => {
9685 /******/ // getDefaultExport function for compatibility with non-harmony modules
9686 /******/ __webpack_require__.n = (module) => {
9687 /******/ var getter = module && module.__esModule ?
9688 /******/ () => (module['default']) :
9689 /******/ () => (module);
9690 /******/ __webpack_require__.d(getter, { a: getter });
9691 /******/ return getter;
9692 /******/ };
9693 /******/ })();
9694 /******/
9695 /******/ /* webpack/runtime/define property getters */
9696 /******/ (() => {
9697 /******/ // define getter functions for harmony exports
9698 /******/ __webpack_require__.d = (exports, definition) => {
9699 /******/ for(var key in definition) {
9700 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
9701 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
9702 /******/ }
9703 /******/ }
9704 /******/ };
9705 /******/ })();
9706 /******/
9707 /******/ /* webpack/runtime/hasOwnProperty shorthand */
9708 /******/ (() => {
9709 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
9710 /******/ })();
9711 /******/
9712 /******/ /* webpack/runtime/make namespace object */
9713 /******/ (() => {
9714 /******/ // define __esModule on exports
9715 /******/ __webpack_require__.r = (exports) => {
9716 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
9717 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
9718 /******/ }
9719 /******/ Object.defineProperty(exports, '__esModule', { value: true });
9720 /******/ };
9721 /******/ })();
9722 /******/
9723 /******/ /* webpack/runtime/nonce */
9724 /******/ (() => {
9725 /******/ __webpack_require__.nc = undefined;
9726 /******/ })();
9727 /******/
9728 /************************************************************************/
9729 var __webpack_exports__ = {};
9730 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
9731 (() => {
9732 "use strict";
9733 /*!**********************************************!*\
9734 !*** ./assets/src/js/admin/edit-question.js ***!
9735 \**********************************************/
9736 __webpack_require__.r(__webpack_exports__);
9737 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9738 /* harmony export */ EditQuestion: () => (/* binding */ EditQuestion)
9739 /* harmony export */ });
9740 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
9741 /* harmony import */ var lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify */ "./assets/src/js/lpToastify.js");
9742 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
9743 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_2__);
9744 /* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! sortablejs */ "./node_modules/sortablejs/modular/sortable.esm.js");
9745 /**
9746 * Edit question JS handler.
9747 *
9748 * @since 4.2.9
9749 * @version 1.0.0
9750 */
9751
9752
9753
9754
9755
9756 const idUrlHandle = 'edit-question';
9757 let fibSelection;
9758 let timeoutAutoUpdateAnswer, timeoutAutoUpdateFib, timeoutAutoUpdateQuestion;
9759
9760 // EditQuestion class
9761 class EditQuestion {
9762 static selectors = {
9763 elEditQuestionWrap: '.lp-edit-question-wrap',
9764 elQuestionEditMain: '.lp-question-edit-main',
9765 elQuestionToggleAll: '.lp-question-toggle-all',
9766 elEditListQuestions: '.lp-edit-list-questions',
9767 elQuestionToggle: '.lp-question-toggle',
9768 elBtnShowPopupItemsToSelect: '.lp-btn-show-popup-items-to-select',
9769 elPopupItemsToSelectClone: '.lp-popup-items-to-select.clone',
9770 elBtnAddQuestion: '.lp-btn-add-question',
9771 elBtnRemoveQuestion: '.lp-btn-remove-question',
9772 elBtnUpdateQuestionTitle: '.lp-btn-update-question-title',
9773 elBtnUpdateQuestionDes: '.lp-btn-update-question-des',
9774 elBtnUpdateQuestionHint: '.lp-btn-update-question-hint',
9775 elBtnUpdateQuestionExplain: '.lp-btn-update-question-explanation',
9776 elQuestionTitleNewInput: '.lp-question-title-new-input',
9777 elQuestionTitleInput: '.lp-question-title-input',
9778 elQuestionTypeLabel: '.lp-question-type-label',
9779 elQuestionTypeNew: '.lp-question-type-new',
9780 elAddNewQuestion: 'add-new-question',
9781 elQuestionClone: '.lp-question-item.clone',
9782 elAnswersConfig: '.lp-answers-config',
9783 elBtnAddAnswer: '.lp-btn-add-question-answer',
9784 elQuestionAnswerItemAddNew: '.lp-question-answer-item-add-new',
9785 elQuestionAnswerTitleNewInput: '.lp-question-answer-title-new-input',
9786 elQuestionAnswerTitleInput: '.lp-question-answer-title-input',
9787 elBtnDeleteAnswer: '.lp-btn-delete-question-answer',
9788 elQuestionByType: '.lp-question-by-type',
9789 elInputAnswerSetTrue: '.lp-input-answer-set-true',
9790 elQuestionAnswerItem: '.lp-question-answer-item',
9791 elBtnUpdateQuestionAnswer: '.lp-btn-update-question-answer',
9792 elBtnFibInsertBlank: '.lp-btn-fib-insert-blank',
9793 elBtnFibDeleteAllBlanks: '.lp-btn-fib-delete-all-blanks',
9794 elBtnFibSaveContent: '.lp-btn-fib-save-content',
9795 elBtnFibClearAllContent: '.lp-btn-fib-clear-all-content',
9796 elFibOptionTitleInput: '.lp-question-fib-option-title-input',
9797 elFibBlankOptions: '.lp-question-fib-blank-options',
9798 elFibBlankOptionItem: '.lp-question-fib-blank-option-item',
9799 elFibBlankOptionItemClone: '.lp-question-fib-blank-option-item.clone',
9800 elFibBlankOptionIndex: '.lp-question-fib-option-index',
9801 elBtnFibOptionDelete: '.lp-btn-fib-option-delete',
9802 elFibOptionMatchCaseWrap: '.lp-question-fib-option-match-case-wrap',
9803 elFibOptionMatchCaseInput: '.lp-question-fib-option-match-case-input',
9804 elQuestionFibOptionDetail: '.lp-question-fib-option-detail',
9805 elFibOptionComparisonInput: '.lp-question-fib-option-comparison-input',
9806 elAutoSaveFib: '.lp-auto-save-fib',
9807 LPTarget: '.lp-target',
9808 elCollapse: 'lp-collapse',
9809 elSectionToggle: '.lp-section-toggle',
9810 elTriggerToggle: '.lp-trigger-toggle',
9811 elAutoSaveQuestion: '.lp-auto-save-question',
9812 elAutoSaveAnswer: '.lp-auto-save-question-answer',
9813 elQuestionFibInput: 'lp-question-fib-input',
9814 elBtnQuestionCreateType: '.lp-btn-question-create-type'
9815 };
9816 constructor() {}
9817 init() {
9818 this.events();
9819 this.initTinyMCE().then();
9820 }
9821 events() {
9822 if (EditQuestion._loadedEvents) {
9823 return;
9824 }
9825 EditQuestion._loadedEvents = true;
9826
9827 // Sortable answers's question
9828 const elQuestionEditMains = document.querySelectorAll(`${EditQuestion.selectors.elQuestionEditMain}`);
9829 elQuestionEditMains.forEach(elQuestionEditMain => {
9830 this.sortAbleQuestionAnswer(elQuestionEditMain);
9831 });
9832 // End sortable
9833
9834 // Event click
9835 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
9836 selector: EditQuestion.selectors.elBtnQuestionCreateType,
9837 callBack: this.createQuestionType.name,
9838 class: this
9839 }, {
9840 selector: EditQuestion.selectors.elBtnAddAnswer,
9841 callBack: this.addQuestionAnswer.name,
9842 class: this
9843 }, {
9844 selector: EditQuestion.selectors.elBtnDeleteAnswer,
9845 callBack: this.deleteQuestionAnswer.name,
9846 class: this
9847 }, {
9848 selector: EditQuestion.selectors.elBtnFibInsertBlank,
9849 callBack: this.fibInsertBlank.name,
9850 class: this
9851 }, {
9852 selector: EditQuestion.selectors.elBtnFibDeleteAllBlanks,
9853 callBack: this.fibDeleteAllBlanks.name,
9854 class: this
9855 }, {
9856 selector: EditQuestion.selectors.elBtnFibSaveContent,
9857 callBack: this.fibSaveContent.name,
9858 class: this
9859 }, {
9860 selector: EditQuestion.selectors.elBtnFibClearAllContent,
9861 callBack: this.fibClearContent.name,
9862 class: this
9863 }, {
9864 selector: EditQuestion.selectors.elBtnFibOptionDelete,
9865 callBack: this.fibDeleteBlank.name,
9866 class: this
9867 }, {
9868 selector: EditQuestion.selectors.elFibOptionMatchCaseInput,
9869 callBack: this.fibShowHideMatchCaseOption.name,
9870 class: this
9871 }, {
9872 selector: EditQuestion.selectors.elFibOptionComparisonInput,
9873 callBack: args => {
9874 const {
9875 e,
9876 target
9877 } = args;
9878 const elQuestionEditMain = target.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
9879 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
9880 elBtnFibSaveContent.click();
9881 }
9882 }]);
9883
9884 // Toggle collapse
9885 document.addEventListener('click', e => {
9886 const target = e.target;
9887 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.toggleCollapse(e, target, EditQuestion.selectors.elTriggerToggle);
9888 });
9889
9890 // Event keyup
9891 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
9892 selector: EditQuestion.selectors.elQuestionAnswerTitleNewInput,
9893 callBack: this.checkCanAddAnswer.name,
9894 class: this
9895 }, {
9896 selector: EditQuestion.selectors.elFibOptionTitleInput,
9897 callBack: this.fibOptionTitleInputChange.name,
9898 class: this
9899 }, {
9900 selector: EditQuestion.selectors.elAutoSaveQuestion,
9901 callBack: this.autoUpdateQuestion.name,
9902 class: this
9903 }]);
9904
9905 // Event keydown
9906 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keydown', [{
9907 selector: EditQuestion.selectors.elQuestionAnswerTitleNewInput,
9908 callBack: this.addQuestionAnswer.name,
9909 class: this,
9910 checkIsEventEnter: true
9911 }]);
9912
9913 // Event change
9914 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('change', [{
9915 selector: EditQuestion.selectors.elAutoSaveAnswer,
9916 callBack: this.autoUpdateAnswer.name,
9917 class: this
9918 }]);
9919
9920 // TinyMCE events
9921 this.eventEditorTinymce();
9922 }
9923
9924 // Run async to re-init all TinyMCE editors, because it slow if have many editors
9925 async initTinyMCE() {
9926 const elTextareas = document.querySelectorAll('.lp-editor-tinymce');
9927 elTextareas.forEach(elTextarea => {
9928 const idTextarea = elTextarea.id;
9929 this.reInitTinymce(idTextarea);
9930 });
9931 }
9932 reInitTinymce(id) {
9933 if (!window.tinymce || !id) {
9934 return;
9935 }
9936 const elTextarea = document.getElementById(id);
9937 if (!elTextarea) {
9938 return;
9939 }
9940 this.reInitQuicktags(id);
9941 const editor = window.tinymce.get(id);
9942 const editorContainer = editor?.getContainer?.();
9943 const isEditorAttached = editor && (editor.targetElm === elTextarea || editor.getElement?.() === elTextarea || editorContainer?.contains(elTextarea));
9944 if (isEditorAttached) {
9945 this.setDefaultEditorTab(id);
9946 return;
9947 }
9948 window.tinymce.execCommand('mceRemoveEditor', true, id);
9949 window.tinymce.execCommand('mceAddEditor', true, id);
9950 this.setDefaultEditorTab(id);
9951 }
9952 reInitQuicktags(id) {
9953 const toolbar = document.getElementById(`qt_${id}_toolbar`);
9954 if (!toolbar || toolbar.children.length || !window.quicktags) {
9955 return;
9956 }
9957 const settings = window.tinyMCEPreInit?.qtInit?.[id] || {
9958 id
9959 };
9960 window.quicktags(settings);
9961 if (window.QTags?._buttonsInit) {
9962 window.QTags._buttonsInit();
9963 }
9964 }
9965 setDefaultEditorTab(id) {
9966 const wrapEditor = document.getElementById(`wp-${id}-wrap`);
9967 if (!wrapEditor) {
9968 return;
9969 }
9970 if (wrapEditor.classList.contains('html-active') && window.switchEditors?.go) {
9971 window.switchEditors.go(id, 'tmce');
9972 }
9973 wrapEditor.classList.add('tmce-active');
9974 wrapEditor.classList.remove('html-active');
9975 const visualTab = document.getElementById(`${id}-tmce`);
9976 const codeTab = document.getElementById(`${id}-html`);
9977 visualTab?.setAttribute('aria-pressed', 'true');
9978 codeTab?.setAttribute('aria-pressed', 'false');
9979 }
9980
9981 // Events for TinyMCE editor
9982 eventEditorTinymce() {
9983 window.tinymce.on('AddEditor', eEditor => {
9984 const id = eEditor.editor.id;
9985 const editor = window.tinymce.get(id);
9986 if (!editor) {
9987 return;
9988 }
9989 if (id === 'content') {
9990 return;
9991 }
9992 this.setDefaultEditorTab(id);
9993 const elTextarea = document.getElementById(id);
9994 if (!elTextarea) {
9995 return;
9996 }
9997 const elQuestionEditMain = elTextarea.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
9998
9999 // Skip if not in question edit context
10000 if (!elQuestionEditMain) {
10001 return;
10002 }
10003 const questionId = elQuestionEditMain.dataset.questionId;
10004 editor.settings.force_p_newlines = false;
10005 editor.settings.forced_root_block = '';
10006 editor.settings.force_br_newlines = true;
10007
10008 // Config use absolute url
10009 editor.settings.relative_urls = false;
10010 editor.settings.remove_script_host = false;
10011 editor.settings.convert_urls = true;
10012 editor.settings.document_base_url = lpData.site_url;
10013 // End config use absolute url
10014
10015 // Events focus in TinyMCE editor
10016 editor.on('change keyup', e => {
10017 // Auto save if it has class lp-auto-save
10018 elTextarea.value = editor.getContent();
10019 this.autoUpdateQuestion({
10020 e,
10021 target: elTextarea
10022 });
10023 });
10024 editor.on('blur', e => {
10025 //console.log( 'Editor blurred:', e.target.id );
10026 });
10027 editor.on('focusin', e => {});
10028 editor.on('init', () => {
10029 // Add style
10030 editor.dom.addStyle(`
10031 body {
10032 line-height: 2.2 !important;
10033 }
10034 .${EditQuestion.selectors.elQuestionFibInput} {
10035 border: 1px dashed rebeccapurple;
10036 padding: 5px;
10037 }
10038 `);
10039 });
10040 editor.on('setcontent', e => {
10041 const uniquid = this.randomString();
10042 const elementg = editor.dom.select(`.${EditQuestion.selectors.elQuestionFibInput}[data-id="${uniquid}"]`);
10043 if (elementg[0]) {
10044 elementg[0].focus();
10045 }
10046 editor.dom.bind(elementg[0], 'input', e => {
10047 //console.log( 'Input changed:', e.target.value );
10048 });
10049 });
10050 editor.on('selectionchange', e => {
10051 fibSelection = editor.selection;
10052
10053 // Check selection is blank, check empty blank content
10054 if (fibSelection.getNode().classList.contains(`${EditQuestion.selectors.elQuestionFibInput}`)) {
10055 const blankId = fibSelection.getNode().dataset.id;
10056 const textBlank = fibSelection.getNode().textContent.trim();
10057 if (textBlank.length === 0) {
10058 const editorId = editor.id;
10059 const questionId = editorId.replace(`${EditQuestion.selectors.elQuestionFibInput}-`, '');
10060 const elQuestionEditMain = document.querySelector(`${EditQuestion.selectors.elQuestionEditMain}[data-question-id="${questionId}"]`);
10061 const elQuestionBlankOptions = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elFibBlankOptions}`);
10062 const elFibBlankOptionItem = elQuestionBlankOptions.querySelector(`${EditQuestion.selectors.elFibBlankOptionItem}[data-id="${blankId}"]`);
10063 if (elFibBlankOptionItem) {
10064 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elFibBlankOptionItem, 0);
10065 }
10066 } else {
10067 const elTextarea = document.getElementById(id);
10068 const elAnswersConfig = elTextarea.closest(`${EditQuestion.selectors.elAnswersConfig}`);
10069 const elFibBlankOptionItem = elAnswersConfig.querySelector(`${EditQuestion.selectors.elFibBlankOptionItem}[data-id="${blankId}"]`);
10070 if (elFibBlankOptionItem) {
10071 const elFibOptionTitleInput = elFibBlankOptionItem.querySelector(`${EditQuestion.selectors.elFibOptionTitleInput}`);
10072 if (elFibOptionTitleInput) {
10073 elFibOptionTitleInput.value = textBlank;
10074 }
10075 }
10076 }
10077 }
10078 });
10079 editor.on('Undo', e => {
10080 const contentUndo = editor.getContent();
10081 const selection = editor.selection;
10082 const nodeUndo = selection.getNode();
10083 if (nodeUndo.classList.contains(`${EditQuestion.selectors.elQuestionFibInput}`)) {
10084 const blankId = nodeUndo.dataset.id;
10085 const elFibBlankOptionItem = document.querySelector(`${EditQuestion.selectors.elFibBlankOptionItem}[data-id="${blankId}"]`);
10086 if (elFibBlankOptionItem) {
10087 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elFibBlankOptionItem, 1);
10088 }
10089 }
10090 });
10091 editor.on('Redo', e => {});
10092 });
10093 }
10094 autoUpdateQuestion(args) {
10095 let {
10096 e,
10097 target,
10098 key,
10099 value
10100 } = args;
10101 const elAutoSave = target.closest(`${EditQuestion.selectors.elAutoSaveQuestion}`);
10102 if (!elAutoSave) {
10103 return;
10104 }
10105 const elQuestionEditMain = elAutoSave.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10106 const questionId = elQuestionEditMain.dataset.questionId;
10107 clearTimeout(timeoutAutoUpdateQuestion);
10108 timeoutAutoUpdateQuestion = setTimeout(() => {
10109 // Call ajax to update question description
10110 const callBack = {
10111 success: response => {
10112 const {
10113 message,
10114 status
10115 } = response;
10116 if (status === 'success') {
10117 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
10118 } else {
10119 throw `Error: ${message}`;
10120 }
10121 },
10122 error: error => {
10123 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
10124 },
10125 completed: () => {}
10126 };
10127 const dataSend = {
10128 action: 'update_question',
10129 question_id: questionId,
10130 args: {
10131 id_url: idUrlHandle
10132 }
10133 };
10134 if (undefined === key) {
10135 key = elAutoSave.dataset.keyAutoSave;
10136 if (!key) {
10137 if (!elAutoSave.classList.contains('lp-editor-tinymce')) {
10138 return;
10139 }
10140 const textAreaId = elAutoSave.id;
10141 key = textAreaId.replace(/lp-/g, '').replace(`-${questionId}`, '').replace(/-/g, '_');
10142 if (!key) {
10143 return;
10144 }
10145 }
10146 value = elAutoSave.value;
10147 }
10148 dataSend[key] = value;
10149 window.lpAJAXG.fetchAJAX(dataSend, callBack);
10150 }, 700);
10151 }
10152 // Create question type
10153 createQuestionType(args) {
10154 const {
10155 e,
10156 target
10157 } = args;
10158 const elBtnQuestionCreateType = target.closest(`${EditQuestion.selectors.elBtnQuestionCreateType}`);
10159 if (!elBtnQuestionCreateType) {
10160 return;
10161 }
10162 const elQuestionEditMain = elBtnQuestionCreateType.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10163 if (!elQuestionEditMain) {
10164 return;
10165 }
10166 const questionId = elQuestionEditMain.dataset.questionId;
10167 const elQuestionTypeNew = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elQuestionTypeNew}`);
10168 if (!elQuestionTypeNew) {
10169 return;
10170 }
10171 const questionType = elQuestionTypeNew.value.trim();
10172 if (!questionType) {
10173 const message = elQuestionTypeNew.dataset.messEmptyType;
10174 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, 'error');
10175 return;
10176 }
10177
10178 // Call ajax to create new question type
10179 const callBack = {
10180 success: response => {
10181 const {
10182 message,
10183 status,
10184 data
10185 } = response;
10186 if (status === 'success') {
10187 const {
10188 html_option_answers
10189 } = data;
10190 const elAnswersConfig = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elAnswersConfig}`);
10191 elAnswersConfig.outerHTML = html_option_answers;
10192 this.initTinyMCE();
10193 this.sortAbleQuestionAnswer(elQuestionEditMain);
10194 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
10195 } else {
10196 throw `Error: ${message}`;
10197 }
10198 },
10199 error: error => {
10200 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
10201 },
10202 completed: () => {}
10203 };
10204 const dataSend = {
10205 action: 'update_question',
10206 question_id: questionId,
10207 question_type: questionType,
10208 args: {
10209 id_url: idUrlHandle
10210 }
10211 };
10212 window.lpAJAXG.fetchAJAX(dataSend, callBack);
10213 }
10214 addQuestionAnswer(args) {
10215 const {
10216 e,
10217 target
10218 } = args;
10219 const elQuestionAnswerItemAddNew = target.closest(`${EditQuestion.selectors.elQuestionAnswerItemAddNew}`);
10220 if (!elQuestionAnswerItemAddNew) {
10221 return;
10222 }
10223 e.preventDefault();
10224 const elQuestionAnswerTitleNewInput = elQuestionAnswerItemAddNew.querySelector(`${EditQuestion.selectors.elQuestionAnswerTitleNewInput}`);
10225 if (!elQuestionAnswerTitleNewInput.value.trim()) {
10226 const message = elQuestionAnswerTitleNewInput.dataset.messEmptyTitle;
10227 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, 'error');
10228 return;
10229 }
10230 const elQuestionEditMain = target.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10231 const elQuestionAnswerClone = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elQuestionAnswerItem}.clone`);
10232 const elQuestionAnswerNew = elQuestionAnswerClone.cloneNode(true);
10233 const elQuestionAnswerTitleInputNew = elQuestionAnswerNew.querySelector(`${EditQuestion.selectors.elQuestionAnswerTitleInput}`);
10234 elQuestionAnswerNew.classList.remove('clone');
10235 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elQuestionAnswerNew, 1);
10236 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elQuestionAnswerNew, 1);
10237 elQuestionAnswerClone.insertAdjacentElement('beforebegin', elQuestionAnswerNew);
10238 const answerTitle = elQuestionAnswerTitleNewInput.value.trim();
10239 elQuestionAnswerTitleInputNew.value = answerTitle;
10240 elQuestionAnswerTitleNewInput.value = '';
10241 const questionId = elQuestionEditMain.dataset.questionId;
10242
10243 // Call ajax to add new question answer
10244 const callBack = {
10245 success: response => {
10246 const {
10247 message,
10248 status,
10249 data
10250 } = response;
10251 if (status === 'success') {
10252 const {
10253 question_answer
10254 } = data;
10255 elQuestionAnswerNew.dataset.answerId = question_answer.question_answer_id;
10256 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elQuestionAnswerNew, 0);
10257
10258 // Set data lp-answers-config
10259 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10260 dataAnswers.push(question_answer);
10261 this.setDataAnswersConfig(elQuestionEditMain, dataAnswers);
10262 } else {
10263 throw `Error: ${message}`;
10264 }
10265 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
10266 },
10267 error: error => {
10268 elQuestionAnswerNew.remove();
10269 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
10270 },
10271 completed: () => {}
10272 };
10273 const dataSend = {
10274 action: 'add_question_answer',
10275 question_id: questionId,
10276 answer_title: answerTitle,
10277 args: {
10278 id_url: idUrlHandle
10279 }
10280 };
10281 window.lpAJAXG.fetchAJAX(dataSend, callBack);
10282 }
10283
10284 // Check to enable or disable add new question button
10285 checkCanAddAnswer(args) {
10286 const {
10287 e,
10288 target
10289 } = args;
10290 const elTrigger = target.closest(EditQuestion.selectors.elQuestionAnswerTitleNewInput);
10291 if (!elTrigger) {
10292 return;
10293 }
10294 const elQuestionAnswerItemAddNew = elTrigger.closest(`${EditQuestion.selectors.elQuestionAnswerItemAddNew}`);
10295 if (!elQuestionAnswerItemAddNew) {
10296 return;
10297 }
10298 const elBtnAddAnswer = elQuestionAnswerItemAddNew.querySelector(`${EditQuestion.selectors.elBtnAddAnswer}`);
10299 if (!elBtnAddAnswer) {
10300 return;
10301 }
10302 const titleValue = elTrigger.value.trim();
10303 if (titleValue) {
10304 elBtnAddAnswer.classList.add('active');
10305 } else {
10306 elBtnAddAnswer.classList.remove('active');
10307 }
10308 }
10309
10310 // Auto update question answer
10311 autoUpdateAnswer(args) {
10312 const {
10313 e,
10314 target
10315 } = args;
10316 const elAutoSaveAnswer = target.closest(`${EditQuestion.selectors.elAutoSaveAnswer}`);
10317 if (!elAutoSaveAnswer) {
10318 return;
10319 }
10320 const elQuestionAnswerItem = elAutoSaveAnswer.closest(`${EditQuestion.selectors.elQuestionAnswerItem}`);
10321 clearTimeout(timeoutAutoUpdateAnswer);
10322 timeoutAutoUpdateAnswer = setTimeout(() => {
10323 const elQuestionEditMain = elAutoSaveAnswer.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10324 const questionId = elQuestionEditMain.dataset.questionId;
10325 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10326 const elAnswersConfig = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elAnswersConfig}`);
10327
10328 // For both radio and checkbox.
10329 const dataAnswersOld = structuredClone(dataAnswers);
10330
10331 // Get position of answers
10332 const elQuestionAnswerItems = elAnswersConfig.querySelectorAll(`${EditQuestion.selectors.elQuestionAnswerItem}:not(.clone)`);
10333 const answersPosition = {};
10334 elQuestionAnswerItems.forEach((elQuestionAnswerItem, index) => {
10335 answersPosition[elQuestionAnswerItem.dataset.answerId] = index + 1; // Start from 1
10336 });
10337
10338 //console.log( 'answersPosition', answersPosition );
10339
10340 dataAnswers.map((answer, k) => {
10341 const elQuestionAnswerItem = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elQuestionAnswerItem}[data-answer-id="${answer.question_answer_id}"]`);
10342 const elInputAnswerSetTrue = elQuestionAnswerItem.querySelector(`${EditQuestion.selectors.elInputAnswerSetTrue}`);
10343 const elInputAnswerTitle = elQuestionAnswerItem.querySelector(`${EditQuestion.selectors.elQuestionAnswerTitleInput}`);
10344
10345 // Set title
10346 if (elInputAnswerTitle) {
10347 answer.title = elInputAnswerTitle.value.trim();
10348 }
10349
10350 // Set true answer
10351 if (elInputAnswerSetTrue) {
10352 if (elInputAnswerSetTrue.checked) {
10353 answer.is_true = 'yes';
10354 } else {
10355 answer.is_true = '';
10356 }
10357 }
10358
10359 // Set position
10360 if (answersPosition[answer.question_answer_id]) {
10361 answer.order = answersPosition[answer.question_answer_id];
10362 }
10363 return answer;
10364 });
10365
10366 //console.log( dataAnswers );
10367
10368 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elQuestionAnswerItem, 1);
10369
10370 // Call ajax to update answers config
10371 const callBack = {
10372 success: response => {
10373 const {
10374 message,
10375 status
10376 } = response;
10377 if (status === 'success') {} else {
10378 throw `Error: ${message}`;
10379 }
10380 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
10381 },
10382 error: error => {
10383 // rollback changes to old data
10384 dataAnswersOld.forEach(answer => {
10385 const elAnswerItem = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elQuestionAnswerItem}[data-answer-id="${answer.question_answer_id}"]`);
10386 const inputAnswerSetTrue = elAnswerItem.querySelector(`${EditQuestion.selectors.elInputAnswerSetTrue}`);
10387 if (answer.is_true === 'yes') {
10388 inputAnswerSetTrue.checked = true;
10389 }
10390 return answer;
10391 });
10392 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
10393 },
10394 completed: () => {
10395 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elQuestionAnswerItem, 0);
10396 }
10397 };
10398 const dataSend = {
10399 action: 'update_question_answers_config',
10400 question_id: questionId,
10401 answers: dataAnswers,
10402 args: {
10403 id_url: idUrlHandle
10404 }
10405 };
10406 window.lpAJAXG.fetchAJAX(dataSend, callBack);
10407 }, 700);
10408 }
10409
10410 // Sortable answers's question
10411 sortAbleQuestionAnswer(elQuestionEditMain) {
10412 let isUpdateSectionPosition = 0;
10413 let timeout;
10414 const elQuestionAnswers = elQuestionEditMain.querySelectorAll(`${EditQuestion.selectors.elAnswersConfig}`);
10415 elQuestionAnswers.forEach(elAnswersConfig => {
10416 new sortablejs__WEBPACK_IMPORTED_MODULE_3__["default"](elAnswersConfig, {
10417 handle: '.drag',
10418 animation: 150,
10419 onEnd: evt => {
10420 const elQuestionAnswerItem = evt.item;
10421 if (!isUpdateSectionPosition) {
10422 // No change in section position, do nothing
10423 return;
10424 }
10425 clearTimeout(timeout);
10426 timeout = setTimeout(() => {
10427 const elAutoSaveAnswer = elQuestionAnswerItem.querySelector(`${EditQuestion.selectors.elAutoSaveAnswer}`);
10428 this.autoUpdateAnswer({
10429 e: null,
10430 target: elAutoSaveAnswer
10431 });
10432 }, 1000);
10433 },
10434 onMove: evt => {
10435 clearTimeout(timeout);
10436 },
10437 onUpdate: evt => {
10438 isUpdateSectionPosition = 1;
10439 }
10440 });
10441 });
10442 }
10443
10444 // Delete question answer
10445 deleteQuestionAnswer(args) {
10446 const {
10447 e,
10448 target
10449 } = args;
10450 const elBtnDeleteAnswer = target.closest(`${EditQuestion.selectors.elBtnDeleteAnswer}`);
10451 if (!elBtnDeleteAnswer) {
10452 return;
10453 }
10454 const elQuestionAnswerItem = elBtnDeleteAnswer.closest(`${EditQuestion.selectors.elQuestionAnswerItem}`);
10455 if (!elQuestionAnswerItem) {
10456 return;
10457 }
10458 const elQuestionEditMain = elBtnDeleteAnswer.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10459 const questionId = elQuestionEditMain.dataset.questionId;
10460 const questionAnswerId = elQuestionAnswerItem.dataset.answerId;
10461 if (!questionId || !questionAnswerId) {
10462 return;
10463 }
10464 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
10465 title: elBtnDeleteAnswer.dataset.title || 'Are you sure?',
10466 text: elBtnDeleteAnswer.dataset.content || 'Do you want to delete this answer?',
10467 icon: 'warning',
10468 showCloseButton: true,
10469 showCancelButton: true,
10470 cancelButtonText: lpData.i18n.cancel,
10471 confirmButtonText: lpData.i18n.yes,
10472 reverseButtons: true
10473 }).then(result => {
10474 if (result.isConfirmed) {
10475 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elQuestionAnswerItem, 1);
10476
10477 // Call ajax to delete item from section
10478 const callBack = {
10479 success: response => {
10480 const {
10481 message,
10482 status
10483 } = response;
10484 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
10485 if (status === 'success') {
10486 const elQuestionAnswerId = parseInt(elQuestionAnswerItem.dataset.answerId);
10487 elQuestionAnswerItem.remove();
10488 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10489 if (dataAnswers) {
10490 const updatedAnswers = dataAnswers.filter(answer => parseInt(answer.question_answer_id) !== elQuestionAnswerId);
10491 this.setDataAnswersConfig(elQuestionEditMain, updatedAnswers);
10492 }
10493 }
10494 },
10495 error: error => {
10496 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
10497 },
10498 completed: () => {
10499 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elQuestionAnswerItem, 0);
10500 }
10501 };
10502 const dataSend = {
10503 action: 'delete_question_answer',
10504 question_id: questionId,
10505 question_answer_id: questionAnswerId,
10506 args: {
10507 id_url: idUrlHandle
10508 }
10509 };
10510 window.lpAJAXG.fetchAJAX(dataSend, callBack);
10511 }
10512 });
10513 }
10514
10515 // Get data answers config
10516 getDataAnswersConfig(elQuestionEditMain) {
10517 const elAnswersConfig = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elAnswersConfig}`);
10518 if (!elAnswersConfig) {
10519 return null;
10520 }
10521 let dataAnswers = elAnswersConfig.dataset.answers || '[]';
10522 try {
10523 dataAnswers = JSON.parse(dataAnswers);
10524 } catch (e) {
10525 dataAnswers = [];
10526 }
10527 if (!dataAnswers.meta_data) {
10528 dataAnswers.meta_data = {};
10529 }
10530 return dataAnswers;
10531 }
10532
10533 // Set data answers config
10534 setDataAnswersConfig(elQuestionEditMain, dataAnswers) {
10535 const elAnswersConfig = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elAnswersConfig}`);
10536 if (!elAnswersConfig) {
10537 return;
10538 }
10539 if (!dataAnswers || typeof dataAnswers !== 'object') {
10540 dataAnswers = {};
10541 }
10542 elAnswersConfig.dataset.answers = JSON.stringify(dataAnswers);
10543 }
10544
10545 /***** Fill in the blank question type *****/
10546 // For FIB question type
10547 fibInsertBlank = args => {
10548 const {
10549 e,
10550 target
10551 } = args;
10552 const elBtnFibInsertBlank = target.closest(EditQuestion.selectors.elBtnFibInsertBlank);
10553 if (!elBtnFibInsertBlank) {
10554 return;
10555 }
10556 const textPlaceholder = elBtnFibInsertBlank.dataset.defaultText;
10557 const elQuestionEditMain = elBtnFibInsertBlank.closest(EditQuestion.selectors.elQuestionEditMain);
10558 const questionId = elQuestionEditMain.dataset.questionId;
10559 const messErrInserted = elBtnFibInsertBlank.dataset.messInserted;
10560 const messErrRequireSelectText = elBtnFibInsertBlank.dataset.messRequireSelectText;
10561 const idEditor = `${EditQuestion.selectors.elQuestionFibInput}-${questionId}`;
10562 const uniquid = this.randomString();
10563 let selectedText;
10564 if (fibSelection) {
10565 const elNode = fibSelection.getNode();
10566 if (!elNode) {
10567 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show('Event insert blank has error, please try again', 'error');
10568 return;
10569 }
10570 const findParent = elNode.closest(`body[data-id="${idEditor}"]`);
10571 if (!findParent) {
10572 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(messErrRequireSelectText, 'error');
10573 return;
10574 }
10575 if (elNode.classList.contains(`${EditQuestion.selectors.elQuestionFibInput}`)) {
10576 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(messErrInserted, 'error');
10577 return;
10578 }
10579 selectedText = fibSelection.getContent();
10580 if (selectedText.length === 0) {
10581 selectedText = textPlaceholder;
10582 }
10583 const elInputNew = `<span class="${EditQuestion.selectors.elQuestionFibInput}" data-id="${uniquid}">${selectedText}</span>`;
10584 fibSelection.setContent(elInputNew);
10585 } else {
10586 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(messErrRequireSelectText, 'error');
10587 return;
10588 }
10589 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10590 dataAnswers.meta_data = dataAnswers.meta_data || {};
10591 // Convert array to object
10592 if (Object.keys(dataAnswers.meta_data).length === 0) {
10593 dataAnswers.meta_data = {};
10594 }
10595 dataAnswers.meta_data[uniquid] = {
10596 id: uniquid,
10597 match_case: 0,
10598 comparison: 'equal',
10599 fill: selectedText,
10600 index: 1,
10601 open: false
10602 };
10603 this.setDataAnswersConfig(elQuestionEditMain, dataAnswers);
10604
10605 // Clone blank options
10606 const elFibBlankOptions = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elFibBlankOptions}`);
10607 const elFibBlankOptionItemClone = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elFibBlankOptionItemClone}`);
10608 const elFibBlankOptionItemNew = elFibBlankOptionItemClone.cloneNode(true);
10609 const countOptions = elFibBlankOptions.querySelectorAll(`${EditQuestion.selectors.elFibBlankOptionItem}:not(.clone)`).length;
10610 const elFibBlankOptionIndex = elFibBlankOptionItemNew.querySelector(`${EditQuestion.selectors.elFibBlankOptionIndex}`);
10611 const elFibOptionTitleInput = elFibBlankOptionItemNew.querySelector(`${EditQuestion.selectors.elFibOptionTitleInput}`);
10612 const elFibOptionMatchCaseInput = elFibBlankOptionItemNew.querySelector(`${EditQuestion.selectors.elFibOptionMatchCaseInput}`);
10613 const elFibOptionComparisonInput = elFibBlankOptionItemNew.querySelectorAll(`${EditQuestion.selectors.elFibOptionComparisonInput}`);
10614 elFibBlankOptionItemNew.dataset.id = uniquid;
10615 elFibOptionTitleInput.name = `${EditQuestion.selectors.elFibOptionTitleInput}-${uniquid}`;
10616 elFibOptionTitleInput.value = this.decodeHtml(selectedText);
10617 elFibBlankOptionIndex.textContent = countOptions + 1 + '.';
10618 elFibOptionMatchCaseInput.name = `${EditQuestion.selectors.elFibOptionMatchCaseInput}-${uniquid}`.replace(/\./g, '');
10619 elFibOptionComparisonInput.forEach(elInput => {
10620 elInput.name = `${EditQuestion.selectors.elFibOptionComparisonInput}-${uniquid}`.replace(/\./g, '');
10621 if (elInput.value === 'equal') {
10622 elInput.checked = true;
10623 }
10624 });
10625 elFibBlankOptionItemClone.insertAdjacentElement('beforebegin', elFibBlankOptionItemNew);
10626 elFibBlankOptionItemNew.classList.remove('clone');
10627 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elFibBlankOptionItemNew, 1);
10628 // End clone blank options
10629
10630 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10631 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibInsertBlank, 1);
10632 this.fibSaveContent({
10633 e: null,
10634 target: elBtnFibSaveContent,
10635 callBackCompleted: () => {
10636 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibInsertBlank, 0);
10637 }
10638 });
10639 };
10640
10641 // Delete all blanks
10642 fibDeleteAllBlanks(args) {
10643 const {
10644 e,
10645 target
10646 } = args;
10647 const elBtnFibDeleteAllBlanks = target.closest(`${EditQuestion.selectors.elBtnFibDeleteAllBlanks}`);
10648 if (!elBtnFibDeleteAllBlanks) {
10649 return;
10650 }
10651 const elQuestionEditMain = elBtnFibDeleteAllBlanks.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10652 if (!elQuestionEditMain) {
10653 return;
10654 }
10655 const questionId = elQuestionEditMain.dataset.questionId;
10656 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10657 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
10658 title: elBtnFibDeleteAllBlanks.dataset.title,
10659 text: elBtnFibDeleteAllBlanks.dataset.content,
10660 icon: 'warning',
10661 showCloseButton: true,
10662 showCancelButton: true,
10663 cancelButtonText: lpData.i18n.cancel,
10664 confirmButtonText: lpData.i18n.yes,
10665 reverseButtons: true
10666 }).then(result => {
10667 if (result.isConfirmed) {
10668 const editor = window.tinymce.get(`${EditQuestion.selectors.elQuestionFibInput}-${questionId}`);
10669 const elBlanks = editor.dom.select(`.${EditQuestion.selectors.elQuestionFibInput}`);
10670 elBlanks.forEach(elBlank => {
10671 editor.dom.remove(elBlank, true);
10672 });
10673 dataAnswers.meta_data = {};
10674 this.setDataAnswersConfig(elQuestionEditMain, dataAnswers);
10675 const elFibBlankOptions = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elFibBlankOptions}`);
10676 const elFibBlankOptionItems = elFibBlankOptions.querySelectorAll(`${EditQuestion.selectors.elFibBlankOptionItem}:not(.clone)`);
10677 elFibBlankOptionItems.forEach(elFibBlankOptionItem => {
10678 elFibBlankOptionItem.remove();
10679 });
10680 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10681 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibDeleteAllBlanks, 1);
10682 this.fibSaveContent({
10683 e: null,
10684 target: elBtnFibSaveContent,
10685 callBackCompleted: () => {
10686 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibDeleteAllBlanks, 0);
10687 }
10688 });
10689 }
10690 });
10691 }
10692 // Clear content FIB question
10693 fibClearContent(args) {
10694 const {
10695 e,
10696 target
10697 } = args;
10698 const elBtnFibClearAllContent = target.closest(`${EditQuestion.selectors.elBtnFibClearAllContent}`);
10699 if (!elBtnFibClearAllContent) {
10700 return;
10701 }
10702 const elQuestionEditMain = elBtnFibClearAllContent.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10703 if (!elQuestionEditMain) {
10704 return;
10705 }
10706 const questionId = elQuestionEditMain.dataset.questionId;
10707 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10708 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
10709 title: elBtnFibClearAllContent.dataset.title,
10710 text: elBtnFibClearAllContent.dataset.content,
10711 icon: 'warning',
10712 showCloseButton: true,
10713 showCancelButton: true,
10714 cancelButtonText: lpData.i18n.cancel,
10715 confirmButtonText: lpData.i18n.yes,
10716 reverseButtons: true
10717 }).then(result => {
10718 if (result.isConfirmed) {
10719 const editor = window.tinymce.get(`lp-question-fib-input-${questionId}`);
10720 editor.setContent('');
10721 dataAnswers.meta_data = {};
10722 this.setDataAnswersConfig(elQuestionEditMain, dataAnswers);
10723 const elFibBlankOptions = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elFibBlankOptions}`);
10724 const elFibBlankOptionItems = elFibBlankOptions.querySelectorAll(`${EditQuestion.selectors.elFibBlankOptionItem}:not(.clone)`);
10725 elFibBlankOptionItems.forEach(elFibBlankOptionItem => {
10726 elFibBlankOptionItem.remove();
10727 });
10728 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10729 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibClearAllContent, 1);
10730 this.fibSaveContent({
10731 e: null,
10732 target: elBtnFibSaveContent,
10733 callBackCompleted: () => {
10734 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibClearAllContent, 0);
10735 }
10736 });
10737 }
10738 });
10739 }
10740
10741 // Remove blank
10742 fibDeleteBlank(args) {
10743 const {
10744 e,
10745 target
10746 } = args;
10747 const elBtnFibOptionDelete = target.closest(`${EditQuestion.selectors.elBtnFibOptionDelete}`);
10748 if (!elBtnFibOptionDelete) {
10749 return;
10750 }
10751 const elQuestionEditMain = elBtnFibOptionDelete.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10752 if (!elQuestionEditMain) {
10753 return;
10754 }
10755 const questionId = elQuestionEditMain.dataset.questionId;
10756 const elAnswersConfig = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elAnswersConfig}`);
10757 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10758 const elFibBlankOptionItem = elBtnFibOptionDelete.closest(`${EditQuestion.selectors.elFibBlankOptionItem}`);
10759 const blankId = elFibBlankOptionItem.dataset.id;
10760 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
10761 title: elBtnFibOptionDelete.dataset.title,
10762 text: elBtnFibOptionDelete.dataset.content,
10763 icon: 'warning',
10764 showCloseButton: true,
10765 showCancelButton: true,
10766 cancelButtonText: lpData.i18n.cancel,
10767 confirmButtonText: lpData.i18n.yes,
10768 reverseButtons: true
10769 }).then(result => {
10770 if (result.isConfirmed) {
10771 // Find span with id on editor and remove it
10772 const editor = window.tinymce.get(`${EditQuestion.selectors.elQuestionFibInput}-${questionId}`);
10773 const elBlank = editor.dom.select(`.${EditQuestion.selectors.elQuestionFibInput}[data-id="${blankId}"]`);
10774 if (elBlank[0]) {
10775 // Remove tag html but keep content
10776 editor.dom.remove(elBlank[0], true);
10777 }
10778 elFibBlankOptionItem.remove();
10779 dataAnswers.meta_data = dataAnswers.meta_data || {};
10780 if (dataAnswers.meta_data[blankId]) {
10781 delete dataAnswers.meta_data[blankId];
10782 }
10783 this.setDataAnswersConfig(elQuestionEditMain, dataAnswers);
10784 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10785 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elFibBlankOptionItem, 1);
10786 this.fibSaveContent({
10787 e: null,
10788 target: elBtnFibSaveContent,
10789 callBackCompleted: () => {
10790 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elFibBlankOptionItem, 0);
10791 }
10792 });
10793 }
10794 });
10795 }
10796
10797 // Change title of blank option
10798 fibOptionTitleInputChange(args) {
10799 const {
10800 e,
10801 target
10802 } = args;
10803 const elFibOptionTitleInput = target.closest(`${EditQuestion.selectors.elFibOptionTitleInput}`);
10804 if (!elFibOptionTitleInput) {
10805 return;
10806 }
10807 const elQuestionFibOptionItem = elFibOptionTitleInput.closest(`${EditQuestion.selectors.elFibBlankOptionItem}`);
10808 if (!elQuestionFibOptionItem) {
10809 return;
10810 }
10811 const elQuestionEditMain = elFibOptionTitleInput.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10812 if (!elQuestionEditMain) {
10813 return;
10814 }
10815 const value = elFibOptionTitleInput.value.trim();
10816 const blankId = elQuestionFibOptionItem.dataset.id;
10817 const questionId = elQuestionEditMain.dataset.questionId;
10818 const editor = window.tinymce.get(`lp-question-fib-input-${questionId}`);
10819 const elBlank = editor.dom.select(`.lp-question-fib-input[data-id="${blankId}"]`);
10820 if (elBlank[0]) {
10821 // Update content of blank
10822 elBlank[0].textContent = value;
10823 }
10824 clearTimeout(timeoutAutoUpdateFib);
10825 timeoutAutoUpdateFib = setTimeout(() => {
10826 // Call ajax to update question description
10827 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10828 this.fibSaveContent({
10829 e: null,
10830 target: elBtnFibSaveContent
10831 });
10832 }, 700);
10833 }
10834
10835 // Save content FIB question
10836 fibSaveContent(args) {
10837 const {
10838 e,
10839 target,
10840 callBackCompleted = null
10841 } = args;
10842 const elBtnFibSaveContent = target.closest(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10843 if (!elBtnFibSaveContent) {
10844 return;
10845 }
10846 const elQuestionEditMain = elBtnFibSaveContent.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10847 const questionId = elQuestionEditMain.dataset.questionId;
10848 const dataAnswers = this.getDataAnswersConfig(elQuestionEditMain);
10849 if (!dataAnswers) {
10850 return;
10851 }
10852 const editor = window.tinymce.get(`${EditQuestion.selectors.elQuestionFibInput}-${questionId}`);
10853 dataAnswers.title = editor.getContent();
10854 const elFibBlankOptionItems = elQuestionEditMain.querySelectorAll(`${EditQuestion.selectors.elFibBlankOptionItem}:not(.clone)`);
10855 if (elFibBlankOptionItems) {
10856 elFibBlankOptionItems.forEach(elFibBlankOptionItem => {
10857 const blankId = elFibBlankOptionItem.dataset.id;
10858 const elFibOptionMatchCaseInput = elFibBlankOptionItem.querySelector(`${EditQuestion.selectors.elFibOptionMatchCaseInput}`);
10859 const elFibOptionComparisonInput = elFibBlankOptionItem.querySelector(`${EditQuestion.selectors.elFibOptionComparisonInput}:checked`);
10860 dataAnswers.meta_data[blankId].match_case = elFibOptionMatchCaseInput.checked ? 1 : 0;
10861 dataAnswers.meta_data[blankId].comparison = elFibOptionComparisonInput.value;
10862 });
10863 }
10864
10865 //console.log( 'dataAnswers', dataAnswers );
10866
10867 if (!callBackCompleted) {
10868 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibSaveContent, 1);
10869 }
10870
10871 // Call ajax to update answers config
10872 const callBack = {
10873 success: response => {
10874 const {
10875 message,
10876 status
10877 } = response;
10878 if (status === 'success') {
10879 this.setDataAnswersConfig(elQuestionEditMain, dataAnswers);
10880 } else {
10881 throw `Error: ${message}`;
10882 }
10883 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
10884 },
10885 error: error => {
10886 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
10887 },
10888 completed: () => {
10889 if (callBackCompleted && typeof callBackCompleted === 'function') {
10890 callBackCompleted();
10891 } else {
10892 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(elBtnFibSaveContent, 0);
10893 }
10894 }
10895 };
10896
10897 //console.log( 'dataAnswers', dataAnswers );
10898
10899 const dataSend = {
10900 action: 'update_question_answers_config',
10901 question_id: questionId,
10902 answers: dataAnswers,
10903 args: {
10904 id_url: idUrlHandle
10905 }
10906 };
10907 window.lpAJAXG.fetchAJAX(dataSend, callBack);
10908 }
10909 // Show/hide match case option
10910 fibShowHideMatchCaseOption(args) {
10911 const {
10912 e,
10913 target
10914 } = args;
10915 const elFibOptionMatchCaseInput = target.closest(`${EditQuestion.selectors.elFibOptionMatchCaseInput}`);
10916 if (!elFibOptionMatchCaseInput) {
10917 return;
10918 }
10919 const elQuestionFibOptionDetail = elFibOptionMatchCaseInput.closest(`${EditQuestion.selectors.elQuestionFibOptionDetail}`);
10920 const elFibOptionMatchCaseWrap = elQuestionFibOptionDetail.querySelector(`${EditQuestion.selectors.elFibOptionMatchCaseWrap}`);
10921 if (!elQuestionFibOptionDetail || !elFibOptionMatchCaseWrap) {
10922 return;
10923 }
10924 if (elFibOptionMatchCaseInput.checked) {
10925 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elFibOptionMatchCaseWrap, 1);
10926 } else {
10927 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elFibOptionMatchCaseWrap, 0);
10928 }
10929 const elQuestionEditMain = elFibOptionMatchCaseInput.closest(`${EditQuestion.selectors.elQuestionEditMain}`);
10930 const elBtnFibSaveContent = elQuestionEditMain.querySelector(`${EditQuestion.selectors.elBtnFibSaveContent}`);
10931 elBtnFibSaveContent.click();
10932 }
10933 /***** End Fill in the blank question type *****/
10934
10935 // Generate a random string of specified length, for set unique id
10936 randomString(length = 10) {
10937 const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
10938 let result = '';
10939 for (let i = 0; i < length; i++) {
10940 result += chars.charAt(Math.floor(Math.random() * chars.length));
10941 }
10942 return result;
10943 }
10944 // Decode HTML entities
10945 decodeHtml(html) {
10946 const txt = document.createElement('textarea');
10947 txt.innerHTML = html;
10948 return txt.value;
10949 }
10950 }
10951 const editQuestion = new EditQuestion();
10952 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady(EditQuestion.selectors.elEditQuestionWrap, elEditQuestionWrap => {
10953 const findClass = EditQuestion.selectors.elQuestionEditMain.replace('.', '');
10954 if (!elEditQuestionWrap.classList.contains(findClass)) {
10955 return;
10956 }
10957 editQuestion.init();
10958 });
10959 })();
10960
10961 /******/ })()
10962 ;
10963 //# sourceMappingURL=edit-question.js.map