easy-admin-rails 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17577,6 +17577,3078 @@ ${m = t3 ? m : H(m, ",")}
17577
17577
  }
17578
17578
  });
17579
17579
 
17580
+ // node_modules/sweetalert2/dist/sweetalert2.all.js
17581
+ var require_sweetalert2_all = __commonJS({
17582
+ "node_modules/sweetalert2/dist/sweetalert2.all.js"(exports, module) {
17583
+ (function(global, factory) {
17584
+ typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.Sweetalert2 = factory());
17585
+ })(exports, function() {
17586
+ "use strict";
17587
+ function _assertClassBrand(e, t, n) {
17588
+ if ("function" == typeof e ? e === t : e.has(t))
17589
+ return arguments.length < 3 ? t : n;
17590
+ throw new TypeError("Private element is not present on this object");
17591
+ }
17592
+ function _checkPrivateRedeclaration(e, t) {
17593
+ if (t.has(e))
17594
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
17595
+ }
17596
+ function _classPrivateFieldGet2(s, a) {
17597
+ return s.get(_assertClassBrand(s, a));
17598
+ }
17599
+ function _classPrivateFieldInitSpec(e, t, a) {
17600
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
17601
+ }
17602
+ function _classPrivateFieldSet2(s, a, r) {
17603
+ return s.set(_assertClassBrand(s, a), r), r;
17604
+ }
17605
+ const RESTORE_FOCUS_TIMEOUT = 100;
17606
+ const globalState = {};
17607
+ const focusPreviousActiveElement = () => {
17608
+ if (globalState.previousActiveElement instanceof HTMLElement) {
17609
+ globalState.previousActiveElement.focus();
17610
+ globalState.previousActiveElement = null;
17611
+ } else if (document.body) {
17612
+ document.body.focus();
17613
+ }
17614
+ };
17615
+ const restoreActiveElement = (returnFocus) => {
17616
+ return new Promise((resolve2) => {
17617
+ if (!returnFocus) {
17618
+ return resolve2();
17619
+ }
17620
+ const x = window.scrollX;
17621
+ const y = window.scrollY;
17622
+ globalState.restoreFocusTimeout = setTimeout(() => {
17623
+ focusPreviousActiveElement();
17624
+ resolve2();
17625
+ }, RESTORE_FOCUS_TIMEOUT);
17626
+ window.scrollTo(x, y);
17627
+ });
17628
+ };
17629
+ const swalPrefix = "swal2-";
17630
+ 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"];
17631
+ const swalClasses = classNames.reduce(
17632
+ (acc, className) => {
17633
+ acc[className] = swalPrefix + className;
17634
+ return acc;
17635
+ },
17636
+ /** @type {SwalClasses} */
17637
+ {}
17638
+ );
17639
+ const icons = ["success", "warning", "info", "question", "error"];
17640
+ const iconTypes = icons.reduce(
17641
+ (acc, icon) => {
17642
+ acc[icon] = swalPrefix + icon;
17643
+ return acc;
17644
+ },
17645
+ /** @type {SwalIcons} */
17646
+ {}
17647
+ );
17648
+ const consolePrefix = "SweetAlert2:";
17649
+ const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1);
17650
+ const warn = (message) => {
17651
+ console.warn(`${consolePrefix} ${typeof message === "object" ? message.join(" ") : message}`);
17652
+ };
17653
+ const error2 = (message) => {
17654
+ console.error(`${consolePrefix} ${message}`);
17655
+ };
17656
+ const previousWarnOnceMessages = [];
17657
+ const warnOnce = (message) => {
17658
+ if (!previousWarnOnceMessages.includes(message)) {
17659
+ previousWarnOnceMessages.push(message);
17660
+ warn(message);
17661
+ }
17662
+ };
17663
+ const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
17664
+ warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ""}`);
17665
+ };
17666
+ const callIfFunction = (arg) => typeof arg === "function" ? arg() : arg;
17667
+ const hasToPromiseFn = (arg) => arg && typeof arg.toPromise === "function";
17668
+ const asPromise = (arg) => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
17669
+ const isPromise = (arg) => arg && Promise.resolve(arg) === arg;
17670
+ const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
17671
+ const elementBySelector = (selectorString) => {
17672
+ const container = getContainer();
17673
+ return container ? container.querySelector(selectorString) : null;
17674
+ };
17675
+ const elementByClass = (className) => {
17676
+ return elementBySelector(`.${className}`);
17677
+ };
17678
+ const getPopup = () => elementByClass(swalClasses.popup);
17679
+ const getIcon = () => elementByClass(swalClasses.icon);
17680
+ const getIconContent = () => elementByClass(swalClasses["icon-content"]);
17681
+ const getTitle = () => elementByClass(swalClasses.title);
17682
+ const getHtmlContainer = () => elementByClass(swalClasses["html-container"]);
17683
+ const getImage = () => elementByClass(swalClasses.image);
17684
+ const getProgressSteps = () => elementByClass(swalClasses["progress-steps"]);
17685
+ const getValidationMessage = () => elementByClass(swalClasses["validation-message"]);
17686
+ const getConfirmButton = () => (
17687
+ /** @type {HTMLButtonElement} */
17688
+ elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`)
17689
+ );
17690
+ const getCancelButton = () => (
17691
+ /** @type {HTMLButtonElement} */
17692
+ elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`)
17693
+ );
17694
+ const getDenyButton = () => (
17695
+ /** @type {HTMLButtonElement} */
17696
+ elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`)
17697
+ );
17698
+ const getInputLabel = () => elementByClass(swalClasses["input-label"]);
17699
+ const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
17700
+ const getActions = () => elementByClass(swalClasses.actions);
17701
+ const getFooter = () => elementByClass(swalClasses.footer);
17702
+ const getTimerProgressBar = () => elementByClass(swalClasses["timer-progress-bar"]);
17703
+ const getCloseButton = () => elementByClass(swalClasses.close);
17704
+ const focusable = `
17705
+ a[href],
17706
+ area[href],
17707
+ input:not([disabled]),
17708
+ select:not([disabled]),
17709
+ textarea:not([disabled]),
17710
+ button:not([disabled]),
17711
+ iframe,
17712
+ object,
17713
+ embed,
17714
+ [tabindex="0"],
17715
+ [contenteditable],
17716
+ audio[controls],
17717
+ video[controls],
17718
+ summary
17719
+ `;
17720
+ const getFocusableElements = () => {
17721
+ const popup = getPopup();
17722
+ if (!popup) {
17723
+ return [];
17724
+ }
17725
+ const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
17726
+ const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex).sort((a, b) => {
17727
+ const tabindexA = parseInt(a.getAttribute("tabindex") || "0");
17728
+ const tabindexB = parseInt(b.getAttribute("tabindex") || "0");
17729
+ if (tabindexA > tabindexB) {
17730
+ return 1;
17731
+ } else if (tabindexA < tabindexB) {
17732
+ return -1;
17733
+ }
17734
+ return 0;
17735
+ });
17736
+ const otherFocusableElements = popup.querySelectorAll(focusable);
17737
+ const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter((el) => el.getAttribute("tabindex") !== "-1");
17738
+ return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter((el) => isVisible$1(el));
17739
+ };
17740
+ const isModal = () => {
17741
+ return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses["toast-shown"]) && !hasClass(document.body, swalClasses["no-backdrop"]);
17742
+ };
17743
+ const isToast = () => {
17744
+ const popup = getPopup();
17745
+ if (!popup) {
17746
+ return false;
17747
+ }
17748
+ return hasClass(popup, swalClasses.toast);
17749
+ };
17750
+ const isLoading = () => {
17751
+ const popup = getPopup();
17752
+ if (!popup) {
17753
+ return false;
17754
+ }
17755
+ return popup.hasAttribute("data-loading");
17756
+ };
17757
+ const setInnerHtml = (elem, html) => {
17758
+ elem.textContent = "";
17759
+ if (html) {
17760
+ const parser = new DOMParser();
17761
+ const parsed = parser.parseFromString(html, `text/html`);
17762
+ const head = parsed.querySelector("head");
17763
+ if (head) {
17764
+ Array.from(head.childNodes).forEach((child) => {
17765
+ elem.appendChild(child);
17766
+ });
17767
+ }
17768
+ const body = parsed.querySelector("body");
17769
+ if (body) {
17770
+ Array.from(body.childNodes).forEach((child) => {
17771
+ if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
17772
+ elem.appendChild(child.cloneNode(true));
17773
+ } else {
17774
+ elem.appendChild(child);
17775
+ }
17776
+ });
17777
+ }
17778
+ }
17779
+ };
17780
+ const hasClass = (elem, className) => {
17781
+ if (!className) {
17782
+ return false;
17783
+ }
17784
+ const classList = className.split(/\s+/);
17785
+ for (let i = 0; i < classList.length; i++) {
17786
+ if (!elem.classList.contains(classList[i])) {
17787
+ return false;
17788
+ }
17789
+ }
17790
+ return true;
17791
+ };
17792
+ const removeCustomClasses = (elem, params) => {
17793
+ Array.from(elem.classList).forEach((className) => {
17794
+ if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
17795
+ elem.classList.remove(className);
17796
+ }
17797
+ });
17798
+ };
17799
+ const applyCustomClass = (elem, params, className) => {
17800
+ removeCustomClasses(elem, params);
17801
+ if (!params.customClass) {
17802
+ return;
17803
+ }
17804
+ const customClass = params.customClass[
17805
+ /** @type {keyof SweetAlertCustomClass} */
17806
+ className
17807
+ ];
17808
+ if (!customClass) {
17809
+ return;
17810
+ }
17811
+ if (typeof customClass !== "string" && !customClass.forEach) {
17812
+ warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
17813
+ return;
17814
+ }
17815
+ addClass(elem, customClass);
17816
+ };
17817
+ const getInput$1 = (popup, inputClass) => {
17818
+ if (!inputClass) {
17819
+ return null;
17820
+ }
17821
+ switch (inputClass) {
17822
+ case "select":
17823
+ case "textarea":
17824
+ case "file":
17825
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
17826
+ case "checkbox":
17827
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
17828
+ case "radio":
17829
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
17830
+ case "range":
17831
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
17832
+ default:
17833
+ return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
17834
+ }
17835
+ };
17836
+ const focusInput = (input) => {
17837
+ input.focus();
17838
+ if (input.type !== "file") {
17839
+ const val = input.value;
17840
+ input.value = "";
17841
+ input.value = val;
17842
+ }
17843
+ };
17844
+ const toggleClass = (target, classList, condition) => {
17845
+ if (!target || !classList) {
17846
+ return;
17847
+ }
17848
+ if (typeof classList === "string") {
17849
+ classList = classList.split(/\s+/).filter(Boolean);
17850
+ }
17851
+ classList.forEach((className) => {
17852
+ if (Array.isArray(target)) {
17853
+ target.forEach((elem) => {
17854
+ if (condition) {
17855
+ elem.classList.add(className);
17856
+ } else {
17857
+ elem.classList.remove(className);
17858
+ }
17859
+ });
17860
+ } else {
17861
+ if (condition) {
17862
+ target.classList.add(className);
17863
+ } else {
17864
+ target.classList.remove(className);
17865
+ }
17866
+ }
17867
+ });
17868
+ };
17869
+ const addClass = (target, classList) => {
17870
+ toggleClass(target, classList, true);
17871
+ };
17872
+ const removeClass = (target, classList) => {
17873
+ toggleClass(target, classList, false);
17874
+ };
17875
+ const getDirectChildByClass = (elem, className) => {
17876
+ const children = Array.from(elem.children);
17877
+ for (let i = 0; i < children.length; i++) {
17878
+ const child = children[i];
17879
+ if (child instanceof HTMLElement && hasClass(child, className)) {
17880
+ return child;
17881
+ }
17882
+ }
17883
+ };
17884
+ const applyNumericalStyle = (elem, property, value) => {
17885
+ if (value === `${parseInt(value)}`) {
17886
+ value = parseInt(value);
17887
+ }
17888
+ if (value || parseInt(value) === 0) {
17889
+ elem.style.setProperty(property, typeof value === "number" ? `${value}px` : value);
17890
+ } else {
17891
+ elem.style.removeProperty(property);
17892
+ }
17893
+ };
17894
+ const show = (elem, display = "flex") => {
17895
+ if (!elem) {
17896
+ return;
17897
+ }
17898
+ elem.style.display = display;
17899
+ };
17900
+ const hide = (elem) => {
17901
+ if (!elem) {
17902
+ return;
17903
+ }
17904
+ elem.style.display = "none";
17905
+ };
17906
+ const showWhenInnerHtmlPresent = (elem, display = "block") => {
17907
+ if (!elem) {
17908
+ return;
17909
+ }
17910
+ new MutationObserver(() => {
17911
+ toggle(elem, elem.innerHTML, display);
17912
+ }).observe(elem, {
17913
+ childList: true,
17914
+ subtree: true
17915
+ });
17916
+ };
17917
+ const setStyle2 = (parent, selector, property, value) => {
17918
+ const el = parent.querySelector(selector);
17919
+ if (el) {
17920
+ el.style.setProperty(property, value);
17921
+ }
17922
+ };
17923
+ const toggle = (elem, condition, display = "flex") => {
17924
+ if (condition) {
17925
+ show(elem, display);
17926
+ } else {
17927
+ hide(elem);
17928
+ }
17929
+ };
17930
+ const isVisible$1 = (elem) => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
17931
+ const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
17932
+ const isScrollable = (elem) => !!(elem.scrollHeight > elem.clientHeight);
17933
+ const selfOrParentIsScrollable = (element, stopElement) => {
17934
+ let parent = element;
17935
+ while (parent && parent !== stopElement) {
17936
+ if (isScrollable(parent)) {
17937
+ return true;
17938
+ }
17939
+ parent = parent.parentElement;
17940
+ }
17941
+ return false;
17942
+ };
17943
+ const hasCssAnimation = (elem) => {
17944
+ const style = window.getComputedStyle(elem);
17945
+ const animDuration = parseFloat(style.getPropertyValue("animation-duration") || "0");
17946
+ const transDuration = parseFloat(style.getPropertyValue("transition-duration") || "0");
17947
+ return animDuration > 0 || transDuration > 0;
17948
+ };
17949
+ const animateTimerProgressBar = (timer, reset = false) => {
17950
+ const timerProgressBar = getTimerProgressBar();
17951
+ if (!timerProgressBar) {
17952
+ return;
17953
+ }
17954
+ if (isVisible$1(timerProgressBar)) {
17955
+ if (reset) {
17956
+ timerProgressBar.style.transition = "none";
17957
+ timerProgressBar.style.width = "100%";
17958
+ }
17959
+ setTimeout(() => {
17960
+ timerProgressBar.style.transition = `width ${timer / 1e3}s linear`;
17961
+ timerProgressBar.style.width = "0%";
17962
+ }, 10);
17963
+ }
17964
+ };
17965
+ const stopTimerProgressBar = () => {
17966
+ const timerProgressBar = getTimerProgressBar();
17967
+ if (!timerProgressBar) {
17968
+ return;
17969
+ }
17970
+ const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
17971
+ timerProgressBar.style.removeProperty("transition");
17972
+ timerProgressBar.style.width = "100%";
17973
+ const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
17974
+ const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
17975
+ timerProgressBar.style.width = `${timerProgressBarPercent}%`;
17976
+ };
17977
+ const isNodeEnv = () => typeof window === "undefined" || typeof document === "undefined";
17978
+ const sweetHTML = `
17979
+ <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses["html-container"]}" class="${swalClasses.popup}" tabindex="-1">
17980
+ <button type="button" class="${swalClasses.close}"></button>
17981
+ <ul class="${swalClasses["progress-steps"]}"></ul>
17982
+ <div class="${swalClasses.icon}"></div>
17983
+ <img class="${swalClasses.image}" />
17984
+ <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
17985
+ <div class="${swalClasses["html-container"]}" id="${swalClasses["html-container"]}"></div>
17986
+ <input class="${swalClasses.input}" id="${swalClasses.input}" />
17987
+ <input type="file" class="${swalClasses.file}" />
17988
+ <div class="${swalClasses.range}">
17989
+ <input type="range" />
17990
+ <output></output>
17991
+ </div>
17992
+ <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
17993
+ <div class="${swalClasses.radio}"></div>
17994
+ <label class="${swalClasses.checkbox}">
17995
+ <input type="checkbox" id="${swalClasses.checkbox}" />
17996
+ <span class="${swalClasses.label}"></span>
17997
+ </label>
17998
+ <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
17999
+ <div class="${swalClasses["validation-message"]}" id="${swalClasses["validation-message"]}"></div>
18000
+ <div class="${swalClasses.actions}">
18001
+ <div class="${swalClasses.loader}"></div>
18002
+ <button type="button" class="${swalClasses.confirm}"></button>
18003
+ <button type="button" class="${swalClasses.deny}"></button>
18004
+ <button type="button" class="${swalClasses.cancel}"></button>
18005
+ </div>
18006
+ <div class="${swalClasses.footer}"></div>
18007
+ <div class="${swalClasses["timer-progress-bar-container"]}">
18008
+ <div class="${swalClasses["timer-progress-bar"]}"></div>
18009
+ </div>
18010
+ </div>
18011
+ `.replace(/(^|\n)\s*/g, "");
18012
+ const resetOldContainer = () => {
18013
+ const oldContainer = getContainer();
18014
+ if (!oldContainer) {
18015
+ return false;
18016
+ }
18017
+ oldContainer.remove();
18018
+ removeClass([document.documentElement, document.body], [swalClasses["no-backdrop"], swalClasses["toast-shown"], swalClasses["has-column"]]);
18019
+ return true;
18020
+ };
18021
+ const resetValidationMessage$1 = () => {
18022
+ globalState.currentInstance.resetValidationMessage();
18023
+ };
18024
+ const addInputChangeListeners = () => {
18025
+ const popup = getPopup();
18026
+ const input = getDirectChildByClass(popup, swalClasses.input);
18027
+ const file = getDirectChildByClass(popup, swalClasses.file);
18028
+ const range = popup.querySelector(`.${swalClasses.range} input`);
18029
+ const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
18030
+ const select = getDirectChildByClass(popup, swalClasses.select);
18031
+ const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
18032
+ const textarea = getDirectChildByClass(popup, swalClasses.textarea);
18033
+ input.oninput = resetValidationMessage$1;
18034
+ file.onchange = resetValidationMessage$1;
18035
+ select.onchange = resetValidationMessage$1;
18036
+ checkbox.onchange = resetValidationMessage$1;
18037
+ textarea.oninput = resetValidationMessage$1;
18038
+ range.oninput = () => {
18039
+ resetValidationMessage$1();
18040
+ rangeOutput.value = range.value;
18041
+ };
18042
+ range.onchange = () => {
18043
+ resetValidationMessage$1();
18044
+ rangeOutput.value = range.value;
18045
+ };
18046
+ };
18047
+ const getTarget = (target) => typeof target === "string" ? document.querySelector(target) : target;
18048
+ const setupAccessibility = (params) => {
18049
+ const popup = getPopup();
18050
+ popup.setAttribute("role", params.toast ? "alert" : "dialog");
18051
+ popup.setAttribute("aria-live", params.toast ? "polite" : "assertive");
18052
+ if (!params.toast) {
18053
+ popup.setAttribute("aria-modal", "true");
18054
+ }
18055
+ };
18056
+ const setupRTL = (targetElement) => {
18057
+ if (window.getComputedStyle(targetElement).direction === "rtl") {
18058
+ addClass(getContainer(), swalClasses.rtl);
18059
+ }
18060
+ };
18061
+ const init = (params) => {
18062
+ const oldContainerExisted = resetOldContainer();
18063
+ if (isNodeEnv()) {
18064
+ error2("SweetAlert2 requires document to initialize");
18065
+ return;
18066
+ }
18067
+ const container = document.createElement("div");
18068
+ container.className = swalClasses.container;
18069
+ if (oldContainerExisted) {
18070
+ addClass(container, swalClasses["no-transition"]);
18071
+ }
18072
+ setInnerHtml(container, sweetHTML);
18073
+ container.dataset["swal2Theme"] = params.theme;
18074
+ const targetElement = getTarget(params.target);
18075
+ targetElement.appendChild(container);
18076
+ if (params.topLayer) {
18077
+ container.setAttribute("popover", "");
18078
+ container.showPopover();
18079
+ }
18080
+ setupAccessibility(params);
18081
+ setupRTL(targetElement);
18082
+ addInputChangeListeners();
18083
+ };
18084
+ const parseHtmlToContainer = (param, target) => {
18085
+ if (param instanceof HTMLElement) {
18086
+ target.appendChild(param);
18087
+ } else if (typeof param === "object") {
18088
+ handleObject(param, target);
18089
+ } else if (param) {
18090
+ setInnerHtml(target, param);
18091
+ }
18092
+ };
18093
+ const handleObject = (param, target) => {
18094
+ if (param.jquery) {
18095
+ handleJqueryElem(target, param);
18096
+ } else {
18097
+ setInnerHtml(target, param.toString());
18098
+ }
18099
+ };
18100
+ const handleJqueryElem = (target, elem) => {
18101
+ target.textContent = "";
18102
+ if (0 in elem) {
18103
+ for (let i = 0; i in elem; i++) {
18104
+ target.appendChild(elem[i].cloneNode(true));
18105
+ }
18106
+ } else {
18107
+ target.appendChild(elem.cloneNode(true));
18108
+ }
18109
+ };
18110
+ const renderActions = (instance, params) => {
18111
+ const actions = getActions();
18112
+ const loader = getLoader();
18113
+ if (!actions || !loader) {
18114
+ return;
18115
+ }
18116
+ if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
18117
+ hide(actions);
18118
+ } else {
18119
+ show(actions);
18120
+ }
18121
+ applyCustomClass(actions, params, "actions");
18122
+ renderButtons(actions, loader, params);
18123
+ setInnerHtml(loader, params.loaderHtml || "");
18124
+ applyCustomClass(loader, params, "loader");
18125
+ };
18126
+ function renderButtons(actions, loader, params) {
18127
+ const confirmButton = getConfirmButton();
18128
+ const denyButton = getDenyButton();
18129
+ const cancelButton = getCancelButton();
18130
+ if (!confirmButton || !denyButton || !cancelButton) {
18131
+ return;
18132
+ }
18133
+ renderButton(confirmButton, "confirm", params);
18134
+ renderButton(denyButton, "deny", params);
18135
+ renderButton(cancelButton, "cancel", params);
18136
+ handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
18137
+ if (params.reverseButtons) {
18138
+ if (params.toast) {
18139
+ actions.insertBefore(cancelButton, confirmButton);
18140
+ actions.insertBefore(denyButton, confirmButton);
18141
+ } else {
18142
+ actions.insertBefore(cancelButton, loader);
18143
+ actions.insertBefore(denyButton, loader);
18144
+ actions.insertBefore(confirmButton, loader);
18145
+ }
18146
+ }
18147
+ }
18148
+ function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
18149
+ if (!params.buttonsStyling) {
18150
+ removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
18151
+ return;
18152
+ }
18153
+ addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
18154
+ if (params.confirmButtonColor) {
18155
+ confirmButton.style.setProperty("--swal2-confirm-button-background-color", params.confirmButtonColor);
18156
+ }
18157
+ if (params.denyButtonColor) {
18158
+ denyButton.style.setProperty("--swal2-deny-button-background-color", params.denyButtonColor);
18159
+ }
18160
+ if (params.cancelButtonColor) {
18161
+ cancelButton.style.setProperty("--swal2-cancel-button-background-color", params.cancelButtonColor);
18162
+ }
18163
+ applyOutlineColor(confirmButton);
18164
+ applyOutlineColor(denyButton);
18165
+ applyOutlineColor(cancelButton);
18166
+ }
18167
+ function applyOutlineColor(button) {
18168
+ const buttonStyle = window.getComputedStyle(button);
18169
+ if (buttonStyle.getPropertyValue("--swal2-action-button-focus-box-shadow")) {
18170
+ return;
18171
+ }
18172
+ const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, "rgba($1, $2, $3, 0.5)");
18173
+ button.style.setProperty("--swal2-action-button-focus-box-shadow", buttonStyle.getPropertyValue("--swal2-outline").replace(/ rgba\(.*/, ` ${outlineColor}`));
18174
+ }
18175
+ function renderButton(button, buttonType, params) {
18176
+ const buttonName = (
18177
+ /** @type {'Confirm' | 'Deny' | 'Cancel'} */
18178
+ capitalizeFirstLetter(buttonType)
18179
+ );
18180
+ toggle(button, params[`show${buttonName}Button`], "inline-block");
18181
+ setInnerHtml(button, params[`${buttonType}ButtonText`] || "");
18182
+ button.setAttribute("aria-label", params[`${buttonType}ButtonAriaLabel`] || "");
18183
+ button.className = swalClasses[buttonType];
18184
+ applyCustomClass(button, params, `${buttonType}Button`);
18185
+ }
18186
+ const renderCloseButton = (instance, params) => {
18187
+ const closeButton = getCloseButton();
18188
+ if (!closeButton) {
18189
+ return;
18190
+ }
18191
+ setInnerHtml(closeButton, params.closeButtonHtml || "");
18192
+ applyCustomClass(closeButton, params, "closeButton");
18193
+ toggle(closeButton, params.showCloseButton);
18194
+ closeButton.setAttribute("aria-label", params.closeButtonAriaLabel || "");
18195
+ };
18196
+ const renderContainer = (instance, params) => {
18197
+ const container = getContainer();
18198
+ if (!container) {
18199
+ return;
18200
+ }
18201
+ handleBackdropParam(container, params.backdrop);
18202
+ handlePositionParam(container, params.position);
18203
+ handleGrowParam(container, params.grow);
18204
+ applyCustomClass(container, params, "container");
18205
+ };
18206
+ function handleBackdropParam(container, backdrop) {
18207
+ if (typeof backdrop === "string") {
18208
+ container.style.background = backdrop;
18209
+ } else if (!backdrop) {
18210
+ addClass([document.documentElement, document.body], swalClasses["no-backdrop"]);
18211
+ }
18212
+ }
18213
+ function handlePositionParam(container, position) {
18214
+ if (!position) {
18215
+ return;
18216
+ }
18217
+ if (position in swalClasses) {
18218
+ addClass(container, swalClasses[position]);
18219
+ } else {
18220
+ warn('The "position" parameter is not valid, defaulting to "center"');
18221
+ addClass(container, swalClasses.center);
18222
+ }
18223
+ }
18224
+ function handleGrowParam(container, grow) {
18225
+ if (!grow) {
18226
+ return;
18227
+ }
18228
+ addClass(container, swalClasses[`grow-${grow}`]);
18229
+ }
18230
+ var privateProps = {
18231
+ innerParams: /* @__PURE__ */ new WeakMap(),
18232
+ domCache: /* @__PURE__ */ new WeakMap()
18233
+ };
18234
+ const inputClasses = ["input", "file", "range", "select", "radio", "checkbox", "textarea"];
18235
+ const renderInput = (instance, params) => {
18236
+ const popup = getPopup();
18237
+ if (!popup) {
18238
+ return;
18239
+ }
18240
+ const innerParams = privateProps.innerParams.get(instance);
18241
+ const rerender = !innerParams || params.input !== innerParams.input;
18242
+ inputClasses.forEach((inputClass) => {
18243
+ const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
18244
+ if (!inputContainer) {
18245
+ return;
18246
+ }
18247
+ setAttributes(inputClass, params.inputAttributes);
18248
+ inputContainer.className = swalClasses[inputClass];
18249
+ if (rerender) {
18250
+ hide(inputContainer);
18251
+ }
18252
+ });
18253
+ if (params.input) {
18254
+ if (rerender) {
18255
+ showInput(params);
18256
+ }
18257
+ setCustomClass(params);
18258
+ }
18259
+ };
18260
+ const showInput = (params) => {
18261
+ if (!params.input) {
18262
+ return;
18263
+ }
18264
+ if (!renderInputType[params.input]) {
18265
+ error2(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(" | ")}, got "${params.input}"`);
18266
+ return;
18267
+ }
18268
+ const inputContainer = getInputContainer(params.input);
18269
+ if (!inputContainer) {
18270
+ return;
18271
+ }
18272
+ const input = renderInputType[params.input](inputContainer, params);
18273
+ show(inputContainer);
18274
+ if (params.inputAutoFocus) {
18275
+ setTimeout(() => {
18276
+ focusInput(input);
18277
+ });
18278
+ }
18279
+ };
18280
+ const removeAttributes = (input) => {
18281
+ for (let i = 0; i < input.attributes.length; i++) {
18282
+ const attrName = input.attributes[i].name;
18283
+ if (!["id", "type", "value", "style"].includes(attrName)) {
18284
+ input.removeAttribute(attrName);
18285
+ }
18286
+ }
18287
+ };
18288
+ const setAttributes = (inputClass, inputAttributes) => {
18289
+ const popup = getPopup();
18290
+ if (!popup) {
18291
+ return;
18292
+ }
18293
+ const input = getInput$1(popup, inputClass);
18294
+ if (!input) {
18295
+ return;
18296
+ }
18297
+ removeAttributes(input);
18298
+ for (const attr in inputAttributes) {
18299
+ input.setAttribute(attr, inputAttributes[attr]);
18300
+ }
18301
+ };
18302
+ const setCustomClass = (params) => {
18303
+ if (!params.input) {
18304
+ return;
18305
+ }
18306
+ const inputContainer = getInputContainer(params.input);
18307
+ if (inputContainer) {
18308
+ applyCustomClass(inputContainer, params, "input");
18309
+ }
18310
+ };
18311
+ const setInputPlaceholder = (input, params) => {
18312
+ if (!input.placeholder && params.inputPlaceholder) {
18313
+ input.placeholder = params.inputPlaceholder;
18314
+ }
18315
+ };
18316
+ const setInputLabel = (input, prependTo, params) => {
18317
+ if (params.inputLabel) {
18318
+ const label = document.createElement("label");
18319
+ const labelClass = swalClasses["input-label"];
18320
+ label.setAttribute("for", input.id);
18321
+ label.className = labelClass;
18322
+ if (typeof params.customClass === "object") {
18323
+ addClass(label, params.customClass.inputLabel);
18324
+ }
18325
+ label.innerText = params.inputLabel;
18326
+ prependTo.insertAdjacentElement("beforebegin", label);
18327
+ }
18328
+ };
18329
+ const getInputContainer = (inputType) => {
18330
+ const popup = getPopup();
18331
+ if (!popup) {
18332
+ return;
18333
+ }
18334
+ return getDirectChildByClass(popup, swalClasses[
18335
+ /** @type {SwalClass} */
18336
+ inputType
18337
+ ] || swalClasses.input);
18338
+ };
18339
+ const checkAndSetInputValue = (input, inputValue) => {
18340
+ if (["string", "number"].includes(typeof inputValue)) {
18341
+ input.value = `${inputValue}`;
18342
+ } else if (!isPromise(inputValue)) {
18343
+ warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
18344
+ }
18345
+ };
18346
+ const renderInputType = {};
18347
+ 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} */
18348
+ (input, params) => {
18349
+ checkAndSetInputValue(input, params.inputValue);
18350
+ setInputLabel(input, input, params);
18351
+ setInputPlaceholder(input, params);
18352
+ input.type = params.input;
18353
+ return input;
18354
+ };
18355
+ renderInputType.file = (input, params) => {
18356
+ setInputLabel(input, input, params);
18357
+ setInputPlaceholder(input, params);
18358
+ return input;
18359
+ };
18360
+ renderInputType.range = (range, params) => {
18361
+ const rangeInput = range.querySelector("input");
18362
+ const rangeOutput = range.querySelector("output");
18363
+ checkAndSetInputValue(rangeInput, params.inputValue);
18364
+ rangeInput.type = params.input;
18365
+ checkAndSetInputValue(rangeOutput, params.inputValue);
18366
+ setInputLabel(rangeInput, range, params);
18367
+ return range;
18368
+ };
18369
+ renderInputType.select = (select, params) => {
18370
+ select.textContent = "";
18371
+ if (params.inputPlaceholder) {
18372
+ const placeholder = document.createElement("option");
18373
+ setInnerHtml(placeholder, params.inputPlaceholder);
18374
+ placeholder.value = "";
18375
+ placeholder.disabled = true;
18376
+ placeholder.selected = true;
18377
+ select.appendChild(placeholder);
18378
+ }
18379
+ setInputLabel(select, select, params);
18380
+ return select;
18381
+ };
18382
+ renderInputType.radio = (radio) => {
18383
+ radio.textContent = "";
18384
+ return radio;
18385
+ };
18386
+ renderInputType.checkbox = (checkboxContainer, params) => {
18387
+ const checkbox = getInput$1(getPopup(), "checkbox");
18388
+ checkbox.value = "1";
18389
+ checkbox.checked = Boolean(params.inputValue);
18390
+ const label = checkboxContainer.querySelector("span");
18391
+ setInnerHtml(label, params.inputPlaceholder || params.inputLabel);
18392
+ return checkbox;
18393
+ };
18394
+ renderInputType.textarea = (textarea, params) => {
18395
+ checkAndSetInputValue(textarea, params.inputValue);
18396
+ setInputPlaceholder(textarea, params);
18397
+ setInputLabel(textarea, textarea, params);
18398
+ const getMargin = (el) => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
18399
+ setTimeout(() => {
18400
+ if ("MutationObserver" in window) {
18401
+ const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
18402
+ const textareaResizeHandler = () => {
18403
+ if (!document.body.contains(textarea)) {
18404
+ return;
18405
+ }
18406
+ const textareaWidth = textarea.offsetWidth + getMargin(textarea);
18407
+ if (textareaWidth > initialPopupWidth) {
18408
+ getPopup().style.width = `${textareaWidth}px`;
18409
+ } else {
18410
+ applyNumericalStyle(getPopup(), "width", params.width);
18411
+ }
18412
+ };
18413
+ new MutationObserver(textareaResizeHandler).observe(textarea, {
18414
+ attributes: true,
18415
+ attributeFilter: ["style"]
18416
+ });
18417
+ }
18418
+ });
18419
+ return textarea;
18420
+ };
18421
+ const renderContent = (instance, params) => {
18422
+ const htmlContainer = getHtmlContainer();
18423
+ if (!htmlContainer) {
18424
+ return;
18425
+ }
18426
+ showWhenInnerHtmlPresent(htmlContainer);
18427
+ applyCustomClass(htmlContainer, params, "htmlContainer");
18428
+ if (params.html) {
18429
+ parseHtmlToContainer(params.html, htmlContainer);
18430
+ show(htmlContainer, "block");
18431
+ } else if (params.text) {
18432
+ htmlContainer.textContent = params.text;
18433
+ show(htmlContainer, "block");
18434
+ } else {
18435
+ hide(htmlContainer);
18436
+ }
18437
+ renderInput(instance, params);
18438
+ };
18439
+ const renderFooter = (instance, params) => {
18440
+ const footer = getFooter();
18441
+ if (!footer) {
18442
+ return;
18443
+ }
18444
+ showWhenInnerHtmlPresent(footer);
18445
+ toggle(footer, params.footer, "block");
18446
+ if (params.footer) {
18447
+ parseHtmlToContainer(params.footer, footer);
18448
+ }
18449
+ applyCustomClass(footer, params, "footer");
18450
+ };
18451
+ const renderIcon = (instance, params) => {
18452
+ const innerParams = privateProps.innerParams.get(instance);
18453
+ const icon = getIcon();
18454
+ if (!icon) {
18455
+ return;
18456
+ }
18457
+ if (innerParams && params.icon === innerParams.icon) {
18458
+ setContent(icon, params);
18459
+ applyStyles(icon, params);
18460
+ return;
18461
+ }
18462
+ if (!params.icon && !params.iconHtml) {
18463
+ hide(icon);
18464
+ return;
18465
+ }
18466
+ if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
18467
+ error2(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
18468
+ hide(icon);
18469
+ return;
18470
+ }
18471
+ show(icon);
18472
+ setContent(icon, params);
18473
+ applyStyles(icon, params);
18474
+ addClass(icon, params.showClass && params.showClass.icon);
18475
+ const colorSchemeQueryList = window.matchMedia("(prefers-color-scheme: dark)");
18476
+ colorSchemeQueryList.addEventListener("change", adjustSuccessIconBackgroundColor);
18477
+ };
18478
+ const applyStyles = (icon, params) => {
18479
+ for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
18480
+ if (params.icon !== iconType) {
18481
+ removeClass(icon, iconClassName);
18482
+ }
18483
+ }
18484
+ addClass(icon, params.icon && iconTypes[params.icon]);
18485
+ setColor(icon, params);
18486
+ adjustSuccessIconBackgroundColor();
18487
+ applyCustomClass(icon, params, "icon");
18488
+ };
18489
+ const adjustSuccessIconBackgroundColor = () => {
18490
+ const popup = getPopup();
18491
+ if (!popup) {
18492
+ return;
18493
+ }
18494
+ const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue("background-color");
18495
+ const successIconParts = popup.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix");
18496
+ for (let i = 0; i < successIconParts.length; i++) {
18497
+ successIconParts[i].style.backgroundColor = popupBackgroundColor;
18498
+ }
18499
+ };
18500
+ const successIconHtml = (params) => `
18501
+ ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ""}
18502
+ <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
18503
+ <div class="swal2-success-ring"></div>
18504
+ ${params.animation ? '<div class="swal2-success-fix"></div>' : ""}
18505
+ ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ""}
18506
+ `;
18507
+ const errorIconHtml = `
18508
+ <span class="swal2-x-mark">
18509
+ <span class="swal2-x-mark-line-left"></span>
18510
+ <span class="swal2-x-mark-line-right"></span>
18511
+ </span>
18512
+ `;
18513
+ const setContent = (icon, params) => {
18514
+ if (!params.icon && !params.iconHtml) {
18515
+ return;
18516
+ }
18517
+ let oldContent = icon.innerHTML;
18518
+ let newContent = "";
18519
+ if (params.iconHtml) {
18520
+ newContent = iconContent(params.iconHtml);
18521
+ } else if (params.icon === "success") {
18522
+ newContent = successIconHtml(params);
18523
+ oldContent = oldContent.replace(/ style=".*?"/g, "");
18524
+ } else if (params.icon === "error") {
18525
+ newContent = errorIconHtml;
18526
+ } else if (params.icon) {
18527
+ const defaultIconHtml = {
18528
+ question: "?",
18529
+ warning: "!",
18530
+ info: "i"
18531
+ };
18532
+ newContent = iconContent(defaultIconHtml[params.icon]);
18533
+ }
18534
+ if (oldContent.trim() !== newContent.trim()) {
18535
+ setInnerHtml(icon, newContent);
18536
+ }
18537
+ };
18538
+ const setColor = (icon, params) => {
18539
+ if (!params.iconColor) {
18540
+ return;
18541
+ }
18542
+ icon.style.color = params.iconColor;
18543
+ icon.style.borderColor = params.iconColor;
18544
+ for (const sel of [".swal2-success-line-tip", ".swal2-success-line-long", ".swal2-x-mark-line-left", ".swal2-x-mark-line-right"]) {
18545
+ setStyle2(icon, sel, "background-color", params.iconColor);
18546
+ }
18547
+ setStyle2(icon, ".swal2-success-ring", "border-color", params.iconColor);
18548
+ };
18549
+ const iconContent = (content) => `<div class="${swalClasses["icon-content"]}">${content}</div>`;
18550
+ const renderImage = (instance, params) => {
18551
+ const image = getImage();
18552
+ if (!image) {
18553
+ return;
18554
+ }
18555
+ if (!params.imageUrl) {
18556
+ hide(image);
18557
+ return;
18558
+ }
18559
+ show(image, "");
18560
+ image.setAttribute("src", params.imageUrl);
18561
+ image.setAttribute("alt", params.imageAlt || "");
18562
+ applyNumericalStyle(image, "width", params.imageWidth);
18563
+ applyNumericalStyle(image, "height", params.imageHeight);
18564
+ image.className = swalClasses.image;
18565
+ applyCustomClass(image, params, "image");
18566
+ };
18567
+ let dragging = false;
18568
+ let mousedownX = 0;
18569
+ let mousedownY = 0;
18570
+ let initialX = 0;
18571
+ let initialY = 0;
18572
+ const addDraggableListeners = (popup) => {
18573
+ popup.addEventListener("mousedown", down);
18574
+ document.body.addEventListener("mousemove", move);
18575
+ popup.addEventListener("mouseup", up);
18576
+ popup.addEventListener("touchstart", down);
18577
+ document.body.addEventListener("touchmove", move);
18578
+ popup.addEventListener("touchend", up);
18579
+ };
18580
+ const removeDraggableListeners = (popup) => {
18581
+ popup.removeEventListener("mousedown", down);
18582
+ document.body.removeEventListener("mousemove", move);
18583
+ popup.removeEventListener("mouseup", up);
18584
+ popup.removeEventListener("touchstart", down);
18585
+ document.body.removeEventListener("touchmove", move);
18586
+ popup.removeEventListener("touchend", up);
18587
+ };
18588
+ const down = (event) => {
18589
+ const popup = getPopup();
18590
+ if (event.target === popup || getIcon().contains(
18591
+ /** @type {HTMLElement} */
18592
+ event.target
18593
+ )) {
18594
+ dragging = true;
18595
+ const clientXY = getClientXY(event);
18596
+ mousedownX = clientXY.clientX;
18597
+ mousedownY = clientXY.clientY;
18598
+ initialX = parseInt(popup.style.insetInlineStart) || 0;
18599
+ initialY = parseInt(popup.style.insetBlockStart) || 0;
18600
+ addClass(popup, "swal2-dragging");
18601
+ }
18602
+ };
18603
+ const move = (event) => {
18604
+ const popup = getPopup();
18605
+ if (dragging) {
18606
+ let {
18607
+ clientX,
18608
+ clientY
18609
+ } = getClientXY(event);
18610
+ popup.style.insetInlineStart = `${initialX + (clientX - mousedownX)}px`;
18611
+ popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
18612
+ }
18613
+ };
18614
+ const up = () => {
18615
+ const popup = getPopup();
18616
+ dragging = false;
18617
+ removeClass(popup, "swal2-dragging");
18618
+ };
18619
+ const getClientXY = (event) => {
18620
+ let clientX = 0, clientY = 0;
18621
+ if (event.type.startsWith("mouse")) {
18622
+ clientX = /** @type {MouseEvent} */
18623
+ event.clientX;
18624
+ clientY = /** @type {MouseEvent} */
18625
+ event.clientY;
18626
+ } else if (event.type.startsWith("touch")) {
18627
+ clientX = /** @type {TouchEvent} */
18628
+ event.touches[0].clientX;
18629
+ clientY = /** @type {TouchEvent} */
18630
+ event.touches[0].clientY;
18631
+ }
18632
+ return {
18633
+ clientX,
18634
+ clientY
18635
+ };
18636
+ };
18637
+ const renderPopup = (instance, params) => {
18638
+ const container = getContainer();
18639
+ const popup = getPopup();
18640
+ if (!container || !popup) {
18641
+ return;
18642
+ }
18643
+ if (params.toast) {
18644
+ applyNumericalStyle(container, "width", params.width);
18645
+ popup.style.width = "100%";
18646
+ const loader = getLoader();
18647
+ if (loader) {
18648
+ popup.insertBefore(loader, getIcon());
18649
+ }
18650
+ } else {
18651
+ applyNumericalStyle(popup, "width", params.width);
18652
+ }
18653
+ applyNumericalStyle(popup, "padding", params.padding);
18654
+ if (params.color) {
18655
+ popup.style.color = params.color;
18656
+ }
18657
+ if (params.background) {
18658
+ popup.style.background = params.background;
18659
+ }
18660
+ hide(getValidationMessage());
18661
+ addClasses$1(popup, params);
18662
+ if (params.draggable && !params.toast) {
18663
+ addClass(popup, swalClasses.draggable);
18664
+ addDraggableListeners(popup);
18665
+ } else {
18666
+ removeClass(popup, swalClasses.draggable);
18667
+ removeDraggableListeners(popup);
18668
+ }
18669
+ };
18670
+ const addClasses$1 = (popup, params) => {
18671
+ const showClass = params.showClass || {};
18672
+ popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ""}`;
18673
+ if (params.toast) {
18674
+ addClass([document.documentElement, document.body], swalClasses["toast-shown"]);
18675
+ addClass(popup, swalClasses.toast);
18676
+ } else {
18677
+ addClass(popup, swalClasses.modal);
18678
+ }
18679
+ applyCustomClass(popup, params, "popup");
18680
+ if (typeof params.customClass === "string") {
18681
+ addClass(popup, params.customClass);
18682
+ }
18683
+ if (params.icon) {
18684
+ addClass(popup, swalClasses[`icon-${params.icon}`]);
18685
+ }
18686
+ };
18687
+ const renderProgressSteps = (instance, params) => {
18688
+ const progressStepsContainer = getProgressSteps();
18689
+ if (!progressStepsContainer) {
18690
+ return;
18691
+ }
18692
+ const {
18693
+ progressSteps,
18694
+ currentProgressStep
18695
+ } = params;
18696
+ if (!progressSteps || progressSteps.length === 0 || currentProgressStep === void 0) {
18697
+ hide(progressStepsContainer);
18698
+ return;
18699
+ }
18700
+ show(progressStepsContainer);
18701
+ progressStepsContainer.textContent = "";
18702
+ if (currentProgressStep >= progressSteps.length) {
18703
+ warn("Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)");
18704
+ }
18705
+ progressSteps.forEach((step, index2) => {
18706
+ const stepEl = createStepElement(step);
18707
+ progressStepsContainer.appendChild(stepEl);
18708
+ if (index2 === currentProgressStep) {
18709
+ addClass(stepEl, swalClasses["active-progress-step"]);
18710
+ }
18711
+ if (index2 !== progressSteps.length - 1) {
18712
+ const lineEl = createLineElement(params);
18713
+ progressStepsContainer.appendChild(lineEl);
18714
+ }
18715
+ });
18716
+ };
18717
+ const createStepElement = (step) => {
18718
+ const stepEl = document.createElement("li");
18719
+ addClass(stepEl, swalClasses["progress-step"]);
18720
+ setInnerHtml(stepEl, step);
18721
+ return stepEl;
18722
+ };
18723
+ const createLineElement = (params) => {
18724
+ const lineEl = document.createElement("li");
18725
+ addClass(lineEl, swalClasses["progress-step-line"]);
18726
+ if (params.progressStepsDistance) {
18727
+ applyNumericalStyle(lineEl, "width", params.progressStepsDistance);
18728
+ }
18729
+ return lineEl;
18730
+ };
18731
+ const renderTitle = (instance, params) => {
18732
+ const title = getTitle();
18733
+ if (!title) {
18734
+ return;
18735
+ }
18736
+ showWhenInnerHtmlPresent(title);
18737
+ toggle(title, params.title || params.titleText, "block");
18738
+ if (params.title) {
18739
+ parseHtmlToContainer(params.title, title);
18740
+ }
18741
+ if (params.titleText) {
18742
+ title.innerText = params.titleText;
18743
+ }
18744
+ applyCustomClass(title, params, "title");
18745
+ };
18746
+ const render = (instance, params) => {
18747
+ renderPopup(instance, params);
18748
+ renderContainer(instance, params);
18749
+ renderProgressSteps(instance, params);
18750
+ renderIcon(instance, params);
18751
+ renderImage(instance, params);
18752
+ renderTitle(instance, params);
18753
+ renderCloseButton(instance, params);
18754
+ renderContent(instance, params);
18755
+ renderActions(instance, params);
18756
+ renderFooter(instance, params);
18757
+ const popup = getPopup();
18758
+ if (typeof params.didRender === "function" && popup) {
18759
+ params.didRender(popup);
18760
+ }
18761
+ globalState.eventEmitter.emit("didRender", popup);
18762
+ };
18763
+ const isVisible = () => {
18764
+ return isVisible$1(getPopup());
18765
+ };
18766
+ const clickConfirm = () => {
18767
+ var _dom$getConfirmButton;
18768
+ return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
18769
+ };
18770
+ const clickDeny = () => {
18771
+ var _dom$getDenyButton;
18772
+ return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
18773
+ };
18774
+ const clickCancel = () => {
18775
+ var _dom$getCancelButton;
18776
+ return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
18777
+ };
18778
+ const DismissReason = Object.freeze({
18779
+ cancel: "cancel",
18780
+ backdrop: "backdrop",
18781
+ close: "close",
18782
+ esc: "esc",
18783
+ timer: "timer"
18784
+ });
18785
+ const removeKeydownHandler = (globalState2) => {
18786
+ if (globalState2.keydownTarget && globalState2.keydownHandlerAdded) {
18787
+ globalState2.keydownTarget.removeEventListener("keydown", globalState2.keydownHandler, {
18788
+ capture: globalState2.keydownListenerCapture
18789
+ });
18790
+ globalState2.keydownHandlerAdded = false;
18791
+ }
18792
+ };
18793
+ const addKeydownHandler = (globalState2, innerParams, dismissWith) => {
18794
+ removeKeydownHandler(globalState2);
18795
+ if (!innerParams.toast) {
18796
+ globalState2.keydownHandler = (e) => keydownHandler(innerParams, e, dismissWith);
18797
+ globalState2.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
18798
+ globalState2.keydownListenerCapture = innerParams.keydownListenerCapture;
18799
+ globalState2.keydownTarget.addEventListener("keydown", globalState2.keydownHandler, {
18800
+ capture: globalState2.keydownListenerCapture
18801
+ });
18802
+ globalState2.keydownHandlerAdded = true;
18803
+ }
18804
+ };
18805
+ const setFocus = (index2, increment) => {
18806
+ var _dom$getPopup;
18807
+ const focusableElements = getFocusableElements();
18808
+ if (focusableElements.length) {
18809
+ index2 = index2 + increment;
18810
+ if (index2 === -2) {
18811
+ index2 = focusableElements.length - 1;
18812
+ }
18813
+ if (index2 === focusableElements.length) {
18814
+ index2 = 0;
18815
+ } else if (index2 === -1) {
18816
+ index2 = focusableElements.length - 1;
18817
+ }
18818
+ focusableElements[index2].focus();
18819
+ return;
18820
+ }
18821
+ (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
18822
+ };
18823
+ const arrowKeysNextButton = ["ArrowRight", "ArrowDown"];
18824
+ const arrowKeysPreviousButton = ["ArrowLeft", "ArrowUp"];
18825
+ const keydownHandler = (innerParams, event, dismissWith) => {
18826
+ if (!innerParams) {
18827
+ return;
18828
+ }
18829
+ if (event.isComposing || event.keyCode === 229) {
18830
+ return;
18831
+ }
18832
+ if (innerParams.stopKeydownPropagation) {
18833
+ event.stopPropagation();
18834
+ }
18835
+ if (event.key === "Enter") {
18836
+ handleEnter(event, innerParams);
18837
+ } else if (event.key === "Tab") {
18838
+ handleTab(event);
18839
+ } else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
18840
+ handleArrows(event.key);
18841
+ } else if (event.key === "Escape") {
18842
+ handleEsc(event, innerParams, dismissWith);
18843
+ }
18844
+ };
18845
+ const handleEnter = (event, innerParams) => {
18846
+ if (!callIfFunction(innerParams.allowEnterKey)) {
18847
+ return;
18848
+ }
18849
+ const input = getInput$1(getPopup(), innerParams.input);
18850
+ if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
18851
+ if (["textarea", "file"].includes(innerParams.input)) {
18852
+ return;
18853
+ }
18854
+ clickConfirm();
18855
+ event.preventDefault();
18856
+ }
18857
+ };
18858
+ const handleTab = (event) => {
18859
+ const targetElement = event.target;
18860
+ const focusableElements = getFocusableElements();
18861
+ let btnIndex = -1;
18862
+ for (let i = 0; i < focusableElements.length; i++) {
18863
+ if (targetElement === focusableElements[i]) {
18864
+ btnIndex = i;
18865
+ break;
18866
+ }
18867
+ }
18868
+ if (!event.shiftKey) {
18869
+ setFocus(btnIndex, 1);
18870
+ } else {
18871
+ setFocus(btnIndex, -1);
18872
+ }
18873
+ event.stopPropagation();
18874
+ event.preventDefault();
18875
+ };
18876
+ const handleArrows = (key) => {
18877
+ const actions = getActions();
18878
+ const confirmButton = getConfirmButton();
18879
+ const denyButton = getDenyButton();
18880
+ const cancelButton = getCancelButton();
18881
+ if (!actions || !confirmButton || !denyButton || !cancelButton) {
18882
+ return;
18883
+ }
18884
+ const buttons = [confirmButton, denyButton, cancelButton];
18885
+ if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
18886
+ return;
18887
+ }
18888
+ const sibling = arrowKeysNextButton.includes(key) ? "nextElementSibling" : "previousElementSibling";
18889
+ let buttonToFocus = document.activeElement;
18890
+ if (!buttonToFocus) {
18891
+ return;
18892
+ }
18893
+ for (let i = 0; i < actions.children.length; i++) {
18894
+ buttonToFocus = buttonToFocus[sibling];
18895
+ if (!buttonToFocus) {
18896
+ return;
18897
+ }
18898
+ if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
18899
+ break;
18900
+ }
18901
+ }
18902
+ if (buttonToFocus instanceof HTMLButtonElement) {
18903
+ buttonToFocus.focus();
18904
+ }
18905
+ };
18906
+ const handleEsc = (event, innerParams, dismissWith) => {
18907
+ event.preventDefault();
18908
+ if (callIfFunction(innerParams.allowEscapeKey)) {
18909
+ dismissWith(DismissReason.esc);
18910
+ }
18911
+ };
18912
+ var privateMethods = {
18913
+ swalPromiseResolve: /* @__PURE__ */ new WeakMap(),
18914
+ swalPromiseReject: /* @__PURE__ */ new WeakMap()
18915
+ };
18916
+ const setAriaHidden = () => {
18917
+ const container = getContainer();
18918
+ const bodyChildren = Array.from(document.body.children);
18919
+ bodyChildren.forEach((el) => {
18920
+ if (el.contains(container)) {
18921
+ return;
18922
+ }
18923
+ if (el.hasAttribute("aria-hidden")) {
18924
+ el.setAttribute("data-previous-aria-hidden", el.getAttribute("aria-hidden") || "");
18925
+ }
18926
+ el.setAttribute("aria-hidden", "true");
18927
+ });
18928
+ };
18929
+ const unsetAriaHidden = () => {
18930
+ const bodyChildren = Array.from(document.body.children);
18931
+ bodyChildren.forEach((el) => {
18932
+ if (el.hasAttribute("data-previous-aria-hidden")) {
18933
+ el.setAttribute("aria-hidden", el.getAttribute("data-previous-aria-hidden") || "");
18934
+ el.removeAttribute("data-previous-aria-hidden");
18935
+ } else {
18936
+ el.removeAttribute("aria-hidden");
18937
+ }
18938
+ });
18939
+ };
18940
+ const isSafariOrIOS = typeof window !== "undefined" && !!window.GestureEvent;
18941
+ const iOSfix = () => {
18942
+ if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
18943
+ const offset = document.body.scrollTop;
18944
+ document.body.style.top = `${offset * -1}px`;
18945
+ addClass(document.body, swalClasses.iosfix);
18946
+ lockBodyScroll();
18947
+ }
18948
+ };
18949
+ const lockBodyScroll = () => {
18950
+ const container = getContainer();
18951
+ if (!container) {
18952
+ return;
18953
+ }
18954
+ let preventTouchMove;
18955
+ container.ontouchstart = (event) => {
18956
+ preventTouchMove = shouldPreventTouchMove(event);
18957
+ };
18958
+ container.ontouchmove = (event) => {
18959
+ if (preventTouchMove) {
18960
+ event.preventDefault();
18961
+ event.stopPropagation();
18962
+ }
18963
+ };
18964
+ };
18965
+ const shouldPreventTouchMove = (event) => {
18966
+ const target = event.target;
18967
+ const container = getContainer();
18968
+ const htmlContainer = getHtmlContainer();
18969
+ if (!container || !htmlContainer) {
18970
+ return false;
18971
+ }
18972
+ if (isStylus(event) || isZoom(event)) {
18973
+ return false;
18974
+ }
18975
+ if (target === container) {
18976
+ return true;
18977
+ }
18978
+ if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) && // #2823
18979
+ target.tagName !== "INPUT" && // #1603
18980
+ target.tagName !== "TEXTAREA" && // #2266
18981
+ !(isScrollable(htmlContainer) && // #1944
18982
+ htmlContainer.contains(target))) {
18983
+ return true;
18984
+ }
18985
+ return false;
18986
+ };
18987
+ const isStylus = (event) => {
18988
+ return event.touches && event.touches.length && event.touches[0].touchType === "stylus";
18989
+ };
18990
+ const isZoom = (event) => {
18991
+ return event.touches && event.touches.length > 1;
18992
+ };
18993
+ const undoIOSfix = () => {
18994
+ if (hasClass(document.body, swalClasses.iosfix)) {
18995
+ const offset = parseInt(document.body.style.top, 10);
18996
+ removeClass(document.body, swalClasses.iosfix);
18997
+ document.body.style.top = "";
18998
+ document.body.scrollTop = offset * -1;
18999
+ }
19000
+ };
19001
+ const measureScrollbar = () => {
19002
+ const scrollDiv = document.createElement("div");
19003
+ scrollDiv.className = swalClasses["scrollbar-measure"];
19004
+ document.body.appendChild(scrollDiv);
19005
+ const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
19006
+ document.body.removeChild(scrollDiv);
19007
+ return scrollbarWidth;
19008
+ };
19009
+ let previousBodyPadding = null;
19010
+ const replaceScrollbarWithPadding = (initialBodyOverflow) => {
19011
+ if (previousBodyPadding !== null) {
19012
+ return;
19013
+ }
19014
+ if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === "scroll") {
19015
+ previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"));
19016
+ document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
19017
+ }
19018
+ };
19019
+ const undoReplaceScrollbarWithPadding = () => {
19020
+ if (previousBodyPadding !== null) {
19021
+ document.body.style.paddingRight = `${previousBodyPadding}px`;
19022
+ previousBodyPadding = null;
19023
+ }
19024
+ };
19025
+ function removePopupAndResetState(instance, container, returnFocus, didClose) {
19026
+ if (isToast()) {
19027
+ triggerDidCloseAndDispose(instance, didClose);
19028
+ } else {
19029
+ restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
19030
+ removeKeydownHandler(globalState);
19031
+ }
19032
+ if (isSafariOrIOS) {
19033
+ container.setAttribute("style", "display:none !important");
19034
+ container.removeAttribute("class");
19035
+ container.innerHTML = "";
19036
+ } else {
19037
+ container.remove();
19038
+ }
19039
+ if (isModal()) {
19040
+ undoReplaceScrollbarWithPadding();
19041
+ undoIOSfix();
19042
+ unsetAriaHidden();
19043
+ }
19044
+ removeBodyClasses();
19045
+ }
19046
+ function removeBodyClasses() {
19047
+ removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses["height-auto"], swalClasses["no-backdrop"], swalClasses["toast-shown"]]);
19048
+ }
19049
+ function close(resolveValue) {
19050
+ resolveValue = prepareResolveValue(resolveValue);
19051
+ const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
19052
+ const didClose = triggerClosePopup(this);
19053
+ if (this.isAwaitingPromise) {
19054
+ if (!resolveValue.isDismissed) {
19055
+ handleAwaitingPromise(this);
19056
+ swalPromiseResolve(resolveValue);
19057
+ }
19058
+ } else if (didClose) {
19059
+ swalPromiseResolve(resolveValue);
19060
+ }
19061
+ }
19062
+ const triggerClosePopup = (instance) => {
19063
+ const popup = getPopup();
19064
+ if (!popup) {
19065
+ return false;
19066
+ }
19067
+ const innerParams = privateProps.innerParams.get(instance);
19068
+ if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
19069
+ return false;
19070
+ }
19071
+ removeClass(popup, innerParams.showClass.popup);
19072
+ addClass(popup, innerParams.hideClass.popup);
19073
+ const backdrop = getContainer();
19074
+ removeClass(backdrop, innerParams.showClass.backdrop);
19075
+ addClass(backdrop, innerParams.hideClass.backdrop);
19076
+ handlePopupAnimation(instance, popup, innerParams);
19077
+ return true;
19078
+ };
19079
+ function rejectPromise(error3) {
19080
+ const rejectPromise2 = privateMethods.swalPromiseReject.get(this);
19081
+ handleAwaitingPromise(this);
19082
+ if (rejectPromise2) {
19083
+ rejectPromise2(error3);
19084
+ }
19085
+ }
19086
+ const handleAwaitingPromise = (instance) => {
19087
+ if (instance.isAwaitingPromise) {
19088
+ delete instance.isAwaitingPromise;
19089
+ if (!privateProps.innerParams.get(instance)) {
19090
+ instance._destroy();
19091
+ }
19092
+ }
19093
+ };
19094
+ const prepareResolveValue = (resolveValue) => {
19095
+ if (typeof resolveValue === "undefined") {
19096
+ return {
19097
+ isConfirmed: false,
19098
+ isDenied: false,
19099
+ isDismissed: true
19100
+ };
19101
+ }
19102
+ return Object.assign({
19103
+ isConfirmed: false,
19104
+ isDenied: false,
19105
+ isDismissed: false
19106
+ }, resolveValue);
19107
+ };
19108
+ const handlePopupAnimation = (instance, popup, innerParams) => {
19109
+ var _globalState$eventEmi;
19110
+ const container = getContainer();
19111
+ const animationIsSupported = hasCssAnimation(popup);
19112
+ if (typeof innerParams.willClose === "function") {
19113
+ innerParams.willClose(popup);
19114
+ }
19115
+ (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit("willClose", popup);
19116
+ if (animationIsSupported) {
19117
+ animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
19118
+ } else {
19119
+ removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
19120
+ }
19121
+ };
19122
+ const animatePopup = (instance, popup, container, returnFocus, didClose) => {
19123
+ globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
19124
+ const swalCloseAnimationFinished = function(e) {
19125
+ if (e.target === popup) {
19126
+ var _globalState$swalClos;
19127
+ (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
19128
+ delete globalState.swalCloseEventFinishedCallback;
19129
+ popup.removeEventListener("animationend", swalCloseAnimationFinished);
19130
+ popup.removeEventListener("transitionend", swalCloseAnimationFinished);
19131
+ }
19132
+ };
19133
+ popup.addEventListener("animationend", swalCloseAnimationFinished);
19134
+ popup.addEventListener("transitionend", swalCloseAnimationFinished);
19135
+ };
19136
+ const triggerDidCloseAndDispose = (instance, didClose) => {
19137
+ setTimeout(() => {
19138
+ var _globalState$eventEmi2;
19139
+ if (typeof didClose === "function") {
19140
+ didClose.bind(instance.params)();
19141
+ }
19142
+ (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit("didClose");
19143
+ if (instance._destroy) {
19144
+ instance._destroy();
19145
+ }
19146
+ });
19147
+ };
19148
+ const showLoading = (buttonToReplace) => {
19149
+ let popup = getPopup();
19150
+ if (!popup) {
19151
+ new Swal2();
19152
+ }
19153
+ popup = getPopup();
19154
+ if (!popup) {
19155
+ return;
19156
+ }
19157
+ const loader = getLoader();
19158
+ if (isToast()) {
19159
+ hide(getIcon());
19160
+ } else {
19161
+ replaceButton(popup, buttonToReplace);
19162
+ }
19163
+ show(loader);
19164
+ popup.setAttribute("data-loading", "true");
19165
+ popup.setAttribute("aria-busy", "true");
19166
+ popup.focus();
19167
+ };
19168
+ const replaceButton = (popup, buttonToReplace) => {
19169
+ const actions = getActions();
19170
+ const loader = getLoader();
19171
+ if (!actions || !loader) {
19172
+ return;
19173
+ }
19174
+ if (!buttonToReplace && isVisible$1(getConfirmButton())) {
19175
+ buttonToReplace = getConfirmButton();
19176
+ }
19177
+ show(actions);
19178
+ if (buttonToReplace) {
19179
+ hide(buttonToReplace);
19180
+ loader.setAttribute("data-button-to-replace", buttonToReplace.className);
19181
+ actions.insertBefore(loader, buttonToReplace);
19182
+ }
19183
+ addClass([popup, actions], swalClasses.loading);
19184
+ };
19185
+ const handleInputOptionsAndValue = (instance, params) => {
19186
+ if (params.input === "select" || params.input === "radio") {
19187
+ handleInputOptions(instance, params);
19188
+ } else if (["text", "email", "number", "tel", "textarea"].some((i) => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
19189
+ showLoading(getConfirmButton());
19190
+ handleInputValue(instance, params);
19191
+ }
19192
+ };
19193
+ const getInputValue = (instance, innerParams) => {
19194
+ const input = instance.getInput();
19195
+ if (!input) {
19196
+ return null;
19197
+ }
19198
+ switch (innerParams.input) {
19199
+ case "checkbox":
19200
+ return getCheckboxValue(input);
19201
+ case "radio":
19202
+ return getRadioValue(input);
19203
+ case "file":
19204
+ return getFileValue(input);
19205
+ default:
19206
+ return innerParams.inputAutoTrim ? input.value.trim() : input.value;
19207
+ }
19208
+ };
19209
+ const getCheckboxValue = (input) => input.checked ? 1 : 0;
19210
+ const getRadioValue = (input) => input.checked ? input.value : null;
19211
+ const getFileValue = (input) => input.files && input.files.length ? input.getAttribute("multiple") !== null ? input.files : input.files[0] : null;
19212
+ const handleInputOptions = (instance, params) => {
19213
+ const popup = getPopup();
19214
+ if (!popup) {
19215
+ return;
19216
+ }
19217
+ const processInputOptions = (inputOptions) => {
19218
+ if (params.input === "select") {
19219
+ populateSelectOptions(popup, formatInputOptions(inputOptions), params);
19220
+ } else if (params.input === "radio") {
19221
+ populateRadioOptions(popup, formatInputOptions(inputOptions), params);
19222
+ }
19223
+ };
19224
+ if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
19225
+ showLoading(getConfirmButton());
19226
+ asPromise(params.inputOptions).then((inputOptions) => {
19227
+ instance.hideLoading();
19228
+ processInputOptions(inputOptions);
19229
+ });
19230
+ } else if (typeof params.inputOptions === "object") {
19231
+ processInputOptions(params.inputOptions);
19232
+ } else {
19233
+ error2(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
19234
+ }
19235
+ };
19236
+ const handleInputValue = (instance, params) => {
19237
+ const input = instance.getInput();
19238
+ if (!input) {
19239
+ return;
19240
+ }
19241
+ hide(input);
19242
+ asPromise(params.inputValue).then((inputValue) => {
19243
+ input.value = params.input === "number" ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
19244
+ show(input);
19245
+ input.focus();
19246
+ instance.hideLoading();
19247
+ }).catch((err) => {
19248
+ error2(`Error in inputValue promise: ${err}`);
19249
+ input.value = "";
19250
+ show(input);
19251
+ input.focus();
19252
+ instance.hideLoading();
19253
+ });
19254
+ };
19255
+ function populateSelectOptions(popup, inputOptions, params) {
19256
+ const select = getDirectChildByClass(popup, swalClasses.select);
19257
+ if (!select) {
19258
+ return;
19259
+ }
19260
+ const renderOption = (parent, optionLabel, optionValue) => {
19261
+ const option = document.createElement("option");
19262
+ option.value = optionValue;
19263
+ setInnerHtml(option, optionLabel);
19264
+ option.selected = isSelected(optionValue, params.inputValue);
19265
+ parent.appendChild(option);
19266
+ };
19267
+ inputOptions.forEach((inputOption) => {
19268
+ const optionValue = inputOption[0];
19269
+ const optionLabel = inputOption[1];
19270
+ if (Array.isArray(optionLabel)) {
19271
+ const optgroup = document.createElement("optgroup");
19272
+ optgroup.label = optionValue;
19273
+ optgroup.disabled = false;
19274
+ select.appendChild(optgroup);
19275
+ optionLabel.forEach((o) => renderOption(optgroup, o[1], o[0]));
19276
+ } else {
19277
+ renderOption(select, optionLabel, optionValue);
19278
+ }
19279
+ });
19280
+ select.focus();
19281
+ }
19282
+ function populateRadioOptions(popup, inputOptions, params) {
19283
+ const radio = getDirectChildByClass(popup, swalClasses.radio);
19284
+ if (!radio) {
19285
+ return;
19286
+ }
19287
+ inputOptions.forEach((inputOption) => {
19288
+ const radioValue = inputOption[0];
19289
+ const radioLabel = inputOption[1];
19290
+ const radioInput = document.createElement("input");
19291
+ const radioLabelElement = document.createElement("label");
19292
+ radioInput.type = "radio";
19293
+ radioInput.name = swalClasses.radio;
19294
+ radioInput.value = radioValue;
19295
+ if (isSelected(radioValue, params.inputValue)) {
19296
+ radioInput.checked = true;
19297
+ }
19298
+ const label = document.createElement("span");
19299
+ setInnerHtml(label, radioLabel);
19300
+ label.className = swalClasses.label;
19301
+ radioLabelElement.appendChild(radioInput);
19302
+ radioLabelElement.appendChild(label);
19303
+ radio.appendChild(radioLabelElement);
19304
+ });
19305
+ const radios = radio.querySelectorAll("input");
19306
+ if (radios.length) {
19307
+ radios[0].focus();
19308
+ }
19309
+ }
19310
+ const formatInputOptions = (inputOptions) => {
19311
+ const result = [];
19312
+ if (inputOptions instanceof Map) {
19313
+ inputOptions.forEach((value, key) => {
19314
+ let valueFormatted = value;
19315
+ if (typeof valueFormatted === "object") {
19316
+ valueFormatted = formatInputOptions(valueFormatted);
19317
+ }
19318
+ result.push([key, valueFormatted]);
19319
+ });
19320
+ } else {
19321
+ Object.keys(inputOptions).forEach((key) => {
19322
+ let valueFormatted = inputOptions[key];
19323
+ if (typeof valueFormatted === "object") {
19324
+ valueFormatted = formatInputOptions(valueFormatted);
19325
+ }
19326
+ result.push([key, valueFormatted]);
19327
+ });
19328
+ }
19329
+ return result;
19330
+ };
19331
+ const isSelected = (optionValue, inputValue) => {
19332
+ return !!inputValue && inputValue.toString() === optionValue.toString();
19333
+ };
19334
+ const handleConfirmButtonClick = (instance) => {
19335
+ const innerParams = privateProps.innerParams.get(instance);
19336
+ instance.disableButtons();
19337
+ if (innerParams.input) {
19338
+ handleConfirmOrDenyWithInput(instance, "confirm");
19339
+ } else {
19340
+ confirm2(instance, true);
19341
+ }
19342
+ };
19343
+ const handleDenyButtonClick = (instance) => {
19344
+ const innerParams = privateProps.innerParams.get(instance);
19345
+ instance.disableButtons();
19346
+ if (innerParams.returnInputValueOnDeny) {
19347
+ handleConfirmOrDenyWithInput(instance, "deny");
19348
+ } else {
19349
+ deny(instance, false);
19350
+ }
19351
+ };
19352
+ const handleCancelButtonClick = (instance, dismissWith) => {
19353
+ instance.disableButtons();
19354
+ dismissWith(DismissReason.cancel);
19355
+ };
19356
+ const handleConfirmOrDenyWithInput = (instance, type) => {
19357
+ const innerParams = privateProps.innerParams.get(instance);
19358
+ if (!innerParams.input) {
19359
+ error2(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
19360
+ return;
19361
+ }
19362
+ const input = instance.getInput();
19363
+ const inputValue = getInputValue(instance, innerParams);
19364
+ if (innerParams.inputValidator) {
19365
+ handleInputValidator(instance, inputValue, type);
19366
+ } else if (input && !input.checkValidity()) {
19367
+ instance.enableButtons();
19368
+ instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
19369
+ } else if (type === "deny") {
19370
+ deny(instance, inputValue);
19371
+ } else {
19372
+ confirm2(instance, inputValue);
19373
+ }
19374
+ };
19375
+ const handleInputValidator = (instance, inputValue, type) => {
19376
+ const innerParams = privateProps.innerParams.get(instance);
19377
+ instance.disableInput();
19378
+ const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
19379
+ validationPromise.then((validationMessage) => {
19380
+ instance.enableButtons();
19381
+ instance.enableInput();
19382
+ if (validationMessage) {
19383
+ instance.showValidationMessage(validationMessage);
19384
+ } else if (type === "deny") {
19385
+ deny(instance, inputValue);
19386
+ } else {
19387
+ confirm2(instance, inputValue);
19388
+ }
19389
+ });
19390
+ };
19391
+ const deny = (instance, value) => {
19392
+ const innerParams = privateProps.innerParams.get(instance || void 0);
19393
+ if (innerParams.showLoaderOnDeny) {
19394
+ showLoading(getDenyButton());
19395
+ }
19396
+ if (innerParams.preDeny) {
19397
+ instance.isAwaitingPromise = true;
19398
+ const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
19399
+ preDenyPromise.then((preDenyValue) => {
19400
+ if (preDenyValue === false) {
19401
+ instance.hideLoading();
19402
+ handleAwaitingPromise(instance);
19403
+ } else {
19404
+ instance.close({
19405
+ isDenied: true,
19406
+ value: typeof preDenyValue === "undefined" ? value : preDenyValue
19407
+ });
19408
+ }
19409
+ }).catch((error3) => rejectWith(instance || void 0, error3));
19410
+ } else {
19411
+ instance.close({
19412
+ isDenied: true,
19413
+ value
19414
+ });
19415
+ }
19416
+ };
19417
+ const succeedWith = (instance, value) => {
19418
+ instance.close({
19419
+ isConfirmed: true,
19420
+ value
19421
+ });
19422
+ };
19423
+ const rejectWith = (instance, error3) => {
19424
+ instance.rejectPromise(error3);
19425
+ };
19426
+ const confirm2 = (instance, value) => {
19427
+ const innerParams = privateProps.innerParams.get(instance || void 0);
19428
+ if (innerParams.showLoaderOnConfirm) {
19429
+ showLoading();
19430
+ }
19431
+ if (innerParams.preConfirm) {
19432
+ instance.resetValidationMessage();
19433
+ instance.isAwaitingPromise = true;
19434
+ const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
19435
+ preConfirmPromise.then((preConfirmValue) => {
19436
+ if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
19437
+ instance.hideLoading();
19438
+ handleAwaitingPromise(instance);
19439
+ } else {
19440
+ succeedWith(instance, typeof preConfirmValue === "undefined" ? value : preConfirmValue);
19441
+ }
19442
+ }).catch((error3) => rejectWith(instance || void 0, error3));
19443
+ } else {
19444
+ succeedWith(instance, value);
19445
+ }
19446
+ };
19447
+ function hideLoading() {
19448
+ const innerParams = privateProps.innerParams.get(this);
19449
+ if (!innerParams) {
19450
+ return;
19451
+ }
19452
+ const domCache = privateProps.domCache.get(this);
19453
+ hide(domCache.loader);
19454
+ if (isToast()) {
19455
+ if (innerParams.icon) {
19456
+ show(getIcon());
19457
+ }
19458
+ } else {
19459
+ showRelatedButton(domCache);
19460
+ }
19461
+ removeClass([domCache.popup, domCache.actions], swalClasses.loading);
19462
+ domCache.popup.removeAttribute("aria-busy");
19463
+ domCache.popup.removeAttribute("data-loading");
19464
+ domCache.confirmButton.disabled = false;
19465
+ domCache.denyButton.disabled = false;
19466
+ domCache.cancelButton.disabled = false;
19467
+ }
19468
+ const showRelatedButton = (domCache) => {
19469
+ const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute("data-button-to-replace"));
19470
+ if (buttonToReplace.length) {
19471
+ show(buttonToReplace[0], "inline-block");
19472
+ } else if (allButtonsAreHidden()) {
19473
+ hide(domCache.actions);
19474
+ }
19475
+ };
19476
+ function getInput() {
19477
+ const innerParams = privateProps.innerParams.get(this);
19478
+ const domCache = privateProps.domCache.get(this);
19479
+ if (!domCache) {
19480
+ return null;
19481
+ }
19482
+ return getInput$1(domCache.popup, innerParams.input);
19483
+ }
19484
+ function setButtonsDisabled(instance, buttons, disabled) {
19485
+ const domCache = privateProps.domCache.get(instance);
19486
+ buttons.forEach((button) => {
19487
+ domCache[button].disabled = disabled;
19488
+ });
19489
+ }
19490
+ function setInputDisabled(input, disabled) {
19491
+ const popup = getPopup();
19492
+ if (!popup || !input) {
19493
+ return;
19494
+ }
19495
+ if (input.type === "radio") {
19496
+ const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
19497
+ for (let i = 0; i < radios.length; i++) {
19498
+ radios[i].disabled = disabled;
19499
+ }
19500
+ } else {
19501
+ input.disabled = disabled;
19502
+ }
19503
+ }
19504
+ function enableButtons() {
19505
+ setButtonsDisabled(this, ["confirmButton", "denyButton", "cancelButton"], false);
19506
+ }
19507
+ function disableButtons() {
19508
+ setButtonsDisabled(this, ["confirmButton", "denyButton", "cancelButton"], true);
19509
+ }
19510
+ function enableInput() {
19511
+ setInputDisabled(this.getInput(), false);
19512
+ }
19513
+ function disableInput() {
19514
+ setInputDisabled(this.getInput(), true);
19515
+ }
19516
+ function showValidationMessage(error3) {
19517
+ const domCache = privateProps.domCache.get(this);
19518
+ const params = privateProps.innerParams.get(this);
19519
+ setInnerHtml(domCache.validationMessage, error3);
19520
+ domCache.validationMessage.className = swalClasses["validation-message"];
19521
+ if (params.customClass && params.customClass.validationMessage) {
19522
+ addClass(domCache.validationMessage, params.customClass.validationMessage);
19523
+ }
19524
+ show(domCache.validationMessage);
19525
+ const input = this.getInput();
19526
+ if (input) {
19527
+ input.setAttribute("aria-invalid", "true");
19528
+ input.setAttribute("aria-describedby", swalClasses["validation-message"]);
19529
+ focusInput(input);
19530
+ addClass(input, swalClasses.inputerror);
19531
+ }
19532
+ }
19533
+ function resetValidationMessage() {
19534
+ const domCache = privateProps.domCache.get(this);
19535
+ if (domCache.validationMessage) {
19536
+ hide(domCache.validationMessage);
19537
+ }
19538
+ const input = this.getInput();
19539
+ if (input) {
19540
+ input.removeAttribute("aria-invalid");
19541
+ input.removeAttribute("aria-describedby");
19542
+ removeClass(input, swalClasses.inputerror);
19543
+ }
19544
+ }
19545
+ const defaultParams = {
19546
+ title: "",
19547
+ titleText: "",
19548
+ text: "",
19549
+ html: "",
19550
+ footer: "",
19551
+ icon: void 0,
19552
+ iconColor: void 0,
19553
+ iconHtml: void 0,
19554
+ template: void 0,
19555
+ toast: false,
19556
+ draggable: false,
19557
+ animation: true,
19558
+ theme: "light",
19559
+ showClass: {
19560
+ popup: "swal2-show",
19561
+ backdrop: "swal2-backdrop-show",
19562
+ icon: "swal2-icon-show"
19563
+ },
19564
+ hideClass: {
19565
+ popup: "swal2-hide",
19566
+ backdrop: "swal2-backdrop-hide",
19567
+ icon: "swal2-icon-hide"
19568
+ },
19569
+ customClass: {},
19570
+ target: "body",
19571
+ color: void 0,
19572
+ backdrop: true,
19573
+ heightAuto: true,
19574
+ allowOutsideClick: true,
19575
+ allowEscapeKey: true,
19576
+ allowEnterKey: true,
19577
+ stopKeydownPropagation: true,
19578
+ keydownListenerCapture: false,
19579
+ showConfirmButton: true,
19580
+ showDenyButton: false,
19581
+ showCancelButton: false,
19582
+ preConfirm: void 0,
19583
+ preDeny: void 0,
19584
+ confirmButtonText: "OK",
19585
+ confirmButtonAriaLabel: "",
19586
+ confirmButtonColor: void 0,
19587
+ denyButtonText: "No",
19588
+ denyButtonAriaLabel: "",
19589
+ denyButtonColor: void 0,
19590
+ cancelButtonText: "Cancel",
19591
+ cancelButtonAriaLabel: "",
19592
+ cancelButtonColor: void 0,
19593
+ buttonsStyling: true,
19594
+ reverseButtons: false,
19595
+ focusConfirm: true,
19596
+ focusDeny: false,
19597
+ focusCancel: false,
19598
+ returnFocus: true,
19599
+ showCloseButton: false,
19600
+ closeButtonHtml: "&times;",
19601
+ closeButtonAriaLabel: "Close this dialog",
19602
+ loaderHtml: "",
19603
+ showLoaderOnConfirm: false,
19604
+ showLoaderOnDeny: false,
19605
+ imageUrl: void 0,
19606
+ imageWidth: void 0,
19607
+ imageHeight: void 0,
19608
+ imageAlt: "",
19609
+ timer: void 0,
19610
+ timerProgressBar: false,
19611
+ width: void 0,
19612
+ padding: void 0,
19613
+ background: void 0,
19614
+ input: void 0,
19615
+ inputPlaceholder: "",
19616
+ inputLabel: "",
19617
+ inputValue: "",
19618
+ inputOptions: {},
19619
+ inputAutoFocus: true,
19620
+ inputAutoTrim: true,
19621
+ inputAttributes: {},
19622
+ inputValidator: void 0,
19623
+ returnInputValueOnDeny: false,
19624
+ validationMessage: void 0,
19625
+ grow: false,
19626
+ position: "center",
19627
+ progressSteps: [],
19628
+ currentProgressStep: void 0,
19629
+ progressStepsDistance: void 0,
19630
+ willOpen: void 0,
19631
+ didOpen: void 0,
19632
+ didRender: void 0,
19633
+ willClose: void 0,
19634
+ didClose: void 0,
19635
+ didDestroy: void 0,
19636
+ scrollbarPadding: true,
19637
+ topLayer: false
19638
+ };
19639
+ const updatableParams = ["allowEscapeKey", "allowOutsideClick", "background", "buttonsStyling", "cancelButtonAriaLabel", "cancelButtonColor", "cancelButtonText", "closeButtonAriaLabel", "closeButtonHtml", "color", "confirmButtonAriaLabel", "confirmButtonColor", "confirmButtonText", "currentProgressStep", "customClass", "denyButtonAriaLabel", "denyButtonColor", "denyButtonText", "didClose", "didDestroy", "draggable", "footer", "hideClass", "html", "icon", "iconColor", "iconHtml", "imageAlt", "imageHeight", "imageUrl", "imageWidth", "preConfirm", "preDeny", "progressSteps", "returnFocus", "reverseButtons", "showCancelButton", "showCloseButton", "showConfirmButton", "showDenyButton", "text", "title", "titleText", "theme", "willClose"];
19640
+ const deprecatedParams = {
19641
+ allowEnterKey: void 0
19642
+ };
19643
+ const toastIncompatibleParams = ["allowOutsideClick", "allowEnterKey", "backdrop", "draggable", "focusConfirm", "focusDeny", "focusCancel", "returnFocus", "heightAuto", "keydownListenerCapture"];
19644
+ const isValidParameter = (paramName) => {
19645
+ return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
19646
+ };
19647
+ const isUpdatableParameter = (paramName) => {
19648
+ return updatableParams.indexOf(paramName) !== -1;
19649
+ };
19650
+ const isDeprecatedParameter = (paramName) => {
19651
+ return deprecatedParams[paramName];
19652
+ };
19653
+ const checkIfParamIsValid = (param) => {
19654
+ if (!isValidParameter(param)) {
19655
+ warn(`Unknown parameter "${param}"`);
19656
+ }
19657
+ };
19658
+ const checkIfToastParamIsValid = (param) => {
19659
+ if (toastIncompatibleParams.includes(param)) {
19660
+ warn(`The parameter "${param}" is incompatible with toasts`);
19661
+ }
19662
+ };
19663
+ const checkIfParamIsDeprecated = (param) => {
19664
+ const isDeprecated = isDeprecatedParameter(param);
19665
+ if (isDeprecated) {
19666
+ warnAboutDeprecation(param, isDeprecated);
19667
+ }
19668
+ };
19669
+ const showWarningsForParams = (params) => {
19670
+ if (params.backdrop === false && params.allowOutsideClick) {
19671
+ warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
19672
+ }
19673
+ if (params.theme && !["light", "dark", "auto", "minimal", "borderless", "embed-iframe", "bulma", "bulma-light", "bulma-dark"].includes(params.theme)) {
19674
+ warn(`Invalid theme "${params.theme}"`);
19675
+ }
19676
+ for (const param in params) {
19677
+ checkIfParamIsValid(param);
19678
+ if (params.toast) {
19679
+ checkIfToastParamIsValid(param);
19680
+ }
19681
+ checkIfParamIsDeprecated(param);
19682
+ }
19683
+ };
19684
+ function update(params) {
19685
+ const container = getContainer();
19686
+ const popup = getPopup();
19687
+ const innerParams = privateProps.innerParams.get(this);
19688
+ if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
19689
+ warn(`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`);
19690
+ return;
19691
+ }
19692
+ const validUpdatableParams = filterValidParams(params);
19693
+ const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
19694
+ showWarningsForParams(updatedParams);
19695
+ container.dataset["swal2Theme"] = updatedParams.theme;
19696
+ render(this, updatedParams);
19697
+ privateProps.innerParams.set(this, updatedParams);
19698
+ Object.defineProperties(this, {
19699
+ params: {
19700
+ value: Object.assign({}, this.params, params),
19701
+ writable: false,
19702
+ enumerable: true
19703
+ }
19704
+ });
19705
+ }
19706
+ const filterValidParams = (params) => {
19707
+ const validUpdatableParams = {};
19708
+ Object.keys(params).forEach((param) => {
19709
+ if (isUpdatableParameter(param)) {
19710
+ validUpdatableParams[param] = params[param];
19711
+ } else {
19712
+ warn(`Invalid parameter to update: ${param}`);
19713
+ }
19714
+ });
19715
+ return validUpdatableParams;
19716
+ };
19717
+ function _destroy() {
19718
+ const domCache = privateProps.domCache.get(this);
19719
+ const innerParams = privateProps.innerParams.get(this);
19720
+ if (!innerParams) {
19721
+ disposeWeakMaps(this);
19722
+ return;
19723
+ }
19724
+ if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
19725
+ globalState.swalCloseEventFinishedCallback();
19726
+ delete globalState.swalCloseEventFinishedCallback;
19727
+ }
19728
+ if (typeof innerParams.didDestroy === "function") {
19729
+ innerParams.didDestroy();
19730
+ }
19731
+ globalState.eventEmitter.emit("didDestroy");
19732
+ disposeSwal(this);
19733
+ }
19734
+ const disposeSwal = (instance) => {
19735
+ disposeWeakMaps(instance);
19736
+ delete instance.params;
19737
+ delete globalState.keydownHandler;
19738
+ delete globalState.keydownTarget;
19739
+ delete globalState.currentInstance;
19740
+ };
19741
+ const disposeWeakMaps = (instance) => {
19742
+ if (instance.isAwaitingPromise) {
19743
+ unsetWeakMaps(privateProps, instance);
19744
+ instance.isAwaitingPromise = true;
19745
+ } else {
19746
+ unsetWeakMaps(privateMethods, instance);
19747
+ unsetWeakMaps(privateProps, instance);
19748
+ delete instance.isAwaitingPromise;
19749
+ delete instance.disableButtons;
19750
+ delete instance.enableButtons;
19751
+ delete instance.getInput;
19752
+ delete instance.disableInput;
19753
+ delete instance.enableInput;
19754
+ delete instance.hideLoading;
19755
+ delete instance.disableLoading;
19756
+ delete instance.showValidationMessage;
19757
+ delete instance.resetValidationMessage;
19758
+ delete instance.close;
19759
+ delete instance.closePopup;
19760
+ delete instance.closeModal;
19761
+ delete instance.closeToast;
19762
+ delete instance.rejectPromise;
19763
+ delete instance.update;
19764
+ delete instance._destroy;
19765
+ }
19766
+ };
19767
+ const unsetWeakMaps = (obj, instance) => {
19768
+ for (const i in obj) {
19769
+ obj[i].delete(instance);
19770
+ }
19771
+ };
19772
+ var instanceMethods = /* @__PURE__ */ Object.freeze({
19773
+ __proto__: null,
19774
+ _destroy,
19775
+ close,
19776
+ closeModal: close,
19777
+ closePopup: close,
19778
+ closeToast: close,
19779
+ disableButtons,
19780
+ disableInput,
19781
+ disableLoading: hideLoading,
19782
+ enableButtons,
19783
+ enableInput,
19784
+ getInput,
19785
+ handleAwaitingPromise,
19786
+ hideLoading,
19787
+ rejectPromise,
19788
+ resetValidationMessage,
19789
+ showValidationMessage,
19790
+ update
19791
+ });
19792
+ const handlePopupClick = (innerParams, domCache, dismissWith) => {
19793
+ if (innerParams.toast) {
19794
+ handleToastClick(innerParams, domCache, dismissWith);
19795
+ } else {
19796
+ handleModalMousedown(domCache);
19797
+ handleContainerMousedown(domCache);
19798
+ handleModalClick(innerParams, domCache, dismissWith);
19799
+ }
19800
+ };
19801
+ const handleToastClick = (innerParams, domCache, dismissWith) => {
19802
+ domCache.popup.onclick = () => {
19803
+ if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
19804
+ return;
19805
+ }
19806
+ dismissWith(DismissReason.close);
19807
+ };
19808
+ };
19809
+ const isAnyButtonShown = (innerParams) => {
19810
+ return !!(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
19811
+ };
19812
+ let ignoreOutsideClick = false;
19813
+ const handleModalMousedown = (domCache) => {
19814
+ domCache.popup.onmousedown = () => {
19815
+ domCache.container.onmouseup = function(e) {
19816
+ domCache.container.onmouseup = () => {
19817
+ };
19818
+ if (e.target === domCache.container) {
19819
+ ignoreOutsideClick = true;
19820
+ }
19821
+ };
19822
+ };
19823
+ };
19824
+ const handleContainerMousedown = (domCache) => {
19825
+ domCache.container.onmousedown = (e) => {
19826
+ if (e.target === domCache.container) {
19827
+ e.preventDefault();
19828
+ }
19829
+ domCache.popup.onmouseup = function(e2) {
19830
+ domCache.popup.onmouseup = () => {
19831
+ };
19832
+ if (e2.target === domCache.popup || e2.target instanceof HTMLElement && domCache.popup.contains(e2.target)) {
19833
+ ignoreOutsideClick = true;
19834
+ }
19835
+ };
19836
+ };
19837
+ };
19838
+ const handleModalClick = (innerParams, domCache, dismissWith) => {
19839
+ domCache.container.onclick = (e) => {
19840
+ if (ignoreOutsideClick) {
19841
+ ignoreOutsideClick = false;
19842
+ return;
19843
+ }
19844
+ if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
19845
+ dismissWith(DismissReason.backdrop);
19846
+ }
19847
+ };
19848
+ };
19849
+ const isJqueryElement = (elem) => typeof elem === "object" && elem.jquery;
19850
+ const isElement = (elem) => elem instanceof Element || isJqueryElement(elem);
19851
+ const argsToParams = (args) => {
19852
+ const params = {};
19853
+ if (typeof args[0] === "object" && !isElement(args[0])) {
19854
+ Object.assign(params, args[0]);
19855
+ } else {
19856
+ ["title", "html", "icon"].forEach((name, index2) => {
19857
+ const arg = args[index2];
19858
+ if (typeof arg === "string" || isElement(arg)) {
19859
+ params[name] = arg;
19860
+ } else if (arg !== void 0) {
19861
+ error2(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
19862
+ }
19863
+ });
19864
+ }
19865
+ return params;
19866
+ };
19867
+ function fire(...args) {
19868
+ return new this(...args);
19869
+ }
19870
+ function mixin(mixinParams) {
19871
+ class MixinSwal extends this {
19872
+ _main(params, priorityMixinParams) {
19873
+ return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
19874
+ }
19875
+ }
19876
+ return MixinSwal;
19877
+ }
19878
+ const getTimerLeft = () => {
19879
+ return globalState.timeout && globalState.timeout.getTimerLeft();
19880
+ };
19881
+ const stopTimer = () => {
19882
+ if (globalState.timeout) {
19883
+ stopTimerProgressBar();
19884
+ return globalState.timeout.stop();
19885
+ }
19886
+ };
19887
+ const resumeTimer = () => {
19888
+ if (globalState.timeout) {
19889
+ const remaining = globalState.timeout.start();
19890
+ animateTimerProgressBar(remaining);
19891
+ return remaining;
19892
+ }
19893
+ };
19894
+ const toggleTimer = () => {
19895
+ const timer = globalState.timeout;
19896
+ return timer && (timer.running ? stopTimer() : resumeTimer());
19897
+ };
19898
+ const increaseTimer = (ms) => {
19899
+ if (globalState.timeout) {
19900
+ const remaining = globalState.timeout.increase(ms);
19901
+ animateTimerProgressBar(remaining, true);
19902
+ return remaining;
19903
+ }
19904
+ };
19905
+ const isTimerRunning = () => {
19906
+ return !!(globalState.timeout && globalState.timeout.isRunning());
19907
+ };
19908
+ let bodyClickListenerAdded = false;
19909
+ const clickHandlers = {};
19910
+ function bindClickHandler(attr = "data-swal-template") {
19911
+ clickHandlers[attr] = this;
19912
+ if (!bodyClickListenerAdded) {
19913
+ document.body.addEventListener("click", bodyClickListener);
19914
+ bodyClickListenerAdded = true;
19915
+ }
19916
+ }
19917
+ const bodyClickListener = (event) => {
19918
+ for (let el = event.target; el && el !== document; el = el.parentNode) {
19919
+ for (const attr in clickHandlers) {
19920
+ const template = el.getAttribute(attr);
19921
+ if (template) {
19922
+ clickHandlers[attr].fire({
19923
+ template
19924
+ });
19925
+ return;
19926
+ }
19927
+ }
19928
+ }
19929
+ };
19930
+ class EventEmitter {
19931
+ constructor() {
19932
+ this.events = {};
19933
+ }
19934
+ /**
19935
+ * @param {string} eventName
19936
+ * @returns {EventHandlers}
19937
+ */
19938
+ _getHandlersByEventName(eventName) {
19939
+ if (typeof this.events[eventName] === "undefined") {
19940
+ this.events[eventName] = [];
19941
+ }
19942
+ return this.events[eventName];
19943
+ }
19944
+ /**
19945
+ * @param {string} eventName
19946
+ * @param {EventHandler} eventHandler
19947
+ */
19948
+ on(eventName, eventHandler) {
19949
+ const currentHandlers = this._getHandlersByEventName(eventName);
19950
+ if (!currentHandlers.includes(eventHandler)) {
19951
+ currentHandlers.push(eventHandler);
19952
+ }
19953
+ }
19954
+ /**
19955
+ * @param {string} eventName
19956
+ * @param {EventHandler} eventHandler
19957
+ */
19958
+ once(eventName, eventHandler) {
19959
+ const onceFn = (...args) => {
19960
+ this.removeListener(eventName, onceFn);
19961
+ eventHandler.apply(this, args);
19962
+ };
19963
+ this.on(eventName, onceFn);
19964
+ }
19965
+ /**
19966
+ * @param {string} eventName
19967
+ * @param {Array} args
19968
+ */
19969
+ emit(eventName, ...args) {
19970
+ this._getHandlersByEventName(eventName).forEach(
19971
+ /**
19972
+ * @param {EventHandler} eventHandler
19973
+ */
19974
+ (eventHandler) => {
19975
+ try {
19976
+ eventHandler.apply(this, args);
19977
+ } catch (error3) {
19978
+ console.error(error3);
19979
+ }
19980
+ }
19981
+ );
19982
+ }
19983
+ /**
19984
+ * @param {string} eventName
19985
+ * @param {EventHandler} eventHandler
19986
+ */
19987
+ removeListener(eventName, eventHandler) {
19988
+ const currentHandlers = this._getHandlersByEventName(eventName);
19989
+ const index2 = currentHandlers.indexOf(eventHandler);
19990
+ if (index2 > -1) {
19991
+ currentHandlers.splice(index2, 1);
19992
+ }
19993
+ }
19994
+ /**
19995
+ * @param {string} eventName
19996
+ */
19997
+ removeAllListeners(eventName) {
19998
+ if (this.events[eventName] !== void 0) {
19999
+ this.events[eventName].length = 0;
20000
+ }
20001
+ }
20002
+ reset() {
20003
+ this.events = {};
20004
+ }
20005
+ }
20006
+ globalState.eventEmitter = new EventEmitter();
20007
+ const on = (eventName, eventHandler) => {
20008
+ globalState.eventEmitter.on(eventName, eventHandler);
20009
+ };
20010
+ const once = (eventName, eventHandler) => {
20011
+ globalState.eventEmitter.once(eventName, eventHandler);
20012
+ };
20013
+ const off = (eventName, eventHandler) => {
20014
+ if (!eventName) {
20015
+ globalState.eventEmitter.reset();
20016
+ return;
20017
+ }
20018
+ if (eventHandler) {
20019
+ globalState.eventEmitter.removeListener(eventName, eventHandler);
20020
+ } else {
20021
+ globalState.eventEmitter.removeAllListeners(eventName);
20022
+ }
20023
+ };
20024
+ var staticMethods = /* @__PURE__ */ Object.freeze({
20025
+ __proto__: null,
20026
+ argsToParams,
20027
+ bindClickHandler,
20028
+ clickCancel,
20029
+ clickConfirm,
20030
+ clickDeny,
20031
+ enableLoading: showLoading,
20032
+ fire,
20033
+ getActions,
20034
+ getCancelButton,
20035
+ getCloseButton,
20036
+ getConfirmButton,
20037
+ getContainer,
20038
+ getDenyButton,
20039
+ getFocusableElements,
20040
+ getFooter,
20041
+ getHtmlContainer,
20042
+ getIcon,
20043
+ getIconContent,
20044
+ getImage,
20045
+ getInputLabel,
20046
+ getLoader,
20047
+ getPopup,
20048
+ getProgressSteps,
20049
+ getTimerLeft,
20050
+ getTimerProgressBar,
20051
+ getTitle,
20052
+ getValidationMessage,
20053
+ increaseTimer,
20054
+ isDeprecatedParameter,
20055
+ isLoading,
20056
+ isTimerRunning,
20057
+ isUpdatableParameter,
20058
+ isValidParameter,
20059
+ isVisible,
20060
+ mixin,
20061
+ off,
20062
+ on,
20063
+ once,
20064
+ resumeTimer,
20065
+ showLoading,
20066
+ stopTimer,
20067
+ toggleTimer
20068
+ });
20069
+ class Timer {
20070
+ /**
20071
+ * @param {Function} callback
20072
+ * @param {number} delay
20073
+ */
20074
+ constructor(callback2, delay) {
20075
+ this.callback = callback2;
20076
+ this.remaining = delay;
20077
+ this.running = false;
20078
+ this.start();
20079
+ }
20080
+ /**
20081
+ * @returns {number}
20082
+ */
20083
+ start() {
20084
+ if (!this.running) {
20085
+ this.running = true;
20086
+ this.started = /* @__PURE__ */ new Date();
20087
+ this.id = setTimeout(this.callback, this.remaining);
20088
+ }
20089
+ return this.remaining;
20090
+ }
20091
+ /**
20092
+ * @returns {number}
20093
+ */
20094
+ stop() {
20095
+ if (this.started && this.running) {
20096
+ this.running = false;
20097
+ clearTimeout(this.id);
20098
+ this.remaining -= (/* @__PURE__ */ new Date()).getTime() - this.started.getTime();
20099
+ }
20100
+ return this.remaining;
20101
+ }
20102
+ /**
20103
+ * @param {number} n
20104
+ * @returns {number}
20105
+ */
20106
+ increase(n) {
20107
+ const running = this.running;
20108
+ if (running) {
20109
+ this.stop();
20110
+ }
20111
+ this.remaining += n;
20112
+ if (running) {
20113
+ this.start();
20114
+ }
20115
+ return this.remaining;
20116
+ }
20117
+ /**
20118
+ * @returns {number}
20119
+ */
20120
+ getTimerLeft() {
20121
+ if (this.running) {
20122
+ this.stop();
20123
+ this.start();
20124
+ }
20125
+ return this.remaining;
20126
+ }
20127
+ /**
20128
+ * @returns {boolean}
20129
+ */
20130
+ isRunning() {
20131
+ return this.running;
20132
+ }
20133
+ }
20134
+ const swalStringParams = ["swal-title", "swal-html", "swal-footer"];
20135
+ const getTemplateParams = (params) => {
20136
+ const template = typeof params.template === "string" ? (
20137
+ /** @type {HTMLTemplateElement} */
20138
+ document.querySelector(params.template)
20139
+ ) : params.template;
20140
+ if (!template) {
20141
+ return {};
20142
+ }
20143
+ const templateContent = template.content;
20144
+ showWarningsForElements(templateContent);
20145
+ const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
20146
+ return result;
20147
+ };
20148
+ const getSwalParams = (templateContent) => {
20149
+ const result = {};
20150
+ const swalParams = Array.from(templateContent.querySelectorAll("swal-param"));
20151
+ swalParams.forEach((param) => {
20152
+ showWarningsForAttributes(param, ["name", "value"]);
20153
+ const paramName = (
20154
+ /** @type {keyof SweetAlertOptions} */
20155
+ param.getAttribute("name")
20156
+ );
20157
+ const value = param.getAttribute("value");
20158
+ if (!paramName || !value) {
20159
+ return;
20160
+ }
20161
+ if (typeof defaultParams[paramName] === "boolean") {
20162
+ result[paramName] = value !== "false";
20163
+ } else if (typeof defaultParams[paramName] === "object") {
20164
+ result[paramName] = JSON.parse(value);
20165
+ } else {
20166
+ result[paramName] = value;
20167
+ }
20168
+ });
20169
+ return result;
20170
+ };
20171
+ const getSwalFunctionParams = (templateContent) => {
20172
+ const result = {};
20173
+ const swalFunctions = Array.from(templateContent.querySelectorAll("swal-function-param"));
20174
+ swalFunctions.forEach((param) => {
20175
+ const paramName = (
20176
+ /** @type {keyof SweetAlertOptions} */
20177
+ param.getAttribute("name")
20178
+ );
20179
+ const value = param.getAttribute("value");
20180
+ if (!paramName || !value) {
20181
+ return;
20182
+ }
20183
+ result[paramName] = new Function(`return ${value}`)();
20184
+ });
20185
+ return result;
20186
+ };
20187
+ const getSwalButtons = (templateContent) => {
20188
+ const result = {};
20189
+ const swalButtons = Array.from(templateContent.querySelectorAll("swal-button"));
20190
+ swalButtons.forEach((button) => {
20191
+ showWarningsForAttributes(button, ["type", "color", "aria-label"]);
20192
+ const type = button.getAttribute("type");
20193
+ if (!type || !["confirm", "cancel", "deny"].includes(type)) {
20194
+ return;
20195
+ }
20196
+ result[`${type}ButtonText`] = button.innerHTML;
20197
+ result[`show${capitalizeFirstLetter(type)}Button`] = true;
20198
+ if (button.hasAttribute("color")) {
20199
+ result[`${type}ButtonColor`] = button.getAttribute("color");
20200
+ }
20201
+ if (button.hasAttribute("aria-label")) {
20202
+ result[`${type}ButtonAriaLabel`] = button.getAttribute("aria-label");
20203
+ }
20204
+ });
20205
+ return result;
20206
+ };
20207
+ const getSwalImage = (templateContent) => {
20208
+ const result = {};
20209
+ const image = templateContent.querySelector("swal-image");
20210
+ if (image) {
20211
+ showWarningsForAttributes(image, ["src", "width", "height", "alt"]);
20212
+ if (image.hasAttribute("src")) {
20213
+ result.imageUrl = image.getAttribute("src") || void 0;
20214
+ }
20215
+ if (image.hasAttribute("width")) {
20216
+ result.imageWidth = image.getAttribute("width") || void 0;
20217
+ }
20218
+ if (image.hasAttribute("height")) {
20219
+ result.imageHeight = image.getAttribute("height") || void 0;
20220
+ }
20221
+ if (image.hasAttribute("alt")) {
20222
+ result.imageAlt = image.getAttribute("alt") || void 0;
20223
+ }
20224
+ }
20225
+ return result;
20226
+ };
20227
+ const getSwalIcon = (templateContent) => {
20228
+ const result = {};
20229
+ const icon = templateContent.querySelector("swal-icon");
20230
+ if (icon) {
20231
+ showWarningsForAttributes(icon, ["type", "color"]);
20232
+ if (icon.hasAttribute("type")) {
20233
+ result.icon = icon.getAttribute("type");
20234
+ }
20235
+ if (icon.hasAttribute("color")) {
20236
+ result.iconColor = icon.getAttribute("color");
20237
+ }
20238
+ result.iconHtml = icon.innerHTML;
20239
+ }
20240
+ return result;
20241
+ };
20242
+ const getSwalInput = (templateContent) => {
20243
+ const result = {};
20244
+ const input = templateContent.querySelector("swal-input");
20245
+ if (input) {
20246
+ showWarningsForAttributes(input, ["type", "label", "placeholder", "value"]);
20247
+ result.input = input.getAttribute("type") || "text";
20248
+ if (input.hasAttribute("label")) {
20249
+ result.inputLabel = input.getAttribute("label");
20250
+ }
20251
+ if (input.hasAttribute("placeholder")) {
20252
+ result.inputPlaceholder = input.getAttribute("placeholder");
20253
+ }
20254
+ if (input.hasAttribute("value")) {
20255
+ result.inputValue = input.getAttribute("value");
20256
+ }
20257
+ }
20258
+ const inputOptions = Array.from(templateContent.querySelectorAll("swal-input-option"));
20259
+ if (inputOptions.length) {
20260
+ result.inputOptions = {};
20261
+ inputOptions.forEach((option) => {
20262
+ showWarningsForAttributes(option, ["value"]);
20263
+ const optionValue = option.getAttribute("value");
20264
+ if (!optionValue) {
20265
+ return;
20266
+ }
20267
+ const optionName = option.innerHTML;
20268
+ result.inputOptions[optionValue] = optionName;
20269
+ });
20270
+ }
20271
+ return result;
20272
+ };
20273
+ const getSwalStringParams = (templateContent, paramNames) => {
20274
+ const result = {};
20275
+ for (const i in paramNames) {
20276
+ const paramName = paramNames[i];
20277
+ const tag = templateContent.querySelector(paramName);
20278
+ if (tag) {
20279
+ showWarningsForAttributes(tag, []);
20280
+ result[paramName.replace(/^swal-/, "")] = tag.innerHTML.trim();
20281
+ }
20282
+ }
20283
+ return result;
20284
+ };
20285
+ const showWarningsForElements = (templateContent) => {
20286
+ const allowedElements = swalStringParams.concat(["swal-param", "swal-function-param", "swal-button", "swal-image", "swal-icon", "swal-input", "swal-input-option"]);
20287
+ Array.from(templateContent.children).forEach((el) => {
20288
+ const tagName = el.tagName.toLowerCase();
20289
+ if (!allowedElements.includes(tagName)) {
20290
+ warn(`Unrecognized element <${tagName}>`);
20291
+ }
20292
+ });
20293
+ };
20294
+ const showWarningsForAttributes = (el, allowedAttributes) => {
20295
+ Array.from(el.attributes).forEach((attribute) => {
20296
+ if (allowedAttributes.indexOf(attribute.name) === -1) {
20297
+ warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(", ")}` : "To set the value, use HTML within the element."}`]);
20298
+ }
20299
+ });
20300
+ };
20301
+ const SHOW_CLASS_TIMEOUT = 10;
20302
+ const openPopup = (params) => {
20303
+ const container = getContainer();
20304
+ const popup = getPopup();
20305
+ if (typeof params.willOpen === "function") {
20306
+ params.willOpen(popup);
20307
+ }
20308
+ globalState.eventEmitter.emit("willOpen", popup);
20309
+ const bodyStyles = window.getComputedStyle(document.body);
20310
+ const initialBodyOverflow = bodyStyles.overflowY;
20311
+ addClasses(container, popup, params);
20312
+ setTimeout(() => {
20313
+ setScrollingVisibility(container, popup);
20314
+ }, SHOW_CLASS_TIMEOUT);
20315
+ if (isModal()) {
20316
+ fixScrollContainer(container, params.scrollbarPadding, initialBodyOverflow);
20317
+ setAriaHidden();
20318
+ }
20319
+ if (!isToast() && !globalState.previousActiveElement) {
20320
+ globalState.previousActiveElement = document.activeElement;
20321
+ }
20322
+ if (typeof params.didOpen === "function") {
20323
+ setTimeout(() => params.didOpen(popup));
20324
+ }
20325
+ globalState.eventEmitter.emit("didOpen", popup);
20326
+ removeClass(container, swalClasses["no-transition"]);
20327
+ };
20328
+ const swalOpenAnimationFinished = (event) => {
20329
+ const popup = getPopup();
20330
+ if (event.target !== popup) {
20331
+ return;
20332
+ }
20333
+ const container = getContainer();
20334
+ popup.removeEventListener("animationend", swalOpenAnimationFinished);
20335
+ popup.removeEventListener("transitionend", swalOpenAnimationFinished);
20336
+ container.style.overflowY = "auto";
20337
+ };
20338
+ const setScrollingVisibility = (container, popup) => {
20339
+ if (hasCssAnimation(popup)) {
20340
+ container.style.overflowY = "hidden";
20341
+ popup.addEventListener("animationend", swalOpenAnimationFinished);
20342
+ popup.addEventListener("transitionend", swalOpenAnimationFinished);
20343
+ } else {
20344
+ container.style.overflowY = "auto";
20345
+ }
20346
+ };
20347
+ const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
20348
+ iOSfix();
20349
+ if (scrollbarPadding && initialBodyOverflow !== "hidden") {
20350
+ replaceScrollbarWithPadding(initialBodyOverflow);
20351
+ }
20352
+ setTimeout(() => {
20353
+ container.scrollTop = 0;
20354
+ });
20355
+ };
20356
+ const addClasses = (container, popup, params) => {
20357
+ addClass(container, params.showClass.backdrop);
20358
+ if (params.animation) {
20359
+ popup.style.setProperty("opacity", "0", "important");
20360
+ show(popup, "grid");
20361
+ setTimeout(() => {
20362
+ addClass(popup, params.showClass.popup);
20363
+ popup.style.removeProperty("opacity");
20364
+ }, SHOW_CLASS_TIMEOUT);
20365
+ } else {
20366
+ show(popup, "grid");
20367
+ }
20368
+ addClass([document.documentElement, document.body], swalClasses.shown);
20369
+ if (params.heightAuto && params.backdrop && !params.toast) {
20370
+ addClass([document.documentElement, document.body], swalClasses["height-auto"]);
20371
+ }
20372
+ };
20373
+ var defaultInputValidators = {
20374
+ /**
20375
+ * @param {string} string
20376
+ * @param {string} [validationMessage]
20377
+ * @returns {Promise<string | void>}
20378
+ */
20379
+ email: (string, validationMessage) => {
20380
+ return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || "Invalid email address");
20381
+ },
20382
+ /**
20383
+ * @param {string} string
20384
+ * @param {string} [validationMessage]
20385
+ * @returns {Promise<string | void>}
20386
+ */
20387
+ url: (string, validationMessage) => {
20388
+ return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || "Invalid URL");
20389
+ }
20390
+ };
20391
+ function setDefaultInputValidators(params) {
20392
+ if (params.inputValidator) {
20393
+ return;
20394
+ }
20395
+ if (params.input === "email") {
20396
+ params.inputValidator = defaultInputValidators["email"];
20397
+ }
20398
+ if (params.input === "url") {
20399
+ params.inputValidator = defaultInputValidators["url"];
20400
+ }
20401
+ }
20402
+ function validateCustomTargetElement(params) {
20403
+ if (!params.target || typeof params.target === "string" && !document.querySelector(params.target) || typeof params.target !== "string" && !params.target.appendChild) {
20404
+ warn('Target parameter is not valid, defaulting to "body"');
20405
+ params.target = "body";
20406
+ }
20407
+ }
20408
+ function setParameters(params) {
20409
+ setDefaultInputValidators(params);
20410
+ if (params.showLoaderOnConfirm && !params.preConfirm) {
20411
+ warn("showLoaderOnConfirm is set to true, but preConfirm is not defined.\nshowLoaderOnConfirm should be used together with preConfirm, see usage example:\nhttps://sweetalert2.github.io/#ajax-request");
20412
+ }
20413
+ validateCustomTargetElement(params);
20414
+ if (typeof params.title === "string") {
20415
+ params.title = params.title.split("\n").join("<br />");
20416
+ }
20417
+ init(params);
20418
+ }
20419
+ let currentInstance;
20420
+ var _promise = /* @__PURE__ */ new WeakMap();
20421
+ class SweetAlert {
20422
+ /**
20423
+ * @param {...any} args
20424
+ * @this {SweetAlert}
20425
+ */
20426
+ constructor(...args) {
20427
+ _classPrivateFieldInitSpec(this, _promise, void 0);
20428
+ if (typeof window === "undefined") {
20429
+ return;
20430
+ }
20431
+ currentInstance = this;
20432
+ const outerParams = Object.freeze(this.constructor.argsToParams(args));
20433
+ this.params = outerParams;
20434
+ this.isAwaitingPromise = false;
20435
+ _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
20436
+ }
20437
+ _main(userParams, mixinParams = {}) {
20438
+ showWarningsForParams(Object.assign({}, mixinParams, userParams));
20439
+ if (globalState.currentInstance) {
20440
+ const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
20441
+ const {
20442
+ isAwaitingPromise
20443
+ } = globalState.currentInstance;
20444
+ globalState.currentInstance._destroy();
20445
+ if (!isAwaitingPromise) {
20446
+ swalPromiseResolve({
20447
+ isDismissed: true
20448
+ });
20449
+ }
20450
+ if (isModal()) {
20451
+ unsetAriaHidden();
20452
+ }
20453
+ }
20454
+ globalState.currentInstance = currentInstance;
20455
+ const innerParams = prepareParams(userParams, mixinParams);
20456
+ setParameters(innerParams);
20457
+ Object.freeze(innerParams);
20458
+ if (globalState.timeout) {
20459
+ globalState.timeout.stop();
20460
+ delete globalState.timeout;
20461
+ }
20462
+ clearTimeout(globalState.restoreFocusTimeout);
20463
+ const domCache = populateDomCache(currentInstance);
20464
+ render(currentInstance, innerParams);
20465
+ privateProps.innerParams.set(currentInstance, innerParams);
20466
+ return swalPromise(currentInstance, domCache, innerParams);
20467
+ }
20468
+ // `catch` cannot be the name of a module export, so we define our thenable methods here instead
20469
+ then(onFulfilled) {
20470
+ return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
20471
+ }
20472
+ finally(onFinally) {
20473
+ return _classPrivateFieldGet2(_promise, this).finally(onFinally);
20474
+ }
20475
+ }
20476
+ const swalPromise = (instance, domCache, innerParams) => {
20477
+ return new Promise((resolve2, reject) => {
20478
+ const dismissWith = (dismiss) => {
20479
+ instance.close({
20480
+ isDismissed: true,
20481
+ dismiss
20482
+ });
20483
+ };
20484
+ privateMethods.swalPromiseResolve.set(instance, resolve2);
20485
+ privateMethods.swalPromiseReject.set(instance, reject);
20486
+ domCache.confirmButton.onclick = () => {
20487
+ handleConfirmButtonClick(instance);
20488
+ };
20489
+ domCache.denyButton.onclick = () => {
20490
+ handleDenyButtonClick(instance);
20491
+ };
20492
+ domCache.cancelButton.onclick = () => {
20493
+ handleCancelButtonClick(instance, dismissWith);
20494
+ };
20495
+ domCache.closeButton.onclick = () => {
20496
+ dismissWith(DismissReason.close);
20497
+ };
20498
+ handlePopupClick(innerParams, domCache, dismissWith);
20499
+ addKeydownHandler(globalState, innerParams, dismissWith);
20500
+ handleInputOptionsAndValue(instance, innerParams);
20501
+ openPopup(innerParams);
20502
+ setupTimer(globalState, innerParams, dismissWith);
20503
+ initFocus(domCache, innerParams);
20504
+ setTimeout(() => {
20505
+ domCache.container.scrollTop = 0;
20506
+ });
20507
+ });
20508
+ };
20509
+ const prepareParams = (userParams, mixinParams) => {
20510
+ const templateParams = getTemplateParams(userParams);
20511
+ const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams);
20512
+ params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
20513
+ params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
20514
+ if (params.animation === false) {
20515
+ params.showClass = {
20516
+ backdrop: "swal2-noanimation"
20517
+ };
20518
+ params.hideClass = {};
20519
+ }
20520
+ return params;
20521
+ };
20522
+ const populateDomCache = (instance) => {
20523
+ const domCache = {
20524
+ popup: getPopup(),
20525
+ container: getContainer(),
20526
+ actions: getActions(),
20527
+ confirmButton: getConfirmButton(),
20528
+ denyButton: getDenyButton(),
20529
+ cancelButton: getCancelButton(),
20530
+ loader: getLoader(),
20531
+ closeButton: getCloseButton(),
20532
+ validationMessage: getValidationMessage(),
20533
+ progressSteps: getProgressSteps()
20534
+ };
20535
+ privateProps.domCache.set(instance, domCache);
20536
+ return domCache;
20537
+ };
20538
+ const setupTimer = (globalState2, innerParams, dismissWith) => {
20539
+ const timerProgressBar = getTimerProgressBar();
20540
+ hide(timerProgressBar);
20541
+ if (innerParams.timer) {
20542
+ globalState2.timeout = new Timer(() => {
20543
+ dismissWith("timer");
20544
+ delete globalState2.timeout;
20545
+ }, innerParams.timer);
20546
+ if (innerParams.timerProgressBar) {
20547
+ show(timerProgressBar);
20548
+ applyCustomClass(timerProgressBar, innerParams, "timerProgressBar");
20549
+ setTimeout(() => {
20550
+ if (globalState2.timeout && globalState2.timeout.running) {
20551
+ animateTimerProgressBar(innerParams.timer);
20552
+ }
20553
+ });
20554
+ }
20555
+ }
20556
+ };
20557
+ const initFocus = (domCache, innerParams) => {
20558
+ if (innerParams.toast) {
20559
+ return;
20560
+ }
20561
+ if (!callIfFunction(innerParams.allowEnterKey)) {
20562
+ warnAboutDeprecation("allowEnterKey");
20563
+ blurActiveElement();
20564
+ return;
20565
+ }
20566
+ if (focusAutofocus(domCache)) {
20567
+ return;
20568
+ }
20569
+ if (focusButton(domCache, innerParams)) {
20570
+ return;
20571
+ }
20572
+ setFocus(-1, 1);
20573
+ };
20574
+ const focusAutofocus = (domCache) => {
20575
+ const autofocusElements = Array.from(domCache.popup.querySelectorAll("[autofocus]"));
20576
+ for (const autofocusElement of autofocusElements) {
20577
+ if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
20578
+ autofocusElement.focus();
20579
+ return true;
20580
+ }
20581
+ }
20582
+ return false;
20583
+ };
20584
+ const focusButton = (domCache, innerParams) => {
20585
+ if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
20586
+ domCache.denyButton.focus();
20587
+ return true;
20588
+ }
20589
+ if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
20590
+ domCache.cancelButton.focus();
20591
+ return true;
20592
+ }
20593
+ if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
20594
+ domCache.confirmButton.focus();
20595
+ return true;
20596
+ }
20597
+ return false;
20598
+ };
20599
+ const blurActiveElement = () => {
20600
+ if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === "function") {
20601
+ document.activeElement.blur();
20602
+ }
20603
+ };
20604
+ SweetAlert.prototype.disableButtons = disableButtons;
20605
+ SweetAlert.prototype.enableButtons = enableButtons;
20606
+ SweetAlert.prototype.getInput = getInput;
20607
+ SweetAlert.prototype.disableInput = disableInput;
20608
+ SweetAlert.prototype.enableInput = enableInput;
20609
+ SweetAlert.prototype.hideLoading = hideLoading;
20610
+ SweetAlert.prototype.disableLoading = hideLoading;
20611
+ SweetAlert.prototype.showValidationMessage = showValidationMessage;
20612
+ SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
20613
+ SweetAlert.prototype.close = close;
20614
+ SweetAlert.prototype.closePopup = close;
20615
+ SweetAlert.prototype.closeModal = close;
20616
+ SweetAlert.prototype.closeToast = close;
20617
+ SweetAlert.prototype.rejectPromise = rejectPromise;
20618
+ SweetAlert.prototype.update = update;
20619
+ SweetAlert.prototype._destroy = _destroy;
20620
+ Object.assign(SweetAlert, staticMethods);
20621
+ Object.keys(instanceMethods).forEach((key) => {
20622
+ SweetAlert[key] = function(...args) {
20623
+ if (currentInstance && currentInstance[key]) {
20624
+ return currentInstance[key](...args);
20625
+ }
20626
+ return null;
20627
+ };
20628
+ });
20629
+ SweetAlert.DismissReason = DismissReason;
20630
+ SweetAlert.version = "11.22.5";
20631
+ const Swal2 = SweetAlert;
20632
+ Swal2.default = Swal2;
20633
+ return Swal2;
20634
+ });
20635
+ if (typeof exports !== "undefined" && exports.Sweetalert2) {
20636
+ exports.swal = exports.sweetAlert = exports.Swal = exports.SweetAlert = exports.Sweetalert2;
20637
+ }
20638
+ "undefined" != typeof document && function(e, t) {
20639
+ var n = e.createElement("style");
20640
+ if (e.getElementsByTagName("head")[0].appendChild(n), n.styleSheet)
20641
+ n.styleSheet.disabled || (n.styleSheet.cssText = t);
20642
+ else
20643
+ try {
20644
+ n.innerHTML = t;
20645
+ } catch (e2) {
20646
+ n.innerText = t;
20647
+ }
20648
+ }(document, ':root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.1s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px $swal2-outline-color;--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:"top-start top top-end" "center-start center center-end" "bottom-start bottom-center bottom-end";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;word-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:"!";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:scale(0.7)}45%{transform:scale(1.05)}80%{transform:scale(0.95)}100%{transform:scale(1)}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(0.5);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}');
20649
+ }
20650
+ });
20651
+
17580
20652
  // node_modules/@rails/actioncable/src/adapters.js
