PT 助手

私密种子站点的助手

  1. // ==UserScript==
  2. // @name PT Helper
  3. // @name:zh-CN PT 助手
  4. // @version 0.1.23
  5. // @namespace https://github.com/amorphobia/pt-helper
  6. // @description A helper for private trackers
  7. // @description:zh-CN 私密种子站点的助手
  8. // @author amorphobia
  9. // @homepage https://github.com/amorphobia/pt-helper
  10. // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2Ij48cGF0aCBmaWxsPSIjNjc4IiBkPSJNMTYwLDE3MGwtNTYtMjhhNTMsNTMsMCwwLDAsMC0yOGw1Ni0yOGE1Myw1MywwLDEsMC05LTE5bC01NiwyOGE1Myw1MywwLDEsMCwwLDY2bDU2LDI4YTUzLDUzLDAsMSwwLDktMTkiLz48Y2lyY2xlIGZpbGw9IiMwZjkiIGN4PSIyMDIiIGN5PSI1MyIgcj0iMzMiLz48Y2lyY2xlIGZpbGw9IiM3Y2UiIGN4PSIyMDIiIGN5PSIyMDIiIHI9IjMzIi8+PGNpcmNsZSBmaWxsPSIjZjU1IiBjeD0iNTMiIGN5PSIxMjgiIHI9IjMzIi8+PC9zdmc+
  11. // @supportURL https://github.com/amorphobia/pt-helper/issues
  12. // @license AGPL-3.0-or-later
  13. // @match *://carpt.net/*
  14. // @match *://hhanclub.top/*
  15. // @match *://kamept.com/*
  16. // @match *://nanyangpt.com/*
  17. // @match *://pt.2xfree.org/*
  18. // @match *://pt.btschool.club/*
  19. // @match *://pt.sjtu.edu.cn/*
  20. // @match *://pterclub.com/*
  21. // @match *://tjupt.org/*
  22. // @match *://u2.dmhy.org/*
  23. // @match *://www.hdarea.co/*
  24. // @match *://www.htpt.cc/*
  25. // @match *://www.icc2022.com/*
  26. // @match *://zmpt.cc/*
  27. // @require https://cdn.jsdelivr.net/npm/clipboard@2.0.11
  28. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11.4.8
  29. // @require https://cdn.jsdelivr.net/npm/ua-parser-js@1.0.33
  30. // @grant GM_addStyle
  31. // @grant GM_getValue
  32. // @grant GM_info
  33. // @grant GM_notification
  34. // @grant GM_openInTab
  35. // @grant GM_registerMenuCommand
  36. // @grant GM_setValue
  37. // @grant GM_unregisterMenuCommand
  38. // @grant GM_xmlhttpRequest
  39. // @noframes
  40. // ==/UserScript==
  41.  
  42. /******/ (() => { // webpackBootstrap
  43. /******/ var __webpack_modules__ = ([
  44. /* 0 */,
  45. /* 1 */
  46. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  47.  
  48. "use strict";
  49.  
  50. Object.defineProperty(exports, "__esModule", ({ value: true }));
  51. exports.CarPT = void 0;
  52. const NexusPHP_1 = __webpack_require__(2);
  53. const i18n_1 = __webpack_require__(4);
  54. class CarPT extends NexusPHP_1.NexusPHP {
  55. constructor() {
  56. super("carpt.net");
  57. this.menu_items = [
  58. {
  59. "id": "bannerHide",
  60. "type": "switch",
  61. "display": i18n_1.I18N[this.locale].bannerHideName,
  62. "name": i18n_1.I18N[this.locale].bannerHideName,
  63. "value": false
  64. },
  65. {
  66. "id": "attendance",
  67. "type": "switch",
  68. "display": i18n_1.I18N[this.locale].attendance,
  69. "name": i18n_1.I18N[this.locale].attendance,
  70. "value": true
  71. }
  72. ].concat(this.menu_items);
  73. }
  74. onLoad() {
  75. super.onLoad();
  76. }
  77. }
  78. exports.CarPT = CarPT;
  79.  
  80.  
  81. /***/ }),
  82. /* 2 */
  83. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  84.  
  85. "use strict";
  86.  
  87. var __importDefault = (this && this.__importDefault) || function (mod) {
  88. return (mod && mod.__esModule) ? mod : { "default": mod };
  89. };
  90. Object.defineProperty(exports, "__esModule", ({ value: true }));
  91. exports.NexusPHP = void 0;
  92. const common_1 = __webpack_require__(3);
  93. const clipboard_1 = __importDefault(__webpack_require__(8));
  94. const sweetalert2_1 = __importDefault(__webpack_require__(9));
  95. const i18n_1 = __webpack_require__(4);
  96. class NexusPHP extends common_1.Common {
  97. constructor(host) {
  98. super(host);
  99. this.passkey = "";
  100. this.menu_items = [
  101. {
  102. "id": "thanks",
  103. "type": "switch",
  104. "display": i18n_1.I18N[this.locale].thanks,
  105. "name": i18n_1.I18N[this.locale].thanks,
  106. "value": true
  107. },
  108. {
  109. "id": "directLink",
  110. "type": "switch",
  111. "display": i18n_1.I18N[this.locale].directLink,
  112. "name": i18n_1.I18N[this.locale].directLinkName,
  113. "value": true
  114. }
  115. ].concat(this.menu_items);
  116. }
  117. onLoad() {
  118. super.onLoad();
  119. this.getPasskey();
  120. this.tweakBanner();
  121. this.sayThanks();
  122. this.addDirectLink();
  123. this.attendance();
  124. }
  125. getPasskey() {
  126. const value = this.getHostValue("passkey");
  127. let passkey = "";
  128. if (value) {
  129. passkey = String(value);
  130. }
  131. if (passkey != "") {
  132. this.passkey = passkey;
  133. return;
  134. }
  135. if (location.href.indexOf("/usercp.php") >= 0) {
  136. if (this.extractPasskey(document)) {
  137. return;
  138. }
  139. }
  140. if (common_1.uaParser.getBrowser().name == "Safari"
  141. && common_1.uaParser.getOS().name == "Mac OS"
  142. && GM_info.scriptHandler == "Tampermonkey") {
  143. return;
  144. }
  145. const cp_url = "https://" + this.host + "/usercp.php";
  146. this.makeGetRequest(cp_url).then((responseText) => {
  147. const container = document.implementation.createHTMLDocument().documentElement;
  148. container.innerHTML = responseText;
  149. this.extractPasskey(container);
  150. });
  151. }
  152. extractPasskey(doc) {
  153. const re = /[\w\d]{32}/;
  154. const tds = doc.querySelectorAll("td.rowfollow");
  155. for (const td of tds) {
  156. const result = re.exec(td.innerHTML);
  157. if (result) {
  158. this.setHostValue("passkey", result[0]);
  159. this.passkey = result[0];
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165. tweakBanner() {
  166. if (this.getHostValue("bannerHide")) {
  167. this.css += `
  168. table.head {
  169. display: none;
  170. }
  171. table.mainouter {
  172. margin-top: 20px;
  173. }`;
  174. }
  175. }
  176. sayThanks(ms = 2000) {
  177. if (!this.getHostValue("thanks") || location.href.indexOf("/details.php") < 0) {
  178. return;
  179. }
  180. this.wait(ms).then(() => {
  181. const input = document.querySelector("#saythanks");
  182. if (input && !input.disabled) {
  183. input.click();
  184. }
  185. }).catch(() => { console.error("Failed to say thanks."); });
  186. }
  187. addDirectLink() {
  188. var _a;
  189. if (!this.getHostValue("directLink")) {
  190. return;
  191. }
  192. this.css += `
  193. .swal2-container {
  194. z-index: 4294967295;
  195. }
  196. h2#swal2-title {
  197. background-color: transparent;
  198. background-image: none;
  199. border: none;
  200. }
  201. img.torrent_direct_link {
  202. width: 16px;
  203. height: 16px;
  204. background: url('${common_1.direct_link_img_url}');
  205. padding-bottom: 1px;
  206. }`;
  207. if (this.passkey == "") {
  208. if (location.href.indexOf("/torrents.php") >= 0) {
  209. sweetalert2_1.default.fire({
  210. position: "top-end",
  211. icon: "info",
  212. title: `${i18n_1.I18N[this.locale].noPasskey}「${i18n_1.I18N[this.locale].directLinkName}」`,
  213. showConfirmButton: false,
  214. timer: 5000,
  215. toast: true
  216. });
  217. }
  218. return;
  219. }
  220. const id_re = /id=[\d]+/;
  221. const trs = document.querySelectorAll("table.torrentname > tbody > tr:nth-of-type(1)");
  222. for (const tr of trs) {
  223. const tds = tr.querySelectorAll("td");
  224. const td = tds.length < 3 ? tds[1] : tds.length < 4 ? tds[2] : tds[3];
  225. const dl = td.querySelector("a");
  226. const result = id_re.exec((_a = dl === null || dl === void 0 ? void 0 : dl.href) !== null && _a !== void 0 ? _a : "");
  227. if (!result) {
  228. continue;
  229. }
  230. const direct_link = `https://${this.host}/download.php?${result[0]}&passkey=${this.passkey}`;
  231. const img = document.createElement("img");
  232. img.setAttribute("src", "pic/trans.gif");
  233. img.setAttribute("class", "torrent_direct_link");
  234. img.setAttribute("alt", "DL");
  235. const a = document.createElement("a");
  236. a.setAttribute("title", i18n_1.I18N[this.locale].passkeyWarning);
  237. a.setAttribute("onclick", "return false");
  238. a.setAttribute("id", "direct_link");
  239. a.setAttribute("href", direct_link);
  240. a.setAttribute("data-clipboard-text", direct_link);
  241. a.appendChild(img);
  242. td.prepend(a);
  243. }
  244. this.registerClipboard("#direct_link");
  245. }
  246. registerClipboard(id) {
  247. const clip = new clipboard_1.default(id);
  248. clip.on("success", () => {
  249. sweetalert2_1.default.fire({
  250. position: "top-end",
  251. icon: "success",
  252. title: i18n_1.I18N[this.locale].copySuccess,
  253. showConfirmButton: false,
  254. timer: 2500,
  255. toast: true
  256. });
  257. });
  258. clip.on("error", err => {
  259. sweetalert2_1.default.fire({
  260. icon: "error",
  261. title: i18n_1.I18N[this.locale].copyError,
  262. html: `${i18n_1.I18N[this.locale].copyByHand}<br><input id="cb-input" style="width: 80%" value="${err.text}">`,
  263. didOpen: () => {
  264. var _a;
  265. (_a = document.getElementById("cb-input")) === null || _a === void 0 ? void 0 : _a.focus();
  266. }
  267. });
  268. });
  269. return clip;
  270. }
  271. attendance() {
  272. if (!this.getHostValue("attendance")) {
  273. return;
  274. }
  275. if (document.body.innerText.indexOf("签到已得") >= 0 || document.body.innerText.indexOf("Attend got") >= 0) {
  276. return;
  277. }
  278. const attend = document.querySelector("a.faqlink");
  279. if (attend) {
  280. this.css += `
  281. .swal2-container {
  282. z-index: 4294967295;
  283. }
  284. h2#swal2-title {
  285. background-color: transparent;
  286. background-image: none;
  287. border: none;
  288. }`;
  289. attend.onclick = () => {
  290. this.makeGetRequest("https://" + this.host + "/attendance.php").then((text) => {
  291. const re = /签到已得\d+|Attend got: \d+/;
  292. const result = re.exec(text);
  293. const icon = result ? "success" : "error";
  294. const title = result ? result[0] : i18n_1.I18N[this.locale].attendanceFail;
  295. sweetalert2_1.default.fire({
  296. position: "top",
  297. icon: icon,
  298. title: title,
  299. showConfirmButton: false,
  300. timer: 3000,
  301. toast: true,
  302. willOpen: (_popup) => {
  303. if (result && attend.parentElement) {
  304. const anchor = document.createElement("a");
  305. anchor.innerHTML = result[0];
  306. attend.parentElement.insertBefore(anchor, attend);
  307. attend.setAttribute("style", "display: none;");
  308. }
  309. }
  310. });
  311. });
  312. return false;
  313. };
  314. this.wait(2000).then(() => {
  315. attend.click();
  316. });
  317. }
  318. }
  319. }
  320. exports.NexusPHP = NexusPHP;
  321.  
  322.  
  323. /***/ }),
  324. /* 3 */
  325. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  326.  
  327. "use strict";
  328.  
  329. Object.defineProperty(exports, "__esModule", ({ value: true }));
  330. exports.Common = exports.uaParser = exports.direct_link_img_url = void 0;
  331. const i18n_1 = __webpack_require__(4);
  332. const ua_parser_js_1 = __webpack_require__(7);
  333. const helper_home = "https://github.com/amorphobia/pt-helper";
  334. const num_emoji = ["0️⃣", "1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"];
  335. exports.direct_link_img_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAH5QTFRFR3BMyKN4cz0Td3d3sLCw6enp////qHg4oaGhcz0TlpaWkV8opnU2lmQrjVklqHg4m2kvo3I03ruJiFMhn24y4r+N2raG5cSP9+jQg04e1rKD68uUnYpv6ceS0q5/fkkaoaGhzqp8h4eHr6+v+Pj4ekQXdkAV+/v78fHxy6Z6f0p3WgAAAAp0Uk5TAP///////5aWlrne7esAAACHSURBVBjTbc5HEsIwEERRA5qxLeecc77/BTEN0oq/m1ddKhnG36xxtPRhBq2UxyFlG5gAt5zXk+hc59IFRM3yQksTAdKOf3UpICxYCEFEXIQAL2NCnHkAJ/4s7jh2AH6uFrkPSOrvgrhOAFWvFn0FGCYWhDemAbBd6h/XBtgfuh1gP3X2fb4BlrkIUt3i2kgAAAAASUVORK5CYII=";
  336. exports.uaParser = new ua_parser_js_1.UAParser(navigator.userAgent);
  337. const impl_localse = new Map([
  338. ["en", "en"],
  339. ["zh", "zh-CN"],
  340. ["zh-CN", "zh-CN"],
  341. ["zh-Hans", "zh-CN"],
  342. ]);
  343. class Common {
  344. constructor(host) {
  345. this.host = "";
  346. this.locale = "en";
  347. this.host = host;
  348. for (const locale of navigator.languages) {
  349. const mapped_locale = impl_localse.get(locale);
  350. if (mapped_locale) {
  351. this.locale = mapped_locale;
  352. break;
  353. }
  354. }
  355. this.menu_items = [{
  356. "id": "feedback",
  357. "type": "link",
  358. "display": i18n_1.I18N[this.locale].feedback,
  359. "value": helper_home + "/issues"
  360. }];
  361. this.registered_items = [];
  362. this.css = "";
  363. }
  364. init() {
  365. for (const item of this.menu_items) {
  366. item.id = this.host + "_" + item.id;
  367. if ((item.type == "switch" || item.type == "selection") && GM_getValue(item.id) == null) {
  368. GM_setValue(item.id, item.value);
  369. }
  370. }
  371. this.registerMenu();
  372. }
  373. onLoad() { }
  374. addStyle() {
  375. if (typeof GM_addStyle !== "undefined") {
  376. GM_addStyle(this.css);
  377. }
  378. else {
  379. const style = document.createElement("style");
  380. style.appendChild(document.createTextNode(this.css));
  381. (document.querySelector("head") || document.documentElement).appendChild(style);
  382. }
  383. }
  384. registerMenu() {
  385. for (const item of this.registered_items) {
  386. GM_unregisterMenuCommand(item);
  387. }
  388. this.registered_items = [];
  389. for (const item of this.menu_items) {
  390. const value = GM_getValue(item.id);
  391. if (value != undefined && value != null) {
  392. item.value = value;
  393. }
  394. let reg_item;
  395. switch (item.type) {
  396. case "switch":
  397. reg_item = GM_registerMenuCommand(`${item.value ? "✅" : "❌"}${item.display}`, () => {
  398. this.toggleSwitch(item);
  399. });
  400. break;
  401. case "selection":
  402. reg_item = GM_registerMenuCommand(`${num_emoji[item.value]}${item.display[item.value]}`, () => {
  403. this.nextSelection(item);
  404. });
  405. break;
  406. case "link":
  407. reg_item = GM_registerMenuCommand(`${item.display}`, () => {
  408. GM_openInTab(item.value, { active: true, insert: true, setParent: true });
  409. });
  410. break;
  411. case "text":
  412. reg_item = GM_registerMenuCommand(`${item.display}`, () => { });
  413. break;
  414. default:
  415. console.log(`Unrecognized menu item: ${item.id}`);
  416. break;
  417. }
  418. if (reg_item !== undefined) {
  419. this.registered_items.push(reg_item);
  420. }
  421. }
  422. }
  423. toggleSwitch(item) {
  424. const status = item.value ? i18n_1.I18N[this.locale].turnOff : i18n_1.I18N[this.locale].turnOn;
  425. GM_setValue(item.id, !item.value);
  426. GM_notification({
  427. text: `${status}「${item.name}」\n${i18n_1.I18N[this.locale].reloadTakeEffect}`,
  428. timeout: 3500,
  429. onclick: () => { location.reload(); }
  430. });
  431. this.registerMenu();
  432. }
  433. nextSelection(item) {
  434. const new_value = (item.value + 1) % item.display.length;
  435. GM_setValue(item.id, new_value);
  436. GM_notification({
  437. text: `${i18n_1.I18N[this.locale].changeTo}「${item.display[new_value]}」\n${i18n_1.I18N[this.locale].reloadTakeEffect}`,
  438. timeout: 3500,
  439. onclick: () => { location.reload(); }
  440. });
  441. this.registerMenu();
  442. }
  443. wait(ms) {
  444. return new Promise((resolve) => {
  445. setTimeout(resolve, ms);
  446. });
  447. }
  448. getHostValue(id) {
  449. return GM_getValue(this.host + "_" + id);
  450. }
  451. setHostValue(id, value) {
  452. GM_setValue(this.host + "_" + id, value);
  453. }
  454. makeGetRequest(url) {
  455. return new Promise((resolve, reject) => {
  456. GM_xmlhttpRequest({
  457. method: "GET",
  458. url: url,
  459. onload: (response) => {
  460. resolve(response.responseText);
  461. },
  462. onerror: (error) => {
  463. reject(error);
  464. }
  465. });
  466. });
  467. }
  468. }
  469. exports.Common = Common;
  470.  
  471.  
  472. /***/ }),
  473. /* 4 */
  474. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  475.  
  476. "use strict";
  477.  
  478. Object.defineProperty(exports, "__esModule", ({ value: true }));
  479. exports.I18N = void 0;
  480. exports.I18N = {
  481. en: __webpack_require__(5),
  482. "zh-CN": __webpack_require__(6),
  483. };
  484.  
  485.  
  486. /***/ }),
  487. /* 5 */
  488. /***/ ((module) => {
  489.  
  490. "use strict";
  491. module.exports = JSON.parse('{"feedback":"💬Feedback","turnOn":"Turned on","turnOff":"Turned off","reloadTakeEffect":"(Click here to reload the page and take effect)","changeTo":"Changed to","thanks":"Auto say thanks","directLink":"Torrent direct link button (click the button to copy)","directLinkName":"Torrent direct link button","passkeyWarning":"Click to copy. Link contains secret passkey. DO NOT SHARE!","copySuccess":"Copied","copyError":"Failed to copy","copyByHand":"Please manually copy it.","bannerFold":"Auto fold the banner (invalid when hidding)","bannerFoldName":"Auto fold the banner","bannerHide":"Hide the banner (auto fold will be invalid)","bannerHideName":"Hide the banner","attendance":"Auto attend","showAllSticky":"Show all sticky torrents","hideSingleSticky":"Hide single sticky torrents","hideSingleDoubleSticky":"Hide single and double sticky torrents","hideAllSticky":"Hide all sticky torrents","colorBlind":"Color blind mode","attendanceFail":"Failed to do auto attendance. Please try again manually.","noPasskey":"Passkey not cached. Please go to control pannel or turn off option"}');
  492.  
  493. /***/ }),
  494. /* 6 */
  495. /***/ ((module) => {
  496.  
  497. "use strict";
  498. module.exports = JSON.parse('{"feedback":"💬反馈与建议","turnOn":"已开启","turnOff":"已关闭","reloadTakeEffect":"(点击这里刷新网页后生效)","changeTo":"切换为","thanks":"自动说谢谢","directLink":"种子直链按钮(左键点击按钮复制直链)","directLinkName":"种子直链按钮","passkeyWarning":"左键单击复制,链接中包含个人秘钥Passkey,切勿泄露!","copySuccess":"复制成功","copyError":"复制失败","copyByHand":"请手动复制","bannerFold":"自动折叠横幅(隐藏时折叠设置无效)","bannerFoldName":"自动折叠横幅","bannerHide":"隐藏横幅(隐藏时折叠设置无效)","bannerHideName":"隐藏横幅","attendance":"自动签到","showAllSticky":"显示所有置顶","hideSingleSticky":"隐藏一重置顶","hideSingleDoubleSticky":"隐藏一、二重置顶","hideAllSticky":"隐藏所有置顶","colorBlind":"色盲模式","attendanceFail":"自动签到失败,请手动重试","noPasskey":"未缓存 passkey,请前往控制面板或关掉选项"}');
  499.  
  500. /***/ }),
  501. /* 7 */
  502. /***/ (function(module, exports, __webpack_require__) {
  503.  
  504. var __WEBPACK_AMD_DEFINE_RESULT__;/////////////////////////////////////////////////////////////////////////////////
  505. /* UAParser.js v1.0.33
  506. Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
  507. MIT License *//*
  508. Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
  509. Supports browser & node.js environment.
  510. Demo : https://faisalman.github.io/ua-parser-js
  511. Source : https://github.com/faisalman/ua-parser-js */
  512. /////////////////////////////////////////////////////////////////////////////////
  513.  
  514. (function (window, undefined) {
  515.  
  516. 'use strict';
  517.  
  518. //////////////
  519. // Constants
  520. /////////////
  521.  
  522.  
  523. var LIBVERSION = '1.0.33',
  524. EMPTY = '',
  525. UNKNOWN = '?',
  526. FUNC_TYPE = 'function',
  527. UNDEF_TYPE = 'undefined',
  528. OBJ_TYPE = 'object',
  529. STR_TYPE = 'string',
  530. MAJOR = 'major',
  531. MODEL = 'model',
  532. NAME = 'name',
  533. TYPE = 'type',
  534. VENDOR = 'vendor',
  535. VERSION = 'version',
  536. ARCHITECTURE= 'architecture',
  537. CONSOLE = 'console',
  538. MOBILE = 'mobile',
  539. TABLET = 'tablet',
  540. SMARTTV = 'smarttv',
  541. WEARABLE = 'wearable',
  542. EMBEDDED = 'embedded',
  543. UA_MAX_LENGTH = 350;
  544.  
  545. var AMAZON = 'Amazon',
  546. APPLE = 'Apple',
  547. ASUS = 'ASUS',
  548. BLACKBERRY = 'BlackBerry',
  549. BROWSER = 'Browser',
  550. CHROME = 'Chrome',
  551. EDGE = 'Edge',
  552. FIREFOX = 'Firefox',
  553. GOOGLE = 'Google',
  554. HUAWEI = 'Huawei',
  555. LG = 'LG',
  556. MICROSOFT = 'Microsoft',
  557. MOTOROLA = 'Motorola',
  558. OPERA = 'Opera',
  559. SAMSUNG = 'Samsung',
  560. SHARP = 'Sharp',
  561. SONY = 'Sony',
  562. XIAOMI = 'Xiaomi',
  563. ZEBRA = 'Zebra',
  564. FACEBOOK = 'Facebook';
  565.  
  566. ///////////
  567. // Helper
  568. //////////
  569.  
  570. var extend = function (regexes, extensions) {
  571. var mergedRegexes = {};
  572. for (var i in regexes) {
  573. if (extensions[i] && extensions[i].length % 2 === 0) {
  574. mergedRegexes[i] = extensions[i].concat(regexes[i]);
  575. } else {
  576. mergedRegexes[i] = regexes[i];
  577. }
  578. }
  579. return mergedRegexes;
  580. },
  581. enumerize = function (arr) {
  582. var enums = {};
  583. for (var i=0; i<arr.length; i++) {
  584. enums[arr[i].toUpperCase()] = arr[i];
  585. }
  586. return enums;
  587. },
  588. has = function (str1, str2) {
  589. return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
  590. },
  591. lowerize = function (str) {
  592. return str.toLowerCase();
  593. },
  594. majorize = function (version) {
  595. return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split('.')[0] : undefined;
  596. },
  597. trim = function (str, len) {
  598. if (typeof(str) === STR_TYPE) {
  599. str = str.replace(/^\s\s*/, EMPTY);
  600. return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
  601. }
  602. };
  603.  
  604. ///////////////
  605. // Map helper
  606. //////////////
  607.  
  608. var rgxMapper = function (ua, arrays) {
  609.  
  610. var i = 0, j, k, p, q, matches, match;
  611.  
  612. // loop through all regexes maps
  613. while (i < arrays.length && !matches) {
  614.  
  615. var regex = arrays[i], // even sequence (0,2,4,..)
  616. props = arrays[i + 1]; // odd sequence (1,3,5,..)
  617. j = k = 0;
  618.  
  619. // try matching uastring with regexes
  620. while (j < regex.length && !matches) {
  621.  
  622. matches = regex[j++].exec(ua);
  623.  
  624. if (!!matches) {
  625. for (p = 0; p < props.length; p++) {
  626. match = matches[++k];
  627. q = props[p];
  628. // check if given property is actually array
  629. if (typeof q === OBJ_TYPE && q.length > 0) {
  630. if (q.length === 2) {
  631. if (typeof q[1] == FUNC_TYPE) {
  632. // assign modified match
  633. this[q[0]] = q[1].call(this, match);
  634. } else {
  635. // assign given value, ignore regex match
  636. this[q[0]] = q[1];
  637. }
  638. } else if (q.length === 3) {
  639. // check whether function or regex
  640. if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
  641. // call function (usually string mapper)
  642. this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined;
  643. } else {
  644. // sanitize match using given regex
  645. this[q[0]] = match ? match.replace(q[1], q[2]) : undefined;
  646. }
  647. } else if (q.length === 4) {
  648. this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined;
  649. }
  650. } else {
  651. this[q] = match ? match : undefined;
  652. }
  653. }
  654. }
  655. }
  656. i += 2;
  657. }
  658. },
  659.  
  660. strMapper = function (str, map) {
  661.  
  662. for (var i in map) {
  663. // check if current value is array
  664. if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
  665. for (var j = 0; j < map[i].length; j++) {
  666. if (has(map[i][j], str)) {
  667. return (i === UNKNOWN) ? undefined : i;
  668. }
  669. }
  670. } else if (has(map[i], str)) {
  671. return (i === UNKNOWN) ? undefined : i;
  672. }
  673. }
  674. return str;
  675. };
  676.  
  677. ///////////////
  678. // String map
  679. //////////////
  680.  
  681. // Safari < 3.0
  682. var oldSafariMap = {
  683. '1.0' : '/8',
  684. '1.2' : '/1',
  685. '1.3' : '/3',
  686. '2.0' : '/412',
  687. '2.0.2' : '/416',
  688. '2.0.3' : '/417',
  689. '2.0.4' : '/419',
  690. '?' : '/'
  691. },
  692. windowsVersionMap = {
  693. 'ME' : '4.90',
  694. 'NT 3.11' : 'NT3.51',
  695. 'NT 4.0' : 'NT4.0',
  696. '2000' : 'NT 5.0',
  697. 'XP' : ['NT 5.1', 'NT 5.2'],
  698. 'Vista' : 'NT 6.0',
  699. '7' : 'NT 6.1',
  700. '8' : 'NT 6.2',
  701. '8.1' : 'NT 6.3',
  702. '10' : ['NT 6.4', 'NT 10.0'],
  703. 'RT' : 'ARM'
  704. };
  705.  
  706. //////////////
  707. // Regex map
  708. /////////////
  709.  
  710. var regexes = {
  711.  
  712. browser : [[
  713.  
  714. /\b(?:crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
  715. ], [VERSION, [NAME, 'Chrome']], [
  716. /edg(?:e|ios|a)?\/([\w\.]+)/i // Microsoft Edge
  717. ], [VERSION, [NAME, 'Edge']], [
  718.  
  719. // Presto based
  720. /(opera mini)\/([-\w\.]+)/i, // Opera Mini
  721. /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i, // Opera Mobi/Tablet
  722. /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i // Opera
  723. ], [NAME, VERSION], [
  724. /opios[\/ ]+([\w\.]+)/i // Opera mini on iphone >= 8.0
  725. ], [VERSION, [NAME, OPERA+' Mini']], [
  726. /\bopr\/([\w\.]+)/i // Opera Webkit
  727. ], [VERSION, [NAME, OPERA]], [
  728.  
  729. // Mixed
  730. /(kindle)\/([\w\.]+)/i, // Kindle
  731. /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i, // Lunascape/Maxthon/Netfront/Jasmine/Blazer
  732. // Trident based
  733. /(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i, // Avant/IEMobile/SlimBrowser
  734. /(ba?idubrowser)[\/ ]?([\w\.]+)/i, // Baidu Browser
  735. /(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer
  736.  
  737. // Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
  738. /(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
  739. // Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ, aka ShouQ
  740. /(weibo)__([\d\.]+)/i // Weibo
  741. ], [NAME, VERSION], [
  742. /(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
  743. ], [VERSION, [NAME, 'UC'+BROWSER]], [
  744. /microm.+\bqbcore\/([\w\.]+)/i, // WeChat Desktop for Windows Built-in Browser
  745. /\bqbcore\/([\w\.]+).+microm/i
  746. ], [VERSION, [NAME, 'WeChat(Win) Desktop']], [
  747. /micromessenger\/([\w\.]+)/i // WeChat
  748. ], [VERSION, [NAME, 'WeChat']], [
  749. /konqueror\/([\w\.]+)/i // Konqueror
  750. ], [VERSION, [NAME, 'Konqueror']], [
  751. /trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i // IE11
  752. ], [VERSION, [NAME, 'IE']], [
  753. /yabrowser\/([\w\.]+)/i // Yandex
  754. ], [VERSION, [NAME, 'Yandex']], [
  755. /(avast|avg)\/([\w\.]+)/i // Avast/AVG Secure Browser
  756. ], [[NAME, /(.+)/, '$1 Secure '+BROWSER], VERSION], [
  757. /\bfocus\/([\w\.]+)/i // Firefox Focus
  758. ], [VERSION, [NAME, FIREFOX+' Focus']], [
  759. /\bopt\/([\w\.]+)/i // Opera Touch
  760. ], [VERSION, [NAME, OPERA+' Touch']], [
  761. /coc_coc\w+\/([\w\.]+)/i // Coc Coc Browser
  762. ], [VERSION, [NAME, 'Coc Coc']], [
  763. /dolfin\/([\w\.]+)/i // Dolphin
  764. ], [VERSION, [NAME, 'Dolphin']], [
  765. /coast\/([\w\.]+)/i // Opera Coast
  766. ], [VERSION, [NAME, OPERA+' Coast']], [
  767. /miuibrowser\/([\w\.]+)/i // MIUI Browser
  768. ], [VERSION, [NAME, 'MIUI '+BROWSER]], [
  769. /fxios\/([-\w\.]+)/i // Firefox for iOS
  770. ], [VERSION, [NAME, FIREFOX]], [
  771. /\bqihu|(qi?ho?o?|360)browser/i // 360
  772. ], [[NAME, '360 '+BROWSER]], [
  773. /(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i
  774. ], [[NAME, /(.+)/, '$1 '+BROWSER], VERSION], [ // Oculus/Samsung/Sailfish/Huawei Browser
  775. /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
  776. ], [[NAME, /_/g, ' '], VERSION], [
  777. /(electron)\/([\w\.]+) safari/i, // Electron-based App
  778. /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, // Tesla
  779. /m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/Baidu App/2345 Browser
  780. ], [NAME, VERSION], [
  781. /(metasr)[\/ ]?([\w\.]+)/i, // SouGouBrowser
  782. /(lbbrowser)/i, // LieBao Browser
  783. /\[(linkedin)app\]/i // LinkedIn App for iOS & Android
  784. ], [NAME], [
  785.  
  786. // WebView
  787. /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
  788. ], [[NAME, FACEBOOK], VERSION], [
  789. /safari (line)\/([\w\.]+)/i, // Line App for iOS
  790. /\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
  791. /(chromium|instagram)[\/ ]([-\w\.]+)/i // Chromium/Instagram
  792. ], [NAME, VERSION], [
  793. /\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
  794. ], [VERSION, [NAME, 'GSA']], [
  795.  
  796. /headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
  797. ], [VERSION, [NAME, CHROME+' Headless']], [
  798.  
  799. / wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
  800. ], [[NAME, CHROME+' WebView'], VERSION], [
  801.  
  802. /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
  803. ], [VERSION, [NAME, 'Android '+BROWSER]], [
  804.  
  805. /(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i // Chrome/OmniWeb/Arora/Tizen/Nokia
  806. ], [NAME, VERSION], [
  807.  
  808. /version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i // Mobile Safari
  809. ], [VERSION, [NAME, 'Mobile Safari']], [
  810. /version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
  811. ], [VERSION, NAME], [
  812. /webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
  813. ], [NAME, [VERSION, strMapper, oldSafariMap]], [
  814.  
  815. /(webkit|khtml)\/([\w\.]+)/i
  816. ], [NAME, VERSION], [
  817.  
  818. // Gecko based
  819. /(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
  820. ], [[NAME, 'Netscape'], VERSION], [
  821. /mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
  822. ], [VERSION, [NAME, FIREFOX+' Reality']], [
  823. /ekiohf.+(flow)\/([\w\.]+)/i, // Flow
  824. /(swiftfox)/i, // Swiftfox
  825. /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
  826. // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror/Klar
  827. /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
  828. // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
  829. /(firefox)\/([\w\.]+)/i, // Other Firefox-based
  830. /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i, // Mozilla
  831.  
  832. // Other
  833. /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
  834. // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser
  835. /(links) \(([\w\.]+)/i // Links
  836. ], [NAME, VERSION], [
  837. /(cobalt)\/([\w\.]+)/i // Cobalt
  838. ], [NAME, [VERSION, /master.|lts./, ""]]
  839. ],
  840.  
  841. cpu : [[
  842.  
  843. /(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i // AMD64 (x64)
  844. ], [[ARCHITECTURE, 'amd64']], [
  845.  
  846. /(ia32(?=;))/i // IA32 (quicktime)
  847. ], [[ARCHITECTURE, lowerize]], [
  848.  
  849. /((?:i[346]|x)86)[;\)]/i // IA32 (x86)
  850. ], [[ARCHITECTURE, 'ia32']], [
  851.  
  852. /\b(aarch64|arm(v?8e?l?|_?64))\b/i // ARM64
  853. ], [[ARCHITECTURE, 'arm64']], [
  854.  
  855. /\b(arm(?:v[67])?ht?n?[fl]p?)\b/i // ARMHF
  856. ], [[ARCHITECTURE, 'armhf']], [
  857.  
  858. // PocketPC mistakenly identified as PowerPC
  859. /windows (ce|mobile); ppc;/i
  860. ], [[ARCHITECTURE, 'arm']], [
  861.  
  862. /((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i // PowerPC
  863. ], [[ARCHITECTURE, /ower/, EMPTY, lowerize]], [
  864.  
  865. /(sun4\w)[;\)]/i // SPARC
  866. ], [[ARCHITECTURE, 'sparc']], [
  867.  
  868. /((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
  869. // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
  870. ], [[ARCHITECTURE, lowerize]]
  871. ],
  872.  
  873. device : [[
  874.  
  875. //////////////////////////
  876. // MOBILES & TABLETS
  877. // Ordered by popularity
  878. /////////////////////////
  879.  
  880. // Samsung
  881. /\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
  882. ], [MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]], [
  883. /\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,
  884. /samsung[- ]([-\w]+)/i,
  885. /sec-(sgh\w+)/i
  886. ], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
  887.  
  888. // Apple
  889. /\((ip(?:hone|od)[\w ]*);/i // iPod/iPhone
  890. ], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [
  891. /\((ipad);[-\w\),; ]+apple/i, // iPad
  892. /applecoremedia\/[\w\.]+ \((ipad)/i,
  893. /\b(ipad)\d\d?,\d\d?[;\]].+ios/i
  894. ], [MODEL, [VENDOR, APPLE], [TYPE, TABLET]], [
  895. /(macintosh);/i
  896. ], [MODEL, [VENDOR, APPLE]], [
  897.  
  898. // Huawei
  899. /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
  900. ], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
  901. /(?:huawei|honor)([-\w ]+)[;\)]/i,
  902. /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
  903. ], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [
  904.  
  905. // Xiaomi
  906. /\b(poco[\w ]+)(?: bui|\))/i, // Xiaomi POCO
  907. /\b; (\w+) build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
  908. /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, // Xiaomi Hongmi
  909. /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, // Xiaomi Redmi
  910. /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i // Xiaomi Mi
  911. ], [[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, MOBILE]], [
  912. /\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i // Mi Pad tablets
  913. ],[[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, TABLET]], [
  914.  
  915. // OPPO
  916. /; (\w+) bui.+ oppo/i,
  917. /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
  918. ], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [
  919.  
  920. // Vivo
  921. /vivo (\w+)(?: bui|\))/i,
  922. /\b(v[12]\d{3}\w?[at])(?: bui|;)/i
  923. ], [MODEL, [VENDOR, 'Vivo'], [TYPE, MOBILE]], [
  924.  
  925. // Realme
  926. /\b(rmx[12]\d{3})(?: bui|;|\))/i
  927. ], [MODEL, [VENDOR, 'Realme'], [TYPE, MOBILE]], [
  928.  
  929. // Motorola
  930. /\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
  931. /\bmot(?:orola)?[- ](\w*)/i,
  932. /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
  933. ], [MODEL, [VENDOR, MOTOROLA], [TYPE, MOBILE]], [
  934. /\b(mz60\d|xoom[2 ]{0,2}) build\//i
  935. ], [MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]], [
  936.  
  937. // LG
  938. /((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
  939. ], [MODEL, [VENDOR, LG], [TYPE, TABLET]], [
  940. /(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
  941. /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
  942. /\blg-?([\d\w]+) bui/i
  943. ], [MODEL, [VENDOR, LG], [TYPE, MOBILE]], [
  944.  
  945. // Lenovo
  946. /(ideatab[-\w ]+)/i,
  947. /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
  948. ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
  949.  
  950. // Nokia
  951. /(?:maemo|nokia).*(n900|lumia \d+)/i,
  952. /nokia[-_ ]?([-\w\.]*)/i
  953. ], [[MODEL, /_/g, ' '], [VENDOR, 'Nokia'], [TYPE, MOBILE]], [
  954.  
  955. // Google
  956. /(pixel c)\b/i // Google Pixel C
  957. ], [MODEL, [VENDOR, GOOGLE], [TYPE, TABLET]], [
  958. /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i // Google Pixel
  959. ], [MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]], [
  960.  
  961. // Sony
  962. /droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
  963. ], [MODEL, [VENDOR, SONY], [TYPE, MOBILE]], [
  964. /sony tablet [ps]/i,
  965. /\b(?:sony)?sgp\w+(?: bui|\))/i
  966. ], [[MODEL, 'Xperia Tablet'], [VENDOR, SONY], [TYPE, TABLET]], [
  967.  
  968. // OnePlus
  969. / (kb2005|in20[12]5|be20[12][59])\b/i,
  970. /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
  971. ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
  972.  
  973. // Amazon
  974. /(alexa)webm/i,
  975. /(kf[a-z]{2}wi)( bui|\))/i, // Kindle Fire without Silk
  976. /(kf[a-z]+)( bui|\)).+silk\//i // Kindle Fire HD
  977. ], [MODEL, [VENDOR, AMAZON], [TYPE, TABLET]], [
  978. /((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i // Fire Phone
  979. ], [[MODEL, /(.+)/g, 'Fire Phone $1'], [VENDOR, AMAZON], [TYPE, MOBILE]], [
  980.  
  981. // BlackBerry
  982. /(playbook);[-\w\),; ]+(rim)/i // BlackBerry PlayBook
  983. ], [MODEL, VENDOR, [TYPE, TABLET]], [
  984. /\b((?:bb[a-f]|st[hv])100-\d)/i,
  985. /\(bb10; (\w+)/i // BlackBerry 10
  986. ], [MODEL, [VENDOR, BLACKBERRY], [TYPE, MOBILE]], [
  987.  
  988. // Asus
  989. /(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
  990. ], [MODEL, [VENDOR, ASUS], [TYPE, TABLET]], [
  991. / (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
  992. ], [MODEL, [VENDOR, ASUS], [TYPE, MOBILE]], [
  993.  
  994. // HTC
  995. /(nexus 9)/i // HTC Nexus 9
  996. ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
  997. /(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i, // HTC
  998.  
  999. // ZTE
  1000. /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
  1001. /(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
  1002. ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
  1003.  
  1004. // Acer
  1005. /droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
  1006. ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
  1007.  
  1008. // Meizu
  1009. /droid.+; (m[1-5] note) bui/i,
  1010. /\bmz-([-\w]{2,})/i
  1011. ], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
  1012.  
  1013. // Sharp
  1014. /\b(sh-?[altvz]?\d\d[a-ekm]?)/i
  1015. ], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [
  1016.  
  1017. // MIXED
  1018. /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,
  1019. // BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
  1020. /(hp) ([\w ]+\w)/i, // HP iPAQ
  1021. /(asus)-?(\w+)/i, // Asus
  1022. /(microsoft); (lumia[\w ]+)/i, // Microsoft Lumia
  1023. /(lenovo)[-_ ]?([-\w]+)/i, // Lenovo
  1024. /(jolla)/i, // Jolla
  1025. /(oppo) ?([\w ]+) bui/i // OPPO
  1026. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  1027.  
  1028. /(archos) (gamepad2?)/i, // Archos
  1029. /(hp).+(touchpad(?!.+tablet)|tablet)/i, // HP TouchPad
  1030. /(kindle)\/([\w\.]+)/i, // Kindle
  1031. /(nook)[\w ]+build\/(\w+)/i, // Nook
  1032. /(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
  1033. /(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
  1034. /(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
  1035. /(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
  1036. /(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
  1037. ], [VENDOR, MODEL, [TYPE, TABLET]], [
  1038.  
  1039. /(surface duo)/i // Surface Duo
  1040. ], [MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]], [
  1041. /droid [\d\.]+; (fp\du?)(?: b|\))/i // Fairphone
  1042. ], [MODEL, [VENDOR, 'Fairphone'], [TYPE, MOBILE]], [
  1043. /(u304aa)/i // AT&T
  1044. ], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
  1045. /\bsie-(\w*)/i // Siemens
  1046. ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
  1047. /\b(rct\w+) b/i // RCA Tablets
  1048. ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
  1049. /\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
  1050. ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
  1051. /\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
  1052. ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
  1053. /\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
  1054. ], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
  1055. /\b(tm\d{3}\w+) b/i
  1056. ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
  1057. /\b(k88) b/i // ZTE K Series Tablet
  1058. ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
  1059. /\b(nx\d{3}j) b/i // ZTE Nubia
  1060. ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
  1061. /\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
  1062. ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
  1063. /\b(zur\d{3}) b/i // Swiss ZUR Tablet
  1064. ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
  1065. /\b((zeki)?tb.*\b) b/i // Zeki Tablets
  1066. ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
  1067. /\b([yr]\d{2}) b/i,
  1068. /\b(dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
  1069. ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
  1070. /\b(ns-?\w{0,9}) b/i // Insignia Tablets
  1071. ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
  1072. /\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
  1073. ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
  1074. /\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
  1075. ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
  1076. /\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
  1077. ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
  1078. /\b(ph-1) /i // Essential PH-1
  1079. ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
  1080. /\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
  1081. ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
  1082. /\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
  1083. ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
  1084. /\btu_(1491) b/i // Rotor Tablets
  1085. ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
  1086. /(shield[\w ]+) b/i // Nvidia Shield Tablets
  1087. ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, TABLET]], [
  1088. /(sprint) (\w+)/i // Sprint Phones
  1089. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  1090. /(kin\.[onetw]{3})/i // Microsoft Kin
  1091. ], [[MODEL, /\./g, ' '], [VENDOR, MICROSOFT], [TYPE, MOBILE]], [
  1092. /droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i // Zebra
  1093. ], [MODEL, [VENDOR, ZEBRA], [TYPE, TABLET]], [
  1094. /droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
  1095. ], [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]], [
  1096.  
  1097. ///////////////////
  1098. // CONSOLES
  1099. ///////////////////
  1100.  
  1101. /(ouya)/i, // Ouya
  1102. /(nintendo) ([wids3utch]+)/i // Nintendo
  1103. ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
  1104. /droid.+; (shield) bui/i // Nvidia
  1105. ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
  1106. /(playstation [345portablevi]+)/i // Playstation
  1107. ], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
  1108. /\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
  1109. ], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [
  1110.  
  1111. ///////////////////
  1112. // SMARTTVS
  1113. ///////////////////
  1114.  
  1115. /smart-tv.+(samsung)/i // Samsung
  1116. ], [VENDOR, [TYPE, SMARTTV]], [
  1117. /hbbtv.+maple;(\d+)/i
  1118. ], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
  1119. /(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
  1120. ], [[VENDOR, LG], [TYPE, SMARTTV]], [
  1121. /(apple) ?tv/i // Apple TV
  1122. ], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
  1123. /crkey/i // Google Chromecast
  1124. ], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
  1125. /droid.+aft(\w)( bui|\))/i // Fire TV
  1126. ], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
  1127. /\(dtv[\);].+(aquos)/i,
  1128. /(aquos-tv[\w ]+)\)/i // Sharp
  1129. ], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
  1130. /(bravia[\w ]+)( bui|\))/i // Sony
  1131. ], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
  1132. /(mitv-\w{5}) bui/i // Xiaomi
  1133. ], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
  1134. /\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
  1135. /hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i // HbbTV devices
  1136. ], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
  1137. /\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
  1138. ], [[TYPE, SMARTTV]], [
  1139.  
  1140. ///////////////////
  1141. // WEARABLES
  1142. ///////////////////
  1143.  
  1144. /((pebble))app/i // Pebble
  1145. ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
  1146. /droid.+; (glass) \d/i // Google Glass
  1147. ], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [
  1148. /droid.+; (wt63?0{2,3})\)/i
  1149. ], [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]], [
  1150. /(quest( 2)?)/i // Oculus Quest
  1151. ], [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]], [
  1152.  
  1153. ///////////////////
  1154. // EMBEDDED
  1155. ///////////////////
  1156.  
  1157. /(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i // Tesla
  1158. ], [VENDOR, [TYPE, EMBEDDED]], [
  1159.  
  1160. ////////////////////
  1161. // MIXED (GENERIC)
  1162. ///////////////////
  1163.  
  1164. /droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i // Android Phones from Unidentified Vendors
  1165. ], [MODEL, [TYPE, MOBILE]], [
  1166. /droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i // Android Tablets from Unidentified Vendors
  1167. ], [MODEL, [TYPE, TABLET]], [
  1168. /\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i // Unidentifiable Tablet
  1169. ], [[TYPE, TABLET]], [
  1170. /(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i // Unidentifiable Mobile
  1171. ], [[TYPE, MOBILE]], [
  1172. /(android[-\w\. ]{0,9});.+buil/i // Generic Android Device
  1173. ], [MODEL, [VENDOR, 'Generic']]
  1174. ],
  1175.  
  1176. engine : [[
  1177.  
  1178. /windows.+ edge\/([\w\.]+)/i // EdgeHTML
  1179. ], [VERSION, [NAME, EDGE+'HTML']], [
  1180.  
  1181. /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
  1182. ], [VERSION, [NAME, 'Blink']], [
  1183.  
  1184. /(presto)\/([\w\.]+)/i, // Presto
  1185. /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
  1186. /ekioh(flow)\/([\w\.]+)/i, // Flow
  1187. /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, // KHTML/Tasman/Links
  1188. /(icab)[\/ ]([23]\.[\d\.]+)/i // iCab
  1189. ], [NAME, VERSION], [
  1190.  
  1191. /rv\:([\w\.]{1,9})\b.+(gecko)/i // Gecko
  1192. ], [VERSION, NAME]
  1193. ],
  1194.  
  1195. os : [[
  1196.  
  1197. // Windows
  1198. /microsoft (windows) (vista|xp)/i // Windows (iTunes)
  1199. ], [NAME, VERSION], [
  1200. /(windows) nt 6\.2; (arm)/i, // Windows RT
  1201. /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i, // Windows Phone
  1202. /(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i
  1203. ], [NAME, [VERSION, strMapper, windowsVersionMap]], [
  1204. /(win(?=3|9|n)|win 9x )([nt\d\.]+)/i
  1205. ], [[NAME, 'Windows'], [VERSION, strMapper, windowsVersionMap]], [
  1206.  
  1207. // iOS/macOS
  1208. /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
  1209. /cfnetwork\/.+darwin/i
  1210. ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
  1211. /(mac os x) ?([\w\. ]*)/i,
  1212. /(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
  1213. ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
  1214.  
  1215. // Mobile OSes
  1216. /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
  1217. ], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS
  1218. /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
  1219. /(blackberry)\w*\/([\w\.]*)/i, // Blackberry
  1220. /(tizen|kaios)[\/ ]([\w\.]+)/i, // Tizen/KaiOS
  1221. /\((series40);/i // Series 40
  1222. ], [NAME, VERSION], [
  1223. /\(bb(10);/i // BlackBerry 10
  1224. ], [VERSION, [NAME, BLACKBERRY]], [
  1225. /(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i // Symbian
  1226. ], [VERSION, [NAME, 'Symbian']], [
  1227. /mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i // Firefox OS
  1228. ], [VERSION, [NAME, FIREFOX+' OS']], [
  1229. /web0s;.+rt(tv)/i,
  1230. /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS
  1231. ], [VERSION, [NAME, 'webOS']], [
  1232.  
  1233. // Google Chromecast
  1234. /crkey\/([\d\.]+)/i // Google Chromecast
  1235. ], [VERSION, [NAME, CHROME+'cast']], [
  1236. /(cros) [\w]+ ([\w\.]+\w)/i // Chromium OS
  1237. ], [[NAME, 'Chromium OS'], VERSION],[
  1238.  
  1239. // Console
  1240. /(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
  1241. /(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
  1242.  
  1243. // Other
  1244. /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
  1245. /(mint)[\/\(\) ]?(\w*)/i, // Mint
  1246. /(mageia|vectorlinux)[; ]/i, // Mageia/VectorLinux
  1247. /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
  1248. // Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware/Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus/Raspbian/Plan9/Minix/RISCOS/Contiki/Deepin/Manjaro/elementary/Sabayon/Linspire
  1249. /(hurd|linux) ?([\w\.]*)/i, // Hurd/Linux
  1250. /(gnu) ?([\w\.]*)/i, // GNU
  1251. /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, // FreeBSD/NetBSD/OpenBSD/PC-BSD/GhostBSD/DragonFly
  1252. /(haiku) (\w+)/i // Haiku
  1253. ], [NAME, VERSION], [
  1254. /(sunos) ?([\w\.\d]*)/i // Solaris
  1255. ], [[NAME, 'Solaris'], VERSION], [
  1256. /((?:open)?solaris)[-\/ ]?([\w\.]*)/i, // Solaris
  1257. /(aix) ((\d)(?=\.|\)| )[\w\.])*/i, // AIX
  1258. /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i, // BeOS/OS2/AmigaOS/MorphOS/OpenVMS/Fuchsia/HP-UX
  1259. /(unix) ?([\w\.]*)/i // UNIX
  1260. ], [NAME, VERSION]
  1261. ]
  1262. };
  1263.  
  1264. /////////////////
  1265. // Constructor
  1266. ////////////////
  1267.  
  1268. var UAParser = function (ua, extensions) {
  1269.  
  1270. if (typeof ua === OBJ_TYPE) {
  1271. extensions = ua;
  1272. ua = undefined;
  1273. }
  1274.  
  1275. if (!(this instanceof UAParser)) {
  1276. return new UAParser(ua, extensions).getResult();
  1277. }
  1278.  
  1279. var _ua = ua || ((typeof window !== UNDEF_TYPE && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
  1280. var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
  1281.  
  1282. this.getBrowser = function () {
  1283. var _browser = {};
  1284. _browser[NAME] = undefined;
  1285. _browser[VERSION] = undefined;
  1286. rgxMapper.call(_browser, _ua, _rgxmap.browser);
  1287. _browser.major = majorize(_browser.version);
  1288. return _browser;
  1289. };
  1290. this.getCPU = function () {
  1291. var _cpu = {};
  1292. _cpu[ARCHITECTURE] = undefined;
  1293. rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
  1294. return _cpu;
  1295. };
  1296. this.getDevice = function () {
  1297. var _device = {};
  1298. _device[VENDOR] = undefined;
  1299. _device[MODEL] = undefined;
  1300. _device[TYPE] = undefined;
  1301. rgxMapper.call(_device, _ua, _rgxmap.device);
  1302. return _device;
  1303. };
  1304. this.getEngine = function () {
  1305. var _engine = {};
  1306. _engine[NAME] = undefined;
  1307. _engine[VERSION] = undefined;
  1308. rgxMapper.call(_engine, _ua, _rgxmap.engine);
  1309. return _engine;
  1310. };
  1311. this.getOS = function () {
  1312. var _os = {};
  1313. _os[NAME] = undefined;
  1314. _os[VERSION] = undefined;
  1315. rgxMapper.call(_os, _ua, _rgxmap.os);
  1316. return _os;
  1317. };
  1318. this.getResult = function () {
  1319. return {
  1320. ua : this.getUA(),
  1321. browser : this.getBrowser(),
  1322. engine : this.getEngine(),
  1323. os : this.getOS(),
  1324. device : this.getDevice(),
  1325. cpu : this.getCPU()
  1326. };
  1327. };
  1328. this.getUA = function () {
  1329. return _ua;
  1330. };
  1331. this.setUA = function (ua) {
  1332. _ua = (typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH) ? trim(ua, UA_MAX_LENGTH) : ua;
  1333. return this;
  1334. };
  1335. this.setUA(_ua);
  1336. return this;
  1337. };
  1338.  
  1339. UAParser.VERSION = LIBVERSION;
  1340. UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR]);
  1341. UAParser.CPU = enumerize([ARCHITECTURE]);
  1342. UAParser.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
  1343. UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);
  1344.  
  1345. ///////////
  1346. // Export
  1347. //////////
  1348.  
  1349. // check js environment
  1350. if (typeof(exports) !== UNDEF_TYPE) {
  1351. // nodejs env
  1352. if ("object" !== UNDEF_TYPE && module.exports) {
  1353. exports = module.exports = UAParser;
  1354. }
  1355. exports.UAParser = UAParser;
  1356. } else {
  1357. // requirejs env (optional)
  1358. if ("function" === FUNC_TYPE && __webpack_require__.amdO) {
  1359. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
  1360. return UAParser;
  1361. }).call(exports, __webpack_require__, exports, module),
  1362. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1363. } else if (typeof window !== UNDEF_TYPE) {
  1364. // browser env
  1365. window.UAParser = UAParser;
  1366. }
  1367. }
  1368.  
  1369. // jQuery/Zepto specific (optional)
  1370. // Note:
  1371. // In AMD env the global scope should be kept clean, but jQuery is an exception.
  1372. // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
  1373. // and we should catch that.
  1374. var $ = typeof window !== UNDEF_TYPE && (window.jQuery || window.Zepto);
  1375. if ($ && !$.ua) {
  1376. var parser = new UAParser();
  1377. $.ua = parser.getResult();
  1378. $.ua.get = function () {
  1379. return parser.getUA();
  1380. };
  1381. $.ua.set = function (ua) {
  1382. parser.setUA(ua);
  1383. var result = parser.getResult();
  1384. for (var prop in result) {
  1385. $.ua[prop] = result[prop];
  1386. }
  1387. };
  1388. }
  1389.  
  1390. })(typeof window === 'object' ? window : this);
  1391.  
  1392.  
  1393. /***/ }),
  1394. /* 8 */
  1395. /***/ (function(module) {
  1396.  
  1397. /*!
  1398. * clipboard.js v2.0.11
  1399. * https://clipboardjs.com/
  1400. *
  1401. * Licensed MIT © Zeno Rocha
  1402. */
  1403. (function webpackUniversalModuleDefinition(root, factory) {
  1404. if(true)
  1405. module.exports = factory();
  1406. else {}
  1407. })(this, function() {
  1408. return /******/ (function() { // webpackBootstrap
  1409. /******/ var __webpack_modules__ = ({
  1410.  
  1411. /***/ 686:
  1412. /***/ (function(__unused_webpack_module, __webpack_exports__, __nested_webpack_require_623__) {
  1413.  
  1414. "use strict";
  1415.  
  1416. // EXPORTS
  1417. __nested_webpack_require_623__.d(__webpack_exports__, {
  1418. "default": function() { return /* binding */ clipboard; }
  1419. });
  1420.  
  1421. // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
  1422. var tiny_emitter = __nested_webpack_require_623__(279);
  1423. var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_623__.n(tiny_emitter);
  1424. // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
  1425. var listen = __nested_webpack_require_623__(370);
  1426. var listen_default = /*#__PURE__*/__nested_webpack_require_623__.n(listen);
  1427. // EXTERNAL MODULE: ./node_modules/select/src/select.js
  1428. var src_select = __nested_webpack_require_623__(817);
  1429. var select_default = /*#__PURE__*/__nested_webpack_require_623__.n(src_select);
  1430. ;// CONCATENATED MODULE: ./src/common/command.js
  1431. /**
  1432. * Executes a given operation type.
  1433. * @param {String} type
  1434. * @return {Boolean}
  1435. */
  1436. function command(type) {
  1437. try {
  1438. return document.execCommand(type);
  1439. } catch (err) {
  1440. return false;
  1441. }
  1442. }
  1443. ;// CONCATENATED MODULE: ./src/actions/cut.js
  1444.  
  1445.  
  1446. /**
  1447. * Cut action wrapper.
  1448. * @param {String|HTMLElement} target
  1449. * @return {String}
  1450. */
  1451.  
  1452. var ClipboardActionCut = function ClipboardActionCut(target) {
  1453. var selectedText = select_default()(target);
  1454. command('cut');
  1455. return selectedText;
  1456. };
  1457.  
  1458. /* harmony default export */ var actions_cut = (ClipboardActionCut);
  1459. ;// CONCATENATED MODULE: ./src/common/create-fake-element.js
  1460. /**
  1461. * Creates a fake textarea element with a value.
  1462. * @param {String} value
  1463. * @return {HTMLElement}
  1464. */
  1465. function createFakeElement(value) {
  1466. var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
  1467. var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS
  1468.  
  1469. fakeElement.style.fontSize = '12pt'; // Reset box model
  1470.  
  1471. fakeElement.style.border = '0';
  1472. fakeElement.style.padding = '0';
  1473. fakeElement.style.margin = '0'; // Move element out of screen horizontally
  1474.  
  1475. fakeElement.style.position = 'absolute';
  1476. fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
  1477.  
  1478. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  1479. fakeElement.style.top = "".concat(yPosition, "px");
  1480. fakeElement.setAttribute('readonly', '');
  1481. fakeElement.value = value;
  1482. return fakeElement;
  1483. }
  1484. ;// CONCATENATED MODULE: ./src/actions/copy.js
  1485.  
  1486.  
  1487.  
  1488. /**
  1489. * Create fake copy action wrapper using a fake element.
  1490. * @param {String} target
  1491. * @param {Object} options
  1492. * @return {String}
  1493. */
  1494.  
  1495. var fakeCopyAction = function fakeCopyAction(value, options) {
  1496. var fakeElement = createFakeElement(value);
  1497. options.container.appendChild(fakeElement);
  1498. var selectedText = select_default()(fakeElement);
  1499. command('copy');
  1500. fakeElement.remove();
  1501. return selectedText;
  1502. };
  1503. /**
  1504. * Copy action wrapper.
  1505. * @param {String|HTMLElement} target
  1506. * @param {Object} options
  1507. * @return {String}
  1508. */
  1509.  
  1510.  
  1511. var ClipboardActionCopy = function ClipboardActionCopy(target) {
  1512. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  1513. container: document.body
  1514. };
  1515. var selectedText = '';
  1516.  
  1517. if (typeof target === 'string') {
  1518. selectedText = fakeCopyAction(target, options);
  1519. } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) {
  1520. // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
  1521. selectedText = fakeCopyAction(target.value, options);
  1522. } else {
  1523. selectedText = select_default()(target);
  1524. command('copy');
  1525. }
  1526.  
  1527. return selectedText;
  1528. };
  1529.  
  1530. /* harmony default export */ var actions_copy = (ClipboardActionCopy);
  1531. ;// CONCATENATED MODULE: ./src/actions/default.js
  1532. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  1533.  
  1534.  
  1535.  
  1536. /**
  1537. * Inner function which performs selection from either `text` or `target`
  1538. * properties and then executes copy or cut operations.
  1539. * @param {Object} options
  1540. */
  1541.  
  1542. var ClipboardActionDefault = function ClipboardActionDefault() {
  1543. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1544. // Defines base properties passed from constructor.
  1545. var _options$action = options.action,
  1546. action = _options$action === void 0 ? 'copy' : _options$action,
  1547. container = options.container,
  1548. target = options.target,
  1549. text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'.
  1550.  
  1551. if (action !== 'copy' && action !== 'cut') {
  1552. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  1553. } // Sets the `target` property using an element that will be have its content copied.
  1554.  
  1555.  
  1556. if (target !== undefined) {
  1557. if (target && _typeof(target) === 'object' && target.nodeType === 1) {
  1558. if (action === 'copy' && target.hasAttribute('disabled')) {
  1559. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  1560. }
  1561.  
  1562. if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  1563. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  1564. }
  1565. } else {
  1566. throw new Error('Invalid "target" value, use a valid Element');
  1567. }
  1568. } // Define selection strategy based on `text` property.
  1569.  
  1570.  
  1571. if (text) {
  1572. return actions_copy(text, {
  1573. container: container
  1574. });
  1575. } // Defines which selection strategy based on `target` property.
  1576.  
  1577.  
  1578. if (target) {
  1579. return action === 'cut' ? actions_cut(target) : actions_copy(target, {
  1580. container: container
  1581. });
  1582. }
  1583. };
  1584.  
  1585. /* harmony default export */ var actions_default = (ClipboardActionDefault);
  1586. ;// CONCATENATED MODULE: ./src/clipboard.js
  1587. function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
  1588.  
  1589. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1590.  
  1591. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  1592.  
  1593. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  1594.  
  1595. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  1596.  
  1597. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  1598.  
  1599. function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  1600.  
  1601. function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  1602.  
  1603. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  1604.  
  1605. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  1606.  
  1607. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614. /**
  1615. * Helper function to retrieve attribute value.
  1616. * @param {String} suffix
  1617. * @param {Element} element
  1618. */
  1619.  
  1620. function getAttributeValue(suffix, element) {
  1621. var attribute = "data-clipboard-".concat(suffix);
  1622.  
  1623. if (!element.hasAttribute(attribute)) {
  1624. return;
  1625. }
  1626.  
  1627. return element.getAttribute(attribute);
  1628. }
  1629. /**
  1630. * Base class which takes one or more elements, adds event listeners to them,
  1631. * and instantiates a new `ClipboardAction` on each click.
  1632. */
  1633.  
  1634.  
  1635. var Clipboard = /*#__PURE__*/function (_Emitter) {
  1636. _inherits(Clipboard, _Emitter);
  1637.  
  1638. var _super = _createSuper(Clipboard);
  1639.  
  1640. /**
  1641. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  1642. * @param {Object} options
  1643. */
  1644. function Clipboard(trigger, options) {
  1645. var _this;
  1646.  
  1647. _classCallCheck(this, Clipboard);
  1648.  
  1649. _this = _super.call(this);
  1650.  
  1651. _this.resolveOptions(options);
  1652.  
  1653. _this.listenClick(trigger);
  1654.  
  1655. return _this;
  1656. }
  1657. /**
  1658. * Defines if attributes would be resolved using internal setter functions
  1659. * or custom functions that were passed in the constructor.
  1660. * @param {Object} options
  1661. */
  1662.  
  1663.  
  1664. _createClass(Clipboard, [{
  1665. key: "resolveOptions",
  1666. value: function resolveOptions() {
  1667. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1668. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  1669. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  1670. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  1671. this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
  1672. }
  1673. /**
  1674. * Adds a click event listener to the passed trigger.
  1675. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  1676. */
  1677.  
  1678. }, {
  1679. key: "listenClick",
  1680. value: function listenClick(trigger) {
  1681. var _this2 = this;
  1682.  
  1683. this.listener = listen_default()(trigger, 'click', function (e) {
  1684. return _this2.onClick(e);
  1685. });
  1686. }
  1687. /**
  1688. * Defines a new `ClipboardAction` on each click event.
  1689. * @param {Event} e
  1690. */
  1691.  
  1692. }, {
  1693. key: "onClick",
  1694. value: function onClick(e) {
  1695. var trigger = e.delegateTarget || e.currentTarget;
  1696. var action = this.action(trigger) || 'copy';
  1697. var text = actions_default({
  1698. action: action,
  1699. container: this.container,
  1700. target: this.target(trigger),
  1701. text: this.text(trigger)
  1702. }); // Fires an event based on the copy operation result.
  1703.  
  1704. this.emit(text ? 'success' : 'error', {
  1705. action: action,
  1706. text: text,
  1707. trigger: trigger,
  1708. clearSelection: function clearSelection() {
  1709. if (trigger) {
  1710. trigger.focus();
  1711. }
  1712.  
  1713. window.getSelection().removeAllRanges();
  1714. }
  1715. });
  1716. }
  1717. /**
  1718. * Default `action` lookup function.
  1719. * @param {Element} trigger
  1720. */
  1721.  
  1722. }, {
  1723. key: "defaultAction",
  1724. value: function defaultAction(trigger) {
  1725. return getAttributeValue('action', trigger);
  1726. }
  1727. /**
  1728. * Default `target` lookup function.
  1729. * @param {Element} trigger
  1730. */
  1731.  
  1732. }, {
  1733. key: "defaultTarget",
  1734. value: function defaultTarget(trigger) {
  1735. var selector = getAttributeValue('target', trigger);
  1736.  
  1737. if (selector) {
  1738. return document.querySelector(selector);
  1739. }
  1740. }
  1741. /**
  1742. * Allow fire programmatically a copy action
  1743. * @param {String|HTMLElement} target
  1744. * @param {Object} options
  1745. * @returns Text copied.
  1746. */
  1747.  
  1748. }, {
  1749. key: "defaultText",
  1750.  
  1751. /**
  1752. * Default `text` lookup function.
  1753. * @param {Element} trigger
  1754. */
  1755. value: function defaultText(trigger) {
  1756. return getAttributeValue('text', trigger);
  1757. }
  1758. /**
  1759. * Destroy lifecycle.
  1760. */
  1761.  
  1762. }, {
  1763. key: "destroy",
  1764. value: function destroy() {
  1765. this.listener.destroy();
  1766. }
  1767. }], [{
  1768. key: "copy",
  1769. value: function copy(target) {
  1770. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  1771. container: document.body
  1772. };
  1773. return actions_copy(target, options);
  1774. }
  1775. /**
  1776. * Allow fire programmatically a cut action
  1777. * @param {String|HTMLElement} target
  1778. * @returns Text cutted.
  1779. */
  1780.  
  1781. }, {
  1782. key: "cut",
  1783. value: function cut(target) {
  1784. return actions_cut(target);
  1785. }
  1786. /**
  1787. * Returns the support of the given action, or all actions if no action is
  1788. * given.
  1789. * @param {String} [action]
  1790. */
  1791.  
  1792. }, {
  1793. key: "isSupported",
  1794. value: function isSupported() {
  1795. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  1796. var actions = typeof action === 'string' ? [action] : action;
  1797. var support = !!document.queryCommandSupported;
  1798. actions.forEach(function (action) {
  1799. support = support && !!document.queryCommandSupported(action);
  1800. });
  1801. return support;
  1802. }
  1803. }]);
  1804.  
  1805. return Clipboard;
  1806. }((tiny_emitter_default()));
  1807.  
  1808. /* harmony default export */ var clipboard = (Clipboard);
  1809.  
  1810. /***/ }),
  1811.  
  1812. /***/ 828:
  1813. /***/ (function(module) {
  1814.  
  1815. var DOCUMENT_NODE_TYPE = 9;
  1816.  
  1817. /**
  1818. * A polyfill for Element.matches()
  1819. */
  1820. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  1821. var proto = Element.prototype;
  1822.  
  1823. proto.matches = proto.matchesSelector ||
  1824. proto.mozMatchesSelector ||
  1825. proto.msMatchesSelector ||
  1826. proto.oMatchesSelector ||
  1827. proto.webkitMatchesSelector;
  1828. }
  1829.  
  1830. /**
  1831. * Finds the closest parent that matches a selector.
  1832. *
  1833. * @param {Element} element
  1834. * @param {String} selector
  1835. * @return {Function}
  1836. */
  1837. function closest (element, selector) {
  1838. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  1839. if (typeof element.matches === 'function' &&
  1840. element.matches(selector)) {
  1841. return element;
  1842. }
  1843. element = element.parentNode;
  1844. }
  1845. }
  1846.  
  1847. module.exports = closest;
  1848.  
  1849.  
  1850. /***/ }),
  1851.  
  1852. /***/ 438:
  1853. /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_15749__) {
  1854.  
  1855. var closest = __nested_webpack_require_15749__(828);
  1856.  
  1857. /**
  1858. * Delegates event to a selector.
  1859. *
  1860. * @param {Element} element
  1861. * @param {String} selector
  1862. * @param {String} type
  1863. * @param {Function} callback
  1864. * @param {Boolean} useCapture
  1865. * @return {Object}
  1866. */
  1867. function _delegate(element, selector, type, callback, useCapture) {
  1868. var listenerFn = listener.apply(this, arguments);
  1869.  
  1870. element.addEventListener(type, listenerFn, useCapture);
  1871.  
  1872. return {
  1873. destroy: function() {
  1874. element.removeEventListener(type, listenerFn, useCapture);
  1875. }
  1876. }
  1877. }
  1878.  
  1879. /**
  1880. * Delegates event to a selector.
  1881. *
  1882. * @param {Element|String|Array} [elements]
  1883. * @param {String} selector
  1884. * @param {String} type
  1885. * @param {Function} callback
  1886. * @param {Boolean} useCapture
  1887. * @return {Object}
  1888. */
  1889. function delegate(elements, selector, type, callback, useCapture) {
  1890. // Handle the regular Element usage
  1891. if (typeof elements.addEventListener === 'function') {
  1892. return _delegate.apply(null, arguments);
  1893. }
  1894.  
  1895. // Handle Element-less usage, it defaults to global delegation
  1896. if (typeof type === 'function') {
  1897. // Use `document` as the first parameter, then apply arguments
  1898. // This is a short way to .unshift `arguments` without running into deoptimizations
  1899. return _delegate.bind(null, document).apply(null, arguments);
  1900. }
  1901.  
  1902. // Handle Selector-based usage
  1903. if (typeof elements === 'string') {
  1904. elements = document.querySelectorAll(elements);
  1905. }
  1906.  
  1907. // Handle Array-like based usage
  1908. return Array.prototype.map.call(elements, function (element) {
  1909. return _delegate(element, selector, type, callback, useCapture);
  1910. });
  1911. }
  1912.  
  1913. /**
  1914. * Finds closest match and invokes callback.
  1915. *
  1916. * @param {Element} element
  1917. * @param {String} selector
  1918. * @param {String} type
  1919. * @param {Function} callback
  1920. * @return {Function}
  1921. */
  1922. function listener(element, selector, type, callback) {
  1923. return function(e) {
  1924. e.delegateTarget = closest(e.target, selector);
  1925.  
  1926. if (e.delegateTarget) {
  1927. callback.call(element, e);
  1928. }
  1929. }
  1930. }
  1931.  
  1932. module.exports = delegate;
  1933.  
  1934.  
  1935. /***/ }),
  1936.  
  1937. /***/ 879:
  1938. /***/ (function(__unused_webpack_module, exports) {
  1939.  
  1940. /**
  1941. * Check if argument is a HTML element.
  1942. *
  1943. * @param {Object} value
  1944. * @return {Boolean}
  1945. */
  1946. exports.node = function(value) {
  1947. return value !== undefined
  1948. && value instanceof HTMLElement
  1949. && value.nodeType === 1;
  1950. };
  1951.  
  1952. /**
  1953. * Check if argument is a list of HTML elements.
  1954. *
  1955. * @param {Object} value
  1956. * @return {Boolean}
  1957. */
  1958. exports.nodeList = function(value) {
  1959. var type = Object.prototype.toString.call(value);
  1960.  
  1961. return value !== undefined
  1962. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  1963. && ('length' in value)
  1964. && (value.length === 0 || exports.node(value[0]));
  1965. };
  1966.  
  1967. /**
  1968. * Check if argument is a string.
  1969. *
  1970. * @param {Object} value
  1971. * @return {Boolean}
  1972. */
  1973. exports.string = function(value) {
  1974. return typeof value === 'string'
  1975. || value instanceof String;
  1976. };
  1977.  
  1978. /**
  1979. * Check if argument is a function.
  1980. *
  1981. * @param {Object} value
  1982. * @return {Boolean}
  1983. */
  1984. exports.fn = function(value) {
  1985. var type = Object.prototype.toString.call(value);
  1986.  
  1987. return type === '[object Function]';
  1988. };
  1989.  
  1990.  
  1991. /***/ }),
  1992.  
  1993. /***/ 370:
  1994. /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_19113__) {
  1995.  
  1996. var is = __nested_webpack_require_19113__(879);
  1997. var delegate = __nested_webpack_require_19113__(438);
  1998.  
  1999. /**
  2000. * Validates all params and calls the right
  2001. * listener function based on its target type.
  2002. *
  2003. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  2004. * @param {String} type
  2005. * @param {Function} callback
  2006. * @return {Object}
  2007. */
  2008. function listen(target, type, callback) {
  2009. if (!target && !type && !callback) {
  2010. throw new Error('Missing required arguments');
  2011. }
  2012.  
  2013. if (!is.string(type)) {
  2014. throw new TypeError('Second argument must be a String');
  2015. }
  2016.  
  2017. if (!is.fn(callback)) {
  2018. throw new TypeError('Third argument must be a Function');
  2019. }
  2020.  
  2021. if (is.node(target)) {
  2022. return listenNode(target, type, callback);
  2023. }
  2024. else if (is.nodeList(target)) {
  2025. return listenNodeList(target, type, callback);
  2026. }
  2027. else if (is.string(target)) {
  2028. return listenSelector(target, type, callback);
  2029. }
  2030. else {
  2031. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  2032. }
  2033. }
  2034.  
  2035. /**
  2036. * Adds an event listener to a HTML element
  2037. * and returns a remove listener function.
  2038. *
  2039. * @param {HTMLElement} node
  2040. * @param {String} type
  2041. * @param {Function} callback
  2042. * @return {Object}
  2043. */
  2044. function listenNode(node, type, callback) {
  2045. node.addEventListener(type, callback);
  2046.  
  2047. return {
  2048. destroy: function() {
  2049. node.removeEventListener(type, callback);
  2050. }
  2051. }
  2052. }
  2053.  
  2054. /**
  2055. * Add an event listener to a list of HTML elements
  2056. * and returns a remove listener function.
  2057. *
  2058. * @param {NodeList|HTMLCollection} nodeList
  2059. * @param {String} type
  2060. * @param {Function} callback
  2061. * @return {Object}
  2062. */
  2063. function listenNodeList(nodeList, type, callback) {
  2064. Array.prototype.forEach.call(nodeList, function(node) {
  2065. node.addEventListener(type, callback);
  2066. });
  2067.  
  2068. return {
  2069. destroy: function() {
  2070. Array.prototype.forEach.call(nodeList, function(node) {
  2071. node.removeEventListener(type, callback);
  2072. });
  2073. }
  2074. }
  2075. }
  2076.  
  2077. /**
  2078. * Add an event listener to a selector
  2079. * and returns a remove listener function.
  2080. *
  2081. * @param {String} selector
  2082. * @param {String} type
  2083. * @param {Function} callback
  2084. * @return {Object}
  2085. */
  2086. function listenSelector(selector, type, callback) {
  2087. return delegate(document.body, selector, type, callback);
  2088. }
  2089.  
  2090. module.exports = listen;
  2091.  
  2092.  
  2093. /***/ }),
  2094.  
  2095. /***/ 817:
  2096. /***/ (function(module) {
  2097.  
  2098. function select(element) {
  2099. var selectedText;
  2100.  
  2101. if (element.nodeName === 'SELECT') {
  2102. element.focus();
  2103.  
  2104. selectedText = element.value;
  2105. }
  2106. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  2107. var isReadOnly = element.hasAttribute('readonly');
  2108.  
  2109. if (!isReadOnly) {
  2110. element.setAttribute('readonly', '');
  2111. }
  2112.  
  2113. element.select();
  2114. element.setSelectionRange(0, element.value.length);
  2115.  
  2116. if (!isReadOnly) {
  2117. element.removeAttribute('readonly');
  2118. }
  2119.  
  2120. selectedText = element.value;
  2121. }
  2122. else {
  2123. if (element.hasAttribute('contenteditable')) {
  2124. element.focus();
  2125. }
  2126.  
  2127. var selection = window.getSelection();
  2128. var range = document.createRange();
  2129.  
  2130. range.selectNodeContents(element);
  2131. selection.removeAllRanges();
  2132. selection.addRange(range);
  2133.  
  2134. selectedText = selection.toString();
  2135. }
  2136.  
  2137. return selectedText;
  2138. }
  2139.  
  2140. module.exports = select;
  2141.  
  2142.  
  2143. /***/ }),
  2144.  
  2145. /***/ 279:
  2146. /***/ (function(module) {
  2147.  
  2148. function E () {
  2149. // Keep this empty so it's easier to inherit from
  2150. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  2151. }
  2152.  
  2153. E.prototype = {
  2154. on: function (name, callback, ctx) {
  2155. var e = this.e || (this.e = {});
  2156.  
  2157. (e[name] || (e[name] = [])).push({
  2158. fn: callback,
  2159. ctx: ctx
  2160. });
  2161.  
  2162. return this;
  2163. },
  2164.  
  2165. once: function (name, callback, ctx) {
  2166. var self = this;
  2167. function listener () {
  2168. self.off(name, listener);
  2169. callback.apply(ctx, arguments);
  2170. };
  2171.  
  2172. listener._ = callback
  2173. return this.on(name, listener, ctx);
  2174. },
  2175.  
  2176. emit: function (name) {
  2177. var data = [].slice.call(arguments, 1);
  2178. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  2179. var i = 0;
  2180. var len = evtArr.length;
  2181.  
  2182. for (i; i < len; i++) {
  2183. evtArr[i].fn.apply(evtArr[i].ctx, data);
  2184. }
  2185.  
  2186. return this;
  2187. },
  2188.  
  2189. off: function (name, callback) {
  2190. var e = this.e || (this.e = {});
  2191. var evts = e[name];
  2192. var liveEvents = [];
  2193.  
  2194. if (evts && callback) {
  2195. for (var i = 0, len = evts.length; i < len; i++) {
  2196. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  2197. liveEvents.push(evts[i]);
  2198. }
  2199. }
  2200.  
  2201. // Remove event from queue to prevent memory leak
  2202. // Suggested by https://github.com/lazd
  2203. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  2204.  
  2205. (liveEvents.length)
  2206. ? e[name] = liveEvents
  2207. : delete e[name];
  2208.  
  2209. return this;
  2210. }
  2211. };
  2212.  
  2213. module.exports = E;
  2214. module.exports.TinyEmitter = E;
  2215.  
  2216.  
  2217. /***/ })
  2218.  
  2219. /******/ });
  2220. /************************************************************************/
  2221. /******/ // The module cache
  2222. /******/ var __webpack_module_cache__ = {};
  2223. /******/
  2224. /******/ // The require function
  2225. /******/ function __nested_webpack_require_24495__(moduleId) {
  2226. /******/ // Check if module is in cache
  2227. /******/ if(__webpack_module_cache__[moduleId]) {
  2228. /******/ return __webpack_module_cache__[moduleId].exports;
  2229. /******/ }
  2230. /******/ // Create a new module (and put it into the cache)
  2231. /******/ var module = __webpack_module_cache__[moduleId] = {
  2232. /******/ // no module.id needed
  2233. /******/ // no module.loaded needed
  2234. /******/ exports: {}
  2235. /******/ };
  2236. /******/
  2237. /******/ // Execute the module function
  2238. /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_24495__);
  2239. /******/
  2240. /******/ // Return the exports of the module
  2241. /******/ return module.exports;
  2242. /******/ }
  2243. /******/
  2244. /************************************************************************/
  2245. /******/ /* webpack/runtime/compat get default export */
  2246. /******/ !function() {
  2247. /******/ // getDefaultExport function for compatibility with non-harmony modules
  2248. /******/ __nested_webpack_require_24495__.n = function(module) {
  2249. /******/ var getter = module && module.__esModule ?
  2250. /******/ function() { return module['default']; } :
  2251. /******/ function() { return module; };
  2252. /******/ __nested_webpack_require_24495__.d(getter, { a: getter });
  2253. /******/ return getter;
  2254. /******/ };
  2255. /******/ }();
  2256. /******/
  2257. /******/ /* webpack/runtime/define property getters */
  2258. /******/ !function() {
  2259. /******/ // define getter functions for harmony exports
  2260. /******/ __nested_webpack_require_24495__.d = function(exports, definition) {
  2261. /******/ for(var key in definition) {
  2262. /******/ if(__nested_webpack_require_24495__.o(definition, key) && !__nested_webpack_require_24495__.o(exports, key)) {
  2263. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  2264. /******/ }
  2265. /******/ }
  2266. /******/ };
  2267. /******/ }();
  2268. /******/
  2269. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  2270. /******/ !function() {
  2271. /******/ __nested_webpack_require_24495__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  2272. /******/ }();
  2273. /******/
  2274. /************************************************************************/
  2275. /******/ // module exports must be returned from runtime so entry inlining is disabled
  2276. /******/ // startup
  2277. /******/ // Load entry module and return exports
  2278. /******/ return __nested_webpack_require_24495__(686);
  2279. /******/ })()
  2280. .default;
  2281. });
  2282.  
  2283. /***/ }),
  2284. /* 9 */
  2285. /***/ (function(module) {
  2286.  
  2287. /*!
  2288. * sweetalert2 v11.4.8
  2289. * Released under the MIT License.
  2290. */
  2291. (function (global, factory) {
  2292. true ? module.exports = factory() :
  2293. 0;
  2294. }(this, function () { 'use strict';
  2295.  
  2296. const consolePrefix = 'SweetAlert2:';
  2297. /**
  2298. * Filter the unique values into a new array
  2299. * @param arr
  2300. */
  2301.  
  2302. const uniqueArray = arr => {
  2303. const result = [];
  2304.  
  2305. for (let i = 0; i < arr.length; i++) {
  2306. if (result.indexOf(arr[i]) === -1) {
  2307. result.push(arr[i]);
  2308. }
  2309. }
  2310.  
  2311. return result;
  2312. };
  2313. /**
  2314. * Capitalize the first letter of a string
  2315. * @param {string} str
  2316. * @returns {string}
  2317. */
  2318.  
  2319. const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
  2320. /**
  2321. * @param {NodeList | HTMLCollection | NamedNodeMap} nodeList
  2322. * @returns {array}
  2323. */
  2324.  
  2325. const toArray = nodeList => Array.prototype.slice.call(nodeList);
  2326. /**
  2327. * Standardize console warnings
  2328. * @param {string | array} message
  2329. */
  2330.  
  2331. const warn = message => {
  2332. console.warn("".concat(consolePrefix, " ").concat(typeof message === 'object' ? message.join(' ') : message));
  2333. };
  2334. /**
  2335. * Standardize console errors
  2336. * @param {string} message
  2337. */
  2338.  
  2339. const error = message => {
  2340. console.error("".concat(consolePrefix, " ").concat(message));
  2341. };
  2342. /**
  2343. * Private global state for `warnOnce`
  2344. * @type {Array}
  2345. * @private
  2346. */
  2347.  
  2348. const previousWarnOnceMessages = [];
  2349. /**
  2350. * Show a console warning, but only if it hasn't already been shown
  2351. * @param {string} message
  2352. */
  2353.  
  2354. const warnOnce = message => {
  2355. if (!previousWarnOnceMessages.includes(message)) {
  2356. previousWarnOnceMessages.push(message);
  2357. warn(message);
  2358. }
  2359. };
  2360. /**
  2361. * Show a one-time console warning about deprecated params/methods
  2362. */
  2363.  
  2364. const warnAboutDeprecation = (deprecatedParam, useInstead) => {
  2365. warnOnce("\"".concat(deprecatedParam, "\" is deprecated and will be removed in the next major release. Please use \"").concat(useInstead, "\" instead."));
  2366. };
  2367. /**
  2368. * If `arg` is a function, call it (with no arguments or context) and return the result.
  2369. * Otherwise, just pass the value through
  2370. * @param arg
  2371. */
  2372.  
  2373. const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
  2374. const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
  2375. const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
  2376. const isPromise = arg => arg && Promise.resolve(arg) === arg;
  2377.  
  2378. const defaultParams = {
  2379. title: '',
  2380. titleText: '',
  2381. text: '',
  2382. html: '',
  2383. footer: '',
  2384. icon: undefined,
  2385. iconColor: undefined,
  2386. iconHtml: undefined,
  2387. template: undefined,
  2388. toast: false,
  2389. showClass: {
  2390. popup: 'swal2-show',
  2391. backdrop: 'swal2-backdrop-show',
  2392. icon: 'swal2-icon-show'
  2393. },
  2394. hideClass: {
  2395. popup: 'swal2-hide',
  2396. backdrop: 'swal2-backdrop-hide',
  2397. icon: 'swal2-icon-hide'
  2398. },
  2399. customClass: {},
  2400. target: 'body',
  2401. color: undefined,
  2402. backdrop: true,
  2403. heightAuto: true,
  2404. allowOutsideClick: true,
  2405. allowEscapeKey: true,
  2406. allowEnterKey: true,
  2407. stopKeydownPropagation: true,
  2408. keydownListenerCapture: false,
  2409. showConfirmButton: true,
  2410. showDenyButton: false,
  2411. showCancelButton: false,
  2412. preConfirm: undefined,
  2413. preDeny: undefined,
  2414. confirmButtonText: 'OK',
  2415. confirmButtonAriaLabel: '',
  2416. confirmButtonColor: undefined,
  2417. denyButtonText: 'No',
  2418. denyButtonAriaLabel: '',
  2419. denyButtonColor: undefined,
  2420. cancelButtonText: 'Cancel',
  2421. cancelButtonAriaLabel: '',
  2422. cancelButtonColor: undefined,
  2423. buttonsStyling: true,
  2424. reverseButtons: false,
  2425. focusConfirm: true,
  2426. focusDeny: false,
  2427. focusCancel: false,
  2428. returnFocus: true,
  2429. showCloseButton: false,
  2430. closeButtonHtml: '&times;',
  2431. closeButtonAriaLabel: 'Close this dialog',
  2432. loaderHtml: '',
  2433. showLoaderOnConfirm: false,
  2434. showLoaderOnDeny: false,
  2435. imageUrl: undefined,
  2436. imageWidth: undefined,
  2437. imageHeight: undefined,
  2438. imageAlt: '',
  2439. timer: undefined,
  2440. timerProgressBar: false,
  2441. width: undefined,
  2442. padding: undefined,
  2443. background: undefined,
  2444. input: undefined,
  2445. inputPlaceholder: '',
  2446. inputLabel: '',
  2447. inputValue: '',
  2448. inputOptions: {},
  2449. inputAutoTrim: true,
  2450. inputAttributes: {},
  2451. inputValidator: undefined,
  2452. returnInputValueOnDeny: false,
  2453. validationMessage: undefined,
  2454. grow: false,
  2455. position: 'center',
  2456. progressSteps: [],
  2457. currentProgressStep: undefined,
  2458. progressStepsDistance: undefined,
  2459. willOpen: undefined,
  2460. didOpen: undefined,
  2461. didRender: undefined,
  2462. willClose: undefined,
  2463. didClose: undefined,
  2464. didDestroy: undefined,
  2465. scrollbarPadding: true
  2466. };
  2467. const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'willClose'];
  2468. const deprecatedParams = {};
  2469. const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
  2470. /**
  2471. * Is valid parameter
  2472. * @param {string} paramName
  2473. */
  2474.  
  2475. const isValidParameter = paramName => {
  2476. return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
  2477. };
  2478. /**
  2479. * Is valid parameter for Swal.update() method
  2480. * @param {string} paramName
  2481. */
  2482.  
  2483. const isUpdatableParameter = paramName => {
  2484. return updatableParams.indexOf(paramName) !== -1;
  2485. };
  2486. /**
  2487. * Is deprecated parameter
  2488. * @param {string} paramName
  2489. */
  2490.  
  2491. const isDeprecatedParameter = paramName => {
  2492. return deprecatedParams[paramName];
  2493. };
  2494.  
  2495. const checkIfParamIsValid = param => {
  2496. if (!isValidParameter(param)) {
  2497. warn("Unknown parameter \"".concat(param, "\""));
  2498. }
  2499. };
  2500.  
  2501. const checkIfToastParamIsValid = param => {
  2502. if (toastIncompatibleParams.includes(param)) {
  2503. warn("The parameter \"".concat(param, "\" is incompatible with toasts"));
  2504. }
  2505. };
  2506.  
  2507. const checkIfParamIsDeprecated = param => {
  2508. if (isDeprecatedParameter(param)) {
  2509. warnAboutDeprecation(param, isDeprecatedParameter(param));
  2510. }
  2511. };
  2512. /**
  2513. * Show relevant warnings for given params
  2514. *
  2515. * @param params
  2516. */
  2517.  
  2518.  
  2519. const showWarningsForParams = params => {
  2520. if (!params.backdrop && params.allowOutsideClick) {
  2521. warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
  2522. }
  2523.  
  2524. for (const param in params) {
  2525. checkIfParamIsValid(param);
  2526.  
  2527. if (params.toast) {
  2528. checkIfToastParamIsValid(param);
  2529. }
  2530.  
  2531. checkIfParamIsDeprecated(param);
  2532. }
  2533. };
  2534.  
  2535. const swalPrefix = 'swal2-';
  2536. const prefix = items => {
  2537. const result = {};
  2538.  
  2539. for (const i in items) {
  2540. result[items[i]] = swalPrefix + items[i];
  2541. }
  2542.  
  2543. return result;
  2544. };
  2545. const swalClasses = prefix(['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'default-outline', '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']);
  2546. const iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
  2547.  
  2548. /**
  2549. * Gets the popup container which contains the backdrop and the popup itself.
  2550. *
  2551. * @returns {HTMLElement | null}
  2552. */
  2553.  
  2554. const getContainer = () => document.body.querySelector(".".concat(swalClasses.container));
  2555. const elementBySelector = selectorString => {
  2556. const container = getContainer();
  2557. return container ? container.querySelector(selectorString) : null;
  2558. };
  2559.  
  2560. const elementByClass = className => {
  2561. return elementBySelector(".".concat(className));
  2562. };
  2563.  
  2564. const getPopup = () => elementByClass(swalClasses.popup);
  2565. const getIcon = () => elementByClass(swalClasses.icon);
  2566. const getTitle = () => elementByClass(swalClasses.title);
  2567. const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
  2568. const getImage = () => elementByClass(swalClasses.image);
  2569. const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
  2570. const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
  2571. const getConfirmButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.confirm));
  2572. const getDenyButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.deny));
  2573. const getInputLabel = () => elementByClass(swalClasses['input-label']);
  2574. const getLoader = () => elementBySelector(".".concat(swalClasses.loader));
  2575. const getCancelButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.cancel));
  2576. const getActions = () => elementByClass(swalClasses.actions);
  2577. const getFooter = () => elementByClass(swalClasses.footer);
  2578. const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
  2579. const getCloseButton = () => elementByClass(swalClasses.close); // https://github.com/jkup/focusable/blob/master/index.js
  2580.  
  2581. const focusable = "\n a[href],\n area[href],\n input:not([disabled]),\n select:not([disabled]),\n textarea:not([disabled]),\n button:not([disabled]),\n iframe,\n object,\n embed,\n [tabindex=\"0\"],\n [contenteditable],\n audio[controls],\n video[controls],\n summary\n";
  2582. const getFocusableElements = () => {
  2583. const focusableElementsWithTabindex = toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')) // sort according to tabindex
  2584. .sort((a, b) => {
  2585. const tabindexA = parseInt(a.getAttribute('tabindex'));
  2586. const tabindexB = parseInt(b.getAttribute('tabindex'));
  2587.  
  2588. if (tabindexA > tabindexB) {
  2589. return 1;
  2590. } else if (tabindexA < tabindexB) {
  2591. return -1;
  2592. }
  2593.  
  2594. return 0;
  2595. });
  2596. const otherFocusableElements = toArray(getPopup().querySelectorAll(focusable)).filter(el => el.getAttribute('tabindex') !== '-1');
  2597. return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter(el => isVisible(el));
  2598. };
  2599. const isModal = () => {
  2600. return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
  2601. };
  2602. const isToast = () => {
  2603. return getPopup() && hasClass(getPopup(), swalClasses.toast);
  2604. };
  2605. const isLoading = () => {
  2606. return getPopup().hasAttribute('data-loading');
  2607. };
  2608.  
  2609. const states = {
  2610. previousBodyPadding: null
  2611. };
  2612. /**
  2613. * Securely set innerHTML of an element
  2614. * https://github.com/sweetalert2/sweetalert2/issues/1926
  2615. *
  2616. * @param {HTMLElement} elem
  2617. * @param {string} html
  2618. */
  2619.  
  2620. const setInnerHtml = (elem, html) => {
  2621. elem.textContent = '';
  2622.  
  2623. if (html) {
  2624. const parser = new DOMParser();
  2625. const parsed = parser.parseFromString(html, "text/html");
  2626. toArray(parsed.querySelector('head').childNodes).forEach(child => {
  2627. elem.appendChild(child);
  2628. });
  2629. toArray(parsed.querySelector('body').childNodes).forEach(child => {
  2630. elem.appendChild(child);
  2631. });
  2632. }
  2633. };
  2634. /**
  2635. * @param {HTMLElement} elem
  2636. * @param {string} className
  2637. * @returns {boolean}
  2638. */
  2639.  
  2640. const hasClass = (elem, className) => {
  2641. if (!className) {
  2642. return false;
  2643. }
  2644.  
  2645. const classList = className.split(/\s+/);
  2646.  
  2647. for (let i = 0; i < classList.length; i++) {
  2648. if (!elem.classList.contains(classList[i])) {
  2649. return false;
  2650. }
  2651. }
  2652.  
  2653. return true;
  2654. };
  2655.  
  2656. const removeCustomClasses = (elem, params) => {
  2657. toArray(elem.classList).forEach(className => {
  2658. if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass).includes(className)) {
  2659. elem.classList.remove(className);
  2660. }
  2661. });
  2662. };
  2663.  
  2664. const applyCustomClass = (elem, params, className) => {
  2665. removeCustomClasses(elem, params);
  2666.  
  2667. if (params.customClass && params.customClass[className]) {
  2668. if (typeof params.customClass[className] !== 'string' && !params.customClass[className].forEach) {
  2669. return warn("Invalid type of customClass.".concat(className, "! Expected string or iterable object, got \"").concat(typeof params.customClass[className], "\""));
  2670. }
  2671.  
  2672. addClass(elem, params.customClass[className]);
  2673. }
  2674. };
  2675. /**
  2676. * @param {HTMLElement} popup
  2677. * @param {string} inputType
  2678. * @returns {HTMLInputElement | null}
  2679. */
  2680.  
  2681. const getInput = (popup, inputType) => {
  2682. if (!inputType) {
  2683. return null;
  2684. }
  2685.  
  2686. switch (inputType) {
  2687. case 'select':
  2688. case 'textarea':
  2689. case 'file':
  2690. return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses[inputType]));
  2691.  
  2692. case 'checkbox':
  2693. return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.checkbox, " input"));
  2694.  
  2695. case 'radio':
  2696. return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.radio, " input:checked")) || popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.radio, " input:first-child"));
  2697.  
  2698. case 'range':
  2699. return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.range, " input"));
  2700.  
  2701. default:
  2702. return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.input));
  2703. }
  2704. };
  2705. /**
  2706. * @param {HTMLInputElement} input
  2707. */
  2708.  
  2709. const focusInput = input => {
  2710. input.focus(); // place cursor at end of text in text input
  2711.  
  2712. if (input.type !== 'file') {
  2713. // http://stackoverflow.com/a/2345915
  2714. const val = input.value;
  2715. input.value = '';
  2716. input.value = val;
  2717. }
  2718. };
  2719. /**
  2720. * @param {HTMLElement | HTMLElement[] | null} target
  2721. * @param {string | string[]} classList
  2722. * @param {boolean} condition
  2723. */
  2724.  
  2725. const toggleClass = (target, classList, condition) => {
  2726. if (!target || !classList) {
  2727. return;
  2728. }
  2729.  
  2730. if (typeof classList === 'string') {
  2731. classList = classList.split(/\s+/).filter(Boolean);
  2732. }
  2733.  
  2734. classList.forEach(className => {
  2735. if (Array.isArray(target)) {
  2736. target.forEach(elem => {
  2737. condition ? elem.classList.add(className) : elem.classList.remove(className);
  2738. });
  2739. } else {
  2740. condition ? target.classList.add(className) : target.classList.remove(className);
  2741. }
  2742. });
  2743. };
  2744. /**
  2745. * @param {HTMLElement | HTMLElement[] | null} target
  2746. * @param {string | string[]} classList
  2747. */
  2748.  
  2749. const addClass = (target, classList) => {
  2750. toggleClass(target, classList, true);
  2751. };
  2752. /**
  2753. * @param {HTMLElement | HTMLElement[] | null} target
  2754. * @param {string | string[]} classList
  2755. */
  2756.  
  2757. const removeClass = (target, classList) => {
  2758. toggleClass(target, classList, false);
  2759. };
  2760. /**
  2761. * Get direct child of an element by class name
  2762. *
  2763. * @param {HTMLElement} elem
  2764. * @param {string} className
  2765. * @returns {HTMLElement | null}
  2766. */
  2767.  
  2768. const getDirectChildByClass = (elem, className) => {
  2769. const childNodes = toArray(elem.childNodes);
  2770.  
  2771. for (let i = 0; i < childNodes.length; i++) {
  2772. if (hasClass(childNodes[i], className)) {
  2773. return childNodes[i];
  2774. }
  2775. }
  2776. };
  2777. /**
  2778. * @param {HTMLElement} elem
  2779. * @param {string} property
  2780. * @param {*} value
  2781. */
  2782.  
  2783. const applyNumericalStyle = (elem, property, value) => {
  2784. if (value === "".concat(parseInt(value))) {
  2785. value = parseInt(value);
  2786. }
  2787.  
  2788. if (value || parseInt(value) === 0) {
  2789. elem.style[property] = typeof value === 'number' ? "".concat(value, "px") : value;
  2790. } else {
  2791. elem.style.removeProperty(property);
  2792. }
  2793. };
  2794. /**
  2795. * @param {HTMLElement} elem
  2796. * @param {string} display
  2797. */
  2798.  
  2799. const show = function (elem) {
  2800. let display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'flex';
  2801. elem.style.display = display;
  2802. };
  2803. /**
  2804. * @param {HTMLElement} elem
  2805. */
  2806.  
  2807. const hide = elem => {
  2808. elem.style.display = 'none';
  2809. };
  2810. const setStyle = (parent, selector, property, value) => {
  2811. const el = parent.querySelector(selector);
  2812.  
  2813. if (el) {
  2814. el.style[property] = value;
  2815. }
  2816. };
  2817. const toggle = (elem, condition, display) => {
  2818. condition ? show(elem, display) : hide(elem);
  2819. }; // borrowed from jquery $(elem).is(':visible') implementation
  2820.  
  2821. const isVisible = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
  2822. const allButtonsAreHidden = () => !isVisible(getConfirmButton()) && !isVisible(getDenyButton()) && !isVisible(getCancelButton());
  2823. const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight); // borrowed from https://stackoverflow.com/a/46352119
  2824.  
  2825. const hasCssAnimation = elem => {
  2826. const style = window.getComputedStyle(elem);
  2827. const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
  2828. const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
  2829. return animDuration > 0 || transDuration > 0;
  2830. };
  2831. const animateTimerProgressBar = function (timer) {
  2832. let reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2833. const timerProgressBar = getTimerProgressBar();
  2834.  
  2835. if (isVisible(timerProgressBar)) {
  2836. if (reset) {
  2837. timerProgressBar.style.transition = 'none';
  2838. timerProgressBar.style.width = '100%';
  2839. }
  2840.  
  2841. setTimeout(() => {
  2842. timerProgressBar.style.transition = "width ".concat(timer / 1000, "s linear");
  2843. timerProgressBar.style.width = '0%';
  2844. }, 10);
  2845. }
  2846. };
  2847. const stopTimerProgressBar = () => {
  2848. const timerProgressBar = getTimerProgressBar();
  2849. const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
  2850. timerProgressBar.style.removeProperty('transition');
  2851. timerProgressBar.style.width = '100%';
  2852. const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
  2853. const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
  2854. timerProgressBar.style.removeProperty('transition');
  2855. timerProgressBar.style.width = "".concat(timerProgressBarPercent, "%");
  2856. };
  2857.  
  2858. /**
  2859. * Detect Node env
  2860. *
  2861. * @returns {boolean}
  2862. */
  2863. const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
  2864.  
  2865. const RESTORE_FOCUS_TIMEOUT = 100;
  2866.  
  2867. const globalState = {};
  2868.  
  2869. const focusPreviousActiveElement = () => {
  2870. if (globalState.previousActiveElement && globalState.previousActiveElement.focus) {
  2871. globalState.previousActiveElement.focus();
  2872. globalState.previousActiveElement = null;
  2873. } else if (document.body) {
  2874. document.body.focus();
  2875. }
  2876. }; // Restore previous active (focused) element
  2877.  
  2878.  
  2879. const restoreActiveElement = returnFocus => {
  2880. return new Promise(resolve => {
  2881. if (!returnFocus) {
  2882. return resolve();
  2883. }
  2884.  
  2885. const x = window.scrollX;
  2886. const y = window.scrollY;
  2887. globalState.restoreFocusTimeout = setTimeout(() => {
  2888. focusPreviousActiveElement();
  2889. resolve();
  2890. }, RESTORE_FOCUS_TIMEOUT); // issues/900
  2891.  
  2892. window.scrollTo(x, y);
  2893. });
  2894. };
  2895.  
  2896. const sweetHTML = "\n <div aria-labelledby=\"".concat(swalClasses.title, "\" aria-describedby=\"").concat(swalClasses['html-container'], "\" class=\"").concat(swalClasses.popup, "\" tabindex=\"-1\">\n <button type=\"button\" class=\"").concat(swalClasses.close, "\"></button>\n <ul class=\"").concat(swalClasses['progress-steps'], "\"></ul>\n <div class=\"").concat(swalClasses.icon, "\"></div>\n <img class=\"").concat(swalClasses.image, "\" />\n <h2 class=\"").concat(swalClasses.title, "\" id=\"").concat(swalClasses.title, "\"></h2>\n <div class=\"").concat(swalClasses['html-container'], "\" id=\"").concat(swalClasses['html-container'], "\"></div>\n <input class=\"").concat(swalClasses.input, "\" />\n <input type=\"file\" class=\"").concat(swalClasses.file, "\" />\n <div class=\"").concat(swalClasses.range, "\">\n <input type=\"range\" />\n <output></output>\n </div>\n <select class=\"").concat(swalClasses.select, "\"></select>\n <div class=\"").concat(swalClasses.radio, "\"></div>\n <label for=\"").concat(swalClasses.checkbox, "\" class=\"").concat(swalClasses.checkbox, "\">\n <input type=\"checkbox\" />\n <span class=\"").concat(swalClasses.label, "\"></span>\n </label>\n <textarea class=\"").concat(swalClasses.textarea, "\"></textarea>\n <div class=\"").concat(swalClasses['validation-message'], "\" id=\"").concat(swalClasses['validation-message'], "\"></div>\n <div class=\"").concat(swalClasses.actions, "\">\n <div class=\"").concat(swalClasses.loader, "\"></div>\n <button type=\"button\" class=\"").concat(swalClasses.confirm, "\"></button>\n <button type=\"button\" class=\"").concat(swalClasses.deny, "\"></button>\n <button type=\"button\" class=\"").concat(swalClasses.cancel, "\"></button>\n </div>\n <div class=\"").concat(swalClasses.footer, "\"></div>\n <div class=\"").concat(swalClasses['timer-progress-bar-container'], "\">\n <div class=\"").concat(swalClasses['timer-progress-bar'], "\"></div>\n </div>\n </div>\n").replace(/(^|\n)\s*/g, '');
  2897.  
  2898. const resetOldContainer = () => {
  2899. const oldContainer = getContainer();
  2900.  
  2901. if (!oldContainer) {
  2902. return false;
  2903. }
  2904.  
  2905. oldContainer.remove();
  2906. removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]);
  2907. return true;
  2908. };
  2909.  
  2910. const resetValidationMessage = () => {
  2911. globalState.currentInstance.resetValidationMessage();
  2912. };
  2913.  
  2914. const addInputChangeListeners = () => {
  2915. const popup = getPopup();
  2916. const input = getDirectChildByClass(popup, swalClasses.input);
  2917. const file = getDirectChildByClass(popup, swalClasses.file);
  2918. const range = popup.querySelector(".".concat(swalClasses.range, " input"));
  2919. const rangeOutput = popup.querySelector(".".concat(swalClasses.range, " output"));
  2920. const select = getDirectChildByClass(popup, swalClasses.select);
  2921. const checkbox = popup.querySelector(".".concat(swalClasses.checkbox, " input"));
  2922. const textarea = getDirectChildByClass(popup, swalClasses.textarea);
  2923. input.oninput = resetValidationMessage;
  2924. file.onchange = resetValidationMessage;
  2925. select.onchange = resetValidationMessage;
  2926. checkbox.onchange = resetValidationMessage;
  2927. textarea.oninput = resetValidationMessage;
  2928.  
  2929. range.oninput = () => {
  2930. resetValidationMessage();
  2931. rangeOutput.value = range.value;
  2932. };
  2933.  
  2934. range.onchange = () => {
  2935. resetValidationMessage();
  2936. range.nextSibling.value = range.value;
  2937. };
  2938. };
  2939.  
  2940. const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;
  2941.  
  2942. const setupAccessibility = params => {
  2943. const popup = getPopup();
  2944. popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
  2945. popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
  2946.  
  2947. if (!params.toast) {
  2948. popup.setAttribute('aria-modal', 'true');
  2949. }
  2950. };
  2951.  
  2952. const setupRTL = targetElement => {
  2953. if (window.getComputedStyle(targetElement).direction === 'rtl') {
  2954. addClass(getContainer(), swalClasses.rtl);
  2955. }
  2956. };
  2957. /*
  2958. * Add modal + backdrop to DOM
  2959. */
  2960.  
  2961.  
  2962. const init = params => {
  2963. // Clean up the old popup container if it exists
  2964. const oldContainerExisted = resetOldContainer();
  2965. /* istanbul ignore if */
  2966.  
  2967. if (isNodeEnv()) {
  2968. error('SweetAlert2 requires document to initialize');
  2969. return;
  2970. }
  2971.  
  2972. const container = document.createElement('div');
  2973. container.className = swalClasses.container;
  2974.  
  2975. if (oldContainerExisted) {
  2976. addClass(container, swalClasses['no-transition']);
  2977. }
  2978.  
  2979. setInnerHtml(container, sweetHTML);
  2980. const targetElement = getTarget(params.target);
  2981. targetElement.appendChild(container);
  2982. setupAccessibility(params);
  2983. setupRTL(targetElement);
  2984. addInputChangeListeners();
  2985. };
  2986.  
  2987. /**
  2988. * @param {HTMLElement | object | string} param
  2989. * @param {HTMLElement} target
  2990. */
  2991.  
  2992. const parseHtmlToContainer = (param, target) => {
  2993. // DOM element
  2994. if (param instanceof HTMLElement) {
  2995. target.appendChild(param);
  2996. } // Object
  2997. else if (typeof param === 'object') {
  2998. handleObject(param, target);
  2999. } // Plain string
  3000. else if (param) {
  3001. setInnerHtml(target, param);
  3002. }
  3003. };
  3004. /**
  3005. * @param {object} param
  3006. * @param {HTMLElement} target
  3007. */
  3008.  
  3009. const handleObject = (param, target) => {
  3010. // JQuery element(s)
  3011. if (param.jquery) {
  3012. handleJqueryElem(target, param);
  3013. } // For other objects use their string representation
  3014. else {
  3015. setInnerHtml(target, param.toString());
  3016. }
  3017. };
  3018.  
  3019. const handleJqueryElem = (target, elem) => {
  3020. target.textContent = '';
  3021.  
  3022. if (0 in elem) {
  3023. for (let i = 0; (i in elem); i++) {
  3024. target.appendChild(elem[i].cloneNode(true));
  3025. }
  3026. } else {
  3027. target.appendChild(elem.cloneNode(true));
  3028. }
  3029. };
  3030.  
  3031. const animationEndEvent = (() => {
  3032. // Prevent run in Node env
  3033.  
  3034. /* istanbul ignore if */
  3035. if (isNodeEnv()) {
  3036. return false;
  3037. }
  3038.  
  3039. const testEl = document.createElement('div');
  3040. const transEndEventNames = {
  3041. WebkitAnimation: 'webkitAnimationEnd',
  3042. // Chrome, Safari and Opera
  3043. animation: 'animationend' // Standard syntax
  3044.  
  3045. };
  3046.  
  3047. for (const i in transEndEventNames) {
  3048. if (Object.prototype.hasOwnProperty.call(transEndEventNames, i) && typeof testEl.style[i] !== 'undefined') {
  3049. return transEndEventNames[i];
  3050. }
  3051. }
  3052.  
  3053. return false;
  3054. })();
  3055.  
  3056. // https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
  3057.  
  3058. const measureScrollbar = () => {
  3059. const scrollDiv = document.createElement('div');
  3060. scrollDiv.className = swalClasses['scrollbar-measure'];
  3061. document.body.appendChild(scrollDiv);
  3062. const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  3063. document.body.removeChild(scrollDiv);
  3064. return scrollbarWidth;
  3065. };
  3066.  
  3067. const renderActions = (instance, params) => {
  3068. const actions = getActions();
  3069. const loader = getLoader(); // Actions (buttons) wrapper
  3070.  
  3071. if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
  3072. hide(actions);
  3073. } else {
  3074. show(actions);
  3075. } // Custom class
  3076.  
  3077.  
  3078. applyCustomClass(actions, params, 'actions'); // Render all the buttons
  3079.  
  3080. renderButtons(actions, loader, params); // Loader
  3081.  
  3082. setInnerHtml(loader, params.loaderHtml);
  3083. applyCustomClass(loader, params, 'loader');
  3084. };
  3085.  
  3086. function renderButtons(actions, loader, params) {
  3087. const confirmButton = getConfirmButton();
  3088. const denyButton = getDenyButton();
  3089. const cancelButton = getCancelButton(); // Render buttons
  3090.  
  3091. renderButton(confirmButton, 'confirm', params);
  3092. renderButton(denyButton, 'deny', params);
  3093. renderButton(cancelButton, 'cancel', params);
  3094. handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
  3095.  
  3096. if (params.reverseButtons) {
  3097. if (params.toast) {
  3098. actions.insertBefore(cancelButton, confirmButton);
  3099. actions.insertBefore(denyButton, confirmButton);
  3100. } else {
  3101. actions.insertBefore(cancelButton, loader);
  3102. actions.insertBefore(denyButton, loader);
  3103. actions.insertBefore(confirmButton, loader);
  3104. }
  3105. }
  3106. }
  3107.  
  3108. function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
  3109. if (!params.buttonsStyling) {
  3110. return removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
  3111. }
  3112.  
  3113. addClass([confirmButton, denyButton, cancelButton], swalClasses.styled); // Buttons background colors
  3114.  
  3115. if (params.confirmButtonColor) {
  3116. confirmButton.style.backgroundColor = params.confirmButtonColor;
  3117. addClass(confirmButton, swalClasses['default-outline']);
  3118. }
  3119.  
  3120. if (params.denyButtonColor) {
  3121. denyButton.style.backgroundColor = params.denyButtonColor;
  3122. addClass(denyButton, swalClasses['default-outline']);
  3123. }
  3124.  
  3125. if (params.cancelButtonColor) {
  3126. cancelButton.style.backgroundColor = params.cancelButtonColor;
  3127. addClass(cancelButton, swalClasses['default-outline']);
  3128. }
  3129. }
  3130.  
  3131. function renderButton(button, buttonType, params) {
  3132. toggle(button, params["show".concat(capitalizeFirstLetter(buttonType), "Button")], 'inline-block');
  3133. setInnerHtml(button, params["".concat(buttonType, "ButtonText")]); // Set caption text
  3134.  
  3135. button.setAttribute('aria-label', params["".concat(buttonType, "ButtonAriaLabel")]); // ARIA label
  3136. // Add buttons custom classes
  3137.  
  3138. button.className = swalClasses[buttonType];
  3139. applyCustomClass(button, params, "".concat(buttonType, "Button"));
  3140. addClass(button, params["".concat(buttonType, "ButtonClass")]);
  3141. }
  3142.  
  3143. function handleBackdropParam(container, backdrop) {
  3144. if (typeof backdrop === 'string') {
  3145. container.style.background = backdrop;
  3146. } else if (!backdrop) {
  3147. addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
  3148. }
  3149. }
  3150.  
  3151. function handlePositionParam(container, position) {
  3152. if (position in swalClasses) {
  3153. addClass(container, swalClasses[position]);
  3154. } else {
  3155. warn('The "position" parameter is not valid, defaulting to "center"');
  3156. addClass(container, swalClasses.center);
  3157. }
  3158. }
  3159.  
  3160. function handleGrowParam(container, grow) {
  3161. if (grow && typeof grow === 'string') {
  3162. const growClass = "grow-".concat(grow);
  3163.  
  3164. if (growClass in swalClasses) {
  3165. addClass(container, swalClasses[growClass]);
  3166. }
  3167. }
  3168. }
  3169.  
  3170. const renderContainer = (instance, params) => {
  3171. const container = getContainer();
  3172.  
  3173. if (!container) {
  3174. return;
  3175. }
  3176.  
  3177. handleBackdropParam(container, params.backdrop);
  3178. handlePositionParam(container, params.position);
  3179. handleGrowParam(container, params.grow); // Custom class
  3180.  
  3181. applyCustomClass(container, params, 'container');
  3182. };
  3183.  
  3184. /**
  3185. * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
  3186. * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
  3187. * This is the approach that Babel will probably take to implement private methods/fields
  3188. * https://github.com/tc39/proposal-private-methods
  3189. * https://github.com/babel/babel/pull/7555
  3190. * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
  3191. * then we can use that language feature.
  3192. */
  3193. var privateProps = {
  3194. awaitingPromise: new WeakMap(),
  3195. promise: new WeakMap(),
  3196. innerParams: new WeakMap(),
  3197. domCache: new WeakMap()
  3198. };
  3199.  
  3200. const inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
  3201. const renderInput = (instance, params) => {
  3202. const popup = getPopup();
  3203. const innerParams = privateProps.innerParams.get(instance);
  3204. const rerender = !innerParams || params.input !== innerParams.input;
  3205. inputTypes.forEach(inputType => {
  3206. const inputClass = swalClasses[inputType];
  3207. const inputContainer = getDirectChildByClass(popup, inputClass); // set attributes
  3208.  
  3209. setAttributes(inputType, params.inputAttributes); // set class
  3210.  
  3211. inputContainer.className = inputClass;
  3212.  
  3213. if (rerender) {
  3214. hide(inputContainer);
  3215. }
  3216. });
  3217.  
  3218. if (params.input) {
  3219. if (rerender) {
  3220. showInput(params);
  3221. } // set custom class
  3222.  
  3223.  
  3224. setCustomClass(params);
  3225. }
  3226. };
  3227.  
  3228. const showInput = params => {
  3229. if (!renderInputType[params.input]) {
  3230. return error("Unexpected type of input! Expected \"text\", \"email\", \"password\", \"number\", \"tel\", \"select\", \"radio\", \"checkbox\", \"textarea\", \"file\" or \"url\", got \"".concat(params.input, "\""));
  3231. }
  3232.  
  3233. const inputContainer = getInputContainer(params.input);
  3234. const input = renderInputType[params.input](inputContainer, params);
  3235. show(input); // input autofocus
  3236.  
  3237. setTimeout(() => {
  3238. focusInput(input);
  3239. });
  3240. };
  3241.  
  3242. const removeAttributes = input => {
  3243. for (let i = 0; i < input.attributes.length; i++) {
  3244. const attrName = input.attributes[i].name;
  3245.  
  3246. if (!['type', 'value', 'style'].includes(attrName)) {
  3247. input.removeAttribute(attrName);
  3248. }
  3249. }
  3250. };
  3251.  
  3252. const setAttributes = (inputType, inputAttributes) => {
  3253. const input = getInput(getPopup(), inputType);
  3254.  
  3255. if (!input) {
  3256. return;
  3257. }
  3258.  
  3259. removeAttributes(input);
  3260.  
  3261. for (const attr in inputAttributes) {
  3262. input.setAttribute(attr, inputAttributes[attr]);
  3263. }
  3264. };
  3265.  
  3266. const setCustomClass = params => {
  3267. const inputContainer = getInputContainer(params.input);
  3268.  
  3269. if (params.customClass) {
  3270. addClass(inputContainer, params.customClass.input);
  3271. }
  3272. };
  3273.  
  3274. const setInputPlaceholder = (input, params) => {
  3275. if (!input.placeholder || params.inputPlaceholder) {
  3276. input.placeholder = params.inputPlaceholder;
  3277. }
  3278. };
  3279.  
  3280. const setInputLabel = (input, prependTo, params) => {
  3281. if (params.inputLabel) {
  3282. input.id = swalClasses.input;
  3283. const label = document.createElement('label');
  3284. const labelClass = swalClasses['input-label'];
  3285. label.setAttribute('for', input.id);
  3286. label.className = labelClass;
  3287. addClass(label, params.customClass.inputLabel);
  3288. label.innerText = params.inputLabel;
  3289. prependTo.insertAdjacentElement('beforebegin', label);
  3290. }
  3291. };
  3292.  
  3293. const getInputContainer = inputType => {
  3294. const inputClass = swalClasses[inputType] ? swalClasses[inputType] : swalClasses.input;
  3295. return getDirectChildByClass(getPopup(), inputClass);
  3296. };
  3297.  
  3298. const renderInputType = {};
  3299.  
  3300. renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = (input, params) => {
  3301. if (typeof params.inputValue === 'string' || typeof params.inputValue === 'number') {
  3302. input.value = params.inputValue;
  3303. } else if (!isPromise(params.inputValue)) {
  3304. warn("Unexpected type of inputValue! Expected \"string\", \"number\" or \"Promise\", got \"".concat(typeof params.inputValue, "\""));
  3305. }
  3306.  
  3307. setInputLabel(input, input, params);
  3308. setInputPlaceholder(input, params);
  3309. input.type = params.input;
  3310. return input;
  3311. };
  3312.  
  3313. renderInputType.file = (input, params) => {
  3314. setInputLabel(input, input, params);
  3315. setInputPlaceholder(input, params);
  3316. return input;
  3317. };
  3318.  
  3319. renderInputType.range = (range, params) => {
  3320. const rangeInput = range.querySelector('input');
  3321. const rangeOutput = range.querySelector('output');
  3322. rangeInput.value = params.inputValue;
  3323. rangeInput.type = params.input;
  3324. rangeOutput.value = params.inputValue;
  3325. setInputLabel(rangeInput, range, params);
  3326. return range;
  3327. };
  3328.  
  3329. renderInputType.select = (select, params) => {
  3330. select.textContent = '';
  3331.  
  3332. if (params.inputPlaceholder) {
  3333. const placeholder = document.createElement('option');
  3334. setInnerHtml(placeholder, params.inputPlaceholder);
  3335. placeholder.value = '';
  3336. placeholder.disabled = true;
  3337. placeholder.selected = true;
  3338. select.appendChild(placeholder);
  3339. }
  3340.  
  3341. setInputLabel(select, select, params);
  3342. return select;
  3343. };
  3344.  
  3345. renderInputType.radio = radio => {
  3346. radio.textContent = '';
  3347. return radio;
  3348. };
  3349.  
  3350. renderInputType.checkbox = (checkboxContainer, params) => {
  3351. /** @type {HTMLInputElement} */
  3352. const checkbox = getInput(getPopup(), 'checkbox');
  3353. checkbox.value = '1';
  3354. checkbox.id = swalClasses.checkbox;
  3355. checkbox.checked = Boolean(params.inputValue);
  3356. const label = checkboxContainer.querySelector('span');
  3357. setInnerHtml(label, params.inputPlaceholder);
  3358. return checkboxContainer;
  3359. };
  3360.  
  3361. renderInputType.textarea = (textarea, params) => {
  3362. textarea.value = params.inputValue;
  3363. setInputPlaceholder(textarea, params);
  3364. setInputLabel(textarea, textarea, params);
  3365.  
  3366. const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight); // https://github.com/sweetalert2/sweetalert2/issues/2291
  3367.  
  3368.  
  3369. setTimeout(() => {
  3370. // https://github.com/sweetalert2/sweetalert2/issues/1699
  3371. if ('MutationObserver' in window) {
  3372. const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
  3373.  
  3374. const textareaResizeHandler = () => {
  3375. const textareaWidth = textarea.offsetWidth + getMargin(textarea);
  3376.  
  3377. if (textareaWidth > initialPopupWidth) {
  3378. getPopup().style.width = "".concat(textareaWidth, "px");
  3379. } else {
  3380. getPopup().style.width = null;
  3381. }
  3382. };
  3383.  
  3384. new MutationObserver(textareaResizeHandler).observe(textarea, {
  3385. attributes: true,
  3386. attributeFilter: ['style']
  3387. });
  3388. }
  3389. });
  3390. return textarea;
  3391. };
  3392.  
  3393. const renderContent = (instance, params) => {
  3394. const htmlContainer = getHtmlContainer();
  3395. applyCustomClass(htmlContainer, params, 'htmlContainer'); // Content as HTML
  3396.  
  3397. if (params.html) {
  3398. parseHtmlToContainer(params.html, htmlContainer);
  3399. show(htmlContainer, 'block');
  3400. } // Content as plain text
  3401. else if (params.text) {
  3402. htmlContainer.textContent = params.text;
  3403. show(htmlContainer, 'block');
  3404. } // No content
  3405. else {
  3406. hide(htmlContainer);
  3407. }
  3408.  
  3409. renderInput(instance, params);
  3410. };
  3411.  
  3412. const renderFooter = (instance, params) => {
  3413. const footer = getFooter();
  3414. toggle(footer, params.footer);
  3415.  
  3416. if (params.footer) {
  3417. parseHtmlToContainer(params.footer, footer);
  3418. } // Custom class
  3419.  
  3420.  
  3421. applyCustomClass(footer, params, 'footer');
  3422. };
  3423.  
  3424. const renderCloseButton = (instance, params) => {
  3425. const closeButton = getCloseButton();
  3426. setInnerHtml(closeButton, params.closeButtonHtml); // Custom class
  3427.  
  3428. applyCustomClass(closeButton, params, 'closeButton');
  3429. toggle(closeButton, params.showCloseButton);
  3430. closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
  3431. };
  3432.  
  3433. const renderIcon = (instance, params) => {
  3434. const innerParams = privateProps.innerParams.get(instance);
  3435. const icon = getIcon(); // if the given icon already rendered, apply the styling without re-rendering the icon
  3436.  
  3437. if (innerParams && params.icon === innerParams.icon) {
  3438. // Custom or default content
  3439. setContent(icon, params);
  3440. applyStyles(icon, params);
  3441. return;
  3442. }
  3443.  
  3444. if (!params.icon && !params.iconHtml) {
  3445. return hide(icon);
  3446. }
  3447.  
  3448. if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
  3449. error("Unknown icon! Expected \"success\", \"error\", \"warning\", \"info\" or \"question\", got \"".concat(params.icon, "\""));
  3450. return hide(icon);
  3451. }
  3452.  
  3453. show(icon); // Custom or default content
  3454.  
  3455. setContent(icon, params);
  3456. applyStyles(icon, params); // Animate icon
  3457.  
  3458. addClass(icon, params.showClass.icon);
  3459. };
  3460.  
  3461. const applyStyles = (icon, params) => {
  3462. for (const iconType in iconTypes) {
  3463. if (params.icon !== iconType) {
  3464. removeClass(icon, iconTypes[iconType]);
  3465. }
  3466. }
  3467.  
  3468. addClass(icon, iconTypes[params.icon]); // Icon color
  3469.  
  3470. setColor(icon, params); // Success icon background color
  3471.  
  3472. adjustSuccessIconBackgroundColor(); // Custom class
  3473.  
  3474. applyCustomClass(icon, params, 'icon');
  3475. }; // Adjust success icon background color to match the popup background color
  3476.  
  3477.  
  3478. const adjustSuccessIconBackgroundColor = () => {
  3479. const popup = getPopup();
  3480. const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
  3481. const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
  3482.  
  3483. for (let i = 0; i < successIconParts.length; i++) {
  3484. successIconParts[i].style.backgroundColor = popupBackgroundColor;
  3485. }
  3486. };
  3487.  
  3488. const successIconHtml = "\n <div class=\"swal2-success-circular-line-left\"></div>\n <span class=\"swal2-success-line-tip\"></span> <span class=\"swal2-success-line-long\"></span>\n <div class=\"swal2-success-ring\"></div> <div class=\"swal2-success-fix\"></div>\n <div class=\"swal2-success-circular-line-right\"></div>\n";
  3489. const errorIconHtml = "\n <span class=\"swal2-x-mark\">\n <span class=\"swal2-x-mark-line-left\"></span>\n <span class=\"swal2-x-mark-line-right\"></span>\n </span>\n";
  3490.  
  3491. const setContent = (icon, params) => {
  3492. icon.textContent = '';
  3493.  
  3494. if (params.iconHtml) {
  3495. setInnerHtml(icon, iconContent(params.iconHtml));
  3496. } else if (params.icon === 'success') {
  3497. setInnerHtml(icon, successIconHtml);
  3498. } else if (params.icon === 'error') {
  3499. setInnerHtml(icon, errorIconHtml);
  3500. } else {
  3501. const defaultIconHtml = {
  3502. question: '?',
  3503. warning: '!',
  3504. info: 'i'
  3505. };
  3506. setInnerHtml(icon, iconContent(defaultIconHtml[params.icon]));
  3507. }
  3508. };
  3509.  
  3510. const setColor = (icon, params) => {
  3511. if (!params.iconColor) {
  3512. return;
  3513. }
  3514.  
  3515. icon.style.color = params.iconColor;
  3516. icon.style.borderColor = params.iconColor;
  3517.  
  3518. for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
  3519. setStyle(icon, sel, 'backgroundColor', params.iconColor);
  3520. }
  3521.  
  3522. setStyle(icon, '.swal2-success-ring', 'borderColor', params.iconColor);
  3523. };
  3524.  
  3525. const iconContent = content => "<div class=\"".concat(swalClasses['icon-content'], "\">").concat(content, "</div>");
  3526.  
  3527. const renderImage = (instance, params) => {
  3528. const image = getImage();
  3529.  
  3530. if (!params.imageUrl) {
  3531. return hide(image);
  3532. }
  3533.  
  3534. show(image, ''); // Src, alt
  3535.  
  3536. image.setAttribute('src', params.imageUrl);
  3537. image.setAttribute('alt', params.imageAlt); // Width, height
  3538.  
  3539. applyNumericalStyle(image, 'width', params.imageWidth);
  3540. applyNumericalStyle(image, 'height', params.imageHeight); // Class
  3541.  
  3542. image.className = swalClasses.image;
  3543. applyCustomClass(image, params, 'image');
  3544. };
  3545.  
  3546. const createStepElement = step => {
  3547. const stepEl = document.createElement('li');
  3548. addClass(stepEl, swalClasses['progress-step']);
  3549. setInnerHtml(stepEl, step);
  3550. return stepEl;
  3551. };
  3552.  
  3553. const createLineElement = params => {
  3554. const lineEl = document.createElement('li');
  3555. addClass(lineEl, swalClasses['progress-step-line']);
  3556.  
  3557. if (params.progressStepsDistance) {
  3558. lineEl.style.width = params.progressStepsDistance;
  3559. }
  3560.  
  3561. return lineEl;
  3562. };
  3563.  
  3564. const renderProgressSteps = (instance, params) => {
  3565. const progressStepsContainer = getProgressSteps();
  3566.  
  3567. if (!params.progressSteps || params.progressSteps.length === 0) {
  3568. return hide(progressStepsContainer);
  3569. }
  3570.  
  3571. show(progressStepsContainer);
  3572. progressStepsContainer.textContent = '';
  3573.  
  3574. if (params.currentProgressStep >= params.progressSteps.length) {
  3575. warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
  3576. }
  3577.  
  3578. params.progressSteps.forEach((step, index) => {
  3579. const stepEl = createStepElement(step);
  3580. progressStepsContainer.appendChild(stepEl);
  3581.  
  3582. if (index === params.currentProgressStep) {
  3583. addClass(stepEl, swalClasses['active-progress-step']);
  3584. }
  3585.  
  3586. if (index !== params.progressSteps.length - 1) {
  3587. const lineEl = createLineElement(params);
  3588. progressStepsContainer.appendChild(lineEl);
  3589. }
  3590. });
  3591. };
  3592.  
  3593. const renderTitle = (instance, params) => {
  3594. const title = getTitle();
  3595. toggle(title, params.title || params.titleText, 'block');
  3596.  
  3597. if (params.title) {
  3598. parseHtmlToContainer(params.title, title);
  3599. }
  3600.  
  3601. if (params.titleText) {
  3602. title.innerText = params.titleText;
  3603. } // Custom class
  3604.  
  3605.  
  3606. applyCustomClass(title, params, 'title');
  3607. };
  3608.  
  3609. const renderPopup = (instance, params) => {
  3610. const container = getContainer();
  3611. const popup = getPopup(); // Width
  3612. // https://github.com/sweetalert2/sweetalert2/issues/2170
  3613.  
  3614. if (params.toast) {
  3615. applyNumericalStyle(container, 'width', params.width);
  3616. popup.style.width = '100%';
  3617. popup.insertBefore(getLoader(), getIcon());
  3618. } else {
  3619. applyNumericalStyle(popup, 'width', params.width);
  3620. } // Padding
  3621.  
  3622.  
  3623. applyNumericalStyle(popup, 'padding', params.padding); // Color
  3624.  
  3625. if (params.color) {
  3626. popup.style.color = params.color;
  3627. } // Background
  3628.  
  3629.  
  3630. if (params.background) {
  3631. popup.style.background = params.background;
  3632. }
  3633.  
  3634. hide(getValidationMessage()); // Classes
  3635.  
  3636. addClasses(popup, params);
  3637. };
  3638.  
  3639. const addClasses = (popup, params) => {
  3640. // Default Class + showClass when updating Swal.update({})
  3641. popup.className = "".concat(swalClasses.popup, " ").concat(isVisible(popup) ? params.showClass.popup : '');
  3642.  
  3643. if (params.toast) {
  3644. addClass([document.documentElement, document.body], swalClasses['toast-shown']);
  3645. addClass(popup, swalClasses.toast);
  3646. } else {
  3647. addClass(popup, swalClasses.modal);
  3648. } // Custom class
  3649.  
  3650.  
  3651. applyCustomClass(popup, params, 'popup');
  3652.  
  3653. if (typeof params.customClass === 'string') {
  3654. addClass(popup, params.customClass);
  3655. } // Icon class (#1842)
  3656.  
  3657.  
  3658. if (params.icon) {
  3659. addClass(popup, swalClasses["icon-".concat(params.icon)]);
  3660. }
  3661. };
  3662.  
  3663. const render = (instance, params) => {
  3664. renderPopup(instance, params);
  3665. renderContainer(instance, params);
  3666. renderProgressSteps(instance, params);
  3667. renderIcon(instance, params);
  3668. renderImage(instance, params);
  3669. renderTitle(instance, params);
  3670. renderCloseButton(instance, params);
  3671. renderContent(instance, params);
  3672. renderActions(instance, params);
  3673. renderFooter(instance, params);
  3674.  
  3675. if (typeof params.didRender === 'function') {
  3676. params.didRender(getPopup());
  3677. }
  3678. };
  3679.  
  3680. const DismissReason = Object.freeze({
  3681. cancel: 'cancel',
  3682. backdrop: 'backdrop',
  3683. close: 'close',
  3684. esc: 'esc',
  3685. timer: 'timer'
  3686. });
  3687.  
  3688. // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
  3689. // elements not within the active modal dialog will not be surfaced if a user opens a screen
  3690. // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
  3691.  
  3692. const setAriaHidden = () => {
  3693. const bodyChildren = toArray(document.body.children);
  3694. bodyChildren.forEach(el => {
  3695. if (el === getContainer() || el.contains(getContainer())) {
  3696. return;
  3697. }
  3698.  
  3699. if (el.hasAttribute('aria-hidden')) {
  3700. el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden'));
  3701. }
  3702.  
  3703. el.setAttribute('aria-hidden', 'true');
  3704. });
  3705. };
  3706. const unsetAriaHidden = () => {
  3707. const bodyChildren = toArray(document.body.children);
  3708. bodyChildren.forEach(el => {
  3709. if (el.hasAttribute('data-previous-aria-hidden')) {
  3710. el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden'));
  3711. el.removeAttribute('data-previous-aria-hidden');
  3712. } else {
  3713. el.removeAttribute('aria-hidden');
  3714. }
  3715. });
  3716. };
  3717.  
  3718. const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
  3719. const getTemplateParams = params => {
  3720. const template = typeof params.template === 'string' ? document.querySelector(params.template) : params.template;
  3721.  
  3722. if (!template) {
  3723. return {};
  3724. }
  3725. /** @type {DocumentFragment} */
  3726.  
  3727.  
  3728. const templateContent = template.content;
  3729. showWarningsForElements(templateContent);
  3730. const result = Object.assign(getSwalParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
  3731. return result;
  3732. };
  3733. /**
  3734. * @param {DocumentFragment} templateContent
  3735. */
  3736.  
  3737. const getSwalParams = templateContent => {
  3738. const result = {};
  3739. toArray(templateContent.querySelectorAll('swal-param')).forEach(param => {
  3740. showWarningsForAttributes(param, ['name', 'value']);
  3741. const paramName = param.getAttribute('name');
  3742. const value = param.getAttribute('value');
  3743.  
  3744. if (typeof defaultParams[paramName] === 'boolean' && value === 'false') {
  3745. result[paramName] = false;
  3746. }
  3747.  
  3748. if (typeof defaultParams[paramName] === 'object') {
  3749. result[paramName] = JSON.parse(value);
  3750. }
  3751. });
  3752. return result;
  3753. };
  3754. /**
  3755. * @param {DocumentFragment} templateContent
  3756. */
  3757.  
  3758.  
  3759. const getSwalButtons = templateContent => {
  3760. const result = {};
  3761. toArray(templateContent.querySelectorAll('swal-button')).forEach(button => {
  3762. showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
  3763. const type = button.getAttribute('type');
  3764. result["".concat(type, "ButtonText")] = button.innerHTML;
  3765. result["show".concat(capitalizeFirstLetter(type), "Button")] = true;
  3766.  
  3767. if (button.hasAttribute('color')) {
  3768. result["".concat(type, "ButtonColor")] = button.getAttribute('color');
  3769. }
  3770.  
  3771. if (button.hasAttribute('aria-label')) {
  3772. result["".concat(type, "ButtonAriaLabel")] = button.getAttribute('aria-label');
  3773. }
  3774. });
  3775. return result;
  3776. };
  3777. /**
  3778. * @param {DocumentFragment} templateContent
  3779. */
  3780.  
  3781.  
  3782. const getSwalImage = templateContent => {
  3783. const result = {};
  3784. /** @type {HTMLElement} */
  3785.  
  3786. const image = templateContent.querySelector('swal-image');
  3787.  
  3788. if (image) {
  3789. showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
  3790.  
  3791. if (image.hasAttribute('src')) {
  3792. result.imageUrl = image.getAttribute('src');
  3793. }
  3794.  
  3795. if (image.hasAttribute('width')) {
  3796. result.imageWidth = image.getAttribute('width');
  3797. }
  3798.  
  3799. if (image.hasAttribute('height')) {
  3800. result.imageHeight = image.getAttribute('height');
  3801. }
  3802.  
  3803. if (image.hasAttribute('alt')) {
  3804. result.imageAlt = image.getAttribute('alt');
  3805. }
  3806. }
  3807.  
  3808. return result;
  3809. };
  3810. /**
  3811. * @param {DocumentFragment} templateContent
  3812. */
  3813.  
  3814.  
  3815. const getSwalIcon = templateContent => {
  3816. const result = {};
  3817. /** @type {HTMLElement} */
  3818.  
  3819. const icon = templateContent.querySelector('swal-icon');
  3820.  
  3821. if (icon) {
  3822. showWarningsForAttributes(icon, ['type', 'color']);
  3823.  
  3824. if (icon.hasAttribute('type')) {
  3825. result.icon = icon.getAttribute('type');
  3826. }
  3827.  
  3828. if (icon.hasAttribute('color')) {
  3829. result.iconColor = icon.getAttribute('color');
  3830. }
  3831.  
  3832. result.iconHtml = icon.innerHTML;
  3833. }
  3834.  
  3835. return result;
  3836. };
  3837. /**
  3838. * @param {DocumentFragment} templateContent
  3839. */
  3840.  
  3841.  
  3842. const getSwalInput = templateContent => {
  3843. const result = {};
  3844. /** @type {HTMLElement} */
  3845.  
  3846. const input = templateContent.querySelector('swal-input');
  3847.  
  3848. if (input) {
  3849. showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
  3850. result.input = input.getAttribute('type') || 'text';
  3851.  
  3852. if (input.hasAttribute('label')) {
  3853. result.inputLabel = input.getAttribute('label');
  3854. }
  3855.  
  3856. if (input.hasAttribute('placeholder')) {
  3857. result.inputPlaceholder = input.getAttribute('placeholder');
  3858. }
  3859.  
  3860. if (input.hasAttribute('value')) {
  3861. result.inputValue = input.getAttribute('value');
  3862. }
  3863. }
  3864.  
  3865. const inputOptions = templateContent.querySelectorAll('swal-input-option');
  3866.  
  3867. if (inputOptions.length) {
  3868. result.inputOptions = {};
  3869. toArray(inputOptions).forEach(option => {
  3870. showWarningsForAttributes(option, ['value']);
  3871. const optionValue = option.getAttribute('value');
  3872. const optionName = option.innerHTML;
  3873. result.inputOptions[optionValue] = optionName;
  3874. });
  3875. }
  3876.  
  3877. return result;
  3878. };
  3879. /**
  3880. * @param {DocumentFragment} templateContent
  3881. * @param {string[]} paramNames
  3882. */
  3883.  
  3884.  
  3885. const getSwalStringParams = (templateContent, paramNames) => {
  3886. const result = {};
  3887.  
  3888. for (const i in paramNames) {
  3889. const paramName = paramNames[i];
  3890. /** @type {HTMLElement} */
  3891.  
  3892. const tag = templateContent.querySelector(paramName);
  3893.  
  3894. if (tag) {
  3895. showWarningsForAttributes(tag, []);
  3896. result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
  3897. }
  3898. }
  3899.  
  3900. return result;
  3901. };
  3902. /**
  3903. * @param {DocumentFragment} templateContent
  3904. */
  3905.  
  3906.  
  3907. const showWarningsForElements = templateContent => {
  3908. const allowedElements = swalStringParams.concat(['swal-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
  3909. toArray(templateContent.children).forEach(el => {
  3910. const tagName = el.tagName.toLowerCase();
  3911.  
  3912. if (allowedElements.indexOf(tagName) === -1) {
  3913. warn("Unrecognized element <".concat(tagName, ">"));
  3914. }
  3915. });
  3916. };
  3917. /**
  3918. * @param {HTMLElement} el
  3919. * @param {string[]} allowedAttributes
  3920. */
  3921.  
  3922.  
  3923. const showWarningsForAttributes = (el, allowedAttributes) => {
  3924. toArray(el.attributes).forEach(attribute => {
  3925. if (allowedAttributes.indexOf(attribute.name) === -1) {
  3926. warn(["Unrecognized attribute \"".concat(attribute.name, "\" on <").concat(el.tagName.toLowerCase(), ">."), "".concat(allowedAttributes.length ? "Allowed attributes are: ".concat(allowedAttributes.join(', ')) : 'To set the value, use HTML within the element.')]);
  3927. }
  3928. });
  3929. };
  3930.  
  3931. var defaultInputValidators = {
  3932. email: (string, validationMessage) => {
  3933. return /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
  3934. },
  3935. url: (string, validationMessage) => {
  3936. // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
  3937. 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');
  3938. }
  3939. };
  3940.  
  3941. function setDefaultInputValidators(params) {
  3942. // Use default `inputValidator` for supported input types if not provided
  3943. if (!params.inputValidator) {
  3944. Object.keys(defaultInputValidators).forEach(key => {
  3945. if (params.input === key) {
  3946. params.inputValidator = defaultInputValidators[key];
  3947. }
  3948. });
  3949. }
  3950. }
  3951.  
  3952. function validateCustomTargetElement(params) {
  3953. // Determine if the custom target element is valid
  3954. if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
  3955. warn('Target parameter is not valid, defaulting to "body"');
  3956. params.target = 'body';
  3957. }
  3958. }
  3959. /**
  3960. * Set type, text and actions on popup
  3961. *
  3962. * @param params
  3963. */
  3964.  
  3965.  
  3966. function setParameters(params) {
  3967. setDefaultInputValidators(params); // showLoaderOnConfirm && preConfirm
  3968.  
  3969. if (params.showLoaderOnConfirm && !params.preConfirm) {
  3970. warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request');
  3971. }
  3972.  
  3973. validateCustomTargetElement(params); // Replace newlines with <br> in title
  3974.  
  3975. if (typeof params.title === 'string') {
  3976. params.title = params.title.split('\n').join('<br />');
  3977. }
  3978.  
  3979. init(params);
  3980. }
  3981.  
  3982. class Timer {
  3983. constructor(callback, delay) {
  3984. this.callback = callback;
  3985. this.remaining = delay;
  3986. this.running = false;
  3987. this.start();
  3988. }
  3989.  
  3990. start() {
  3991. if (!this.running) {
  3992. this.running = true;
  3993. this.started = new Date();
  3994. this.id = setTimeout(this.callback, this.remaining);
  3995. }
  3996.  
  3997. return this.remaining;
  3998. }
  3999.  
  4000. stop() {
  4001. if (this.running) {
  4002. this.running = false;
  4003. clearTimeout(this.id);
  4004. this.remaining -= new Date().getTime() - this.started.getTime();
  4005. }
  4006.  
  4007. return this.remaining;
  4008. }
  4009.  
  4010. increase(n) {
  4011. const running = this.running;
  4012.  
  4013. if (running) {
  4014. this.stop();
  4015. }
  4016.  
  4017. this.remaining += n;
  4018.  
  4019. if (running) {
  4020. this.start();
  4021. }
  4022.  
  4023. return this.remaining;
  4024. }
  4025.  
  4026. getTimerLeft() {
  4027. if (this.running) {
  4028. this.stop();
  4029. this.start();
  4030. }
  4031.  
  4032. return this.remaining;
  4033. }
  4034.  
  4035. isRunning() {
  4036. return this.running;
  4037. }
  4038.  
  4039. }
  4040.  
  4041. const fixScrollbar = () => {
  4042. // for queues, do not do this more than once
  4043. if (states.previousBodyPadding !== null) {
  4044. return;
  4045. } // if the body has overflow
  4046.  
  4047.  
  4048. if (document.body.scrollHeight > window.innerHeight) {
  4049. // add padding so the content doesn't shift after removal of scrollbar
  4050. states.previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
  4051. document.body.style.paddingRight = "".concat(states.previousBodyPadding + measureScrollbar(), "px");
  4052. }
  4053. };
  4054. const undoScrollbar = () => {
  4055. if (states.previousBodyPadding !== null) {
  4056. document.body.style.paddingRight = "".concat(states.previousBodyPadding, "px");
  4057. states.previousBodyPadding = null;
  4058. }
  4059. };
  4060.  
  4061. /* istanbul ignore file */
  4062.  
  4063. const iOSfix = () => {
  4064. const iOS = // @ts-ignore
  4065. /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
  4066.  
  4067. if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
  4068. const offset = document.body.scrollTop;
  4069. document.body.style.top = "".concat(offset * -1, "px");
  4070. addClass(document.body, swalClasses.iosfix);
  4071. lockBodyScroll();
  4072. addBottomPaddingForTallPopups();
  4073. }
  4074. };
  4075. /**
  4076. * https://github.com/sweetalert2/sweetalert2/issues/1948
  4077. */
  4078.  
  4079. const addBottomPaddingForTallPopups = () => {
  4080. const ua = navigator.userAgent;
  4081. const iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
  4082. const webkit = !!ua.match(/WebKit/i);
  4083. const iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
  4084.  
  4085. if (iOSSafari) {
  4086. const bottomPanelHeight = 44;
  4087.  
  4088. if (getPopup().scrollHeight > window.innerHeight - bottomPanelHeight) {
  4089. getContainer().style.paddingBottom = "".concat(bottomPanelHeight, "px");
  4090. }
  4091. }
  4092. };
  4093. /**
  4094. * https://github.com/sweetalert2/sweetalert2/issues/1246
  4095. */
  4096.  
  4097.  
  4098. const lockBodyScroll = () => {
  4099. const container = getContainer();
  4100. let preventTouchMove;
  4101.  
  4102. container.ontouchstart = e => {
  4103. preventTouchMove = shouldPreventTouchMove(e);
  4104. };
  4105.  
  4106. container.ontouchmove = e => {
  4107. if (preventTouchMove) {
  4108. e.preventDefault();
  4109. e.stopPropagation();
  4110. }
  4111. };
  4112. };
  4113.  
  4114. const shouldPreventTouchMove = event => {
  4115. const target = event.target;
  4116. const container = getContainer();
  4117.  
  4118. if (isStylus(event) || isZoom(event)) {
  4119. return false;
  4120. }
  4121.  
  4122. if (target === container) {
  4123. return true;
  4124. }
  4125.  
  4126. if (!isScrollable(container) && target.tagName !== 'INPUT' && // #1603
  4127. target.tagName !== 'TEXTAREA' && // #2266
  4128. !(isScrollable(getHtmlContainer()) && // #1944
  4129. getHtmlContainer().contains(target))) {
  4130. return true;
  4131. }
  4132.  
  4133. return false;
  4134. };
  4135. /**
  4136. * https://github.com/sweetalert2/sweetalert2/issues/1786
  4137. *
  4138. * @param {*} event
  4139. * @returns {boolean}
  4140. */
  4141.  
  4142.  
  4143. const isStylus = event => {
  4144. return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';
  4145. };
  4146. /**
  4147. * https://github.com/sweetalert2/sweetalert2/issues/1891
  4148. *
  4149. * @param {TouchEvent} event
  4150. * @returns {boolean}
  4151. */
  4152.  
  4153.  
  4154. const isZoom = event => {
  4155. return event.touches && event.touches.length > 1;
  4156. };
  4157.  
  4158. const undoIOSfix = () => {
  4159. if (hasClass(document.body, swalClasses.iosfix)) {
  4160. const offset = parseInt(document.body.style.top, 10);
  4161. removeClass(document.body, swalClasses.iosfix);
  4162. document.body.style.top = '';
  4163. document.body.scrollTop = offset * -1;
  4164. }
  4165. };
  4166.  
  4167. const SHOW_CLASS_TIMEOUT = 10;
  4168. /**
  4169. * Open popup, add necessary classes and styles, fix scrollbar
  4170. *
  4171. * @param params
  4172. */
  4173.  
  4174. const openPopup = params => {
  4175. const container = getContainer();
  4176. const popup = getPopup();
  4177.  
  4178. if (typeof params.willOpen === 'function') {
  4179. params.willOpen(popup);
  4180. }
  4181.  
  4182. const bodyStyles = window.getComputedStyle(document.body);
  4183. const initialBodyOverflow = bodyStyles.overflowY;
  4184. addClasses$1(container, popup, params); // scrolling is 'hidden' until animation is done, after that 'auto'
  4185.  
  4186. setTimeout(() => {
  4187. setScrollingVisibility(container, popup);
  4188. }, SHOW_CLASS_TIMEOUT);
  4189.  
  4190. if (isModal()) {
  4191. fixScrollContainer(container, params.scrollbarPadding, initialBodyOverflow);
  4192. setAriaHidden();
  4193. }
  4194.  
  4195. if (!isToast() && !globalState.previousActiveElement) {
  4196. globalState.previousActiveElement = document.activeElement;
  4197. }
  4198.  
  4199. if (typeof params.didOpen === 'function') {
  4200. setTimeout(() => params.didOpen(popup));
  4201. }
  4202.  
  4203. removeClass(container, swalClasses['no-transition']);
  4204. };
  4205.  
  4206. const swalOpenAnimationFinished = event => {
  4207. const popup = getPopup();
  4208.  
  4209. if (event.target !== popup) {
  4210. return;
  4211. }
  4212.  
  4213. const container = getContainer();
  4214. popup.removeEventListener(animationEndEvent, swalOpenAnimationFinished);
  4215. container.style.overflowY = 'auto';
  4216. };
  4217.  
  4218. const setScrollingVisibility = (container, popup) => {
  4219. if (animationEndEvent && hasCssAnimation(popup)) {
  4220. container.style.overflowY = 'hidden';
  4221. popup.addEventListener(animationEndEvent, swalOpenAnimationFinished);
  4222. } else {
  4223. container.style.overflowY = 'auto';
  4224. }
  4225. };
  4226.  
  4227. const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
  4228. iOSfix();
  4229.  
  4230. if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
  4231. fixScrollbar();
  4232. } // sweetalert2/issues/1247
  4233.  
  4234.  
  4235. setTimeout(() => {
  4236. container.scrollTop = 0;
  4237. });
  4238. };
  4239.  
  4240. const addClasses$1 = (container, popup, params) => {
  4241. addClass(container, params.showClass.backdrop); // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
  4242.  
  4243. popup.style.setProperty('opacity', '0', 'important');
  4244. show(popup, 'grid');
  4245. setTimeout(() => {
  4246. // Animate popup right after showing it
  4247. addClass(popup, params.showClass.popup); // and remove the opacity workaround
  4248.  
  4249. popup.style.removeProperty('opacity');
  4250. }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
  4251.  
  4252. addClass([document.documentElement, document.body], swalClasses.shown);
  4253.  
  4254. if (params.heightAuto && params.backdrop && !params.toast) {
  4255. addClass([document.documentElement, document.body], swalClasses['height-auto']);
  4256. }
  4257. };
  4258.  
  4259. /**
  4260. * Shows loader (spinner), this is useful with AJAX requests.
  4261. * By default the loader be shown instead of the "Confirm" button.
  4262. */
  4263.  
  4264. const showLoading = buttonToReplace => {
  4265. let popup = getPopup();
  4266.  
  4267. if (!popup) {
  4268. new Swal(); // eslint-disable-line no-new
  4269. }
  4270.  
  4271. popup = getPopup();
  4272. const loader = getLoader();
  4273.  
  4274. if (isToast()) {
  4275. hide(getIcon());
  4276. } else {
  4277. replaceButton(popup, buttonToReplace);
  4278. }
  4279.  
  4280. show(loader);
  4281. popup.setAttribute('data-loading', true);
  4282. popup.setAttribute('aria-busy', true);
  4283. popup.focus();
  4284. };
  4285.  
  4286. const replaceButton = (popup, buttonToReplace) => {
  4287. const actions = getActions();
  4288. const loader = getLoader();
  4289.  
  4290. if (!buttonToReplace && isVisible(getConfirmButton())) {
  4291. buttonToReplace = getConfirmButton();
  4292. }
  4293.  
  4294. show(actions);
  4295.  
  4296. if (buttonToReplace) {
  4297. hide(buttonToReplace);
  4298. loader.setAttribute('data-button-to-replace', buttonToReplace.className);
  4299. }
  4300.  
  4301. loader.parentNode.insertBefore(loader, buttonToReplace);
  4302. addClass([popup, actions], swalClasses.loading);
  4303. };
  4304.  
  4305. const handleInputOptionsAndValue = (instance, params) => {
  4306. if (params.input === 'select' || params.input === 'radio') {
  4307. handleInputOptions(instance, params);
  4308. } else if (['text', 'email', 'number', 'tel', 'textarea'].includes(params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
  4309. showLoading(getConfirmButton());
  4310. handleInputValue(instance, params);
  4311. }
  4312. };
  4313. const getInputValue = (instance, innerParams) => {
  4314. const input = instance.getInput();
  4315.  
  4316. if (!input) {
  4317. return null;
  4318. }
  4319.  
  4320. switch (innerParams.input) {
  4321. case 'checkbox':
  4322. return getCheckboxValue(input);
  4323.  
  4324. case 'radio':
  4325. return getRadioValue(input);
  4326.  
  4327. case 'file':
  4328. return getFileValue(input);
  4329.  
  4330. default:
  4331. return innerParams.inputAutoTrim ? input.value.trim() : input.value;
  4332. }
  4333. };
  4334.  
  4335. const getCheckboxValue = input => input.checked ? 1 : 0;
  4336.  
  4337. const getRadioValue = input => input.checked ? input.value : null;
  4338.  
  4339. const getFileValue = input => input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
  4340.  
  4341. const handleInputOptions = (instance, params) => {
  4342. const popup = getPopup();
  4343.  
  4344. const processInputOptions = inputOptions => populateInputOptions[params.input](popup, formatInputOptions(inputOptions), params);
  4345.  
  4346. if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
  4347. showLoading(getConfirmButton());
  4348. asPromise(params.inputOptions).then(inputOptions => {
  4349. instance.hideLoading();
  4350. processInputOptions(inputOptions);
  4351. });
  4352. } else if (typeof params.inputOptions === 'object') {
  4353. processInputOptions(params.inputOptions);
  4354. } else {
  4355. error("Unexpected type of inputOptions! Expected object, Map or Promise, got ".concat(typeof params.inputOptions));
  4356. }
  4357. };
  4358.  
  4359. const handleInputValue = (instance, params) => {
  4360. const input = instance.getInput();
  4361. hide(input);
  4362. asPromise(params.inputValue).then(inputValue => {
  4363. input.value = params.input === 'number' ? parseFloat(inputValue) || 0 : "".concat(inputValue);
  4364. show(input);
  4365. input.focus();
  4366. instance.hideLoading();
  4367. }).catch(err => {
  4368. error("Error in inputValue promise: ".concat(err));
  4369. input.value = '';
  4370. show(input);
  4371. input.focus();
  4372. instance.hideLoading();
  4373. });
  4374. };
  4375.  
  4376. const populateInputOptions = {
  4377. select: (popup, inputOptions, params) => {
  4378. const select = getDirectChildByClass(popup, swalClasses.select);
  4379.  
  4380. const renderOption = (parent, optionLabel, optionValue) => {
  4381. const option = document.createElement('option');
  4382. option.value = optionValue;
  4383. setInnerHtml(option, optionLabel);
  4384. option.selected = isSelected(optionValue, params.inputValue);
  4385. parent.appendChild(option);
  4386. };
  4387.  
  4388. inputOptions.forEach(inputOption => {
  4389. const optionValue = inputOption[0];
  4390. const optionLabel = inputOption[1]; // <optgroup> spec:
  4391. // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
  4392. // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
  4393. // check whether this is a <optgroup>
  4394.  
  4395. if (Array.isArray(optionLabel)) {
  4396. // if it is an array, then it is an <optgroup>
  4397. const optgroup = document.createElement('optgroup');
  4398. optgroup.label = optionValue;
  4399. optgroup.disabled = false; // not configurable for now
  4400.  
  4401. select.appendChild(optgroup);
  4402. optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
  4403. } else {
  4404. // case of <option>
  4405. renderOption(select, optionLabel, optionValue);
  4406. }
  4407. });
  4408. select.focus();
  4409. },
  4410. radio: (popup, inputOptions, params) => {
  4411. const radio = getDirectChildByClass(popup, swalClasses.radio);
  4412. inputOptions.forEach(inputOption => {
  4413. const radioValue = inputOption[0];
  4414. const radioLabel = inputOption[1];
  4415. const radioInput = document.createElement('input');
  4416. const radioLabelElement = document.createElement('label');
  4417. radioInput.type = 'radio';
  4418. radioInput.name = swalClasses.radio;
  4419. radioInput.value = radioValue;
  4420.  
  4421. if (isSelected(radioValue, params.inputValue)) {
  4422. radioInput.checked = true;
  4423. }
  4424.  
  4425. const label = document.createElement('span');
  4426. setInnerHtml(label, radioLabel);
  4427. label.className = swalClasses.label;
  4428. radioLabelElement.appendChild(radioInput);
  4429. radioLabelElement.appendChild(label);
  4430. radio.appendChild(radioLabelElement);
  4431. });
  4432. const radios = radio.querySelectorAll('input');
  4433.  
  4434. if (radios.length) {
  4435. radios[0].focus();
  4436. }
  4437. }
  4438. };
  4439. /**
  4440. * Converts `inputOptions` into an array of `[value, label]`s
  4441. * @param inputOptions
  4442. */
  4443.  
  4444. const formatInputOptions = inputOptions => {
  4445. const result = [];
  4446.  
  4447. if (typeof Map !== 'undefined' && inputOptions instanceof Map) {
  4448. inputOptions.forEach((value, key) => {
  4449. let valueFormatted = value;
  4450.  
  4451. if (typeof valueFormatted === 'object') {
  4452. // case of <optgroup>
  4453. valueFormatted = formatInputOptions(valueFormatted);
  4454. }
  4455.  
  4456. result.push([key, valueFormatted]);
  4457. });
  4458. } else {
  4459. Object.keys(inputOptions).forEach(key => {
  4460. let valueFormatted = inputOptions[key];
  4461.  
  4462. if (typeof valueFormatted === 'object') {
  4463. // case of <optgroup>
  4464. valueFormatted = formatInputOptions(valueFormatted);
  4465. }
  4466.  
  4467. result.push([key, valueFormatted]);
  4468. });
  4469. }
  4470.  
  4471. return result;
  4472. };
  4473.  
  4474. const isSelected = (optionValue, inputValue) => {
  4475. return inputValue && inputValue.toString() === optionValue.toString();
  4476. };
  4477.  
  4478. /**
  4479. * Hides loader and shows back the button which was hidden by .showLoading()
  4480. */
  4481.  
  4482. function hideLoading() {
  4483. // do nothing if popup is closed
  4484. const innerParams = privateProps.innerParams.get(this);
  4485.  
  4486. if (!innerParams) {
  4487. return;
  4488. }
  4489.  
  4490. const domCache = privateProps.domCache.get(this);
  4491. hide(domCache.loader);
  4492.  
  4493. if (isToast()) {
  4494. if (innerParams.icon) {
  4495. show(getIcon());
  4496. }
  4497. } else {
  4498. showRelatedButton(domCache);
  4499. }
  4500.  
  4501. removeClass([domCache.popup, domCache.actions], swalClasses.loading);
  4502. domCache.popup.removeAttribute('aria-busy');
  4503. domCache.popup.removeAttribute('data-loading');
  4504. domCache.confirmButton.disabled = false;
  4505. domCache.denyButton.disabled = false;
  4506. domCache.cancelButton.disabled = false;
  4507. }
  4508.  
  4509. const showRelatedButton = domCache => {
  4510. const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute('data-button-to-replace'));
  4511.  
  4512. if (buttonToReplace.length) {
  4513. show(buttonToReplace[0], 'inline-block');
  4514. } else if (allButtonsAreHidden()) {
  4515. hide(domCache.actions);
  4516. }
  4517. };
  4518.  
  4519. /**
  4520. * Gets the input DOM node, this method works with input parameter.
  4521. * @returns {HTMLElement | null}
  4522. */
  4523.  
  4524. function getInput$1(instance) {
  4525. const innerParams = privateProps.innerParams.get(instance || this);
  4526. const domCache = privateProps.domCache.get(instance || this);
  4527.  
  4528. if (!domCache) {
  4529. return null;
  4530. }
  4531.  
  4532. return getInput(domCache.popup, innerParams.input);
  4533. }
  4534.  
  4535. /**
  4536. * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
  4537. * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
  4538. * This is the approach that Babel will probably take to implement private methods/fields
  4539. * https://github.com/tc39/proposal-private-methods
  4540. * https://github.com/babel/babel/pull/7555
  4541. * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
  4542. * then we can use that language feature.
  4543. */
  4544. var privateMethods = {
  4545. swalPromiseResolve: new WeakMap(),
  4546. swalPromiseReject: new WeakMap()
  4547. };
  4548.  
  4549. /*
  4550. * Global function to determine if SweetAlert2 popup is shown
  4551. */
  4552.  
  4553. const isVisible$1 = () => {
  4554. return isVisible(getPopup());
  4555. };
  4556. /*
  4557. * Global function to click 'Confirm' button
  4558. */
  4559.  
  4560. const clickConfirm = () => getConfirmButton() && getConfirmButton().click();
  4561. /*
  4562. * Global function to click 'Deny' button
  4563. */
  4564.  
  4565. const clickDeny = () => getDenyButton() && getDenyButton().click();
  4566. /*
  4567. * Global function to click 'Cancel' button
  4568. */
  4569.  
  4570. const clickCancel = () => getCancelButton() && getCancelButton().click();
  4571.  
  4572. const removeKeydownHandler = globalState => {
  4573. if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
  4574. globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
  4575. capture: globalState.keydownListenerCapture
  4576. });
  4577. globalState.keydownHandlerAdded = false;
  4578. }
  4579. };
  4580. const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
  4581. removeKeydownHandler(globalState);
  4582.  
  4583. if (!innerParams.toast) {
  4584. globalState.keydownHandler = e => keydownHandler(instance, e, dismissWith);
  4585.  
  4586. globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
  4587. globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
  4588. globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
  4589. capture: globalState.keydownListenerCapture
  4590. });
  4591. globalState.keydownHandlerAdded = true;
  4592. }
  4593. }; // Focus handling
  4594.  
  4595. const setFocus = (innerParams, index, increment) => {
  4596. const focusableElements = getFocusableElements(); // search for visible elements and select the next possible match
  4597.  
  4598. if (focusableElements.length) {
  4599. index = index + increment; // rollover to first item
  4600.  
  4601. if (index === focusableElements.length) {
  4602. index = 0; // go to last item
  4603. } else if (index === -1) {
  4604. index = focusableElements.length - 1;
  4605. }
  4606.  
  4607. return focusableElements[index].focus();
  4608. } // no visible focusable elements, focus the popup
  4609.  
  4610.  
  4611. getPopup().focus();
  4612. };
  4613. const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
  4614. const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
  4615.  
  4616. const keydownHandler = (instance, e, dismissWith) => {
  4617. const innerParams = privateProps.innerParams.get(instance);
  4618.  
  4619. if (!innerParams) {
  4620. return; // This instance has already been destroyed
  4621. } // Ignore keydown during IME composition
  4622. // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
  4623. // https://github.com/sweetalert2/sweetalert2/issues/720
  4624. // https://github.com/sweetalert2/sweetalert2/issues/2406
  4625.  
  4626.  
  4627. if (e.isComposing || e.keyCode === 229) {
  4628. return;
  4629. }
  4630.  
  4631. if (innerParams.stopKeydownPropagation) {
  4632. e.stopPropagation();
  4633. } // ENTER
  4634.  
  4635.  
  4636. if (e.key === 'Enter') {
  4637. handleEnter(instance, e, innerParams);
  4638. } // TAB
  4639. else if (e.key === 'Tab') {
  4640. handleTab(e, innerParams);
  4641. } // ARROWS - switch focus between buttons
  4642. else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)) {
  4643. handleArrows(e.key);
  4644. } // ESC
  4645. else if (e.key === 'Escape') {
  4646. handleEsc(e, innerParams, dismissWith);
  4647. }
  4648. };
  4649.  
  4650. const handleEnter = (instance, e, innerParams) => {
  4651. // https://github.com/sweetalert2/sweetalert2/issues/2386
  4652. if (!callIfFunction(innerParams.allowEnterKey)) {
  4653. return;
  4654. }
  4655.  
  4656. if (e.target && instance.getInput() && e.target.outerHTML === instance.getInput().outerHTML) {
  4657. if (['textarea', 'file'].includes(innerParams.input)) {
  4658. return; // do not submit
  4659. }
  4660.  
  4661. clickConfirm();
  4662. e.preventDefault();
  4663. }
  4664. };
  4665.  
  4666. const handleTab = (e, innerParams) => {
  4667. const targetElement = e.target;
  4668. const focusableElements = getFocusableElements();
  4669. let btnIndex = -1;
  4670.  
  4671. for (let i = 0; i < focusableElements.length; i++) {
  4672. if (targetElement === focusableElements[i]) {
  4673. btnIndex = i;
  4674. break;
  4675. }
  4676. } // Cycle to the next button
  4677.  
  4678.  
  4679. if (!e.shiftKey) {
  4680. setFocus(innerParams, btnIndex, 1);
  4681. } // Cycle to the prev button
  4682. else {
  4683. setFocus(innerParams, btnIndex, -1);
  4684. }
  4685.  
  4686. e.stopPropagation();
  4687. e.preventDefault();
  4688. };
  4689.  
  4690. const handleArrows = key => {
  4691. const confirmButton = getConfirmButton();
  4692. const denyButton = getDenyButton();
  4693. const cancelButton = getCancelButton();
  4694.  
  4695. if (![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
  4696. return;
  4697. }
  4698.  
  4699. const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
  4700. let buttonToFocus = document.activeElement;
  4701.  
  4702. for (let i = 0; i < getActions().children.length; i++) {
  4703. buttonToFocus = buttonToFocus[sibling];
  4704.  
  4705. if (!buttonToFocus) {
  4706. return;
  4707. }
  4708.  
  4709. if (isVisible(buttonToFocus) && buttonToFocus instanceof HTMLButtonElement) {
  4710. break;
  4711. }
  4712. }
  4713.  
  4714. if (buttonToFocus instanceof HTMLButtonElement) {
  4715. buttonToFocus.focus();
  4716. }
  4717. };
  4718.  
  4719. const handleEsc = (e, innerParams, dismissWith) => {
  4720. if (callIfFunction(innerParams.allowEscapeKey)) {
  4721. e.preventDefault();
  4722. dismissWith(DismissReason.esc);
  4723. }
  4724. };
  4725.  
  4726. /*
  4727. * Instance method to close sweetAlert
  4728. */
  4729.  
  4730. function removePopupAndResetState(instance, container, returnFocus, didClose) {
  4731. if (isToast()) {
  4732. triggerDidCloseAndDispose(instance, didClose);
  4733. } else {
  4734. restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
  4735. removeKeydownHandler(globalState);
  4736. }
  4737.  
  4738. const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // workaround for #2088
  4739. // for some reason removing the container in Safari will scroll the document to bottom
  4740.  
  4741. if (isSafari) {
  4742. container.setAttribute('style', 'display:none !important');
  4743. container.removeAttribute('class');
  4744. container.innerHTML = '';
  4745. } else {
  4746. container.remove();
  4747. }
  4748.  
  4749. if (isModal()) {
  4750. undoScrollbar();
  4751. undoIOSfix();
  4752. unsetAriaHidden();
  4753. }
  4754.  
  4755. removeBodyClasses();
  4756. }
  4757.  
  4758. function removeBodyClasses() {
  4759. removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
  4760. }
  4761.  
  4762. function close(resolveValue) {
  4763. resolveValue = prepareResolveValue(resolveValue);
  4764. const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
  4765. const didClose = triggerClosePopup(this);
  4766.  
  4767. if (this.isAwaitingPromise()) {
  4768. // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
  4769. if (!resolveValue.isDismissed) {
  4770. handleAwaitingPromise(this);
  4771. swalPromiseResolve(resolveValue);
  4772. }
  4773. } else if (didClose) {
  4774. // Resolve Swal promise
  4775. swalPromiseResolve(resolveValue);
  4776. }
  4777. }
  4778. function isAwaitingPromise() {
  4779. return !!privateProps.awaitingPromise.get(this);
  4780. }
  4781.  
  4782. const triggerClosePopup = instance => {
  4783. const popup = getPopup();
  4784.  
  4785. if (!popup) {
  4786. return false;
  4787. }
  4788.  
  4789. const innerParams = privateProps.innerParams.get(instance);
  4790.  
  4791. if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
  4792. return false;
  4793. }
  4794.  
  4795. removeClass(popup, innerParams.showClass.popup);
  4796. addClass(popup, innerParams.hideClass.popup);
  4797. const backdrop = getContainer();
  4798. removeClass(backdrop, innerParams.showClass.backdrop);
  4799. addClass(backdrop, innerParams.hideClass.backdrop);
  4800. handlePopupAnimation(instance, popup, innerParams);
  4801. return true;
  4802. };
  4803.  
  4804. function rejectPromise(error) {
  4805. const rejectPromise = privateMethods.swalPromiseReject.get(this);
  4806. handleAwaitingPromise(this);
  4807.  
  4808. if (rejectPromise) {
  4809. // Reject Swal promise
  4810. rejectPromise(error);
  4811. }
  4812. }
  4813. const handleAwaitingPromise = instance => {
  4814. if (instance.isAwaitingPromise()) {
  4815. privateProps.awaitingPromise.delete(instance); // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
  4816.  
  4817. if (!privateProps.innerParams.get(instance)) {
  4818. instance._destroy();
  4819. }
  4820. }
  4821. };
  4822.  
  4823. const prepareResolveValue = resolveValue => {
  4824. // When user calls Swal.close()
  4825. if (typeof resolveValue === 'undefined') {
  4826. return {
  4827. isConfirmed: false,
  4828. isDenied: false,
  4829. isDismissed: true
  4830. };
  4831. }
  4832.  
  4833. return Object.assign({
  4834. isConfirmed: false,
  4835. isDenied: false,
  4836. isDismissed: false
  4837. }, resolveValue);
  4838. };
  4839.  
  4840. const handlePopupAnimation = (instance, popup, innerParams) => {
  4841. const container = getContainer(); // If animation is supported, animate
  4842.  
  4843. const animationIsSupported = animationEndEvent && hasCssAnimation(popup);
  4844.  
  4845. if (typeof innerParams.willClose === 'function') {
  4846. innerParams.willClose(popup);
  4847. }
  4848.  
  4849. if (animationIsSupported) {
  4850. animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
  4851. } else {
  4852. // Otherwise, remove immediately
  4853. removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
  4854. }
  4855. };
  4856.  
  4857. const animatePopup = (instance, popup, container, returnFocus, didClose) => {
  4858. globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
  4859. popup.addEventListener(animationEndEvent, function (e) {
  4860. if (e.target === popup) {
  4861. globalState.swalCloseEventFinishedCallback();
  4862. delete globalState.swalCloseEventFinishedCallback;
  4863. }
  4864. });
  4865. };
  4866.  
  4867. const triggerDidCloseAndDispose = (instance, didClose) => {
  4868. setTimeout(() => {
  4869. if (typeof didClose === 'function') {
  4870. didClose.bind(instance.params)();
  4871. }
  4872.  
  4873. instance._destroy();
  4874. });
  4875. };
  4876.  
  4877. function setButtonsDisabled(instance, buttons, disabled) {
  4878. const domCache = privateProps.domCache.get(instance);
  4879. buttons.forEach(button => {
  4880. domCache[button].disabled = disabled;
  4881. });
  4882. }
  4883.  
  4884. function setInputDisabled(input, disabled) {
  4885. if (!input) {
  4886. return false;
  4887. }
  4888.  
  4889. if (input.type === 'radio') {
  4890. const radiosContainer = input.parentNode.parentNode;
  4891. const radios = radiosContainer.querySelectorAll('input');
  4892.  
  4893. for (let i = 0; i < radios.length; i++) {
  4894. radios[i].disabled = disabled;
  4895. }
  4896. } else {
  4897. input.disabled = disabled;
  4898. }
  4899. }
  4900.  
  4901. function enableButtons() {
  4902. setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
  4903. }
  4904. function disableButtons() {
  4905. setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
  4906. }
  4907. function enableInput() {
  4908. return setInputDisabled(this.getInput(), false);
  4909. }
  4910. function disableInput() {
  4911. return setInputDisabled(this.getInput(), true);
  4912. }
  4913.  
  4914. function showValidationMessage(error) {
  4915. const domCache = privateProps.domCache.get(this);
  4916. const params = privateProps.innerParams.get(this);
  4917. setInnerHtml(domCache.validationMessage, error);
  4918. domCache.validationMessage.className = swalClasses['validation-message'];
  4919.  
  4920. if (params.customClass && params.customClass.validationMessage) {
  4921. addClass(domCache.validationMessage, params.customClass.validationMessage);
  4922. }
  4923.  
  4924. show(domCache.validationMessage);
  4925. const input = this.getInput();
  4926.  
  4927. if (input) {
  4928. input.setAttribute('aria-invalid', true);
  4929. input.setAttribute('aria-describedby', swalClasses['validation-message']);
  4930. focusInput(input);
  4931. addClass(input, swalClasses.inputerror);
  4932. }
  4933. } // Hide block with validation message
  4934.  
  4935. function resetValidationMessage$1() {
  4936. const domCache = privateProps.domCache.get(this);
  4937.  
  4938. if (domCache.validationMessage) {
  4939. hide(domCache.validationMessage);
  4940. }
  4941.  
  4942. const input = this.getInput();
  4943.  
  4944. if (input) {
  4945. input.removeAttribute('aria-invalid');
  4946. input.removeAttribute('aria-describedby');
  4947. removeClass(input, swalClasses.inputerror);
  4948. }
  4949. }
  4950.  
  4951. function getProgressSteps$1() {
  4952. const domCache = privateProps.domCache.get(this);
  4953. return domCache.progressSteps;
  4954. }
  4955.  
  4956. /**
  4957. * Updates popup parameters.
  4958. */
  4959.  
  4960. function update(params) {
  4961. const popup = getPopup();
  4962. const innerParams = privateProps.innerParams.get(this);
  4963.  
  4964. if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
  4965. return 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.");
  4966. }
  4967.  
  4968. const validUpdatableParams = filterValidParams(params);
  4969. const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
  4970. render(this, updatedParams);
  4971. privateProps.innerParams.set(this, updatedParams);
  4972. Object.defineProperties(this, {
  4973. params: {
  4974. value: Object.assign({}, this.params, params),
  4975. writable: false,
  4976. enumerable: true
  4977. }
  4978. });
  4979. }
  4980.  
  4981. const filterValidParams = params => {
  4982. const validUpdatableParams = {};
  4983. Object.keys(params).forEach(param => {
  4984. if (isUpdatableParameter(param)) {
  4985. validUpdatableParams[param] = params[param];
  4986. } else {
  4987. warn("Invalid parameter to update: \"".concat(param, "\". Updatable params are listed here: https://github.com/sweetalert2/sweetalert2/blob/master/src/utils/params.js\n\nIf you think this parameter should be updatable, request it here: https://github.com/sweetalert2/sweetalert2/issues/new?template=02_feature_request.md"));
  4988. }
  4989. });
  4990. return validUpdatableParams;
  4991. };
  4992.  
  4993. function _destroy() {
  4994. const domCache = privateProps.domCache.get(this);
  4995. const innerParams = privateProps.innerParams.get(this);
  4996.  
  4997. if (!innerParams) {
  4998. disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
  4999.  
  5000. return; // This instance has already been destroyed
  5001. } // Check if there is another Swal closing
  5002.  
  5003.  
  5004. if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
  5005. globalState.swalCloseEventFinishedCallback();
  5006. delete globalState.swalCloseEventFinishedCallback;
  5007. } // Check if there is a swal disposal defer timer
  5008.  
  5009.  
  5010. if (globalState.deferDisposalTimer) {
  5011. clearTimeout(globalState.deferDisposalTimer);
  5012. delete globalState.deferDisposalTimer;
  5013. }
  5014.  
  5015. if (typeof innerParams.didDestroy === 'function') {
  5016. innerParams.didDestroy();
  5017. }
  5018.  
  5019. disposeSwal(this);
  5020. }
  5021.  
  5022. const disposeSwal = instance => {
  5023. disposeWeakMaps(instance); // Unset this.params so GC will dispose it (#1569)
  5024.  
  5025. delete instance.params; // Unset globalState props so GC will dispose globalState (#1569)
  5026.  
  5027. delete globalState.keydownHandler;
  5028. delete globalState.keydownTarget; // Unset currentInstance
  5029.  
  5030. delete globalState.currentInstance;
  5031. };
  5032.  
  5033. const disposeWeakMaps = instance => {
  5034. // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
  5035. if (instance.isAwaitingPromise()) {
  5036. unsetWeakMaps(privateProps, instance);
  5037. privateProps.awaitingPromise.set(instance, true);
  5038. } else {
  5039. unsetWeakMaps(privateMethods, instance);
  5040. unsetWeakMaps(privateProps, instance);
  5041. }
  5042. };
  5043.  
  5044. const unsetWeakMaps = (obj, instance) => {
  5045. for (const i in obj) {
  5046. obj[i].delete(instance);
  5047. }
  5048. };
  5049.  
  5050.  
  5051.  
  5052. var instanceMethods = /*#__PURE__*/Object.freeze({
  5053. hideLoading: hideLoading,
  5054. disableLoading: hideLoading,
  5055. getInput: getInput$1,
  5056. close: close,
  5057. isAwaitingPromise: isAwaitingPromise,
  5058. rejectPromise: rejectPromise,
  5059. handleAwaitingPromise: handleAwaitingPromise,
  5060. closePopup: close,
  5061. closeModal: close,
  5062. closeToast: close,
  5063. enableButtons: enableButtons,
  5064. disableButtons: disableButtons,
  5065. enableInput: enableInput,
  5066. disableInput: disableInput,
  5067. showValidationMessage: showValidationMessage,
  5068. resetValidationMessage: resetValidationMessage$1,
  5069. getProgressSteps: getProgressSteps$1,
  5070. update: update,
  5071. _destroy: _destroy
  5072. });
  5073.  
  5074. const handleConfirmButtonClick = instance => {
  5075. const innerParams = privateProps.innerParams.get(instance);
  5076. instance.disableButtons();
  5077.  
  5078. if (innerParams.input) {
  5079. handleConfirmOrDenyWithInput(instance, 'confirm');
  5080. } else {
  5081. confirm(instance, true);
  5082. }
  5083. };
  5084. const handleDenyButtonClick = instance => {
  5085. const innerParams = privateProps.innerParams.get(instance);
  5086. instance.disableButtons();
  5087.  
  5088. if (innerParams.returnInputValueOnDeny) {
  5089. handleConfirmOrDenyWithInput(instance, 'deny');
  5090. } else {
  5091. deny(instance, false);
  5092. }
  5093. };
  5094. const handleCancelButtonClick = (instance, dismissWith) => {
  5095. instance.disableButtons();
  5096. dismissWith(DismissReason.cancel);
  5097. };
  5098.  
  5099. const handleConfirmOrDenyWithInput = (instance, type
  5100. /* 'confirm' | 'deny' */
  5101. ) => {
  5102. const innerParams = privateProps.innerParams.get(instance);
  5103.  
  5104. if (!innerParams.input) {
  5105. return error("The \"input\" parameter is needed to be set when using returnInputValueOn".concat(capitalizeFirstLetter(type)));
  5106. }
  5107.  
  5108. const inputValue = getInputValue(instance, innerParams);
  5109.  
  5110. if (innerParams.inputValidator) {
  5111. handleInputValidator(instance, inputValue, type);
  5112. } else if (!instance.getInput().checkValidity()) {
  5113. instance.enableButtons();
  5114. instance.showValidationMessage(innerParams.validationMessage);
  5115. } else if (type === 'deny') {
  5116. deny(instance, inputValue);
  5117. } else {
  5118. confirm(instance, inputValue);
  5119. }
  5120. };
  5121.  
  5122. const handleInputValidator = (instance, inputValue, type
  5123. /* 'confirm' | 'deny' */
  5124. ) => {
  5125. const innerParams = privateProps.innerParams.get(instance);
  5126. instance.disableInput();
  5127. const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
  5128. validationPromise.then(validationMessage => {
  5129. instance.enableButtons();
  5130. instance.enableInput();
  5131.  
  5132. if (validationMessage) {
  5133. instance.showValidationMessage(validationMessage);
  5134. } else if (type === 'deny') {
  5135. deny(instance, inputValue);
  5136. } else {
  5137. confirm(instance, inputValue);
  5138. }
  5139. });
  5140. };
  5141.  
  5142. const deny = (instance, value) => {
  5143. const innerParams = privateProps.innerParams.get(instance || undefined);
  5144.  
  5145. if (innerParams.showLoaderOnDeny) {
  5146. showLoading(getDenyButton());
  5147. }
  5148.  
  5149. if (innerParams.preDeny) {
  5150. privateProps.awaitingPromise.set(instance || undefined, true); // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
  5151.  
  5152. const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
  5153. preDenyPromise.then(preDenyValue => {
  5154. if (preDenyValue === false) {
  5155. instance.hideLoading();
  5156. handleAwaitingPromise(instance);
  5157. } else {
  5158. instance.closePopup({
  5159. isDenied: true,
  5160. value: typeof preDenyValue === 'undefined' ? value : preDenyValue
  5161. });
  5162. }
  5163. }).catch(error$$1 => rejectWith(instance || undefined, error$$1));
  5164. } else {
  5165. instance.closePopup({
  5166. isDenied: true,
  5167. value
  5168. });
  5169. }
  5170. };
  5171.  
  5172. const succeedWith = (instance, value) => {
  5173. instance.closePopup({
  5174. isConfirmed: true,
  5175. value
  5176. });
  5177. };
  5178.  
  5179. const rejectWith = (instance, error$$1) => {
  5180. instance.rejectPromise(error$$1);
  5181. };
  5182.  
  5183. const confirm = (instance, value) => {
  5184. const innerParams = privateProps.innerParams.get(instance || undefined);
  5185.  
  5186. if (innerParams.showLoaderOnConfirm) {
  5187. showLoading();
  5188. }
  5189.  
  5190. if (innerParams.preConfirm) {
  5191. instance.resetValidationMessage();
  5192. privateProps.awaitingPromise.set(instance || undefined, true); // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
  5193.  
  5194. const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
  5195. preConfirmPromise.then(preConfirmValue => {
  5196. if (isVisible(getValidationMessage()) || preConfirmValue === false) {
  5197. instance.hideLoading();
  5198. handleAwaitingPromise(instance);
  5199. } else {
  5200. succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
  5201. }
  5202. }).catch(error$$1 => rejectWith(instance || undefined, error$$1));
  5203. } else {
  5204. succeedWith(instance, value);
  5205. }
  5206. };
  5207.  
  5208. const handlePopupClick = (instance, domCache, dismissWith) => {
  5209. const innerParams = privateProps.innerParams.get(instance);
  5210.  
  5211. if (innerParams.toast) {
  5212. handleToastClick(instance, domCache, dismissWith);
  5213. } else {
  5214. // Ignore click events that had mousedown on the popup but mouseup on the container
  5215. // This can happen when the user drags a slider
  5216. handleModalMousedown(domCache); // Ignore click events that had mousedown on the container but mouseup on the popup
  5217.  
  5218. handleContainerMousedown(domCache);
  5219. handleModalClick(instance, domCache, dismissWith);
  5220. }
  5221. };
  5222.  
  5223. const handleToastClick = (instance, domCache, dismissWith) => {
  5224. // Closing toast by internal click
  5225. domCache.popup.onclick = () => {
  5226. const innerParams = privateProps.innerParams.get(instance);
  5227.  
  5228. if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
  5229. return;
  5230. }
  5231.  
  5232. dismissWith(DismissReason.close);
  5233. };
  5234. };
  5235. /**
  5236. * @param {*} innerParams
  5237. * @returns {boolean}
  5238. */
  5239.  
  5240.  
  5241. const isAnyButtonShown = innerParams => {
  5242. return innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton;
  5243. };
  5244.  
  5245. let ignoreOutsideClick = false;
  5246.  
  5247. const handleModalMousedown = domCache => {
  5248. domCache.popup.onmousedown = () => {
  5249. domCache.container.onmouseup = function (e) {
  5250. domCache.container.onmouseup = undefined; // We only check if the mouseup target is the container because usually it doesn't
  5251. // have any other direct children aside of the popup
  5252.  
  5253. if (e.target === domCache.container) {
  5254. ignoreOutsideClick = true;
  5255. }
  5256. };
  5257. };
  5258. };
  5259.  
  5260. const handleContainerMousedown = domCache => {
  5261. domCache.container.onmousedown = () => {
  5262. domCache.popup.onmouseup = function (e) {
  5263. domCache.popup.onmouseup = undefined; // We also need to check if the mouseup target is a child of the popup
  5264.  
  5265. if (e.target === domCache.popup || domCache.popup.contains(e.target)) {
  5266. ignoreOutsideClick = true;
  5267. }
  5268. };
  5269. };
  5270. };
  5271.  
  5272. const handleModalClick = (instance, domCache, dismissWith) => {
  5273. domCache.container.onclick = e => {
  5274. const innerParams = privateProps.innerParams.get(instance);
  5275.  
  5276. if (ignoreOutsideClick) {
  5277. ignoreOutsideClick = false;
  5278. return;
  5279. }
  5280.  
  5281. if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
  5282. dismissWith(DismissReason.backdrop);
  5283. }
  5284. };
  5285. };
  5286.  
  5287. const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
  5288.  
  5289. const isElement = elem => elem instanceof Element || isJqueryElement(elem);
  5290.  
  5291. const argsToParams = args => {
  5292. const params = {};
  5293.  
  5294. if (typeof args[0] === 'object' && !isElement(args[0])) {
  5295. Object.assign(params, args[0]);
  5296. } else {
  5297. ['title', 'html', 'icon'].forEach((name, index) => {
  5298. const arg = args[index];
  5299.  
  5300. if (typeof arg === 'string' || isElement(arg)) {
  5301. params[name] = arg;
  5302. } else if (arg !== undefined) {
  5303. error("Unexpected type of ".concat(name, "! Expected \"string\" or \"Element\", got ").concat(typeof arg));
  5304. }
  5305. });
  5306. }
  5307.  
  5308. return params;
  5309. };
  5310.  
  5311. function fire() {
  5312. const Swal = this; // eslint-disable-line @typescript-eslint/no-this-alias
  5313.  
  5314. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5315. args[_key] = arguments[_key];
  5316. }
  5317.  
  5318. return new Swal(...args);
  5319. }
  5320.  
  5321. /**
  5322. * Returns an extended version of `Swal` containing `params` as defaults.
  5323. * Useful for reusing Swal configuration.
  5324. *
  5325. * For example:
  5326. *
  5327. * Before:
  5328. * const textPromptOptions = { input: 'text', showCancelButton: true }
  5329. * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
  5330. * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
  5331. *
  5332. * After:
  5333. * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
  5334. * const {value: firstName} = await TextPrompt('What is your first name?')
  5335. * const {value: lastName} = await TextPrompt('What is your last name?')
  5336. *
  5337. * @param mixinParams
  5338. */
  5339. function mixin(mixinParams) {
  5340. class MixinSwal extends this {
  5341. _main(params, priorityMixinParams) {
  5342. return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
  5343. }
  5344.  
  5345. }
  5346.  
  5347. return MixinSwal;
  5348. }
  5349.  
  5350. /**
  5351. * If `timer` parameter is set, returns number of milliseconds of timer remained.
  5352. * Otherwise, returns undefined.
  5353. */
  5354.  
  5355. const getTimerLeft = () => {
  5356. return globalState.timeout && globalState.timeout.getTimerLeft();
  5357. };
  5358. /**
  5359. * Stop timer. Returns number of milliseconds of timer remained.
  5360. * If `timer` parameter isn't set, returns undefined.
  5361. */
  5362.  
  5363. const stopTimer = () => {
  5364. if (globalState.timeout) {
  5365. stopTimerProgressBar();
  5366. return globalState.timeout.stop();
  5367. }
  5368. };
  5369. /**
  5370. * Resume timer. Returns number of milliseconds of timer remained.
  5371. * If `timer` parameter isn't set, returns undefined.
  5372. */
  5373.  
  5374. const resumeTimer = () => {
  5375. if (globalState.timeout) {
  5376. const remaining = globalState.timeout.start();
  5377. animateTimerProgressBar(remaining);
  5378. return remaining;
  5379. }
  5380. };
  5381. /**
  5382. * Resume timer. Returns number of milliseconds of timer remained.
  5383. * If `timer` parameter isn't set, returns undefined.
  5384. */
  5385.  
  5386. const toggleTimer = () => {
  5387. const timer = globalState.timeout;
  5388. return timer && (timer.running ? stopTimer() : resumeTimer());
  5389. };
  5390. /**
  5391. * Increase timer. Returns number of milliseconds of an updated timer.
  5392. * If `timer` parameter isn't set, returns undefined.
  5393. */
  5394.  
  5395. const increaseTimer = n => {
  5396. if (globalState.timeout) {
  5397. const remaining = globalState.timeout.increase(n);
  5398. animateTimerProgressBar(remaining, true);
  5399. return remaining;
  5400. }
  5401. };
  5402. /**
  5403. * Check if timer is running. Returns true if timer is running
  5404. * or false if timer is paused or stopped.
  5405. * If `timer` parameter isn't set, returns undefined
  5406. */
  5407.  
  5408. const isTimerRunning = () => {
  5409. return globalState.timeout && globalState.timeout.isRunning();
  5410. };
  5411.  
  5412. let bodyClickListenerAdded = false;
  5413. const clickHandlers = {};
  5414. function bindClickHandler() {
  5415. let attr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'data-swal-template';
  5416. clickHandlers[attr] = this;
  5417.  
  5418. if (!bodyClickListenerAdded) {
  5419. document.body.addEventListener('click', bodyClickListener);
  5420. bodyClickListenerAdded = true;
  5421. }
  5422. }
  5423.  
  5424. const bodyClickListener = event => {
  5425. for (let el = event.target; el && el !== document; el = el.parentNode) {
  5426. for (const attr in clickHandlers) {
  5427. const template = el.getAttribute(attr);
  5428.  
  5429. if (template) {
  5430. clickHandlers[attr].fire({
  5431. template
  5432. });
  5433. return;
  5434. }
  5435. }
  5436. }
  5437. };
  5438.  
  5439.  
  5440.  
  5441. var staticMethods = /*#__PURE__*/Object.freeze({
  5442. isValidParameter: isValidParameter,
  5443. isUpdatableParameter: isUpdatableParameter,
  5444. isDeprecatedParameter: isDeprecatedParameter,
  5445. argsToParams: argsToParams,
  5446. isVisible: isVisible$1,
  5447. clickConfirm: clickConfirm,
  5448. clickDeny: clickDeny,
  5449. clickCancel: clickCancel,
  5450. getContainer: getContainer,
  5451. getPopup: getPopup,
  5452. getTitle: getTitle,
  5453. getHtmlContainer: getHtmlContainer,
  5454. getImage: getImage,
  5455. getIcon: getIcon,
  5456. getInputLabel: getInputLabel,
  5457. getCloseButton: getCloseButton,
  5458. getActions: getActions,
  5459. getConfirmButton: getConfirmButton,
  5460. getDenyButton: getDenyButton,
  5461. getCancelButton: getCancelButton,
  5462. getLoader: getLoader,
  5463. getFooter: getFooter,
  5464. getTimerProgressBar: getTimerProgressBar,
  5465. getFocusableElements: getFocusableElements,
  5466. getValidationMessage: getValidationMessage,
  5467. isLoading: isLoading,
  5468. fire: fire,
  5469. mixin: mixin,
  5470. showLoading: showLoading,
  5471. enableLoading: showLoading,
  5472. getTimerLeft: getTimerLeft,
  5473. stopTimer: stopTimer,
  5474. resumeTimer: resumeTimer,
  5475. toggleTimer: toggleTimer,
  5476. increaseTimer: increaseTimer,
  5477. isTimerRunning: isTimerRunning,
  5478. bindClickHandler: bindClickHandler
  5479. });
  5480.  
  5481. let currentInstance;
  5482.  
  5483. class SweetAlert {
  5484. constructor() {
  5485. // Prevent run in Node env
  5486. if (typeof window === 'undefined') {
  5487. return;
  5488. }
  5489.  
  5490. currentInstance = this; // @ts-ignore
  5491.  
  5492. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5493. args[_key] = arguments[_key];
  5494. }
  5495.  
  5496. const outerParams = Object.freeze(this.constructor.argsToParams(args));
  5497. Object.defineProperties(this, {
  5498. params: {
  5499. value: outerParams,
  5500. writable: false,
  5501. enumerable: true,
  5502. configurable: true
  5503. }
  5504. }); // @ts-ignore
  5505.  
  5506. const promise = this._main(this.params);
  5507.  
  5508. privateProps.promise.set(this, promise);
  5509. }
  5510.  
  5511. _main(userParams) {
  5512. let mixinParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5513. showWarningsForParams(Object.assign({}, mixinParams, userParams));
  5514.  
  5515. if (globalState.currentInstance) {
  5516. globalState.currentInstance._destroy();
  5517.  
  5518. if (isModal()) {
  5519. unsetAriaHidden();
  5520. }
  5521. }
  5522.  
  5523. globalState.currentInstance = this;
  5524. const innerParams = prepareParams(userParams, mixinParams);
  5525. setParameters(innerParams);
  5526. Object.freeze(innerParams); // clear the previous timer
  5527.  
  5528. if (globalState.timeout) {
  5529. globalState.timeout.stop();
  5530. delete globalState.timeout;
  5531. } // clear the restore focus timeout
  5532.  
  5533.  
  5534. clearTimeout(globalState.restoreFocusTimeout);
  5535. const domCache = populateDomCache(this);
  5536. render(this, innerParams);
  5537. privateProps.innerParams.set(this, innerParams);
  5538. return swalPromise(this, domCache, innerParams);
  5539. } // `catch` cannot be the name of a module export, so we define our thenable methods here instead
  5540.  
  5541.  
  5542. then(onFulfilled) {
  5543. const promise = privateProps.promise.get(this);
  5544. return promise.then(onFulfilled);
  5545. }
  5546.  
  5547. finally(onFinally) {
  5548. const promise = privateProps.promise.get(this);
  5549. return promise.finally(onFinally);
  5550. }
  5551.  
  5552. }
  5553.  
  5554. const swalPromise = (instance, domCache, innerParams) => {
  5555. return new Promise((resolve, reject) => {
  5556. // functions to handle all closings/dismissals
  5557. const dismissWith = dismiss => {
  5558. instance.closePopup({
  5559. isDismissed: true,
  5560. dismiss
  5561. });
  5562. };
  5563.  
  5564. privateMethods.swalPromiseResolve.set(instance, resolve);
  5565. privateMethods.swalPromiseReject.set(instance, reject);
  5566.  
  5567. domCache.confirmButton.onclick = () => handleConfirmButtonClick(instance);
  5568.  
  5569. domCache.denyButton.onclick = () => handleDenyButtonClick(instance);
  5570.  
  5571. domCache.cancelButton.onclick = () => handleCancelButtonClick(instance, dismissWith);
  5572.  
  5573. domCache.closeButton.onclick = () => dismissWith(DismissReason.close);
  5574.  
  5575. handlePopupClick(instance, domCache, dismissWith);
  5576. addKeydownHandler(instance, globalState, innerParams, dismissWith);
  5577. handleInputOptionsAndValue(instance, innerParams);
  5578. openPopup(innerParams);
  5579. setupTimer(globalState, innerParams, dismissWith);
  5580. initFocus(domCache, innerParams); // Scroll container to top on open (#1247, #1946)
  5581.  
  5582. setTimeout(() => {
  5583. domCache.container.scrollTop = 0;
  5584. });
  5585. });
  5586. };
  5587.  
  5588. const prepareParams = (userParams, mixinParams) => {
  5589. const templateParams = getTemplateParams(userParams);
  5590. const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
  5591.  
  5592. params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
  5593. params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
  5594. return params;
  5595. };
  5596.  
  5597. const populateDomCache = instance => {
  5598. const domCache = {
  5599. popup: getPopup(),
  5600. container: getContainer(),
  5601. actions: getActions(),
  5602. confirmButton: getConfirmButton(),
  5603. denyButton: getDenyButton(),
  5604. cancelButton: getCancelButton(),
  5605. loader: getLoader(),
  5606. closeButton: getCloseButton(),
  5607. validationMessage: getValidationMessage(),
  5608. progressSteps: getProgressSteps()
  5609. };
  5610. privateProps.domCache.set(instance, domCache);
  5611. return domCache;
  5612. };
  5613.  
  5614. const setupTimer = (globalState$$1, innerParams, dismissWith) => {
  5615. const timerProgressBar = getTimerProgressBar();
  5616. hide(timerProgressBar);
  5617.  
  5618. if (innerParams.timer) {
  5619. globalState$$1.timeout = new Timer(() => {
  5620. dismissWith('timer');
  5621. delete globalState$$1.timeout;
  5622. }, innerParams.timer);
  5623.  
  5624. if (innerParams.timerProgressBar) {
  5625. show(timerProgressBar);
  5626. applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
  5627. setTimeout(() => {
  5628. if (globalState$$1.timeout && globalState$$1.timeout.running) {
  5629. // timer can be already stopped or unset at this point
  5630. animateTimerProgressBar(innerParams.timer);
  5631. }
  5632. });
  5633. }
  5634. }
  5635. };
  5636.  
  5637. const initFocus = (domCache, innerParams) => {
  5638. if (innerParams.toast) {
  5639. return;
  5640. }
  5641.  
  5642. if (!callIfFunction(innerParams.allowEnterKey)) {
  5643. return blurActiveElement();
  5644. }
  5645.  
  5646. if (!focusButton(domCache, innerParams)) {
  5647. setFocus(innerParams, -1, 1);
  5648. }
  5649. };
  5650.  
  5651. const focusButton = (domCache, innerParams) => {
  5652. if (innerParams.focusDeny && isVisible(domCache.denyButton)) {
  5653. domCache.denyButton.focus();
  5654. return true;
  5655. }
  5656.  
  5657. if (innerParams.focusCancel && isVisible(domCache.cancelButton)) {
  5658. domCache.cancelButton.focus();
  5659. return true;
  5660. }
  5661.  
  5662. if (innerParams.focusConfirm && isVisible(domCache.confirmButton)) {
  5663. domCache.confirmButton.focus();
  5664. return true;
  5665. }
  5666.  
  5667. return false;
  5668. };
  5669.  
  5670. const blurActiveElement = () => {
  5671. if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
  5672. document.activeElement.blur();
  5673. }
  5674. }; // Assign instance methods from src/instanceMethods/*.js to prototype
  5675.  
  5676.  
  5677. Object.assign(SweetAlert.prototype, instanceMethods); // Assign static methods from src/staticMethods/*.js to constructor
  5678.  
  5679. Object.assign(SweetAlert, staticMethods); // Proxy to instance methods to constructor, for now, for backwards compatibility
  5680.  
  5681. Object.keys(instanceMethods).forEach(key => {
  5682. SweetAlert[key] = function () {
  5683. if (currentInstance) {
  5684. return currentInstance[key](...arguments);
  5685. }
  5686. };
  5687. });
  5688. SweetAlert.DismissReason = DismissReason;
  5689. SweetAlert.version = '11.4.8';
  5690.  
  5691. const Swal = SweetAlert; // @ts-ignore
  5692.  
  5693. Swal.default = Swal;
  5694.  
  5695. return Swal;
  5696.  
  5697. }));
  5698. if (typeof this !== 'undefined' && this.Sweetalert2){ this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
  5699.  
  5700. "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,".swal2-popup.swal2-toast{box-sizing:border-box;grid-column:1/4!important;grid-row:1/4!important;grid-template-columns:1fr 99fr 1fr;padding:1em;overflow-y:hidden;background:#fff;box-shadow:0 0 1px rgba(0,0,0,.075),0 1px 2px rgba(0,0,0,.075),1px 2px 4px rgba(0,0,0,.075),1px 3px 8px rgba(0,0,0,.075),2px 4px 16px rgba(0,0,0,.075);pointer-events:all}.swal2-popup.swal2-toast>*{grid-column:2}.swal2-popup.swal2-toast .swal2-title{margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-loading{justify-content:center}.swal2-popup.swal2-toast .swal2-input{height:2em;margin:.5em;font-size:1em}.swal2-popup.swal2-toast .swal2-validation-message{font-size:1em}.swal2-popup.swal2-toast .swal2-footer{margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-popup.swal2-toast .swal2-close{grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-popup.swal2-toast .swal2-html-container{margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-popup.swal2-toast .swal2-html-container:empty{padding:0}.swal2-popup.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-popup.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-popup.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:700}.swal2-popup.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-popup.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-popup.swal2-toast .swal2-actions{justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-popup.swal2-toast .swal2-styled{margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-popup.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;transform:rotate(45deg);border-radius:50%}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.8em;left:-.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-popup.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-popup.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-popup.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{-webkit-animation:swal2-toast-animate-success-line-tip .75s;animation:swal2-toast-animate-success-line-tip .75s}.swal2-popup.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{-webkit-animation:swal2-toast-animate-success-line-long .75s;animation:swal2-toast-animate-success-line-long .75s}.swal2-popup.swal2-toast.swal2-show{-webkit-animation:swal2-toast-show .5s;animation:swal2-toast-show .5s}.swal2-popup.swal2-toast.swal2-hide{-webkit-animation:swal2-toast-hide .1s forwards;animation:swal2-toast-hide .1s forwards}.swal2-container{display:grid;position:fixed;z-index:1060;top:0;right:0;bottom:0;left: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(-webkit-min-content,auto) minmax(-webkit-min-content,auto) minmax(-webkit-min-content,auto);grid-template-rows:minmax(min-content,auto) minmax(min-content,auto) minmax(min-content,auto);height:100%;padding:.625em;overflow-x:hidden;transition:background-color .1s;-webkit-overflow-scrolling:touch}.swal2-container.swal2-backdrop-show,.swal2-container.swal2-noanimation{background:rgba(0,0,0,.4)}.swal2-container.swal2-backdrop-hide{background:0 0!important}.swal2-container.swal2-bottom-start,.swal2-container.swal2-center-start,.swal2-container.swal2-top-start{grid-template-columns:minmax(0,1fr) auto auto}.swal2-container.swal2-bottom,.swal2-container.swal2-center,.swal2-container.swal2-top{grid-template-columns:auto minmax(0,1fr) auto}.swal2-container.swal2-bottom-end,.swal2-container.swal2-center-end,.swal2-container.swal2-top-end{grid-template-columns:auto auto minmax(0,1fr)}.swal2-container.swal2-top-start>.swal2-popup{align-self:start}.swal2-container.swal2-top>.swal2-popup{grid-column:2;align-self:start;justify-self:center}.swal2-container.swal2-top-end>.swal2-popup,.swal2-container.swal2-top-right>.swal2-popup{grid-column:3;align-self:start;justify-self:end}.swal2-container.swal2-center-left>.swal2-popup,.swal2-container.swal2-center-start>.swal2-popup{grid-row:2;align-self:center}.swal2-container.swal2-center>.swal2-popup{grid-column:2;grid-row:2;align-self:center;justify-self:center}.swal2-container.swal2-center-end>.swal2-popup,.swal2-container.swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;align-self:center;justify-self:end}.swal2-container.swal2-bottom-left>.swal2-popup,.swal2-container.swal2-bottom-start>.swal2-popup{grid-column:1;grid-row:3;align-self:end}.swal2-container.swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;justify-self:center;align-self:end}.swal2-container.swal2-bottom-end>.swal2-popup,.swal2-container.swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;align-self:end;justify-self:end}.swal2-container.swal2-grow-fullscreen>.swal2-popup,.swal2-container.swal2-grow-row>.swal2-popup{grid-column:1/4;width:100%}.swal2-container.swal2-grow-column>.swal2-popup,.swal2-container.swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}.swal2-container.swal2-no-transition{transition:none!important}.swal2-popup{display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0,100%);width:32em;max-width:100%;padding:0 0 1.25em;border:none;border-radius:5px;background:#fff;color:#545454;font-family:inherit;font-size:1rem}.swal2-popup:focus{outline:0}.swal2-popup.swal2-loading{overflow-y:hidden}.swal2-title{position:relative;max-width:100%;margin:0;padding:.8em 1em 0;color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;word-wrap:break-word}.swal2-actions{display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:center;width:auto;margin:1.25em auto 0;padding:0}.swal2-actions:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4}.swal2-actions:not(.swal2-loading) .swal2-styled:hover{background-image:linear-gradient(rgba(0,0,0,.1),rgba(0,0,0,.1))}.swal2-actions:not(.swal2-loading) .swal2-styled:active{background-image:linear-gradient(rgba(0,0,0,.2),rgba(0,0,0,.2))}.swal2-loader{display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;-webkit-animation:swal2-rotate-loading 1.5s linear 0s infinite normal;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 transparent #2778c4 transparent}.swal2-styled{margin:.3125em;padding:.625em 1.1em;transition:box-shadow .1s;box-shadow:0 0 0 3px transparent;font-weight:500}.swal2-styled:not([disabled]){cursor:pointer}.swal2-styled.swal2-confirm{border:0;border-radius:.25em;background:initial;background-color:#7066e0;color:#fff;font-size:1em}.swal2-styled.swal2-confirm:focus{box-shadow:0 0 0 3px rgba(112,102,224,.5)}.swal2-styled.swal2-deny{border:0;border-radius:.25em;background:initial;background-color:#dc3741;color:#fff;font-size:1em}.swal2-styled.swal2-deny:focus{box-shadow:0 0 0 3px rgba(220,55,65,.5)}.swal2-styled.swal2-cancel{border:0;border-radius:.25em;background:initial;background-color:#6e7881;color:#fff;font-size:1em}.swal2-styled.swal2-cancel:focus{box-shadow:0 0 0 3px rgba(110,120,129,.5)}.swal2-styled.swal2-default-outline:focus{box-shadow:0 0 0 3px rgba(100,150,200,.5)}.swal2-styled:focus{outline:0}.swal2-styled::-moz-focus-inner{border:0}.swal2-footer{justify-content:center;margin:1em 0 0;padding:1em 1em 0;border-top:1px solid #eee;color:inherit;font-size:1em}.swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto!important;overflow:hidden;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.swal2-timer-progress-bar{width:100%;height:.25em;background:rgba(0,0,0,.2)}.swal2-image{max-width:100%;margin:2em auto 1em}.swal2-close{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:color .1s,box-shadow .1s;border:none;border-radius:5px;background:0 0;color:#ccc;font-family:serif;font-family:monospace;font-size:2.5em;cursor:pointer;justify-self:end}.swal2-close:hover{transform:none;background:0 0;color:#f27474}.swal2-close:focus{outline:0;box-shadow:inset 0 0 0 3px rgba(100,150,200,.5)}.swal2-close::-moz-focus-inner{border:0}.swal2-html-container{z-index:1;justify-content:center;margin:1em 1.6em .3em;padding:0;overflow:auto;color:inherit;font-size:1.125em;font-weight:400;line-height:normal;text-align:center;word-wrap:break-word;word-break:break-word}.swal2-checkbox,.swal2-file,.swal2-input,.swal2-radio,.swal2-select,.swal2-textarea{margin:1em 2em 3px}.swal2-file,.swal2-input,.swal2-textarea{box-sizing:border-box;width:auto;transition:border-color .1s,box-shadow .1s;border:1px solid #d9d9d9;border-radius:.1875em;background:inherit;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px transparent;color:inherit;font-size:1.125em}.swal2-file.swal2-inputerror,.swal2-input.swal2-inputerror,.swal2-textarea.swal2-inputerror{border-color:#f27474!important;box-shadow:0 0 2px #f27474!important}.swal2-file:focus,.swal2-input:focus,.swal2-textarea:focus{border:1px solid #b4dbed;outline:0;box-shadow:inset 0 1px 1px rgba(0,0,0,.06),0 0 0 3px rgba(100,150,200,.5)}.swal2-file::-moz-placeholder,.swal2-input::-moz-placeholder,.swal2-textarea::-moz-placeholder{color:#ccc}.swal2-file:-ms-input-placeholder,.swal2-input:-ms-input-placeholder,.swal2-textarea:-ms-input-placeholder{color:#ccc}.swal2-file::placeholder,.swal2-input::placeholder,.swal2-textarea::placeholder{color:#ccc}.swal2-range{margin:1em 2em 3px;background:#fff}.swal2-range input{width:80%}.swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}.swal2-range input,.swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}.swal2-input{height:2.625em;padding:0 .75em}.swal2-file{width:75%;margin-right:auto;margin-left:auto;background:inherit;font-size:1.125em}.swal2-textarea{height:6.75em;padding:.75em}.swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:inherit;color:inherit;font-size:1.125em}.swal2-checkbox,.swal2-radio{align-items:center;justify-content:center;background:#fff;color:inherit}.swal2-checkbox label,.swal2-radio label{margin:0 .6em;font-size:1.125em}.swal2-checkbox input,.swal2-radio input{flex-shrink:0;margin:0 .4em}.swal2-input-label{display:flex;justify-content:center;margin:1em auto 0}.swal2-validation-message{align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:#f0f0f0;color:#666;font-size:1em;font-weight:300}.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}.swal2-icon{position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;border:.25em solid transparent;border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}.swal2-icon.swal2-error{border-color:#f27474;color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{position:relative;flex-grow:1}.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}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}.swal2-icon.swal2-error.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-error.swal2-icon-show .swal2-x-mark{-webkit-animation:swal2-animate-error-x-mark .5s;animation:swal2-animate-error-x-mark .5s}.swal2-icon.swal2-warning{border-color:#facea8;color:#f8bb86}.swal2-icon.swal2-warning.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-warning.swal2-icon-show .swal2-icon-content{-webkit-animation:swal2-animate-i-mark .5s;animation:swal2-animate-i-mark .5s}.swal2-icon.swal2-info{border-color:#9de0f6;color:#3fc3ee}.swal2-icon.swal2-info.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-info.swal2-icon-show .swal2-icon-content{-webkit-animation:swal2-animate-i-mark .8s;animation:swal2-animate-i-mark .8s}.swal2-icon.swal2-question{border-color:#c9dae1;color:#87adbd}.swal2-icon.swal2-question.swal2-icon-show{-webkit-animation:swal2-animate-error-icon .5s;animation:swal2-animate-error-icon .5s}.swal2-icon.swal2-question.swal2-icon-show .swal2-icon-content{-webkit-animation:swal2-animate-question-mark .8s;animation:swal2-animate-question-mark .8s}.swal2-icon.swal2-success{border-color:#a5dc86;color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;transform:rotate(45deg);border-radius:50%}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{top:-.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{top:-.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}.swal2-icon.swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-.25em;left:-.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}.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)}.swal2-icon.swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-tip{-webkit-animation:swal2-animate-success-line-tip .75s;animation:swal2-animate-success-line-tip .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-line-long{-webkit-animation:swal2-animate-success-line-long .75s;animation:swal2-animate-success-line-long .75s}.swal2-icon.swal2-success.swal2-icon-show .swal2-success-circular-line-right{-webkit-animation:swal2-rotate-success-circular-line 4.25s ease-in;animation:swal2-rotate-success-circular-line 4.25s ease-in}.swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:inherit;font-weight:600}.swal2-progress-steps li{display:inline-block;position:relative}.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}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:#add8e6;color:#fff}.swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:#add8e6}.swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}[class^=swal2]{-webkit-tap-highlight-color:transparent}.swal2-show{-webkit-animation:swal2-show .3s;animation:swal2-show .3s}.swal2-hide{-webkit-animation:swal2-hide .15s forwards;animation:swal2-hide .15s forwards}.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}@-webkit-keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0)}}@keyframes swal2-toast-show{0%{transform:translateY(-.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0)}}@-webkit-keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@-webkit-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:-.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-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@-webkit-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}}@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}}@-webkit-keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@keyframes swal2-show{0%{transform:scale(.7)}45%{transform:scale(1.05)}80%{transform:scale(.95)}100%{transform:scale(1)}}@-webkit-keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@keyframes swal2-hide{0%{transform:scale(1);opacity:1}100%{transform:scale(.5);opacity:0}}@-webkit-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:-.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-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@-webkit-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-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}}@-webkit-keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@-webkit-keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(.4);opacity:0}50%{margin-top:1.625em;transform:scale(.4);opacity:0}80%{margin-top:-.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@-webkit-keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0);opacity:1}}@-webkit-keyframes swal2-rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes swal2-rotate-loading{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@-webkit-keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@-webkit-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-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}}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto!important}body.swal2-no-backdrop .swal2-container{background-color:transparent!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 rgba(0,0,0,.4)}@media print{body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown){overflow-y:scroll!important}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) .swal2-container{position:static!important}}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:transparent;pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{top:0;right:auto;bottom:auto;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{top:0;right:0;bottom:auto;left:auto}body.swal2-toast-shown .swal2-container.swal2-top-left,body.swal2-toast-shown .swal2-container.swal2-top-start{top:0;right:auto;bottom:auto;left:0}body.swal2-toast-shown .swal2-container.swal2-center-left,body.swal2-toast-shown .swal2-container.swal2-center-start{top:50%;right:auto;bottom:auto;left:0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{top:50%;right:auto;bottom:auto;left:50%;transform:translate(-50%,-50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{top:50%;right:0;bottom:auto;left:auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-left,body.swal2-toast-shown .swal2-container.swal2-bottom-start{top:auto;right:auto;bottom:0;left:0}body.swal2-toast-shown .swal2-container.swal2-bottom{top:auto;right:auto;bottom:0;left:50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{top:auto;right:0;bottom:0;left:auto}");
  5701.  
  5702. /***/ }),
  5703. /* 10 */
  5704. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5705.  
  5706. "use strict";
  5707.  
  5708. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5709. exports.Hhanclub = void 0;
  5710. const index_1 = __webpack_require__(2);
  5711. const i18n_1 = __webpack_require__(4);
  5712. class Hhanclub extends index_1.NexusPHP {
  5713. constructor() {
  5714. super("hhanclub.top");
  5715. this.menu_items = [
  5716. {
  5717. "id": "bannerFold",
  5718. "type": "switch",
  5719. "display": i18n_1.I18N[this.locale].bannerFold,
  5720. "name": i18n_1.I18N[this.locale].bannerFoldName,
  5721. "value": true
  5722. },
  5723. {
  5724. "id": "bannerHide",
  5725. "type": "switch",
  5726. "display": i18n_1.I18N[this.locale].bannerHide,
  5727. "name": i18n_1.I18N[this.locale].bannerHideName,
  5728. "value": false
  5729. },
  5730. {
  5731. "id": "attendance",
  5732. "type": "switch",
  5733. "display": i18n_1.I18N[this.locale].attendance,
  5734. "name": i18n_1.I18N[this.locale].attendance,
  5735. "value": true
  5736. }
  5737. ].concat(this.menu_items);
  5738. }
  5739. onLoad() {
  5740. super.onLoad();
  5741. }
  5742. tweakBanner() {
  5743. if (this.getHostValue("bannerHide")) {
  5744. this.css += `
  5745. td.clear.nowrap img {
  5746. display: none;
  5747. }`;
  5748. }
  5749. else if (this.getHostValue("bannerFold")) {
  5750. const banner = document.querySelector("td.clear.nowrap");
  5751. const original_height = banner === null || banner === void 0 ? void 0 : banner.clientHeight;
  5752. this.css += `
  5753. td.clear.nowrap img {
  5754. height: 10px;
  5755. object-fit: cover;
  5756. overflow: hidden;
  5757. transition: height 0.5s;
  5758. }
  5759. table.head {
  5760. height: auto;
  5761. }
  5762. td.clear.nowrap img:hover {
  5763. height: ${original_height}px;
  5764. }`;
  5765. }
  5766. }
  5767. }
  5768. exports.Hhanclub = Hhanclub;
  5769.  
  5770.  
  5771. /***/ }),
  5772. /* 11 */
  5773. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5774.  
  5775. "use strict";
  5776.  
  5777. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5778. exports.KamePT = void 0;
  5779. const NexusPHP_1 = __webpack_require__(2);
  5780. const i18n_1 = __webpack_require__(4);
  5781. class KamePT extends NexusPHP_1.NexusPHP {
  5782. constructor() {
  5783. super("kamept.com");
  5784. this.menu_items = [
  5785. {
  5786. "id": "bannerHide",
  5787. "type": "switch",
  5788. "display": i18n_1.I18N[this.locale].bannerHideName,
  5789. "name": i18n_1.I18N[this.locale].bannerHideName,
  5790. "value": false
  5791. },
  5792. {
  5793. "id": "attendance",
  5794. "type": "switch",
  5795. "display": i18n_1.I18N[this.locale].attendance,
  5796. "name": i18n_1.I18N[this.locale].attendance,
  5797. "value": true
  5798. }
  5799. ].concat(this.menu_items);
  5800. }
  5801. onLoad() {
  5802. super.onLoad();
  5803. }
  5804. }
  5805. exports.KamePT = KamePT;
  5806.  
  5807.  
  5808. /***/ }),
  5809. /* 12 */
  5810. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5811.  
  5812. "use strict";
  5813.  
  5814. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5815. exports.NanyangPT = void 0;
  5816. const NexusPHP_1 = __webpack_require__(2);
  5817. const i18n_1 = __webpack_require__(4);
  5818. class NanyangPT extends NexusPHP_1.NexusPHP {
  5819. constructor() {
  5820. super("nanyangpt.com");
  5821. this.menu_items = [
  5822. {
  5823. "id": "bannerHide",
  5824. "type": "switch",
  5825. "display": i18n_1.I18N[this.locale].bannerHideName,
  5826. "name": i18n_1.I18N[this.locale].bannerHideName,
  5827. "value": false
  5828. }
  5829. ].concat(this.menu_items);
  5830. }
  5831. init() {
  5832. const url = new URL(window.location.href);
  5833. if (url.protocol == "http:") {
  5834. url.protocol = "https:";
  5835. window.location.replace(url);
  5836. }
  5837. }
  5838. onLoad() {
  5839. super.onLoad();
  5840. }
  5841. tweakBanner() {
  5842. if (this.getHostValue("bannerHide")) {
  5843. const info = document.querySelector("#info_block");
  5844. const info_height = (info === null || info === void 0 ? void 0 : info.clientHeight) ? info.clientHeight + 5 : 30;
  5845. this.css += `
  5846. table.head {
  5847. display: none;
  5848. }
  5849.  
  5850. table.mainouter {
  5851. margin-top: ${info_height}px;
  5852. }`;
  5853. }
  5854. }
  5855. }
  5856. exports.NanyangPT = NanyangPT;
  5857.  
  5858.  
  5859. /***/ }),
  5860. /* 13 */
  5861. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5862.  
  5863. "use strict";
  5864.  
  5865. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5866. exports._2xFree = void 0;
  5867. const NexusPHP_1 = __webpack_require__(2);
  5868. const i18n_1 = __webpack_require__(4);
  5869. class _2xFree extends NexusPHP_1.NexusPHP {
  5870. constructor() {
  5871. super("pt.2xfree.org");
  5872. this.menu_items = [
  5873. {
  5874. "id": "bannerHide",
  5875. "type": "switch",
  5876. "display": i18n_1.I18N[this.locale].bannerHideName,
  5877. "name": i18n_1.I18N[this.locale].bannerHideName,
  5878. "value": false
  5879. },
  5880. {
  5881. "id": "attendance",
  5882. "type": "switch",
  5883. "display": i18n_1.I18N[this.locale].attendance,
  5884. "name": i18n_1.I18N[this.locale].attendance,
  5885. "value": true
  5886. }
  5887. ].concat(this.menu_items);
  5888. }
  5889. onLoad() {
  5890. super.onLoad();
  5891. }
  5892. }
  5893. exports._2xFree = _2xFree;
  5894.  
  5895.  
  5896. /***/ }),
  5897. /* 14 */
  5898. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  5899.  
  5900. "use strict";
  5901.  
  5902. var __importDefault = (this && this.__importDefault) || function (mod) {
  5903. return (mod && mod.__esModule) ? mod : { "default": mod };
  5904. };
  5905. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5906. exports.BTSCHOOL = void 0;
  5907. const sweetalert2_1 = __importDefault(__webpack_require__(9));
  5908. const NexusPHP_1 = __webpack_require__(2);
  5909. const i18n_1 = __webpack_require__(4);
  5910. class BTSCHOOL extends NexusPHP_1.NexusPHP {
  5911. constructor() {
  5912. super("pt.btschool.club");
  5913. this.menu_items = [
  5914. {
  5915. "id": "bannerHide",
  5916. "type": "switch",
  5917. "display": i18n_1.I18N[this.locale].bannerHideName,
  5918. "name": i18n_1.I18N[this.locale].bannerHideName,
  5919. "value": false
  5920. },
  5921. {
  5922. "id": "attendance",
  5923. "type": "switch",
  5924. "display": i18n_1.I18N[this.locale].attendance,
  5925. "name": i18n_1.I18N[this.locale].attendance,
  5926. "value": true
  5927. }
  5928. ].concat(this.menu_items);
  5929. }
  5930. onLoad() {
  5931. super.onLoad();
  5932. }
  5933. sayThanks() {
  5934. super.sayThanks(20000);
  5935. }
  5936. attendance() {
  5937. if (!this.getHostValue("attendance")) {
  5938. return;
  5939. }
  5940. const attend = document.querySelector("#outer [href^=\"index.php?action=addbonus\"]");
  5941. if (!attend) {
  5942. return;
  5943. }
  5944. this.css += `
  5945. .swal2-container {
  5946. z-index: 4294967295;
  5947. }
  5948. h2#swal2-title {
  5949. background-color: transparent;
  5950. background-image: none;
  5951. border: none;
  5952. }`;
  5953. attend.onclick = () => {
  5954. this.makeGetRequest("https://" + this.host + "/index.php?action=addbonus").then((text) => {
  5955. const re = /今天签到您获得\d+点魔力值|Sign in today and get it\s?\d+\s?Point of magic value/;
  5956. const result = re.exec(text);
  5957. const icon = result ? "success" : "error";
  5958. const title = result ? result[0] : i18n_1.I18N[this.locale].attendanceFail;
  5959. sweetalert2_1.default.fire({
  5960. position: "top",
  5961. icon: icon,
  5962. title: title,
  5963. showConfirmButton: false,
  5964. timer: 3000,
  5965. toast: true,
  5966. willOpen(_popup) {
  5967. if (result && attend.parentElement && attend.parentElement.parentElement) {
  5968. attend.parentElement.parentElement.setAttribute("style", "border: none; padding: 10px; background: green");
  5969. attend.setAttribute("href", "index.php");
  5970. attend.innerHTML = `<font color="white">${result[0]}</font>`;
  5971. }
  5972. },
  5973. });
  5974. });
  5975. return false;
  5976. };
  5977. this.wait(2000).then(() => {
  5978. attend.click();
  5979. });
  5980. }
  5981. }
  5982. exports.BTSCHOOL = BTSCHOOL;
  5983.  
  5984.  
  5985. /***/ }),
  5986. /* 15 */
  5987. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  5988.  
  5989. "use strict";
  5990.  
  5991. Object.defineProperty(exports, "__esModule", ({ value: true }));
  5992. exports.SJTU = void 0;
  5993. const index_1 = __webpack_require__(2);
  5994. const i18n_1 = __webpack_require__(4);
  5995. class SJTU extends index_1.NexusPHP {
  5996. constructor() {
  5997. super("pt.sjtu.edu.cn");
  5998. this.menu_items = [
  5999. {
  6000. "id": "bannerHide",
  6001. "type": "switch",
  6002. "display": i18n_1.I18N[this.locale].bannerHideName,
  6003. "name": i18n_1.I18N[this.locale].bannerHideName,
  6004. "value": false
  6005. }
  6006. ].concat(this.menu_items);
  6007. }
  6008. tweakBanner() {
  6009. if (this.getHostValue("bannerHide")) {
  6010. const info = document.querySelector("#userbar");
  6011. const info_height = (info === null || info === void 0 ? void 0 : info.clientHeight) ? info.clientHeight + 5 : 30;
  6012. this.css += `
  6013. table.head {
  6014. display: none !important; /* set important for iOS safari */
  6015. }
  6016.  
  6017. table.mainouter {
  6018. margin-top: ${info_height}px;
  6019. }`;
  6020. }
  6021. }
  6022. }
  6023. exports.SJTU = SJTU;
  6024.  
  6025.  
  6026. /***/ }),
  6027. /* 16 */
  6028. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6029.  
  6030. "use strict";
  6031.  
  6032. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6033. exports.Pterclub = void 0;
  6034. const NexusPHP_1 = __webpack_require__(2);
  6035. const common_1 = __webpack_require__(3);
  6036. const i18n_1 = __webpack_require__(4);
  6037. class Pterclub extends NexusPHP_1.NexusPHP {
  6038. constructor() {
  6039. super("pterclub.com");
  6040. this.menu_items = [
  6041. {
  6042. "id": "bannerHide",
  6043. "type": "switch",
  6044. "display": i18n_1.I18N[this.locale].bannerHideName,
  6045. "name": i18n_1.I18N[this.locale].bannerHideName,
  6046. "value": false
  6047. },
  6048. {
  6049. "id": "attendance",
  6050. "type": "switch",
  6051. "display": i18n_1.I18N[this.locale].attendance,
  6052. "name": i18n_1.I18N[this.locale].attendance,
  6053. "value": true
  6054. }
  6055. ].concat(this.menu_items);
  6056. }
  6057. onLoad() {
  6058. super.onLoad();
  6059. }
  6060. addDirectLink() {
  6061. if (!this.getHostValue("directLink")) {
  6062. return;
  6063. }
  6064. const trs = document.querySelectorAll("table.torrentname > tbody > tr:nth-of-type(1)");
  6065. for (const tr of trs) {
  6066. const tds = tr.querySelectorAll("td");
  6067. if (!tds || tds.length < 5) {
  6068. continue;
  6069. }
  6070. const dl = tds[3].querySelector("a");
  6071. const direct_link = dl ? dl.href : "";
  6072. if (direct_link == "") {
  6073. continue;
  6074. }
  6075. const img = document.createElement("img");
  6076. img.setAttribute("src", "pic/trans.gif");
  6077. img.setAttribute("class", "torrent_direct_link");
  6078. img.setAttribute("alt", "DL");
  6079. const a = document.createElement("a");
  6080. a.setAttribute("title", i18n_1.I18N[this.locale].passkeyWarning);
  6081. a.setAttribute("onclick", "return false");
  6082. a.setAttribute("id", "direct_link");
  6083. a.setAttribute("href", direct_link);
  6084. a.setAttribute("data-clipboard-text", direct_link);
  6085. a.appendChild(img);
  6086. tds[4].prepend(a);
  6087. }
  6088. this.css += `
  6089. .swal2-container {
  6090. z-index: 4294967295;
  6091. }
  6092. img.torrent_direct_link {
  6093. width: 16px;
  6094. height: 16px;
  6095. background: url('${common_1.direct_link_img_url}');
  6096. padding-bottom: 1px;
  6097. }`;
  6098. this.registerClipboard("#direct_link");
  6099. }
  6100. attendance() {
  6101. if (!this.getHostValue("attendance")) {
  6102. return;
  6103. }
  6104. const do_attendance = document.querySelector("a#do-attendance");
  6105. if (do_attendance) {
  6106. this.wait(2000).then(() => {
  6107. do_attendance.click();
  6108. });
  6109. }
  6110. }
  6111. }
  6112. exports.Pterclub = Pterclub;
  6113.  
  6114.  
  6115. /***/ }),
  6116. /* 17 */
  6117. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6118.  
  6119. "use strict";
  6120.  
  6121. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6122. exports.TJUPT = void 0;
  6123. const index_1 = __webpack_require__(2);
  6124. const i18n_1 = __webpack_require__(4);
  6125. class TJUPT extends index_1.NexusPHP {
  6126. constructor() {
  6127. super("tjupt.org");
  6128. this.menu_items = [
  6129. {
  6130. "id": "bannerFold",
  6131. "type": "switch",
  6132. "display": i18n_1.I18N[this.locale].bannerFold,
  6133. "name": i18n_1.I18N[this.locale].bannerFoldName,
  6134. "value": true
  6135. },
  6136. {
  6137. "id": "bannerHide",
  6138. "type": "switch",
  6139. "display": i18n_1.I18N[this.locale].bannerHide,
  6140. "name": i18n_1.I18N[this.locale].bannerHideName,
  6141. "value": false
  6142. },
  6143. {
  6144. "id": "stickyHide",
  6145. "type": "selection",
  6146. "display": [
  6147. i18n_1.I18N[this.locale].showAllSticky,
  6148. i18n_1.I18N[this.locale].hideSingleSticky,
  6149. i18n_1.I18N[this.locale].hideSingleDoubleSticky,
  6150. i18n_1.I18N[this.locale].hideAllSticky
  6151. ],
  6152. "value": 0
  6153. },
  6154. {
  6155. "id": "colorBlind",
  6156. "type": "switch",
  6157. "display": i18n_1.I18N[this.locale].colorBlind,
  6158. "name": i18n_1.I18N[this.locale].colorBlind,
  6159. "value": false
  6160. }
  6161. ].concat(this.menu_items);
  6162. }
  6163. onLoad() {
  6164. super.onLoad();
  6165. switch (this.getHostValue("stickyHide")) {
  6166. case 3:
  6167. this.css += `
  6168. .triple_sticky_bg {
  6169. display: none;
  6170. }`;
  6171. case 2:
  6172. this.css += `
  6173. .double_sticky_bg {
  6174. display: none;
  6175. }`;
  6176. case 1:
  6177. this.css += `
  6178. .sticky_bg {
  6179. display: none;
  6180. }`;
  6181. default:
  6182. break;
  6183. }
  6184. if (this.getHostValue("colorBlind")) {
  6185. if (location.href.indexOf("/classes.php") >= 0) {
  6186. const spans = document.querySelectorAll("table.main > tbody > tr > td:nth-of-type(2) > ul > li > span[style=\"color: green\"]");
  6187. for (const span of spans) {
  6188. span.setAttribute("style", "color: blue");
  6189. }
  6190. }
  6191. }
  6192. }
  6193. getPasskey() {
  6194. const value = this.getHostValue("passkey");
  6195. let passkey = "";
  6196. if (value) {
  6197. passkey = String(value);
  6198. }
  6199. if (passkey != "") {
  6200. this.passkey = passkey;
  6201. return;
  6202. }
  6203. const link = document.querySelector("[title=\"Latest Torrents\"]");
  6204. const re = /passkey=([\d\w]+)/;
  6205. const result = re.exec(link.href);
  6206. this.passkey = result && result.length > 1 ? result[1] : "";
  6207. if (this.passkey != "") {
  6208. this.setHostValue("passkey", this.passkey);
  6209. }
  6210. }
  6211. tweakBanner() {
  6212. if (this.getHostValue("bannerHide")) {
  6213. this.css += `
  6214. .logo_img img {
  6215. display: none;
  6216. }`;
  6217. }
  6218. else if (this.getHostValue("bannerFold")) {
  6219. const logo_img = document.querySelector(".logo_img");
  6220. const original_height = logo_img === null || logo_img === void 0 ? void 0 : logo_img.clientHeight;
  6221. this.css += `
  6222. .logo_img {
  6223. height: 10px;
  6224. overflow: hidden;
  6225. transition: height 0.5s;
  6226. }
  6227.  
  6228. .logo_img:hover {
  6229. height: ${original_height}px;
  6230. }`;
  6231. }
  6232. }
  6233. }
  6234. exports.TJUPT = TJUPT;
  6235.  
  6236.  
  6237. /***/ }),
  6238. /* 18 */
  6239. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6240.  
  6241. "use strict";
  6242.  
  6243. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6244. exports.DMHY = void 0;
  6245. const NexusPHP_1 = __webpack_require__(2);
  6246. const i18n_1 = __webpack_require__(4);
  6247. class DMHY extends NexusPHP_1.NexusPHP {
  6248. constructor() {
  6249. super("u2.dmhy.org");
  6250. this.menu_items = [
  6251. {
  6252. "id": "bannerHide",
  6253. "type": "switch",
  6254. "display": i18n_1.I18N[this.locale].bannerHideName,
  6255. "name": i18n_1.I18N[this.locale].bannerHideName,
  6256. "value": false
  6257. }
  6258. ].concat(this.menu_items);
  6259. }
  6260. onLoad() {
  6261. super.onLoad();
  6262. }
  6263. sayThanks(ms = 2000) {
  6264. if (!this.getHostValue("thanks") || location.href.indexOf("/details.php") < 0) {
  6265. return;
  6266. }
  6267. this.wait(ms).then(() => {
  6268. const url = window.location.href;
  6269. const result = /id=(\d+)/.exec(url);
  6270. if (!result) {
  6271. return;
  6272. }
  6273. const input = document.querySelector("[onclick=\"saythanks(" + result[1] + ",0);\"]");
  6274. if (input && !input.disabled) {
  6275. input.click();
  6276. }
  6277. }).catch(() => { console.error("Failed to say thanks."); });
  6278. }
  6279. }
  6280. exports.DMHY = DMHY;
  6281.  
  6282.  
  6283. /***/ }),
  6284. /* 19 */
  6285. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  6286.  
  6287. "use strict";
  6288.  
  6289. var __importDefault = (this && this.__importDefault) || function (mod) {
  6290. return (mod && mod.__esModule) ? mod : { "default": mod };
  6291. };
  6292. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6293. exports.HDarea = void 0;
  6294. const sweetalert2_1 = __importDefault(__webpack_require__(9));
  6295. const NexusPHP_1 = __webpack_require__(2);
  6296. const i18n_1 = __webpack_require__(4);
  6297. class HDarea extends NexusPHP_1.NexusPHP {
  6298. constructor() {
  6299. super("www.hdarea.co");
  6300. this.menu_items = [
  6301. {
  6302. "id": "bannerHide",
  6303. "type": "switch",
  6304. "display": i18n_1.I18N[this.locale].bannerHideName,
  6305. "name": i18n_1.I18N[this.locale].bannerHideName,
  6306. "value": false
  6307. },
  6308. {
  6309. "id": "attendance",
  6310. "type": "switch",
  6311. "display": i18n_1.I18N[this.locale].attendance,
  6312. "name": i18n_1.I18N[this.locale].attendance,
  6313. "value": true
  6314. }
  6315. ].concat(this.menu_items);
  6316. }
  6317. onLoad() {
  6318. super.onLoad();
  6319. }
  6320. attendance() {
  6321. if (!this.getHostValue("attendance")) {
  6322. return;
  6323. }
  6324. const attend = document.querySelector("span#sign_in > a");
  6325. if (attend) {
  6326. const anchor = attend;
  6327. anchor.onclick = () => {
  6328. this.makeGetRequest("https://" + this.host + "/sign_in.php?action=sign_in").then((text) => {
  6329. const repeat = text.indexOf("重") >= 0 || text.indexOf("repeat") >= 0;
  6330. const icon = repeat ? "info" : "success";
  6331. sweetalert2_1.default.fire({
  6332. position: "top",
  6333. icon: `${icon}`,
  6334. title: `${text}`,
  6335. showConfirmButton: false,
  6336. timer: 3000,
  6337. toast: true,
  6338. willOpen: (_popup) => {
  6339. const sign_in = document.getElementById("sign_in");
  6340. const sign_in_done = document.getElementById("sign_in_done");
  6341. if (sign_in) {
  6342. sign_in.style.display = "none";
  6343. }
  6344. if (sign_in_done) {
  6345. sign_in_done.style.display = "inline";
  6346. }
  6347. }
  6348. });
  6349. });
  6350. return false;
  6351. };
  6352. this.wait(2000).then(() => {
  6353. attend.click();
  6354. });
  6355. }
  6356. }
  6357. }
  6358. exports.HDarea = HDarea;
  6359.  
  6360.  
  6361. /***/ }),
  6362. /* 20 */
  6363. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6364.  
  6365. "use strict";
  6366.  
  6367. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6368. exports.HTPT = void 0;
  6369. const NexusPHP_1 = __webpack_require__(2);
  6370. const i18n_1 = __webpack_require__(4);
  6371. class HTPT extends NexusPHP_1.NexusPHP {
  6372. constructor() {
  6373. super("www.htpt.cc");
  6374. this.menu_items = [
  6375. {
  6376. "id": "bannerHide",
  6377. "type": "switch",
  6378. "display": i18n_1.I18N[this.locale].bannerHideName,
  6379. "name": i18n_1.I18N[this.locale].bannerHideName,
  6380. "value": false
  6381. },
  6382. {
  6383. "id": "attendance",
  6384. "type": "switch",
  6385. "display": i18n_1.I18N[this.locale].attendance,
  6386. "name": i18n_1.I18N[this.locale].attendance,
  6387. "value": true
  6388. }
  6389. ].concat(this.menu_items);
  6390. }
  6391. onLoad() {
  6392. super.onLoad();
  6393. }
  6394. }
  6395. exports.HTPT = HTPT;
  6396.  
  6397.  
  6398. /***/ }),
  6399. /* 21 */
  6400. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6401.  
  6402. "use strict";
  6403.  
  6404. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6405. exports.ICC2022 = void 0;
  6406. const NexusPHP_1 = __webpack_require__(2);
  6407. const i18n_1 = __webpack_require__(4);
  6408. class ICC2022 extends NexusPHP_1.NexusPHP {
  6409. constructor() {
  6410. super("www.icc2022.com");
  6411. this.menu_items = [
  6412. {
  6413. "id": "bannerHide",
  6414. "type": "switch",
  6415. "display": i18n_1.I18N[this.locale].bannerHideName,
  6416. "name": i18n_1.I18N[this.locale].bannerHideName,
  6417. "value": false
  6418. },
  6419. {
  6420. "id": "attendance",
  6421. "type": "switch",
  6422. "display": i18n_1.I18N[this.locale].attendance,
  6423. "name": i18n_1.I18N[this.locale].attendance,
  6424. "value": true
  6425. }
  6426. ].concat(this.menu_items);
  6427. }
  6428. onLoad() {
  6429. super.onLoad();
  6430. }
  6431. }
  6432. exports.ICC2022 = ICC2022;
  6433.  
  6434.  
  6435. /***/ }),
  6436. /* 22 */
  6437. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  6438.  
  6439. "use strict";
  6440.  
  6441. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6442. exports.ZmPT = void 0;
  6443. const NexusPHP_1 = __webpack_require__(2);
  6444. const i18n_1 = __webpack_require__(4);
  6445. class ZmPT extends NexusPHP_1.NexusPHP {
  6446. constructor() {
  6447. super("zmpt.cc");
  6448. this.menu_items = [
  6449. {
  6450. "id": "bannerHide",
  6451. "type": "switch",
  6452. "display": i18n_1.I18N[this.locale].bannerHideName,
  6453. "name": i18n_1.I18N[this.locale].bannerHideName,
  6454. "value": false
  6455. },
  6456. {
  6457. "id": "attendance",
  6458. "type": "switch",
  6459. "display": i18n_1.I18N[this.locale].attendance,
  6460. "name": i18n_1.I18N[this.locale].attendance,
  6461. "value": true
  6462. }
  6463. ].concat(this.menu_items);
  6464. }
  6465. onLoad() {
  6466. super.onLoad();
  6467. }
  6468. }
  6469. exports.ZmPT = ZmPT;
  6470.  
  6471.  
  6472. /***/ })
  6473. /******/ ]);
  6474. /************************************************************************/
  6475. /******/ // The module cache
  6476. /******/ var __webpack_module_cache__ = {};
  6477. /******/
  6478. /******/ // The require function
  6479. /******/ function __webpack_require__(moduleId) {
  6480. /******/ // Check if module is in cache
  6481. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  6482. /******/ if (cachedModule !== undefined) {
  6483. /******/ return cachedModule.exports;
  6484. /******/ }
  6485. /******/ // Create a new module (and put it into the cache)
  6486. /******/ var module = __webpack_module_cache__[moduleId] = {
  6487. /******/ // no module.id needed
  6488. /******/ // no module.loaded needed
  6489. /******/ exports: {}
  6490. /******/ };
  6491. /******/
  6492. /******/ // Execute the module function
  6493. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  6494. /******/
  6495. /******/ // Return the exports of the module
  6496. /******/ return module.exports;
  6497. /******/ }
  6498. /******/
  6499. /************************************************************************/
  6500. /******/ /* webpack/runtime/amd options */
  6501. /******/ (() => {
  6502. /******/ __webpack_require__.amdO = {};
  6503. /******/ })();
  6504. /******/
  6505. /************************************************************************/
  6506. var __webpack_exports__ = {};
  6507. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  6508. (() => {
  6509. "use strict";
  6510. var exports = __webpack_exports__;
  6511.  
  6512. Object.defineProperty(exports, "__esModule", ({ value: true }));
  6513. const carpt_net_1 = __webpack_require__(1);
  6514. const hhanclub_top_1 = __webpack_require__(10);
  6515. const kamept_com_1 = __webpack_require__(11);
  6516. const nanyangpt_com_1 = __webpack_require__(12);
  6517. const pt_2xfree_org_1 = __webpack_require__(13);
  6518. const pt_btschool_club_1 = __webpack_require__(14);
  6519. const pt_sjtu_edu_cn_1 = __webpack_require__(15);
  6520. const pterclub_com_1 = __webpack_require__(16);
  6521. const index_1 = __webpack_require__(17);
  6522. const u2_dmhy_org_1 = __webpack_require__(18);
  6523. const www_hdarea_co_1 = __webpack_require__(19);
  6524. const www_htpt_cc_1 = __webpack_require__(20);
  6525. const www_icc2022_com_1 = __webpack_require__(21);
  6526. const zmpt_cc_1 = __webpack_require__(22);
  6527. const host = window.location.host;
  6528. const sites = new Map([
  6529. ["carpt.net", carpt_net_1.CarPT],
  6530. ["hhanclub.top", hhanclub_top_1.Hhanclub],
  6531. ["kamept.com", kamept_com_1.KamePT],
  6532. ["nanyangpt.com", nanyangpt_com_1.NanyangPT],
  6533. ["pt.2xfree.org", pt_2xfree_org_1._2xFree],
  6534. ["pt.btschool.club", pt_btschool_club_1.BTSCHOOL],
  6535. ["pt.sjtu.edu.cn", pt_sjtu_edu_cn_1.SJTU],
  6536. ["pterclub.com", pterclub_com_1.Pterclub],
  6537. ["tjupt.org", index_1.TJUPT],
  6538. ["u2.dmhy.org", u2_dmhy_org_1.DMHY],
  6539. ["www.hdarea.co", www_hdarea_co_1.HDarea],
  6540. ["www.htpt.cc", www_htpt_cc_1.HTPT],
  6541. ["www.icc2022.com", www_icc2022_com_1.ICC2022],
  6542. ["zmpt.cc", zmpt_cc_1.ZmPT],
  6543. ]);
  6544. const site = sites.has(host) ? new (sites.get(host))() : undefined;
  6545. if (site) {
  6546. site.init();
  6547. site.onLoad();
  6548. site.addStyle();
  6549. }
  6550.  
  6551. })();
  6552.  
  6553. /******/ })()
  6554. ;