diff --git a/frontend/js/pages/logs/index.js b/frontend/js/pages/logs/index.js
index d44aa6e..7c882c7 100644
--- a/frontend/js/pages/logs/index.js
+++ b/frontend/js/pages/logs/index.js
@@ -1,3 +1,4 @@
+// Filename: frontend/js/pages/logs/index.js
import { apiFetchJson } from '../../services/api.js';
import LogList from './logList.js';
import CustomSelectV2 from '../../components/customSelectV2.js';
@@ -145,6 +146,7 @@ class LogsPage {
switchToView(viewName) {
if (this.state.currentView === viewName && this.elements.contentContainer.innerHTML !== '') return;
+
if (this.systemLogTerminal) {
this.systemLogTerminal.disconnect();
this.systemLogTerminal = null;
@@ -153,25 +155,22 @@ class LogsPage {
this.fp.destroy();
this.fp = null;
}
-
if (this.themeObserver) {
this.themeObserver.disconnect();
this.themeObserver = null;
}
-
this.state.currentView = viewName;
this.elements.contentContainer.innerHTML = '';
- if (viewName === 'error') {
- this.elements.errorFilters.classList.remove('hidden');
- this.elements.systemControls.classList.add('hidden');
+ const isErrorView = viewName === 'error';
+ this.elements.errorFilters.style.display = isErrorView ? 'flex' : 'none';
+ this.elements.systemControls.style.display = isErrorView ? 'none' : 'flex';
+ if (isErrorView) {
const template = this.elements.errorTemplate.content.cloneNode(true);
this.elements.contentContainer.appendChild(template);
requestAnimationFrame(() => {
this._initErrorLogView();
});
} else if (viewName === 'system') {
- this.elements.errorFilters.classList.add('hidden');
- this.elements.systemControls.classList.remove('hidden');
const template = this.elements.systemTemplate.content.cloneNode(true);
this.elements.contentContainer.appendChild(template);
requestAnimationFrame(() => {
@@ -328,7 +327,7 @@ class LogsPage {
template.className = 'custom-select-panel-template';
template.innerHTML = `
-
+
`;
nativeMonthSelect.classList.add('hidden');
@@ -359,8 +358,14 @@ class LogsPage {
this.elements.selectAllCheckbox.addEventListener('change', (event) => this.handleSelectAllChange(event));
}
if (this.elements.tableBody) {
- this.elements.tableBody.addEventListener('change', (event) => {
- if (event.target.type === 'checkbox') this.handleSelectionChange(event.target);
+ this.elements.tableBody.addEventListener('click', (event) => {
+ const checkbox = event.target.closest('input[type="checkbox"]');
+ const actionButton = event.target.closest('button[data-action]');
+ if (checkbox) {
+ this.handleSelectionChange(checkbox);
+ } else if (actionButton) {
+ this._handleLogRowAction(actionButton);
+ }
});
}
if (this.elements.searchInput) {
@@ -465,6 +470,118 @@ class LogsPage {
deleteSelectedBtn.disabled = !hasSelection;
}
}
+
+ async _handleLogRowAction(button) {
+ const action = button.dataset.action;
+ const row = button.closest('.table-row');
+ const isDarkMode = document.documentElement.classList.contains('dark');
+ if (!row) return;
+ const logId = parseInt(row.dataset.logId, 10);
+ const log = this.state.logs.find(l => l.ID === logId);
+ if (!log) {
+ Swal.fire({ toast: true, position: 'top-end', icon: 'error', title: '找不到日志数据', showConfirmButton: false, timer: 2000 });
+ return;
+ }
+ switch (action) {
+ case 'view-log-details': {
+ const detailsHtml = `
+
+
状态码
${log.StatusCode || 'N/A'}
+
+
模型
${log.ModelName || 'N/A'}
+
+
+
错误消息
+
+ ${log.ErrorMessage ? log.ErrorMessage.replace(/\n/g, '
') : '无错误消息。'}
+
+
+
+ `;
+ Swal.fire({
+ target: '#main-content-wrapper',
+ width: '32rem',
+ backdrop: `rgba(0,0,0,0.5)`,
+ heightAuto: false,
+ customClass: {
+ popup: `swal2-custom-style rounded-xl ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}`,
+ title: 'text-lg font-bold',
+ htmlContainer: 'm-0 text-left',
+ },
+ title: '日志详情',
+ html: detailsHtml,
+ showCloseButton: false,
+ showConfirmButton: false,
+ });
+ break;
+ }
+ case 'copy-api-key': {
+ const key = dataStore.keys.get(log.KeyID);
+ if (key && key.APIKey) {
+ navigator.clipboard.writeText(key.APIKey).then(() => {
+ Swal.fire({ toast: true, position: 'top-end', customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` }, icon: 'success', title: 'API Key 已复制', showConfirmButton: false, timer: 1500 });
+ }).catch(err => {
+ Swal.fire({ toast: true, position: 'top-end', icon: 'error', title: '复制失败', text: err.message, showConfirmButton: false, timer: 2000 });
+ });
+ } else {
+ Swal.fire({ toast: true, position: 'top-end', icon: 'warning', title: '未找到完整的API Key', showConfirmButton: false, timer: 2000 });
+ return;
+ }
+ if (navigator.clipboard && window.isSecureContext) {
+ navigator.clipboard.writeText(key.APIKey).then(() => {
+ Swal.fire({ toast: true, position: 'top-end', icon: 'success', title: 'API Key 已复制', showConfirmButton: false, timer: 1500 });
+ }).catch(err => {
+ Swal.fire({ toast: true, position: 'top-end', icon: 'error', title: '复制失败', text: err.message, showConfirmButton: false, timer: 2000 });
+ });
+ } else {
+ // 如果不可用,则提供明确的错误提示
+ Swal.fire({
+ icon: 'error',
+ title: '复制失败',
+ text: '此功能需要安全连接 (HTTPS) 或在 localhost 环境下使用。',
+ target: '#main-content-wrapper',
+ customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` },
+ });
+ }
+ break;
+ }
+ case 'delete-log': {
+ Swal.fire({
+ width: '20rem',
+ backdrop: `rgba(0,0,0,0.5)`,
+ heightAuto: false,
+ customClass: { popup: `swal2-custom-style ${document.documentElement.classList.contains('dark') ? 'swal2-dark' : ''}` },
+ title: '确认删除',
+ text: `您确定要删除这条日志吗?此操作不可撤销。`,
+ showCancelButton: true,
+ confirmButtonText: '确认删除',
+ cancelButtonText: '取消',
+ reverseButtons: false,
+ confirmButtonColor: '#ef4444',
+ cancelButtonColor: '#6b7280',
+ focusCancel: true,
+ target: '#main-content-wrapper',
+ }).then(async (result) => {
+ if (result.isConfirmed) {
+ try {
+ const url = `/admin/logs?ids=${logId}`;
+ const { success, message } = await apiFetchJson(url, { method: 'DELETE' });
+ if (success) {
+ Swal.fire({ toast: true, position: 'top-end', icon: 'success', title: '删除成功', showConfirmButton: false, timer: 2000, timerProgressBar: true });
+ this.loadAndRenderLogs();
+ } else {
+ throw new Error(message || '删除失败,请稍后重试。');
+ }
+ } catch (error) {
+ Swal.fire({ icon: 'error', title: '操作失败', text: error.message, target: '#main-content-wrapper' });
+ }
+ }
+ });
+ break;
+ }
+ }
+ }
+
changePageSize(newSize) {
this.state.filters.page_size = newSize;
this.state.filters.page = 1;
@@ -520,23 +637,33 @@ class LogsPage {
finalParams[key] = filters[key];
}
});
- const translatedErrorCodes = new Set();
- const translatedStatusCodes = new Set(filters.status_codes);
+ // --- [MODIFIED] START: Combine all error-related filters into a single parameter for OR logic ---
+ const allErrorCodes = new Set();
+ const allStatusCodes = new Set(filters.status_codes);
if (filters.error_types.size > 0) {
filters.error_types.forEach(type => {
- for (const [code, obj] of Object.entries(STATUS_CODE_MAP)) {
- if (obj.type === type) translatedStatusCodes.add(code);
- }
+ // Find matching static error codes (e.g., 'API_KEY_INVALID')
for (const [code, obj] of Object.entries(STATIC_ERROR_MAP)) {
- if (obj.type === type) translatedErrorCodes.add(code);
+ if (obj.type === type) {
+ allErrorCodes.add(code);
+ }
+ }
+ // Find matching status codes (e.g., 400, 401)
+ for (const [code, obj] of Object.entries(STATUS_CODE_MAP)) {
+ if (obj.type === type) {
+ allStatusCodes.add(code);
+ }
}
});
}
+ // Pass the combined codes to the backend. The backend will handle the OR logic.
+ if (allErrorCodes.size > 0) finalParams.error_codes = [...allErrorCodes].join(',');
+ if (allStatusCodes.size > 0) finalParams.status_codes = [...allStatusCodes].join(',');
+ // --- [MODIFIED] END ---
+
if (filters.key_ids.size > 0) finalParams.key_ids = [...filters.key_ids].join(',');
if (filters.group_ids.size > 0) finalParams.group_ids = [...filters.group_ids].join(',');
- if (translatedErrorCodes.size > 0) finalParams.error_codes = [...translatedErrorCodes].join(',');
- if (translatedStatusCodes.size > 0) finalParams.status_codes = [...translatedStatusCodes].join(',');
Object.keys(finalParams).forEach(key => {
if (finalParams[key] === '' || finalParams[key] === null || finalParams[key] === undefined) {
diff --git a/frontend/js/pages/logs/logList.js b/frontend/js/pages/logs/logList.js
index 81be013..487dbbb 100644
--- a/frontend/js/pages/logs/logList.js
+++ b/frontend/js/pages/logs/logList.js
@@ -78,7 +78,7 @@ class LogList {
statusCodeHtml: `
成功`
};
}
- // 2. [新增] 特殊场景优先判断 (结合ErrorCode和ErrorMessage)
+ // 2. 特殊场景优先判断 (结合ErrorCode和ErrorMessage)
const codeMatch = log.ErrorCode ? log.ErrorCode.match(errorCodeRegex) : null;
if (codeMatch && codeMatch[1] && log.ErrorMessage) {
const code = parseInt(codeMatch[1], 10);
@@ -146,7 +146,7 @@ class LogList {
const checkedAttr = isChecked ? 'checked' : '';
return `
-
+
|
|
@@ -157,10 +157,26 @@ class LogList {
${errorInfo.statusCodeHtml} |
${modelNameFormatted} |
${requestTime} |
-
-
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
|
`;
diff --git a/frontend/js/vendor/anime.esm.js b/frontend/js/vendor/anime.esm.js
new file mode 100644
index 0000000..42adc8d
--- /dev/null
+++ b/frontend/js/vendor/anime.esm.js
@@ -0,0 +1,1311 @@
+/*
+ * anime.js v3.2.2
+ * (c) 2023 Julian Garnier
+ * Released under the MIT license
+ * animejs.com
+ */
+
+// Defaults
+
+var defaultInstanceSettings = {
+ update: null,
+ begin: null,
+ loopBegin: null,
+ changeBegin: null,
+ change: null,
+ changeComplete: null,
+ loopComplete: null,
+ complete: null,
+ loop: 1,
+ direction: 'normal',
+ autoplay: true,
+ timelineOffset: 0
+};
+
+var defaultTweenSettings = {
+ duration: 1000,
+ delay: 0,
+ endDelay: 0,
+ easing: 'easeOutElastic(1, .5)',
+ round: 0
+};
+
+var validTransforms = ['translateX', 'translateY', 'translateZ', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'perspective', 'matrix', 'matrix3d'];
+
+// Caching
+
+var cache = {
+ CSS: {},
+ springs: {}
+};
+
+// Utils
+
+function minMax(val, min, max) {
+ return Math.min(Math.max(val, min), max);
+}
+
+function stringContains(str, text) {
+ return str.indexOf(text) > -1;
+}
+
+function applyArguments(func, args) {
+ return func.apply(null, args);
+}
+
+var is = {
+ arr: function (a) { return Array.isArray(a); },
+ obj: function (a) { return stringContains(Object.prototype.toString.call(a), 'Object'); },
+ pth: function (a) { return is.obj(a) && a.hasOwnProperty('totalLength'); },
+ svg: function (a) { return a instanceof SVGElement; },
+ inp: function (a) { return a instanceof HTMLInputElement; },
+ dom: function (a) { return a.nodeType || is.svg(a); },
+ str: function (a) { return typeof a === 'string'; },
+ fnc: function (a) { return typeof a === 'function'; },
+ und: function (a) { return typeof a === 'undefined'; },
+ nil: function (a) { return is.und(a) || a === null; },
+ hex: function (a) { return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a); },
+ rgb: function (a) { return /^rgb/.test(a); },
+ hsl: function (a) { return /^hsl/.test(a); },
+ col: function (a) { return (is.hex(a) || is.rgb(a) || is.hsl(a)); },
+ key: function (a) { return !defaultInstanceSettings.hasOwnProperty(a) && !defaultTweenSettings.hasOwnProperty(a) && a !== 'targets' && a !== 'keyframes'; },
+};
+
+// Easings
+
+function parseEasingParameters(string) {
+ var match = /\(([^)]+)\)/.exec(string);
+ return match ? match[1].split(',').map(function (p) { return parseFloat(p); }) : [];
+}
+
+// Spring solver inspired by Webkit Copyright © 2016 Apple Inc. All rights reserved. https://webkit.org/demos/spring/spring.js
+
+function spring(string, duration) {
+
+ var params = parseEasingParameters(string);
+ var mass = minMax(is.und(params[0]) ? 1 : params[0], .1, 100);
+ var stiffness = minMax(is.und(params[1]) ? 100 : params[1], .1, 100);
+ var damping = minMax(is.und(params[2]) ? 10 : params[2], .1, 100);
+ var velocity = minMax(is.und(params[3]) ? 0 : params[3], .1, 100);
+ var w0 = Math.sqrt(stiffness / mass);
+ var zeta = damping / (2 * Math.sqrt(stiffness * mass));
+ var wd = zeta < 1 ? w0 * Math.sqrt(1 - zeta * zeta) : 0;
+ var a = 1;
+ var b = zeta < 1 ? (zeta * w0 + -velocity) / wd : -velocity + w0;
+
+ function solver(t) {
+ var progress = duration ? (duration * t) / 1000 : t;
+ if (zeta < 1) {
+ progress = Math.exp(-progress * zeta * w0) * (a * Math.cos(wd * progress) + b * Math.sin(wd * progress));
+ } else {
+ progress = (a + b * progress) * Math.exp(-progress * w0);
+ }
+ if (t === 0 || t === 1) { return t; }
+ return 1 - progress;
+ }
+
+ function getDuration() {
+ var cached = cache.springs[string];
+ if (cached) { return cached; }
+ var frame = 1/6;
+ var elapsed = 0;
+ var rest = 0;
+ while(true) {
+ elapsed += frame;
+ if (solver(elapsed) === 1) {
+ rest++;
+ if (rest >= 16) { break; }
+ } else {
+ rest = 0;
+ }
+ }
+ var duration = elapsed * frame * 1000;
+ cache.springs[string] = duration;
+ return duration;
+ }
+
+ return duration ? solver : getDuration;
+
+}
+
+// Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
+
+function steps(steps) {
+ if ( steps === void 0 ) steps = 10;
+
+ return function (t) { return Math.ceil((minMax(t, 0.000001, 1)) * steps) * (1 / steps); };
+}
+
+// BezierEasing https://github.com/gre/bezier-easing
+
+var bezier = (function () {
+
+ var kSplineTableSize = 11;
+ var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
+
+ function A(aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1 }
+ function B(aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1 }
+ function C(aA1) { return 3.0 * aA1 }
+
+ function calcBezier(aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT }
+ function getSlope(aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1) }
+
+ function binarySubdivide(aX, aA, aB, mX1, mX2) {
+ var currentX, currentT, i = 0;
+ do {
+ currentT = aA + (aB - aA) / 2.0;
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
+ if (currentX > 0.0) { aB = currentT; } else { aA = currentT; }
+ } while (Math.abs(currentX) > 0.0000001 && ++i < 10);
+ return currentT;
+ }
+
+ function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
+ for (var i = 0; i < 4; ++i) {
+ var currentSlope = getSlope(aGuessT, mX1, mX2);
+ if (currentSlope === 0.0) { return aGuessT; }
+ var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
+ aGuessT -= currentX / currentSlope;
+ }
+ return aGuessT;
+ }
+
+ function bezier(mX1, mY1, mX2, mY2) {
+
+ if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) { return; }
+ var sampleValues = new Float32Array(kSplineTableSize);
+
+ if (mX1 !== mY1 || mX2 !== mY2) {
+ for (var i = 0; i < kSplineTableSize; ++i) {
+ sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
+ }
+ }
+
+ function getTForX(aX) {
+
+ var intervalStart = 0;
+ var currentSample = 1;
+ var lastSample = kSplineTableSize - 1;
+
+ for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
+ intervalStart += kSampleStepSize;
+ }
+
+ --currentSample;
+
+ var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
+ var guessForT = intervalStart + dist * kSampleStepSize;
+ var initialSlope = getSlope(guessForT, mX1, mX2);
+
+ if (initialSlope >= 0.001) {
+ return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
+ } else if (initialSlope === 0.0) {
+ return guessForT;
+ } else {
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
+ }
+
+ }
+
+ return function (x) {
+ if (mX1 === mY1 && mX2 === mY2) { return x; }
+ if (x === 0 || x === 1) { return x; }
+ return calcBezier(getTForX(x), mY1, mY2);
+ }
+
+ }
+
+ return bezier;
+
+})();
+
+var penner = (function () {
+
+ // Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing)
+
+ var eases = { linear: function () { return function (t) { return t; }; } };
+
+ var functionEasings = {
+ Sine: function () { return function (t) { return 1 - Math.cos(t * Math.PI / 2); }; },
+ Expo: function () { return function (t) { return t ? Math.pow(2, 10 * t - 10) : 0; }; },
+ Circ: function () { return function (t) { return 1 - Math.sqrt(1 - t * t); }; },
+ Back: function () { return function (t) { return t * t * (3 * t - 2); }; },
+ Bounce: function () { return function (t) {
+ var pow2, b = 4;
+ while (t < (( pow2 = Math.pow(2, --b)) - 1) / 11) {}
+ return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow(( pow2 * 3 - 2 ) / 22 - t, 2)
+ }; },
+ Elastic: function (amplitude, period) {
+ if ( amplitude === void 0 ) amplitude = 1;
+ if ( period === void 0 ) period = .5;
+
+ var a = minMax(amplitude, 1, 10);
+ var p = minMax(period, .1, 2);
+ return function (t) {
+ return (t === 0 || t === 1) ? t :
+ -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p);
+ }
+ }
+ };
+
+ var baseEasings = ['Quad', 'Cubic', 'Quart', 'Quint'];
+
+ baseEasings.forEach(function (name, i) {
+ functionEasings[name] = function () { return function (t) { return Math.pow(t, i + 2); }; };
+ });
+
+ Object.keys(functionEasings).forEach(function (name) {
+ var easeIn = functionEasings[name];
+ eases['easeIn' + name] = easeIn;
+ eases['easeOut' + name] = function (a, b) { return function (t) { return 1 - easeIn(a, b)(1 - t); }; };
+ eases['easeInOut' + name] = function (a, b) { return function (t) { return t < 0.5 ? easeIn(a, b)(t * 2) / 2 :
+ 1 - easeIn(a, b)(t * -2 + 2) / 2; }; };
+ eases['easeOutIn' + name] = function (a, b) { return function (t) { return t < 0.5 ? (1 - easeIn(a, b)(1 - t * 2)) / 2 :
+ (easeIn(a, b)(t * 2 - 1) + 1) / 2; }; };
+ });
+
+ return eases;
+
+})();
+
+function parseEasings(easing, duration) {
+ if (is.fnc(easing)) { return easing; }
+ var name = easing.split('(')[0];
+ var ease = penner[name];
+ var args = parseEasingParameters(easing);
+ switch (name) {
+ case 'spring' : return spring(easing, duration);
+ case 'cubicBezier' : return applyArguments(bezier, args);
+ case 'steps' : return applyArguments(steps, args);
+ default : return applyArguments(ease, args);
+ }
+}
+
+// Strings
+
+function selectString(str) {
+ try {
+ var nodes = document.querySelectorAll(str);
+ return nodes;
+ } catch(e) {
+ return;
+ }
+}
+
+// Arrays
+
+function filterArray(arr, callback) {
+ var len = arr.length;
+ var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
+ var result = [];
+ for (var i = 0; i < len; i++) {
+ if (i in arr) {
+ var val = arr[i];
+ if (callback.call(thisArg, val, i, arr)) {
+ result.push(val);
+ }
+ }
+ }
+ return result;
+}
+
+function flattenArray(arr) {
+ return arr.reduce(function (a, b) { return a.concat(is.arr(b) ? flattenArray(b) : b); }, []);
+}
+
+function toArray(o) {
+ if (is.arr(o)) { return o; }
+ if (is.str(o)) { o = selectString(o) || o; }
+ if (o instanceof NodeList || o instanceof HTMLCollection) { return [].slice.call(o); }
+ return [o];
+}
+
+function arrayContains(arr, val) {
+ return arr.some(function (a) { return a === val; });
+}
+
+// Objects
+
+function cloneObject(o) {
+ var clone = {};
+ for (var p in o) { clone[p] = o[p]; }
+ return clone;
+}
+
+function replaceObjectProps(o1, o2) {
+ var o = cloneObject(o1);
+ for (var p in o1) { o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p]; }
+ return o;
+}
+
+function mergeObjects(o1, o2) {
+ var o = cloneObject(o1);
+ for (var p in o2) { o[p] = is.und(o1[p]) ? o2[p] : o1[p]; }
+ return o;
+}
+
+// Colors
+
+function rgbToRgba(rgbValue) {
+ var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
+ return rgb ? ("rgba(" + (rgb[1]) + ",1)") : rgbValue;
+}
+
+function hexToRgba(hexValue) {
+ var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
+ var hex = hexValue.replace(rgx, function (m, r, g, b) { return r + r + g + g + b + b; } );
+ var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
+ var r = parseInt(rgb[1], 16);
+ var g = parseInt(rgb[2], 16);
+ var b = parseInt(rgb[3], 16);
+ return ("rgba(" + r + "," + g + "," + b + ",1)");
+}
+
+function hslToRgba(hslValue) {
+ var hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(hslValue) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(hslValue);
+ var h = parseInt(hsl[1], 10) / 360;
+ var s = parseInt(hsl[2], 10) / 100;
+ var l = parseInt(hsl[3], 10) / 100;
+ var a = hsl[4] || 1;
+ function hue2rgb(p, q, t) {
+ if (t < 0) { t += 1; }
+ if (t > 1) { t -= 1; }
+ if (t < 1/6) { return p + (q - p) * 6 * t; }
+ if (t < 1/2) { return q; }
+ if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; }
+ return p;
+ }
+ var r, g, b;
+ if (s == 0) {
+ r = g = b = l;
+ } else {
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ var p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1/3);
+ g = hue2rgb(p, q, h);
+ b = hue2rgb(p, q, h - 1/3);
+ }
+ return ("rgba(" + (r * 255) + "," + (g * 255) + "," + (b * 255) + "," + a + ")");
+}
+
+function colorToRgb(val) {
+ if (is.rgb(val)) { return rgbToRgba(val); }
+ if (is.hex(val)) { return hexToRgba(val); }
+ if (is.hsl(val)) { return hslToRgba(val); }
+}
+
+// Units
+
+function getUnit(val) {
+ var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val);
+ if (split) { return split[1]; }
+}
+
+function getTransformUnit(propName) {
+ if (stringContains(propName, 'translate') || propName === 'perspective') { return 'px'; }
+ if (stringContains(propName, 'rotate') || stringContains(propName, 'skew')) { return 'deg'; }
+}
+
+// Values
+
+function getFunctionValue(val, animatable) {
+ if (!is.fnc(val)) { return val; }
+ return val(animatable.target, animatable.id, animatable.total);
+}
+
+function getAttribute(el, prop) {
+ return el.getAttribute(prop);
+}
+
+function convertPxToUnit(el, value, unit) {
+ var valueUnit = getUnit(value);
+ if (arrayContains([unit, 'deg', 'rad', 'turn'], valueUnit)) { return value; }
+ var cached = cache.CSS[value + unit];
+ if (!is.und(cached)) { return cached; }
+ var baseline = 100;
+ var tempEl = document.createElement(el.tagName);
+ var parentEl = (el.parentNode && (el.parentNode !== document)) ? el.parentNode : document.body;
+ parentEl.appendChild(tempEl);
+ tempEl.style.position = 'absolute';
+ tempEl.style.width = baseline + unit;
+ var factor = baseline / tempEl.offsetWidth;
+ parentEl.removeChild(tempEl);
+ var convertedUnit = factor * parseFloat(value);
+ cache.CSS[value + unit] = convertedUnit;
+ return convertedUnit;
+}
+
+function getCSSValue(el, prop, unit) {
+ if (prop in el.style) {
+ var uppercasePropName = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
+ var value = el.style[prop] || getComputedStyle(el).getPropertyValue(uppercasePropName) || '0';
+ return unit ? convertPxToUnit(el, value, unit) : value;
+ }
+}
+
+function getAnimationType(el, prop) {
+ if (is.dom(el) && !is.inp(el) && (!is.nil(getAttribute(el, prop)) || (is.svg(el) && el[prop]))) { return 'attribute'; }
+ if (is.dom(el) && arrayContains(validTransforms, prop)) { return 'transform'; }
+ if (is.dom(el) && (prop !== 'transform' && getCSSValue(el, prop))) { return 'css'; }
+ if (el[prop] != null) { return 'object'; }
+}
+
+function getElementTransforms(el) {
+ if (!is.dom(el)) { return; }
+ var str = el.style.transform || '';
+ var reg = /(\w+)\(([^)]*)\)/g;
+ var transforms = new Map();
+ var m; while (m = reg.exec(str)) { transforms.set(m[1], m[2]); }
+ return transforms;
+}
+
+function getTransformValue(el, propName, animatable, unit) {
+ var defaultVal = stringContains(propName, 'scale') ? 1 : 0 + getTransformUnit(propName);
+ var value = getElementTransforms(el).get(propName) || defaultVal;
+ if (animatable) {
+ animatable.transforms.list.set(propName, value);
+ animatable.transforms['last'] = propName;
+ }
+ return unit ? convertPxToUnit(el, value, unit) : value;
+}
+
+function getOriginalTargetValue(target, propName, unit, animatable) {
+ switch (getAnimationType(target, propName)) {
+ case 'transform': return getTransformValue(target, propName, animatable, unit);
+ case 'css': return getCSSValue(target, propName, unit);
+ case 'attribute': return getAttribute(target, propName);
+ default: return target[propName] || 0;
+ }
+}
+
+function getRelativeValue(to, from) {
+ var operator = /^(\*=|\+=|-=)/.exec(to);
+ if (!operator) { return to; }
+ var u = getUnit(to) || 0;
+ var x = parseFloat(from);
+ var y = parseFloat(to.replace(operator[0], ''));
+ switch (operator[0][0]) {
+ case '+': return x + y + u;
+ case '-': return x - y + u;
+ case '*': return x * y + u;
+ }
+}
+
+function validateValue(val, unit) {
+ if (is.col(val)) { return colorToRgb(val); }
+ if (/\s/g.test(val)) { return val; }
+ var originalUnit = getUnit(val);
+ var unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val;
+ if (unit) { return unitLess + unit; }
+ return unitLess;
+}
+
+// getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes
+// adapted from https://gist.github.com/SebLambla/3e0550c496c236709744
+
+function getDistance(p1, p2) {
+ return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
+}
+
+function getCircleLength(el) {
+ return Math.PI * 2 * getAttribute(el, 'r');
+}
+
+function getRectLength(el) {
+ return (getAttribute(el, 'width') * 2) + (getAttribute(el, 'height') * 2);
+}
+
+function getLineLength(el) {
+ return getDistance(
+ {x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')},
+ {x: getAttribute(el, 'x2'), y: getAttribute(el, 'y2')}
+ );
+}
+
+function getPolylineLength(el) {
+ var points = el.points;
+ var totalLength = 0;
+ var previousPos;
+ for (var i = 0 ; i < points.numberOfItems; i++) {
+ var currentPos = points.getItem(i);
+ if (i > 0) { totalLength += getDistance(previousPos, currentPos); }
+ previousPos = currentPos;
+ }
+ return totalLength;
+}
+
+function getPolygonLength(el) {
+ var points = el.points;
+ return getPolylineLength(el) + getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
+}
+
+// Path animation
+
+function getTotalLength(el) {
+ if (el.getTotalLength) { return el.getTotalLength(); }
+ switch(el.tagName.toLowerCase()) {
+ case 'circle': return getCircleLength(el);
+ case 'rect': return getRectLength(el);
+ case 'line': return getLineLength(el);
+ case 'polyline': return getPolylineLength(el);
+ case 'polygon': return getPolygonLength(el);
+ }
+}
+
+function setDashoffset(el) {
+ var pathLength = getTotalLength(el);
+ el.setAttribute('stroke-dasharray', pathLength);
+ return pathLength;
+}
+
+// Motion path
+
+function getParentSvgEl(el) {
+ var parentEl = el.parentNode;
+ while (is.svg(parentEl)) {
+ if (!is.svg(parentEl.parentNode)) { break; }
+ parentEl = parentEl.parentNode;
+ }
+ return parentEl;
+}
+
+function getParentSvg(pathEl, svgData) {
+ var svg = svgData || {};
+ var parentSvgEl = svg.el || getParentSvgEl(pathEl);
+ var rect = parentSvgEl.getBoundingClientRect();
+ var viewBoxAttr = getAttribute(parentSvgEl, 'viewBox');
+ var width = rect.width;
+ var height = rect.height;
+ var viewBox = svg.viewBox || (viewBoxAttr ? viewBoxAttr.split(' ') : [0, 0, width, height]);
+ return {
+ el: parentSvgEl,
+ viewBox: viewBox,
+ x: viewBox[0] / 1,
+ y: viewBox[1] / 1,
+ w: width,
+ h: height,
+ vW: viewBox[2],
+ vH: viewBox[3]
+ }
+}
+
+function getPath(path, percent) {
+ var pathEl = is.str(path) ? selectString(path)[0] : path;
+ var p = percent || 100;
+ return function(property) {
+ return {
+ property: property,
+ el: pathEl,
+ svg: getParentSvg(pathEl),
+ totalLength: getTotalLength(pathEl) * (p / 100)
+ }
+ }
+}
+
+function getPathProgress(path, progress, isPathTargetInsideSVG) {
+ function point(offset) {
+ if ( offset === void 0 ) offset = 0;
+
+ var l = progress + offset >= 1 ? progress + offset : 0;
+ return path.el.getPointAtLength(l);
+ }
+ var svg = getParentSvg(path.el, path.svg);
+ var p = point();
+ var p0 = point(-1);
+ var p1 = point(+1);
+ var scaleX = isPathTargetInsideSVG ? 1 : svg.w / svg.vW;
+ var scaleY = isPathTargetInsideSVG ? 1 : svg.h / svg.vH;
+ switch (path.property) {
+ case 'x': return (p.x - svg.x) * scaleX;
+ case 'y': return (p.y - svg.y) * scaleY;
+ case 'angle': return Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI;
+ }
+}
+
+// Decompose value
+
+function decomposeValue(val, unit) {
+ // const rgx = /-?\d*\.?\d+/g; // handles basic numbers
+ // const rgx = /[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
+ var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
+ var value = validateValue((is.pth(val) ? val.totalLength : val), unit) + '';
+ return {
+ original: value,
+ numbers: value.match(rgx) ? value.match(rgx).map(Number) : [0],
+ strings: (is.str(val) || unit) ? value.split(rgx) : []
+ }
+}
+
+// Animatables
+
+function parseTargets(targets) {
+ var targetsArray = targets ? (flattenArray(is.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
+ return filterArray(targetsArray, function (item, pos, self) { return self.indexOf(item) === pos; });
+}
+
+function getAnimatables(targets) {
+ var parsed = parseTargets(targets);
+ return parsed.map(function (t, i) {
+ return {target: t, id: i, total: parsed.length, transforms: { list: getElementTransforms(t) } };
+ });
+}
+
+// Properties
+
+function normalizePropertyTweens(prop, tweenSettings) {
+ var settings = cloneObject(tweenSettings);
+ // Override duration if easing is a spring
+ if (/^spring/.test(settings.easing)) { settings.duration = spring(settings.easing); }
+ if (is.arr(prop)) {
+ var l = prop.length;
+ var isFromTo = (l === 2 && !is.obj(prop[0]));
+ if (!isFromTo) {
+ // Duration divided by the number of tweens
+ if (!is.fnc(tweenSettings.duration)) { settings.duration = tweenSettings.duration / l; }
+ } else {
+ // Transform [from, to] values shorthand to a valid tween value
+ prop = {value: prop};
+ }
+ }
+ var propArray = is.arr(prop) ? prop : [prop];
+ return propArray.map(function (v, i) {
+ var obj = (is.obj(v) && !is.pth(v)) ? v : {value: v};
+ // Default delay value should only be applied to the first tween
+ if (is.und(obj.delay)) { obj.delay = !i ? tweenSettings.delay : 0; }
+ // Default endDelay value should only be applied to the last tween
+ if (is.und(obj.endDelay)) { obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0; }
+ return obj;
+ }).map(function (k) { return mergeObjects(k, settings); });
+}
+
+
+function flattenKeyframes(keyframes) {
+ var propertyNames = filterArray(flattenArray(keyframes.map(function (key) { return Object.keys(key); })), function (p) { return is.key(p); })
+ .reduce(function (a,b) { if (a.indexOf(b) < 0) { a.push(b); } return a; }, []);
+ var properties = {};
+ var loop = function ( i ) {
+ var propName = propertyNames[i];
+ properties[propName] = keyframes.map(function (key) {
+ var newKey = {};
+ for (var p in key) {
+ if (is.key(p)) {
+ if (p == propName) { newKey.value = key[p]; }
+ } else {
+ newKey[p] = key[p];
+ }
+ }
+ return newKey;
+ });
+ };
+
+ for (var i = 0; i < propertyNames.length; i++) loop( i );
+ return properties;
+}
+
+function getProperties(tweenSettings, params) {
+ var properties = [];
+ var keyframes = params.keyframes;
+ if (keyframes) { params = mergeObjects(flattenKeyframes(keyframes), params); }
+ for (var p in params) {
+ if (is.key(p)) {
+ properties.push({
+ name: p,
+ tweens: normalizePropertyTweens(params[p], tweenSettings)
+ });
+ }
+ }
+ return properties;
+}
+
+// Tweens
+
+function normalizeTweenValues(tween, animatable) {
+ var t = {};
+ for (var p in tween) {
+ var value = getFunctionValue(tween[p], animatable);
+ if (is.arr(value)) {
+ value = value.map(function (v) { return getFunctionValue(v, animatable); });
+ if (value.length === 1) { value = value[0]; }
+ }
+ t[p] = value;
+ }
+ t.duration = parseFloat(t.duration);
+ t.delay = parseFloat(t.delay);
+ return t;
+}
+
+function normalizeTweens(prop, animatable) {
+ var previousTween;
+ return prop.tweens.map(function (t) {
+ var tween = normalizeTweenValues(t, animatable);
+ var tweenValue = tween.value;
+ var to = is.arr(tweenValue) ? tweenValue[1] : tweenValue;
+ var toUnit = getUnit(to);
+ var originalValue = getOriginalTargetValue(animatable.target, prop.name, toUnit, animatable);
+ var previousValue = previousTween ? previousTween.to.original : originalValue;
+ var from = is.arr(tweenValue) ? tweenValue[0] : previousValue;
+ var fromUnit = getUnit(from) || getUnit(originalValue);
+ var unit = toUnit || fromUnit;
+ if (is.und(to)) { to = previousValue; }
+ tween.from = decomposeValue(from, unit);
+ tween.to = decomposeValue(getRelativeValue(to, from), unit);
+ tween.start = previousTween ? previousTween.end : 0;
+ tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
+ tween.easing = parseEasings(tween.easing, tween.duration);
+ tween.isPath = is.pth(tweenValue);
+ tween.isPathTargetInsideSVG = tween.isPath && is.svg(animatable.target);
+ tween.isColor = is.col(tween.from.original);
+ if (tween.isColor) { tween.round = 1; }
+ previousTween = tween;
+ return tween;
+ });
+}
+
+// Tween progress
+
+var setProgressValue = {
+ css: function (t, p, v) { return t.style[p] = v; },
+ attribute: function (t, p, v) { return t.setAttribute(p, v); },
+ object: function (t, p, v) { return t[p] = v; },
+ transform: function (t, p, v, transforms, manual) {
+ transforms.list.set(p, v);
+ if (p === transforms.last || manual) {
+ var str = '';
+ transforms.list.forEach(function (value, prop) { str += prop + "(" + value + ") "; });
+ t.style.transform = str;
+ }
+ }
+};
+
+// Set Value helper
+
+function setTargetsValue(targets, properties) {
+ var animatables = getAnimatables(targets);
+ animatables.forEach(function (animatable) {
+ for (var property in properties) {
+ var value = getFunctionValue(properties[property], animatable);
+ var target = animatable.target;
+ var valueUnit = getUnit(value);
+ var originalValue = getOriginalTargetValue(target, property, valueUnit, animatable);
+ var unit = valueUnit || getUnit(originalValue);
+ var to = getRelativeValue(validateValue(value, unit), originalValue);
+ var animType = getAnimationType(target, property);
+ setProgressValue[animType](target, property, to, animatable.transforms, true);
+ }
+ });
+}
+
+// Animations
+
+function createAnimation(animatable, prop) {
+ var animType = getAnimationType(animatable.target, prop.name);
+ if (animType) {
+ var tweens = normalizeTweens(prop, animatable);
+ var lastTween = tweens[tweens.length - 1];
+ return {
+ type: animType,
+ property: prop.name,
+ animatable: animatable,
+ tweens: tweens,
+ duration: lastTween.end,
+ delay: tweens[0].delay,
+ endDelay: lastTween.endDelay
+ }
+ }
+}
+
+function getAnimations(animatables, properties) {
+ return filterArray(flattenArray(animatables.map(function (animatable) {
+ return properties.map(function (prop) {
+ return createAnimation(animatable, prop);
+ });
+ })), function (a) { return !is.und(a); });
+}
+
+// Create Instance
+
+function getInstanceTimings(animations, tweenSettings) {
+ var animLength = animations.length;
+ var getTlOffset = function (anim) { return anim.timelineOffset ? anim.timelineOffset : 0; };
+ var timings = {};
+ timings.duration = animLength ? Math.max.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.duration; })) : tweenSettings.duration;
+ timings.delay = animLength ? Math.min.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.delay; })) : tweenSettings.delay;
+ timings.endDelay = animLength ? timings.duration - Math.max.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.duration - anim.endDelay; })) : tweenSettings.endDelay;
+ return timings;
+}
+
+var instanceID = 0;
+
+function createNewInstance(params) {
+ var instanceSettings = replaceObjectProps(defaultInstanceSettings, params);
+ var tweenSettings = replaceObjectProps(defaultTweenSettings, params);
+ var properties = getProperties(tweenSettings, params);
+ var animatables = getAnimatables(params.targets);
+ var animations = getAnimations(animatables, properties);
+ var timings = getInstanceTimings(animations, tweenSettings);
+ var id = instanceID;
+ instanceID++;
+ return mergeObjects(instanceSettings, {
+ id: id,
+ children: [],
+ animatables: animatables,
+ animations: animations,
+ duration: timings.duration,
+ delay: timings.delay,
+ endDelay: timings.endDelay
+ });
+}
+
+// Core
+
+var activeInstances = [];
+
+var engine = (function () {
+ var raf;
+
+ function play() {
+ if (!raf && (!isDocumentHidden() || !anime.suspendWhenDocumentHidden) && activeInstances.length > 0) {
+ raf = requestAnimationFrame(step);
+ }
+ }
+ function step(t) {
+ // memo on algorithm issue:
+ // dangerous iteration over mutable `activeInstances`
+ // (that collection may be updated from within callbacks of `tick`-ed animation instances)
+ var activeInstancesLength = activeInstances.length;
+ var i = 0;
+ while (i < activeInstancesLength) {
+ var activeInstance = activeInstances[i];
+ if (!activeInstance.paused) {
+ activeInstance.tick(t);
+ i++;
+ } else {
+ activeInstances.splice(i, 1);
+ activeInstancesLength--;
+ }
+ }
+ raf = i > 0 ? requestAnimationFrame(step) : undefined;
+ }
+
+ function handleVisibilityChange() {
+ if (!anime.suspendWhenDocumentHidden) { return; }
+
+ if (isDocumentHidden()) {
+ // suspend ticks
+ raf = cancelAnimationFrame(raf);
+ } else { // is back to active tab
+ // first adjust animations to consider the time that ticks were suspended
+ activeInstances.forEach(
+ function (instance) { return instance ._onDocumentVisibility(); }
+ );
+ engine();
+ }
+ }
+ if (typeof document !== 'undefined') {
+ document.addEventListener('visibilitychange', handleVisibilityChange);
+ }
+
+ return play;
+})();
+
+function isDocumentHidden() {
+ return !!document && document.hidden;
+}
+
+// Public Instance
+
+function anime(params) {
+ if ( params === void 0 ) params = {};
+
+
+ var startTime = 0, lastTime = 0, now = 0;
+ var children, childrenLength = 0;
+ var resolve = null;
+
+ function makePromise(instance) {
+ var promise = window.Promise && new Promise(function (_resolve) { return resolve = _resolve; });
+ instance.finished = promise;
+ return promise;
+ }
+
+ var instance = createNewInstance(params);
+ var promise = makePromise(instance);
+
+ function toggleInstanceDirection() {
+ var direction = instance.direction;
+ if (direction !== 'alternate') {
+ instance.direction = direction !== 'normal' ? 'normal' : 'reverse';
+ }
+ instance.reversed = !instance.reversed;
+ children.forEach(function (child) { return child.reversed = instance.reversed; });
+ }
+
+ function adjustTime(time) {
+ return instance.reversed ? instance.duration - time : time;
+ }
+
+ function resetTime() {
+ startTime = 0;
+ lastTime = adjustTime(instance.currentTime) * (1 / anime.speed);
+ }
+
+ function seekChild(time, child) {
+ if (child) { child.seek(time - child.timelineOffset); }
+ }
+
+ function syncInstanceChildren(time) {
+ if (!instance.reversePlayback) {
+ for (var i = 0; i < childrenLength; i++) { seekChild(time, children[i]); }
+ } else {
+ for (var i$1 = childrenLength; i$1--;) { seekChild(time, children[i$1]); }
+ }
+ }
+
+ function setAnimationsProgress(insTime) {
+ var i = 0;
+ var animations = instance.animations;
+ var animationsLength = animations.length;
+ while (i < animationsLength) {
+ var anim = animations[i];
+ var animatable = anim.animatable;
+ var tweens = anim.tweens;
+ var tweenLength = tweens.length - 1;
+ var tween = tweens[tweenLength];
+ // Only check for keyframes if there is more than one tween
+ if (tweenLength) { tween = filterArray(tweens, function (t) { return (insTime < t.end); })[0] || tween; }
+ var elapsed = minMax(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
+ var eased = isNaN(elapsed) ? 1 : tween.easing(elapsed);
+ var strings = tween.to.strings;
+ var round = tween.round;
+ var numbers = [];
+ var toNumbersLength = tween.to.numbers.length;
+ var progress = (void 0);
+ for (var n = 0; n < toNumbersLength; n++) {
+ var value = (void 0);
+ var toNumber = tween.to.numbers[n];
+ var fromNumber = tween.from.numbers[n] || 0;
+ if (!tween.isPath) {
+ value = fromNumber + (eased * (toNumber - fromNumber));
+ } else {
+ value = getPathProgress(tween.value, eased * toNumber, tween.isPathTargetInsideSVG);
+ }
+ if (round) {
+ if (!(tween.isColor && n > 2)) {
+ value = Math.round(value * round) / round;
+ }
+ }
+ numbers.push(value);
+ }
+ // Manual Array.reduce for better performances
+ var stringsLength = strings.length;
+ if (!stringsLength) {
+ progress = numbers[0];
+ } else {
+ progress = strings[0];
+ for (var s = 0; s < stringsLength; s++) {
+ var a = strings[s];
+ var b = strings[s + 1];
+ var n$1 = numbers[s];
+ if (!isNaN(n$1)) {
+ if (!b) {
+ progress += n$1 + ' ';
+ } else {
+ progress += n$1 + b;
+ }
+ }
+ }
+ }
+ setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
+ anim.currentValue = progress;
+ i++;
+ }
+ }
+
+ function setCallback(cb) {
+ if (instance[cb] && !instance.passThrough) { instance[cb](instance); }
+ }
+
+ function countIteration() {
+ if (instance.remaining && instance.remaining !== true) {
+ instance.remaining--;
+ }
+ }
+
+ function setInstanceProgress(engineTime) {
+ var insDuration = instance.duration;
+ var insDelay = instance.delay;
+ var insEndDelay = insDuration - instance.endDelay;
+ var insTime = adjustTime(engineTime);
+ instance.progress = minMax((insTime / insDuration) * 100, 0, 100);
+ instance.reversePlayback = insTime < instance.currentTime;
+ if (children) { syncInstanceChildren(insTime); }
+ if (!instance.began && instance.currentTime > 0) {
+ instance.began = true;
+ setCallback('begin');
+ }
+ if (!instance.loopBegan && instance.currentTime > 0) {
+ instance.loopBegan = true;
+ setCallback('loopBegin');
+ }
+ if (insTime <= insDelay && instance.currentTime !== 0) {
+ setAnimationsProgress(0);
+ }
+ if ((insTime >= insEndDelay && instance.currentTime !== insDuration) || !insDuration) {
+ setAnimationsProgress(insDuration);
+ }
+ if (insTime > insDelay && insTime < insEndDelay) {
+ if (!instance.changeBegan) {
+ instance.changeBegan = true;
+ instance.changeCompleted = false;
+ setCallback('changeBegin');
+ }
+ setCallback('change');
+ setAnimationsProgress(insTime);
+ } else {
+ if (instance.changeBegan) {
+ instance.changeCompleted = true;
+ instance.changeBegan = false;
+ setCallback('changeComplete');
+ }
+ }
+ instance.currentTime = minMax(insTime, 0, insDuration);
+ if (instance.began) { setCallback('update'); }
+ if (engineTime >= insDuration) {
+ lastTime = 0;
+ countIteration();
+ if (!instance.remaining) {
+ instance.paused = true;
+ if (!instance.completed) {
+ instance.completed = true;
+ setCallback('loopComplete');
+ setCallback('complete');
+ if (!instance.passThrough && 'Promise' in window) {
+ resolve();
+ promise = makePromise(instance);
+ }
+ }
+ } else {
+ startTime = now;
+ setCallback('loopComplete');
+ instance.loopBegan = false;
+ if (instance.direction === 'alternate') {
+ toggleInstanceDirection();
+ }
+ }
+ }
+ }
+
+ instance.reset = function() {
+ var direction = instance.direction;
+ instance.passThrough = false;
+ instance.currentTime = 0;
+ instance.progress = 0;
+ instance.paused = true;
+ instance.began = false;
+ instance.loopBegan = false;
+ instance.changeBegan = false;
+ instance.completed = false;
+ instance.changeCompleted = false;
+ instance.reversePlayback = false;
+ instance.reversed = direction === 'reverse';
+ instance.remaining = instance.loop;
+ children = instance.children;
+ childrenLength = children.length;
+ for (var i = childrenLength; i--;) { instance.children[i].reset(); }
+ if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; }
+ setAnimationsProgress(instance.reversed ? instance.duration : 0);
+ };
+
+ // internal method (for engine) to adjust animation timings before restoring engine ticks (rAF)
+ instance._onDocumentVisibility = resetTime;
+
+ // Set Value helper
+
+ instance.set = function(targets, properties) {
+ setTargetsValue(targets, properties);
+ return instance;
+ };
+
+ instance.tick = function(t) {
+ now = t;
+ if (!startTime) { startTime = now; }
+ setInstanceProgress((now + (lastTime - startTime)) * anime.speed);
+ };
+
+ instance.seek = function(time) {
+ setInstanceProgress(adjustTime(time));
+ };
+
+ instance.pause = function() {
+ instance.paused = true;
+ resetTime();
+ };
+
+ instance.play = function() {
+ if (!instance.paused) { return; }
+ if (instance.completed) { instance.reset(); }
+ instance.paused = false;
+ activeInstances.push(instance);
+ resetTime();
+ engine();
+ };
+
+ instance.reverse = function() {
+ toggleInstanceDirection();
+ instance.completed = instance.reversed ? false : true;
+ resetTime();
+ };
+
+ instance.restart = function() {
+ instance.reset();
+ instance.play();
+ };
+
+ instance.remove = function(targets) {
+ var targetsArray = parseTargets(targets);
+ removeTargetsFromInstance(targetsArray, instance);
+ };
+
+ instance.reset();
+
+ if (instance.autoplay) { instance.play(); }
+
+ return instance;
+
+}
+
+// Remove targets from animation
+
+function removeTargetsFromAnimations(targetsArray, animations) {
+ for (var a = animations.length; a--;) {
+ if (arrayContains(targetsArray, animations[a].animatable.target)) {
+ animations.splice(a, 1);
+ }
+ }
+}
+
+function removeTargetsFromInstance(targetsArray, instance) {
+ var animations = instance.animations;
+ var children = instance.children;
+ removeTargetsFromAnimations(targetsArray, animations);
+ for (var c = children.length; c--;) {
+ var child = children[c];
+ var childAnimations = child.animations;
+ removeTargetsFromAnimations(targetsArray, childAnimations);
+ if (!childAnimations.length && !child.children.length) { children.splice(c, 1); }
+ }
+ if (!animations.length && !children.length) { instance.pause(); }
+}
+
+function removeTargetsFromActiveInstances(targets) {
+ var targetsArray = parseTargets(targets);
+ for (var i = activeInstances.length; i--;) {
+ var instance = activeInstances[i];
+ removeTargetsFromInstance(targetsArray, instance);
+ }
+}
+
+// Stagger helpers
+
+function stagger(val, params) {
+ if ( params === void 0 ) params = {};
+
+ var direction = params.direction || 'normal';
+ var easing = params.easing ? parseEasings(params.easing) : null;
+ var grid = params.grid;
+ var axis = params.axis;
+ var fromIndex = params.from || 0;
+ var fromFirst = fromIndex === 'first';
+ var fromCenter = fromIndex === 'center';
+ var fromLast = fromIndex === 'last';
+ var isRange = is.arr(val);
+ var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);
+ var val2 = isRange ? parseFloat(val[1]) : 0;
+ var unit = getUnit(isRange ? val[1] : val) || 0;
+ var start = params.start || 0 + (isRange ? val1 : 0);
+ var values = [];
+ var maxValue = 0;
+ return function (el, i, t) {
+ if (fromFirst) { fromIndex = 0; }
+ if (fromCenter) { fromIndex = (t - 1) / 2; }
+ if (fromLast) { fromIndex = t - 1; }
+ if (!values.length) {
+ for (var index = 0; index < t; index++) {
+ if (!grid) {
+ values.push(Math.abs(fromIndex - index));
+ } else {
+ var fromX = !fromCenter ? fromIndex%grid[0] : (grid[0]-1)/2;
+ var fromY = !fromCenter ? Math.floor(fromIndex/grid[0]) : (grid[1]-1)/2;
+ var toX = index%grid[0];
+ var toY = Math.floor(index/grid[0]);
+ var distanceX = fromX - toX;
+ var distanceY = fromY - toY;
+ var value = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
+ if (axis === 'x') { value = -distanceX; }
+ if (axis === 'y') { value = -distanceY; }
+ values.push(value);
+ }
+ maxValue = Math.max.apply(Math, values);
+ }
+ if (easing) { values = values.map(function (val) { return easing(val / maxValue) * maxValue; }); }
+ if (direction === 'reverse') { values = values.map(function (val) { return axis ? (val < 0) ? val * -1 : -val : Math.abs(maxValue - val); }); }
+ }
+ var spacing = isRange ? (val2 - val1) / maxValue : val1;
+ return start + (spacing * (Math.round(values[i] * 100) / 100)) + unit;
+ }
+}
+
+// Timeline
+
+function timeline(params) {
+ if ( params === void 0 ) params = {};
+
+ var tl = anime(params);
+ tl.duration = 0;
+ tl.add = function(instanceParams, timelineOffset) {
+ var tlIndex = activeInstances.indexOf(tl);
+ var children = tl.children;
+ if (tlIndex > -1) { activeInstances.splice(tlIndex, 1); }
+ function passThrough(ins) { ins.passThrough = true; }
+ for (var i = 0; i < children.length; i++) { passThrough(children[i]); }
+ var insParams = mergeObjects(instanceParams, replaceObjectProps(defaultTweenSettings, params));
+ insParams.targets = insParams.targets || params.targets;
+ var tlDuration = tl.duration;
+ insParams.autoplay = false;
+ insParams.direction = tl.direction;
+ insParams.timelineOffset = is.und(timelineOffset) ? tlDuration : getRelativeValue(timelineOffset, tlDuration);
+ passThrough(tl);
+ tl.seek(insParams.timelineOffset);
+ var ins = anime(insParams);
+ passThrough(ins);
+ children.push(ins);
+ var timings = getInstanceTimings(children, params);
+ tl.delay = timings.delay;
+ tl.endDelay = timings.endDelay;
+ tl.duration = timings.duration;
+ tl.seek(0);
+ tl.reset();
+ if (tl.autoplay) { tl.play(); }
+ return tl;
+ };
+ return tl;
+}
+
+anime.version = '3.2.1';
+anime.speed = 1;
+// TODO:#review: naming, documentation
+anime.suspendWhenDocumentHidden = true;
+anime.running = activeInstances;
+anime.remove = removeTargetsFromActiveInstances;
+anime.get = getOriginalTargetValue;
+anime.set = setTargetsValue;
+anime.convertPx = convertPxToUnit;
+anime.path = getPath;
+anime.setDashoffset = setDashoffset;
+anime.stagger = stagger;
+anime.timeline = timeline;
+anime.easing = parseEasings;
+anime.penner = penner;
+anime.random = function (min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; };
+
+export default anime;
\ No newline at end of file
diff --git a/frontend/js/vendor/sweetalert2.esm.js b/frontend/js/vendor/sweetalert2.esm.js
new file mode 100644
index 0000000..7167a32
--- /dev/null
+++ b/frontend/js/vendor/sweetalert2.esm.js
@@ -0,0 +1,4611 @@
+/*!
+* sweetalert2 v11.26.3
+* Released under the MIT License.
+*/
+function _assertClassBrand(e, t, n) {
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
+ throw new TypeError("Private element is not present on this object");
+}
+function _checkPrivateRedeclaration(e, t) {
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
+}
+function _classPrivateFieldGet2(s, a) {
+ return s.get(_assertClassBrand(s, a));
+}
+function _classPrivateFieldInitSpec(e, t, a) {
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
+}
+function _classPrivateFieldSet2(s, a, r) {
+ return s.set(_assertClassBrand(s, a), r), r;
+}
+
+const RESTORE_FOCUS_TIMEOUT = 100;
+
+/** @type {GlobalState} */
+const globalState = {};
+const focusPreviousActiveElement = () => {
+ if (globalState.previousActiveElement instanceof HTMLElement) {
+ globalState.previousActiveElement.focus();
+ globalState.previousActiveElement = null;
+ } else if (document.body) {
+ document.body.focus();
+ }
+};
+
+/**
+ * Restore previous active (focused) element
+ *
+ * @param {boolean} returnFocus
+ * @returns {Promise
}
+ */
+const restoreActiveElement = returnFocus => {
+ return new Promise(resolve => {
+ if (!returnFocus) {
+ return resolve();
+ }
+ const x = window.scrollX;
+ const y = window.scrollY;
+ globalState.restoreFocusTimeout = setTimeout(() => {
+ focusPreviousActiveElement();
+ resolve();
+ }, RESTORE_FOCUS_TIMEOUT); // issues/900
+
+ window.scrollTo(x, y);
+ });
+};
+
+const swalPrefix = 'swal2-';
+
+/**
+ * @typedef {Record} SwalClasses
+ */
+
+/**
+ * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
+ * @typedef {Record} SwalIcons
+ */
+
+/** @type {SwalClass[]} */
+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'];
+const swalClasses = classNames.reduce((acc, className) => {
+ acc[className] = swalPrefix + className;
+ return acc;
+}, /** @type {SwalClasses} */{});
+
+/** @type {SwalIcon[]} */
+const icons = ['success', 'warning', 'info', 'question', 'error'];
+const iconTypes = icons.reduce((acc, icon) => {
+ acc[icon] = swalPrefix + icon;
+ return acc;
+}, /** @type {SwalIcons} */{});
+
+const consolePrefix = 'SweetAlert2:';
+
+/**
+ * Capitalize the first letter of a string
+ *
+ * @param {string} str
+ * @returns {string}
+ */
+const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
+
+/**
+ * Standardize console warnings
+ *
+ * @param {string | string[]} message
+ */
+const warn = message => {
+ console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
+};
+
+/**
+ * Standardize console errors
+ *
+ * @param {string} message
+ */
+const error = message => {
+ console.error(`${consolePrefix} ${message}`);
+};
+
+/**
+ * Private global state for `warnOnce`
+ *
+ * @type {string[]}
+ * @private
+ */
+const previousWarnOnceMessages = [];
+
+/**
+ * Show a console warning, but only if it hasn't already been shown
+ *
+ * @param {string} message
+ */
+const warnOnce = message => {
+ if (!previousWarnOnceMessages.includes(message)) {
+ previousWarnOnceMessages.push(message);
+ warn(message);
+ }
+};
+
+/**
+ * Show a one-time console warning about deprecated params/methods
+ *
+ * @param {string} deprecatedParam
+ * @param {string?} useInstead
+ */
+const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
+ warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
+};
+
+/**
+ * If `arg` is a function, call it (with no arguments or context) and return the result.
+ * Otherwise, just pass the value through
+ *
+ * @param {(() => *) | *} arg
+ * @returns {*}
+ */
+const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
+
+/**
+ * @param {*} arg
+ * @returns {boolean}
+ */
+const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
+
+/**
+ * @param {*} arg
+ * @returns {Promise<*>}
+ */
+const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
+
+/**
+ * @param {*} arg
+ * @returns {boolean}
+ */
+const isPromise = arg => arg && Promise.resolve(arg) === arg;
+
+/**
+ * Gets the popup container which contains the backdrop and the popup itself.
+ *
+ * @returns {HTMLElement | null}
+ */
+const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
+
+/**
+ * @param {string} selectorString
+ * @returns {HTMLElement | null}
+ */
+const elementBySelector = selectorString => {
+ const container = getContainer();
+ return container ? container.querySelector(selectorString) : null;
+};
+
+/**
+ * @param {string} className
+ * @returns {HTMLElement | null}
+ */
+const elementByClass = className => {
+ return elementBySelector(`.${className}`);
+};
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getPopup = () => elementByClass(swalClasses.popup);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getIcon = () => elementByClass(swalClasses.icon);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getIconContent = () => elementByClass(swalClasses['icon-content']);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getTitle = () => elementByClass(swalClasses.title);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getImage = () => elementByClass(swalClasses.image);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
+
+/**
+ * @returns {HTMLButtonElement | null}
+ */
+const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
+
+/**
+ * @returns {HTMLButtonElement | null}
+ */
+const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
+
+/**
+ * @returns {HTMLButtonElement | null}
+ */
+const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getInputLabel = () => elementByClass(swalClasses['input-label']);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getActions = () => elementByClass(swalClasses.actions);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getFooter = () => elementByClass(swalClasses.footer);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
+
+/**
+ * @returns {HTMLElement | null}
+ */
+const getCloseButton = () => elementByClass(swalClasses.close);
+
+// https://github.com/jkup/focusable/blob/master/index.js
+const focusable = `
+ a[href],
+ area[href],
+ input:not([disabled]),
+ select:not([disabled]),
+ textarea:not([disabled]),
+ button:not([disabled]),
+ iframe,
+ object,
+ embed,
+ [tabindex="0"],
+ [contenteditable],
+ audio[controls],
+ video[controls],
+ summary
+`;
+/**
+ * @returns {HTMLElement[]}
+ */
+const getFocusableElements = () => {
+ const popup = getPopup();
+ if (!popup) {
+ return [];
+ }
+ /** @type {NodeListOf} */
+ const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
+ const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
+ // sort according to tabindex
+ .sort((a, b) => {
+ const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
+ const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
+ if (tabindexA > tabindexB) {
+ return 1;
+ } else if (tabindexA < tabindexB) {
+ return -1;
+ }
+ return 0;
+ });
+
+ /** @type {NodeListOf} */
+ const otherFocusableElements = popup.querySelectorAll(focusable);
+ const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
+ return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
+};
+
+/**
+ * @returns {boolean}
+ */
+const isModal = () => {
+ return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
+};
+
+/**
+ * @returns {boolean}
+ */
+const isToast = () => {
+ const popup = getPopup();
+ if (!popup) {
+ return false;
+ }
+ return hasClass(popup, swalClasses.toast);
+};
+
+/**
+ * @returns {boolean}
+ */
+const isLoading = () => {
+ const popup = getPopup();
+ if (!popup) {
+ return false;
+ }
+ return popup.hasAttribute('data-loading');
+};
+
+/**
+ * Securely set innerHTML of an element
+ * https://github.com/sweetalert2/sweetalert2/issues/1926
+ *
+ * @param {HTMLElement} elem
+ * @param {string} html
+ */
+const setInnerHtml = (elem, html) => {
+ elem.textContent = '';
+ if (html) {
+ const parser = new DOMParser();
+ const parsed = parser.parseFromString(html, `text/html`);
+ const head = parsed.querySelector('head');
+ if (head) {
+ Array.from(head.childNodes).forEach(child => {
+ elem.appendChild(child);
+ });
+ }
+ const body = parsed.querySelector('body');
+ if (body) {
+ Array.from(body.childNodes).forEach(child => {
+ if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
+ elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
+ } else {
+ elem.appendChild(child);
+ }
+ });
+ }
+ }
+};
+
+/**
+ * @param {HTMLElement} elem
+ * @param {string} className
+ * @returns {boolean}
+ */
+const hasClass = (elem, className) => {
+ if (!className) {
+ return false;
+ }
+ const classList = className.split(/\s+/);
+ for (let i = 0; i < classList.length; i++) {
+ if (!elem.classList.contains(classList[i])) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
+ * @param {HTMLElement} elem
+ * @param {SweetAlertOptions} params
+ */
+const removeCustomClasses = (elem, params) => {
+ Array.from(elem.classList).forEach(className => {
+ if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
+ elem.classList.remove(className);
+ }
+ });
+};
+
+/**
+ * @param {HTMLElement} elem
+ * @param {SweetAlertOptions} params
+ * @param {string} className
+ */
+const applyCustomClass = (elem, params, className) => {
+ removeCustomClasses(elem, params);
+ if (!params.customClass) {
+ return;
+ }
+ const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
+ if (!customClass) {
+ return;
+ }
+ if (typeof customClass !== 'string' && !customClass.forEach) {
+ warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
+ return;
+ }
+ addClass(elem, customClass);
+};
+
+/**
+ * @param {HTMLElement} popup
+ * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
+ * @returns {HTMLInputElement | null}
+ */
+const getInput$1 = (popup, inputClass) => {
+ if (!inputClass) {
+ return null;
+ }
+ switch (inputClass) {
+ case 'select':
+ case 'textarea':
+ case 'file':
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
+ case 'checkbox':
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
+ case 'radio':
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
+ case 'range':
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
+ default:
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
+ }
+};
+
+/**
+ * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
+ */
+const focusInput = input => {
+ input.focus();
+
+ // place cursor at end of text in text input
+ if (input.type !== 'file') {
+ // http://stackoverflow.com/a/2345915
+ const val = input.value;
+ input.value = '';
+ input.value = val;
+ }
+};
+
+/**
+ * @param {HTMLElement | HTMLElement[] | null} target
+ * @param {string | string[] | readonly string[] | undefined} classList
+ * @param {boolean} condition
+ */
+const toggleClass = (target, classList, condition) => {
+ if (!target || !classList) {
+ return;
+ }
+ if (typeof classList === 'string') {
+ classList = classList.split(/\s+/).filter(Boolean);
+ }
+ classList.forEach(className => {
+ if (Array.isArray(target)) {
+ target.forEach(elem => {
+ if (condition) {
+ elem.classList.add(className);
+ } else {
+ elem.classList.remove(className);
+ }
+ });
+ } else {
+ if (condition) {
+ target.classList.add(className);
+ } else {
+ target.classList.remove(className);
+ }
+ }
+ });
+};
+
+/**
+ * @param {HTMLElement | HTMLElement[] | null} target
+ * @param {string | string[] | readonly string[] | undefined} classList
+ */
+const addClass = (target, classList) => {
+ toggleClass(target, classList, true);
+};
+
+/**
+ * @param {HTMLElement | HTMLElement[] | null} target
+ * @param {string | string[] | readonly string[] | undefined} classList
+ */
+const removeClass = (target, classList) => {
+ toggleClass(target, classList, false);
+};
+
+/**
+ * Get direct child of an element by class name
+ *
+ * @param {HTMLElement} elem
+ * @param {string} className
+ * @returns {HTMLElement | undefined}
+ */
+const getDirectChildByClass = (elem, className) => {
+ const children = Array.from(elem.children);
+ for (let i = 0; i < children.length; i++) {
+ const child = children[i];
+ if (child instanceof HTMLElement && hasClass(child, className)) {
+ return child;
+ }
+ }
+};
+
+/**
+ * @param {HTMLElement} elem
+ * @param {string} property
+ * @param {string | number | null | undefined} value
+ */
+const applyNumericalStyle = (elem, property, value) => {
+ if (value === `${parseInt(`${value}`)}`) {
+ value = parseInt(value);
+ }
+ if (value || parseInt(`${value}`) === 0) {
+ elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : value);
+ } else {
+ elem.style.removeProperty(property);
+ }
+};
+
+/**
+ * @param {HTMLElement | null} elem
+ * @param {string} display
+ */
+const show = (elem, display = 'flex') => {
+ if (!elem) {
+ return;
+ }
+ elem.style.display = display;
+};
+
+/**
+ * @param {HTMLElement | null} elem
+ */
+const hide = elem => {
+ if (!elem) {
+ return;
+ }
+ elem.style.display = 'none';
+};
+
+/**
+ * @param {HTMLElement | null} elem
+ * @param {string} display
+ */
+const showWhenInnerHtmlPresent = (elem, display = 'block') => {
+ if (!elem) {
+ return;
+ }
+ new MutationObserver(() => {
+ toggle(elem, elem.innerHTML, display);
+ }).observe(elem, {
+ childList: true,
+ subtree: true
+ });
+};
+
+/**
+ * @param {HTMLElement} parent
+ * @param {string} selector
+ * @param {string} property
+ * @param {string} value
+ */
+const setStyle = (parent, selector, property, value) => {
+ /** @type {HTMLElement | null} */
+ const el = parent.querySelector(selector);
+ if (el) {
+ el.style.setProperty(property, value);
+ }
+};
+
+/**
+ * @param {HTMLElement} elem
+ * @param {boolean | string | null | undefined} condition
+ * @param {string} display
+ */
+const toggle = (elem, condition, display = 'flex') => {
+ if (condition) {
+ show(elem, display);
+ } else {
+ hide(elem);
+ }
+};
+
+/**
+ * borrowed from jquery $(elem).is(':visible') implementation
+ *
+ * @param {HTMLElement | null} elem
+ * @returns {boolean}
+ */
+const isVisible$1 = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
+
+/**
+ * @returns {boolean}
+ */
+const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
+
+/**
+ * @param {HTMLElement} elem
+ * @returns {boolean}
+ */
+const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight);
+
+/**
+ * @param {HTMLElement} element
+ * @param {HTMLElement} stopElement
+ * @returns {boolean}
+ */
+const selfOrParentIsScrollable = (element, stopElement) => {
+ let parent = element;
+ while (parent && parent !== stopElement) {
+ if (isScrollable(parent)) {
+ return true;
+ }
+ parent = parent.parentElement;
+ }
+ return false;
+};
+
+/**
+ * borrowed from https://stackoverflow.com/a/46352119
+ *
+ * @param {HTMLElement} elem
+ * @returns {boolean}
+ */
+const hasCssAnimation = elem => {
+ const style = window.getComputedStyle(elem);
+ const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
+ const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
+ return animDuration > 0 || transDuration > 0;
+};
+
+/**
+ * @param {number} timer
+ * @param {boolean} reset
+ */
+const animateTimerProgressBar = (timer, reset = false) => {
+ const timerProgressBar = getTimerProgressBar();
+ if (!timerProgressBar) {
+ return;
+ }
+ if (isVisible$1(timerProgressBar)) {
+ if (reset) {
+ timerProgressBar.style.transition = 'none';
+ timerProgressBar.style.width = '100%';
+ }
+ setTimeout(() => {
+ timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
+ timerProgressBar.style.width = '0%';
+ }, 10);
+ }
+};
+const stopTimerProgressBar = () => {
+ const timerProgressBar = getTimerProgressBar();
+ if (!timerProgressBar) {
+ return;
+ }
+ const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
+ timerProgressBar.style.removeProperty('transition');
+ timerProgressBar.style.width = '100%';
+ const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
+ const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
+ timerProgressBar.style.width = `${timerProgressBarPercent}%`;
+};
+
+/**
+ * Detect Node env
+ *
+ * @returns {boolean}
+ */
+const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
+
+const sweetHTML = `
+
+`.replace(/(^|\n)\s*/g, '');
+
+/**
+ * @returns {boolean}
+ */
+const resetOldContainer = () => {
+ const oldContainer = getContainer();
+ if (!oldContainer) {
+ return false;
+ }
+ oldContainer.remove();
+ removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]);
+ return true;
+};
+const resetValidationMessage$1 = () => {
+ globalState.currentInstance.resetValidationMessage();
+};
+const addInputChangeListeners = () => {
+ const popup = getPopup();
+ const input = getDirectChildByClass(popup, swalClasses.input);
+ const file = getDirectChildByClass(popup, swalClasses.file);
+ /** @type {HTMLInputElement} */
+ const range = popup.querySelector(`.${swalClasses.range} input`);
+ /** @type {HTMLOutputElement} */
+ const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
+ const select = getDirectChildByClass(popup, swalClasses.select);
+ /** @type {HTMLInputElement} */
+ const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
+ const textarea = getDirectChildByClass(popup, swalClasses.textarea);
+ input.oninput = resetValidationMessage$1;
+ file.onchange = resetValidationMessage$1;
+ select.onchange = resetValidationMessage$1;
+ checkbox.onchange = resetValidationMessage$1;
+ textarea.oninput = resetValidationMessage$1;
+ range.oninput = () => {
+ resetValidationMessage$1();
+ rangeOutput.value = range.value;
+ };
+ range.onchange = () => {
+ resetValidationMessage$1();
+ rangeOutput.value = range.value;
+ };
+};
+
+/**
+ * @param {string | HTMLElement} target
+ * @returns {HTMLElement}
+ */
+const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;
+
+/**
+ * @param {SweetAlertOptions} params
+ */
+const setupAccessibility = params => {
+ const popup = getPopup();
+ popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
+ popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
+ if (!params.toast) {
+ popup.setAttribute('aria-modal', 'true');
+ }
+};
+
+/**
+ * @param {HTMLElement} targetElement
+ */
+const setupRTL = targetElement => {
+ if (window.getComputedStyle(targetElement).direction === 'rtl') {
+ addClass(getContainer(), swalClasses.rtl);
+ }
+};
+
+/**
+ * Add modal + backdrop to DOM
+ *
+ * @param {SweetAlertOptions} params
+ */
+const init = params => {
+ // Clean up the old popup container if it exists
+ const oldContainerExisted = resetOldContainer();
+ if (isNodeEnv()) {
+ error('SweetAlert2 requires document to initialize');
+ return;
+ }
+ const container = document.createElement('div');
+ container.className = swalClasses.container;
+ if (oldContainerExisted) {
+ addClass(container, swalClasses['no-transition']);
+ }
+ setInnerHtml(container, sweetHTML);
+ container.dataset['swal2Theme'] = params.theme;
+ const targetElement = getTarget(params.target);
+ targetElement.appendChild(container);
+ if (params.topLayer) {
+ container.setAttribute('popover', '');
+ container.showPopover();
+ }
+ setupAccessibility(params);
+ setupRTL(targetElement);
+ addInputChangeListeners();
+};
+
+/**
+ * @param {HTMLElement | object | string} param
+ * @param {HTMLElement} target
+ */
+const parseHtmlToContainer = (param, target) => {
+ // DOM element
+ if (param instanceof HTMLElement) {
+ target.appendChild(param);
+ }
+
+ // Object
+ else if (typeof param === 'object') {
+ handleObject(param, target);
+ }
+
+ // Plain string
+ else if (param) {
+ setInnerHtml(target, param);
+ }
+};
+
+/**
+ * @param {object} param
+ * @param {HTMLElement} target
+ */
+const handleObject = (param, target) => {
+ // JQuery element(s)
+ if (param.jquery) {
+ handleJqueryElem(target, param);
+ }
+
+ // For other objects use their string representation
+ else {
+ setInnerHtml(target, param.toString());
+ }
+};
+
+/**
+ * @param {HTMLElement} target
+ * @param {object} elem
+ */
+const handleJqueryElem = (target, elem) => {
+ target.textContent = '';
+ if (0 in elem) {
+ for (let i = 0; i in elem; i++) {
+ target.appendChild(elem[i].cloneNode(true));
+ }
+ } else {
+ target.appendChild(elem.cloneNode(true));
+ }
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderActions = (instance, params) => {
+ const actions = getActions();
+ const loader = getLoader();
+ if (!actions || !loader) {
+ return;
+ }
+
+ // Actions (buttons) wrapper
+ if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
+ hide(actions);
+ } else {
+ show(actions);
+ }
+
+ // Custom class
+ applyCustomClass(actions, params, 'actions');
+
+ // Render all the buttons
+ renderButtons(actions, loader, params);
+
+ // Loader
+ setInnerHtml(loader, params.loaderHtml || '');
+ applyCustomClass(loader, params, 'loader');
+};
+
+/**
+ * @param {HTMLElement} actions
+ * @param {HTMLElement} loader
+ * @param {SweetAlertOptions} params
+ */
+function renderButtons(actions, loader, params) {
+ const confirmButton = getConfirmButton();
+ const denyButton = getDenyButton();
+ const cancelButton = getCancelButton();
+ if (!confirmButton || !denyButton || !cancelButton) {
+ return;
+ }
+
+ // Render buttons
+ renderButton(confirmButton, 'confirm', params);
+ renderButton(denyButton, 'deny', params);
+ renderButton(cancelButton, 'cancel', params);
+ handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
+ if (params.reverseButtons) {
+ if (params.toast) {
+ actions.insertBefore(cancelButton, confirmButton);
+ actions.insertBefore(denyButton, confirmButton);
+ } else {
+ actions.insertBefore(cancelButton, loader);
+ actions.insertBefore(denyButton, loader);
+ actions.insertBefore(confirmButton, loader);
+ }
+ }
+}
+
+/**
+ * @param {HTMLElement} confirmButton
+ * @param {HTMLElement} denyButton
+ * @param {HTMLElement} cancelButton
+ * @param {SweetAlertOptions} params
+ */
+function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
+ if (!params.buttonsStyling) {
+ removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
+ return;
+ }
+ addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
+
+ // Apply custom background colors to action buttons
+ if (params.confirmButtonColor) {
+ confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
+ }
+ if (params.denyButtonColor) {
+ denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
+ }
+ if (params.cancelButtonColor) {
+ cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
+ }
+
+ // Apply the outline color to action buttons
+ applyOutlineColor(confirmButton);
+ applyOutlineColor(denyButton);
+ applyOutlineColor(cancelButton);
+}
+
+/**
+ * @param {HTMLElement} button
+ */
+function applyOutlineColor(button) {
+ const buttonStyle = window.getComputedStyle(button);
+ if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
+ // If the button already has a custom outline color, no need to change it
+ return;
+ }
+ const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
+ button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
+}
+
+/**
+ * @param {HTMLElement} button
+ * @param {'confirm' | 'deny' | 'cancel'} buttonType
+ * @param {SweetAlertOptions} params
+ */
+function renderButton(button, buttonType, params) {
+ const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
+ toggle(button, params[`show${buttonName}Button`], 'inline-block');
+ setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
+ button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
+
+ // Add buttons custom classes
+ button.className = swalClasses[buttonType];
+ applyCustomClass(button, params, `${buttonType}Button`);
+}
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderCloseButton = (instance, params) => {
+ const closeButton = getCloseButton();
+ if (!closeButton) {
+ return;
+ }
+ setInnerHtml(closeButton, params.closeButtonHtml || '');
+
+ // Custom class
+ applyCustomClass(closeButton, params, 'closeButton');
+ toggle(closeButton, params.showCloseButton);
+ closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderContainer = (instance, params) => {
+ const container = getContainer();
+ if (!container) {
+ return;
+ }
+ handleBackdropParam(container, params.backdrop);
+ handlePositionParam(container, params.position);
+ handleGrowParam(container, params.grow);
+
+ // Custom class
+ applyCustomClass(container, params, 'container');
+};
+
+/**
+ * @param {HTMLElement} container
+ * @param {SweetAlertOptions['backdrop']} backdrop
+ */
+function handleBackdropParam(container, backdrop) {
+ if (typeof backdrop === 'string') {
+ container.style.background = backdrop;
+ } else if (!backdrop) {
+ addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
+ }
+}
+
+/**
+ * @param {HTMLElement} container
+ * @param {SweetAlertOptions['position']} position
+ */
+function handlePositionParam(container, position) {
+ if (!position) {
+ return;
+ }
+ if (position in swalClasses) {
+ addClass(container, swalClasses[position]);
+ } else {
+ warn('The "position" parameter is not valid, defaulting to "center"');
+ addClass(container, swalClasses.center);
+ }
+}
+
+/**
+ * @param {HTMLElement} container
+ * @param {SweetAlertOptions['grow']} grow
+ */
+function handleGrowParam(container, grow) {
+ if (!grow) {
+ return;
+ }
+ addClass(container, swalClasses[`grow-${grow}`]);
+}
+
+/**
+ * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
+ * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
+ * This is the approach that Babel will probably take to implement private methods/fields
+ * https://github.com/tc39/proposal-private-methods
+ * https://github.com/babel/babel/pull/7555
+ * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
+ * then we can use that language feature.
+ */
+
+var privateProps = {
+ innerParams: new WeakMap(),
+ domCache: new WeakMap()
+};
+
+///
+
+
+/** @type {InputClass[]} */
+const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderInput = (instance, params) => {
+ const popup = getPopup();
+ if (!popup) {
+ return;
+ }
+ const innerParams = privateProps.innerParams.get(instance);
+ const rerender = !innerParams || params.input !== innerParams.input;
+ inputClasses.forEach(inputClass => {
+ const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
+ if (!inputContainer) {
+ return;
+ }
+
+ // set attributes
+ setAttributes(inputClass, params.inputAttributes);
+
+ // set class
+ inputContainer.className = swalClasses[inputClass];
+ if (rerender) {
+ hide(inputContainer);
+ }
+ });
+ if (params.input) {
+ if (rerender) {
+ showInput(params);
+ }
+ // set custom class
+ setCustomClass(params);
+ }
+};
+
+/**
+ * @param {SweetAlertOptions} params
+ */
+const showInput = params => {
+ if (!params.input) {
+ return;
+ }
+ if (!renderInputType[params.input]) {
+ error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
+ return;
+ }
+ const inputContainer = getInputContainer(params.input);
+ if (!inputContainer) {
+ return;
+ }
+ const input = renderInputType[params.input](inputContainer, params);
+ show(inputContainer);
+
+ // input autofocus
+ if (params.inputAutoFocus) {
+ setTimeout(() => {
+ focusInput(input);
+ });
+ }
+};
+
+/**
+ * @param {HTMLInputElement} input
+ */
+const removeAttributes = input => {
+ for (let i = 0; i < input.attributes.length; i++) {
+ const attrName = input.attributes[i].name;
+ if (!['id', 'type', 'value', 'style'].includes(attrName)) {
+ input.removeAttribute(attrName);
+ }
+ }
+};
+
+/**
+ * @param {InputClass} inputClass
+ * @param {SweetAlertOptions['inputAttributes']} inputAttributes
+ */
+const setAttributes = (inputClass, inputAttributes) => {
+ const popup = getPopup();
+ if (!popup) {
+ return;
+ }
+ const input = getInput$1(popup, inputClass);
+ if (!input) {
+ return;
+ }
+ removeAttributes(input);
+ for (const attr in inputAttributes) {
+ input.setAttribute(attr, inputAttributes[attr]);
+ }
+};
+
+/**
+ * @param {SweetAlertOptions} params
+ */
+const setCustomClass = params => {
+ if (!params.input) {
+ return;
+ }
+ const inputContainer = getInputContainer(params.input);
+ if (inputContainer) {
+ applyCustomClass(inputContainer, params, 'input');
+ }
+};
+
+/**
+ * @param {HTMLInputElement | HTMLTextAreaElement} input
+ * @param {SweetAlertOptions} params
+ */
+const setInputPlaceholder = (input, params) => {
+ if (!input.placeholder && params.inputPlaceholder) {
+ input.placeholder = params.inputPlaceholder;
+ }
+};
+
+/**
+ * @param {Input} input
+ * @param {Input} prependTo
+ * @param {SweetAlertOptions} params
+ */
+const setInputLabel = (input, prependTo, params) => {
+ if (params.inputLabel) {
+ const label = document.createElement('label');
+ const labelClass = swalClasses['input-label'];
+ label.setAttribute('for', input.id);
+ label.className = labelClass;
+ if (typeof params.customClass === 'object') {
+ addClass(label, params.customClass.inputLabel);
+ }
+ label.innerText = params.inputLabel;
+ prependTo.insertAdjacentElement('beforebegin', label);
+ }
+};
+
+/**
+ * @param {SweetAlertInput} inputType
+ * @returns {HTMLElement | undefined}
+ */
+const getInputContainer = inputType => {
+ const popup = getPopup();
+ if (!popup) {
+ return;
+ }
+ return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
+};
+
+/**
+ * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
+ * @param {SweetAlertOptions['inputValue']} inputValue
+ */
+const checkAndSetInputValue = (input, inputValue) => {
+ if (['string', 'number'].includes(typeof inputValue)) {
+ input.value = `${inputValue}`;
+ } else if (!isPromise(inputValue)) {
+ warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
+ }
+};
+
+/** @type {Record Input>} */
+const renderInputType = {};
+
+/**
+ * @param {HTMLInputElement} input
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLInputElement}
+ */
+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} */
+(input, params) => {
+ checkAndSetInputValue(input, params.inputValue);
+ setInputLabel(input, input, params);
+ setInputPlaceholder(input, params);
+ input.type = params.input;
+ return input;
+};
+
+/**
+ * @param {HTMLInputElement} input
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLInputElement}
+ */
+renderInputType.file = (input, params) => {
+ setInputLabel(input, input, params);
+ setInputPlaceholder(input, params);
+ return input;
+};
+
+/**
+ * @param {HTMLInputElement} range
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLInputElement}
+ */
+renderInputType.range = (range, params) => {
+ const rangeInput = range.querySelector('input');
+ const rangeOutput = range.querySelector('output');
+ checkAndSetInputValue(rangeInput, params.inputValue);
+ rangeInput.type = params.input;
+ checkAndSetInputValue(rangeOutput, params.inputValue);
+ setInputLabel(rangeInput, range, params);
+ return range;
+};
+
+/**
+ * @param {HTMLSelectElement} select
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLSelectElement}
+ */
+renderInputType.select = (select, params) => {
+ select.textContent = '';
+ if (params.inputPlaceholder) {
+ const placeholder = document.createElement('option');
+ setInnerHtml(placeholder, params.inputPlaceholder);
+ placeholder.value = '';
+ placeholder.disabled = true;
+ placeholder.selected = true;
+ select.appendChild(placeholder);
+ }
+ setInputLabel(select, select, params);
+ return select;
+};
+
+/**
+ * @param {HTMLInputElement} radio
+ * @returns {HTMLInputElement}
+ */
+renderInputType.radio = radio => {
+ radio.textContent = '';
+ return radio;
+};
+
+/**
+ * @param {HTMLLabelElement} checkboxContainer
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLInputElement}
+ */
+renderInputType.checkbox = (checkboxContainer, params) => {
+ const checkbox = getInput$1(getPopup(), 'checkbox');
+ checkbox.value = '1';
+ checkbox.checked = Boolean(params.inputValue);
+ const label = checkboxContainer.querySelector('span');
+ setInnerHtml(label, params.inputPlaceholder || params.inputLabel);
+ return checkbox;
+};
+
+/**
+ * @param {HTMLTextAreaElement} textarea
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLTextAreaElement}
+ */
+renderInputType.textarea = (textarea, params) => {
+ checkAndSetInputValue(textarea, params.inputValue);
+ setInputPlaceholder(textarea, params);
+ setInputLabel(textarea, textarea, params);
+
+ /**
+ * @param {HTMLElement} el
+ * @returns {number}
+ */
+ const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
+
+ // https://github.com/sweetalert2/sweetalert2/issues/2291
+ setTimeout(() => {
+ // https://github.com/sweetalert2/sweetalert2/issues/1699
+ if ('MutationObserver' in window) {
+ const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
+ const textareaResizeHandler = () => {
+ // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
+ if (!document.body.contains(textarea)) {
+ return;
+ }
+ const textareaWidth = textarea.offsetWidth + getMargin(textarea);
+ if (textareaWidth > initialPopupWidth) {
+ getPopup().style.width = `${textareaWidth}px`;
+ } else {
+ applyNumericalStyle(getPopup(), 'width', params.width);
+ }
+ };
+ new MutationObserver(textareaResizeHandler).observe(textarea, {
+ attributes: true,
+ attributeFilter: ['style']
+ });
+ }
+ });
+ return textarea;
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderContent = (instance, params) => {
+ const htmlContainer = getHtmlContainer();
+ if (!htmlContainer) {
+ return;
+ }
+ showWhenInnerHtmlPresent(htmlContainer);
+ applyCustomClass(htmlContainer, params, 'htmlContainer');
+
+ // Content as HTML
+ if (params.html) {
+ parseHtmlToContainer(params.html, htmlContainer);
+ show(htmlContainer, 'block');
+ }
+
+ // Content as plain text
+ else if (params.text) {
+ htmlContainer.textContent = params.text;
+ show(htmlContainer, 'block');
+ }
+
+ // No content
+ else {
+ hide(htmlContainer);
+ }
+ renderInput(instance, params);
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderFooter = (instance, params) => {
+ const footer = getFooter();
+ if (!footer) {
+ return;
+ }
+ showWhenInnerHtmlPresent(footer);
+ toggle(footer, Boolean(params.footer), 'block');
+ if (params.footer) {
+ parseHtmlToContainer(params.footer, footer);
+ }
+
+ // Custom class
+ applyCustomClass(footer, params, 'footer');
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderIcon = (instance, params) => {
+ const innerParams = privateProps.innerParams.get(instance);
+ const icon = getIcon();
+ if (!icon) {
+ return;
+ }
+
+ // if the given icon already rendered, apply the styling without re-rendering the icon
+ if (innerParams && params.icon === innerParams.icon) {
+ // Custom or default content
+ setContent(icon, params);
+ applyStyles(icon, params);
+ return;
+ }
+ if (!params.icon && !params.iconHtml) {
+ hide(icon);
+ return;
+ }
+ if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
+ error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
+ hide(icon);
+ return;
+ }
+ show(icon);
+
+ // Custom or default content
+ setContent(icon, params);
+ applyStyles(icon, params);
+
+ // Animate icon
+ addClass(icon, params.showClass && params.showClass.icon);
+
+ // Re-adjust the success icon on system theme change
+ const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
+ colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
+};
+
+/**
+ * @param {HTMLElement} icon
+ * @param {SweetAlertOptions} params
+ */
+const applyStyles = (icon, params) => {
+ for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
+ if (params.icon !== iconType) {
+ removeClass(icon, iconClassName);
+ }
+ }
+ addClass(icon, params.icon && iconTypes[params.icon]);
+
+ // Icon color
+ setColor(icon, params);
+
+ // Success icon background color
+ adjustSuccessIconBackgroundColor();
+
+ // Custom class
+ applyCustomClass(icon, params, 'icon');
+};
+
+// Adjust success icon background color to match the popup background color
+const adjustSuccessIconBackgroundColor = () => {
+ const popup = getPopup();
+ if (!popup) {
+ return;
+ }
+ const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
+ /** @type {NodeListOf} */
+ const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
+ for (let i = 0; i < successIconParts.length; i++) {
+ successIconParts[i].style.backgroundColor = popupBackgroundColor;
+ }
+};
+
+/**
+ *
+ * @param {SweetAlertOptions} params
+ * @returns {string}
+ */
+const successIconHtml = params => `
+ ${params.animation ? '' : ''}
+
+
+ ${params.animation ? '' : ''}
+ ${params.animation ? '' : ''}
+`;
+const errorIconHtml = `
+
+
+
+
+`;
+
+/**
+ * @param {HTMLElement} icon
+ * @param {SweetAlertOptions} params
+ */
+const setContent = (icon, params) => {
+ if (!params.icon && !params.iconHtml) {
+ return;
+ }
+ let oldContent = icon.innerHTML;
+ let newContent = '';
+ if (params.iconHtml) {
+ newContent = iconContent(params.iconHtml);
+ } else if (params.icon === 'success') {
+ newContent = successIconHtml(params);
+ oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
+ } else if (params.icon === 'error') {
+ newContent = errorIconHtml;
+ } else if (params.icon) {
+ const defaultIconHtml = {
+ question: '?',
+ warning: '!',
+ info: 'i'
+ };
+ newContent = iconContent(defaultIconHtml[params.icon]);
+ }
+ if (oldContent.trim() !== newContent.trim()) {
+ setInnerHtml(icon, newContent);
+ }
+};
+
+/**
+ * @param {HTMLElement} icon
+ * @param {SweetAlertOptions} params
+ */
+const setColor = (icon, params) => {
+ if (!params.iconColor) {
+ return;
+ }
+ icon.style.color = params.iconColor;
+ icon.style.borderColor = params.iconColor;
+ for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
+ setStyle(icon, sel, 'background-color', params.iconColor);
+ }
+ setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
+};
+
+/**
+ * @param {string} content
+ * @returns {string}
+ */
+const iconContent = content => `${content}
`;
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderImage = (instance, params) => {
+ const image = getImage();
+ if (!image) {
+ return;
+ }
+ if (!params.imageUrl) {
+ hide(image);
+ return;
+ }
+ show(image, '');
+
+ // Src, alt
+ image.setAttribute('src', params.imageUrl);
+ image.setAttribute('alt', params.imageAlt || '');
+
+ // Width, height
+ applyNumericalStyle(image, 'width', params.imageWidth);
+ applyNumericalStyle(image, 'height', params.imageHeight);
+
+ // Class
+ image.className = swalClasses.image;
+ applyCustomClass(image, params, 'image');
+};
+
+let dragging = false;
+let mousedownX = 0;
+let mousedownY = 0;
+let initialX = 0;
+let initialY = 0;
+
+/**
+ * @param {HTMLElement} popup
+ */
+const addDraggableListeners = popup => {
+ popup.addEventListener('mousedown', down);
+ document.body.addEventListener('mousemove', move);
+ popup.addEventListener('mouseup', up);
+ popup.addEventListener('touchstart', down);
+ document.body.addEventListener('touchmove', move);
+ popup.addEventListener('touchend', up);
+};
+
+/**
+ * @param {HTMLElement} popup
+ */
+const removeDraggableListeners = popup => {
+ popup.removeEventListener('mousedown', down);
+ document.body.removeEventListener('mousemove', move);
+ popup.removeEventListener('mouseup', up);
+ popup.removeEventListener('touchstart', down);
+ document.body.removeEventListener('touchmove', move);
+ popup.removeEventListener('touchend', up);
+};
+
+/**
+ * @param {MouseEvent | TouchEvent} event
+ */
+const down = event => {
+ const popup = getPopup();
+ if (event.target === popup || getIcon().contains(/** @type {HTMLElement} */event.target)) {
+ dragging = true;
+ const clientXY = getClientXY(event);
+ mousedownX = clientXY.clientX;
+ mousedownY = clientXY.clientY;
+ initialX = parseInt(popup.style.insetInlineStart) || 0;
+ initialY = parseInt(popup.style.insetBlockStart) || 0;
+ addClass(popup, 'swal2-dragging');
+ }
+};
+
+/**
+ * @param {MouseEvent | TouchEvent} event
+ */
+const move = event => {
+ const popup = getPopup();
+ if (dragging) {
+ let {
+ clientX,
+ clientY
+ } = getClientXY(event);
+ popup.style.insetInlineStart = `${initialX + (clientX - mousedownX)}px`;
+ popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
+ }
+};
+const up = () => {
+ const popup = getPopup();
+ dragging = false;
+ removeClass(popup, 'swal2-dragging');
+};
+
+/**
+ * @param {MouseEvent | TouchEvent} event
+ * @returns {{ clientX: number, clientY: number }}
+ */
+const getClientXY = event => {
+ let clientX = 0,
+ clientY = 0;
+ if (event.type.startsWith('mouse')) {
+ clientX = /** @type {MouseEvent} */event.clientX;
+ clientY = /** @type {MouseEvent} */event.clientY;
+ } else if (event.type.startsWith('touch')) {
+ clientX = /** @type {TouchEvent} */event.touches[0].clientX;
+ clientY = /** @type {TouchEvent} */event.touches[0].clientY;
+ }
+ return {
+ clientX,
+ clientY
+ };
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderPopup = (instance, params) => {
+ const container = getContainer();
+ const popup = getPopup();
+ if (!container || !popup) {
+ return;
+ }
+
+ // Width
+ // https://github.com/sweetalert2/sweetalert2/issues/2170
+ if (params.toast) {
+ applyNumericalStyle(container, 'width', params.width);
+ popup.style.width = '100%';
+ const loader = getLoader();
+ if (loader) {
+ popup.insertBefore(loader, getIcon());
+ }
+ } else {
+ applyNumericalStyle(popup, 'width', params.width);
+ }
+
+ // Padding
+ applyNumericalStyle(popup, 'padding', params.padding);
+
+ // Color
+ if (params.color) {
+ popup.style.color = params.color;
+ }
+
+ // Background
+ if (params.background) {
+ popup.style.background = params.background;
+ }
+ hide(getValidationMessage());
+
+ // Classes
+ addClasses$1(popup, params);
+ if (params.draggable && !params.toast) {
+ addClass(popup, swalClasses.draggable);
+ addDraggableListeners(popup);
+ } else {
+ removeClass(popup, swalClasses.draggable);
+ removeDraggableListeners(popup);
+ }
+};
+
+/**
+ * @param {HTMLElement} popup
+ * @param {SweetAlertOptions} params
+ */
+const addClasses$1 = (popup, params) => {
+ const showClass = params.showClass || {};
+ // Default Class + showClass when updating Swal.update({})
+ popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
+ if (params.toast) {
+ addClass([document.documentElement, document.body], swalClasses['toast-shown']);
+ addClass(popup, swalClasses.toast);
+ } else {
+ addClass(popup, swalClasses.modal);
+ }
+
+ // Custom class
+ applyCustomClass(popup, params, 'popup');
+ // TODO: remove in the next major
+ if (typeof params.customClass === 'string') {
+ addClass(popup, params.customClass);
+ }
+
+ // Icon class (#1842)
+ if (params.icon) {
+ addClass(popup, swalClasses[`icon-${params.icon}`]);
+ }
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderProgressSteps = (instance, params) => {
+ const progressStepsContainer = getProgressSteps();
+ if (!progressStepsContainer) {
+ return;
+ }
+ const {
+ progressSteps,
+ currentProgressStep
+ } = params;
+ if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
+ hide(progressStepsContainer);
+ return;
+ }
+ show(progressStepsContainer);
+ progressStepsContainer.textContent = '';
+ if (currentProgressStep >= progressSteps.length) {
+ warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
+ }
+ progressSteps.forEach((step, index) => {
+ const stepEl = createStepElement(step);
+ progressStepsContainer.appendChild(stepEl);
+ if (index === currentProgressStep) {
+ addClass(stepEl, swalClasses['active-progress-step']);
+ }
+ if (index !== progressSteps.length - 1) {
+ const lineEl = createLineElement(params);
+ progressStepsContainer.appendChild(lineEl);
+ }
+ });
+};
+
+/**
+ * @param {string} step
+ * @returns {HTMLLIElement}
+ */
+const createStepElement = step => {
+ const stepEl = document.createElement('li');
+ addClass(stepEl, swalClasses['progress-step']);
+ setInnerHtml(stepEl, step);
+ return stepEl;
+};
+
+/**
+ * @param {SweetAlertOptions} params
+ * @returns {HTMLLIElement}
+ */
+const createLineElement = params => {
+ const lineEl = document.createElement('li');
+ addClass(lineEl, swalClasses['progress-step-line']);
+ if (params.progressStepsDistance) {
+ applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
+ }
+ return lineEl;
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const renderTitle = (instance, params) => {
+ const title = getTitle();
+ if (!title) {
+ return;
+ }
+ showWhenInnerHtmlPresent(title);
+ toggle(title, Boolean(params.title || params.titleText), 'block');
+ if (params.title) {
+ parseHtmlToContainer(params.title, title);
+ }
+ if (params.titleText) {
+ title.innerText = params.titleText;
+ }
+
+ // Custom class
+ applyCustomClass(title, params, 'title');
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const render = (instance, params) => {
+ renderPopup(instance, params);
+ renderContainer(instance, params);
+ renderProgressSteps(instance, params);
+ renderIcon(instance, params);
+ renderImage(instance, params);
+ renderTitle(instance, params);
+ renderCloseButton(instance, params);
+ renderContent(instance, params);
+ renderActions(instance, params);
+ renderFooter(instance, params);
+ const popup = getPopup();
+ if (typeof params.didRender === 'function' && popup) {
+ params.didRender(popup);
+ }
+ globalState.eventEmitter.emit('didRender', popup);
+};
+
+/*
+ * Global function to determine if SweetAlert2 popup is shown
+ */
+const isVisible = () => {
+ return isVisible$1(getPopup());
+};
+
+/*
+ * Global function to click 'Confirm' button
+ */
+const clickConfirm = () => {
+ var _dom$getConfirmButton;
+ return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
+};
+
+/*
+ * Global function to click 'Deny' button
+ */
+const clickDeny = () => {
+ var _dom$getDenyButton;
+ return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
+};
+
+/*
+ * Global function to click 'Cancel' button
+ */
+const clickCancel = () => {
+ var _dom$getCancelButton;
+ return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
+};
+
+/** @type {Record} */
+const DismissReason = Object.freeze({
+ cancel: 'cancel',
+ backdrop: 'backdrop',
+ close: 'close',
+ esc: 'esc',
+ timer: 'timer'
+});
+
+/**
+ * @param {GlobalState} globalState
+ */
+const removeKeydownHandler = globalState => {
+ if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
+ globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
+ capture: globalState.keydownListenerCapture
+ });
+ globalState.keydownHandlerAdded = false;
+ }
+};
+
+/**
+ * @param {GlobalState} globalState
+ * @param {SweetAlertOptions} innerParams
+ * @param {(dismiss: DismissReason) => void} dismissWith
+ */
+const addKeydownHandler = (globalState, innerParams, dismissWith) => {
+ removeKeydownHandler(globalState);
+ if (!innerParams.toast) {
+ globalState.keydownHandler = e => keydownHandler(innerParams, e, dismissWith);
+ globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
+ globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
+ globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
+ capture: globalState.keydownListenerCapture
+ });
+ globalState.keydownHandlerAdded = true;
+ }
+};
+
+/**
+ * @param {number} index
+ * @param {number} increment
+ */
+const setFocus = (index, increment) => {
+ var _dom$getPopup;
+ const focusableElements = getFocusableElements();
+ // search for visible elements and select the next possible match
+ if (focusableElements.length) {
+ index = index + increment;
+
+ // shift + tab when .swal2-popup is focused
+ if (index === -2) {
+ index = focusableElements.length - 1;
+ }
+
+ // rollover to first item
+ if (index === focusableElements.length) {
+ index = 0;
+
+ // go to last item
+ } else if (index === -1) {
+ index = focusableElements.length - 1;
+ }
+ focusableElements[index].focus();
+ return;
+ }
+ // no visible focusable elements, focus the popup
+ (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
+};
+const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
+const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
+
+/**
+ * @param {SweetAlertOptions} innerParams
+ * @param {KeyboardEvent} event
+ * @param {(dismiss: DismissReason) => void} dismissWith
+ */
+const keydownHandler = (innerParams, event, dismissWith) => {
+ if (!innerParams) {
+ return; // This instance has already been destroyed
+ }
+
+ // Ignore keydown during IME composition
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
+ // https://github.com/sweetalert2/sweetalert2/issues/720
+ // https://github.com/sweetalert2/sweetalert2/issues/2406
+ if (event.isComposing || event.keyCode === 229) {
+ return;
+ }
+ if (innerParams.stopKeydownPropagation) {
+ event.stopPropagation();
+ }
+
+ // ENTER
+ if (event.key === 'Enter') {
+ handleEnter(event, innerParams);
+ }
+
+ // TAB
+ else if (event.key === 'Tab') {
+ handleTab(event);
+ }
+
+ // ARROWS - switch focus between buttons
+ else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
+ handleArrows(event.key);
+ }
+
+ // ESC
+ else if (event.key === 'Escape') {
+ handleEsc(event, innerParams, dismissWith);
+ }
+};
+
+/**
+ * @param {KeyboardEvent} event
+ * @param {SweetAlertOptions} innerParams
+ */
+const handleEnter = (event, innerParams) => {
+ // https://github.com/sweetalert2/sweetalert2/issues/2386
+ if (!callIfFunction(innerParams.allowEnterKey)) {
+ return;
+ }
+ const input = getInput$1(getPopup(), innerParams.input);
+ if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
+ if (['textarea', 'file'].includes(innerParams.input)) {
+ return; // do not submit
+ }
+ clickConfirm();
+ event.preventDefault();
+ }
+};
+
+/**
+ * @param {KeyboardEvent} event
+ */
+const handleTab = event => {
+ const targetElement = event.target;
+ const focusableElements = getFocusableElements();
+ let btnIndex = -1;
+ for (let i = 0; i < focusableElements.length; i++) {
+ if (targetElement === focusableElements[i]) {
+ btnIndex = i;
+ break;
+ }
+ }
+
+ // Cycle to the next button
+ if (!event.shiftKey) {
+ setFocus(btnIndex, 1);
+ }
+
+ // Cycle to the prev button
+ else {
+ setFocus(btnIndex, -1);
+ }
+ event.stopPropagation();
+ event.preventDefault();
+};
+
+/**
+ * @param {string} key
+ */
+const handleArrows = key => {
+ const actions = getActions();
+ const confirmButton = getConfirmButton();
+ const denyButton = getDenyButton();
+ const cancelButton = getCancelButton();
+ if (!actions || !confirmButton || !denyButton || !cancelButton) {
+ return;
+ }
+ /** @type HTMLElement[] */
+ const buttons = [confirmButton, denyButton, cancelButton];
+ if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
+ return;
+ }
+ const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
+ let buttonToFocus = document.activeElement;
+ if (!buttonToFocus) {
+ return;
+ }
+ for (let i = 0; i < actions.children.length; i++) {
+ buttonToFocus = buttonToFocus[sibling];
+ if (!buttonToFocus) {
+ return;
+ }
+ if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
+ break;
+ }
+ }
+ if (buttonToFocus instanceof HTMLButtonElement) {
+ buttonToFocus.focus();
+ }
+};
+
+/**
+ * @param {KeyboardEvent} event
+ * @param {SweetAlertOptions} innerParams
+ * @param {(dismiss: DismissReason) => void} dismissWith
+ */
+const handleEsc = (event, innerParams, dismissWith) => {
+ event.preventDefault();
+ if (callIfFunction(innerParams.allowEscapeKey)) {
+ dismissWith(DismissReason.esc);
+ }
+};
+
+/**
+ * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
+ * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
+ * This is the approach that Babel will probably take to implement private methods/fields
+ * https://github.com/tc39/proposal-private-methods
+ * https://github.com/babel/babel/pull/7555
+ * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
+ * then we can use that language feature.
+ */
+
+var privateMethods = {
+ swalPromiseResolve: new WeakMap(),
+ swalPromiseReject: new WeakMap()
+};
+
+// From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
+// Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
+// elements not within the active modal dialog will not be surfaced if a user opens a screen
+// reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
+
+const setAriaHidden = () => {
+ const container = getContainer();
+ const bodyChildren = Array.from(document.body.children);
+ bodyChildren.forEach(el => {
+ if (el.contains(container)) {
+ return;
+ }
+ if (el.hasAttribute('aria-hidden')) {
+ el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
+ }
+ el.setAttribute('aria-hidden', 'true');
+ });
+};
+const unsetAriaHidden = () => {
+ const bodyChildren = Array.from(document.body.children);
+ bodyChildren.forEach(el => {
+ if (el.hasAttribute('data-previous-aria-hidden')) {
+ el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
+ el.removeAttribute('data-previous-aria-hidden');
+ } else {
+ el.removeAttribute('aria-hidden');
+ }
+ });
+};
+
+// @ts-ignore
+const isSafariOrIOS = typeof window !== 'undefined' && !!window.GestureEvent; // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
+
+/**
+ * Fix iOS scrolling
+ * http://stackoverflow.com/q/39626302
+ */
+const iOSfix = () => {
+ if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
+ const offset = document.body.scrollTop;
+ document.body.style.top = `${offset * -1}px`;
+ addClass(document.body, swalClasses.iosfix);
+ lockBodyScroll();
+ }
+};
+
+/**
+ * https://github.com/sweetalert2/sweetalert2/issues/1246
+ */
+const lockBodyScroll = () => {
+ const container = getContainer();
+ if (!container) {
+ return;
+ }
+ /** @type {boolean} */
+ let preventTouchMove;
+ /**
+ * @param {TouchEvent} event
+ */
+ container.ontouchstart = event => {
+ preventTouchMove = shouldPreventTouchMove(event);
+ };
+ /**
+ * @param {TouchEvent} event
+ */
+ container.ontouchmove = event => {
+ if (preventTouchMove) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ };
+};
+
+/**
+ * @param {TouchEvent} event
+ * @returns {boolean}
+ */
+const shouldPreventTouchMove = event => {
+ const target = event.target;
+ const container = getContainer();
+ const htmlContainer = getHtmlContainer();
+ if (!container || !htmlContainer) {
+ return false;
+ }
+ if (isStylus(event) || isZoom(event)) {
+ return false;
+ }
+ if (target === container) {
+ return true;
+ }
+ if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
+ // #2823
+ target.tagName !== 'INPUT' &&
+ // #1603
+ target.tagName !== 'TEXTAREA' &&
+ // #2266
+ !(isScrollable(htmlContainer) &&
+ // #1944
+ htmlContainer.contains(target))) {
+ return true;
+ }
+ return false;
+};
+
+/**
+ * https://github.com/sweetalert2/sweetalert2/issues/1786
+ *
+ * @param {object} event
+ * @returns {boolean}
+ */
+const isStylus = event => {
+ return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';
+};
+
+/**
+ * https://github.com/sweetalert2/sweetalert2/issues/1891
+ *
+ * @param {TouchEvent} event
+ * @returns {boolean}
+ */
+const isZoom = event => {
+ return event.touches && event.touches.length > 1;
+};
+const undoIOSfix = () => {
+ if (hasClass(document.body, swalClasses.iosfix)) {
+ const offset = parseInt(document.body.style.top, 10);
+ removeClass(document.body, swalClasses.iosfix);
+ document.body.style.top = '';
+ document.body.scrollTop = offset * -1;
+ }
+};
+
+/**
+ * Measure scrollbar width for padding body during modal show/hide
+ * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
+ *
+ * @returns {number}
+ */
+const measureScrollbar = () => {
+ const scrollDiv = document.createElement('div');
+ scrollDiv.className = swalClasses['scrollbar-measure'];
+ document.body.appendChild(scrollDiv);
+ const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
+ document.body.removeChild(scrollDiv);
+ return scrollbarWidth;
+};
+
+/**
+ * Remember state in cases where opening and handling a modal will fiddle with it.
+ * @type {number | null}
+ */
+let previousBodyPadding = null;
+
+/**
+ * @param {string} initialBodyOverflow
+ */
+const replaceScrollbarWithPadding = initialBodyOverflow => {
+ // for queues, do not do this more than once
+ if (previousBodyPadding !== null) {
+ return;
+ }
+ // if the body has overflow
+ if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
+ ) {
+ // add padding so the content doesn't shift after removal of scrollbar
+ previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
+ document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
+ }
+};
+const undoReplaceScrollbarWithPadding = () => {
+ if (previousBodyPadding !== null) {
+ document.body.style.paddingRight = `${previousBodyPadding}px`;
+ previousBodyPadding = null;
+ }
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {HTMLElement} container
+ * @param {boolean} returnFocus
+ * @param {() => void} didClose
+ */
+function removePopupAndResetState(instance, container, returnFocus, didClose) {
+ if (isToast()) {
+ triggerDidCloseAndDispose(instance, didClose);
+ } else {
+ restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
+ removeKeydownHandler(globalState);
+ }
+
+ // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
+ // for some reason removing the container in Safari will scroll the document to bottom
+ if (isSafariOrIOS) {
+ container.setAttribute('style', 'display:none !important');
+ container.removeAttribute('class');
+ container.innerHTML = '';
+ } else {
+ container.remove();
+ }
+ if (isModal()) {
+ undoReplaceScrollbarWithPadding();
+ undoIOSfix();
+ unsetAriaHidden();
+ }
+ removeBodyClasses();
+}
+
+/**
+ * Remove SweetAlert2 classes from body
+ */
+function removeBodyClasses() {
+ removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
+}
+
+/**
+ * Instance method to close sweetAlert
+ *
+ * @param {SweetAlertResult | undefined} resolveValue
+ */
+function close(resolveValue) {
+ resolveValue = prepareResolveValue(resolveValue);
+ const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
+ const didClose = triggerClosePopup(this);
+ if (this.isAwaitingPromise) {
+ // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
+ if (!resolveValue.isDismissed) {
+ handleAwaitingPromise(this);
+ swalPromiseResolve(resolveValue);
+ }
+ } else if (didClose) {
+ // Resolve Swal promise
+ swalPromiseResolve(resolveValue);
+ }
+}
+const triggerClosePopup = instance => {
+ const popup = getPopup();
+ if (!popup) {
+ return false;
+ }
+ const innerParams = privateProps.innerParams.get(instance);
+ if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
+ return false;
+ }
+ removeClass(popup, innerParams.showClass.popup);
+ addClass(popup, innerParams.hideClass.popup);
+ const backdrop = getContainer();
+ removeClass(backdrop, innerParams.showClass.backdrop);
+ addClass(backdrop, innerParams.hideClass.backdrop);
+ handlePopupAnimation(instance, popup, innerParams);
+ return true;
+};
+
+/**
+ * @param {Error | string} error
+ */
+function rejectPromise(error) {
+ const rejectPromise = privateMethods.swalPromiseReject.get(this);
+ handleAwaitingPromise(this);
+ if (rejectPromise) {
+ // Reject Swal promise
+ rejectPromise(error);
+ }
+}
+
+/**
+ * @param {SweetAlert} instance
+ */
+const handleAwaitingPromise = instance => {
+ if (instance.isAwaitingPromise) {
+ delete instance.isAwaitingPromise;
+ // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
+ if (!privateProps.innerParams.get(instance)) {
+ instance._destroy();
+ }
+ }
+};
+
+/**
+ * @param {SweetAlertResult | undefined} resolveValue
+ * @returns {SweetAlertResult}
+ */
+const prepareResolveValue = resolveValue => {
+ // When user calls Swal.close()
+ if (typeof resolveValue === 'undefined') {
+ return {
+ isConfirmed: false,
+ isDenied: false,
+ isDismissed: true
+ };
+ }
+ return Object.assign({
+ isConfirmed: false,
+ isDenied: false,
+ isDismissed: false
+ }, resolveValue);
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {HTMLElement} popup
+ * @param {SweetAlertOptions} innerParams
+ */
+const handlePopupAnimation = (instance, popup, innerParams) => {
+ var _globalState$eventEmi;
+ const container = getContainer();
+ // If animation is supported, animate
+ const animationIsSupported = hasCssAnimation(popup);
+ if (typeof innerParams.willClose === 'function') {
+ innerParams.willClose(popup);
+ }
+ (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
+ if (animationIsSupported) {
+ animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
+ } else {
+ // Otherwise, remove immediately
+ removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
+ }
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {HTMLElement} popup
+ * @param {HTMLElement} container
+ * @param {boolean} returnFocus
+ * @param {() => void} didClose
+ */
+const animatePopup = (instance, popup, container, returnFocus, didClose) => {
+ globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
+ /**
+ * @param {AnimationEvent | TransitionEvent} e
+ */
+ const swalCloseAnimationFinished = function (e) {
+ if (e.target === popup) {
+ var _globalState$swalClos;
+ (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
+ delete globalState.swalCloseEventFinishedCallback;
+ popup.removeEventListener('animationend', swalCloseAnimationFinished);
+ popup.removeEventListener('transitionend', swalCloseAnimationFinished);
+ }
+ };
+ popup.addEventListener('animationend', swalCloseAnimationFinished);
+ popup.addEventListener('transitionend', swalCloseAnimationFinished);
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {() => void} didClose
+ */
+const triggerDidCloseAndDispose = (instance, didClose) => {
+ setTimeout(() => {
+ var _globalState$eventEmi2;
+ if (typeof didClose === 'function') {
+ didClose.bind(instance.params)();
+ }
+ (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
+ // instance might have been destroyed already
+ if (instance._destroy) {
+ instance._destroy();
+ }
+ });
+};
+
+/**
+ * Shows loader (spinner), this is useful with AJAX requests.
+ * By default the loader be shown instead of the "Confirm" button.
+ *
+ * @param {HTMLButtonElement | null} [buttonToReplace]
+ */
+const showLoading = buttonToReplace => {
+ let popup = getPopup();
+ if (!popup) {
+ new Swal();
+ }
+ popup = getPopup();
+ if (!popup) {
+ return;
+ }
+ const loader = getLoader();
+ if (isToast()) {
+ hide(getIcon());
+ } else {
+ replaceButton(popup, buttonToReplace);
+ }
+ show(loader);
+ popup.setAttribute('data-loading', 'true');
+ popup.setAttribute('aria-busy', 'true');
+ popup.focus();
+};
+
+/**
+ * @param {HTMLElement} popup
+ * @param {HTMLButtonElement | null} [buttonToReplace]
+ */
+const replaceButton = (popup, buttonToReplace) => {
+ const actions = getActions();
+ const loader = getLoader();
+ if (!actions || !loader) {
+ return;
+ }
+ if (!buttonToReplace && isVisible$1(getConfirmButton())) {
+ buttonToReplace = getConfirmButton();
+ }
+ show(actions);
+ if (buttonToReplace) {
+ hide(buttonToReplace);
+ loader.setAttribute('data-button-to-replace', buttonToReplace.className);
+ actions.insertBefore(loader, buttonToReplace);
+ }
+ addClass([popup, actions], swalClasses.loading);
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const handleInputOptionsAndValue = (instance, params) => {
+ if (params.input === 'select' || params.input === 'radio') {
+ handleInputOptions(instance, params);
+ } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
+ showLoading(getConfirmButton());
+ handleInputValue(instance, params);
+ }
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} innerParams
+ * @returns {SweetAlertInputValue}
+ */
+const getInputValue = (instance, innerParams) => {
+ const input = instance.getInput();
+ if (!input) {
+ return null;
+ }
+ switch (innerParams.input) {
+ case 'checkbox':
+ return getCheckboxValue(input);
+ case 'radio':
+ return getRadioValue(input);
+ case 'file':
+ return getFileValue(input);
+ default:
+ return innerParams.inputAutoTrim ? input.value.trim() : input.value;
+ }
+};
+
+/**
+ * @param {HTMLInputElement} input
+ * @returns {number}
+ */
+const getCheckboxValue = input => input.checked ? 1 : 0;
+
+/**
+ * @param {HTMLInputElement} input
+ * @returns {string | null}
+ */
+const getRadioValue = input => input.checked ? input.value : null;
+
+/**
+ * @param {HTMLInputElement} input
+ * @returns {FileList | File | null}
+ */
+const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const handleInputOptions = (instance, params) => {
+ const popup = getPopup();
+ if (!popup) {
+ return;
+ }
+ /**
+ * @param {*} inputOptions
+ */
+ const processInputOptions = inputOptions => {
+ if (params.input === 'select') {
+ populateSelectOptions(popup, formatInputOptions(inputOptions), params);
+ } else if (params.input === 'radio') {
+ populateRadioOptions(popup, formatInputOptions(inputOptions), params);
+ }
+ };
+ if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
+ showLoading(getConfirmButton());
+ asPromise(params.inputOptions).then(inputOptions => {
+ instance.hideLoading();
+ processInputOptions(inputOptions);
+ });
+ } else if (typeof params.inputOptions === 'object') {
+ processInputOptions(params.inputOptions);
+ } else {
+ error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
+ }
+};
+
+/**
+ * @param {SweetAlert} instance
+ * @param {SweetAlertOptions} params
+ */
+const handleInputValue = (instance, params) => {
+ const input = instance.getInput();
+ if (!input) {
+ return;
+ }
+ hide(input);
+ asPromise(params.inputValue).then(inputValue => {
+ input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
+ show(input);
+ input.focus();
+ instance.hideLoading();
+ }).catch(err => {
+ error(`Error in inputValue promise: ${err}`);
+ input.value = '';
+ show(input);
+ input.focus();
+ instance.hideLoading();
+ });
+};
+
+/**
+ * @param {HTMLElement} popup
+ * @param {InputOptionFlattened[]} inputOptions
+ * @param {SweetAlertOptions} params
+ */
+function populateSelectOptions(popup, inputOptions, params) {
+ const select = getDirectChildByClass(popup, swalClasses.select);
+ if (!select) {
+ return;
+ }
+ /**
+ * @param {HTMLElement} parent
+ * @param {string} optionLabel
+ * @param {string} optionValue
+ */
+ const renderOption = (parent, optionLabel, optionValue) => {
+ const option = document.createElement('option');
+ option.value = optionValue;
+ setInnerHtml(option, optionLabel);
+ option.selected = isSelected(optionValue, params.inputValue);
+ parent.appendChild(option);
+ };
+ inputOptions.forEach(inputOption => {
+ const optionValue = inputOption[0];
+ const optionLabel = inputOption[1];
+ // ',e.default=e.modalMarkup},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.OVERLAY,i='
';e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.ICON;e.errorIconMarkup=function(){var t=r+"--error",e=t+"__line";return'\n
\n '}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.CONTENT;e.contentMarkup='\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),r=o.default.BUTTON_CONTAINER,i=o.default.BUTTON,a=o.default.BUTTON_LOADER;e.buttonMarkup='\n
\n'},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),r=n(2),i=n(0),a=i.default.ICON,s=i.default.ICON_CUSTOM,c=["error","warning","success","info"],l={error:r.errorIconMarkup(),warning:r.warningIconMarkup(),success:r.successIconMarkup()},u=function(t,e){var n=a+"--"+t;e.classList.add(n);var o=l[t];o&&(e.innerHTML=o)},f=function(t,e){e.classList.add(s);var n=document.createElement("img");n.src=t,e.appendChild(n)},d=function(t){if(t){var e=o.injectElIntoModal(r.iconMarkup);c.includes(t)?u(t,e):f(t,e)}};e.default=d},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(2),r=n(4),i=function(t){navigator.userAgent.includes("AppleWebKit")&&(t.style.display="none",t.offsetHeight,t.style.display="")};e.initTitle=function(t){if(t){var e=r.injectElIntoModal(o.titleMarkup);e.textContent=t,i(e)}},e.initText=function(t){if(t){var e=document.createDocumentFragment();t.split("\n").forEach(function(t,n,o){e.appendChild(document.createTextNode(t)),n