17581
20653
  var adapters_default;
17582
20654
  var init_adapters = __esm({
@@ -20779,7 +23851,7 @@ ${m = t3 ? m : H(m, ",")}
20779
23851
 
20780
23852
  // app/javascript/easy_admin/controllers/select_field_controller.js
20781
23853
  var select_field_controller_default = class extends Controller {
20782
- static targets = ["search", "dropdown", "selectedItems", "option", "hiddenInput", "display", "noResults", "loading"];
23854
+ static targets = ["search", "dropdown", "selectedItems", "option", "hiddenInput", "display", "noResults", "loading", "searchInput", "optionsContainer"];
20783
23855
  static values = { multiple: Boolean, placeholder: String, suggest: Boolean, suggestUrl: String };
20784
23856
  connect() {
20785
23857
  this.setupDropdown();
@@ -21207,6 +24279,34 @@ ${m = t3 ? m : H(m, ",")}
21207
24279
  this.loadingTarget.style.display = "none";
21208
24280
  }
21209
24281
  }
24282
+ // Filter options for index page filters
24283
+ filterOptions(event) {
24284
+ const searchTerm = event.target.value.toLowerCase();
24285
+ if (this.hasOptionsContainerTarget) {
24286
+ const options = this.optionsContainerTarget.querySelectorAll('[data-select-field-target="option"]');
24287
+ let visibleCount = 0;
24288
+ options.forEach((option) => {
24289
+ const text = option.textContent.toLowerCase();
24290
+ if (text.includes(searchTerm)) {
24291
+ option.style.display = "block";
24292
+ visibleCount++;
24293
+ } else {
24294
+ option.style.display = "none";
24295
+ }
24296
+ });
24297
+ if (visibleCount === 0 && this.hasNoResultsTarget) {
24298
+ this.noResultsTarget.style.display = "block";
24299
+ this.noResultsTarget.textContent = "No results found";
24300
+ } else if (this.hasNoResultsTarget) {
24301
+ this.noResultsTarget.style.display = "none";
24302
+ }
24303
+ } else {
24304
+ this.filter(event);
24305
+ }
24306
+ }
24307
+ stopPropagation(event) {
24308
+ event.stopPropagation();
24309
+ }
21210
24310
  };
21211
24311
 
21212
24312
  // node_modules/@kurkle/color/dist/color.esm.js
@@ -37858,6 +40958,102 @@ ${m = t3 ? m : H(m, ",")}
37858
40958
  }
37859
40959
  };
37860
40960
 
40961
+ // app/javascript/easy_admin/controllers/version_revert_controller.js
40962
+ var import_sweetalert2 = __toESM(require_sweetalert2_all());
40963
+ var version_revert_controller_default = class extends Controller {
40964
+ static values = {
40965
+ versionId: Number,
40966
+ resourceId: String,
40967
+ resourceName: String
40968
+ };
40969
+ confirm(event) {
40970
+ event.preventDefault();
40971
+ import_sweetalert2.default.fire({
40972
+ title: "Revert to Version?",
40973
+ html: `Are you sure you want to revert to version <strong>#${this.versionIdValue}</strong>?<br><br>This will restore the old data and create a new version entry.`,
40974
+ icon: "question",
40975
+ showCancelButton: true,
40976
+ confirmButtonText: "Yes, Revert",
40977
+ cancelButtonText: "Cancel",
40978
+ reverseButtons: true,
40979
+ focusCancel: true,
40980
+ ...this.getAdminPanelStyles()
40981
+ }).then((result) => {
40982
+ if (result.isConfirmed) {
40983
+ this.performRevert();
40984
+ }
40985
+ });
40986
+ }
40987
+ async performRevert() {
40988
+ const url = `/admin/${this.resourceNameValue}/${this.resourceIdValue}/versions/${this.versionIdValue}/revert`;
40989
+ import_sweetalert2.default.fire({
40990
+ title: "Reverting...",
40991
+ text: `Restoring version #${this.versionIdValue}`,
40992
+ allowOutsideClick: false,
40993
+ allowEscapeKey: false,
40994
+ showConfirmButton: false,
40995
+ didOpen: () => {
40996
+ import_sweetalert2.default.showLoading();
40997
+ },
40998
+ ...this.getAdminPanelStyles()
40999
+ });
41000
+ try {
41001
+ const request = new FetchRequest("post", url, {
41002
+ headers: {
41003
+ "X-CSRF-Token": document.querySelector('meta[name="csrf-token"]').content,
41004
+ "Accept": "text/vnd.turbo-stream.html"
41005
+ }
41006
+ });
41007
+ const response = await request.perform();
41008
+ if (response.ok) {
41009
+ import_sweetalert2.default.fire({
41010
+ title: "Success!",
41011
+ text: `Reverted to version #${this.versionIdValue}`,
41012
+ icon: "success",
41013
+ timer: 1500,
41014
+ showConfirmButton: false,
41015
+ ...this.getAdminPanelStyles()
41016
+ }).then(() => {
41017
+ window.location.reload();
41018
+ });
41019
+ } else {
41020
+ console.error("Revert failed:", response.statusText);
41021
+ this.showError("Failed to revert. Please try again.");
41022
+ }
41023
+ } catch (error2) {
41024
+ console.error("Revert error:", error2);
41025
+ this.showError("An error occurred while reverting. Please try again.");
41026
+ }
41027
+ }
41028
+ showError(message) {
41029
+ import_sweetalert2.default.fire({
41030
+ title: "Error",
41031
+ text: message,
41032
+ icon: "error",
41033
+ confirmButtonText: "OK",
41034
+ ...this.getAdminPanelStyles()
41035
+ });
41036
+ }
41037
+ getAdminPanelStyles() {
41038
+ return {
41039
+ buttonsStyling: false,
41040
+ customClass: {
41041
+ popup: "easy-admin-swal-popup",
41042
+ title: "easy-admin-swal-title",
41043
+ htmlContainer: "easy-admin-swal-content",
41044
+ confirmButton: "easy-admin-swal-confirm-button",
41045
+ cancelButton: "easy-admin-swal-cancel-button",
41046
+ actions: "easy-admin-swal-actions"
41047
+ },
41048
+ background: "#ffffff",
41049
+ backdrop: "rgba(0, 0, 0, 0.4)",
41050
+ width: "28rem",
41051
+ padding: "0",
41052
+ borderRadius: "0.75rem"
41053
+ };
41054
+ }
41055
+ };
41056
+
37861
41057
  // app/javascript/easy_admin/controllers.js
37862
41058
  application.register("sidebar", sidebar_controller_default);
37863
41059
  application.register("sidebar-nav", sidebar_nav_controller_default);
@@ -37884,6 +41080,7 @@ ${m = t3 ? m : H(m, ",")}
37884
41080
  application.register("row-modal", row_modal_controller_default);
37885
41081
  application.register("row-action", row_action_controller_default);
37886
41082
  application.register("jsoneditor", jsoneditor_controller_default);
41083
+ application.register("version-revert", version_revert_controller_default);
37887
41084
 
37888
41085
  // node_modules/@hotwired/turbo/dist/turbo.es2017-esm.js
37889
41086
  var turbo_es2017_esm_exports = {};
@@ -43472,6 +46669,12 @@ jsoneditor/dist/jsoneditor.min.js:
43472
46669
  *)
43473
46670
  (** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *)
43474
46671
 
46672
+ sweetalert2/dist/sweetalert2.all.js:
46673
+ (*!
46674
+ * sweetalert2 v11.22.5
46675
+ * Released under the MIT License.
46676
+ *)
46677
+
43475
46678
  @kurkle/color/dist/color.esm.js:
43476
46679
  (*!
43477
46680
  * @kurkle/color v0.3.4