summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-10-26 16:39:03 +0200
committerRaindropsSys <raindrops@equestria.dev>2023-10-26 16:39:03 +0200
commit9f9d66afebc59c6c265c4424f7b8fb36d8876541 (patch)
tree8af8fc2fb1634a2f53df35544081a48956e6efad
parentae187b6d75c8079da0be1dc288613bad8466fe61 (diff)
downloadmist-9f9d66afebc59c6c265c4424f7b8fb36d8876541.tar.gz
mist-9f9d66afebc59c6c265c4424f7b8fb36d8876541.tar.bz2
mist-9f9d66afebc59c6c265c4424f7b8fb36d8876541.zip
Updated 34 files and added 146 files (automated)
-rw-r--r--.DS_Storebin14340 -> 16388 bytes
-rw-r--r--.gitignore3
-rw-r--r--.idea/deployment.xml2
-rw-r--r--.idea/vcs.xml6
-rw-r--r--api/addHistory.php9
-rw-r--r--app/download.php74
-rw-r--r--app/explore.php23
-rw-r--r--app/index.php46
-rw-r--r--app/info.php186
-rw-r--r--app/listing.php24
-rw-r--r--app/lyrics.php8
-rw-r--r--app/modal.php48
-rw-r--r--app/navigation.php3
-rw-r--r--app/player-mobile.php2
-rw-r--r--app/queue.php78
-rw-r--r--app/search.php91
-rw-r--r--app/settings.php2
-rw-r--r--assets/.DS_Storebin10244 -> 10244 bytes
-rw-r--r--assets/dark.css52
-rw-r--r--assets/icons/add.svg1
-rw-r--r--assets/icons/download.svg1
-rw-r--r--assets/icons/info.svg1
-rw-r--r--assets/icons/menu.svg1
-rw-r--r--assets/icons/playlist.svg2
-rw-r--r--assets/icons/playnext.svg1
-rw-r--r--assets/icons/remove.svg1
-rw-r--r--assets/icons/settings.svg2
-rw-r--r--assets/logo-display.icobin0 -> 13603 bytes
-rw-r--r--assets/logo-mac.pngbin0 -> 386333 bytes
-rw-r--r--assets/logo.icnsbin0 -> 420932 bytes
-rw-r--r--assets/styles.css18
-rwxr-xr-xbuild.sh8
-rw-r--r--desktop/package.json1
-rw-r--r--icons/maskable.pngbin17018 -> 15075 bytes
-rw-r--r--icons/maskable.svg100
-rw-r--r--icons/maskable_128x128.pngbin8496 -> 7231 bytes
-rw-r--r--icons/maskable_144x144.pngbin9620 -> 8334 bytes
-rw-r--r--icons/maskable_152x152.pngbin10223 -> 8844 bytes
-rw-r--r--icons/maskable_192x192.pngbin13286 -> 11503 bytes
-rw-r--r--icons/maskable_256x256.pngbin18494 -> 15991 bytes
-rw-r--r--icons/maskable_384x384.pngbin29306 -> 25823 bytes
-rw-r--r--icons/maskable_64x64.pngbin3752 -> 3138 bytes
-rw-r--r--icons/maskable_72x72.pngbin4375 -> 3649 bytes
-rw-r--r--icons/maskable_96x96.pngbin6062 -> 5172 bytes
-rw-r--r--includes/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--includes/editor.js193
-rw-r--r--includes/node_modules/.package-lock.json97
-rw-r--r--includes/node_modules/ansi-styles/index.d.ts345
-rw-r--r--includes/node_modules/ansi-styles/index.js163
-rw-r--r--includes/node_modules/ansi-styles/license9
-rw-r--r--includes/node_modules/ansi-styles/package.json56
-rw-r--r--includes/node_modules/ansi-styles/readme.md152
-rw-r--r--includes/node_modules/chalk/index.d.ts415
-rw-r--r--includes/node_modules/chalk/license9
-rw-r--r--includes/node_modules/chalk/package.json68
-rw-r--r--includes/node_modules/chalk/readme.md341
-rw-r--r--includes/node_modules/chalk/source/index.js229
-rw-r--r--includes/node_modules/chalk/source/templates.js134
-rw-r--r--includes/node_modules/chalk/source/util.js39
-rw-r--r--includes/node_modules/color-convert/CHANGELOG.md54
-rw-r--r--includes/node_modules/color-convert/LICENSE21
-rw-r--r--includes/node_modules/color-convert/README.md68
-rw-r--r--includes/node_modules/color-convert/conversions.js839
-rw-r--r--includes/node_modules/color-convert/index.js81
-rw-r--r--includes/node_modules/color-convert/package.json48
-rw-r--r--includes/node_modules/color-convert/route.js97
-rw-r--r--includes/node_modules/color-name/LICENSE8
-rw-r--r--includes/node_modules/color-name/README.md11
-rw-r--r--includes/node_modules/color-name/index.js152
-rw-r--r--includes/node_modules/color-name/package.json28
-rw-r--r--includes/node_modules/fuse.js/LICENSE201
-rw-r--r--includes/node_modules/fuse.js/README.md61
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.basic.cjs1329
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.basic.js1335
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.basic.min.cjs9
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.basic.min.js9
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.basic.min.mjs9
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.basic.mjs1259
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.cjs2004
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.d.ts368
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.js2010
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.min.cjs9
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.min.js9
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.min.mjs9
-rw-r--r--includes/node_modules/fuse.js/dist/fuse.mjs1778
-rw-r--r--includes/node_modules/fuse.js/package.json118
-rw-r--r--includes/node_modules/has-flag/index.d.ts39
-rw-r--r--includes/node_modules/has-flag/index.js8
-rw-r--r--includes/node_modules/has-flag/license9
-rw-r--r--includes/node_modules/has-flag/package.json46
-rw-r--r--includes/node_modules/has-flag/readme.md89
-rw-r--r--includes/node_modules/kleur/index.js104
-rw-r--r--includes/node_modules/kleur/kleur.d.ts45
-rw-r--r--includes/node_modules/kleur/license21
-rw-r--r--includes/node_modules/kleur/package.json35
-rw-r--r--includes/node_modules/kleur/readme.md172
-rw-r--r--includes/node_modules/prompts/dist/dateparts/datepart.js39
-rw-r--r--includes/node_modules/prompts/dist/dateparts/day.js35
-rw-r--r--includes/node_modules/prompts/dist/dateparts/hours.js30
-rw-r--r--includes/node_modules/prompts/dist/dateparts/index.js13
-rw-r--r--includes/node_modules/prompts/dist/dateparts/meridiem.js25
-rw-r--r--includes/node_modules/prompts/dist/dateparts/milliseconds.js28
-rw-r--r--includes/node_modules/prompts/dist/dateparts/minutes.js29
-rw-r--r--includes/node_modules/prompts/dist/dateparts/month.js31
-rw-r--r--includes/node_modules/prompts/dist/dateparts/seconds.js29
-rw-r--r--includes/node_modules/prompts/dist/dateparts/year.js29
-rw-r--r--includes/node_modules/prompts/dist/elements/autocomplete.js285
-rw-r--r--includes/node_modules/prompts/dist/elements/autocompleteMultiselect.js201
-rw-r--r--includes/node_modules/prompts/dist/elements/confirm.js93
-rw-r--r--includes/node_modules/prompts/dist/elements/date.js250
-rw-r--r--includes/node_modules/prompts/dist/elements/index.js13
-rw-r--r--includes/node_modules/prompts/dist/elements/multiselect.js289
-rw-r--r--includes/node_modules/prompts/dist/elements/number.js250
-rw-r--r--includes/node_modules/prompts/dist/elements/prompt.js82
-rw-r--r--includes/node_modules/prompts/dist/elements/select.js190
-rw-r--r--includes/node_modules/prompts/dist/elements/text.js245
-rw-r--r--includes/node_modules/prompts/dist/elements/toggle.js124
-rw-r--r--includes/node_modules/prompts/dist/index.js154
-rw-r--r--includes/node_modules/prompts/dist/prompts.js222
-rw-r--r--includes/node_modules/prompts/dist/util/action.js38
-rw-r--r--includes/node_modules/prompts/dist/util/clear.js42
-rw-r--r--includes/node_modules/prompts/dist/util/entriesToDisplay.js21
-rw-r--r--includes/node_modules/prompts/dist/util/figures.js32
-rw-r--r--includes/node_modules/prompts/dist/util/index.js12
-rw-r--r--includes/node_modules/prompts/dist/util/lines.js14
-rw-r--r--includes/node_modules/prompts/dist/util/strip.js7
-rw-r--r--includes/node_modules/prompts/dist/util/style.js51
-rw-r--r--includes/node_modules/prompts/dist/util/wrap.js16
-rw-r--r--includes/node_modules/prompts/index.js14
-rw-r--r--includes/node_modules/prompts/lib/dateparts/datepart.js35
-rw-r--r--includes/node_modules/prompts/lib/dateparts/day.js42
-rw-r--r--includes/node_modules/prompts/lib/dateparts/hours.js30
-rw-r--r--includes/node_modules/prompts/lib/dateparts/index.js13
-rw-r--r--includes/node_modules/prompts/lib/dateparts/meridiem.js24
-rw-r--r--includes/node_modules/prompts/lib/dateparts/milliseconds.js28
-rw-r--r--includes/node_modules/prompts/lib/dateparts/minutes.js28
-rw-r--r--includes/node_modules/prompts/lib/dateparts/month.js33
-rw-r--r--includes/node_modules/prompts/lib/dateparts/seconds.js28
-rw-r--r--includes/node_modules/prompts/lib/dateparts/year.js28
-rw-r--r--includes/node_modules/prompts/lib/elements/autocomplete.js264
-rw-r--r--includes/node_modules/prompts/lib/elements/autocompleteMultiselect.js194
-rw-r--r--includes/node_modules/prompts/lib/elements/confirm.js89
-rw-r--r--includes/node_modules/prompts/lib/elements/date.js209
-rw-r--r--includes/node_modules/prompts/lib/elements/index.js13
-rw-r--r--includes/node_modules/prompts/lib/elements/multiselect.js271
-rw-r--r--includes/node_modules/prompts/lib/elements/number.js213
-rw-r--r--includes/node_modules/prompts/lib/elements/prompt.js68
-rw-r--r--includes/node_modules/prompts/lib/elements/select.js175
-rw-r--r--includes/node_modules/prompts/lib/elements/text.js208
-rw-r--r--includes/node_modules/prompts/lib/elements/toggle.js118
-rw-r--r--includes/node_modules/prompts/lib/index.js98
-rw-r--r--includes/node_modules/prompts/lib/prompts.js206
-rw-r--r--includes/node_modules/prompts/lib/util/action.js39
-rw-r--r--includes/node_modules/prompts/lib/util/clear.js22
-rw-r--r--includes/node_modules/prompts/lib/util/entriesToDisplay.js21
-rw-r--r--includes/node_modules/prompts/lib/util/figures.js33
-rw-r--r--includes/node_modules/prompts/lib/util/index.js12
-rw-r--r--includes/node_modules/prompts/lib/util/lines.js15
-rw-r--r--includes/node_modules/prompts/lib/util/strip.js11
-rw-r--r--includes/node_modules/prompts/lib/util/style.js40
-rw-r--r--includes/node_modules/prompts/lib/util/wrap.js27
-rw-r--r--includes/node_modules/prompts/license21
-rw-r--r--includes/node_modules/prompts/package.json53
-rwxr-xr-xincludes/node_modules/prompts/readme.md882
-rw-r--r--includes/node_modules/sisteransi/license21
-rwxr-xr-xincludes/node_modules/sisteransi/package.json34
-rwxr-xr-xincludes/node_modules/sisteransi/readme.md113
-rw-r--r--includes/node_modules/sisteransi/src/index.js58
-rw-r--r--includes/node_modules/sisteransi/src/sisteransi.d.ts35
-rw-r--r--includes/node_modules/supports-color/browser.js5
-rw-r--r--includes/node_modules/supports-color/index.js135
-rw-r--r--includes/node_modules/supports-color/license9
-rw-r--r--includes/node_modules/supports-color/package.json53
-rw-r--r--includes/node_modules/supports-color/readme.md76
-rw-r--r--includes/package-lock.json102
-rw-r--r--includes/package.json5
-rw-r--r--includes/process.js230
-rw-r--r--includes/reset.js12
-rw-r--r--includes/session.php85
-rw-r--r--version2
180 files changed, 22897 insertions, 138 deletions
diff --git a/.DS_Store b/.DS_Store
index cba7b56..4087871 100644
--- a/.DS_Store
+++ b/.DS_Store
Binary files differ
diff --git a/.gitignore b/.gitignore
index 66bc8ac..2f42df5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
includes/app.json
includes/tokens
includes/users
-assets/content \ No newline at end of file
+assets/content
+build \ No newline at end of file
diff --git a/.idea/deployment.xml b/.idea/deployment.xml
index 80c15f7..4500cde 100644
--- a/.idea/deployment.xml
+++ b/.idea/deployment.xml
@@ -10,6 +10,8 @@
</mappings>
<excludedPaths>
<excludedPath local="true" path="$PROJECT_DIR$/desktop" />
+ <excludedPath local="true" path="$PROJECT_DIR$/build" />
+ <excludedPath local="true" path="$PROJECT_DIR$/assets/content" />
</excludedPaths>
</serverdata>
</paths>
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/api/addHistory.php b/api/addHistory.php
new file mode 100644
index 0000000..cc35409
--- /dev/null
+++ b/api/addHistory.php
@@ -0,0 +1,9 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
+global $songs; global $_PROFILE; global $history;
+
+if (!isset($_GET["i"])) return;
+$history[] = $_GET["i"];
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-history.json", json_encode($history)); \ No newline at end of file
diff --git a/app/download.php b/app/download.php
new file mode 100644
index 0000000..dd1321c
--- /dev/null
+++ b/app/download.php
@@ -0,0 +1,74 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $songs;
+
+if (!isset($_GET["i"]) || !isset($songs[$_GET["i"]])) {
+ die();
+}
+
+$song = $songs[$_GET["i"]];
+$fileName = str_replace(["/", "<", ">", ":", "\"", "\\", "|", "?", "*"], "-", $song["artist"] . " - " . $song["title"]);
+
+function getSize($bytes) {
+ if ($bytes < 1024) {
+ return $bytes;
+ }
+
+ if ($bytes < 1024**2) {
+ return round($bytes / 1024, 1) . " KB";
+ }
+
+ if ($bytes < 1024**3) {
+ return round($bytes / 1024**2, 1) . " MB";
+ }
+
+ return round($bytes / 1024**3, 1) . " GB";
+}
+
+?>
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport"
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <title>download</title>
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/assets/dark.css" rel="stylesheet">
+ <link href="/assets/styles.css" rel="stylesheet">
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
+ <script src="/assets/localforage.min.js"></script>
+ <script src="/assets/fuse.min.js"></script>
+ <script src="/assets/shortcuts.js"></script>
+ <link id="native-css" href="/assets/native.css" rel="stylesheet" disabled>
+</head>
+<body class="crossplatform" style="background-color: transparent !important;">
+ <script>
+ if (navigator.userAgent.includes("MistNative/darwin") || navigator.userAgent.includes("MistNative/win32")) {
+ document.getElementById("native-css").disabled = false;
+ document.body.classList.remove("crossplatform");
+ }
+ </script>
+ <div style="padding: 1rem;">
+ <p>
+ <?= $song["artist"] ?> — <?= $song["title"] ?><br>
+ <?= $song["album"] ?>
+ </p>
+
+ <p>Select the version of the song you would like to download:</p>
+ <ul class="list-group">
+ <li class="list-group-item">Lossless (FLAC, <?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".flac")) ?>)<a style="float: right;" download="<?= $fileName ?>.flac" href="/assets/content/<?= $_GET["i"] ?>.flac">Download</a></li>
+ <li class="list-group-item">AAC-LC (MP4, <?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".m4a")) ?>)<a style="float: right;" download="<?= $fileName ?>.m4a" href="/assets/content/<?= $_GET["i"] ?>.m4a">Download</a></li>
+ <li class="list-group-item">Album art (JPEG, <?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".jpg")) ?>)<a style="float: right;" download="<?= $fileName ?>.jpg" href="/assets/content/<?= $_GET["i"] ?>.jpg">Download</a></li>
+ </ul>
+ </div>
+
+ <script>
+ window.sizeInterval = setInterval(() => {
+ if (document.body.clientHeight > 0) {
+ clearInterval(sizeInterval);
+ window.parent.document.getElementById("modal-frame").style.height = document.body.clientHeight + "px";
+ }
+ });
+ </script>
+</body>
+</html> \ No newline at end of file
diff --git a/app/explore.php b/app/explore.php
index a51731b..4887022 100644
--- a/app/explore.php
+++ b/app/explore.php
@@ -1,4 +1,4 @@
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; ?>
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $songs; global $albums; ?>
<!doctype html>
<html lang="en">
<head>
@@ -25,7 +25,26 @@
</script>
<div class="container">
<br>
- <h2 style="margin-top: 10px; margin-bottom: 20px; margin-left: 10px;">Explore<input placeholder="Filter" id="filter" class="form-control" style="width: 256px; float: right;" onchange="updateFilter();" onkeyup="updateFilter();"></h2>
+ <h2 style="margin-top: 10px; margin-bottom: 20px; margin-left: 10px;">Explore</h2>
+
+ <form action="search.php">
+ <div style="margin-left: 10px;" class="input-group mb-3">
+ <input name="q" type="text" id="search" class="form-control" placeholder="Search on Mist">
+ <button class="btn btn-outline-secondary" type="submit" id="btn-search">Search</button>
+ </div>
+ </form>
+
+ <hr style="margin-left: 10px;">
+
+ <?php if (count($songs) === 0 && count($albums) === 0): ?>
+ <div class="text-muted" style="position: fixed; display: flex; inset: 0; align-items: center; justify-content: center;">
+ <div style="text-align: center;">
+ <img class="icon" src="/assets/logo-transparent.svg" style="filter: grayscale(1) invert(1); width: 96px; height: 96px;" alt="">
+ <h4 style="opacity: .75;">Upload music to this server</h4>
+ <p style="max-width: 300px; margin-left: auto; margin-right: auto;">Add millions of songs and let your users play them whenever they want.</p>
+ </div>
+ </div>
+ <?php endif; ?>
<div id="album-grid" style="display: grid; grid-template-columns: repeat(5, 1fr);">
<?php global $albums;
diff --git a/app/index.php b/app/index.php
index e6d93ff..0f22e2f 100644
--- a/app/index.php
+++ b/app/index.php
@@ -23,12 +23,12 @@
<meta name="apple-mobile-web-app-status-bar-style" content="white-translucent" media="(prefers-color-scheme: light)">
<meta name="description" content="Mist Audio Player">
</head>
-<body>
+<body <?php if (!str_contains($_SERVER['HTTP_USER_AGENT'], "MistNative/")): ?>class="web"<?php endif; ?>>
<script>
if (location.hash.trim() === "") location.hash = "#/albums";
if (window.MistNative) {
- MistNative.version("<?= explode("|", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/version")))[0] ?>", "<?= trim(file_get_contents("/opt/spotify/build.txt")) ?>");
+ MistNative.version("<?= explode("|", trim(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/version")))[0] ?>", "<?= trim(file_exists("/opt/spotify/build.txt") ? file_get_contents("/opt/spotify/build.txt") : "trunk") ?>");
MistNative.userInfo(`<?= str_replace("`", "\\`", json_encode($_PROFILE)) ?>`);
}
</script>
@@ -182,8 +182,8 @@
}
if (playlist[currentPlaylistPosition + 1]) {
- playSong(playlist[currentPlaylistPosition + 1], "keep");
currentPlaylistPosition++;
+ playSong(playlist[currentPlaylistPosition], "keep", false);
} else {
stop();
}
@@ -307,18 +307,18 @@
playerDocument.getElementById("badge-lossy").style.display = "none";
playerDocument.getElementById("badge-cd").style.display = "none";
playerDocument.getElementById("badge-hires").style.display = "inline";
- playerDocument.getElementById("badge-hires").innerHTML = "<span style='display: grid; grid-template-columns: max-content max-content'><span><img src='/assets/icons/lossless.svg' alt='' class='player-badge-icon' style='filter: invert(1);'>Hi-Res Lossless</span><span class='player-badge-desktop'>" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000).toFixed(1) + " kHz</span>";
+ playerDocument.getElementById("badge-hires").innerHTML = "<span style='display: grid; grid-template-columns: max-content max-content'><span><img src='/assets/icons/lossless.svg' alt='' class='player-badge-icon' style='filter: invert(1);'>Hi-Res Lossless</span><span class='player-badge-desktop'>" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000) + " kHz</span>";
playerDocumentMobile.getElementById("badge-lossy").style.display = "none";
playerDocumentMobile.getElementById("badge-cd").style.display = "none";
playerDocumentMobile.getElementById("badge-hires").style.display = "inline";
} else if (window.currentSong) {
- playerDocument.getElementById("badge-lossy").style.display = "inline";
+ playerDocument.getElementById("badge-lossy").style.display = "none";
playerDocument.getElementById("badge-cd").style.display = "inline";
playerDocument.getElementById("badge-hires").style.display = "none";
- playerDocumentMobile.getElementById("badge-lossy").style.display = "inline";
+ playerDocumentMobile.getElementById("badge-lossy").style.display = "none";
playerDocumentMobile.getElementById("badge-cd").style.display = "inline";
playerDocumentMobile.getElementById("badge-hires").style.display = "none";
- playerDocument.getElementById("badge-cd").innerHTML = "<span style='display: grid; grid-template-columns: max-content max-content;'>'><span><img src='/assets/icons/lossless.svg' alt='' class='player-badge-icon' style='filter: invert(1);'>Lossless</span><span class='player-badge-desktop'>" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000).toFixed(1) + " kHz</span>";
+ playerDocument.getElementById("badge-cd").innerHTML = "<span style='display: grid; grid-template-columns: max-content max-content;'><span><img src='/assets/icons/lossless.svg' alt='' class='player-badge-icon' style='filter: invert(1);'>Lossless</span><span class='player-badge-desktop'>" + window.currentSong.bitDepth + "-bit " + (window.currentSong.sampleRate / 1000) + " kHz</span>";
}
}
@@ -347,30 +347,34 @@
}
}
- window.redownloadFavorite = async () => {
+ window.redownloadFavorites = async () => {
document.getElementById("loading-text").innerText = "Downloading favorites...";
- window.favorites = await (await fetch("/api/getFavorites.php")).json();
+ window.favorites = await (await fetch("/api/getFavorites.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json();
}
window.redownloadLibrary = async () => {
document.getElementById("loading-text").innerText = "Downloading library...";
- window.favorites = await (await fetch("/api/getLibrary.php")).json();
+ window.library = await (await fetch("/api/getLibrary.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json();
}
(async () => {
document.getElementById("loading-text").innerText = "Downloading list of songs...";
- window.songs = await (await fetch("/assets/content/songs.json")).json();
+ window.songs = await (await fetch("/assets/content/songs.json?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json();
document.getElementById("loading-text").innerText = "Downloading list of albums...";
- window.albums = await (await fetch("/assets/content/albums.json")).json();
+ window.albums = await (await fetch("/assets/content/albums.json?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json();
document.getElementById("loading-text").innerText = "Downloading favorites...";
- window.favorites = await (await fetch("/api/getFavorites.php")).json();
+ window.favorites = await (await fetch("/api/getFavorites.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json();
+
+ document.getElementById("loading-text").innerText = "Downloading library...";
+ window.library = await (await fetch("/api/getLibrary.php?_=" + [...crypto.getRandomValues(new Uint8Array(40))].map(m=>('0'+m.toString(16)).slice(-2)).join(''))).json();
document.getElementById("loading-text").innerText = "Saving database...";
await localforage.setItem("albums", window.albums);
await localforage.setItem("songs", window.songs);
await localforage.setItem("favorites", window.favorites);
+ await localforage.setItem("library", window.library);
document.getElementById("loading-text").innerText = "Done loading.";
document.getElementById("loading").style.display = "none";
@@ -455,7 +459,7 @@
window.currentPlaylistID = null;
- window.playSong = async (id, playlistID) => {
+ window.playSong = async (id, playlistID, updatePosition) => {
playerDocument.getElementById("player-audio").pause();
playerDocument.getElementById("player-audio").currentTime = 0;
@@ -471,6 +475,8 @@
} else if (playlistID !== "keep") {
window.playlist = [id];
window.currentPlaylistPosition = 0;
+ } else if (typeof updatePosition !== "boolean" || updatePosition) {
+ window.currentPlaylistPosition = window.playlist.indexOf(id) ?? 0;
}
} else {
window.currentPlaylistID = null;
@@ -481,6 +487,7 @@
window.currentSong = songs[id];
window.currentSongID = id;
updateDisplay();
+ if (document.getElementById("ui").contentWindow.refreshQueue) document.getElementById("ui").contentWindow.refreshQueue();
if (!window.preloaded[id]) {
if (localStorage.getItem("data-saving") === "true") {
@@ -547,5 +554,16 @@
}
}
</script>
+
+ <iframe id="modal" src="modal.php" style="width: 100vw; height: 100vh; border: none; inset: 0; position: fixed; z-index: 99999; display: none;"></iframe>
+ <script>
+ function openModal(title, url) {
+ document.getElementById("modal").style.display = "";
+ document.getElementById("modal").contentWindow.document.getElementById("modal-title").innerText = title;
+ document.getElementById("modal").contentWindow.document.getElementById("modal-frame").src = url;
+ document.getElementById("modal").contentWindow.document.getElementById("modal-frame").style.height = "calc(100vh - 130px)";
+ document.getElementById("modal").contentWindow._modal.show();
+ }
+ </script>
</body>
</html> \ No newline at end of file
diff --git a/app/info.php b/app/info.php
new file mode 100644
index 0000000..cfc7bc2
--- /dev/null
+++ b/app/info.php
@@ -0,0 +1,186 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $songs;
+
+if (!isset($_GET["i"]) || !isset($songs[$_GET["i"]])) {
+ die();
+}
+
+$song = $songs[$_GET["i"]];
+$fileName = str_replace(["/", "<", ">", ":", "\"", "\\", "|", "?", "*"], "-", $song["artist"] . " - " . $song["title"]);
+
+function getSize($bytes) {
+ if ($bytes < 1024) {
+ return $bytes;
+ }
+
+ if ($bytes < 1024**2) {
+ return round($bytes / 1024, 1) . " KB";
+ }
+
+ if ($bytes < 1024**3) {
+ return round($bytes / 1024**2, 1) . " MB";
+ }
+
+ return round($bytes / 1024**3, 1) . " GB";
+}
+
+function timeToDuration($seconds) {
+ $hours = floor($seconds / 3600);
+ $minutes = floor($seconds / 60) - ($hours * 60);
+ $seconds = floor($seconds) - ($hours * 3600) - ($minutes * 60);
+ $parts = [];
+
+ if ($hours > 0) $parts[] = $hours . " hour" . ($hours > 1 ? "s" : "");
+ if ($minutes > 0) $parts[] = $minutes . " minute" . ($minutes > 1 ? "s" : "");
+ if ($seconds > 0) $parts[] = $seconds . " second" . ($seconds > 1 ? "s" : "");
+
+ return implode(", ", $parts);
+}
+
+function getBitRate($bits) {
+ $bitsValue = $bits . " bps";
+
+ if ($bits > 1000) {
+ if ($bits > 1000000) {
+ if ($bits > 1000000000) {
+ $bitsValue = round($bits / 1000000000, 2) . " Gbps";
+ } else {
+ $bitsValue = round($bits / 1000000, 2) . " Mbps";
+ }
+ } else {
+ $bitsValue = round($bits / 1000, 2) . " kbps";
+ }
+ }
+
+ $bytesValue = ($bits / 8) . " B/s";
+
+ if (($bits / 8) > 1000) {
+ if (($bits / 8) > 1000000) {
+ if (($bits / 8) > 1000000000) {
+ $bytesValue = round(($bits / 8) / 1000000000, 2) . " GB/s";
+ } else {
+ $bytesValue = round(($bits / 8) / 1000000, 2) . " MB/s";
+ }
+ } else {
+ $bytesValue = round(($bits / 8) / 1000, 2) . " kB/s";
+ }
+ }
+
+ return $bitsValue . " (" . $bytesValue . ")";
+}
+
+function getChannelConfiguration($c) {
+ if ($c === 1) return " (Mono)";
+ if ($c === 2) return " (Stereo)";
+ if ($c === 3) return " (Stereo+1)";
+ if ($c === 4) return " (3.1)";
+ if ($c === 5) return " (4.1 or 5.0 Surround)";
+ if ($c === 6) return " (5.1 Surround)";
+ if ($c === 7) return " (6.1 or 7.0 Surround)";
+ if ($c === 8) return " (7.1 Surround)";
+ if ($c === 9) return " (9.0 or 7.2 Spatial Audio)";
+ if ($c === 10) return " (9.1 Spatial Audio)";
+ if ($c >= 11) return " (Dolby Atmos)";
+ return "";
+}
+
+?>
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport"
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <title>info</title>
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/assets/dark.css" rel="stylesheet">
+ <link href="/assets/styles.css" rel="stylesheet">
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
+ <script src="/assets/localforage.min.js"></script>
+ <script src="/assets/fuse.min.js"></script>
+ <script src="/assets/shortcuts.js"></script>
+ <link id="native-css" href="/assets/native.css" rel="stylesheet" disabled>
+</head>
+<body class="crossplatform" style="background-color: transparent !important;">
+ <script>
+ if (navigator.userAgent.includes("MistNative/darwin") || navigator.userAgent.includes("MistNative/win32")) {
+ document.getElementById("native-css").disabled = false;
+ document.body.classList.remove("crossplatform");
+ }
+ </script>
+ <div style="padding: 1rem;">
+ <div style="display: grid; grid-template-columns: 96px 1fr; grid-gap: 15px;">
+ <img alt="" src="/assets/content/<?= $_GET["i"] ?>.jpg" style="aspect-ratio: 1; width: 96px;">
+ <div style="display: flex; align-items: center; width: 100%;">
+ <div>
+ <div style="white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis; max-width: 100%;"><b><?= $song["title"] ?></b></div>
+ <div style="white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis; max-width: 100%;"><?= $song["artist"] ?></div>
+ <div style="white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis; max-width: 100%;"><?= $song["album"] ?></div>
+ </div>
+ </div>
+ </div>
+
+ <hr>
+
+ <table style="width: 100%;">
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Track</td>
+ <td><?php if (isset($song["disc"])): ?>Disc <?= $song["disc"] ?>, track <?php endif; ?><?= $song["track"] > 0 ? $song["track"] : "-" ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Duration</td>
+ <td><?= timeToDuration($song["length"]) ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Bit rate</td>
+ <td><?= getBitRate($song["bitRate"]) ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Sample rate</td>
+ <td><?= $song["sampleRate"] ?> Hz</td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Bits per sample</td>
+ <td><?= $song["bitDepth"] ?> bits</td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Channels</td>
+ <td><?= $song["channels"] ?><?= getChannelConfiguration($song["channels"]) ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Year</td>
+ <td><?= $song["date"] ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">High-resolution</td>
+ <td><?= $song["hiRes"] ? "Yes" : "No" ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Mist Stella</td>
+ <td>No</td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Copyright</td>
+ <td><?= trim($song["copyright"] ?? "") !== "" ? $song["copyright"] : "-" ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">File size (lossless)</td>
+ <td><?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".flac")) ?></td>
+ </tr>
+ <tr>
+ <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">File size (AAC-LC)</td>
+ <td><?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".m4a")) ?></td>
+ </tr>
+ </table>
+ </div>
+
+ <script>
+ window.sizeInterval = setInterval(() => {
+ if (document.body.clientHeight > 0) {
+ clearInterval(sizeInterval);
+ window.parent.document.getElementById("modal-frame").style.height = document.body.clientHeight + "px";
+ }
+ });
+ </script>
+</body>
+</html> \ No newline at end of file
diff --git a/app/listing.php b/app/listing.php
index 8ea25d4..9d50178 100644
--- a/app/listing.php
+++ b/app/listing.php
@@ -148,30 +148,6 @@ if (!$presetList) {
}
<?php endif; ?>
- async function favoriteSong(id) {
- document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-on.svg";
- document.getElementById("btn-favorite-" + id).onclick = () => {
- unfavoriteSong(id);
- }
- await fetch("/api/addFavorite.php?i=" + id);
-
- window.parent.redownloadFavorites();
- }
-
- async function unfavoriteSong(id) {
- document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-off.svg";
- document.getElementById("btn-favorite-" + id).onclick = () => {
- favoriteSong(id);
- }
- await fetch("/api/removeFavorite.php?i=" + id);
-
- <?php if (isset($favoritesList)): ?>
- location.reload();
- <?php endif; ?>
-
- window.parent.redownloadFavorites();
- }
-
let items = Array.from(document.getElementsByClassName("track")).map(i => { return { title: i.getAttribute("data-item-track"), artist: i.getAttribute("data-item-artist"), id: i.id } });
const fuse = new Fuse(items, {
diff --git a/app/lyrics.php b/app/lyrics.php
index fbdca1d..4a7537d 100644
--- a/app/lyrics.php
+++ b/app/lyrics.php
@@ -59,7 +59,7 @@
</div>
<div id="lyrics-unsynced" style="display: none; position: fixed; inset: 16px; overflow: auto;"></div>
- <div id="lyrics-synced" style="display: none; position: fixed; left: 16px; right: 16px; top: 0; bottom: 0; z-index: 5;"></div>
+ <div id="lyrics-synced" style="text-align: center; display: none; position: fixed; left: 16px; right: 16px; top: 0; bottom: 0; z-index: 5;"></div>
<div id="lyrics-synced-fade" style="display: none; position: fixed; inset: 0; z-index: 10; background-image: linear-gradient(180deg, rgba(255,0,0,0) 25%, rgba(255,255,255,1) 100%);"></div>
</div>
@@ -88,6 +88,10 @@
document.getElementById("not-playing").style.display = "none";
if (!window.lyrics[lastID]) {
+ window.lyricsLoadTimeout = setTimeout(() => {
+ location.reload();
+ }, 10000);
+
try {
window.lyrics[lastID] = await (await fetch("/api/lyrics.php?id=" + lastID)).json()
} catch (e) {
@@ -97,6 +101,8 @@
}
}
+ clearTimeout(window.lyricsLoadTimeout);
+
if (window.lyrics[lastID] && window.lyrics[lastID].payload) {
if (window.lyrics[lastID].synced) {
document.getElementById("lyrics-synced").style.display = "";
diff --git a/app/modal.php b/app/modal.php
new file mode 100644
index 0000000..b939996
--- /dev/null
+++ b/app/modal.php
@@ -0,0 +1,48 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport"
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <title>modal</title>
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/assets/dark.css" rel="stylesheet">
+ <link href="/assets/styles.css" rel="stylesheet">
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
+ <script src="/assets/localforage.min.js"></script>
+ <script src="/assets/fuse.min.js"></script>
+ <script src="/assets/shortcuts.js"></script>
+ <link id="native-css" href="/assets/native.css" rel="stylesheet" disabled>
+</head>
+<body class="crossplatform" style="background-color: transparent !important;">
+ <script>
+ if (navigator.userAgent.includes("MistNative/darwin") || navigator.userAgent.includes("MistNative/win32")) {
+ document.getElementById("native-css").disabled = false;
+ document.body.classList.remove("crossplatform");
+ }
+ </script>
+ <div class="modal fade" id="modal">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title" id="modal-title">Title</h4>
+ <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
+ </div>
+
+ <div class="modal-body" style="padding: 0;">
+ <iframe id="modal-frame" style="width: 100%; border-bottom-right-radius: 0.5rem; margin-bottom: -6px; border-bottom-left-radius: 0.5rem; height: calc(100vh - 130px);"></iframe>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script>
+ window._modal = new bootstrap.Modal(document.getElementById("modal"));
+
+ document.getElementById("modal").addEventListener("hidden.bs.modal", () => {
+ window.parent.document.getElementById("modal").style.display = "none";
+ });
+ </script>
+</body>
+</html> \ No newline at end of file
diff --git a/app/navigation.php b/app/navigation.php
index f07c38f..00d1457 100644
--- a/app/navigation.php
+++ b/app/navigation.php
@@ -51,6 +51,9 @@
<div id="lyrics" class="navigation-item" onclick="window.parent.showLyrics();">
<img class="icon" alt="" src="/assets/icons/lyrics.svg" style="vertical-align: middle; width: 32px;"><span style="vertical-align: middle; margin-left: 5px;" class="navigation-desktop">Lyrics</span>
</div>
+ <div id="queue" class="navigation-item" onclick="window.parent.openUI('queue');">
+ <img class="icon" alt="" src="/assets/icons/playlist.svg" style="vertical-align: middle; width: 32px;"><span style="vertical-align: middle; margin-left: 5px;" class="navigation-desktop">Queue</span>
+ </div>
<div id="settings" class="navigation-item" onclick="window.parent.openUI('settings');">
<img class="icon" alt="" src="/assets/icons/settings.svg" style="vertical-align: middle; width: 32px;"><span style="vertical-align: middle; margin-left: 5px;" class="navigation-desktop">Settings</span>
</div>
diff --git a/app/player-mobile.php b/app/player-mobile.php
index cab8ada..8308eda 100644
--- a/app/player-mobile.php
+++ b/app/player-mobile.php
@@ -26,7 +26,7 @@
<div id="act-2" onclick="window.parent.hideMobilePlayer();" style="position: fixed; z-index: 9999999; bottom: 0; right: 0; top: 0; width: 20px;"></div>
<div id="album-art-bg" style="position: fixed;inset: 0;background-position: center;background-size: cover; z-index: 5;"></div>
- <div id="album-art-bg2" style="z-index: 10; position: fixed;inset: 0; backdrop-filter: blur(100px);"></div>
+ <div id="album-art-bg2" style="background-color: rgba(0, 0, 0, .1); z-index: 10; position: fixed;inset: 0; backdrop-filter: blur(100px);"></div>
<div id="player" class="bg-white mobile-player" style="background-color: transparent !important; color: white;position: fixed; bottom: 0; left: 0; right: 0; height: 64px; z-index: 9999;">
<div class="container" style="display: grid; grid-template-columns: 1fr 1.5fr 1fr;">
<div id="buttons" style="height: 48px;position: fixed;width: max-content;left: 0;right: 0;margin: 8px auto;bottom: 30px;">
diff --git a/app/queue.php b/app/queue.php
new file mode 100644
index 0000000..86fda0e
--- /dev/null
+++ b/app/queue.php
@@ -0,0 +1,78 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; ?>
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport"
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <title>queue</title>
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/assets/dark.css" rel="stylesheet">
+ <link href="/assets/styles.css" rel="stylesheet">
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
+ <script src="/assets/localforage.min.js"></script>
+ <script src="/assets/fuse.min.js"></script>
+ <script src="/assets/shortcuts.js"></script>
+ <link id="native-css" href="/assets/native.css" rel="stylesheet" disabled>
+</head>
+<body class="crossplatform">
+ <script>
+ if (navigator.userAgent.includes("MistNative/darwin") || navigator.userAgent.includes("MistNative/win32")) {
+ document.getElementById("native-css").disabled = false;
+ document.body.classList.remove("crossplatform");
+ }
+ </script>
+ <div class="container">
+ <br>
+ <h2 style="margin-top: 10px; margin-bottom: 20px; margin-left: 10px;">Queue</h2>
+ <div class="list-group" style="margin-left: 10px; margin-top: 20px;" id="main-list"></div>
+ <div class="text-muted" style="margin-left: 10px; margin-top: 20px; display: none;" id="empty">
+ There are no songs playing next. To add songs to the queue, browse your library and select Add to queue.
+ </div>
+ </div>
+
+ <script>
+ function refreshQueue() {
+ let list = window.parent.playlist.slice(window.parent.currentPlaylistPosition + 1);
+
+ if (list.length === 0) {
+ document.getElementById('main-list').style.display = "none";
+ document.getElementById('empty').style.display = "";
+ } else {
+ document.getElementById('main-list').style.display = "";
+ document.getElementById('empty').style.display = "none";
+
+ document.getElementById('main-list').innerHTML = list.map(i => [window.parent.songs[i], i]).map((i, j) => `
+ <div data-item-track="${i[0].title}" data-item-artist="${i[0].artist}" id="item-${i[1]}" class="list-group-item track" style="display: grid; grid-template-columns: 32px 1fr max-content;">
+ <div style="opacity: .5; display: flex; align-items: center; justify-content: left;"></div>
+ <div style="display: grid; grid-template-columns: 48px 1fr; grid-gap: 10px;">
+ <img src="/assets/content/${i[1]}.jpg" style="width: 48px; height: 48px;">
+ <div style="width: 50vw; height: 3em; display: flex; align-items: center; justify-content: left;">
+ <div style="max-width: 100%;"><div style="max-width: 100%; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;">${i[0].title}</div><div style="max-width: 100%; opacity: .5; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;">${i[0].artist}</div></div>
+ </div>
+ </div>
+ <div class="list-actions">
+ <span onclick="removeSong(${j + window.parent.currentPlaylistPosition + 1});" class="player-btn" style="border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; height: 48px; width: 48px;" id="btn-remove-${i[1]}">
+ <img class="icon" alt="" src="/assets/icons/remove.svg" style="pointer-events: none; width: 32px; height: 32px;" id="btn-remove-${i[1]}-icon">
+ </span>
+ <span onclick="window.parent.playSong('${i[1]}', 'keep');" class="player-btn" style="border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; height: 48px; width: 48px;" id="btn-play-${i[1]}">
+ <img class="icon" alt="" src="/assets/icons/play.svg" style="pointer-events: none; width: 32px; height: 32px;" id="btn-play-${i[1]}-icon">
+ </span>
+ </div>
+ </div>
+ `).join("");
+ }
+ }
+
+ function removeSong(index) {
+ window.parent.playlist.splice(index, 1);
+ refreshQueue();
+ }
+
+ refreshQueue();
+ </script>
+
+ <br><br>
+</body>
+</html> \ No newline at end of file
diff --git a/app/search.php b/app/search.php
new file mode 100644
index 0000000..2f5f164
--- /dev/null
+++ b/app/search.php
@@ -0,0 +1,91 @@
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php";
+
+if (!isset($_GET["q"]) || trim($_GET["q"]) === "" || trim(preg_replace("/ +/m", " ", preg_replace("/[^a-z\d ]/m", " ", strtolower($_GET["q"])))) === "") {
+ header("Location: explore.php");
+ die();
+}
+
+?>
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport"
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <title>search</title>
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/assets/dark.css" rel="stylesheet">
+ <link href="/assets/styles.css" rel="stylesheet">
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
+ <script src="/assets/localforage.min.js"></script>
+ <script src="/assets/fuse.min.js"></script>
+ <script src="/assets/shortcuts.js"></script>
+ <link id="native-css" href="/assets/native.css" rel="stylesheet" disabled>
+</head>
+<body class="crossplatform">
+ <script>
+ if (navigator.userAgent.includes("MistNative/darwin") || navigator.userAgent.includes("MistNative/win32")) {
+ document.getElementById("native-css").disabled = false;
+ document.body.classList.remove("crossplatform");
+ }
+ </script>
+ <div class="container">
+ <br>
+ <h2 style="margin-top: 10px; margin-bottom: 20px; margin-left: 10px;">Search results for "<?= strip_tags($_GET["q"]) ?>"</h2>
+ <?php
+
+ global $albums; global $songs;
+
+ function getMatches($item) {
+ $n = 0;
+ $query = preg_replace("/ +/m", " ", preg_replace("/[^a-z\d ]/m", " ", strtolower($_GET["q"])));
+
+ if (isset($item["title"]) && str_contains(preg_replace("/ +/m", " ", preg_replace("/[^a-z\d ]/m", " ", strtolower($item["title"]))), $query)) $n++;
+ if (isset($item["artist"]) && str_contains(preg_replace("/ +/m", " ", preg_replace("/[^a-z\d ]/m", " ", strtolower($item["artist"]))), $query)) $n++;
+ if (isset($item["album"]) && str_contains(preg_replace("/ +/m", " ", preg_replace("/[^a-z\d ]/m", " ", strtolower($item["album"]))), $query)) $n++;
+
+ return $n;
+ }
+
+ $albums = array_filter($albums, function ($i) {
+ return getMatches($i) > 0;
+ });
+
+ uasort($albums, function ($a, $b) {
+ return strcmp($a["title"], $b["title"]);
+ });
+
+ uasort($albums, function ($a, $b) {
+ return strcmp($a["artist"], $b["artist"]);
+ });
+
+ uasort($albums, function ($a, $b) {
+ return getMatches($b) - getMatches($a);
+ });
+
+ $songs = array_filter($songs, function ($i) {
+ return getMatches($i) > 0;
+ });
+
+ uasort($songs, function ($a, $b) {
+ return getMatches($b) - getMatches($a);
+ });
+
+ ?>
+
+ <div id="album-grid" style="display: grid; grid-template-columns: repeat(5, 1fr);">
+ <?php foreach ($albums as $id => $album): ?>
+ <a id="album-<?= $id ?>" data-item-track="<?= $album["title"] ?>" data-item-artist="<?= $album["artist"] ?>" href="listing.php?a=<?= $id ?>" style="padding: 10px; color: inherit; text-decoration: inherit;" class="album">
+ <img class="album-list-art" alt="" src="/assets/content/<?= $id ?>.jpg" style="width: 100%; aspect-ratio: 1; border-radius: 5px; margin-bottom: 5px;">
+ <div class="album-list-item" style="max-width: calc(80vw / 5); white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;"><?= $album["title"] ?></div>
+ <div class="album-list-item" style="max-width: calc(80vw / 5); opacity: .5; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;"><?= $album["artist"] ?></div>
+ </a>
+ <?php endforeach; ?>
+ </div>
+ <?php global $songs; displayList($songs); ?>
+ </div>
+
+ <br><br>
+</body>
+</html> \ No newline at end of file
diff --git a/app/settings.php b/app/settings.php
index 4c2a287..a80fad1 100644
--- a/app/settings.php
+++ b/app/settings.php
@@ -60,7 +60,7 @@
<?php else: ?>
<div class="text-muted">
<img class="icon" src="/assets/logo-transparent.svg" style="vertical-align: middle; filter: grayscale(1) invert(1); width: 32px; height: 32px;" alt="">
- <span style="vertical-align: middle;">Mist version <?= str_replace("|", " ", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/version")) ?> (build <?= file_get_contents("/opt/spotify/build.txt") ?>) · © <?= date('Y') ?> Equestria.dev</span>
+ <span style="vertical-align: middle;">Mist version <?= str_replace("|", " ", file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/version")) ?> (build <?= trim(file_exists("/opt/spotify/build.txt") ? file_get_contents("/opt/spotify/build.txt") : "trunk") ?>) · © <?= date('Y') ?> Equestria.dev</span>
</div>
<?php endif; ?>
</div>
diff --git a/assets/.DS_Store b/assets/.DS_Store
index eb23c80..5cbb3b6 100644
--- a/assets/.DS_Store
+++ b/assets/.DS_Store
Binary files differ
diff --git a/assets/dark.css b/assets/dark.css
index e969545..8279657 100644
--- a/assets/dark.css
+++ b/assets/dark.css
@@ -11,16 +11,16 @@
filter: brightness(0%) invert(1) grayscale(1) !important;
}
- .navigation-item.active, .navigation-item:active {
+ div.navigation-item.active, div.navigation-item:active {
background-color: rgba(255, 255, 255, .25) !important;
}
.navigation-item:hover {
- background-color: rgba(255, 255, 255, .1);
+ background-color: rgba(255, 255, 255, .1) !important;
}
.album:hover {
- background-color: rgba(255, 255, 255, .1);
+ background-color: rgba(255, 255, 255, .1) !important;
}
#player.bg-white {
@@ -32,11 +32,19 @@
}
.player-btn:hover {
- background-color: rgba(255, 255, 255, .1);
+ background-color: rgba(255, 255, 255, .1) !important;
}
.player-btn:active {
- background-color: rgba(255, 255, 255, .25);
+ background-color: rgba(255, 255, 255, .25) !important;
+ }
+
+ .dropdown-menu {
+ filter: invert(1) hue-rotate(180deg);
+ }
+
+ .dropdown-item:hover {
+ background-color: rgba(0, 0, 0, .25);
}
.desktop-player #album-art[src="/assets/nothing.svg"] {
@@ -52,16 +60,22 @@
color: #666 !important;
}
- #filter, .list-group-item, .btn, .form-check-input, .link {
+ #filter, .btn, .form-check-input, .link, .btn-close {
filter: invert(1) hue-rotate(180deg);
}
- .list-group-item img {
- filter: invert(1) hue-rotate(180deg);
+ .list-group-item .icon {
+ filter: invert(1) !important;
}
- .list-group-item .icon {
- filter: none !important;
+ .list-group-item {
+ background: #050505;
+ color: white;
+ border-color: #333;
+ }
+
+ .dropdown-menu.show {
+ z-index: 999999 !important;
}
.desktop-player #seekbar-container {
@@ -83,4 +97,22 @@
#lyrics-outer #loading {
background-color: transparent !important;
}
+
+ body.web {
+ background-color: black !important;
+ }
+
+ .dropdown-item img {
+ filter: none !important;
+ }
+
+
+ .modal-header {
+ border-bottom: 1px solid #353738;
+ }
+
+ .modal-content {
+ border: 1px solid rgba(255, 255, 255, .2);
+ background-color: #111;
+ }
} \ No newline at end of file
diff --git a/assets/icons/add.svg b/assets/icons/add.svg
new file mode 100644
index 0000000..37cf0c2
--- /dev/null
+++ b/assets/icons/add.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M453-371h54v-122h122v-54H507v-122h-54v122H331v54h122v122ZM344-140v-88H192q-36.725 0-61.363-24.637Q106-277.275 106-314v-420q0-36.725 24.637-61.362Q155.275-820 192-820h576q36.725 0 61.362 24.638Q854-770.725 854-734v420q0 36.725-24.638 61.363Q804.725-228 768-228H616v88H344ZM192-282h576q12 0 22-10t10-22v-420q0-12-10-22t-22-10H192q-12 0-22 10t-10 22v420q0 12 10 22t22 10Zm-32 0v-484 484Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/download.svg b/assets/icons/download.svg
new file mode 100644
index 0000000..2e1cd9c
--- /dev/null
+++ b/assets/icons/download.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M479-336 315-500l39-37 98 98v-341h54v341l98-98 39 37-164 164ZM266-180q-36.725 0-61.363-24.637Q180-229.275 180-266v-90h54v90q0 12 10 22t22 10h428q12 0 22-10t10-22v-90h54v90q0 37-24.638 61.5Q730.725-180 694-180H266Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/info.svg b/assets/icons/info.svg
new file mode 100644
index 0000000..5cd0fe5
--- /dev/null
+++ b/assets/icons/info.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M454-290h54v-230h-54v230Zm25.825-296q12.675 0 21.425-8.575 8.75-8.574 8.75-21.25 0-12.675-8.575-21.425-8.574-8.75-21.25-8.75-12.675 0-21.425 8.575-8.75 8.574-8.75 21.25 0 12.675 8.575 21.425 8.574 8.75 21.25 8.75Zm.349 486q-78.814 0-148.212-29.911-69.399-29.912-120.734-81.188-51.336-51.277-81.282-120.595Q100-401.012 100-479.826q0-79.07 29.97-148.694 29.971-69.623 81.348-121.126 51.378-51.502 120.594-80.928Q401.128-860 479.826-860q79.06 0 148.676 29.391 69.615 29.392 121.13 80.848 51.516 51.457 80.942 121.018Q860-559.181 860-480.091q0 79.091-29.391 148.149-29.392 69.059-80.835 120.496-51.443 51.436-120.987 81.441Q559.244-100 480.174-100ZM480-154q136.513 0 231.256-94.744Q806-343.487 806-480t-94.744-231.256Q616.513-806 480-806t-231.256 94.744Q154-616.513 154-480t94.744 231.256Q343.487-154 480-154Zm0-326Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/menu.svg b/assets/icons/menu.svg
new file mode 100644
index 0000000..b182f03
--- /dev/null
+++ b/assets/icons/menu.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M479.841-186q-17.391 0-29.616-12.384Q438-210.769 438-228.159q0-17.391 12.384-29.616Q462.769-270 480.159-270q17.391 0 29.616 12.384Q522-245.231 522-227.841q0 17.391-12.384 29.616Q497.231-186 479.841-186Zm0-252q-17.391 0-29.616-12.384Q438-462.769 438-480.159q0-17.391 12.384-29.616Q462.769-522 480.159-522q17.391 0 29.616 12.384Q522-497.231 522-479.841q0 17.391-12.384 29.616Q497.231-438 479.841-438Zm0-252q-17.391 0-29.616-12.384Q438-714.769 438-732.159q0-17.391 12.384-29.616Q462.769-774 480.159-774q17.391 0 29.616 12.384Q522-749.231 522-731.841q0 17.391-12.384 29.616Q497.231-690 479.841-690Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/playlist.svg b/assets/icons/playlist.svg
index 471d3f2..76c1216 100644
--- a/assets/icons/playlist.svg
+++ b/assets/icons/playlist.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M631.765-180Q589-180 558.5-210.11 528-240.221 528-283.235q0-43.848 30.333-74.807Q588.667-389 632-389q14.548 0 27.774 7T684-367v-333h176v77H737v340q0 42.917-30.694 72.958Q675.613-180 631.765-180ZM140-341v-53h295v53H140Zm0-153v-53h444v53H140Zm0-153v-53h444v53H140Z"/></svg> \ No newline at end of file
+<svg fill="#79c2f6" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M631.765-180Q589-180 558.5-210.11 528-240.221 528-283.235q0-43.848 30.333-74.807Q588.667-389 632-389q14.548 0 27.774 7T684-367v-333h176v77H737v340q0 42.917-30.694 72.958Q675.613-180 631.765-180ZM140-341v-53h295v53H140Zm0-153v-53h444v53H140Zm0-153v-53h444v53H140Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/playnext.svg b/assets/icons/playnext.svg
new file mode 100644
index 0000000..78824a5
--- /dev/null
+++ b/assets/icons/playnext.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m790-77-35-35 126-126-126-126 35-35 161 161L790-77Zm-446-63v-88H192q-36.725 0-61.363-24.637Q106-277.275 106-314v-420q0-36.725 24.637-61.362Q155.275-820 192-820h576q36.725 0 61.362 24.638Q854-770.725 854-734v252h-54v-252q0-12-10-22t-22-10H192q-12 0-22 10t-10 22v420q0 12 10 22t22 10h495v54h-82v88H344Zm111-234h54v-122h122v-54H509v-122h-54v122H333v54h122v122Zm-295 92v-484 484Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/remove.svg b/assets/icons/remove.svg
new file mode 100644
index 0000000..e24e387
--- /dev/null
+++ b/assets/icons/remove.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M220-454v-54h520v54H220Z"/></svg> \ No newline at end of file
diff --git a/assets/icons/settings.svg b/assets/icons/settings.svg
index 759e748..1e37786 100644
--- a/assets/icons/settings.svg
+++ b/assets/icons/settings.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m393-100-16-119q-15-5-36.779-16.455Q318.441-246.909 305-260l-112 47-86-156 92-71q-1-9.926-2.5-21t-1.5-21q0-8.407 1.5-18.5T199-524l-92-69 86-152 107 44q17-14 38-25.5t39-18.5l16-117h174l15 119q21 9 38.5 18.5T656-700l111-45 86 152-98 74q3 11 3.5 21t.5 18q0 7-1 17t-2 24l94 70-86 156-113-48q-17 14-33.5 24T583-221l-16 121H393Zm46-54h78.849L533-264q31-8 55.913-22.085Q613.827-300.17 641-326l98 42 41-68-86-66q5-18 7-33.23 2-15.23 2-30.5 0-16.27-1.5-29.27t-6.5-33l87-66-39-68-102 41q-17-20-49.393-38.795T532-700l-11-108h-83l-10 106q-34 7-61 22.5T314-637l-97-41-41 68 84 65q-5 17-7 33t-2 30.424Q251-469 253-453t6 36l-83 65 41 68 97-41q28 26 54.5 40.5T427-262l12 108Zm36-212q48.6 0 82.3-33.7Q591-433.4 591-482q0-48.6-33.7-82.3Q523.6-598 475-598q-48 0-82 33.7T359-482q0 48.6 34 82.3 34 33.7 82 33.7Zm4-115Z"/></svg> \ No newline at end of file
+<svg fill="#79c2f6" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m393-100-16-119q-15-5-36.779-16.455Q318.441-246.909 305-260l-112 47-86-156 92-71q-1-9.926-2.5-21t-1.5-21q0-8.407 1.5-18.5T199-524l-92-69 86-152 107 44q17-14 38-25.5t39-18.5l16-117h174l15 119q21 9 38.5 18.5T656-700l111-45 86 152-98 74q3 11 3.5 21t.5 18q0 7-1 17t-2 24l94 70-86 156-113-48q-17 14-33.5 24T583-221l-16 121H393Zm46-54h78.849L533-264q31-8 55.913-22.085Q613.827-300.17 641-326l98 42 41-68-86-66q5-18 7-33.23 2-15.23 2-30.5 0-16.27-1.5-29.27t-6.5-33l87-66-39-68-102 41q-17-20-49.393-38.795T532-700l-11-108h-83l-10 106q-34 7-61 22.5T314-637l-97-41-41 68 84 65q-5 17-7 33t-2 30.424Q251-469 253-453t6 36l-83 65 41 68 97-41q28 26 54.5 40.5T427-262l12 108Zm36-212q48.6 0 82.3-33.7Q591-433.4 591-482q0-48.6-33.7-82.3Q523.6-598 475-598q-48 0-82 33.7T359-482q0 48.6 34 82.3 34 33.7 82 33.7Zm4-115Z"/></svg> \ No newline at end of file
diff --git a/assets/logo-display.ico b/assets/logo-display.ico
new file mode 100644
index 0000000..1860aa0
--- /dev/null
+++ b/assets/logo-display.ico
Binary files differ
diff --git a/assets/logo-mac.png b/assets/logo-mac.png
new file mode 100644
index 0000000..29d8a1e
--- /dev/null
+++ b/assets/logo-mac.png
Binary files differ
diff --git a/assets/logo.icns b/assets/logo.icns
new file mode 100644
index 0000000..f3c9a2d
--- /dev/null
+++ b/assets/logo.icns
Binary files differ
diff --git a/assets/styles.css b/assets/styles.css
index de4d33f..100ea0d 100644
--- a/assets/styles.css
+++ b/assets/styles.css
@@ -370,7 +370,7 @@ iframe {
}
#navigation-container {
- grid-template-columns: repeat(5, 1fr) !important;
+ grid-template-columns: repeat(6, 1fr) !important;
display: grid !important;
margin-top: 2px;
}
@@ -407,6 +407,14 @@ iframe {
}
}
+@media (min-height: 64px) {
+ #info-grid-title, #info-grid-info {
+ position: relative;
+ top: 5px;
+ z-index: -1;
+ }
+}
+
@media (max-width: 823px) {
#lyrics-outer, #lyrics-outer * {
color: rgba(255, 255, 255, .75);
@@ -429,4 +437,12 @@ iframe {
#badges {
-webkit-app-region: drag;
+}
+
+.dropdown-item:active img {
+ filter: invert(1);
+}
+
+body.web {
+ background-color: white;
} \ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..79c358a
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+cd desktop
+#npx electron-packager . Mist --asar --overwrite --platform=darwin --arch=x64 --icon=../assets/logo.icns --out=../build
+npx electron-packager . Mist --asar --overwrite --platform=darwin --arch=arm64 --icon=../assets/logo.icns --out=../build
+#npx electron-packager . Mist --asar --overwrite --platform=linux --arch=x64 --icon=../assets/logo-display.png --out=../build
+#npx electron-packager . Mist --asar --overwrite --platform=linux --arch=arm64 --icon=../assets/logo-display.png --out=../build
+npx electron-packager . Mist --asar --overwrite --platform=win32 --arch=x64 --icon=../assets/logo-display.ico --out=../build
+#npx electron-packager . Mist --asar --overwrite --platform=win32 --arch=arm64 --icon=../assets/logo-display.ico --out=../build \ No newline at end of file
diff --git a/desktop/package.json b/desktop/package.json
index 235d0c9..d27d3d7 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -1,4 +1,5 @@
{
+ "main": "main.js",
"dependencies": {
"electron": "^27.0.2",
"electron-packager": "^17.1.2"
diff --git a/icons/maskable.png b/icons/maskable.png
index 3b305e0..4bf01ce 100644
--- a/icons/maskable.png
+++ b/icons/maskable.png
Binary files differ
diff --git a/icons/maskable.svg b/icons/maskable.svg
index aa4f35a..72082a7 100644
--- a/icons/maskable.svg
+++ b/icons/maskable.svg
@@ -13,62 +13,50 @@
.st7{fill:#4D426A;}
.st8{fill:#4B4168;}
</style>
-<rect x="0" y="0" class="st0" width="512" height="512"/>
+<rect class="st0" width="512" height="512"/>
<g>
- <path class="st1" d="M281.63,222.68c13.9-18.51,28.16-36.7,45.6-52.1c15.57-13.74,32.28-25.55,52.97-30.4
- c7.16-1.68,14.34-1.92,21.57-0.42c10.59,2.21,17.55,9.86,18.84,20.59c1.07,8.92-0.61,17.59-2.45,26.21
- c-5.54,25.88-11.3,51.71-22.15,76.04c-3.36,7.52-7.29,14.78-12.99,20.87c-3.66,3.9-7.7,7.27-13.02,8.68
- c-2.09,2.82-4.57,1.57-6.83,0.46c-19.4-9.57-40.36-10.51-61.37-11.09c-4.5-0.12-9.01-0.1-13.52,0.01
- c-2.45,0.06-4.67-0.46-6.47-2.27c-1.65-1.85-2.32-4.19-2.48-6.49c-0.61-8.5-3.72-16.39-5.74-24.54c-1.15-4.66-1.14-8.85,2.15-12.69
- c1.85-2.16,2.3-4.93,2.82-7.63C278.96,225.81,279.19,223.6,281.63,222.68z"/>
- <path class="st1" d="M131.67,294.79c-4.4-2.11-8.67-4.38-11.32-8.76c-8.45-11.8-15-24.6-20.13-38.16
- c-4.3-11.36-7.68-22.98-9.84-34.93c-1.53-8.47-3.33-16.9-5.78-25.12c-2.73-9.18-3.47-18.28-1.9-27.65
- c2.31-9.82,9.52-13.94,18.59-15.48c14.63-2.48,28.44,0.54,41.66,6.9c20.29,9.77,36.79,24.41,52.12,40.54
- c9.46,9.95,17.77,20.88,26.47,31.48c0.19,0.02,0.54,0.01,0.56,0.08c2.49,9.52,12.62,16.89,7.4,28.67
- c-2.34,5.28-3.49,11.15-4.01,17.06c-0.28,3.24-0.39,6.7-2.83,9.38c-2.63,2.55-5.96,2.55-9.3,2.6c-18.55,0.26-37,1.42-55.04,6.16
- c-6.62,1.74-12.81,4.63-19.13,7.15C136.74,295.68,134.2,297.42,131.67,294.79z"/>
- <path class="st2" d="M221.8,277.72c1.09-10.87,2.8-21.61,7.29-31.7c0.55-1.24,1.56-2.76,0.15-3.71c-6.79-4.55-6.51-11.9-7.69-18.69
- c3.57-7.61,6.51-15.64,14.14-20.49c1.49-0.95,1.36-2.57,0.95-4.25c-4.4-18.06-12.28-34.27-25.16-47.88
- c-3.04-3.21-6.39-5.32-11.02-6c-9.66-1.4-15.41-9.02-14.92-18.76c0.34-6.63,5.63-10.21,11.95-7.89
- c7.02,2.58,11.35,7.75,12.62,15.04c1.02,5.87,3.8,10.34,7.89,14.6c12.37,12.84,20.42,28.22,24.75,45.46
- c1.19,4.74,3.16,6.89,8.13,5.47c1.09-0.31,2.39-0.32,3.5-0.07c4.37,1,5.79-1.14,6.57-5.11c3.49-17.68,10.87-33.56,23.26-46.77
- c3.93-4.19,6.85-8.17,8.16-14.19c1.66-7.63,7.52-12.67,15.65-14.22c4.37-0.83,8.48-0.26,11,3.64c2.65,4.1,1.73,8.42-1.25,12.03
- c-4.77,5.79-10.85,9.7-18.38,10.68c-2.97,0.38-5.1,1.56-7.05,3.66c-13.54,14.54-20.78,32.09-24.73,51.24
- c-0.41,2.01-0.27,4.01,1.51,5.36c5.98,4.55,9.17,11.07,12.51,17.49c-0.47,6.28-1.06,12.49-5.85,17.34
- c-1.23,1.24-1.02,2.85-0.55,4.43c3.47,11.45,6.12,23.1,8.3,34.86c3.73,4.21,3.13,9.59,3.49,14.52c1.24,17.12-1.3,33.87-6.05,50.32
- c-0.44,1.52-0.9,3.03-2.59,3.66c-2.1,1.12-2.48,3.42-3.55,5.23c-2.09,3.53-4.23,7.01-7.13,9.97c-8.83,9.04-18.82,9.1-27.55-0.04
- c-3.22-3.37-6.08-7.1-9.1-10.66c-2.92-0.93-3.28-3.61-4.1-5.98c-6.7-19.46-8.91-39.5-8.17-59.99
- C218.92,282.97,220.11,280.35,221.8,277.72z"/>
- <path class="st3" d="M221.8,277.72c-1.55,25.44,0.95,50.37,9.26,74.59c-1.99,11.8-3.82,23.59-10.35,34.07
- c-7.11,11.41-17.32,16.64-30.58,16.13c-9.4-0.37-14.44-4.42-16.81-13.48c-2.59-9.92-3.81-20.01-3.33-30.28
- c0.41-8.81,0.36-8.86-7.99-5.23c-8.12,3.52-16.47,6.3-25.13,8.18c-4.28,0.93-8.55,1.1-12.84,0.16
- c-10.19-2.25-15.83-10.02-14.06-20.33c3.01-17.48,9.24-33.57,21.68-46.73c7.64-2.91,15.15-6.24,22.95-8.63
- c19.45-5.96,39.52-7.41,59.75-7.42C216.89,278.73,219.47,279.14,221.8,277.72z"/>
- <path class="st3" d="M278.39,347.81c0.16-2.13-0.06-4.38,0.55-6.37c5.97-19.43,7.01-39.19,4.3-59.25c-0.13-0.93,0.19-1.92,0.3-2.88
- c22.13-0.9,44.11-0.35,65.78,5.07c7.25,1.81,13.38,6.28,20.67,7.79c3.6,5.59,8.96,9.75,12.41,15.52
- c4.67,7.82,8.56,15.92,9.93,24.96c2.25,14.87-6.15,24.04-21.05,23.02c-10.48-0.72-20.38-3.82-29.91-8.16
- c-5.8-2.64-5.66-2.67-5.33,3.5c0.54,10.18,0.89,20.33-1.12,30.46c-1.69,8.52-7.08,12.87-15.15,14.19
- c-9.27,1.51-17.42-0.9-24.22-7.65C284.35,376.9,279.62,363.12,278.39,347.81z"/>
- <path class="st3" d="M356.69,256.64c-9.32,2.05-21.03,1.65-32.76,0.56c-3.27-0.31-4.93-1.99-5.11-5.26
- c-0.82-15.35-0.04-30.54,5.18-45.18c2.64-7.39,8.4-11.07,15.95-12.15c5.3-0.75,10.09,2.48,11.68,7.65c1.3,4.24,0.8,8.49,0.26,12.8
- c-0.99,8-0.89,8.02,6.74,5.99c3.6-0.96,7.17-1.92,10.96-1.82c7.82,0.21,11.79,4.81,10.74,12.59
- C378.9,242.48,369.4,253.24,356.69,256.64z"/>
- <path class="st4" d="M367.18,196.96c-2.51-9.58,4.72-22.51,14.23-25.42c6.54-2,11.81,1.12,13.15,7.79
- c1.9,9.43-5.58,21.9-14.81,24.71C373.78,205.85,368.77,203.03,367.18,196.96z"/>
- <path class="st3" d="M180.35,219.06c2.43,11.62,3.75,23.44,2.91,35.48c-0.24,3.39-1.69,4.99-4.95,5.29
- c-10.73,1-21.45,2.25-32.22,0.43c-12.42-2.1-23.27-13.26-24.88-25.75c-0.85-6.54,3.28-11.1,10.58-10.93
- c4.46,0.1,9.01,0.76,13.31,1.94c4.07,1.12,5.02,0,4.5-3.83c-0.52-3.87-1.21-7.8-1.07-11.67c0.38-10.02,8.12-14.55,17.6-10.79
- C175.13,202.8,177.6,210.91,180.35,219.06z"/>
- <path class="st5" d="M134.84,193.65c0.35,1.19,0.7,4.06,0.05,7.03c-1.47,6.76-7.43,9.96-13.87,7.39
- c-7.75-3.09-14.39-13.08-14.23-21.4c0.19-9.45,8.16-13.94,16.41-9.21C128.93,180.75,132.68,185.58,134.84,193.65z"/>
- <path class="st6" d="M268.28,304.04c0.35,1.11,0.22,2.04-0.58,2.77c-1.05,0.95-2.21,0.78-3.18-0.04
- c-7.25-6.07-14.33-4.77-21.43,0.31c-1.15,0.83-2.54,1.19-3.69-0.14c-0.92-1.06-0.54-2.1,0.11-3.2c4.61-7.77,23.66-8.22,28.27-0.64
- C267.98,303.44,268.14,303.79,268.28,304.04z"/>
- <path class="st7" d="M250.87,274.88c4.94-1.08,9.31,0.92,12.89,5.04c0.93,1.07,1.67,2.42,0.72,3.7c-1.12,1.52-2.35,0.63-3.45-0.31
- c-5.11-4.37-10.15-4.29-15.15,0.2c-1.01,0.9-2.21,2.12-3.51,0.89c-1.37-1.3-0.68-2.87,0.34-4.19
- C244.66,277.67,247.15,275.89,250.87,274.88z"/>
- <path class="st8" d="M265.33,328.25c0.25,1.23,0.45,2.22-0.49,2.92c-0.97,0.72-1.92,0.31-2.64-0.37
- c-5.57-5.27-10.85-4.21-16.01,0.65c-0.72,0.68-1.66,1.11-2.67,0.56c-1.02-0.55-1.06-1.52-0.85-2.53c0.66-3.28,7.15-7.5,11.75-7.49
- C259.31,322.01,263.02,324.16,265.33,328.25z"/>
+ <path class="st1" d="M276.9,228.5c11.7-15.6,23.8-31,38.5-44c13.2-11.6,27.3-21.6,44.7-25.7c6-1.4,12.1-1.6,18.2-0.4
+ c8.9,1.9,14.8,8.3,15.9,17.4c0.9,7.5-0.5,14.9-2.1,22.1c-4.7,21.9-9.5,43.7-18.7,64.2c-2.8,6.4-6.2,12.5-11,17.6
+ c-3.1,3.3-6.5,6.1-11,7.3c-1.8,2.4-3.9,1.3-5.8,0.4c-16.4-8.1-34.1-8.9-51.8-9.4c-3.8-0.1-7.6-0.1-11.4,0c-2.1,0.1-3.9-0.4-5.5-1.9
+ c-1.4-1.6-2-3.5-2.1-5.5c-0.5-7.2-3.1-13.8-4.8-20.7c-1-3.9-1-7.5,1.8-10.7c1.6-1.8,1.9-4.2,2.4-6.4
+ C274.7,231.1,274.9,229.3,276.9,228.5z"/>
+ <path class="st1" d="M150.3,289.4c-3.7-1.8-7.3-3.7-9.6-7.4c-7.1-10-12.7-20.8-17-32.2c-3.6-9.6-6.5-19.4-8.3-29.5
+ c-1.3-7.2-2.8-14.3-4.9-21.2c-2.3-7.8-2.9-15.4-1.6-23.4c2-8.3,8-11.8,15.7-13.1c12.4-2.1,24,0.5,35.2,5.8
+ c17.1,8.3,31.1,20.6,44,34.2c8,8.4,15,17.6,22.4,26.6c0.2,0,0.5,0,0.5,0.1c2.1,8,10.7,14.3,6.3,24.2c-2,4.5-2.9,9.4-3.4,14.4
+ c-0.2,2.7-0.3,5.7-2.4,7.9c-2.2,2.2-5,2.2-7.9,2.2c-15.7,0.2-31.3,1.2-46.5,5.2c-5.6,1.5-10.8,3.9-16.2,6
+ C154.5,290.2,152.4,291.6,150.3,289.4z"/>
+ <path class="st2" d="M226.4,275c0.9-9.2,2.4-18.3,6.2-26.8c0.5-1,1.3-2.3,0.1-3.1c-5.7-3.8-5.5-10.1-6.5-15.8
+ c3-6.4,5.5-13.2,11.9-17.3c1.3-0.8,1.1-2.2,0.8-3.6c-3.7-15.3-10.4-28.9-21.3-40.4c-2.6-2.7-5.4-4.5-9.3-5.1
+ c-8.2-1.2-13-7.6-12.6-15.8c0.3-5.6,4.8-8.6,10.1-6.7c5.9,2.2,9.6,6.5,10.7,12.7c0.9,5,3.2,8.7,6.7,12.3
+ c10.4,10.8,17.2,23.8,20.9,38.4c1,4,2.7,5.8,6.9,4.6c0.9-0.3,2-0.3,3-0.1c3.7,0.8,4.9-1,5.5-4.3c2.9-14.9,9.2-28.3,19.6-39.5
+ c3.3-3.5,5.8-6.9,6.9-12c1.4-6.4,6.4-10.7,13.2-12c3.7-0.7,7.2-0.2,9.3,3.1c2.2,3.5,1.5,7.1-1.1,10.2c-4,4.9-9.2,8.2-15.5,9
+ c-2.5,0.3-4.3,1.3-6,3.1c-11.4,12.3-17.6,27.1-20.9,43.3c-0.3,1.7-0.2,3.4,1.3,4.5c5.1,3.8,7.7,9.4,10.6,14.8
+ c-0.4,5.3-0.9,10.6-4.9,14.6c-1,1-0.9,2.4-0.5,3.7c2.9,9.7,5.2,19.5,7,29.4c3.2,3.6,2.6,8.1,2.9,12.3c1,14.5-1.1,28.6-5.1,42.5
+ c-0.4,1.3-0.8,2.6-2.2,3.1c-1.8,0.9-2.1,2.9-3,4.4c-1.8,3-3.6,5.9-6,8.4c-7.5,7.6-15.9,7.7-23.3,0c-2.7-2.8-5.1-6-7.7-9
+ c-2.5-0.8-2.8-3-3.5-5.1c-5.7-16.4-7.5-33.4-6.9-50.7C224,279.4,225,277.2,226.4,275z"/>
+ <path class="st3" d="M226.4,275c-1.3,21.5,0.8,42.5,7.8,63c-1.7,10-3.2,19.9-8.7,28.8c-6,9.6-14.6,14.1-25.8,13.6
+ c-7.9-0.3-12.2-3.7-14.2-11.4c-2.2-8.4-3.2-16.9-2.8-25.6c0.3-7.4,0.3-7.5-6.7-4.4c-6.9,3-13.9,5.3-21.2,6.9
+ c-3.6,0.8-7.2,0.9-10.8,0.1c-8.6-1.9-13.4-8.5-11.9-17.2c2.5-14.8,7.8-28.4,18.3-39.5c6.5-2.5,12.8-5.3,19.4-7.3
+ c16.4-5,33.4-6.3,50.5-6.3C222.3,275.8,224.4,276.2,226.4,275z"/>
+ <path class="st3" d="M274.2,334.2c0.1-1.8-0.1-3.7,0.5-5.4c5-16.4,5.9-33.1,3.6-50.1c-0.1-0.8,0.2-1.6,0.3-2.4
+ c18.7-0.8,37.3-0.3,55.6,4.3c6.1,1.5,11.3,5.3,17.5,6.6c3,4.7,7.6,8.2,10.5,13.1c3.9,6.6,7.2,13.4,8.4,21.1
+ c1.9,12.6-5.2,20.3-17.8,19.4c-8.9-0.6-17.2-3.2-25.3-6.9c-4.9-2.2-4.8-2.3-4.5,3c0.5,8.6,0.8,17.2-0.9,25.7
+ c-1.4,7.2-6,10.9-12.8,12c-7.8,1.3-14.7-0.8-20.5-6.5C279.2,358.8,275.2,347.1,274.2,334.2z"/>
+ <path class="st3" d="M340.3,257.2c-7.9,1.7-17.8,1.4-27.7,0.5c-2.8-0.3-4.2-1.7-4.3-4.4c-0.7-13,0-25.8,4.4-38.2
+ c2.2-6.2,7.1-9.4,13.5-10.3c4.5-0.6,8.5,2.1,9.9,6.5c1.1,3.6,0.7,7.2,0.2,10.8c-0.8,6.8-0.8,6.8,5.7,5.1c3-0.8,6.1-1.6,9.3-1.5
+ c6.6,0.2,10,4.1,9.1,10.6C359.1,245.2,351.1,254.3,340.3,257.2z"/>
+ <path class="st4" d="M349.2,206.8c-2.1-8.1,4-19,12-21.5c5.5-1.7,10,0.9,11.1,6.6c1.6,8-4.7,18.5-12.5,20.9
+ C354.8,214.3,350.5,211.9,349.2,206.8z"/>
+ <path class="st3" d="M191.4,225.4c2.1,9.8,3.2,19.8,2.5,30c-0.2,2.9-1.4,4.2-4.2,4.5c-9.1,0.8-18.1,1.9-27.2,0.4
+ c-10.5-1.8-19.7-11.2-21-21.8c-0.7-5.5,2.8-9.4,8.9-9.2c3.8,0.1,7.6,0.6,11.2,1.6c3.4,0.9,4.2,0,3.8-3.2c-0.4-3.3-1-6.6-0.9-9.9
+ c0.3-8.5,6.9-12.3,14.9-9.1C187,211.7,189.1,218.5,191.4,225.4z"/>
+ <path class="st5" d="M152.9,204c0.3,1,0.6,3.4,0,5.9c-1.2,5.7-6.3,8.4-11.7,6.2c-6.5-2.6-12.2-11-12-18.1c0.2-8,6.9-11.8,13.9-7.8
+ C147.9,193.1,151.1,197.1,152.9,204z"/>
+ <path class="st6" d="M265.7,297.2c0.3,0.9,0.2,1.7-0.5,2.3c-0.9,0.8-1.9,0.7-2.7,0c-6.1-5.1-12.1-4-18.1,0.3c-1,0.7-2.1,1-3.1-0.1
+ c-0.8-0.9-0.5-1.8,0.1-2.7c3.9-6.6,20-6.9,23.9-0.5C265.4,296.7,265.5,297,265.7,297.2z"/>
+ <path class="st7" d="M251,272.6c4.2-0.9,7.9,0.8,10.9,4.3c0.8,0.9,1.4,2,0.6,3.1c-0.9,1.3-2,0.5-2.9-0.3c-4.3-3.7-8.6-3.6-12.8,0.2
+ c-0.9,0.8-1.9,1.8-3,0.8c-1.2-1.1-0.6-2.4,0.3-3.5C245.7,274.9,247.8,273.4,251,272.6z"/>
+ <path class="st8" d="M263.2,317.7c0.2,1,0.4,1.9-0.4,2.5c-0.8,0.6-1.6,0.3-2.2-0.3c-4.7-4.5-9.2-3.6-13.5,0.5
+ c-0.6,0.6-1.4,0.9-2.3,0.5c-0.9-0.5-0.9-1.3-0.7-2.1c0.6-2.8,6-6.3,9.9-6.3C258.1,312.4,261.2,314.2,263.2,317.7z"/>
</g>
</svg>
diff --git a/icons/maskable_128x128.png b/icons/maskable_128x128.png
index e8d1b33..afaafcb 100644
--- a/icons/maskable_128x128.png
+++ b/icons/maskable_128x128.png
Binary files differ
diff --git a/icons/maskable_144x144.png b/icons/maskable_144x144.png
index 8865f85..1fcb544 100644
--- a/icons/maskable_144x144.png
+++ b/icons/maskable_144x144.png
Binary files differ
diff --git a/icons/maskable_152x152.png b/icons/maskable_152x152.png
index b3e939f..c794a43 100644
--- a/icons/maskable_152x152.png
+++ b/icons/maskable_152x152.png
Binary files differ
diff --git a/icons/maskable_192x192.png b/icons/maskable_192x192.png
index ae21420..f58d220 100644
--- a/icons/maskable_192x192.png
+++ b/icons/maskable_192x192.png
Binary files differ
diff --git a/icons/maskable_256x256.png b/icons/maskable_256x256.png
index 6e7be53..beb78f5 100644
--- a/icons/maskable_256x256.png
+++ b/icons/maskable_256x256.png
Binary files differ
diff --git a/icons/maskable_384x384.png b/icons/maskable_384x384.png
index 5979943..0b33b22 100644
--- a/icons/maskable_384x384.png
+++ b/icons/maskable_384x384.png
Binary files differ
diff --git a/icons/maskable_64x64.png b/icons/maskable_64x64.png
index 74cf23a..b8b8a0b 100644
--- a/icons/maskable_64x64.png
+++ b/icons/maskable_64x64.png
Binary files differ
diff --git a/icons/maskable_72x72.png b/icons/maskable_72x72.png
index 84f614d..cdc2b62 100644
--- a/icons/maskable_72x72.png
+++ b/icons/maskable_72x72.png
Binary files differ
diff --git a/icons/maskable_96x96.png b/icons/maskable_96x96.png
index 5e96798..181f238 100644
--- a/icons/maskable_96x96.png
+++ b/icons/maskable_96x96.png
Binary files differ
diff --git a/includes/.DS_Store b/includes/.DS_Store
index 7969503..d91aeee 100644
--- a/includes/.DS_Store
+++ b/includes/.DS_Store
Binary files differ
diff --git a/includes/editor.js b/includes/editor.js
new file mode 100644
index 0000000..df0baf3
--- /dev/null
+++ b/includes/editor.js
@@ -0,0 +1,193 @@
+const prompts = require('prompts');
+const songs = require('../assets/content/songs.json');
+const albums = require('../assets/content/albums.json');
+const fs = require("fs");
+const path = require("path");
+const chalk = require("chalk");
+const Fuse = require("fuse.js");
+
+function reload() {
+ for (let songID of Object.keys(songs)) {
+ if (fs.existsSync("/opt/mist")) {
+ if (!fs.existsSync("/opt/mist/flac/" + songID + ".flac") || !fs.existsSync("/opt/mist/aac/" + songID + ".m4a") || !fs.existsSync("/opt/mist/jpeg/" + songID + ".jpg")) {
+ delete songs[songID];
+ }
+ } else {
+ if (!fs.existsSync("../assets/content/" + songID + ".flac") || !fs.existsSync("../assets/content/" + songID + ".m4a") || !fs.existsSync("../assets/content/" + songID + ".jpg")) {
+ delete songs[songID];
+ }
+ }
+ }
+
+ let idList = [...Object.keys(songs), ...Object.keys(albums)];
+
+ if (fs.existsSync("/opt/mist")) {
+ for (let file of fs.readdirSync("/opt/mist/flac")) {
+ if (fs.lstatSync("/opt/mist/flac/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("/opt/mist/flac/" + file);
+ if (fs.existsSync("../assets/content/" + file)) fs.unlinkSync("../assets/content/" + file);
+ } else {
+ if (!fs.existsSync("../assets/content/" + file)) fs.symlinkSync("/opt/mist/flac/" + file, "../assets/content/" + file);
+ }
+ }
+ }
+
+ for (let file of fs.readdirSync("/opt/mist/aac")) {
+ if (fs.lstatSync("/opt/mist/aac/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("/opt/mist/aac/" + file);
+ if (fs.existsSync("../assets/content/" + file)) fs.unlinkSync("../assets/content/" + file);
+ } else {
+ if (!fs.existsSync("../assets/content/" + file)) fs.symlinkSync("/opt/mist/aac/" + file, "../assets/content/" + file);
+ }
+ }
+ }
+
+ for (let file of fs.readdirSync("/opt/mist/jpeg")) {
+ if (fs.lstatSync("/opt/mist/jpeg/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("/opt/mist/jpeg/" + file);
+ if (fs.existsSync("../assets/content/" + file)) fs.unlinkSync("../assets/content/" + file);
+ } else {
+ if (!fs.existsSync("../assets/content/" + file)) fs.symlinkSync("/opt/mist/jpeg/" + file, "../assets/content/" + file);
+ }
+ }
+ }
+ } else {
+ for (let file of fs.readdirSync("../assets/content")) {
+ if (fs.lstatSync("../assets/content/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("../assets/content/" + file);
+ }
+ }
+ }
+ }
+
+ for (let albumID of Object.keys(albums)) {
+ let album = albums[albumID];
+ album["tracks"] = [...new Set(album["tracks"])].sort((a, b) => {
+ return songs[a]['track'] - songs[b]['track'];
+ });
+ }
+
+ fs.writeFileSync("../assets/content/songs.json", JSON.stringify(songs));
+ fs.writeFileSync("../assets/content/albums.json", JSON.stringify(albums));
+}
+
+reload();
+
+console.log(chalk.bold("Mist metadata editor") + "\n");
+
+const fuse = new Fuse([...Object.entries(songs).map(i => {
+ j = i[1];
+ j['_type'] = "song";
+ j['_id'] = i[0];
+ return j;
+}), ...Object.entries(albums).map(i => {
+ j = i[1];
+ j['_type'] = "album";
+ j['_id'] = i[0];
+ return j;
+})], {
+ keys: ['title', 'artist']
+});
+
+async function main() {
+ console.clear();
+ const response = await prompts({
+ type: 'text',
+ name: 'search',
+ message: 'Enter the name of a song or album:'
+ });
+
+ if (!response['search']) {
+ return;
+ }
+
+ let query = response['search'];
+ let results = fuse.search(query);
+ let items = [];
+
+ for (let result of results) {
+ items.push({
+ title: chalk.cyan(result.item._type === "song" ? "Song: " : "Album: ") + result.item.artist + " - " + result.item.title,
+ value: result.item._type + ":" + result.item._id
+ })
+ }
+
+ const select = await prompts({
+ type: 'select',
+ name: 'choice',
+ message: 'Select a song or album in the list.',
+ choices: items
+ });
+
+ if (!select['choice']) {
+ return;
+ }
+
+ await item(select['choice']);
+}
+
+async function item(meta) {
+ console.clear();
+ let id = meta.split(":")[1];
+ let type = meta.split(":")[0];
+ let item;
+
+ if (type === "song") item = songs[id];
+ if (type === "album") item = albums[id];
+
+ let options = [
+ { title: "ID: " + id, value: "", disabled: true },
+ { title: chalk.gray("Back"), value: "back" },
+ ];
+
+ options.push({ title: chalk.red("Delete"), value: "delete" });
+
+ const select = await prompts({
+ type: 'select',
+ name: 'choice',
+ message: chalk.cyan(type === "song" ? "Song: " : "Album: ") + item.artist + " - " + item.title,
+ choices: options
+ });
+
+ if (!select['choice']) {
+ return;
+ }
+
+ if (select['choice'] === "back") {
+ main();
+ return;
+ }
+
+ if (select['choice'] === "delete") {
+ let confirm = await prompts({
+ type: 'confirm',
+ name: 'confirm',
+ message: 'Are you sure you want to delete this ' + type + '? This is permanent and will affect users.'
+ });
+
+ if (typeof confirm['confirm'] !== "boolean") {
+ return;
+ } else {
+ if (confirm['confirm']) {
+ // TODO: Delete
+ main();
+ } else {
+
+ }
+ }
+ }
+}
+
+main(); \ No newline at end of file
diff --git a/includes/node_modules/.package-lock.json b/includes/node_modules/.package-lock.json
index 23f9a60..4a34ccd 100644
--- a/includes/node_modules/.package-lock.json
+++ b/includes/node_modules/.package-lock.json
@@ -3,6 +3,75 @@
"lockfileVersion": 3,
"requires": true,
"packages": {
+ "node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
+ },
+ "node_modules/fuse.js": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz",
+ "integrity": "sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==",
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/kleur": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
+ "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/node-watch": {
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/node-watch/-/node-watch-0.7.4.tgz",
@@ -10,6 +79,34 @@
"engines": {
"node": ">=6"
}
+ },
+ "node_modules/prompts": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",
+ "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==",
+ "dependencies": {
+ "kleur": "^3.0.3",
+ "sisteransi": "^1.0.5"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/sisteransi": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
+ "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="
+ },
+ "node_modules/supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
}
}
}
diff --git a/includes/node_modules/ansi-styles/index.d.ts b/includes/node_modules/ansi-styles/index.d.ts
new file mode 100644
index 0000000..44a907e
--- /dev/null
+++ b/includes/node_modules/ansi-styles/index.d.ts
@@ -0,0 +1,345 @@
+declare type CSSColor =
+ | 'aliceblue'
+ | 'antiquewhite'
+ | 'aqua'
+ | 'aquamarine'
+ | 'azure'
+ | 'beige'
+ | 'bisque'
+ | 'black'
+ | 'blanchedalmond'
+ | 'blue'
+ | 'blueviolet'
+ | 'brown'
+ | 'burlywood'
+ | 'cadetblue'
+ | 'chartreuse'
+ | 'chocolate'
+ | 'coral'
+ | 'cornflowerblue'
+ | 'cornsilk'
+ | 'crimson'
+ | 'cyan'
+ | 'darkblue'
+ | 'darkcyan'
+ | 'darkgoldenrod'
+ | 'darkgray'
+ | 'darkgreen'
+ | 'darkgrey'
+ | 'darkkhaki'
+ | 'darkmagenta'
+ | 'darkolivegreen'
+ | 'darkorange'
+ | 'darkorchid'
+ | 'darkred'
+ | 'darksalmon'
+ | 'darkseagreen'
+ | 'darkslateblue'
+ | 'darkslategray'
+ | 'darkslategrey'
+ | 'darkturquoise'
+ | 'darkviolet'
+ | 'deeppink'
+ | 'deepskyblue'
+ | 'dimgray'
+ | 'dimgrey'
+ | 'dodgerblue'
+ | 'firebrick'
+ | 'floralwhite'
+ | 'forestgreen'
+ | 'fuchsia'
+ | 'gainsboro'
+ | 'ghostwhite'
+ | 'gold'
+ | 'goldenrod'
+ | 'gray'
+ | 'green'
+ | 'greenyellow'
+ | 'grey'
+ | 'honeydew'
+ | 'hotpink'
+ | 'indianred'
+ | 'indigo'
+ | 'ivory'
+ | 'khaki'
+ | 'lavender'
+ | 'lavenderblush'
+ | 'lawngreen'
+ | 'lemonchiffon'
+ | 'lightblue'
+ | 'lightcoral'
+ | 'lightcyan'
+ | 'lightgoldenrodyellow'
+ | 'lightgray'
+ | 'lightgreen'
+ | 'lightgrey'
+ | 'lightpink'
+ | 'lightsalmon'
+ | 'lightseagreen'
+ | 'lightskyblue'
+ | 'lightslategray'
+ | 'lightslategrey'
+ | 'lightsteelblue'
+ | 'lightyellow'
+ | 'lime'
+ | 'limegreen'
+ | 'linen'
+ | 'magenta'
+ | 'maroon'
+ | 'mediumaquamarine'
+ | 'mediumblue'
+ | 'mediumorchid'
+ | 'mediumpurple'
+ | 'mediumseagreen'
+ | 'mediumslateblue'
+ | 'mediumspringgreen'
+ | 'mediumturquoise'
+ | 'mediumvioletred'
+ | 'midnightblue'
+ | 'mintcream'
+ | 'mistyrose'
+ | 'moccasin'
+ | 'navajowhite'
+ | 'navy'
+ | 'oldlace'
+ | 'olive'
+ | 'olivedrab'
+ | 'orange'
+ | 'orangered'
+ | 'orchid'
+ | 'palegoldenrod'
+ | 'palegreen'
+ | 'paleturquoise'
+ | 'palevioletred'
+ | 'papayawhip'
+ | 'peachpuff'
+ | 'peru'
+ | 'pink'
+ | 'plum'
+ | 'powderblue'
+ | 'purple'
+ | 'rebeccapurple'
+ | 'red'
+ | 'rosybrown'
+ | 'royalblue'
+ | 'saddlebrown'
+ | 'salmon'
+ | 'sandybrown'
+ | 'seagreen'
+ | 'seashell'
+ | 'sienna'
+ | 'silver'
+ | 'skyblue'
+ | 'slateblue'
+ | 'slategray'
+ | 'slategrey'
+ | 'snow'
+ | 'springgreen'
+ | 'steelblue'
+ | 'tan'
+ | 'teal'
+ | 'thistle'
+ | 'tomato'
+ | 'turquoise'
+ | 'violet'
+ | 'wheat'
+ | 'white'
+ | 'whitesmoke'
+ | 'yellow'
+ | 'yellowgreen';
+
+declare namespace ansiStyles {
+ interface ColorConvert {
+ /**
+ The RGB color space.
+
+ @param red - (`0`-`255`)
+ @param green - (`0`-`255`)
+ @param blue - (`0`-`255`)
+ */
+ rgb(red: number, green: number, blue: number): string;
+
+ /**
+ The RGB HEX color space.
+
+ @param hex - A hexadecimal string containing RGB data.
+ */
+ hex(hex: string): string;
+
+ /**
+ @param keyword - A CSS color name.
+ */
+ keyword(keyword: CSSColor): string;
+
+ /**
+ The HSL color space.
+
+ @param hue - (`0`-`360`)
+ @param saturation - (`0`-`100`)
+ @param lightness - (`0`-`100`)
+ */
+ hsl(hue: number, saturation: number, lightness: number): string;
+
+ /**
+ The HSV color space.
+
+ @param hue - (`0`-`360`)
+ @param saturation - (`0`-`100`)
+ @param value - (`0`-`100`)
+ */
+ hsv(hue: number, saturation: number, value: number): string;
+
+ /**
+ The HSV color space.
+
+ @param hue - (`0`-`360`)
+ @param whiteness - (`0`-`100`)
+ @param blackness - (`0`-`100`)
+ */
+ hwb(hue: number, whiteness: number, blackness: number): string;
+
+ /**
+ Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
+ */
+ ansi(ansi: number): string;
+
+ /**
+ Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
+ */
+ ansi256(ansi: number): string;
+ }
+
+ interface CSPair {
+ /**
+ The ANSI terminal control sequence for starting this style.
+ */
+ readonly open: string;
+
+ /**
+ The ANSI terminal control sequence for ending this style.
+ */
+ readonly close: string;
+ }
+
+ interface ColorBase {
+ readonly ansi: ColorConvert;
+ readonly ansi256: ColorConvert;
+ readonly ansi16m: ColorConvert;
+
+ /**
+ The ANSI terminal control sequence for ending this color.
+ */
+ readonly close: string;
+ }
+
+ interface Modifier {
+ /**
+ Resets the current color chain.
+ */
+ readonly reset: CSPair;
+
+ /**
+ Make text bold.
+ */
+ readonly bold: CSPair;
+
+ /**
+ Emitting only a small amount of light.
+ */
+ readonly dim: CSPair;
+
+ /**
+ Make text italic. (Not widely supported)
+ */
+ readonly italic: CSPair;
+
+ /**
+ Make text underline. (Not widely supported)
+ */
+ readonly underline: CSPair;
+
+ /**
+ Inverse background and foreground colors.
+ */
+ readonly inverse: CSPair;
+
+ /**
+ Prints the text, but makes it invisible.
+ */
+ readonly hidden: CSPair;
+
+ /**
+ Puts a horizontal line through the center of the text. (Not widely supported)
+ */
+ readonly strikethrough: CSPair;
+ }
+
+ interface ForegroundColor {
+ readonly black: CSPair;
+ readonly red: CSPair;
+ readonly green: CSPair;
+ readonly yellow: CSPair;
+ readonly blue: CSPair;
+ readonly cyan: CSPair;
+ readonly magenta: CSPair;
+ readonly white: CSPair;
+
+ /**
+ Alias for `blackBright`.
+ */
+ readonly gray: CSPair;
+
+ /**
+ Alias for `blackBright`.
+ */
+ readonly grey: CSPair;
+
+ readonly blackBright: CSPair;
+ readonly redBright: CSPair;
+ readonly greenBright: CSPair;
+ readonly yellowBright: CSPair;
+ readonly blueBright: CSPair;
+ readonly cyanBright: CSPair;
+ readonly magentaBright: CSPair;
+ readonly whiteBright: CSPair;
+ }
+
+ interface BackgroundColor {
+ readonly bgBlack: CSPair;
+ readonly bgRed: CSPair;
+ readonly bgGreen: CSPair;
+ readonly bgYellow: CSPair;
+ readonly bgBlue: CSPair;
+ readonly bgCyan: CSPair;
+ readonly bgMagenta: CSPair;
+ readonly bgWhite: CSPair;
+
+ /**
+ Alias for `bgBlackBright`.
+ */
+ readonly bgGray: CSPair;
+
+ /**
+ Alias for `bgBlackBright`.
+ */
+ readonly bgGrey: CSPair;
+
+ readonly bgBlackBright: CSPair;
+ readonly bgRedBright: CSPair;
+ readonly bgGreenBright: CSPair;
+ readonly bgYellowBright: CSPair;
+ readonly bgBlueBright: CSPair;
+ readonly bgCyanBright: CSPair;
+ readonly bgMagentaBright: CSPair;
+ readonly bgWhiteBright: CSPair;
+ }
+}
+
+declare const ansiStyles: {
+ readonly modifier: ansiStyles.Modifier;
+ readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
+ readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
+ readonly codes: ReadonlyMap<number, number>;
+} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
+
+export = ansiStyles;
diff --git a/includes/node_modules/ansi-styles/index.js b/includes/node_modules/ansi-styles/index.js
new file mode 100644
index 0000000..5d82581
--- /dev/null
+++ b/includes/node_modules/ansi-styles/index.js
@@ -0,0 +1,163 @@
+'use strict';
+
+const wrapAnsi16 = (fn, offset) => (...args) => {
+ const code = fn(...args);
+ return `\u001B[${code + offset}m`;
+};
+
+const wrapAnsi256 = (fn, offset) => (...args) => {
+ const code = fn(...args);
+ return `\u001B[${38 + offset};5;${code}m`;
+};
+
+const wrapAnsi16m = (fn, offset) => (...args) => {
+ const rgb = fn(...args);
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
+};
+
+const ansi2ansi = n => n;
+const rgb2rgb = (r, g, b) => [r, g, b];
+
+const setLazyProperty = (object, property, get) => {
+ Object.defineProperty(object, property, {
+ get: () => {
+ const value = get();
+
+ Object.defineProperty(object, property, {
+ value,
+ enumerable: true,
+ configurable: true
+ });
+
+ return value;
+ },
+ enumerable: true,
+ configurable: true
+ });
+};
+
+/** @type {typeof import('color-convert')} */
+let colorConvert;
+const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
+ if (colorConvert === undefined) {
+ colorConvert = require('color-convert');
+ }
+
+ const offset = isBackground ? 10 : 0;
+ const styles = {};
+
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
+ const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
+ if (sourceSpace === targetSpace) {
+ styles[name] = wrap(identity, offset);
+ } else if (typeof suite === 'object') {
+ styles[name] = wrap(suite[targetSpace], offset);
+ }
+ }
+
+ return styles;
+};
+
+function assembleStyles() {
+ const codes = new Map();
+ const styles = {
+ modifier: {
+ reset: [0, 0],
+ // 21 isn't widely supported and 22 does the same thing
+ bold: [1, 22],
+ dim: [2, 22],
+ italic: [3, 23],
+ underline: [4, 24],
+ inverse: [7, 27],
+ hidden: [8, 28],
+ strikethrough: [9, 29]
+ },
+ color: {
+ black: [30, 39],
+ red: [31, 39],
+ green: [32, 39],
+ yellow: [33, 39],
+ blue: [34, 39],
+ magenta: [35, 39],
+ cyan: [36, 39],
+ white: [37, 39],
+
+ // Bright color
+ blackBright: [90, 39],
+ redBright: [91, 39],
+ greenBright: [92, 39],
+ yellowBright: [93, 39],
+ blueBright: [94, 39],
+ magentaBright: [95, 39],
+ cyanBright: [96, 39],
+ whiteBright: [97, 39]
+ },
+ bgColor: {
+ bgBlack: [40, 49],
+ bgRed: [41, 49],
+ bgGreen: [42, 49],
+ bgYellow: [43, 49],
+ bgBlue: [44, 49],
+ bgMagenta: [45, 49],
+ bgCyan: [46, 49],
+ bgWhite: [47, 49],
+
+ // Bright color
+ bgBlackBright: [100, 49],
+ bgRedBright: [101, 49],
+ bgGreenBright: [102, 49],
+ bgYellowBright: [103, 49],
+ bgBlueBright: [104, 49],
+ bgMagentaBright: [105, 49],
+ bgCyanBright: [106, 49],
+ bgWhiteBright: [107, 49]
+ }
+ };
+
+ // Alias bright black as gray (and grey)
+ styles.color.gray = styles.color.blackBright;
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
+ styles.color.grey = styles.color.blackBright;
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
+
+ for (const [groupName, group] of Object.entries(styles)) {
+ for (const [styleName, style] of Object.entries(group)) {
+ styles[styleName] = {
+ open: `\u001B[${style[0]}m`,
+ close: `\u001B[${style[1]}m`
+ };
+
+ group[styleName] = styles[styleName];
+
+ codes.set(style[0], style[1]);
+ }
+
+ Object.defineProperty(styles, groupName, {
+ value: group,
+ enumerable: false
+ });
+ }
+
+ Object.defineProperty(styles, 'codes', {
+ value: codes,
+ enumerable: false
+ });
+
+ styles.color.close = '\u001B[39m';
+ styles.bgColor.close = '\u001B[49m';
+
+ setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
+ setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
+ setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
+ setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
+ setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
+ setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
+
+ return styles;
+}
+
+// Make the export immutable
+Object.defineProperty(module, 'exports', {
+ enumerable: true,
+ get: assembleStyles
+});
diff --git a/includes/node_modules/ansi-styles/license b/includes/node_modules/ansi-styles/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/includes/node_modules/ansi-styles/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/node_modules/ansi-styles/package.json b/includes/node_modules/ansi-styles/package.json
new file mode 100644
index 0000000..7539328
--- /dev/null
+++ b/includes/node_modules/ansi-styles/package.json
@@ -0,0 +1,56 @@
+{
+ "name": "ansi-styles",
+ "version": "4.3.0",
+ "description": "ANSI escape codes for styling strings in the terminal",
+ "license": "MIT",
+ "repository": "chalk/ansi-styles",
+ "funding": "https://github.com/chalk/ansi-styles?sponsor=1",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd",
+ "screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "ansi",
+ "styles",
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "string",
+ "tty",
+ "escape",
+ "formatting",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "log",
+ "logging",
+ "command-line",
+ "text"
+ ],
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "devDependencies": {
+ "@types/color-convert": "^1.9.0",
+ "ava": "^2.3.0",
+ "svg-term-cli": "^2.1.1",
+ "tsd": "^0.11.0",
+ "xo": "^0.25.3"
+ }
+}
diff --git a/includes/node_modules/ansi-styles/readme.md b/includes/node_modules/ansi-styles/readme.md
new file mode 100644
index 0000000..24883de
--- /dev/null
+++ b/includes/node_modules/ansi-styles/readme.md
@@ -0,0 +1,152 @@
+# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
+
+> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
+
+You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
+
+<img src="screenshot.svg" width="900">
+
+## Install
+
+```
+$ npm install ansi-styles
+```
+
+## Usage
+
+```js
+const style = require('ansi-styles');
+
+console.log(`${style.green.open}Hello world!${style.green.close}`);
+
+
+// Color conversion between 16/256/truecolor
+// NOTE: If conversion goes to 16 colors or 256 colors, the original color
+// may be degraded to fit that color palette. This means terminals
+// that do not support 16 million colors will best-match the
+// original color.
+console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
+console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
+console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
+```
+
+## API
+
+Each style has an `open` and `close` property.
+
+## Styles
+
+### Modifiers
+
+- `reset`
+- `bold`
+- `dim`
+- `italic` *(Not widely supported)*
+- `underline`
+- `inverse`
+- `hidden`
+- `strikethrough` *(Not widely supported)*
+
+### Colors
+
+- `black`
+- `red`
+- `green`
+- `yellow`
+- `blue`
+- `magenta`
+- `cyan`
+- `white`
+- `blackBright` (alias: `gray`, `grey`)
+- `redBright`
+- `greenBright`
+- `yellowBright`
+- `blueBright`
+- `magentaBright`
+- `cyanBright`
+- `whiteBright`
+
+### Background colors
+
+- `bgBlack`
+- `bgRed`
+- `bgGreen`
+- `bgYellow`
+- `bgBlue`
+- `bgMagenta`
+- `bgCyan`
+- `bgWhite`
+- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
+- `bgRedBright`
+- `bgGreenBright`
+- `bgYellowBright`
+- `bgBlueBright`
+- `bgMagentaBright`
+- `bgCyanBright`
+- `bgWhiteBright`
+
+## Advanced usage
+
+By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
+
+- `style.modifier`
+- `style.color`
+- `style.bgColor`
+
+###### Example
+
+```js
+console.log(style.color.green.open);
+```
+
+Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
+
+###### Example
+
+```js
+console.log(style.codes.get(36));
+//=> 39
+```
+
+## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
+
+`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
+
+The following color spaces from `color-convert` are supported:
+
+- `rgb`
+- `hex`
+- `keyword`
+- `hsl`
+- `hsv`
+- `hwb`
+- `ansi`
+- `ansi256`
+
+To use these, call the associated conversion function with the intended output, for example:
+
+```js
+style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
+style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
+
+style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
+style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
+
+style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
+style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
+```
+
+## Related
+
+- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
+
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
+
+## For enterprise
+
+Available as part of the Tidelift Subscription.
+
+The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
diff --git a/includes/node_modules/chalk/index.d.ts b/includes/node_modules/chalk/index.d.ts
new file mode 100644
index 0000000..9cd88f3
--- /dev/null
+++ b/includes/node_modules/chalk/index.d.ts
@@ -0,0 +1,415 @@
+/**
+Basic foreground colors.
+
+[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
+*/
+declare type ForegroundColor =
+ | 'black'
+ | 'red'
+ | 'green'
+ | 'yellow'
+ | 'blue'
+ | 'magenta'
+ | 'cyan'
+ | 'white'
+ | 'gray'
+ | 'grey'
+ | 'blackBright'
+ | 'redBright'
+ | 'greenBright'
+ | 'yellowBright'
+ | 'blueBright'
+ | 'magentaBright'
+ | 'cyanBright'
+ | 'whiteBright';
+
+/**
+Basic background colors.
+
+[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
+*/
+declare type BackgroundColor =
+ | 'bgBlack'
+ | 'bgRed'
+ | 'bgGreen'
+ | 'bgYellow'
+ | 'bgBlue'
+ | 'bgMagenta'
+ | 'bgCyan'
+ | 'bgWhite'
+ | 'bgGray'
+ | 'bgGrey'
+ | 'bgBlackBright'
+ | 'bgRedBright'
+ | 'bgGreenBright'
+ | 'bgYellowBright'
+ | 'bgBlueBright'
+ | 'bgMagentaBright'
+ | 'bgCyanBright'
+ | 'bgWhiteBright';
+
+/**
+Basic colors.
+
+[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
+*/
+declare type Color = ForegroundColor | BackgroundColor;
+
+declare type Modifiers =
+ | 'reset'
+ | 'bold'
+ | 'dim'
+ | 'italic'
+ | 'underline'
+ | 'inverse'
+ | 'hidden'
+ | 'strikethrough'
+ | 'visible';
+
+declare namespace chalk {
+ /**
+ Levels:
+ - `0` - All colors disabled.
+ - `1` - Basic 16 colors support.
+ - `2` - ANSI 256 colors support.
+ - `3` - Truecolor 16 million colors support.
+ */
+ type Level = 0 | 1 | 2 | 3;
+
+ interface Options {
+ /**
+ Specify the color support for Chalk.
+
+ By default, color support is automatically detected based on the environment.
+
+ Levels:
+ - `0` - All colors disabled.
+ - `1` - Basic 16 colors support.
+ - `2` - ANSI 256 colors support.
+ - `3` - Truecolor 16 million colors support.
+ */
+ level?: Level;
+ }
+
+ /**
+ Return a new Chalk instance.
+ */
+ type Instance = new (options?: Options) => Chalk;
+
+ /**
+ Detect whether the terminal supports color.
+ */
+ interface ColorSupport {
+ /**
+ The color level used by Chalk.
+ */
+ level: Level;
+
+ /**
+ Return whether Chalk supports basic 16 colors.
+ */
+ hasBasic: boolean;
+
+ /**
+ Return whether Chalk supports ANSI 256 colors.
+ */
+ has256: boolean;
+
+ /**
+ Return whether Chalk supports Truecolor 16 million colors.
+ */
+ has16m: boolean;
+ }
+
+ interface ChalkFunction {
+ /**
+ Use a template string.
+
+ @remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
+
+ @example
+ ```
+ import chalk = require('chalk');
+
+ log(chalk`
+ CPU: {red ${cpu.totalPercent}%}
+ RAM: {green ${ram.used / ram.total * 100}%}
+ DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
+ `);
+ ```
+
+ @example
+ ```
+ import chalk = require('chalk');
+
+ log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
+ ```
+ */
+ (text: TemplateStringsArray, ...placeholders: unknown[]): string;
+
+ (...text: unknown[]): string;
+ }
+
+ interface Chalk extends ChalkFunction {
+ /**
+ Return a new Chalk instance.
+ */
+ Instance: Instance;
+
+ /**
+ The color support for Chalk.
+
+ By default, color support is automatically detected based on the environment.
+
+ Levels:
+ - `0` - All colors disabled.
+ - `1` - Basic 16 colors support.
+ - `2` - ANSI 256 colors support.
+ - `3` - Truecolor 16 million colors support.
+ */
+ level: Level;
+
+ /**
+ Use HEX value to set text color.
+
+ @param color - Hexadecimal value representing the desired color.
+
+ @example
+ ```
+ import chalk = require('chalk');
+
+ chalk.hex('#DEADED');
+ ```
+ */
+ hex(color: string): Chalk;
+
+ /**
+ Use keyword color value to set text color.
+
+ @param color - Keyword value representing the desired color.
+
+ @example
+ ```
+ import chalk = require('chalk');
+
+ chalk.keyword('orange');
+ ```
+ */
+ keyword(color: string): Chalk;
+
+ /**
+ Use RGB values to set text color.
+ */
+ rgb(red: number, green: number, blue: number): Chalk;
+
+ /**
+ Use HSL values to set text color.
+ */
+ hsl(hue: number, saturation: number, lightness: number): Chalk;
+
+ /**
+ Use HSV values to set text color.
+ */
+ hsv(hue: number, saturation: number, value: number): Chalk;
+
+ /**
+ Use HWB values to set text color.
+ */
+ hwb(hue: number, whiteness: number, blackness: number): Chalk;
+
+ /**
+ Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
+
+ 30 <= code && code < 38 || 90 <= code && code < 98
+ For example, 31 for red, 91 for redBright.
+ */
+ ansi(code: number): Chalk;
+
+ /**
+ Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
+ */
+ ansi256(index: number): Chalk;
+
+ /**
+ Use HEX value to set background color.
+
+ @param color - Hexadecimal value representing the desired color.
+
+ @example
+ ```
+ import chalk = require('chalk');
+
+ chalk.bgHex('#DEADED');
+ ```
+ */
+ bgHex(color: string): Chalk;
+
+ /**
+ Use keyword color value to set background color.
+
+ @param color - Keyword value representing the desired color.
+
+ @example
+ ```
+ import chalk = require('chalk');
+
+ chalk.bgKeyword('orange');
+ ```
+ */
+ bgKeyword(color: string): Chalk;
+
+ /**
+ Use RGB values to set background color.
+ */
+ bgRgb(red: number, green: number, blue: number): Chalk;
+
+ /**
+ Use HSL values to set background color.
+ */
+ bgHsl(hue: number, saturation: number, lightness: number): Chalk;
+
+ /**
+ Use HSV values to set background color.
+ */
+ bgHsv(hue: number, saturation: number, value: number): Chalk;
+
+ /**
+ Use HWB values to set background color.
+ */
+ bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
+
+ /**
+ Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
+
+ 30 <= code && code < 38 || 90 <= code && code < 98
+ For example, 31 for red, 91 for redBright.
+ Use the foreground code, not the background code (for example, not 41, nor 101).
+ */
+ bgAnsi(code: number): Chalk;
+
+ /**
+ Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
+ */
+ bgAnsi256(index: number): Chalk;
+
+ /**
+ Modifier: Resets the current color chain.
+ */
+ readonly reset: Chalk;
+
+ /**
+ Modifier: Make text bold.
+ */
+ readonly bold: Chalk;
+
+ /**
+ Modifier: Emitting only a small amount of light.
+ */
+ readonly dim: Chalk;
+
+ /**
+ Modifier: Make text italic. (Not widely supported)
+ */
+ readonly italic: Chalk;
+
+ /**
+ Modifier: Make text underline. (Not widely supported)
+ */
+ readonly underline: Chalk;
+
+ /**
+ Modifier: Inverse background and foreground colors.
+ */
+ readonly inverse: Chalk;
+
+ /**
+ Modifier: Prints the text, but makes it invisible.
+ */
+ readonly hidden: Chalk;
+
+ /**
+ Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
+ */
+ readonly strikethrough: Chalk;
+
+ /**
+ Modifier: Prints the text only when Chalk has a color support level > 0.
+ Can be useful for things that are purely cosmetic.
+ */
+ readonly visible: Chalk;
+
+ readonly black: Chalk;
+ readonly red: Chalk;
+ readonly green: Chalk;
+ readonly yellow: Chalk;
+ readonly blue: Chalk;
+ readonly magenta: Chalk;
+ readonly cyan: Chalk;
+ readonly white: Chalk;
+
+ /*
+ Alias for `blackBright`.
+ */
+ readonly gray: Chalk;
+
+ /*
+ Alias for `blackBright`.
+ */
+ readonly grey: Chalk;
+
+ readonly blackBright: Chalk;
+ readonly redBright: Chalk;
+ readonly greenBright: Chalk;
+ readonly yellowBright: Chalk;
+ readonly blueBright: Chalk;
+ readonly magentaBright: Chalk;
+ readonly cyanBright: Chalk;
+ readonly whiteBright: Chalk;
+
+ readonly bgBlack: Chalk;
+ readonly bgRed: Chalk;
+ readonly bgGreen: Chalk;
+ readonly bgYellow: Chalk;
+ readonly bgBlue: Chalk;
+ readonly bgMagenta: Chalk;
+ readonly bgCyan: Chalk;
+ readonly bgWhite: Chalk;
+
+ /*
+ Alias for `bgBlackBright`.
+ */
+ readonly bgGray: Chalk;
+
+ /*
+ Alias for `bgBlackBright`.
+ */
+ readonly bgGrey: Chalk;
+
+ readonly bgBlackBright: Chalk;
+ readonly bgRedBright: Chalk;
+ readonly bgGreenBright: Chalk;
+ readonly bgYellowBright: Chalk;
+ readonly bgBlueBright: Chalk;
+ readonly bgMagentaBright: Chalk;
+ readonly bgCyanBright: Chalk;
+ readonly bgWhiteBright: Chalk;
+ }
+}
+
+/**
+Main Chalk object that allows to chain styles together.
+Call the last one as a method with a string argument.
+Order doesn't matter, and later styles take precedent in case of a conflict.
+This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
+*/
+declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
+ supportsColor: chalk.ColorSupport | false;
+ Level: chalk.Level;
+ Color: Color;
+ ForegroundColor: ForegroundColor;
+ BackgroundColor: BackgroundColor;
+ Modifiers: Modifiers;
+ stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
+};
+
+export = chalk;
diff --git a/includes/node_modules/chalk/license b/includes/node_modules/chalk/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/includes/node_modules/chalk/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/node_modules/chalk/package.json b/includes/node_modules/chalk/package.json
new file mode 100644
index 0000000..47c23f2
--- /dev/null
+++ b/includes/node_modules/chalk/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "chalk",
+ "version": "4.1.2",
+ "description": "Terminal string styling done right",
+ "license": "MIT",
+ "repository": "chalk/chalk",
+ "funding": "https://github.com/chalk/chalk?sponsor=1",
+ "main": "source",
+ "engines": {
+ "node": ">=10"
+ },
+ "scripts": {
+ "test": "xo && nyc ava && tsd",
+ "bench": "matcha benchmark.js"
+ },
+ "files": [
+ "source",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "string",
+ "str",
+ "ansi",
+ "style",
+ "styles",
+ "tty",
+ "formatting",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "log",
+ "logging",
+ "command-line",
+ "text"
+ ],
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "devDependencies": {
+ "ava": "^2.4.0",
+ "coveralls": "^3.0.7",
+ "execa": "^4.0.0",
+ "import-fresh": "^3.1.0",
+ "matcha": "^0.7.0",
+ "nyc": "^15.0.0",
+ "resolve-from": "^5.0.0",
+ "tsd": "^0.7.4",
+ "xo": "^0.28.2"
+ },
+ "xo": {
+ "rules": {
+ "unicorn/prefer-string-slice": "off",
+ "unicorn/prefer-includes": "off",
+ "@typescript-eslint/member-ordering": "off",
+ "no-redeclare": "off",
+ "unicorn/string-content": "off",
+ "unicorn/better-regex": "off"
+ }
+ }
+}
diff --git a/includes/node_modules/chalk/readme.md b/includes/node_modules/chalk/readme.md
new file mode 100644
index 0000000..a055d21
--- /dev/null
+++ b/includes/node_modules/chalk/readme.md
@@ -0,0 +1,341 @@
+<h1 align="center">
+ <br>
+ <br>
+ <img width="320" src="media/logo.svg" alt="Chalk">
+ <br>
+ <br>
+ <br>
+</h1>
+
+> Terminal string styling done right
+
+[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
+
+<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
+
+<br>
+
+---
+
+<div align="center">
+ <p>
+ <p>
+ <sup>
+ Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
+ </sup>
+ </p>
+ <sup>Special thanks to:</sup>
+ <br>
+ <br>
+ <a href="https://standardresume.co/tech">
+ <img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
+ </a>
+ <br>
+ <br>
+ <a href="https://retool.com/?utm_campaign=sindresorhus">
+ <img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
+ </a>
+ <br>
+ <br>
+ <a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
+ <div>
+ <img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
+ </div>
+ <b>All your environment variables, in one place</b>
+ <div>
+ <span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
+ <br>
+ <span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
+ </div>
+ </a>
+ <br>
+ <a href="https://uibakery.io/?utm_source=chalk&utm_medium=sponsor&utm_campaign=github">
+ <div>
+ <img src="https://sindresorhus.com/assets/thanks/uibakery-logo.jpg" width="270" alt="UI Bakery">
+ </div>
+ </a>
+ </p>
+</div>
+
+---
+
+<br>
+
+## Highlights
+
+- Expressive API
+- Highly performant
+- Ability to nest styles
+- [256/Truecolor color support](#256-and-truecolor-color-support)
+- Auto-detects color support
+- Doesn't extend `String.prototype`
+- Clean and focused
+- Actively maintained
+- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
+
+## Install
+
+```console
+$ npm install chalk
+```
+
+## Usage
+
+```js
+const chalk = require('chalk');
+
+console.log(chalk.blue('Hello world!'));
+```
+
+Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
+
+```js
+const chalk = require('chalk');
+const log = console.log;
+
+// Combine styled and normal strings
+log(chalk.blue('Hello') + ' World' + chalk.red('!'));
+
+// Compose multiple styles using the chainable API
+log(chalk.blue.bgRed.bold('Hello world!'));
+
+// Pass in multiple arguments
+log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
+
+// Nest styles
+log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
+
+// Nest styles of the same type even (color, underline, background)
+log(chalk.green(
+ 'I am a green line ' +
+ chalk.blue.underline.bold('with a blue substring') +
+ ' that becomes green again!'
+));
+
+// ES2015 template literal
+log(`
+CPU: ${chalk.red('90%')}
+RAM: ${chalk.green('40%')}
+DISK: ${chalk.yellow('70%')}
+`);
+
+// ES2015 tagged template literal
+log(chalk`
+CPU: {red ${cpu.totalPercent}%}
+RAM: {green ${ram.used / ram.total * 100}%}
+DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
+`);
+
+// Use RGB colors in terminal emulators that support it.
+log(chalk.keyword('orange')('Yay for orange colored text!'));
+log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
+log(chalk.hex('#DEADED').bold('Bold gray!'));
+```
+
+Easily define your own themes:
+
+```js
+const chalk = require('chalk');
+
+const error = chalk.bold.red;
+const warning = chalk.keyword('orange');
+
+console.log(error('Error!'));
+console.log(warning('Warning!'));
+```
+
+Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
+
+```js
+const name = 'Sindre';
+console.log(chalk.green('Hello %s'), name);
+//=> 'Hello Sindre'
+```
+
+## API
+
+### chalk.`<style>[.<style>...](string, [string...])`
+
+Example: `chalk.red.bold.underline('Hello', 'world');`
+
+Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
+
+Multiple arguments will be separated by space.
+
+### chalk.level
+
+Specifies the level of color support.
+
+Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
+
+If you need to change this in a reusable module, create a new instance:
+
+```js
+const ctx = new chalk.Instance({level: 0});
+```
+
+| Level | Description |
+| :---: | :--- |
+| `0` | All colors disabled |
+| `1` | Basic color support (16 colors) |
+| `2` | 256 color support |
+| `3` | Truecolor support (16 million colors) |
+
+### chalk.supportsColor
+
+Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
+
+Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
+
+Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
+
+### chalk.stderr and chalk.stderr.supportsColor
+
+`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
+
+## Styles
+
+### Modifiers
+
+- `reset` - Resets the current color chain.
+- `bold` - Make text bold.
+- `dim` - Emitting only a small amount of light.
+- `italic` - Make text italic. *(Not widely supported)*
+- `underline` - Make text underline. *(Not widely supported)*
+- `inverse`- Inverse background and foreground colors.
+- `hidden` - Prints the text, but makes it invisible.
+- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
+- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
+
+### Colors
+
+- `black`
+- `red`
+- `green`
+- `yellow`
+- `blue`
+- `magenta`
+- `cyan`
+- `white`
+- `blackBright` (alias: `gray`, `grey`)
+- `redBright`
+- `greenBright`
+- `yellowBright`
+- `blueBright`
+- `magentaBright`
+- `cyanBright`
+- `whiteBright`
+
+### Background colors
+
+- `bgBlack`
+- `bgRed`
+- `bgGreen`
+- `bgYellow`
+- `bgBlue`
+- `bgMagenta`
+- `bgCyan`
+- `bgWhite`
+- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
+- `bgRedBright`
+- `bgGreenBright`
+- `bgYellowBright`
+- `bgBlueBright`
+- `bgMagentaBright`
+- `bgCyanBright`
+- `bgWhiteBright`
+
+## Tagged template literal
+
+Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
+
+```js
+const chalk = require('chalk');
+
+const miles = 18;
+const calculateFeet = miles => miles * 5280;
+
+console.log(chalk`
+ There are {bold 5280 feet} in a mile.
+ In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
+`);
+```
+
+Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
+
+Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
+
+```js
+console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
+console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
+console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
+```
+
+Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
+
+All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
+
+## 256 and Truecolor color support
+
+Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
+
+Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
+
+Examples:
+
+- `chalk.hex('#DEADED').underline('Hello, world!')`
+- `chalk.keyword('orange')('Some orange text')`
+- `chalk.rgb(15, 100, 204).inverse('Hello!')`
+
+Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
+
+- `chalk.bgHex('#DEADED').underline('Hello, world!')`
+- `chalk.bgKeyword('orange')('Some orange text')`
+- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
+
+The following color models can be used:
+
+- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
+- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
+- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
+- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
+- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
+- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
+- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
+- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
+
+## Windows
+
+If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
+
+## Origin story
+
+[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
+
+## chalk for enterprise
+
+Available as part of the Tidelift Subscription.
+
+The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
+
+## Related
+
+- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
+- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
+- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
+- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
+- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
+- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
+- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
+- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
+- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
+- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
+- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
+- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
+- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
+- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
+
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
diff --git a/includes/node_modules/chalk/source/index.js b/includes/node_modules/chalk/source/index.js
new file mode 100644
index 0000000..75ec663
--- /dev/null
+++ b/includes/node_modules/chalk/source/index.js
@@ -0,0 +1,229 @@
+'use strict';
+const ansiStyles = require('ansi-styles');
+const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
+const {
+ stringReplaceAll,
+ stringEncaseCRLFWithFirstIndex
+} = require('./util');
+
+const {isArray} = Array;
+
+// `supportsColor.level` → `ansiStyles.color[name]` mapping
+const levelMapping = [
+ 'ansi',
+ 'ansi',
+ 'ansi256',
+ 'ansi16m'
+];
+
+const styles = Object.create(null);
+
+const applyOptions = (object, options = {}) => {
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
+ throw new Error('The `level` option should be an integer from 0 to 3');
+ }
+
+ // Detect level if not set manually
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
+ object.level = options.level === undefined ? colorLevel : options.level;
+};
+
+class ChalkClass {
+ constructor(options) {
+ // eslint-disable-next-line no-constructor-return
+ return chalkFactory(options);
+ }
+}
+
+const chalkFactory = options => {
+ const chalk = {};
+ applyOptions(chalk, options);
+
+ chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
+
+ Object.setPrototypeOf(chalk, Chalk.prototype);
+ Object.setPrototypeOf(chalk.template, chalk);
+
+ chalk.template.constructor = () => {
+ throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
+ };
+
+ chalk.template.Instance = ChalkClass;
+
+ return chalk.template;
+};
+
+function Chalk(options) {
+ return chalkFactory(options);
+}
+
+for (const [styleName, style] of Object.entries(ansiStyles)) {
+ styles[styleName] = {
+ get() {
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
+ Object.defineProperty(this, styleName, {value: builder});
+ return builder;
+ }
+ };
+}
+
+styles.visible = {
+ get() {
+ const builder = createBuilder(this, this._styler, true);
+ Object.defineProperty(this, 'visible', {value: builder});
+ return builder;
+ }
+};
+
+const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
+
+for (const model of usedModels) {
+ styles[model] = {
+ get() {
+ const {level} = this;
+ return function (...arguments_) {
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
+ return createBuilder(this, styler, this._isEmpty);
+ };
+ }
+ };
+}
+
+for (const model of usedModels) {
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
+ styles[bgModel] = {
+ get() {
+ const {level} = this;
+ return function (...arguments_) {
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
+ return createBuilder(this, styler, this._isEmpty);
+ };
+ }
+ };
+}
+
+const proto = Object.defineProperties(() => {}, {
+ ...styles,
+ level: {
+ enumerable: true,
+ get() {
+ return this._generator.level;
+ },
+ set(level) {
+ this._generator.level = level;
+ }
+ }
+});
+
+const createStyler = (open, close, parent) => {
+ let openAll;
+ let closeAll;
+ if (parent === undefined) {
+ openAll = open;
+ closeAll = close;
+ } else {
+ openAll = parent.openAll + open;
+ closeAll = close + parent.closeAll;
+ }
+
+ return {
+ open,
+ close,
+ openAll,
+ closeAll,
+ parent
+ };
+};
+
+const createBuilder = (self, _styler, _isEmpty) => {
+ const builder = (...arguments_) => {
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
+ // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
+ return applyStyle(builder, chalkTag(builder, ...arguments_));
+ }
+
+ // Single argument is hot path, implicit coercion is faster than anything
+ // eslint-disable-next-line no-implicit-coercion
+ return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
+ };
+
+ // We alter the prototype because we must return a function, but there is
+ // no way to create a function with a different prototype
+ Object.setPrototypeOf(builder, proto);
+
+ builder._generator = self;
+ builder._styler = _styler;
+ builder._isEmpty = _isEmpty;
+
+ return builder;
+};
+
+const applyStyle = (self, string) => {
+ if (self.level <= 0 || !string) {
+ return self._isEmpty ? '' : string;
+ }
+
+ let styler = self._styler;
+
+ if (styler === undefined) {
+ return string;
+ }
+
+ const {openAll, closeAll} = styler;
+ if (string.indexOf('\u001B') !== -1) {
+ while (styler !== undefined) {
+ // Replace any instances already present with a re-opening code
+ // otherwise only the part of the string until said closing code
+ // will be colored, and the rest will simply be 'plain'.
+ string = stringReplaceAll(string, styler.close, styler.open);
+
+ styler = styler.parent;
+ }
+ }
+
+ // We can move both next actions out of loop, because remaining actions in loop won't have
+ // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
+ // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
+ const lfIndex = string.indexOf('\n');
+ if (lfIndex !== -1) {
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
+ }
+
+ return openAll + string + closeAll;
+};
+
+let template;
+const chalkTag = (chalk, ...strings) => {
+ const [firstString] = strings;
+
+ if (!isArray(firstString) || !isArray(firstString.raw)) {
+ // If chalk() was called by itself or with a string,
+ // return the string itself as a string.
+ return strings.join(' ');
+ }
+
+ const arguments_ = strings.slice(1);
+ const parts = [firstString.raw[0]];
+
+ for (let i = 1; i < firstString.length; i++) {
+ parts.push(
+ String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
+ String(firstString.raw[i])
+ );
+ }
+
+ if (template === undefined) {
+ template = require('./templates');
+ }
+
+ return template(chalk, parts.join(''));
+};
+
+Object.defineProperties(Chalk.prototype, styles);
+
+const chalk = Chalk(); // eslint-disable-line new-cap
+chalk.supportsColor = stdoutColor;
+chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
+chalk.stderr.supportsColor = stderrColor;
+
+module.exports = chalk;
diff --git a/includes/node_modules/chalk/source/templates.js b/includes/node_modules/chalk/source/templates.js
new file mode 100644
index 0000000..b130949
--- /dev/null
+++ b/includes/node_modules/chalk/source/templates.js
@@ -0,0 +1,134 @@
+'use strict';
+const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
+const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
+const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
+const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
+
+const ESCAPES = new Map([
+ ['n', '\n'],
+ ['r', '\r'],
+ ['t', '\t'],
+ ['b', '\b'],
+ ['f', '\f'],
+ ['v', '\v'],
+ ['0', '\0'],
+ ['\\', '\\'],
+ ['e', '\u001B'],
+ ['a', '\u0007']
+]);
+
+function unescape(c) {
+ const u = c[0] === 'u';
+ const bracket = c[1] === '{';
+
+ if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
+ return String.fromCharCode(parseInt(c.slice(1), 16));
+ }
+
+ if (u && bracket) {
+ return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
+ }
+
+ return ESCAPES.get(c) || c;
+}
+
+function parseArguments(name, arguments_) {
+ const results = [];
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
+ let matches;
+
+ for (const chunk of chunks) {
+ const number = Number(chunk);
+ if (!Number.isNaN(number)) {
+ results.push(number);
+ } else if ((matches = chunk.match(STRING_REGEX))) {
+ results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
+ } else {
+ throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
+ }
+ }
+
+ return results;
+}
+
+function parseStyle(style) {
+ STYLE_REGEX.lastIndex = 0;
+
+ const results = [];
+ let matches;
+
+ while ((matches = STYLE_REGEX.exec(style)) !== null) {
+ const name = matches[1];
+
+ if (matches[2]) {
+ const args = parseArguments(name, matches[2]);
+ results.push([name].concat(args));
+ } else {
+ results.push([name]);
+ }
+ }
+
+ return results;
+}
+
+function buildStyle(chalk, styles) {
+ const enabled = {};
+
+ for (const layer of styles) {
+ for (const style of layer.styles) {
+ enabled[style[0]] = layer.inverse ? null : style.slice(1);
+ }
+ }
+
+ let current = chalk;
+ for (const [styleName, styles] of Object.entries(enabled)) {
+ if (!Array.isArray(styles)) {
+ continue;
+ }
+
+ if (!(styleName in current)) {
+ throw new Error(`Unknown Chalk style: ${styleName}`);
+ }
+
+ current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
+ }
+
+ return current;
+}
+
+module.exports = (chalk, temporary) => {
+ const styles = [];
+ const chunks = [];
+ let chunk = [];
+
+ // eslint-disable-next-line max-params
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
+ if (escapeCharacter) {
+ chunk.push(unescape(escapeCharacter));
+ } else if (style) {
+ const string = chunk.join('');
+ chunk = [];
+ chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
+ styles.push({inverse, styles: parseStyle(style)});
+ } else if (close) {
+ if (styles.length === 0) {
+ throw new Error('Found extraneous } in Chalk template literal');
+ }
+
+ chunks.push(buildStyle(chalk, styles)(chunk.join('')));
+ chunk = [];
+ styles.pop();
+ } else {
+ chunk.push(character);
+ }
+ });
+
+ chunks.push(chunk.join(''));
+
+ if (styles.length > 0) {
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
+ throw new Error(errMessage);
+ }
+
+ return chunks.join('');
+};
diff --git a/includes/node_modules/chalk/source/util.js b/includes/node_modules/chalk/source/util.js
new file mode 100644
index 0000000..ca466fd
--- /dev/null
+++ b/includes/node_modules/chalk/source/util.js
@@ -0,0 +1,39 @@
+'use strict';
+
+const stringReplaceAll = (string, substring, replacer) => {
+ let index = string.indexOf(substring);
+ if (index === -1) {
+ return string;
+ }
+
+ const substringLength = substring.length;
+ let endIndex = 0;
+ let returnValue = '';
+ do {
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
+ endIndex = index + substringLength;
+ index = string.indexOf(substring, endIndex);
+ } while (index !== -1);
+
+ returnValue += string.substr(endIndex);
+ return returnValue;
+};
+
+const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
+ let endIndex = 0;
+ let returnValue = '';
+ do {
+ const gotCR = string[index - 1] === '\r';
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
+ endIndex = index + 1;
+ index = string.indexOf('\n', endIndex);
+ } while (index !== -1);
+
+ returnValue += string.substr(endIndex);
+ return returnValue;
+};
+
+module.exports = {
+ stringReplaceAll,
+ stringEncaseCRLFWithFirstIndex
+};
diff --git a/includes/node_modules/color-convert/CHANGELOG.md b/includes/node_modules/color-convert/CHANGELOG.md
new file mode 100644
index 0000000..0a7bce4
--- /dev/null
+++ b/includes/node_modules/color-convert/CHANGELOG.md
@@ -0,0 +1,54 @@
+# 1.0.0 - 2016-01-07
+
+- Removed: unused speed test
+- Added: Automatic routing between previously unsupported conversions
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Removed: `convert()` class
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Changed: all functions to lookup dictionary
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Changed: `ansi` to `ansi256`
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Fixed: argument grouping for functions requiring only one argument
+([#27](https://github.com/Qix-/color-convert/pull/27))
+
+# 0.6.0 - 2015-07-23
+
+- Added: methods to handle
+[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
+ - rgb2ansi16
+ - rgb2ansi
+ - hsl2ansi16
+ - hsl2ansi
+ - hsv2ansi16
+ - hsv2ansi
+ - hwb2ansi16
+ - hwb2ansi
+ - cmyk2ansi16
+ - cmyk2ansi
+ - keyword2ansi16
+ - keyword2ansi
+ - ansi162rgb
+ - ansi162hsl
+ - ansi162hsv
+ - ansi162hwb
+ - ansi162cmyk
+ - ansi162keyword
+ - ansi2rgb
+ - ansi2hsl
+ - ansi2hsv
+ - ansi2hwb
+ - ansi2cmyk
+ - ansi2keyword
+([#18](https://github.com/harthur/color-convert/pull/18))
+
+# 0.5.3 - 2015-06-02
+
+- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
+([#15](https://github.com/harthur/color-convert/issues/15))
+
+---
+
+Check out commit logs for older releases
diff --git a/includes/node_modules/color-convert/LICENSE b/includes/node_modules/color-convert/LICENSE
new file mode 100644
index 0000000..5b4c386
--- /dev/null
+++ b/includes/node_modules/color-convert/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/includes/node_modules/color-convert/README.md b/includes/node_modules/color-convert/README.md
new file mode 100644
index 0000000..d4b08fc
--- /dev/null
+++ b/includes/node_modules/color-convert/README.md
@@ -0,0 +1,68 @@
+# color-convert
+
+[![Build Status](https://travis-ci.org/Qix-/color-convert.svg?branch=master)](https://travis-ci.org/Qix-/color-convert)
+
+Color-convert is a color conversion library for JavaScript and node.
+It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
+
+```js
+var convert = require('color-convert');
+
+convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
+convert.keyword.rgb('blue'); // [0, 0, 255]
+
+var rgbChannels = convert.rgb.channels; // 3
+var cmykChannels = convert.cmyk.channels; // 4
+var ansiChannels = convert.ansi16.channels; // 1
+```
+
+# Install
+
+```console
+$ npm install color-convert
+```
+
+# API
+
+Simply get the property of the _from_ and _to_ conversion that you're looking for.
+
+All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function.
+
+All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
+
+```js
+var convert = require('color-convert');
+
+// Hex to LAB
+convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
+convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
+
+// RGB to CMYK
+convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
+convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
+```
+
+### Arrays
+All functions that accept multiple arguments also support passing an array.
+
+Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
+
+```js
+var convert = require('color-convert');
+
+convert.rgb.hex(123, 45, 67); // '7B2D43'
+convert.rgb.hex([123, 45, 67]); // '7B2D43'
+```
+
+## Routing
+
+Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex).
+
+Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js).
+
+# Contribute
+
+If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.
+
+# License
+Copyright &copy; 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).
diff --git a/includes/node_modules/color-convert/conversions.js b/includes/node_modules/color-convert/conversions.js
new file mode 100644
index 0000000..2657f26
--- /dev/null
+++ b/includes/node_modules/color-convert/conversions.js
@@ -0,0 +1,839 @@
+/* MIT license */
+/* eslint-disable no-mixed-operators */
+const cssKeywords = require('color-name');
+
+// NOTE: conversions should only return primitive values (i.e. arrays, or
+// values that give correct `typeof` results).
+// do not use box values types (i.e. Number(), String(), etc.)
+
+const reverseKeywords = {};
+for (const key of Object.keys(cssKeywords)) {
+ reverseKeywords[cssKeywords[key]] = key;
+}
+
+const convert = {
+ rgb: {channels: 3, labels: 'rgb'},
+ hsl: {channels: 3, labels: 'hsl'},
+ hsv: {channels: 3, labels: 'hsv'},
+ hwb: {channels: 3, labels: 'hwb'},
+ cmyk: {channels: 4, labels: 'cmyk'},
+ xyz: {channels: 3, labels: 'xyz'},
+ lab: {channels: 3, labels: 'lab'},
+ lch: {channels: 3, labels: 'lch'},
+ hex: {channels: 1, labels: ['hex']},
+ keyword: {channels: 1, labels: ['keyword']},
+ ansi16: {channels: 1, labels: ['ansi16']},
+ ansi256: {channels: 1, labels: ['ansi256']},
+ hcg: {channels: 3, labels: ['h', 'c', 'g']},
+ apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
+ gray: {channels: 1, labels: ['gray']}
+};
+
+module.exports = convert;
+
+// Hide .channels and .labels properties
+for (const model of Object.keys(convert)) {
+ if (!('channels' in convert[model])) {
+ throw new Error('missing channels property: ' + model);
+ }
+
+ if (!('labels' in convert[model])) {
+ throw new Error('missing channel labels property: ' + model);
+ }
+
+ if (convert[model].labels.length !== convert[model].channels) {
+ throw new Error('channel and label counts mismatch: ' + model);
+ }
+
+ const {channels, labels} = convert[model];
+ delete convert[model].channels;
+ delete convert[model].labels;
+ Object.defineProperty(convert[model], 'channels', {value: channels});
+ Object.defineProperty(convert[model], 'labels', {value: labels});
+}
+
+convert.rgb.hsl = function (rgb) {
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+ const min = Math.min(r, g, b);
+ const max = Math.max(r, g, b);
+ const delta = max - min;
+ let h;
+ let s;
+
+ if (max === min) {
+ h = 0;
+ } else if (r === max) {
+ h = (g - b) / delta;
+ } else if (g === max) {
+ h = 2 + (b - r) / delta;
+ } else if (b === max) {
+ h = 4 + (r - g) / delta;
+ }
+
+ h = Math.min(h * 60, 360);
+
+ if (h < 0) {
+ h += 360;
+ }
+
+ const l = (min + max) / 2;
+
+ if (max === min) {
+ s = 0;
+ } else if (l <= 0.5) {
+ s = delta / (max + min);
+ } else {
+ s = delta / (2 - max - min);
+ }
+
+ return [h, s * 100, l * 100];
+};
+
+convert.rgb.hsv = function (rgb) {
+ let rdif;
+ let gdif;
+ let bdif;
+ let h;
+ let s;
+
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+ const v = Math.max(r, g, b);
+ const diff = v - Math.min(r, g, b);
+ const diffc = function (c) {
+ return (v - c) / 6 / diff + 1 / 2;
+ };
+
+ if (diff === 0) {
+ h = 0;
+ s = 0;
+ } else {
+ s = diff / v;
+ rdif = diffc(r);
+ gdif = diffc(g);
+ bdif = diffc(b);
+
+ if (r === v) {
+ h = bdif - gdif;
+ } else if (g === v) {
+ h = (1 / 3) + rdif - bdif;
+ } else if (b === v) {
+ h = (2 / 3) + gdif - rdif;
+ }
+
+ if (h < 0) {
+ h += 1;
+ } else if (h > 1) {
+ h -= 1;
+ }
+ }
+
+ return [
+ h * 360,
+ s * 100,
+ v * 100
+ ];
+};
+
+convert.rgb.hwb = function (rgb) {
+ const r = rgb[0];
+ const g = rgb[1];
+ let b = rgb[2];
+ const h = convert.rgb.hsl(rgb)[0];
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
+
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
+
+ return [h, w * 100, b * 100];
+};
+
+convert.rgb.cmyk = function (rgb) {
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+
+ const k = Math.min(1 - r, 1 - g, 1 - b);
+ const c = (1 - r - k) / (1 - k) || 0;
+ const m = (1 - g - k) / (1 - k) || 0;
+ const y = (1 - b - k) / (1 - k) || 0;
+
+ return [c * 100, m * 100, y * 100, k * 100];
+};
+
+function comparativeDistance(x, y) {
+ /*
+ See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
+ */
+ return (
+ ((x[0] - y[0]) ** 2) +
+ ((x[1] - y[1]) ** 2) +
+ ((x[2] - y[2]) ** 2)
+ );
+}
+
+convert.rgb.keyword = function (rgb) {
+ const reversed = reverseKeywords[rgb];
+ if (reversed) {
+ return reversed;
+ }
+
+ let currentClosestDistance = Infinity;
+ let currentClosestKeyword;
+
+ for (const keyword of Object.keys(cssKeywords)) {
+ const value = cssKeywords[keyword];
+
+ // Compute comparative distance
+ const distance = comparativeDistance(rgb, value);
+
+ // Check if its less, if so set as closest
+ if (distance < currentClosestDistance) {
+ currentClosestDistance = distance;
+ currentClosestKeyword = keyword;
+ }
+ }
+
+ return currentClosestKeyword;
+};
+
+convert.keyword.rgb = function (keyword) {
+ return cssKeywords[keyword];
+};
+
+convert.rgb.xyz = function (rgb) {
+ let r = rgb[0] / 255;
+ let g = rgb[1] / 255;
+ let b = rgb[2] / 255;
+
+ // Assume sRGB
+ r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
+ g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
+ b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
+
+ const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
+ const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
+ const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
+
+ return [x * 100, y * 100, z * 100];
+};
+
+convert.rgb.lab = function (rgb) {
+ const xyz = convert.rgb.xyz(rgb);
+ let x = xyz[0];
+ let y = xyz[1];
+ let z = xyz[2];
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
+
+ const l = (116 * y) - 16;
+ const a = 500 * (x - y);
+ const b = 200 * (y - z);
+
+ return [l, a, b];
+};
+
+convert.hsl.rgb = function (hsl) {
+ const h = hsl[0] / 360;
+ const s = hsl[1] / 100;
+ const l = hsl[2] / 100;
+ let t2;
+ let t3;
+ let val;
+
+ if (s === 0) {
+ val = l * 255;
+ return [val, val, val];
+ }
+
+ if (l < 0.5) {
+ t2 = l * (1 + s);
+ } else {
+ t2 = l + s - l * s;
+ }
+
+ const t1 = 2 * l - t2;
+
+ const rgb = [0, 0, 0];
+ for (let i = 0; i < 3; i++) {
+ t3 = h + 1 / 3 * -(i - 1);
+ if (t3 < 0) {
+ t3++;
+ }
+
+ if (t3 > 1) {
+ t3--;
+ }
+
+ if (6 * t3 < 1) {
+ val = t1 + (t2 - t1) * 6 * t3;
+ } else if (2 * t3 < 1) {
+ val = t2;
+ } else if (3 * t3 < 2) {
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
+ } else {
+ val = t1;
+ }
+
+ rgb[i] = val * 255;
+ }
+
+ return rgb;
+};
+
+convert.hsl.hsv = function (hsl) {
+ const h = hsl[0];
+ let s = hsl[1] / 100;
+ let l = hsl[2] / 100;
+ let smin = s;
+ const lmin = Math.max(l, 0.01);
+
+ l *= 2;
+ s *= (l <= 1) ? l : 2 - l;
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
+ const v = (l + s) / 2;
+ const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
+
+ return [h, sv * 100, v * 100];
+};
+
+convert.hsv.rgb = function (hsv) {
+ const h = hsv[0] / 60;
+ const s = hsv[1] / 100;
+ let v = hsv[2] / 100;
+ const hi = Math.floor(h) % 6;
+
+ const f = h - Math.floor(h);
+ const p = 255 * v * (1 - s);
+ const q = 255 * v * (1 - (s * f));
+ const t = 255 * v * (1 - (s * (1 - f)));
+ v *= 255;
+
+ switch (hi) {
+ case 0:
+ return [v, t, p];
+ case 1:
+ return [q, v, p];
+ case 2:
+ return [p, v, t];
+ case 3:
+ return [p, q, v];
+ case 4:
+ return [t, p, v];
+ case 5:
+ return [v, p, q];
+ }
+};
+
+convert.hsv.hsl = function (hsv) {
+ const h = hsv[0];
+ const s = hsv[1] / 100;
+ const v = hsv[2] / 100;
+ const vmin = Math.max(v, 0.01);
+ let sl;
+ let l;
+
+ l = (2 - s) * v;
+ const lmin = (2 - s) * vmin;
+ sl = s * vmin;
+ sl /= (lmin <= 1) ? lmin : 2 - lmin;
+ sl = sl || 0;
+ l /= 2;
+
+ return [h, sl * 100, l * 100];
+};
+
+// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
+convert.hwb.rgb = function (hwb) {
+ const h = hwb[0] / 360;
+ let wh = hwb[1] / 100;
+ let bl = hwb[2] / 100;
+ const ratio = wh + bl;
+ let f;
+
+ // Wh + bl cant be > 1
+ if (ratio > 1) {
+ wh /= ratio;
+ bl /= ratio;
+ }
+
+ const i = Math.floor(6 * h);
+ const v = 1 - bl;
+ f = 6 * h - i;
+
+ if ((i & 0x01) !== 0) {
+ f = 1 - f;
+ }
+
+ const n = wh + f * (v - wh); // Linear interpolation
+
+ let r;
+ let g;
+ let b;
+ /* eslint-disable max-statements-per-line,no-multi-spaces */
+ switch (i) {
+ default:
+ case 6:
+ case 0: r = v; g = n; b = wh; break;
+ case 1: r = n; g = v; b = wh; break;
+ case 2: r = wh; g = v; b = n; break;
+ case 3: r = wh; g = n; b = v; break;
+ case 4: r = n; g = wh; b = v; break;
+ case 5: r = v; g = wh; b = n; break;
+ }
+ /* eslint-enable max-statements-per-line,no-multi-spaces */
+
+ return [r * 255, g * 255, b * 255];
+};
+
+convert.cmyk.rgb = function (cmyk) {
+ const c = cmyk[0] / 100;
+ const m = cmyk[1] / 100;
+ const y = cmyk[2] / 100;
+ const k = cmyk[3] / 100;
+
+ const r = 1 - Math.min(1, c * (1 - k) + k);
+ const g = 1 - Math.min(1, m * (1 - k) + k);
+ const b = 1 - Math.min(1, y * (1 - k) + k);
+
+ return [r * 255, g * 255, b * 255];
+};
+
+convert.xyz.rgb = function (xyz) {
+ const x = xyz[0] / 100;
+ const y = xyz[1] / 100;
+ const z = xyz[2] / 100;
+ let r;
+ let g;
+ let b;
+
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
+
+ // Assume sRGB
+ r = r > 0.0031308
+ ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
+ : r * 12.92;
+
+ g = g > 0.0031308
+ ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
+ : g * 12.92;
+
+ b = b > 0.0031308
+ ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
+ : b * 12.92;
+
+ r = Math.min(Math.max(0, r), 1);
+ g = Math.min(Math.max(0, g), 1);
+ b = Math.min(Math.max(0, b), 1);
+
+ return [r * 255, g * 255, b * 255];
+};
+
+convert.xyz.lab = function (xyz) {
+ let x = xyz[0];
+ let y = xyz[1];
+ let z = xyz[2];
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
+
+ const l = (116 * y) - 16;
+ const a = 500 * (x - y);
+ const b = 200 * (y - z);
+
+ return [l, a, b];
+};
+
+convert.lab.xyz = function (lab) {
+ const l = lab[0];
+ const a = lab[1];
+ const b = lab[2];
+ let x;
+ let y;
+ let z;
+
+ y = (l + 16) / 116;
+ x = a / 500 + y;
+ z = y - b / 200;
+
+ const y2 = y ** 3;
+ const x2 = x ** 3;
+ const z2 = z ** 3;
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
+
+ x *= 95.047;
+ y *= 100;
+ z *= 108.883;
+
+ return [x, y, z];
+};
+
+convert.lab.lch = function (lab) {
+ const l = lab[0];
+ const a = lab[1];
+ const b = lab[2];
+ let h;
+
+ const hr = Math.atan2(b, a);
+ h = hr * 360 / 2 / Math.PI;
+
+ if (h < 0) {
+ h += 360;
+ }
+
+ const c = Math.sqrt(a * a + b * b);
+
+ return [l, c, h];
+};
+
+convert.lch.lab = function (lch) {
+ const l = lch[0];
+ const c = lch[1];
+ const h = lch[2];
+
+ const hr = h / 360 * 2 * Math.PI;
+ const a = c * Math.cos(hr);
+ const b = c * Math.sin(hr);
+
+ return [l, a, b];
+};
+
+convert.rgb.ansi16 = function (args, saturation = null) {
+ const [r, g, b] = args;
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
+
+ value = Math.round(value / 50);
+
+ if (value === 0) {
+ return 30;
+ }
+
+ let ansi = 30
+ + ((Math.round(b / 255) << 2)
+ | (Math.round(g / 255) << 1)
+ | Math.round(r / 255));
+
+ if (value === 2) {
+ ansi += 60;
+ }
+
+ return ansi;
+};
+
+convert.hsv.ansi16 = function (args) {
+ // Optimization here; we already know the value and don't need to get
+ // it converted for us.
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
+};
+
+convert.rgb.ansi256 = function (args) {
+ const r = args[0];
+ const g = args[1];
+ const b = args[2];
+
+ // We use the extended greyscale palette here, with the exception of
+ // black and white. normal palette only has 4 greyscale shades.
+ if (r === g && g === b) {
+ if (r < 8) {
+ return 16;
+ }
+
+ if (r > 248) {
+ return 231;
+ }
+
+ return Math.round(((r - 8) / 247) * 24) + 232;
+ }
+
+ const ansi = 16
+ + (36 * Math.round(r / 255 * 5))
+ + (6 * Math.round(g / 255 * 5))
+ + Math.round(b / 255 * 5);
+
+ return ansi;
+};
+
+convert.ansi16.rgb = function (args) {
+ let color = args % 10;
+
+ // Handle greyscale
+ if (color === 0 || color === 7) {
+ if (args > 50) {
+ color += 3.5;
+ }
+
+ color = color / 10.5 * 255;
+
+ return [color, color, color];
+ }
+
+ const mult = (~~(args > 50) + 1) * 0.5;
+ const r = ((color & 1) * mult) * 255;
+ const g = (((color >> 1) & 1) * mult) * 255;
+ const b = (((color >> 2) & 1) * mult) * 255;
+
+ return [r, g, b];
+};
+
+convert.ansi256.rgb = function (args) {
+ // Handle greyscale
+ if (args >= 232) {
+ const c = (args - 232) * 10 + 8;
+ return [c, c, c];
+ }
+
+ args -= 16;
+
+ let rem;
+ const r = Math.floor(args / 36) / 5 * 255;
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
+ const b = (rem % 6) / 5 * 255;
+
+ return [r, g, b];
+};
+
+convert.rgb.hex = function (args) {
+ const integer = ((Math.round(args[0]) & 0xFF) << 16)
+ + ((Math.round(args[1]) & 0xFF) << 8)
+ + (Math.round(args[2]) & 0xFF);
+
+ const string = integer.toString(16).toUpperCase();
+ return '000000'.substring(string.length) + string;
+};
+
+convert.hex.rgb = function (args) {
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
+ if (!match) {
+ return [0, 0, 0];
+ }
+
+ let colorString = match[0];
+
+ if (match[0].length === 3) {
+ colorString = colorString.split('').map(char => {
+ return char + char;
+ }).join('');
+ }
+
+ const integer = parseInt(colorString, 16);
+ const r = (integer >> 16) & 0xFF;
+ const g = (integer >> 8) & 0xFF;
+ const b = integer & 0xFF;
+
+ return [r, g, b];
+};
+
+convert.rgb.hcg = function (rgb) {
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+ const max = Math.max(Math.max(r, g), b);
+ const min = Math.min(Math.min(r, g), b);
+ const chroma = (max - min);
+ let grayscale;
+ let hue;
+
+ if (chroma < 1) {
+ grayscale = min / (1 - chroma);
+ } else {
+ grayscale = 0;
+ }
+
+ if (chroma <= 0) {
+ hue = 0;
+ } else
+ if (max === r) {
+ hue = ((g - b) / chroma) % 6;
+ } else
+ if (max === g) {
+ hue = 2 + (b - r) / chroma;
+ } else {
+ hue = 4 + (r - g) / chroma;
+ }
+
+ hue /= 6;
+ hue %= 1;
+
+ return [hue * 360, chroma * 100, grayscale * 100];
+};
+
+convert.hsl.hcg = function (hsl) {
+ const s = hsl[1] / 100;
+ const l = hsl[2] / 100;
+
+ const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
+
+ let f = 0;
+ if (c < 1.0) {
+ f = (l - 0.5 * c) / (1.0 - c);
+ }
+
+ return [hsl[0], c * 100, f * 100];
+};
+
+convert.hsv.hcg = function (hsv) {
+ const s = hsv[1] / 100;
+ const v = hsv[2] / 100;
+
+ const c = s * v;
+ let f = 0;
+
+ if (c < 1.0) {
+ f = (v - c) / (1 - c);
+ }
+
+ return [hsv[0], c * 100, f * 100];
+};
+
+convert.hcg.rgb = function (hcg) {
+ const h = hcg[0] / 360;
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+
+ if (c === 0.0) {
+ return [g * 255, g * 255, g * 255];
+ }
+
+ const pure = [0, 0, 0];
+ const hi = (h % 1) * 6;
+ const v = hi % 1;
+ const w = 1 - v;
+ let mg = 0;
+
+ /* eslint-disable max-statements-per-line */
+ switch (Math.floor(hi)) {
+ case 0:
+ pure[0] = 1; pure[1] = v; pure[2] = 0; break;
+ case 1:
+ pure[0] = w; pure[1] = 1; pure[2] = 0; break;
+ case 2:
+ pure[0] = 0; pure[1] = 1; pure[2] = v; break;
+ case 3:
+ pure[0] = 0; pure[1] = w; pure[2] = 1; break;
+ case 4:
+ pure[0] = v; pure[1] = 0; pure[2] = 1; break;
+ default:
+ pure[0] = 1; pure[1] = 0; pure[2] = w;
+ }
+ /* eslint-enable max-statements-per-line */
+
+ mg = (1.0 - c) * g;
+
+ return [
+ (c * pure[0] + mg) * 255,
+ (c * pure[1] + mg) * 255,
+ (c * pure[2] + mg) * 255
+ ];
+};
+
+convert.hcg.hsv = function (hcg) {
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+
+ const v = c + g * (1.0 - c);
+ let f = 0;
+
+ if (v > 0.0) {
+ f = c / v;
+ }
+
+ return [hcg[0], f * 100, v * 100];
+};
+
+convert.hcg.hsl = function (hcg) {
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+
+ const l = g * (1.0 - c) + 0.5 * c;
+ let s = 0;
+
+ if (l > 0.0 && l < 0.5) {
+ s = c / (2 * l);
+ } else
+ if (l >= 0.5 && l < 1.0) {
+ s = c / (2 * (1 - l));
+ }
+
+ return [hcg[0], s * 100, l * 100];
+};
+
+convert.hcg.hwb = function (hcg) {
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+ const v = c + g * (1.0 - c);
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
+};
+
+convert.hwb.hcg = function (hwb) {
+ const w = hwb[1] / 100;
+ const b = hwb[2] / 100;
+ const v = 1 - b;
+ const c = v - w;
+ let g = 0;
+
+ if (c < 1) {
+ g = (v - c) / (1 - c);
+ }
+
+ return [hwb[0], c * 100, g * 100];
+};
+
+convert.apple.rgb = function (apple) {
+ return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
+};
+
+convert.rgb.apple = function (rgb) {
+ return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
+};
+
+convert.gray.rgb = function (args) {
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
+};
+
+convert.gray.hsl = function (args) {
+ return [0, 0, args[0]];
+};
+
+convert.gray.hsv = convert.gray.hsl;
+
+convert.gray.hwb = function (gray) {
+ return [0, 100, gray[0]];
+};
+
+convert.gray.cmyk = function (gray) {
+ return [0, 0, 0, gray[0]];
+};
+
+convert.gray.lab = function (gray) {
+ return [gray[0], 0, 0];
+};
+
+convert.gray.hex = function (gray) {
+ const val = Math.round(gray[0] / 100 * 255) & 0xFF;
+ const integer = (val << 16) + (val << 8) + val;
+
+ const string = integer.toString(16).toUpperCase();
+ return '000000'.substring(string.length) + string;
+};
+
+convert.rgb.gray = function (rgb) {
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
+ return [val / 255 * 100];
+};
diff --git a/includes/node_modules/color-convert/index.js b/includes/node_modules/color-convert/index.js
new file mode 100644
index 0000000..b648e57
--- /dev/null
+++ b/includes/node_modules/color-convert/index.js
@@ -0,0 +1,81 @@
+const conversions = require('./conversions');
+const route = require('./route');
+
+const convert = {};
+
+const models = Object.keys(conversions);
+
+function wrapRaw(fn) {
+ const wrappedFn = function (...args) {
+ const arg0 = args[0];
+ if (arg0 === undefined || arg0 === null) {
+ return arg0;
+ }
+
+ if (arg0.length > 1) {
+ args = arg0;
+ }
+
+ return fn(args);
+ };
+
+ // Preserve .conversion property if there is one
+ if ('conversion' in fn) {
+ wrappedFn.conversion = fn.conversion;
+ }
+
+ return wrappedFn;
+}
+
+function wrapRounded(fn) {
+ const wrappedFn = function (...args) {
+ const arg0 = args[0];
+
+ if (arg0 === undefined || arg0 === null) {
+ return arg0;
+ }
+
+ if (arg0.length > 1) {
+ args = arg0;
+ }
+
+ const result = fn(args);
+
+ // We're assuming the result is an array here.
+ // see notice in conversions.js; don't use box types
+ // in conversion functions.
+ if (typeof result === 'object') {
+ for (let len = result.length, i = 0; i < len; i++) {
+ result[i] = Math.round(result[i]);
+ }
+ }
+
+ return result;
+ };
+
+ // Preserve .conversion property if there is one
+ if ('conversion' in fn) {
+ wrappedFn.conversion = fn.conversion;
+ }
+
+ return wrappedFn;
+}
+
+models.forEach(fromModel => {
+ convert[fromModel] = {};
+
+ Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
+ Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
+
+ const routes = route(fromModel);
+ const routeModels = Object.keys(routes);
+
+ routeModels.forEach(toModel => {
+ const fn = routes[toModel];
+
+ convert[fromModel][toModel] = wrapRounded(fn);
+ convert[fromModel][toModel].raw = wrapRaw(fn);
+ });
+});
+
+module.exports = convert;
diff --git a/includes/node_modules/color-convert/package.json b/includes/node_modules/color-convert/package.json
new file mode 100644
index 0000000..6e48000
--- /dev/null
+++ b/includes/node_modules/color-convert/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "color-convert",
+ "description": "Plain color conversion functions",
+ "version": "2.0.1",
+ "author": "Heather Arthur <fayearthur@gmail.com>",
+ "license": "MIT",
+ "repository": "Qix-/color-convert",
+ "scripts": {
+ "pretest": "xo",
+ "test": "node test/basic.js"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ },
+ "keywords": [
+ "color",
+ "colour",
+ "convert",
+ "converter",
+ "conversion",
+ "rgb",
+ "hsl",
+ "hsv",
+ "hwb",
+ "cmyk",
+ "ansi",
+ "ansi16"
+ ],
+ "files": [
+ "index.js",
+ "conversions.js",
+ "route.js"
+ ],
+ "xo": {
+ "rules": {
+ "default-case": 0,
+ "no-inline-comments": 0,
+ "operator-linebreak": 0
+ }
+ },
+ "devDependencies": {
+ "chalk": "^2.4.2",
+ "xo": "^0.24.0"
+ },
+ "dependencies": {
+ "color-name": "~1.1.4"
+ }
+}
diff --git a/includes/node_modules/color-convert/route.js b/includes/node_modules/color-convert/route.js
new file mode 100644
index 0000000..1a08521
--- /dev/null
+++ b/includes/node_modules/color-convert/route.js
@@ -0,0 +1,97 @@
+const conversions = require('./conversions');
+
+/*
+ This function routes a model to all other models.
+
+ all functions that are routed have a property `.conversion` attached
+ to the returned synthetic function. This property is an array
+ of strings, each with the steps in between the 'from' and 'to'
+ color models (inclusive).
+
+ conversions that are not possible simply are not included.
+*/
+
+function buildGraph() {
+ const graph = {};
+ // https://jsperf.com/object-keys-vs-for-in-with-closure/3
+ const models = Object.keys(conversions);
+
+ for (let len = models.length, i = 0; i < len; i++) {
+ graph[models[i]] = {
+ // http://jsperf.com/1-vs-infinity
+ // micro-opt, but this is simple.
+ distance: -1,
+ parent: null
+ };
+ }
+
+ return graph;
+}
+
+// https://en.wikipedia.org/wiki/Breadth-first_search
+function deriveBFS(fromModel) {
+ const graph = buildGraph();
+ const queue = [fromModel]; // Unshift -> queue -> pop
+
+ graph[fromModel].distance = 0;
+
+ while (queue.length) {
+ const current = queue.pop();
+ const adjacents = Object.keys(conversions[current]);
+
+ for (let len = adjacents.length, i = 0; i < len; i++) {
+ const adjacent = adjacents[i];
+ const node = graph[adjacent];
+
+ if (node.distance === -1) {
+ node.distance = graph[current].distance + 1;
+ node.parent = current;
+ queue.unshift(adjacent);
+ }
+ }
+ }
+
+ return graph;
+}
+
+function link(from, to) {
+ return function (args) {
+ return to(from(args));
+ };
+}
+
+function wrapConversion(toModel, graph) {
+ const path = [graph[toModel].parent, toModel];
+ let fn = conversions[graph[toModel].parent][toModel];
+
+ let cur = graph[toModel].parent;
+ while (graph[cur].parent) {
+ path.unshift(graph[cur].parent);
+ fn = link(conversions[graph[cur].parent][cur], fn);
+ cur = graph[cur].parent;
+ }
+
+ fn.conversion = path;
+ return fn;
+}
+
+module.exports = function (fromModel) {
+ const graph = deriveBFS(fromModel);
+ const conversion = {};
+
+ const models = Object.keys(graph);
+ for (let len = models.length, i = 0; i < len; i++) {
+ const toModel = models[i];
+ const node = graph[toModel];
+
+ if (node.parent === null) {
+ // No possible conversion, or this node is the source model.
+ continue;
+ }
+
+ conversion[toModel] = wrapConversion(toModel, graph);
+ }
+
+ return conversion;
+};
+
diff --git a/includes/node_modules/color-name/LICENSE b/includes/node_modules/color-name/LICENSE
new file mode 100644
index 0000000..c6b1001
--- /dev/null
+++ b/includes/node_modules/color-name/LICENSE
@@ -0,0 +1,8 @@
+The MIT License (MIT)
+Copyright (c) 2015 Dmitry Ivanov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/includes/node_modules/color-name/README.md b/includes/node_modules/color-name/README.md
new file mode 100644
index 0000000..932b979
--- /dev/null
+++ b/includes/node_modules/color-name/README.md
@@ -0,0 +1,11 @@
+A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
+
+[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/)
+
+
+```js
+var colors = require('color-name');
+colors.red //[255,0,0]
+```
+
+<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>
diff --git a/includes/node_modules/color-name/index.js b/includes/node_modules/color-name/index.js
new file mode 100644
index 0000000..b7c198a
--- /dev/null
+++ b/includes/node_modules/color-name/index.js
@@ -0,0 +1,152 @@
+'use strict'
+
+module.exports = {
+ "aliceblue": [240, 248, 255],
+ "antiquewhite": [250, 235, 215],
+ "aqua": [0, 255, 255],
+ "aquamarine": [127, 255, 212],
+ "azure": [240, 255, 255],
+ "beige": [245, 245, 220],
+ "bisque": [255, 228, 196],
+ "black": [0, 0, 0],
+ "blanchedalmond": [255, 235, 205],
+ "blue": [0, 0, 255],
+ "blueviolet": [138, 43, 226],
+ "brown": [165, 42, 42],
+ "burlywood": [222, 184, 135],
+ "cadetblue": [95, 158, 160],
+ "chartreuse": [127, 255, 0],
+ "chocolate": [210, 105, 30],
+ "coral": [255, 127, 80],
+ "cornflowerblue": [100, 149, 237],
+ "cornsilk": [255, 248, 220],
+ "crimson": [220, 20, 60],
+ "cyan": [0, 255, 255],
+ "darkblue": [0, 0, 139],
+ "darkcyan": [0, 139, 139],
+ "darkgoldenrod": [184, 134, 11],
+ "darkgray": [169, 169, 169],
+ "darkgreen": [0, 100, 0],
+ "darkgrey": [169, 169, 169],
+ "darkkhaki": [189, 183, 107],
+ "darkmagenta": [139, 0, 139],
+ "darkolivegreen": [85, 107, 47],
+ "darkorange": [255, 140, 0],
+ "darkorchid": [153, 50, 204],
+ "darkred": [139, 0, 0],
+ "darksalmon": [233, 150, 122],
+ "darkseagreen": [143, 188, 143],
+ "darkslateblue": [72, 61, 139],
+ "darkslategray": [47, 79, 79],
+ "darkslategrey": [47, 79, 79],
+ "darkturquoise": [0, 206, 209],
+ "darkviolet": [148, 0, 211],
+ "deeppink": [255, 20, 147],
+ "deepskyblue": [0, 191, 255],
+ "dimgray": [105, 105, 105],
+ "dimgrey": [105, 105, 105],
+ "dodgerblue": [30, 144, 255],
+ "firebrick": [178, 34, 34],
+ "floralwhite": [255, 250, 240],
+ "forestgreen": [34, 139, 34],
+ "fuchsia": [255, 0, 255],
+ "gainsboro": [220, 220, 220],
+ "ghostwhite": [248, 248, 255],
+ "gold": [255, 215, 0],
+ "goldenrod": [218, 165, 32],
+ "gray": [128, 128, 128],
+ "green": [0, 128, 0],
+ "greenyellow": [173, 255, 47],
+ "grey": [128, 128, 128],
+ "honeydew": [240, 255, 240],
+ "hotpink": [255, 105, 180],
+ "indianred": [205, 92, 92],
+ "indigo": [75, 0, 130],
+ "ivory": [255, 255, 240],
+ "khaki": [240, 230, 140],
+ "lavender": [230, 230, 250],
+ "lavenderblush": [255, 240, 245],
+ "lawngreen": [124, 252, 0],
+ "lemonchiffon": [255, 250, 205],
+ "lightblue": [173, 216, 230],
+ "lightcoral": [240, 128, 128],
+ "lightcyan": [224, 255, 255],
+ "lightgoldenrodyellow": [250, 250, 210],
+ "lightgray": [211, 211, 211],
+ "lightgreen": [144, 238, 144],
+ "lightgrey": [211, 211, 211],
+ "lightpink": [255, 182, 193],
+ "lightsalmon": [255, 160, 122],
+ "lightseagreen": [32, 178, 170],
+ "lightskyblue": [135, 206, 250],
+ "lightslategray": [119, 136, 153],
+ "lightslategrey": [119, 136, 153],
+ "lightsteelblue": [176, 196, 222],
+ "lightyellow": [255, 255, 224],
+ "lime": [0, 255, 0],
+ "limegreen": [50, 205, 50],
+ "linen": [250, 240, 230],
+ "magenta": [255, 0, 255],
+ "maroon": [128, 0, 0],
+ "mediumaquamarine": [102, 205, 170],
+ "mediumblue": [0, 0, 205],
+ "mediumorchid": [186, 85, 211],
+ "mediumpurple": [147, 112, 219],
+ "mediumseagreen": [60, 179, 113],
+ "mediumslateblue": [123, 104, 238],
+ "mediumspringgreen": [0, 250, 154],
+ "mediumturquoise": [72, 209, 204],
+ "mediumvioletred": [199, 21, 133],
+ "midnightblue": [25, 25, 112],
+ "mintcream": [245, 255, 250],
+ "mistyrose": [255, 228, 225],
+ "moccasin": [255, 228, 181],
+ "navajowhite": [255, 222, 173],
+ "navy": [0, 0, 128],
+ "oldlace": [253, 245, 230],
+ "olive": [128, 128, 0],
+ "olivedrab": [107, 142, 35],
+ "orange": [255, 165, 0],
+ "orangered": [255, 69, 0],
+ "orchid": [218, 112, 214],
+ "palegoldenrod": [238, 232, 170],
+ "palegreen": [152, 251, 152],
+ "paleturquoise": [175, 238, 238],
+ "palevioletred": [219, 112, 147],
+ "papayawhip": [255, 239, 213],
+ "peachpuff": [255, 218, 185],
+ "peru": [205, 133, 63],
+ "pink": [255, 192, 203],
+ "plum": [221, 160, 221],
+ "powderblue": [176, 224, 230],
+ "purple": [128, 0, 128],
+ "rebeccapurple": [102, 51, 153],
+ "red": [255, 0, 0],
+ "rosybrown": [188, 143, 143],
+ "royalblue": [65, 105, 225],
+ "saddlebrown": [139, 69, 19],
+ "salmon": [250, 128, 114],
+ "sandybrown": [244, 164, 96],
+ "seagreen": [46, 139, 87],
+ "seashell": [255, 245, 238],
+ "sienna": [160, 82, 45],
+ "silver": [192, 192, 192],
+ "skyblue": [135, 206, 235],
+ "slateblue": [106, 90, 205],
+ "slategray": [112, 128, 144],
+ "slategrey": [112, 128, 144],
+ "snow": [255, 250, 250],
+ "springgreen": [0, 255, 127],
+ "steelblue": [70, 130, 180],
+ "tan": [210, 180, 140],
+ "teal": [0, 128, 128],
+ "thistle": [216, 191, 216],
+ "tomato": [255, 99, 71],
+ "turquoise": [64, 224, 208],
+ "violet": [238, 130, 238],
+ "wheat": [245, 222, 179],
+ "white": [255, 255, 255],
+ "whitesmoke": [245, 245, 245],
+ "yellow": [255, 255, 0],
+ "yellowgreen": [154, 205, 50]
+};
diff --git a/includes/node_modules/color-name/package.json b/includes/node_modules/color-name/package.json
new file mode 100644
index 0000000..782dd82
--- /dev/null
+++ b/includes/node_modules/color-name/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "color-name",
+ "version": "1.1.4",
+ "description": "A list of color names and its values",
+ "main": "index.js",
+ "files": [
+ "index.js"
+ ],
+ "scripts": {
+ "test": "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:colorjs/color-name.git"
+ },
+ "keywords": [
+ "color-name",
+ "color",
+ "color-keyword",
+ "keyword"
+ ],
+ "author": "DY <dfcreative@gmail.com>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/colorjs/color-name/issues"
+ },
+ "homepage": "https://github.com/colorjs/color-name"
+}
diff --git a/includes/node_modules/fuse.js/LICENSE b/includes/node_modules/fuse.js/LICENSE
new file mode 100644
index 0000000..453d70b
--- /dev/null
+++ b/includes/node_modules/fuse.js/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2017 Kirollos Risk
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/includes/node_modules/fuse.js/README.md b/includes/node_modules/fuse.js/README.md
new file mode 100644
index 0000000..def839c
--- /dev/null
+++ b/includes/node_modules/fuse.js/README.md
@@ -0,0 +1,61 @@
+# Fuse.js
+
+![Node.js CI](https://github.com/krisk/Fuse/workflows/Node.js%20CI/badge.svg)
+[![Version](https://img.shields.io/npm/v/fuse.js.svg)](https://www.npmjs.com/package/fuse.js)
+[![Downloads](https://img.shields.io/npm/dm/fuse.js.svg)](https://npmcharts.com/compare/fuse.js?minimal=tru)
+[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
+[![Contributors](https://img.shields.io/github/contributors/krisk/fuse.svg)](https://github.com/krisk/Fuse/graphs/contributors)
+![License](https://img.shields.io/npm/l/fuse.js.svg)
+
+## Supporting Fuse.js
+
+Through contributions, donations, and sponsorship, you allow Fuse.js to thrive. Also, you will be recognized as a beacon of support to open-source developers.
+
+- [Become a backer or sponsor on **GitHub**.](https://github.com/sponsors/krisk)
+- [Become a backer or sponsor on **Patreon**.](https://patreon.com/fusejs)
+- [One-time donation via **PayPal**.](https://www.paypal.me/kirorisk)
+
+---
+
+<h3 align="center">Silver Sponsors</h3>
+<!--Silver start-->
+<table>
+<tbody>
+ <tr>
+ <td align="center" valign="middle">
+ <a href="https://www.worksome.com" target="_blank">
+ <img width="222px" src="https://raw.githubusercontent.com/krisk/Fuse/7a0d77d85ac90063575613b6a738f418b624357f/docs/.vuepress/public/assets/img/sponsors/worksome.svg">
+ </a>
+ </td>
+ <td align="center" valign="middle">
+ <a href="https://www.bairesdev.com/sponsoring-open-source-projects/" target="_blank">
+ <img width="222px" src="https://github.com/krisk/Fuse/blob/gh-pages/assets/img/sponsors/bairesdev.png?raw=true">
+ </a>
+ </td>
+ </tr>
+</body>
+</table>
+<!--Silver end-->
+
+---
+
+## Introduction
+
+Fuse.js is a lightweight fuzzy-search, in JavaScript, with zero dependencies.
+
+### Browser Compatibility
+
+Fuse.js supports all browsers that are [ES5-compliant](http://kangax.github.io/compat-table/es5/) (IE8 and below are not supported).
+
+## Documentation
+
+To check out a [live demo](https://fusejs.io/demo.html) and docs, visit [fusejs.io](https://fusejs.io).
+
+## Develop
+
+Here's a separate document for [developers](https://github.com/krisk/Fuse/blob/master/DEVELOPERS.md).
+
+## Contribute
+
+We've set up a separate document for our
+[contribution guidelines](https://github.com/krisk/Fuse/blob/master/CONTRIBUTING.md).
diff --git a/includes/node_modules/fuse.js/dist/fuse.basic.cjs b/includes/node_modules/fuse.js/dist/fuse.basic.cjs
new file mode 100644
index 0000000..f7f09be
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.basic.cjs
@@ -0,0 +1,1329 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+'use strict';
+
+function ownKeys(object, enumerableOnly) {
+ var keys = Object.keys(object);
+ if (Object.getOwnPropertySymbols) {
+ var symbols = Object.getOwnPropertySymbols(object);
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
+ })), keys.push.apply(keys, symbols);
+ }
+ return keys;
+}
+function _objectSpread2(target) {
+ for (var i = 1; i < arguments.length; i++) {
+ var source = null != arguments[i] ? arguments[i] : {};
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
+ _defineProperty(target, key, source[key]);
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
+ });
+ }
+ return target;
+}
+function _typeof(obj) {
+ "@babel/helpers - typeof";
+
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
+ return typeof obj;
+ } : function (obj) {
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
+ }, _typeof(obj);
+}
+function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+}
+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, _toPropertyKey(descriptor.key), descriptor);
+ }
+}
+function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ Object.defineProperty(Constructor, "prototype", {
+ writable: false
+ });
+ return Constructor;
+}
+function _defineProperty(obj, key, value) {
+ key = _toPropertyKey(key);
+ if (key in obj) {
+ Object.defineProperty(obj, key, {
+ value: value,
+ enumerable: true,
+ configurable: true,
+ writable: true
+ });
+ } else {
+ obj[key] = value;
+ }
+ return obj;
+}
+function _toConsumableArray(arr) {
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
+}
+function _arrayWithoutHoles(arr) {
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+}
+function _iterableToArray(iter) {
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
+}
+function _unsupportedIterableToArray(o, minLen) {
+ if (!o) return;
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+ var n = Object.prototype.toString.call(o).slice(8, -1);
+ if (n === "Object" && o.constructor) n = o.constructor.name;
+ if (n === "Map" || n === "Set") return Array.from(o);
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
+}
+function _arrayLikeToArray(arr, len) {
+ if (len == null || len > arr.length) len = arr.length;
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+ return arr2;
+}
+function _nonIterableSpread() {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+}
+function _toPrimitive(input, hint) {
+ if (typeof input !== "object" || input === null) return input;
+ var prim = input[Symbol.toPrimitive];
+ if (prim !== undefined) {
+ var res = prim.call(input, hint || "default");
+ if (typeof res !== "object") return res;
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return (hint === "string" ? String : Number)(input);
+}
+function _toPropertyKey(arg) {
+ var key = _toPrimitive(arg, "string");
+ return typeof key === "symbol" ? key : String(key);
+}
+
+function isArray(value) {
+ return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value);
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
+var INFINITY = 1 / 0;
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ var result = value + '';
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result;
+}
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+function isString(value) {
+ return typeof value === 'string';
+}
+function isNumber(value) {
+ return typeof value === 'number';
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
+function isBoolean(value) {
+ return value === true || value === false || isObjectLike(value) && getTag(value) == '[object Boolean]';
+}
+function isObject(value) {
+ return _typeof(value) === 'object';
+}
+
+// Checks if `value` is object-like.
+function isObjectLike(value) {
+ return isObject(value) && value !== null;
+}
+function isDefined(value) {
+ return value !== undefined && value !== null;
+}
+function isBlank(value) {
+ return !value.trim().length;
+}
+
+// Gets the `toStringTag` of `value`.
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
+function getTag(value) {
+ return value == null ? value === undefined ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(value);
+}
+
+var EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
+var LOGICAL_SEARCH_UNAVAILABLE = 'Logical search is not available';
+var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
+var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = function LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key) {
+ return "Invalid value for key ".concat(key);
+};
+var PATTERN_LENGTH_TOO_LARGE = function PATTERN_LENGTH_TOO_LARGE(max) {
+ return "Pattern length exceeds max of ".concat(max, ".");
+};
+var MISSING_KEY_PROPERTY = function MISSING_KEY_PROPERTY(name) {
+ return "Missing ".concat(name, " property in key");
+};
+var INVALID_KEY_WEIGHT_VALUE = function INVALID_KEY_WEIGHT_VALUE(key) {
+ return "Property 'weight' in key '".concat(key, "' must be a positive integer");
+};
+
+var hasOwn = Object.prototype.hasOwnProperty;
+var KeyStore = /*#__PURE__*/function () {
+ function KeyStore(keys) {
+ var _this = this;
+ _classCallCheck(this, KeyStore);
+ this._keys = [];
+ this._keyMap = {};
+ var totalWeight = 0;
+ keys.forEach(function (key) {
+ var obj = createKey(key);
+ _this._keys.push(obj);
+ _this._keyMap[obj.id] = obj;
+ totalWeight += obj.weight;
+ });
+
+ // Normalize weights so that their sum is equal to 1
+ this._keys.forEach(function (key) {
+ key.weight /= totalWeight;
+ });
+ }
+ _createClass(KeyStore, [{
+ key: "get",
+ value: function get(keyId) {
+ return this._keyMap[keyId];
+ }
+ }, {
+ key: "keys",
+ value: function keys() {
+ return this._keys;
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return JSON.stringify(this._keys);
+ }
+ }]);
+ return KeyStore;
+}();
+function createKey(key) {
+ var path = null;
+ var id = null;
+ var src = null;
+ var weight = 1;
+ var getFn = null;
+ if (isString(key) || isArray(key)) {
+ src = key;
+ path = createKeyPath(key);
+ id = createKeyId(key);
+ } else {
+ if (!hasOwn.call(key, 'name')) {
+ throw new Error(MISSING_KEY_PROPERTY('name'));
+ }
+ var name = key.name;
+ src = name;
+ if (hasOwn.call(key, 'weight')) {
+ weight = key.weight;
+ if (weight <= 0) {
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
+ }
+ }
+ path = createKeyPath(name);
+ id = createKeyId(name);
+ getFn = key.getFn;
+ }
+ return {
+ path: path,
+ id: id,
+ weight: weight,
+ src: src,
+ getFn: getFn
+ };
+}
+function createKeyPath(key) {
+ return isArray(key) ? key : key.split('.');
+}
+function createKeyId(key) {
+ return isArray(key) ? key.join('.') : key;
+}
+
+function get(obj, path) {
+ var list = [];
+ var arr = false;
+ var deepGet = function deepGet(obj, path, index) {
+ if (!isDefined(obj)) {
+ return;
+ }
+ if (!path[index]) {
+ // If there's no path left, we've arrived at the object we care about.
+ list.push(obj);
+ } else {
+ var key = path[index];
+ var value = obj[key];
+ if (!isDefined(value)) {
+ return;
+ }
+
+ // If we're at the last value in the path, and if it's a string/number/bool,
+ // add it to the list
+ if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
+ list.push(toString(value));
+ } else if (isArray(value)) {
+ arr = true;
+ // Search each item in the array.
+ for (var i = 0, len = value.length; i < len; i += 1) {
+ deepGet(value[i], path, index + 1);
+ }
+ } else if (path.length) {
+ // An object. Recurse further.
+ deepGet(value, path, index + 1);
+ }
+ }
+ };
+
+ // Backwards compatibility (since path used to be a string)
+ deepGet(obj, isString(path) ? path.split('.') : path, 0);
+ return arr ? list : list[0];
+}
+
+var MatchOptions = {
+ // Whether the matches should be included in the result set. When `true`, each record in the result
+ // set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
+ includeMatches: false,
+ // When `true`, the matching function will continue to the end of a search pattern even if
+ // a perfect match has already been located in the string.
+ findAllMatches: false,
+ // Minimum number of characters that must be matched before a result is considered a match
+ minMatchCharLength: 1
+};
+var BasicOptions = {
+ // When `true`, the algorithm continues searching to the end of the input even if a perfect
+ // match is found before the end of the same input.
+ isCaseSensitive: false,
+ // When true, the matching function will continue to the end of a search pattern even if
+ includeScore: false,
+ // List of properties that will be searched. This also supports nested properties.
+ keys: [],
+ // Whether to sort the result list, by score
+ shouldSort: true,
+ // Default sort function: sort by ascending score, ascending index
+ sortFn: function sortFn(a, b) {
+ return a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1;
+ }
+};
+var FuzzyOptions = {
+ // Approximately where in the text is the pattern expected to be found?
+ location: 0,
+ // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
+ // (of both letters and location), a threshold of '1.0' would match anything.
+ threshold: 0.6,
+ // Determines how close the match must be to the fuzzy location (specified above).
+ // An exact letter match which is 'distance' characters away from the fuzzy location
+ // would score as a complete mismatch. A distance of '0' requires the match be at
+ // the exact location specified, a threshold of '1000' would require a perfect match
+ // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
+ distance: 100
+};
+var AdvancedOptions = {
+ // When `true`, it enables the use of unix-like search commands
+ useExtendedSearch: false,
+ // The get function to use when fetching an object's properties.
+ // The default will search nested paths *ie foo.bar.baz*
+ getFn: get,
+ // When `true`, search will ignore `location` and `distance`, so it won't matter
+ // where in the string the pattern appears.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
+ ignoreLocation: false,
+ // When `true`, the calculation for the relevance score (used for sorting) will
+ // ignore the field-length norm.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
+ ignoreFieldNorm: false,
+ // The weight to determine how much field length norm effects scoring.
+ fieldNormWeight: 1
+};
+var Config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, BasicOptions), MatchOptions), FuzzyOptions), AdvancedOptions);
+
+var SPACE = /[^ ]+/g;
+
+// Field-length norm: the shorter the field, the higher the weight.
+// Set to 3 decimals to reduce index size.
+function norm() {
+ var weight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
+ var mantissa = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
+ var cache = new Map();
+ var m = Math.pow(10, mantissa);
+ return {
+ get: function get(value) {
+ var numTokens = value.match(SPACE).length;
+ if (cache.has(numTokens)) {
+ return cache.get(numTokens);
+ }
+
+ // Default function is 1/sqrt(x), weight makes that variable
+ var norm = 1 / Math.pow(numTokens, 0.5 * weight);
+
+ // In place of `toFixed(mantissa)`, for faster computation
+ var n = parseFloat(Math.round(norm * m) / m);
+ cache.set(numTokens, n);
+ return n;
+ },
+ clear: function clear() {
+ cache.clear();
+ }
+ };
+}
+
+var FuseIndex = /*#__PURE__*/function () {
+ function FuseIndex() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$getFn = _ref.getFn,
+ getFn = _ref$getFn === void 0 ? Config.getFn : _ref$getFn,
+ _ref$fieldNormWeight = _ref.fieldNormWeight,
+ fieldNormWeight = _ref$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref$fieldNormWeight;
+ _classCallCheck(this, FuseIndex);
+ this.norm = norm(fieldNormWeight, 3);
+ this.getFn = getFn;
+ this.isCreated = false;
+ this.setIndexRecords();
+ }
+ _createClass(FuseIndex, [{
+ key: "setSources",
+ value: function setSources() {
+ var docs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.docs = docs;
+ }
+ }, {
+ key: "setIndexRecords",
+ value: function setIndexRecords() {
+ var records = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.records = records;
+ }
+ }, {
+ key: "setKeys",
+ value: function setKeys() {
+ var _this = this;
+ var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.keys = keys;
+ this._keysMap = {};
+ keys.forEach(function (key, idx) {
+ _this._keysMap[key.id] = idx;
+ });
+ }
+ }, {
+ key: "create",
+ value: function create() {
+ var _this2 = this;
+ if (this.isCreated || !this.docs.length) {
+ return;
+ }
+ this.isCreated = true;
+
+ // List is Array<String>
+ if (isString(this.docs[0])) {
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addString(doc, docIndex);
+ });
+ } else {
+ // List is Array<Object>
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addObject(doc, docIndex);
+ });
+ }
+ this.norm.clear();
+ }
+ // Adds a doc to the end of the index
+ }, {
+ key: "add",
+ value: function add(doc) {
+ var idx = this.size();
+ if (isString(doc)) {
+ this._addString(doc, idx);
+ } else {
+ this._addObject(doc, idx);
+ }
+ }
+ // Removes the doc at the specified index of the index
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this.records.splice(idx, 1);
+
+ // Change ref index of every subsquent doc
+ for (var i = idx, len = this.size(); i < len; i += 1) {
+ this.records[i].i -= 1;
+ }
+ }
+ }, {
+ key: "getValueForItemAtKeyId",
+ value: function getValueForItemAtKeyId(item, keyId) {
+ return item[this._keysMap[keyId]];
+ }
+ }, {
+ key: "size",
+ value: function size() {
+ return this.records.length;
+ }
+ }, {
+ key: "_addString",
+ value: function _addString(doc, docIndex) {
+ if (!isDefined(doc) || isBlank(doc)) {
+ return;
+ }
+ var record = {
+ v: doc,
+ i: docIndex,
+ n: this.norm.get(doc)
+ };
+ this.records.push(record);
+ }
+ }, {
+ key: "_addObject",
+ value: function _addObject(doc, docIndex) {
+ var _this3 = this;
+ var record = {
+ i: docIndex,
+ $: {}
+ };
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ this.keys.forEach(function (key, keyIndex) {
+ var value = key.getFn ? key.getFn(doc) : _this3.getFn(doc, key.path);
+ if (!isDefined(value)) {
+ return;
+ }
+ if (isArray(value)) {
+ var subRecords = [];
+ var stack = [{
+ nestedArrIndex: -1,
+ value: value
+ }];
+ while (stack.length) {
+ var _stack$pop = stack.pop(),
+ nestedArrIndex = _stack$pop.nestedArrIndex,
+ _value = _stack$pop.value;
+ if (!isDefined(_value)) {
+ continue;
+ }
+ if (isString(_value) && !isBlank(_value)) {
+ var subRecord = {
+ v: _value,
+ i: nestedArrIndex,
+ n: _this3.norm.get(_value)
+ };
+ subRecords.push(subRecord);
+ } else if (isArray(_value)) {
+ _value.forEach(function (item, k) {
+ stack.push({
+ nestedArrIndex: k,
+ value: item
+ });
+ });
+ } else ;
+ }
+ record.$[keyIndex] = subRecords;
+ } else if (isString(value) && !isBlank(value)) {
+ var _subRecord = {
+ v: value,
+ n: _this3.norm.get(value)
+ };
+ record.$[keyIndex] = _subRecord;
+ }
+ });
+ this.records.push(record);
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return {
+ keys: this.keys,
+ records: this.records
+ };
+ }
+ }]);
+ return FuseIndex;
+}();
+function createIndex(keys, docs) {
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref2$getFn = _ref2.getFn,
+ getFn = _ref2$getFn === void 0 ? Config.getFn : _ref2$getFn,
+ _ref2$fieldNormWeight = _ref2.fieldNormWeight,
+ fieldNormWeight = _ref2$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref2$fieldNormWeight;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys.map(createKey));
+ myIndex.setSources(docs);
+ myIndex.create();
+ return myIndex;
+}
+function parseIndex(data) {
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref3$getFn = _ref3.getFn,
+ getFn = _ref3$getFn === void 0 ? Config.getFn : _ref3$getFn,
+ _ref3$fieldNormWeight = _ref3.fieldNormWeight,
+ fieldNormWeight = _ref3$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref3$fieldNormWeight;
+ var keys = data.keys,
+ records = data.records;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys);
+ myIndex.setIndexRecords(records);
+ return myIndex;
+}
+
+function computeScore$1(pattern) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$errors = _ref.errors,
+ errors = _ref$errors === void 0 ? 0 : _ref$errors,
+ _ref$currentLocation = _ref.currentLocation,
+ currentLocation = _ref$currentLocation === void 0 ? 0 : _ref$currentLocation,
+ _ref$expectedLocation = _ref.expectedLocation,
+ expectedLocation = _ref$expectedLocation === void 0 ? 0 : _ref$expectedLocation,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ var accuracy = errors / pattern.length;
+ if (ignoreLocation) {
+ return accuracy;
+ }
+ var proximity = Math.abs(expectedLocation - currentLocation);
+ if (!distance) {
+ // Dodge divide by zero error.
+ return proximity ? 1.0 : accuracy;
+ }
+ return accuracy + proximity / distance;
+}
+
+function convertMaskToIndices() {
+ var matchmask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ var minMatchCharLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Config.minMatchCharLength;
+ var indices = [];
+ var start = -1;
+ var end = -1;
+ var i = 0;
+ for (var len = matchmask.length; i < len; i += 1) {
+ var match = matchmask[i];
+ if (match && start === -1) {
+ start = i;
+ } else if (!match && start !== -1) {
+ end = i - 1;
+ if (end - start + 1 >= minMatchCharLength) {
+ indices.push([start, end]);
+ }
+ start = -1;
+ }
+ }
+
+ // (i-1 - start) + 1 => i - start
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
+ indices.push([start, i - 1]);
+ }
+ return indices;
+}
+
+// Machine word size
+var MAX_BITS = 32;
+
+function search(text, pattern, patternAlphabet) {
+ var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ if (pattern.length > MAX_BITS) {
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
+ }
+ var patternLen = pattern.length;
+ // Set starting location at beginning text and initialize the alphabet.
+ var textLen = text.length;
+ // Handle the case when location > text.length
+ var expectedLocation = Math.max(0, Math.min(location, textLen));
+ // Highest score beyond which we give up.
+ var currentThreshold = threshold;
+ // Is there a nearby exact match? (speedup)
+ var bestLocation = expectedLocation;
+
+ // Performance: only computer matches when the minMatchCharLength > 1
+ // OR if `includeMatches` is true.
+ var computeMatches = minMatchCharLength > 1 || includeMatches;
+ // A mask of the matches, used for building the indices
+ var matchMask = computeMatches ? Array(textLen) : [];
+ var index;
+
+ // Get all exact matches, here for speed up
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
+ var score = computeScore$1(pattern, {
+ currentLocation: index,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ currentThreshold = Math.min(score, currentThreshold);
+ bestLocation = index + patternLen;
+ if (computeMatches) {
+ var i = 0;
+ while (i < patternLen) {
+ matchMask[index + i] = 1;
+ i += 1;
+ }
+ }
+ }
+
+ // Reset the best location
+ bestLocation = -1;
+ var lastBitArr = [];
+ var finalScore = 1;
+ var binMax = patternLen + textLen;
+ var mask = 1 << patternLen - 1;
+ for (var _i = 0; _i < patternLen; _i += 1) {
+ // Scan for the best match; each iteration allows for one more error.
+ // Run a binary search to determine how far from the match location we can stray
+ // at this error level.
+ var binMin = 0;
+ var binMid = binMax;
+ while (binMin < binMid) {
+ var _score = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: expectedLocation + binMid,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score <= currentThreshold) {
+ binMin = binMid;
+ } else {
+ binMax = binMid;
+ }
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
+ }
+
+ // Use the result from this iteration as the maximum for the next.
+ binMax = binMid;
+ var start = Math.max(1, expectedLocation - binMid + 1);
+ var finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
+
+ // Initialize the bit array
+ var bitArr = Array(finish + 2);
+ bitArr[finish + 1] = (1 << _i) - 1;
+ for (var j = finish; j >= start; j -= 1) {
+ var currentLocation = j - 1;
+ var charMatch = patternAlphabet[text.charAt(currentLocation)];
+ if (computeMatches) {
+ // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
+ matchMask[currentLocation] = +!!charMatch;
+ }
+
+ // First pass: exact match
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
+
+ // Subsequent passes: fuzzy match
+ if (_i) {
+ bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
+ }
+ if (bitArr[j] & mask) {
+ finalScore = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: currentLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+
+ // This match will almost certainly be better than any existing match.
+ // But check anyway.
+ if (finalScore <= currentThreshold) {
+ // Indeed it is
+ currentThreshold = finalScore;
+ bestLocation = currentLocation;
+
+ // Already passed `loc`, downhill from here on in.
+ if (bestLocation <= expectedLocation) {
+ break;
+ }
+
+ // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
+ }
+ }
+ }
+
+ // No hope for a (better) match at greater error levels.
+ var _score2 = computeScore$1(pattern, {
+ errors: _i + 1,
+ currentLocation: expectedLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score2 > currentThreshold) {
+ break;
+ }
+ lastBitArr = bitArr;
+ }
+ var result = {
+ isMatch: bestLocation >= 0,
+ // Count exact matches (those with a score of 0) to be "almost" exact
+ score: Math.max(0.001, finalScore)
+ };
+ if (computeMatches) {
+ var indices = convertMaskToIndices(matchMask, minMatchCharLength);
+ if (!indices.length) {
+ result.isMatch = false;
+ } else if (includeMatches) {
+ result.indices = indices;
+ }
+ }
+ return result;
+}
+
+function createPatternAlphabet(pattern) {
+ var mask = {};
+ for (var i = 0, len = pattern.length; i < len; i += 1) {
+ var _char = pattern.charAt(i);
+ mask[_char] = (mask[_char] || 0) | 1 << len - i - 1;
+ }
+ return mask;
+}
+
+var BitapSearch = /*#__PURE__*/function () {
+ function BitapSearch(pattern) {
+ var _this = this;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ _classCallCheck(this, BitapSearch);
+ this.options = {
+ location: location,
+ threshold: threshold,
+ distance: distance,
+ includeMatches: includeMatches,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ isCaseSensitive: isCaseSensitive,
+ ignoreLocation: ignoreLocation
+ };
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.chunks = [];
+ if (!this.pattern.length) {
+ return;
+ }
+ var addChunk = function addChunk(pattern, startIndex) {
+ _this.chunks.push({
+ pattern: pattern,
+ alphabet: createPatternAlphabet(pattern),
+ startIndex: startIndex
+ });
+ };
+ var len = this.pattern.length;
+ if (len > MAX_BITS) {
+ var i = 0;
+ var remainder = len % MAX_BITS;
+ var end = len - remainder;
+ while (i < end) {
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
+ i += MAX_BITS;
+ }
+ if (remainder) {
+ var startIndex = len - MAX_BITS;
+ addChunk(this.pattern.substr(startIndex), startIndex);
+ }
+ } else {
+ addChunk(this.pattern, 0);
+ }
+ }
+ _createClass(BitapSearch, [{
+ key: "searchIn",
+ value: function searchIn(text) {
+ var _this$options = this.options,
+ isCaseSensitive = _this$options.isCaseSensitive,
+ includeMatches = _this$options.includeMatches;
+ if (!isCaseSensitive) {
+ text = text.toLowerCase();
+ }
+
+ // Exact match
+ if (this.pattern === text) {
+ var _result = {
+ isMatch: true,
+ score: 0
+ };
+ if (includeMatches) {
+ _result.indices = [[0, text.length - 1]];
+ }
+ return _result;
+ }
+
+ // Otherwise, use Bitap algorithm
+ var _this$options2 = this.options,
+ location = _this$options2.location,
+ distance = _this$options2.distance,
+ threshold = _this$options2.threshold,
+ findAllMatches = _this$options2.findAllMatches,
+ minMatchCharLength = _this$options2.minMatchCharLength,
+ ignoreLocation = _this$options2.ignoreLocation;
+ var allIndices = [];
+ var totalScore = 0;
+ var hasMatches = false;
+ this.chunks.forEach(function (_ref2) {
+ var pattern = _ref2.pattern,
+ alphabet = _ref2.alphabet,
+ startIndex = _ref2.startIndex;
+ var _search = search(text, pattern, alphabet, {
+ location: location + startIndex,
+ distance: distance,
+ threshold: threshold,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ includeMatches: includeMatches,
+ ignoreLocation: ignoreLocation
+ }),
+ isMatch = _search.isMatch,
+ score = _search.score,
+ indices = _search.indices;
+ if (isMatch) {
+ hasMatches = true;
+ }
+ totalScore += score;
+ if (isMatch && indices) {
+ allIndices = [].concat(_toConsumableArray(allIndices), _toConsumableArray(indices));
+ }
+ });
+ var result = {
+ isMatch: hasMatches,
+ score: hasMatches ? totalScore / this.chunks.length : 1
+ };
+ if (hasMatches && includeMatches) {
+ result.indices = allIndices;
+ }
+ return result;
+ }
+ }]);
+ return BitapSearch;
+}();
+
+var registeredSearchers = [];
+function createSearcher(pattern, options) {
+ for (var i = 0, len = registeredSearchers.length; i < len; i += 1) {
+ var searcherClass = registeredSearchers[i];
+ if (searcherClass.condition(pattern, options)) {
+ return new searcherClass(pattern, options);
+ }
+ }
+ return new BitapSearch(pattern, options);
+}
+
+var LogicalOperator = {
+ AND: '$and',
+ OR: '$or'
+};
+var KeyType = {
+ PATH: '$path',
+ PATTERN: '$val'
+};
+var isExpression = function isExpression(query) {
+ return !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
+};
+var isPath = function isPath(query) {
+ return !!query[KeyType.PATH];
+};
+var isLeaf = function isLeaf(query) {
+ return !isArray(query) && isObject(query) && !isExpression(query);
+};
+var convertToExplicit = function convertToExplicit(query) {
+ return _defineProperty({}, LogicalOperator.AND, Object.keys(query).map(function (key) {
+ return _defineProperty({}, key, query[key]);
+ }));
+};
+
+// When `auto` is `true`, the parse function will infer and initialize and add
+// the appropriate `Searcher` instance
+function parse(query, options) {
+ var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref3$auto = _ref3.auto,
+ auto = _ref3$auto === void 0 ? true : _ref3$auto;
+ var next = function next(query) {
+ var keys = Object.keys(query);
+ var isQueryPath = isPath(query);
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
+ return next(convertToExplicit(query));
+ }
+ if (isLeaf(query)) {
+ var key = isQueryPath ? query[KeyType.PATH] : keys[0];
+ var pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
+ if (!isString(pattern)) {
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
+ }
+ var obj = {
+ keyId: createKeyId(key),
+ pattern: pattern
+ };
+ if (auto) {
+ obj.searcher = createSearcher(pattern, options);
+ }
+ return obj;
+ }
+ var node = {
+ children: [],
+ operator: keys[0]
+ };
+ keys.forEach(function (key) {
+ var value = query[key];
+ if (isArray(value)) {
+ value.forEach(function (item) {
+ node.children.push(next(item));
+ });
+ }
+ });
+ return node;
+ };
+ if (!isExpression(query)) {
+ query = convertToExplicit(query);
+ }
+ return next(query);
+}
+
+// Practical scoring function
+function computeScore(results, _ref) {
+ var _ref$ignoreFieldNorm = _ref.ignoreFieldNorm,
+ ignoreFieldNorm = _ref$ignoreFieldNorm === void 0 ? Config.ignoreFieldNorm : _ref$ignoreFieldNorm;
+ results.forEach(function (result) {
+ var totalScore = 1;
+ result.matches.forEach(function (_ref2) {
+ var key = _ref2.key,
+ norm = _ref2.norm,
+ score = _ref2.score;
+ var weight = key ? key.weight : null;
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
+ });
+ result.score = totalScore;
+ });
+}
+
+function transformMatches(result, data) {
+ var matches = result.matches;
+ data.matches = [];
+ if (!isDefined(matches)) {
+ return;
+ }
+ matches.forEach(function (match) {
+ if (!isDefined(match.indices) || !match.indices.length) {
+ return;
+ }
+ var indices = match.indices,
+ value = match.value;
+ var obj = {
+ indices: indices,
+ value: value
+ };
+ if (match.key) {
+ obj.key = match.key.src;
+ }
+ if (match.idx > -1) {
+ obj.refIndex = match.idx;
+ }
+ data.matches.push(obj);
+ });
+}
+
+function transformScore(result, data) {
+ data.score = result.score;
+}
+
+function format(results, docs) {
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$includeScore = _ref.includeScore,
+ includeScore = _ref$includeScore === void 0 ? Config.includeScore : _ref$includeScore;
+ var transformers = [];
+ if (includeMatches) transformers.push(transformMatches);
+ if (includeScore) transformers.push(transformScore);
+ return results.map(function (result) {
+ var idx = result.idx;
+ var data = {
+ item: docs[idx],
+ refIndex: idx
+ };
+ if (transformers.length) {
+ transformers.forEach(function (transformer) {
+ transformer(result, data);
+ });
+ }
+ return data;
+ });
+}
+
+var Fuse$1 = /*#__PURE__*/function () {
+ function Fuse(docs) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ var index = arguments.length > 2 ? arguments[2] : undefined;
+ _classCallCheck(this, Fuse);
+ this.options = _objectSpread2(_objectSpread2({}, Config), options);
+ if (this.options.useExtendedSearch && !false) {
+ throw new Error(EXTENDED_SEARCH_UNAVAILABLE);
+ }
+ this._keyStore = new KeyStore(this.options.keys);
+ this.setCollection(docs, index);
+ }
+ _createClass(Fuse, [{
+ key: "setCollection",
+ value: function setCollection(docs, index) {
+ this._docs = docs;
+ if (index && !(index instanceof FuseIndex)) {
+ throw new Error(INCORRECT_INDEX_TYPE);
+ }
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
+ getFn: this.options.getFn,
+ fieldNormWeight: this.options.fieldNormWeight
+ });
+ }
+ }, {
+ key: "add",
+ value: function add(doc) {
+ if (!isDefined(doc)) {
+ return;
+ }
+ this._docs.push(doc);
+ this._myIndex.add(doc);
+ }
+ }, {
+ key: "remove",
+ value: function remove() {
+ var predicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function /* doc, idx */ () {
+ return false;
+ };
+ var results = [];
+ for (var i = 0, len = this._docs.length; i < len; i += 1) {
+ var doc = this._docs[i];
+ if (predicate(doc, i)) {
+ this.removeAt(i);
+ i -= 1;
+ len -= 1;
+ results.push(doc);
+ }
+ }
+ return results;
+ }
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this._docs.splice(idx, 1);
+ this._myIndex.removeAt(idx);
+ }
+ }, {
+ key: "getIndex",
+ value: function getIndex() {
+ return this._myIndex;
+ }
+ }, {
+ key: "search",
+ value: function search(query) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$limit = _ref.limit,
+ limit = _ref$limit === void 0 ? -1 : _ref$limit;
+ var _this$options = this.options,
+ includeMatches = _this$options.includeMatches,
+ includeScore = _this$options.includeScore,
+ shouldSort = _this$options.shouldSort,
+ sortFn = _this$options.sortFn,
+ ignoreFieldNorm = _this$options.ignoreFieldNorm;
+ var results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
+ computeScore(results, {
+ ignoreFieldNorm: ignoreFieldNorm
+ });
+ if (shouldSort) {
+ results.sort(sortFn);
+ }
+ if (isNumber(limit) && limit > -1) {
+ results = results.slice(0, limit);
+ }
+ return format(results, this._docs, {
+ includeMatches: includeMatches,
+ includeScore: includeScore
+ });
+ }
+ }, {
+ key: "_searchStringList",
+ value: function _searchStringList(query) {
+ var searcher = createSearcher(query, this.options);
+ var records = this._myIndex.records;
+ var results = [];
+
+ // Iterate over every string in the index
+ records.forEach(function (_ref2) {
+ var text = _ref2.v,
+ idx = _ref2.i,
+ norm = _ref2.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn = searcher.searchIn(text),
+ isMatch = _searcher$searchIn.isMatch,
+ score = _searcher$searchIn.score,
+ indices = _searcher$searchIn.indices;
+ if (isMatch) {
+ results.push({
+ item: text,
+ idx: idx,
+ matches: [{
+ score: score,
+ value: text,
+ norm: norm,
+ indices: indices
+ }]
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_searchLogical",
+ value: function _searchLogical(query) {
+ {
+ throw new Error(LOGICAL_SEARCH_UNAVAILABLE);
+ }
+ }
+ }, {
+ key: "_searchObjectList",
+ value: function _searchObjectList(query) {
+ var _this2 = this;
+ var searcher = createSearcher(query, this.options);
+ var _this$_myIndex = this._myIndex,
+ keys = _this$_myIndex.keys,
+ records = _this$_myIndex.records;
+ var results = [];
+
+ // List is Array<Object>
+ records.forEach(function (_ref5) {
+ var item = _ref5.$,
+ idx = _ref5.i;
+ if (!isDefined(item)) {
+ return;
+ }
+ var matches = [];
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ keys.forEach(function (key, keyIndex) {
+ matches.push.apply(matches, _toConsumableArray(_this2._findMatches({
+ key: key,
+ value: item[keyIndex],
+ searcher: searcher
+ })));
+ });
+ if (matches.length) {
+ results.push({
+ idx: idx,
+ item: item,
+ matches: matches
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_findMatches",
+ value: function _findMatches(_ref6) {
+ var key = _ref6.key,
+ value = _ref6.value,
+ searcher = _ref6.searcher;
+ if (!isDefined(value)) {
+ return [];
+ }
+ var matches = [];
+ if (isArray(value)) {
+ value.forEach(function (_ref7) {
+ var text = _ref7.v,
+ idx = _ref7.i,
+ norm = _ref7.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn2 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn2.isMatch,
+ score = _searcher$searchIn2.score,
+ indices = _searcher$searchIn2.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ idx: idx,
+ norm: norm,
+ indices: indices
+ });
+ }
+ });
+ } else {
+ var text = value.v,
+ norm = value.n;
+ var _searcher$searchIn3 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn3.isMatch,
+ score = _searcher$searchIn3.score,
+ indices = _searcher$searchIn3.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ norm: norm,
+ indices: indices
+ });
+ }
+ }
+ return matches;
+ }
+ }]);
+ return Fuse;
+}();
+
+Fuse$1.version = '7.0.0';
+Fuse$1.createIndex = createIndex;
+Fuse$1.parseIndex = parseIndex;
+Fuse$1.config = Config;
+{
+ Fuse$1.parseQuery = parse;
+}
+var Fuse = Fuse$1;
+
+module.exports = Fuse;
diff --git a/includes/node_modules/fuse.js/dist/fuse.basic.js b/includes/node_modules/fuse.js/dist/fuse.basic.js
new file mode 100644
index 0000000..0e7292e
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.basic.js
@@ -0,0 +1,1335 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Fuse = factory());
+})(this, (function () { 'use strict';
+
+ function ownKeys(object, enumerableOnly) {
+ var keys = Object.keys(object);
+ if (Object.getOwnPropertySymbols) {
+ var symbols = Object.getOwnPropertySymbols(object);
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
+ })), keys.push.apply(keys, symbols);
+ }
+ return keys;
+ }
+ function _objectSpread2(target) {
+ for (var i = 1; i < arguments.length; i++) {
+ var source = null != arguments[i] ? arguments[i] : {};
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
+ _defineProperty(target, key, source[key]);
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
+ });
+ }
+ return target;
+ }
+ function _typeof(obj) {
+ "@babel/helpers - typeof";
+
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
+ return typeof obj;
+ } : function (obj) {
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
+ }, _typeof(obj);
+ }
+ function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+ }
+ 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, _toPropertyKey(descriptor.key), descriptor);
+ }
+ }
+ function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ Object.defineProperty(Constructor, "prototype", {
+ writable: false
+ });
+ return Constructor;
+ }
+ function _defineProperty(obj, key, value) {
+ key = _toPropertyKey(key);
+ if (key in obj) {
+ Object.defineProperty(obj, key, {
+ value: value,
+ enumerable: true,
+ configurable: true,
+ writable: true
+ });
+ } else {
+ obj[key] = value;
+ }
+ return obj;
+ }
+ function _toConsumableArray(arr) {
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
+ }
+ function _arrayWithoutHoles(arr) {
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+ }
+ function _iterableToArray(iter) {
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
+ }
+ function _unsupportedIterableToArray(o, minLen) {
+ if (!o) return;
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+ var n = Object.prototype.toString.call(o).slice(8, -1);
+ if (n === "Object" && o.constructor) n = o.constructor.name;
+ if (n === "Map" || n === "Set") return Array.from(o);
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
+ }
+ function _arrayLikeToArray(arr, len) {
+ if (len == null || len > arr.length) len = arr.length;
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+ return arr2;
+ }
+ function _nonIterableSpread() {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+ }
+ function _toPrimitive(input, hint) {
+ if (typeof input !== "object" || input === null) return input;
+ var prim = input[Symbol.toPrimitive];
+ if (prim !== undefined) {
+ var res = prim.call(input, hint || "default");
+ if (typeof res !== "object") return res;
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return (hint === "string" ? String : Number)(input);
+ }
+ function _toPropertyKey(arg) {
+ var key = _toPrimitive(arg, "string");
+ return typeof key === "symbol" ? key : String(key);
+ }
+
+ function isArray(value) {
+ return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value);
+ }
+
+ // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
+ var INFINITY = 1 / 0;
+ function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ var result = value + '';
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result;
+ }
+ function toString(value) {
+ return value == null ? '' : baseToString(value);
+ }
+ function isString(value) {
+ return typeof value === 'string';
+ }
+ function isNumber(value) {
+ return typeof value === 'number';
+ }
+
+ // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
+ function isBoolean(value) {
+ return value === true || value === false || isObjectLike(value) && getTag(value) == '[object Boolean]';
+ }
+ function isObject(value) {
+ return _typeof(value) === 'object';
+ }
+
+ // Checks if `value` is object-like.
+ function isObjectLike(value) {
+ return isObject(value) && value !== null;
+ }
+ function isDefined(value) {
+ return value !== undefined && value !== null;
+ }
+ function isBlank(value) {
+ return !value.trim().length;
+ }
+
+ // Gets the `toStringTag` of `value`.
+ // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
+ function getTag(value) {
+ return value == null ? value === undefined ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(value);
+ }
+
+ var EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
+ var LOGICAL_SEARCH_UNAVAILABLE = 'Logical search is not available';
+ var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
+ var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = function LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key) {
+ return "Invalid value for key ".concat(key);
+ };
+ var PATTERN_LENGTH_TOO_LARGE = function PATTERN_LENGTH_TOO_LARGE(max) {
+ return "Pattern length exceeds max of ".concat(max, ".");
+ };
+ var MISSING_KEY_PROPERTY = function MISSING_KEY_PROPERTY(name) {
+ return "Missing ".concat(name, " property in key");
+ };
+ var INVALID_KEY_WEIGHT_VALUE = function INVALID_KEY_WEIGHT_VALUE(key) {
+ return "Property 'weight' in key '".concat(key, "' must be a positive integer");
+ };
+
+ var hasOwn = Object.prototype.hasOwnProperty;
+ var KeyStore = /*#__PURE__*/function () {
+ function KeyStore(keys) {
+ var _this = this;
+ _classCallCheck(this, KeyStore);
+ this._keys = [];
+ this._keyMap = {};
+ var totalWeight = 0;
+ keys.forEach(function (key) {
+ var obj = createKey(key);
+ _this._keys.push(obj);
+ _this._keyMap[obj.id] = obj;
+ totalWeight += obj.weight;
+ });
+
+ // Normalize weights so that their sum is equal to 1
+ this._keys.forEach(function (key) {
+ key.weight /= totalWeight;
+ });
+ }
+ _createClass(KeyStore, [{
+ key: "get",
+ value: function get(keyId) {
+ return this._keyMap[keyId];
+ }
+ }, {
+ key: "keys",
+ value: function keys() {
+ return this._keys;
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return JSON.stringify(this._keys);
+ }
+ }]);
+ return KeyStore;
+ }();
+ function createKey(key) {
+ var path = null;
+ var id = null;
+ var src = null;
+ var weight = 1;
+ var getFn = null;
+ if (isString(key) || isArray(key)) {
+ src = key;
+ path = createKeyPath(key);
+ id = createKeyId(key);
+ } else {
+ if (!hasOwn.call(key, 'name')) {
+ throw new Error(MISSING_KEY_PROPERTY('name'));
+ }
+ var name = key.name;
+ src = name;
+ if (hasOwn.call(key, 'weight')) {
+ weight = key.weight;
+ if (weight <= 0) {
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
+ }
+ }
+ path = createKeyPath(name);
+ id = createKeyId(name);
+ getFn = key.getFn;
+ }
+ return {
+ path: path,
+ id: id,
+ weight: weight,
+ src: src,
+ getFn: getFn
+ };
+ }
+ function createKeyPath(key) {
+ return isArray(key) ? key : key.split('.');
+ }
+ function createKeyId(key) {
+ return isArray(key) ? key.join('.') : key;
+ }
+
+ function get(obj, path) {
+ var list = [];
+ var arr = false;
+ var deepGet = function deepGet(obj, path, index) {
+ if (!isDefined(obj)) {
+ return;
+ }
+ if (!path[index]) {
+ // If there's no path left, we've arrived at the object we care about.
+ list.push(obj);
+ } else {
+ var key = path[index];
+ var value = obj[key];
+ if (!isDefined(value)) {
+ return;
+ }
+
+ // If we're at the last value in the path, and if it's a string/number/bool,
+ // add it to the list
+ if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
+ list.push(toString(value));
+ } else if (isArray(value)) {
+ arr = true;
+ // Search each item in the array.
+ for (var i = 0, len = value.length; i < len; i += 1) {
+ deepGet(value[i], path, index + 1);
+ }
+ } else if (path.length) {
+ // An object. Recurse further.
+ deepGet(value, path, index + 1);
+ }
+ }
+ };
+
+ // Backwards compatibility (since path used to be a string)
+ deepGet(obj, isString(path) ? path.split('.') : path, 0);
+ return arr ? list : list[0];
+ }
+
+ var MatchOptions = {
+ // Whether the matches should be included in the result set. When `true`, each record in the result
+ // set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
+ includeMatches: false,
+ // When `true`, the matching function will continue to the end of a search pattern even if
+ // a perfect match has already been located in the string.
+ findAllMatches: false,
+ // Minimum number of characters that must be matched before a result is considered a match
+ minMatchCharLength: 1
+ };
+ var BasicOptions = {
+ // When `true`, the algorithm continues searching to the end of the input even if a perfect
+ // match is found before the end of the same input.
+ isCaseSensitive: false,
+ // When true, the matching function will continue to the end of a search pattern even if
+ includeScore: false,
+ // List of properties that will be searched. This also supports nested properties.
+ keys: [],
+ // Whether to sort the result list, by score
+ shouldSort: true,
+ // Default sort function: sort by ascending score, ascending index
+ sortFn: function sortFn(a, b) {
+ return a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1;
+ }
+ };
+ var FuzzyOptions = {
+ // Approximately where in the text is the pattern expected to be found?
+ location: 0,
+ // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
+ // (of both letters and location), a threshold of '1.0' would match anything.
+ threshold: 0.6,
+ // Determines how close the match must be to the fuzzy location (specified above).
+ // An exact letter match which is 'distance' characters away from the fuzzy location
+ // would score as a complete mismatch. A distance of '0' requires the match be at
+ // the exact location specified, a threshold of '1000' would require a perfect match
+ // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
+ distance: 100
+ };
+ var AdvancedOptions = {
+ // When `true`, it enables the use of unix-like search commands
+ useExtendedSearch: false,
+ // The get function to use when fetching an object's properties.
+ // The default will search nested paths *ie foo.bar.baz*
+ getFn: get,
+ // When `true`, search will ignore `location` and `distance`, so it won't matter
+ // where in the string the pattern appears.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
+ ignoreLocation: false,
+ // When `true`, the calculation for the relevance score (used for sorting) will
+ // ignore the field-length norm.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
+ ignoreFieldNorm: false,
+ // The weight to determine how much field length norm effects scoring.
+ fieldNormWeight: 1
+ };
+ var Config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, BasicOptions), MatchOptions), FuzzyOptions), AdvancedOptions);
+
+ var SPACE = /[^ ]+/g;
+
+ // Field-length norm: the shorter the field, the higher the weight.
+ // Set to 3 decimals to reduce index size.
+ function norm() {
+ var weight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
+ var mantissa = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
+ var cache = new Map();
+ var m = Math.pow(10, mantissa);
+ return {
+ get: function get(value) {
+ var numTokens = value.match(SPACE).length;
+ if (cache.has(numTokens)) {
+ return cache.get(numTokens);
+ }
+
+ // Default function is 1/sqrt(x), weight makes that variable
+ var norm = 1 / Math.pow(numTokens, 0.5 * weight);
+
+ // In place of `toFixed(mantissa)`, for faster computation
+ var n = parseFloat(Math.round(norm * m) / m);
+ cache.set(numTokens, n);
+ return n;
+ },
+ clear: function clear() {
+ cache.clear();
+ }
+ };
+ }
+
+ var FuseIndex = /*#__PURE__*/function () {
+ function FuseIndex() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$getFn = _ref.getFn,
+ getFn = _ref$getFn === void 0 ? Config.getFn : _ref$getFn,
+ _ref$fieldNormWeight = _ref.fieldNormWeight,
+ fieldNormWeight = _ref$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref$fieldNormWeight;
+ _classCallCheck(this, FuseIndex);
+ this.norm = norm(fieldNormWeight, 3);
+ this.getFn = getFn;
+ this.isCreated = false;
+ this.setIndexRecords();
+ }
+ _createClass(FuseIndex, [{
+ key: "setSources",
+ value: function setSources() {
+ var docs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.docs = docs;
+ }
+ }, {
+ key: "setIndexRecords",
+ value: function setIndexRecords() {
+ var records = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.records = records;
+ }
+ }, {
+ key: "setKeys",
+ value: function setKeys() {
+ var _this = this;
+ var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.keys = keys;
+ this._keysMap = {};
+ keys.forEach(function (key, idx) {
+ _this._keysMap[key.id] = idx;
+ });
+ }
+ }, {
+ key: "create",
+ value: function create() {
+ var _this2 = this;
+ if (this.isCreated || !this.docs.length) {
+ return;
+ }
+ this.isCreated = true;
+
+ // List is Array<String>
+ if (isString(this.docs[0])) {
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addString(doc, docIndex);
+ });
+ } else {
+ // List is Array<Object>
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addObject(doc, docIndex);
+ });
+ }
+ this.norm.clear();
+ }
+ // Adds a doc to the end of the index
+ }, {
+ key: "add",
+ value: function add(doc) {
+ var idx = this.size();
+ if (isString(doc)) {
+ this._addString(doc, idx);
+ } else {
+ this._addObject(doc, idx);
+ }
+ }
+ // Removes the doc at the specified index of the index
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this.records.splice(idx, 1);
+
+ // Change ref index of every subsquent doc
+ for (var i = idx, len = this.size(); i < len; i += 1) {
+ this.records[i].i -= 1;
+ }
+ }
+ }, {
+ key: "getValueForItemAtKeyId",
+ value: function getValueForItemAtKeyId(item, keyId) {
+ return item[this._keysMap[keyId]];
+ }
+ }, {
+ key: "size",
+ value: function size() {
+ return this.records.length;
+ }
+ }, {
+ key: "_addString",
+ value: function _addString(doc, docIndex) {
+ if (!isDefined(doc) || isBlank(doc)) {
+ return;
+ }
+ var record = {
+ v: doc,
+ i: docIndex,
+ n: this.norm.get(doc)
+ };
+ this.records.push(record);
+ }
+ }, {
+ key: "_addObject",
+ value: function _addObject(doc, docIndex) {
+ var _this3 = this;
+ var record = {
+ i: docIndex,
+ $: {}
+ };
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ this.keys.forEach(function (key, keyIndex) {
+ var value = key.getFn ? key.getFn(doc) : _this3.getFn(doc, key.path);
+ if (!isDefined(value)) {
+ return;
+ }
+ if (isArray(value)) {
+ var subRecords = [];
+ var stack = [{
+ nestedArrIndex: -1,
+ value: value
+ }];
+ while (stack.length) {
+ var _stack$pop = stack.pop(),
+ nestedArrIndex = _stack$pop.nestedArrIndex,
+ _value = _stack$pop.value;
+ if (!isDefined(_value)) {
+ continue;
+ }
+ if (isString(_value) && !isBlank(_value)) {
+ var subRecord = {
+ v: _value,
+ i: nestedArrIndex,
+ n: _this3.norm.get(_value)
+ };
+ subRecords.push(subRecord);
+ } else if (isArray(_value)) {
+ _value.forEach(function (item, k) {
+ stack.push({
+ nestedArrIndex: k,
+ value: item
+ });
+ });
+ } else ;
+ }
+ record.$[keyIndex] = subRecords;
+ } else if (isString(value) && !isBlank(value)) {
+ var _subRecord = {
+ v: value,
+ n: _this3.norm.get(value)
+ };
+ record.$[keyIndex] = _subRecord;
+ }
+ });
+ this.records.push(record);
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return {
+ keys: this.keys,
+ records: this.records
+ };
+ }
+ }]);
+ return FuseIndex;
+ }();
+ function createIndex(keys, docs) {
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref2$getFn = _ref2.getFn,
+ getFn = _ref2$getFn === void 0 ? Config.getFn : _ref2$getFn,
+ _ref2$fieldNormWeight = _ref2.fieldNormWeight,
+ fieldNormWeight = _ref2$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref2$fieldNormWeight;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys.map(createKey));
+ myIndex.setSources(docs);
+ myIndex.create();
+ return myIndex;
+ }
+ function parseIndex(data) {
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref3$getFn = _ref3.getFn,
+ getFn = _ref3$getFn === void 0 ? Config.getFn : _ref3$getFn,
+ _ref3$fieldNormWeight = _ref3.fieldNormWeight,
+ fieldNormWeight = _ref3$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref3$fieldNormWeight;
+ var keys = data.keys,
+ records = data.records;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys);
+ myIndex.setIndexRecords(records);
+ return myIndex;
+ }
+
+ function computeScore$1(pattern) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$errors = _ref.errors,
+ errors = _ref$errors === void 0 ? 0 : _ref$errors,
+ _ref$currentLocation = _ref.currentLocation,
+ currentLocation = _ref$currentLocation === void 0 ? 0 : _ref$currentLocation,
+ _ref$expectedLocation = _ref.expectedLocation,
+ expectedLocation = _ref$expectedLocation === void 0 ? 0 : _ref$expectedLocation,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ var accuracy = errors / pattern.length;
+ if (ignoreLocation) {
+ return accuracy;
+ }
+ var proximity = Math.abs(expectedLocation - currentLocation);
+ if (!distance) {
+ // Dodge divide by zero error.
+ return proximity ? 1.0 : accuracy;
+ }
+ return accuracy + proximity / distance;
+ }
+
+ function convertMaskToIndices() {
+ var matchmask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ var minMatchCharLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Config.minMatchCharLength;
+ var indices = [];
+ var start = -1;
+ var end = -1;
+ var i = 0;
+ for (var len = matchmask.length; i < len; i += 1) {
+ var match = matchmask[i];
+ if (match && start === -1) {
+ start = i;
+ } else if (!match && start !== -1) {
+ end = i - 1;
+ if (end - start + 1 >= minMatchCharLength) {
+ indices.push([start, end]);
+ }
+ start = -1;
+ }
+ }
+
+ // (i-1 - start) + 1 => i - start
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
+ indices.push([start, i - 1]);
+ }
+ return indices;
+ }
+
+ // Machine word size
+ var MAX_BITS = 32;
+
+ function search(text, pattern, patternAlphabet) {
+ var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ if (pattern.length > MAX_BITS) {
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
+ }
+ var patternLen = pattern.length;
+ // Set starting location at beginning text and initialize the alphabet.
+ var textLen = text.length;
+ // Handle the case when location > text.length
+ var expectedLocation = Math.max(0, Math.min(location, textLen));
+ // Highest score beyond which we give up.
+ var currentThreshold = threshold;
+ // Is there a nearby exact match? (speedup)
+ var bestLocation = expectedLocation;
+
+ // Performance: only computer matches when the minMatchCharLength > 1
+ // OR if `includeMatches` is true.
+ var computeMatches = minMatchCharLength > 1 || includeMatches;
+ // A mask of the matches, used for building the indices
+ var matchMask = computeMatches ? Array(textLen) : [];
+ var index;
+
+ // Get all exact matches, here for speed up
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
+ var score = computeScore$1(pattern, {
+ currentLocation: index,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ currentThreshold = Math.min(score, currentThreshold);
+ bestLocation = index + patternLen;
+ if (computeMatches) {
+ var i = 0;
+ while (i < patternLen) {
+ matchMask[index + i] = 1;
+ i += 1;
+ }
+ }
+ }
+
+ // Reset the best location
+ bestLocation = -1;
+ var lastBitArr = [];
+ var finalScore = 1;
+ var binMax = patternLen + textLen;
+ var mask = 1 << patternLen - 1;
+ for (var _i = 0; _i < patternLen; _i += 1) {
+ // Scan for the best match; each iteration allows for one more error.
+ // Run a binary search to determine how far from the match location we can stray
+ // at this error level.
+ var binMin = 0;
+ var binMid = binMax;
+ while (binMin < binMid) {
+ var _score = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: expectedLocation + binMid,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score <= currentThreshold) {
+ binMin = binMid;
+ } else {
+ binMax = binMid;
+ }
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
+ }
+
+ // Use the result from this iteration as the maximum for the next.
+ binMax = binMid;
+ var start = Math.max(1, expectedLocation - binMid + 1);
+ var finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
+
+ // Initialize the bit array
+ var bitArr = Array(finish + 2);
+ bitArr[finish + 1] = (1 << _i) - 1;
+ for (var j = finish; j >= start; j -= 1) {
+ var currentLocation = j - 1;
+ var charMatch = patternAlphabet[text.charAt(currentLocation)];
+ if (computeMatches) {
+ // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
+ matchMask[currentLocation] = +!!charMatch;
+ }
+
+ // First pass: exact match
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
+
+ // Subsequent passes: fuzzy match
+ if (_i) {
+ bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
+ }
+ if (bitArr[j] & mask) {
+ finalScore = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: currentLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+
+ // This match will almost certainly be better than any existing match.
+ // But check anyway.
+ if (finalScore <= currentThreshold) {
+ // Indeed it is
+ currentThreshold = finalScore;
+ bestLocation = currentLocation;
+
+ // Already passed `loc`, downhill from here on in.
+ if (bestLocation <= expectedLocation) {
+ break;
+ }
+
+ // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
+ }
+ }
+ }
+
+ // No hope for a (better) match at greater error levels.
+ var _score2 = computeScore$1(pattern, {
+ errors: _i + 1,
+ currentLocation: expectedLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score2 > currentThreshold) {
+ break;
+ }
+ lastBitArr = bitArr;
+ }
+ var result = {
+ isMatch: bestLocation >= 0,
+ // Count exact matches (those with a score of 0) to be "almost" exact
+ score: Math.max(0.001, finalScore)
+ };
+ if (computeMatches) {
+ var indices = convertMaskToIndices(matchMask, minMatchCharLength);
+ if (!indices.length) {
+ result.isMatch = false;
+ } else if (includeMatches) {
+ result.indices = indices;
+ }
+ }
+ return result;
+ }
+
+ function createPatternAlphabet(pattern) {
+ var mask = {};
+ for (var i = 0, len = pattern.length; i < len; i += 1) {
+ var _char = pattern.charAt(i);
+ mask[_char] = (mask[_char] || 0) | 1 << len - i - 1;
+ }
+ return mask;
+ }
+
+ var BitapSearch = /*#__PURE__*/function () {
+ function BitapSearch(pattern) {
+ var _this = this;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ _classCallCheck(this, BitapSearch);
+ this.options = {
+ location: location,
+ threshold: threshold,
+ distance: distance,
+ includeMatches: includeMatches,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ isCaseSensitive: isCaseSensitive,
+ ignoreLocation: ignoreLocation
+ };
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.chunks = [];
+ if (!this.pattern.length) {
+ return;
+ }
+ var addChunk = function addChunk(pattern, startIndex) {
+ _this.chunks.push({
+ pattern: pattern,
+ alphabet: createPatternAlphabet(pattern),
+ startIndex: startIndex
+ });
+ };
+ var len = this.pattern.length;
+ if (len > MAX_BITS) {
+ var i = 0;
+ var remainder = len % MAX_BITS;
+ var end = len - remainder;
+ while (i < end) {
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
+ i += MAX_BITS;
+ }
+ if (remainder) {
+ var startIndex = len - MAX_BITS;
+ addChunk(this.pattern.substr(startIndex), startIndex);
+ }
+ } else {
+ addChunk(this.pattern, 0);
+ }
+ }
+ _createClass(BitapSearch, [{
+ key: "searchIn",
+ value: function searchIn(text) {
+ var _this$options = this.options,
+ isCaseSensitive = _this$options.isCaseSensitive,
+ includeMatches = _this$options.includeMatches;
+ if (!isCaseSensitive) {
+ text = text.toLowerCase();
+ }
+
+ // Exact match
+ if (this.pattern === text) {
+ var _result = {
+ isMatch: true,
+ score: 0
+ };
+ if (includeMatches) {
+ _result.indices = [[0, text.length - 1]];
+ }
+ return _result;
+ }
+
+ // Otherwise, use Bitap algorithm
+ var _this$options2 = this.options,
+ location = _this$options2.location,
+ distance = _this$options2.distance,
+ threshold = _this$options2.threshold,
+ findAllMatches = _this$options2.findAllMatches,
+ minMatchCharLength = _this$options2.minMatchCharLength,
+ ignoreLocation = _this$options2.ignoreLocation;
+ var allIndices = [];
+ var totalScore = 0;
+ var hasMatches = false;
+ this.chunks.forEach(function (_ref2) {
+ var pattern = _ref2.pattern,
+ alphabet = _ref2.alphabet,
+ startIndex = _ref2.startIndex;
+ var _search = search(text, pattern, alphabet, {
+ location: location + startIndex,
+ distance: distance,
+ threshold: threshold,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ includeMatches: includeMatches,
+ ignoreLocation: ignoreLocation
+ }),
+ isMatch = _search.isMatch,
+ score = _search.score,
+ indices = _search.indices;
+ if (isMatch) {
+ hasMatches = true;
+ }
+ totalScore += score;
+ if (isMatch && indices) {
+ allIndices = [].concat(_toConsumableArray(allIndices), _toConsumableArray(indices));
+ }
+ });
+ var result = {
+ isMatch: hasMatches,
+ score: hasMatches ? totalScore / this.chunks.length : 1
+ };
+ if (hasMatches && includeMatches) {
+ result.indices = allIndices;
+ }
+ return result;
+ }
+ }]);
+ return BitapSearch;
+ }();
+
+ var registeredSearchers = [];
+ function createSearcher(pattern, options) {
+ for (var i = 0, len = registeredSearchers.length; i < len; i += 1) {
+ var searcherClass = registeredSearchers[i];
+ if (searcherClass.condition(pattern, options)) {
+ return new searcherClass(pattern, options);
+ }
+ }
+ return new BitapSearch(pattern, options);
+ }
+
+ var LogicalOperator = {
+ AND: '$and',
+ OR: '$or'
+ };
+ var KeyType = {
+ PATH: '$path',
+ PATTERN: '$val'
+ };
+ var isExpression = function isExpression(query) {
+ return !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
+ };
+ var isPath = function isPath(query) {
+ return !!query[KeyType.PATH];
+ };
+ var isLeaf = function isLeaf(query) {
+ return !isArray(query) && isObject(query) && !isExpression(query);
+ };
+ var convertToExplicit = function convertToExplicit(query) {
+ return _defineProperty({}, LogicalOperator.AND, Object.keys(query).map(function (key) {
+ return _defineProperty({}, key, query[key]);
+ }));
+ };
+
+ // When `auto` is `true`, the parse function will infer and initialize and add
+ // the appropriate `Searcher` instance
+ function parse(query, options) {
+ var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref3$auto = _ref3.auto,
+ auto = _ref3$auto === void 0 ? true : _ref3$auto;
+ var next = function next(query) {
+ var keys = Object.keys(query);
+ var isQueryPath = isPath(query);
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
+ return next(convertToExplicit(query));
+ }
+ if (isLeaf(query)) {
+ var key = isQueryPath ? query[KeyType.PATH] : keys[0];
+ var pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
+ if (!isString(pattern)) {
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
+ }
+ var obj = {
+ keyId: createKeyId(key),
+ pattern: pattern
+ };
+ if (auto) {
+ obj.searcher = createSearcher(pattern, options);
+ }
+ return obj;
+ }
+ var node = {
+ children: [],
+ operator: keys[0]
+ };
+ keys.forEach(function (key) {
+ var value = query[key];
+ if (isArray(value)) {
+ value.forEach(function (item) {
+ node.children.push(next(item));
+ });
+ }
+ });
+ return node;
+ };
+ if (!isExpression(query)) {
+ query = convertToExplicit(query);
+ }
+ return next(query);
+ }
+
+ // Practical scoring function
+ function computeScore(results, _ref) {
+ var _ref$ignoreFieldNorm = _ref.ignoreFieldNorm,
+ ignoreFieldNorm = _ref$ignoreFieldNorm === void 0 ? Config.ignoreFieldNorm : _ref$ignoreFieldNorm;
+ results.forEach(function (result) {
+ var totalScore = 1;
+ result.matches.forEach(function (_ref2) {
+ var key = _ref2.key,
+ norm = _ref2.norm,
+ score = _ref2.score;
+ var weight = key ? key.weight : null;
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
+ });
+ result.score = totalScore;
+ });
+ }
+
+ function transformMatches(result, data) {
+ var matches = result.matches;
+ data.matches = [];
+ if (!isDefined(matches)) {
+ return;
+ }
+ matches.forEach(function (match) {
+ if (!isDefined(match.indices) || !match.indices.length) {
+ return;
+ }
+ var indices = match.indices,
+ value = match.value;
+ var obj = {
+ indices: indices,
+ value: value
+ };
+ if (match.key) {
+ obj.key = match.key.src;
+ }
+ if (match.idx > -1) {
+ obj.refIndex = match.idx;
+ }
+ data.matches.push(obj);
+ });
+ }
+
+ function transformScore(result, data) {
+ data.score = result.score;
+ }
+
+ function format(results, docs) {
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$includeScore = _ref.includeScore,
+ includeScore = _ref$includeScore === void 0 ? Config.includeScore : _ref$includeScore;
+ var transformers = [];
+ if (includeMatches) transformers.push(transformMatches);
+ if (includeScore) transformers.push(transformScore);
+ return results.map(function (result) {
+ var idx = result.idx;
+ var data = {
+ item: docs[idx],
+ refIndex: idx
+ };
+ if (transformers.length) {
+ transformers.forEach(function (transformer) {
+ transformer(result, data);
+ });
+ }
+ return data;
+ });
+ }
+
+ var Fuse$1 = /*#__PURE__*/function () {
+ function Fuse(docs) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ var index = arguments.length > 2 ? arguments[2] : undefined;
+ _classCallCheck(this, Fuse);
+ this.options = _objectSpread2(_objectSpread2({}, Config), options);
+ if (this.options.useExtendedSearch && !false) {
+ throw new Error(EXTENDED_SEARCH_UNAVAILABLE);
+ }
+ this._keyStore = new KeyStore(this.options.keys);
+ this.setCollection(docs, index);
+ }
+ _createClass(Fuse, [{
+ key: "setCollection",
+ value: function setCollection(docs, index) {
+ this._docs = docs;
+ if (index && !(index instanceof FuseIndex)) {
+ throw new Error(INCORRECT_INDEX_TYPE);
+ }
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
+ getFn: this.options.getFn,
+ fieldNormWeight: this.options.fieldNormWeight
+ });
+ }
+ }, {
+ key: "add",
+ value: function add(doc) {
+ if (!isDefined(doc)) {
+ return;
+ }
+ this._docs.push(doc);
+ this._myIndex.add(doc);
+ }
+ }, {
+ key: "remove",
+ value: function remove() {
+ var predicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function /* doc, idx */ () {
+ return false;
+ };
+ var results = [];
+ for (var i = 0, len = this._docs.length; i < len; i += 1) {
+ var doc = this._docs[i];
+ if (predicate(doc, i)) {
+ this.removeAt(i);
+ i -= 1;
+ len -= 1;
+ results.push(doc);
+ }
+ }
+ return results;
+ }
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this._docs.splice(idx, 1);
+ this._myIndex.removeAt(idx);
+ }
+ }, {
+ key: "getIndex",
+ value: function getIndex() {
+ return this._myIndex;
+ }
+ }, {
+ key: "search",
+ value: function search(query) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$limit = _ref.limit,
+ limit = _ref$limit === void 0 ? -1 : _ref$limit;
+ var _this$options = this.options,
+ includeMatches = _this$options.includeMatches,
+ includeScore = _this$options.includeScore,
+ shouldSort = _this$options.shouldSort,
+ sortFn = _this$options.sortFn,
+ ignoreFieldNorm = _this$options.ignoreFieldNorm;
+ var results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
+ computeScore(results, {
+ ignoreFieldNorm: ignoreFieldNorm
+ });
+ if (shouldSort) {
+ results.sort(sortFn);
+ }
+ if (isNumber(limit) && limit > -1) {
+ results = results.slice(0, limit);
+ }
+ return format(results, this._docs, {
+ includeMatches: includeMatches,
+ includeScore: includeScore
+ });
+ }
+ }, {
+ key: "_searchStringList",
+ value: function _searchStringList(query) {
+ var searcher = createSearcher(query, this.options);
+ var records = this._myIndex.records;
+ var results = [];
+
+ // Iterate over every string in the index
+ records.forEach(function (_ref2) {
+ var text = _ref2.v,
+ idx = _ref2.i,
+ norm = _ref2.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn = searcher.searchIn(text),
+ isMatch = _searcher$searchIn.isMatch,
+ score = _searcher$searchIn.score,
+ indices = _searcher$searchIn.indices;
+ if (isMatch) {
+ results.push({
+ item: text,
+ idx: idx,
+ matches: [{
+ score: score,
+ value: text,
+ norm: norm,
+ indices: indices
+ }]
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_searchLogical",
+ value: function _searchLogical(query) {
+ {
+ throw new Error(LOGICAL_SEARCH_UNAVAILABLE);
+ }
+ }
+ }, {
+ key: "_searchObjectList",
+ value: function _searchObjectList(query) {
+ var _this2 = this;
+ var searcher = createSearcher(query, this.options);
+ var _this$_myIndex = this._myIndex,
+ keys = _this$_myIndex.keys,
+ records = _this$_myIndex.records;
+ var results = [];
+
+ // List is Array<Object>
+ records.forEach(function (_ref5) {
+ var item = _ref5.$,
+ idx = _ref5.i;
+ if (!isDefined(item)) {
+ return;
+ }
+ var matches = [];
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ keys.forEach(function (key, keyIndex) {
+ matches.push.apply(matches, _toConsumableArray(_this2._findMatches({
+ key: key,
+ value: item[keyIndex],
+ searcher: searcher
+ })));
+ });
+ if (matches.length) {
+ results.push({
+ idx: idx,
+ item: item,
+ matches: matches
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_findMatches",
+ value: function _findMatches(_ref6) {
+ var key = _ref6.key,
+ value = _ref6.value,
+ searcher = _ref6.searcher;
+ if (!isDefined(value)) {
+ return [];
+ }
+ var matches = [];
+ if (isArray(value)) {
+ value.forEach(function (_ref7) {
+ var text = _ref7.v,
+ idx = _ref7.i,
+ norm = _ref7.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn2 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn2.isMatch,
+ score = _searcher$searchIn2.score,
+ indices = _searcher$searchIn2.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ idx: idx,
+ norm: norm,
+ indices: indices
+ });
+ }
+ });
+ } else {
+ var text = value.v,
+ norm = value.n;
+ var _searcher$searchIn3 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn3.isMatch,
+ score = _searcher$searchIn3.score,
+ indices = _searcher$searchIn3.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ norm: norm,
+ indices: indices
+ });
+ }
+ }
+ return matches;
+ }
+ }]);
+ return Fuse;
+ }();
+
+ Fuse$1.version = '7.0.0';
+ Fuse$1.createIndex = createIndex;
+ Fuse$1.parseIndex = parseIndex;
+ Fuse$1.config = Config;
+ {
+ Fuse$1.parseQuery = parse;
+ }
+ var Fuse = Fuse$1;
+
+ return Fuse;
+
+}));
diff --git a/includes/node_modules/fuse.js/dist/fuse.basic.min.cjs b/includes/node_modules/fuse.js/dist/fuse.basic.min.cjs
new file mode 100644
index 0000000..56c2bf8
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.basic.min.cjs
@@ -0,0 +1,9 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,h(r.key),r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function h(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function u(e){return Array.isArray?Array.isArray(e):"[object Array]"===m(e)}var l=1/0;function d(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}(e)}function f(e){return"string"==typeof e}function v(e){return"number"==typeof e}function g(e){return!0===e||!1===e||function(e){return function(e){return"object"===n(e)}(e)&&null!==e}(e)&&"[object Boolean]"==m(e)}function y(e){return null!=e}function p(e){return!e.trim().length}function m(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var b=function(e){return"Missing ".concat(e," property in key")},k=function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")},M=Object.prototype.hasOwnProperty,w=function(){function e(t){var n=this;r(this,e),this._keys=[],this._keyMap={};var i=0;t.forEach((function(e){var t=x(e);n._keys.push(t),n._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return o(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function x(e){var t=null,n=null,r=null,i=1,o=null;if(f(e)||u(e))r=e,t=L(e),n=S(e);else{if(!M.call(e,"name"))throw new Error(b("name"));var a=e.name;if(r=a,M.call(e,"weight")&&(i=e.weight)<=0)throw new Error(k(a));t=L(a),n=S(a),o=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:o}}function L(e){return u(e)?e:e.split(".")}function S(e){return u(e)?e.join("."):e}var _={useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(y(t))if(i[o]){var a=t[i[o]];if(!y(a))return;if(o===i.length-1&&(f(a)||v(a)||g(a)))n.push(d(a));else if(u(a)){r=!0;for(var c=0,s=a.length;c<s;c+=1)e(a[c],i,o+1)}else i.length&&e(a,i,o+1)}else n.push(t)}(e,f(t)?t.split("."):t,0),r?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},O=t(t(t(t({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),_),j=/[^ ]+/g;var A=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?O.getFn:n,o=t.fieldNormWeight,a=void 0===o?O.fieldNormWeight:o;r(this,e),this.norm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(j).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),a=parseFloat(Math.round(o*r)/r);return n.set(i,a),a},clear:function(){n.clear()}}}(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,f(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();f(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,t){if(y(e)&&!p(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(e,t){var n=this,r={i:t,$:{}};this.keys.forEach((function(t,i){var o=t.getFn?t.getFn(e):n.getFn(e,t.path);if(y(o))if(u(o)){for(var a=[],c=[{nestedArrIndex:-1,value:o}];c.length;){var s=c.pop(),h=s.nestedArrIndex,l=s.value;if(y(l))if(f(l)&&!p(l)){var d={v:l,i:h,n:n.norm.get(l)};a.push(d)}else u(l)&&l.forEach((function(e,t){c.push({nestedArrIndex:t,value:e})}))}r.$[i]=a}else if(f(o)&&!p(o)){var v={v:o,n:n.norm.get(o)};r.$[i]=v}})),this.records.push(r)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),e}();function E(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?O.getFn:r,o=n.fieldNormWeight,a=void 0===o?O.fieldNormWeight:o,c=new A({getFn:i,fieldNormWeight:a});return c.setKeys(e.map(x)),c.setSources(t),c.create(),c}function I(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,a=t.expectedLocation,c=void 0===a?0:a,s=t.distance,h=void 0===s?O.distance:s,u=t.ignoreLocation,l=void 0===u?O.ignoreLocation:u,d=r/e.length;if(l)return d;var f=Math.abs(c-o);return h?d+f/h:f?1:d}var F=32;function C(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?O.location:i,a=r.distance,c=void 0===a?O.distance:a,s=r.threshold,h=void 0===s?O.threshold:s,u=r.findAllMatches,l=void 0===u?O.findAllMatches:u,d=r.minMatchCharLength,f=void 0===d?O.minMatchCharLength:d,v=r.includeMatches,g=void 0===v?O.includeMatches:v,y=r.ignoreLocation,p=void 0===y?O.ignoreLocation:y;if(t.length>F)throw new Error("Pattern length exceeds max of ".concat(F,"."));for(var m,b=t.length,k=e.length,M=Math.max(0,Math.min(o,k)),w=h,x=M,L=f>1||g,S=L?Array(k):[];(m=e.indexOf(t,x))>-1;){var _=I(t,{currentLocation:m,expectedLocation:M,distance:c,ignoreLocation:p});if(w=Math.min(_,w),x=m+b,L)for(var j=0;j<b;)S[m+j]=1,j+=1}x=-1;for(var A=[],E=1,C=b+k,N=1<<b-1,P=0;P<b;P+=1){for(var W=0,$=C;W<$;){I(t,{errors:P,currentLocation:M+$,expectedLocation:M,distance:c,ignoreLocation:p})<=w?W=$:C=$,$=Math.floor((C-W)/2+W)}C=$;var D=Math.max(1,M-$+1),K=l?k:Math.min(M+$,k)+b,z=Array(K+2);z[K+1]=(1<<P)-1;for(var J=K;J>=D;J-=1){var R=J-1,T=n[e.charAt(R)];if(L&&(S[R]=+!!T),z[J]=(z[J+1]<<1|1)&T,P&&(z[J]|=(A[J+1]|A[J])<<1|1|A[J+1]),z[J]&N&&(E=I(t,{errors:P,currentLocation:R,expectedLocation:M,distance:c,ignoreLocation:p}))<=w){if(w=E,(x=R)<=M)break;D=Math.max(1,2*M-x)}}if(I(t,{errors:P+1,currentLocation:M,expectedLocation:M,distance:c,ignoreLocation:p})>w)break;A=z}var U={isMatch:x>=0,score:Math.max(.001,E)};if(L){var B=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O.minMatchCharLength,n=[],r=-1,i=-1,o=0,a=e.length;o<a;o+=1){var c=e[o];c&&-1===r?r=o:c||-1===r||((i=o-1)-r+1>=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}(S,f);B.length?g&&(U.indices=B):U.isMatch=!1}return U}function N(e){for(var t={},n=0,r=e.length;n<r;n+=1){var i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}var P=function(){function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,a=void 0===o?O.location:o,c=i.threshold,s=void 0===c?O.threshold:c,h=i.distance,u=void 0===h?O.distance:h,l=i.includeMatches,d=void 0===l?O.includeMatches:l,f=i.findAllMatches,v=void 0===f?O.findAllMatches:f,g=i.minMatchCharLength,y=void 0===g?O.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?O.isCaseSensitive:p,b=i.ignoreLocation,k=void 0===b?O.ignoreLocation:b;if(r(this,e),this.options={location:a,threshold:s,distance:u,includeMatches:d,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:k},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var M=function(e,t){n.chunks.push({pattern:e,alphabet:N(e),startIndex:t})},w=this.pattern.length;if(w>F){for(var x=0,L=w%F,S=w-L;x<S;)M(this.pattern.substr(x,F),x),x+=F;if(L){var _=w-F;M(this.pattern.substr(_),_)}}else M(this.pattern,0)}}return o(e,[{key:"searchIn",value:function(e){var t=this.options,n=t.isCaseSensitive,r=t.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var i={isMatch:!0,score:0};return r&&(i.indices=[[0,e.length-1]]),i}var o=this.options,a=o.location,s=o.distance,h=o.threshold,u=o.findAllMatches,l=o.minMatchCharLength,d=o.ignoreLocation,f=[],v=0,g=!1;this.chunks.forEach((function(t){var n=t.pattern,i=t.alphabet,o=t.startIndex,y=C(e,n,i,{location:a+o,distance:s,threshold:h,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:d}),p=y.isMatch,m=y.score,b=y.indices;p&&(g=!0),v+=m,p&&b&&(f=[].concat(c(f),c(b)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=f),y}}]),e}(),W=[];function $(e,t){for(var n=0,r=W.length;n<r;n+=1){var i=W[n];if(i.condition(e,t))return new i(e,t)}return new P(e,t)}function D(e,t){var n=e.matches;t.matches=[],y(n)&&n.forEach((function(e){if(y(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function K(e,t){t.score=e.score}var z=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(r(this,e),this.options=t(t({},O),i),this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new w(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof A))throw new Error("Incorrect 'index' type");this._myIndex=t||E(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){y(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n<r;n+=1){var i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,t.push(i))}return t}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).limit,n=void 0===t?-1:t,r=this.options,i=r.includeMatches,o=r.includeScore,a=r.shouldSort,c=r.sortFn,s=r.ignoreFieldNorm,h=f(e)?f(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,t){var n=t.ignoreFieldNorm,r=void 0===n?O.ignoreFieldNorm:n;e.forEach((function(e){var t=1;e.matches.forEach((function(e){var n=e.key,i=e.norm,o=e.score,a=n?n.weight:null;t*=Math.pow(0===o&&a?Number.EPSILON:o,(a||1)*(r?1:i))})),e.score=t}))}(h,{ignoreFieldNorm:s}),a&&h.sort(c),v(n)&&n>-1&&(h=h.slice(0,n)),function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?O.includeMatches:r,o=n.includeScore,a=void 0===o?O.includeScore:o,c=[];return i&&c.push(D),a&&c.push(K),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return c.length&&c.forEach((function(t){t(e,r)})),r}))}(h,this._docs,{includeMatches:i,includeScore:o})}},{key:"_searchStringList",value:function(e){var t=$(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(y(n)){var a=t.searchIn(n),c=a.isMatch,s=a.score,h=a.indices;c&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:h}]})}})),r}},{key:"_searchLogical",value:function(e){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(e){var t=this,n=$(e,this.options),r=this._myIndex,i=r.keys,o=r.records,a=[];return o.forEach((function(e){var r=e.$,o=e.i;if(y(r)){var s=[];i.forEach((function(e,i){s.push.apply(s,c(t._findMatches({key:e,value:r[i],searcher:n})))})),s.length&&a.push({idx:o,item:r,matches:s})}})),a}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!y(n))return[];var i=[];if(u(n))n.forEach((function(e){var n=e.v,o=e.i,a=e.n;if(y(n)){var c=r.searchIn(n),s=c.isMatch,h=c.score,u=c.indices;s&&i.push({score:h,key:t,value:n,idx:o,norm:a,indices:u})}}));else{var o=n.v,a=n.n,c=r.searchIn(o),s=c.isMatch,h=c.score,l=c.indices;s&&i.push({score:h,key:t,value:o,norm:a,indices:l})}return i}}]),e}();z.version="7.0.0",z.createIndex=E,z.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?O.getFn:n,i=t.fieldNormWeight,o=void 0===i?O.fieldNormWeight:i,a=e.keys,c=e.records,s=new A({getFn:r,fieldNormWeight:o});return s.setKeys(a),s.setIndexRecords(c),s},z.config=O;var J=z;module.exports=J; \ No newline at end of file
diff --git a/includes/node_modules/fuse.js/dist/fuse.basic.min.js b/includes/node_modules/fuse.js/dist/fuse.basic.min.js
new file mode 100644
index 0000000..7457721
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.basic.min.js
@@ -0,0 +1,9 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,h(r.key),r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function h(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function u(e){return Array.isArray?Array.isArray(e):"[object Array]"===m(e)}var l=1/0;function d(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}(e)}function f(e){return"string"==typeof e}function v(e){return"number"==typeof e}function g(e){return!0===e||!1===e||function(e){return function(e){return"object"===n(e)}(e)&&null!==e}(e)&&"[object Boolean]"==m(e)}function y(e){return null!=e}function p(e){return!e.trim().length}function m(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var b=function(e){return"Missing ".concat(e," property in key")},k=function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")},M=Object.prototype.hasOwnProperty,w=function(){function e(t){var n=this;r(this,e),this._keys=[],this._keyMap={};var i=0;t.forEach((function(e){var t=x(e);n._keys.push(t),n._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return o(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function x(e){var t=null,n=null,r=null,i=1,o=null;if(f(e)||u(e))r=e,t=L(e),n=S(e);else{if(!M.call(e,"name"))throw new Error(b("name"));var a=e.name;if(r=a,M.call(e,"weight")&&(i=e.weight)<=0)throw new Error(k(a));t=L(a),n=S(a),o=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:o}}function L(e){return u(e)?e:e.split(".")}function S(e){return u(e)?e.join("."):e}var _={useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(y(t))if(i[o]){var a=t[i[o]];if(!y(a))return;if(o===i.length-1&&(f(a)||v(a)||g(a)))n.push(d(a));else if(u(a)){r=!0;for(var c=0,s=a.length;c<s;c+=1)e(a[c],i,o+1)}else i.length&&e(a,i,o+1)}else n.push(t)}(e,f(t)?t.split("."):t,0),r?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},O=t(t(t(t({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),_),j=/[^ ]+/g,A=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?O.getFn:n,o=t.fieldNormWeight,a=void 0===o?O.fieldNormWeight:o;r(this,e),this.norm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(j).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),a=parseFloat(Math.round(o*r)/r);return n.set(i,a),a},clear:function(){n.clear()}}}(a,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,f(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();f(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,t){if(y(e)&&!p(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(e,t){var n=this,r={i:t,$:{}};this.keys.forEach((function(t,i){var o=t.getFn?t.getFn(e):n.getFn(e,t.path);if(y(o))if(u(o)){for(var a=[],c=[{nestedArrIndex:-1,value:o}];c.length;){var s=c.pop(),h=s.nestedArrIndex,l=s.value;if(y(l))if(f(l)&&!p(l)){var d={v:l,i:h,n:n.norm.get(l)};a.push(d)}else u(l)&&l.forEach((function(e,t){c.push({nestedArrIndex:t,value:e})}))}r.$[i]=a}else if(f(o)&&!p(o)){var v={v:o,n:n.norm.get(o)};r.$[i]=v}})),this.records.push(r)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),e}();function E(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?O.getFn:r,o=n.fieldNormWeight,a=void 0===o?O.fieldNormWeight:o,c=new A({getFn:i,fieldNormWeight:a});return c.setKeys(e.map(x)),c.setSources(t),c.create(),c}function I(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,a=t.expectedLocation,c=void 0===a?0:a,s=t.distance,h=void 0===s?O.distance:s,u=t.ignoreLocation,l=void 0===u?O.ignoreLocation:u,d=r/e.length;if(l)return d;var f=Math.abs(c-o);return h?d+f/h:f?1:d}var F=32;function C(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?O.location:i,a=r.distance,c=void 0===a?O.distance:a,s=r.threshold,h=void 0===s?O.threshold:s,u=r.findAllMatches,l=void 0===u?O.findAllMatches:u,d=r.minMatchCharLength,f=void 0===d?O.minMatchCharLength:d,v=r.includeMatches,g=void 0===v?O.includeMatches:v,y=r.ignoreLocation,p=void 0===y?O.ignoreLocation:y;if(t.length>F)throw new Error("Pattern length exceeds max of ".concat(F,"."));for(var m,b=t.length,k=e.length,M=Math.max(0,Math.min(o,k)),w=h,x=M,L=f>1||g,S=L?Array(k):[];(m=e.indexOf(t,x))>-1;){var _=I(t,{currentLocation:m,expectedLocation:M,distance:c,ignoreLocation:p});if(w=Math.min(_,w),x=m+b,L)for(var j=0;j<b;)S[m+j]=1,j+=1}x=-1;for(var A=[],E=1,C=b+k,N=1<<b-1,P=0;P<b;P+=1){for(var W=0,T=C;W<T;)I(t,{errors:P,currentLocation:M+T,expectedLocation:M,distance:c,ignoreLocation:p})<=w?W=T:C=T,T=Math.floor((C-W)/2+W);C=T;var $=Math.max(1,M-T+1),D=l?k:Math.min(M+T,k)+b,K=Array(D+2);K[D+1]=(1<<P)-1;for(var z=D;z>=$;z-=1){var J=z-1,R=n[e.charAt(J)];if(L&&(S[J]=+!!R),K[z]=(K[z+1]<<1|1)&R,P&&(K[z]|=(A[z+1]|A[z])<<1|1|A[z+1]),K[z]&N&&(E=I(t,{errors:P,currentLocation:J,expectedLocation:M,distance:c,ignoreLocation:p}))<=w){if(w=E,(x=J)<=M)break;$=Math.max(1,2*M-x)}}if(I(t,{errors:P+1,currentLocation:M,expectedLocation:M,distance:c,ignoreLocation:p})>w)break;A=K}var U={isMatch:x>=0,score:Math.max(.001,E)};if(L){var B=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O.minMatchCharLength,n=[],r=-1,i=-1,o=0,a=e.length;o<a;o+=1){var c=e[o];c&&-1===r?r=o:c||-1===r||((i=o-1)-r+1>=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}(S,f);B.length?g&&(U.indices=B):U.isMatch=!1}return U}function N(e){for(var t={},n=0,r=e.length;n<r;n+=1){var i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}var P=function(){function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,a=void 0===o?O.location:o,c=i.threshold,s=void 0===c?O.threshold:c,h=i.distance,u=void 0===h?O.distance:h,l=i.includeMatches,d=void 0===l?O.includeMatches:l,f=i.findAllMatches,v=void 0===f?O.findAllMatches:f,g=i.minMatchCharLength,y=void 0===g?O.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?O.isCaseSensitive:p,b=i.ignoreLocation,k=void 0===b?O.ignoreLocation:b;if(r(this,e),this.options={location:a,threshold:s,distance:u,includeMatches:d,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:k},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var M=function(e,t){n.chunks.push({pattern:e,alphabet:N(e),startIndex:t})},w=this.pattern.length;if(w>F){for(var x=0,L=w%F,S=w-L;x<S;)M(this.pattern.substr(x,F),x),x+=F;if(L){var _=w-F;M(this.pattern.substr(_),_)}}else M(this.pattern,0)}}return o(e,[{key:"searchIn",value:function(e){var t=this.options,n=t.isCaseSensitive,r=t.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var i={isMatch:!0,score:0};return r&&(i.indices=[[0,e.length-1]]),i}var o=this.options,a=o.location,s=o.distance,h=o.threshold,u=o.findAllMatches,l=o.minMatchCharLength,d=o.ignoreLocation,f=[],v=0,g=!1;this.chunks.forEach((function(t){var n=t.pattern,i=t.alphabet,o=t.startIndex,y=C(e,n,i,{location:a+o,distance:s,threshold:h,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:d}),p=y.isMatch,m=y.score,b=y.indices;p&&(g=!0),v+=m,p&&b&&(f=[].concat(c(f),c(b)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=f),y}}]),e}(),W=[];function T(e,t){for(var n=0,r=W.length;n<r;n+=1){var i=W[n];if(i.condition(e,t))return new i(e,t)}return new P(e,t)}function $(e,t){var n=e.matches;t.matches=[],y(n)&&n.forEach((function(e){if(y(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function D(e,t){t.score=e.score}var K=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(r(this,e),this.options=t(t({},O),i),this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new w(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof A))throw new Error("Incorrect 'index' type");this._myIndex=t||E(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){y(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n<r;n+=1){var i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,t.push(i))}return t}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).limit,n=void 0===t?-1:t,r=this.options,i=r.includeMatches,o=r.includeScore,a=r.shouldSort,c=r.sortFn,s=r.ignoreFieldNorm,h=f(e)?f(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,t){var n=t.ignoreFieldNorm,r=void 0===n?O.ignoreFieldNorm:n;e.forEach((function(e){var t=1;e.matches.forEach((function(e){var n=e.key,i=e.norm,o=e.score,a=n?n.weight:null;t*=Math.pow(0===o&&a?Number.EPSILON:o,(a||1)*(r?1:i))})),e.score=t}))}(h,{ignoreFieldNorm:s}),a&&h.sort(c),v(n)&&n>-1&&(h=h.slice(0,n)),function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?O.includeMatches:r,o=n.includeScore,a=void 0===o?O.includeScore:o,c=[];return i&&c.push($),a&&c.push(D),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return c.length&&c.forEach((function(t){t(e,r)})),r}))}(h,this._docs,{includeMatches:i,includeScore:o})}},{key:"_searchStringList",value:function(e){var t=T(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(y(n)){var a=t.searchIn(n),c=a.isMatch,s=a.score,h=a.indices;c&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:h}]})}})),r}},{key:"_searchLogical",value:function(e){throw new Error("Logical search is not available")}},{key:"_searchObjectList",value:function(e){var t=this,n=T(e,this.options),r=this._myIndex,i=r.keys,o=r.records,a=[];return o.forEach((function(e){var r=e.$,o=e.i;if(y(r)){var s=[];i.forEach((function(e,i){s.push.apply(s,c(t._findMatches({key:e,value:r[i],searcher:n})))})),s.length&&a.push({idx:o,item:r,matches:s})}})),a}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!y(n))return[];var i=[];if(u(n))n.forEach((function(e){var n=e.v,o=e.i,a=e.n;if(y(n)){var c=r.searchIn(n),s=c.isMatch,h=c.score,u=c.indices;s&&i.push({score:h,key:t,value:n,idx:o,norm:a,indices:u})}}));else{var o=n.v,a=n.n,c=r.searchIn(o),s=c.isMatch,h=c.score,l=c.indices;s&&i.push({score:h,key:t,value:o,norm:a,indices:l})}return i}}]),e}();return K.version="7.0.0",K.createIndex=E,K.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?O.getFn:n,i=t.fieldNormWeight,o=void 0===i?O.fieldNormWeight:i,a=e.keys,c=e.records,s=new A({getFn:r,fieldNormWeight:o});return s.setKeys(a),s.setIndexRecords(c),s},K.config=O,K},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t(); \ No newline at end of file
diff --git a/includes/node_modules/fuse.js/dist/fuse.basic.min.mjs b/includes/node_modules/fuse.js/dist/fuse.basic.min.mjs
new file mode 100644
index 0000000..07e34d5
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.basic.min.mjs
@@ -0,0 +1,9 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+function t(t){return Array.isArray?Array.isArray(t):"[object Array]"===h(t)}const e=1/0;function n(t){return null==t?"":function(t){if("string"==typeof t)return t;let n=t+"";return"0"==n&&1/t==-e?"-0":n}(t)}function i(t){return"string"==typeof t}function s(t){return"number"==typeof t}function r(t){return!0===t||!1===t||function(t){return function(t){return"object"==typeof t}(t)&&null!==t}(t)&&"[object Boolean]"==h(t)}function o(t){return null!=t}function c(t){return!t.trim().length}function h(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const a=t=>`Missing ${t} property in key`,l=t=>`Property 'weight' in key '${t}' must be a positive integer`,d=Object.prototype.hasOwnProperty;class u{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{let n=f(t);this._keys.push(n),this._keyMap[n.id]=n,e+=n.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function f(e){let n=null,s=null,r=null,o=1,c=null;if(i(e)||t(e))r=e,n=g(e),s=p(e);else{if(!d.call(e,"name"))throw new Error(a("name"));const t=e.name;if(r=t,d.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(l(t));n=g(t),s=p(t),c=e.getFn}return{path:n,id:s,weight:o,src:r,getFn:c}}function g(e){return t(e)?e:e.split(".")}function p(e){return t(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...{useExtendedSearch:!1,getFn:function(e,c){let h=[],a=!1;const l=(e,c,d)=>{if(o(e))if(c[d]){const u=e[c[d]];if(!o(u))return;if(d===c.length-1&&(i(u)||s(u)||r(u)))h.push(n(u));else if(t(u)){a=!0;for(let t=0,e=u.length;t<e;t+=1)l(u[t],c,d+1)}else c.length&&l(u,c,d+1)}else h.push(e)};return l(e,i(c)?c.split("."):c,0),a?h:h[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const y=/[^ ]+/g;class M{constructor({getFn:t=m.getFn,fieldNormWeight:e=m.fieldNormWeight}={}){this.norm=function(t=1,e=3){const n=new Map,i=Math.pow(10,e);return{get(e){const s=e.match(y).length;if(n.has(s))return n.get(s);const r=1/Math.pow(s,.5*t),o=parseFloat(Math.round(r*i)/i);return n.set(s,o),o},clear(){n.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach(((t,e)=>{this._keysMap[t.id]=e}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,i(this.docs[0])?this.docs.forEach(((t,e)=>{this._addString(t,e)})):this.docs.forEach(((t,e)=>{this._addObject(t,e)})),this.norm.clear())}add(t){const e=this.size();i(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,n=this.size();e<n;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!o(t)||c(t))return;let n={v:t,i:e,n:this.norm.get(t)};this.records.push(n)}_addObject(e,n){let s={i:n,$:{}};this.keys.forEach(((n,r)=>{let h=n.getFn?n.getFn(e):this.getFn(e,n.path);if(o(h))if(t(h)){let e=[];const n=[{nestedArrIndex:-1,value:h}];for(;n.length;){const{nestedArrIndex:s,value:r}=n.pop();if(o(r))if(i(r)&&!c(r)){let t={v:r,i:s,n:this.norm.get(r)};e.push(t)}else t(r)&&r.forEach(((t,e)=>{n.push({nestedArrIndex:e,value:t})}))}s.$[r]=e}else if(i(h)&&!c(h)){let t={v:h,n:this.norm.get(h)};s.$[r]=t}})),this.records.push(s)}toJSON(){return{keys:this.keys,records:this.records}}}function x(t,e,{getFn:n=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const s=new M({getFn:n,fieldNormWeight:i});return s.setKeys(t.map(f)),s.setSources(e),s.create(),s}function L(t,{errors:e=0,currentLocation:n=0,expectedLocation:i=0,distance:s=m.distance,ignoreLocation:r=m.ignoreLocation}={}){const o=e/t.length;if(r)return o;const c=Math.abs(i-n);return s?o+c/s:c?1:o}const _=32;function k(t,e,n,{location:i=m.location,distance:s=m.distance,threshold:r=m.threshold,findAllMatches:o=m.findAllMatches,minMatchCharLength:c=m.minMatchCharLength,includeMatches:h=m.includeMatches,ignoreLocation:a=m.ignoreLocation}={}){if(e.length>_)throw new Error(`Pattern length exceeds max of ${_}.`);const l=e.length,d=t.length,u=Math.max(0,Math.min(i,d));let f=r,g=u;const p=c>1||h,y=p?Array(d):[];let M;for(;(M=t.indexOf(e,g))>-1;){let t=L(e,{currentLocation:M,expectedLocation:u,distance:s,ignoreLocation:a});if(f=Math.min(t,f),g=M+l,p){let t=0;for(;t<l;)y[M+t]=1,t+=1}}g=-1;let x=[],k=1,v=l+d;const w=1<<l-1;for(let i=0;i<l;i+=1){let r=0,c=v;for(;r<c;){L(e,{errors:i,currentLocation:u+c,expectedLocation:u,distance:s,ignoreLocation:a})<=f?r=c:v=c,c=Math.floor((v-r)/2+r)}v=c;let h=Math.max(1,u-c+1),m=o?d:Math.min(u+c,d)+l,M=Array(m+2);M[m+1]=(1<<i)-1;for(let r=m;r>=h;r-=1){let o=r-1,c=n[t.charAt(o)];if(p&&(y[o]=+!!c),M[r]=(M[r+1]<<1|1)&c,i&&(M[r]|=(x[r+1]|x[r])<<1|1|x[r+1]),M[r]&w&&(k=L(e,{errors:i,currentLocation:o,expectedLocation:u,distance:s,ignoreLocation:a}),k<=f)){if(f=k,g=o,g<=u)break;h=Math.max(1,2*u-g)}}if(L(e,{errors:i+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:a})>f)break;x=M}const I={isMatch:g>=0,score:Math.max(.001,k)};if(p){const t=function(t=[],e=m.minMatchCharLength){let n=[],i=-1,s=-1,r=0;for(let o=t.length;r<o;r+=1){let o=t[r];o&&-1===i?i=r:o||-1===i||(s=r-1,s-i+1>=e&&n.push([i,s]),i=-1)}return t[r-1]&&r-i>=e&&n.push([i,r-1]),n}(y,c);t.length?h&&(I.indices=t):I.isMatch=!1}return I}function v(t){let e={};for(let n=0,i=t.length;n<i;n+=1){const s=t.charAt(n);e[s]=(e[s]||0)|1<<i-n-1}return e}class w{constructor(t,{location:e=m.location,threshold:n=m.threshold,distance:i=m.distance,includeMatches:s=m.includeMatches,findAllMatches:r=m.findAllMatches,minMatchCharLength:o=m.minMatchCharLength,isCaseSensitive:c=m.isCaseSensitive,ignoreLocation:h=m.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:i,includeMatches:s,findAllMatches:r,minMatchCharLength:o,isCaseSensitive:c,ignoreLocation:h},this.pattern=c?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const a=(t,e)=>{this.chunks.push({pattern:t,alphabet:v(t),startIndex:e})},l=this.pattern.length;if(l>_){let t=0;const e=l%_,n=l-e;for(;t<n;)a(this.pattern.substr(t,_),t),t+=_;if(e){const t=l-_;a(this.pattern.substr(t),t)}}else a(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:n}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let e={isMatch:!0,score:0};return n&&(e.indices=[[0,t.length-1]]),e}const{location:i,distance:s,threshold:r,findAllMatches:o,minMatchCharLength:c,ignoreLocation:h}=this.options;let a=[],l=0,d=!1;this.chunks.forEach((({pattern:e,alphabet:u,startIndex:f})=>{const{isMatch:g,score:p,indices:m}=k(t,e,u,{location:i+f,distance:s,threshold:r,findAllMatches:o,minMatchCharLength:c,includeMatches:n,ignoreLocation:h});g&&(d=!0),l+=p,g&&m&&(a=[...a,...m])}));let u={isMatch:d,score:d?l/this.chunks.length:1};return d&&n&&(u.indices=a),u}}const I=[];function S(t,e){for(let n=0,i=I.length;n<i;n+=1){let i=I[n];if(i.condition(t,e))return new i(t,e)}return new w(t,e)}function E(t,e){const n=t.matches;e.matches=[],o(n)&&n.forEach((t=>{if(!o(t.indices)||!t.indices.length)return;const{indices:n,value:i}=t;let s={indices:n,value:i};t.key&&(s.key=t.key.src),t.idx>-1&&(s.refIndex=t.idx),e.matches.push(s)}))}function F(t,e){e.score=t.score}class A{constructor(t,e={},n){if(this.options={...m,...e},this.options.useExtendedSearch)throw new Error("Extended search is not available");this._keyStore=new u(this.options.keys),this.setCollection(t,n)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof M))throw new Error("Incorrect 'index' type");this._myIndex=e||x(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){o(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=(()=>!1)){const e=[];for(let n=0,i=this._docs.length;n<i;n+=1){const s=this._docs[n];t(s,n)&&(this.removeAt(n),n-=1,i-=1,e.push(s))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:o,sortFn:c,ignoreFieldNorm:h}=this.options;let a=i(t)?i(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return function(t,{ignoreFieldNorm:e=m.ignoreFieldNorm}){t.forEach((t=>{let n=1;t.matches.forEach((({key:t,norm:i,score:s})=>{const r=t?t.weight:null;n*=Math.pow(0===s&&r?Number.EPSILON:s,(r||1)*(e?1:i))})),t.score=n}))}(a,{ignoreFieldNorm:h}),o&&a.sort(c),s(e)&&e>-1&&(a=a.slice(0,e)),function(t,e,{includeMatches:n=m.includeMatches,includeScore:i=m.includeScore}={}){const s=[];return n&&s.push(E),i&&s.push(F),t.map((t=>{const{idx:n}=t,i={item:e[n],refIndex:n};return s.length&&s.forEach((e=>{e(t,i)})),i}))}(a,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(t){const e=S(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach((({v:t,i:n,n:s})=>{if(!o(t))return;const{isMatch:r,score:c,indices:h}=e.searchIn(t);r&&i.push({item:t,idx:n,matches:[{score:c,value:t,norm:s,indices:h}]})})),i}_searchLogical(t){throw new Error("Logical search is not available")}_searchObjectList(t){const e=S(t,this.options),{keys:n,records:i}=this._myIndex,s=[];return i.forEach((({$:t,i:i})=>{if(!o(t))return;let r=[];n.forEach(((n,i)=>{r.push(...this._findMatches({key:n,value:t[i],searcher:e}))})),r.length&&s.push({idx:i,item:t,matches:r})})),s}_findMatches({key:e,value:n,searcher:i}){if(!o(n))return[];let s=[];if(t(n))n.forEach((({v:t,i:n,n:r})=>{if(!o(t))return;const{isMatch:c,score:h,indices:a}=i.searchIn(t);c&&s.push({score:h,key:e,value:t,idx:n,norm:r,indices:a})}));else{const{v:t,n:r}=n,{isMatch:o,score:c,indices:h}=i.searchIn(t);o&&s.push({score:c,key:e,value:t,norm:r,indices:h})}return s}}A.version="7.0.0",A.createIndex=x,A.parseIndex=function(t,{getFn:e=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const{keys:i,records:s}=t,r=new M({getFn:e,fieldNormWeight:n});return r.setKeys(i),r.setIndexRecords(s),r},A.config=m;export{A as default}; \ No newline at end of file
diff --git a/includes/node_modules/fuse.js/dist/fuse.basic.mjs b/includes/node_modules/fuse.js/dist/fuse.basic.mjs
new file mode 100644
index 0000000..4126591
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.basic.mjs
@@ -0,0 +1,1259 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+function isArray(value) {
+ return !Array.isArray
+ ? getTag(value) === '[object Array]'
+ : Array.isArray(value)
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
+const INFINITY = 1 / 0;
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value
+ }
+ let result = value + '';
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result
+}
+
+function toString(value) {
+ return value == null ? '' : baseToString(value)
+}
+
+function isString(value) {
+ return typeof value === 'string'
+}
+
+function isNumber(value) {
+ return typeof value === 'number'
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
+function isBoolean(value) {
+ return (
+ value === true ||
+ value === false ||
+ (isObjectLike(value) && getTag(value) == '[object Boolean]')
+ )
+}
+
+function isObject(value) {
+ return typeof value === 'object'
+}
+
+// Checks if `value` is object-like.
+function isObjectLike(value) {
+ return isObject(value) && value !== null
+}
+
+function isDefined(value) {
+ return value !== undefined && value !== null
+}
+
+function isBlank(value) {
+ return !value.trim().length
+}
+
+// Gets the `toStringTag` of `value`.
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
+function getTag(value) {
+ return value == null
+ ? value === undefined
+ ? '[object Undefined]'
+ : '[object Null]'
+ : Object.prototype.toString.call(value)
+}
+
+const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
+
+const LOGICAL_SEARCH_UNAVAILABLE = 'Logical search is not available';
+
+const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
+
+const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
+ `Invalid value for key ${key}`;
+
+const PATTERN_LENGTH_TOO_LARGE = (max) =>
+ `Pattern length exceeds max of ${max}.`;
+
+const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
+
+const INVALID_KEY_WEIGHT_VALUE = (key) =>
+ `Property 'weight' in key '${key}' must be a positive integer`;
+
+const hasOwn = Object.prototype.hasOwnProperty;
+
+class KeyStore {
+ constructor(keys) {
+ this._keys = [];
+ this._keyMap = {};
+
+ let totalWeight = 0;
+
+ keys.forEach((key) => {
+ let obj = createKey(key);
+
+ this._keys.push(obj);
+ this._keyMap[obj.id] = obj;
+
+ totalWeight += obj.weight;
+ });
+
+ // Normalize weights so that their sum is equal to 1
+ this._keys.forEach((key) => {
+ key.weight /= totalWeight;
+ });
+ }
+ get(keyId) {
+ return this._keyMap[keyId]
+ }
+ keys() {
+ return this._keys
+ }
+ toJSON() {
+ return JSON.stringify(this._keys)
+ }
+}
+
+function createKey(key) {
+ let path = null;
+ let id = null;
+ let src = null;
+ let weight = 1;
+ let getFn = null;
+
+ if (isString(key) || isArray(key)) {
+ src = key;
+ path = createKeyPath(key);
+ id = createKeyId(key);
+ } else {
+ if (!hasOwn.call(key, 'name')) {
+ throw new Error(MISSING_KEY_PROPERTY('name'))
+ }
+
+ const name = key.name;
+ src = name;
+
+ if (hasOwn.call(key, 'weight')) {
+ weight = key.weight;
+
+ if (weight <= 0) {
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
+ }
+ }
+
+ path = createKeyPath(name);
+ id = createKeyId(name);
+ getFn = key.getFn;
+ }
+
+ return { path, id, weight, src, getFn }
+}
+
+function createKeyPath(key) {
+ return isArray(key) ? key : key.split('.')
+}
+
+function createKeyId(key) {
+ return isArray(key) ? key.join('.') : key
+}
+
+function get(obj, path) {
+ let list = [];
+ let arr = false;
+
+ const deepGet = (obj, path, index) => {
+ if (!isDefined(obj)) {
+ return
+ }
+ if (!path[index]) {
+ // If there's no path left, we've arrived at the object we care about.
+ list.push(obj);
+ } else {
+ let key = path[index];
+
+ const value = obj[key];
+
+ if (!isDefined(value)) {
+ return
+ }
+
+ // If we're at the last value in the path, and if it's a string/number/bool,
+ // add it to the list
+ if (
+ index === path.length - 1 &&
+ (isString(value) || isNumber(value) || isBoolean(value))
+ ) {
+ list.push(toString(value));
+ } else if (isArray(value)) {
+ arr = true;
+ // Search each item in the array.
+ for (let i = 0, len = value.length; i < len; i += 1) {
+ deepGet(value[i], path, index + 1);
+ }
+ } else if (path.length) {
+ // An object. Recurse further.
+ deepGet(value, path, index + 1);
+ }
+ }
+ };
+
+ // Backwards compatibility (since path used to be a string)
+ deepGet(obj, isString(path) ? path.split('.') : path, 0);
+
+ return arr ? list : list[0]
+}
+
+const MatchOptions = {
+ // Whether the matches should be included in the result set. When `true`, each record in the result
+ // set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
+ includeMatches: false,
+ // When `true`, the matching function will continue to the end of a search pattern even if
+ // a perfect match has already been located in the string.
+ findAllMatches: false,
+ // Minimum number of characters that must be matched before a result is considered a match
+ minMatchCharLength: 1
+};
+
+const BasicOptions = {
+ // When `true`, the algorithm continues searching to the end of the input even if a perfect
+ // match is found before the end of the same input.
+ isCaseSensitive: false,
+ // When true, the matching function will continue to the end of a search pattern even if
+ includeScore: false,
+ // List of properties that will be searched. This also supports nested properties.
+ keys: [],
+ // Whether to sort the result list, by score
+ shouldSort: true,
+ // Default sort function: sort by ascending score, ascending index
+ sortFn: (a, b) =>
+ a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
+};
+
+const FuzzyOptions = {
+ // Approximately where in the text is the pattern expected to be found?
+ location: 0,
+ // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
+ // (of both letters and location), a threshold of '1.0' would match anything.
+ threshold: 0.6,
+ // Determines how close the match must be to the fuzzy location (specified above).
+ // An exact letter match which is 'distance' characters away from the fuzzy location
+ // would score as a complete mismatch. A distance of '0' requires the match be at
+ // the exact location specified, a threshold of '1000' would require a perfect match
+ // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
+ distance: 100
+};
+
+const AdvancedOptions = {
+ // When `true`, it enables the use of unix-like search commands
+ useExtendedSearch: false,
+ // The get function to use when fetching an object's properties.
+ // The default will search nested paths *ie foo.bar.baz*
+ getFn: get,
+ // When `true`, search will ignore `location` and `distance`, so it won't matter
+ // where in the string the pattern appears.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
+ ignoreLocation: false,
+ // When `true`, the calculation for the relevance score (used for sorting) will
+ // ignore the field-length norm.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
+ ignoreFieldNorm: false,
+ // The weight to determine how much field length norm effects scoring.
+ fieldNormWeight: 1
+};
+
+var Config = {
+ ...BasicOptions,
+ ...MatchOptions,
+ ...FuzzyOptions,
+ ...AdvancedOptions
+};
+
+const SPACE = /[^ ]+/g;
+
+// Field-length norm: the shorter the field, the higher the weight.
+// Set to 3 decimals to reduce index size.
+function norm(weight = 1, mantissa = 3) {
+ const cache = new Map();
+ const m = Math.pow(10, mantissa);
+
+ return {
+ get(value) {
+ const numTokens = value.match(SPACE).length;
+
+ if (cache.has(numTokens)) {
+ return cache.get(numTokens)
+ }
+
+ // Default function is 1/sqrt(x), weight makes that variable
+ const norm = 1 / Math.pow(numTokens, 0.5 * weight);
+
+ // In place of `toFixed(mantissa)`, for faster computation
+ const n = parseFloat(Math.round(norm * m) / m);
+
+ cache.set(numTokens, n);
+
+ return n
+ },
+ clear() {
+ cache.clear();
+ }
+ }
+}
+
+class FuseIndex {
+ constructor({
+ getFn = Config.getFn,
+ fieldNormWeight = Config.fieldNormWeight
+ } = {}) {
+ this.norm = norm(fieldNormWeight, 3);
+ this.getFn = getFn;
+ this.isCreated = false;
+
+ this.setIndexRecords();
+ }
+ setSources(docs = []) {
+ this.docs = docs;
+ }
+ setIndexRecords(records = []) {
+ this.records = records;
+ }
+ setKeys(keys = []) {
+ this.keys = keys;
+ this._keysMap = {};
+ keys.forEach((key, idx) => {
+ this._keysMap[key.id] = idx;
+ });
+ }
+ create() {
+ if (this.isCreated || !this.docs.length) {
+ return
+ }
+
+ this.isCreated = true;
+
+ // List is Array<String>
+ if (isString(this.docs[0])) {
+ this.docs.forEach((doc, docIndex) => {
+ this._addString(doc, docIndex);
+ });
+ } else {
+ // List is Array<Object>
+ this.docs.forEach((doc, docIndex) => {
+ this._addObject(doc, docIndex);
+ });
+ }
+
+ this.norm.clear();
+ }
+ // Adds a doc to the end of the index
+ add(doc) {
+ const idx = this.size();
+
+ if (isString(doc)) {
+ this._addString(doc, idx);
+ } else {
+ this._addObject(doc, idx);
+ }
+ }
+ // Removes the doc at the specified index of the index
+ removeAt(idx) {
+ this.records.splice(idx, 1);
+
+ // Change ref index of every subsquent doc
+ for (let i = idx, len = this.size(); i < len; i += 1) {
+ this.records[i].i -= 1;
+ }
+ }
+ getValueForItemAtKeyId(item, keyId) {
+ return item[this._keysMap[keyId]]
+ }
+ size() {
+ return this.records.length
+ }
+ _addString(doc, docIndex) {
+ if (!isDefined(doc) || isBlank(doc)) {
+ return
+ }
+
+ let record = {
+ v: doc,
+ i: docIndex,
+ n: this.norm.get(doc)
+ };
+
+ this.records.push(record);
+ }
+ _addObject(doc, docIndex) {
+ let record = { i: docIndex, $: {} };
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ this.keys.forEach((key, keyIndex) => {
+ let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
+
+ if (!isDefined(value)) {
+ return
+ }
+
+ if (isArray(value)) {
+ let subRecords = [];
+ const stack = [{ nestedArrIndex: -1, value }];
+
+ while (stack.length) {
+ const { nestedArrIndex, value } = stack.pop();
+
+ if (!isDefined(value)) {
+ continue
+ }
+
+ if (isString(value) && !isBlank(value)) {
+ let subRecord = {
+ v: value,
+ i: nestedArrIndex,
+ n: this.norm.get(value)
+ };
+
+ subRecords.push(subRecord);
+ } else if (isArray(value)) {
+ value.forEach((item, k) => {
+ stack.push({
+ nestedArrIndex: k,
+ value: item
+ });
+ });
+ } else ;
+ }
+ record.$[keyIndex] = subRecords;
+ } else if (isString(value) && !isBlank(value)) {
+ let subRecord = {
+ v: value,
+ n: this.norm.get(value)
+ };
+
+ record.$[keyIndex] = subRecord;
+ }
+ });
+
+ this.records.push(record);
+ }
+ toJSON() {
+ return {
+ keys: this.keys,
+ records: this.records
+ }
+ }
+}
+
+function createIndex(
+ keys,
+ docs,
+ { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
+) {
+ const myIndex = new FuseIndex({ getFn, fieldNormWeight });
+ myIndex.setKeys(keys.map(createKey));
+ myIndex.setSources(docs);
+ myIndex.create();
+ return myIndex
+}
+
+function parseIndex(
+ data,
+ { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
+) {
+ const { keys, records } = data;
+ const myIndex = new FuseIndex({ getFn, fieldNormWeight });
+ myIndex.setKeys(keys);
+ myIndex.setIndexRecords(records);
+ return myIndex
+}
+
+function computeScore$1(
+ pattern,
+ {
+ errors = 0,
+ currentLocation = 0,
+ expectedLocation = 0,
+ distance = Config.distance,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+) {
+ const accuracy = errors / pattern.length;
+
+ if (ignoreLocation) {
+ return accuracy
+ }
+
+ const proximity = Math.abs(expectedLocation - currentLocation);
+
+ if (!distance) {
+ // Dodge divide by zero error.
+ return proximity ? 1.0 : accuracy
+ }
+
+ return accuracy + proximity / distance
+}
+
+function convertMaskToIndices(
+ matchmask = [],
+ minMatchCharLength = Config.minMatchCharLength
+) {
+ let indices = [];
+ let start = -1;
+ let end = -1;
+ let i = 0;
+
+ for (let len = matchmask.length; i < len; i += 1) {
+ let match = matchmask[i];
+ if (match && start === -1) {
+ start = i;
+ } else if (!match && start !== -1) {
+ end = i - 1;
+ if (end - start + 1 >= minMatchCharLength) {
+ indices.push([start, end]);
+ }
+ start = -1;
+ }
+ }
+
+ // (i-1 - start) + 1 => i - start
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
+ indices.push([start, i - 1]);
+ }
+
+ return indices
+}
+
+// Machine word size
+const MAX_BITS = 32;
+
+function search(
+ text,
+ pattern,
+ patternAlphabet,
+ {
+ location = Config.location,
+ distance = Config.distance,
+ threshold = Config.threshold,
+ findAllMatches = Config.findAllMatches,
+ minMatchCharLength = Config.minMatchCharLength,
+ includeMatches = Config.includeMatches,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+) {
+ if (pattern.length > MAX_BITS) {
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
+ }
+
+ const patternLen = pattern.length;
+ // Set starting location at beginning text and initialize the alphabet.
+ const textLen = text.length;
+ // Handle the case when location > text.length
+ const expectedLocation = Math.max(0, Math.min(location, textLen));
+ // Highest score beyond which we give up.
+ let currentThreshold = threshold;
+ // Is there a nearby exact match? (speedup)
+ let bestLocation = expectedLocation;
+
+ // Performance: only computer matches when the minMatchCharLength > 1
+ // OR if `includeMatches` is true.
+ const computeMatches = minMatchCharLength > 1 || includeMatches;
+ // A mask of the matches, used for building the indices
+ const matchMask = computeMatches ? Array(textLen) : [];
+
+ let index;
+
+ // Get all exact matches, here for speed up
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
+ let score = computeScore$1(pattern, {
+ currentLocation: index,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ currentThreshold = Math.min(score, currentThreshold);
+ bestLocation = index + patternLen;
+
+ if (computeMatches) {
+ let i = 0;
+ while (i < patternLen) {
+ matchMask[index + i] = 1;
+ i += 1;
+ }
+ }
+ }
+
+ // Reset the best location
+ bestLocation = -1;
+
+ let lastBitArr = [];
+ let finalScore = 1;
+ let binMax = patternLen + textLen;
+
+ const mask = 1 << (patternLen - 1);
+
+ for (let i = 0; i < patternLen; i += 1) {
+ // Scan for the best match; each iteration allows for one more error.
+ // Run a binary search to determine how far from the match location we can stray
+ // at this error level.
+ let binMin = 0;
+ let binMid = binMax;
+
+ while (binMin < binMid) {
+ const score = computeScore$1(pattern, {
+ errors: i,
+ currentLocation: expectedLocation + binMid,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ if (score <= currentThreshold) {
+ binMin = binMid;
+ } else {
+ binMax = binMid;
+ }
+
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
+ }
+
+ // Use the result from this iteration as the maximum for the next.
+ binMax = binMid;
+
+ let start = Math.max(1, expectedLocation - binMid + 1);
+ let finish = findAllMatches
+ ? textLen
+ : Math.min(expectedLocation + binMid, textLen) + patternLen;
+
+ // Initialize the bit array
+ let bitArr = Array(finish + 2);
+
+ bitArr[finish + 1] = (1 << i) - 1;
+
+ for (let j = finish; j >= start; j -= 1) {
+ let currentLocation = j - 1;
+ let charMatch = patternAlphabet[text.charAt(currentLocation)];
+
+ if (computeMatches) {
+ // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
+ matchMask[currentLocation] = +!!charMatch;
+ }
+
+ // First pass: exact match
+ bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
+
+ // Subsequent passes: fuzzy match
+ if (i) {
+ bitArr[j] |=
+ ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
+ }
+
+ if (bitArr[j] & mask) {
+ finalScore = computeScore$1(pattern, {
+ errors: i,
+ currentLocation,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ // This match will almost certainly be better than any existing match.
+ // But check anyway.
+ if (finalScore <= currentThreshold) {
+ // Indeed it is
+ currentThreshold = finalScore;
+ bestLocation = currentLocation;
+
+ // Already passed `loc`, downhill from here on in.
+ if (bestLocation <= expectedLocation) {
+ break
+ }
+
+ // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
+ }
+ }
+ }
+
+ // No hope for a (better) match at greater error levels.
+ const score = computeScore$1(pattern, {
+ errors: i + 1,
+ currentLocation: expectedLocation,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ if (score > currentThreshold) {
+ break
+ }
+
+ lastBitArr = bitArr;
+ }
+
+ const result = {
+ isMatch: bestLocation >= 0,
+ // Count exact matches (those with a score of 0) to be "almost" exact
+ score: Math.max(0.001, finalScore)
+ };
+
+ if (computeMatches) {
+ const indices = convertMaskToIndices(matchMask, minMatchCharLength);
+ if (!indices.length) {
+ result.isMatch = false;
+ } else if (includeMatches) {
+ result.indices = indices;
+ }
+ }
+
+ return result
+}
+
+function createPatternAlphabet(pattern) {
+ let mask = {};
+
+ for (let i = 0, len = pattern.length; i < len; i += 1) {
+ const char = pattern.charAt(i);
+ mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
+ }
+
+ return mask
+}
+
+class BitapSearch {
+ constructor(
+ pattern,
+ {
+ location = Config.location,
+ threshold = Config.threshold,
+ distance = Config.distance,
+ includeMatches = Config.includeMatches,
+ findAllMatches = Config.findAllMatches,
+ minMatchCharLength = Config.minMatchCharLength,
+ isCaseSensitive = Config.isCaseSensitive,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+ ) {
+ this.options = {
+ location,
+ threshold,
+ distance,
+ includeMatches,
+ findAllMatches,
+ minMatchCharLength,
+ isCaseSensitive,
+ ignoreLocation
+ };
+
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+
+ this.chunks = [];
+
+ if (!this.pattern.length) {
+ return
+ }
+
+ const addChunk = (pattern, startIndex) => {
+ this.chunks.push({
+ pattern,
+ alphabet: createPatternAlphabet(pattern),
+ startIndex
+ });
+ };
+
+ const len = this.pattern.length;
+
+ if (len > MAX_BITS) {
+ let i = 0;
+ const remainder = len % MAX_BITS;
+ const end = len - remainder;
+
+ while (i < end) {
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
+ i += MAX_BITS;
+ }
+
+ if (remainder) {
+ const startIndex = len - MAX_BITS;
+ addChunk(this.pattern.substr(startIndex), startIndex);
+ }
+ } else {
+ addChunk(this.pattern, 0);
+ }
+ }
+
+ searchIn(text) {
+ const { isCaseSensitive, includeMatches } = this.options;
+
+ if (!isCaseSensitive) {
+ text = text.toLowerCase();
+ }
+
+ // Exact match
+ if (this.pattern === text) {
+ let result = {
+ isMatch: true,
+ score: 0
+ };
+
+ if (includeMatches) {
+ result.indices = [[0, text.length - 1]];
+ }
+
+ return result
+ }
+
+ // Otherwise, use Bitap algorithm
+ const {
+ location,
+ distance,
+ threshold,
+ findAllMatches,
+ minMatchCharLength,
+ ignoreLocation
+ } = this.options;
+
+ let allIndices = [];
+ let totalScore = 0;
+ let hasMatches = false;
+
+ this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
+ const { isMatch, score, indices } = search(text, pattern, alphabet, {
+ location: location + startIndex,
+ distance,
+ threshold,
+ findAllMatches,
+ minMatchCharLength,
+ includeMatches,
+ ignoreLocation
+ });
+
+ if (isMatch) {
+ hasMatches = true;
+ }
+
+ totalScore += score;
+
+ if (isMatch && indices) {
+ allIndices = [...allIndices, ...indices];
+ }
+ });
+
+ let result = {
+ isMatch: hasMatches,
+ score: hasMatches ? totalScore / this.chunks.length : 1
+ };
+
+ if (hasMatches && includeMatches) {
+ result.indices = allIndices;
+ }
+
+ return result
+ }
+}
+
+const registeredSearchers = [];
+
+function createSearcher(pattern, options) {
+ for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
+ let searcherClass = registeredSearchers[i];
+ if (searcherClass.condition(pattern, options)) {
+ return new searcherClass(pattern, options)
+ }
+ }
+
+ return new BitapSearch(pattern, options)
+}
+
+const LogicalOperator = {
+ AND: '$and',
+ OR: '$or'
+};
+
+const KeyType = {
+ PATH: '$path',
+ PATTERN: '$val'
+};
+
+const isExpression = (query) =>
+ !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
+
+const isPath = (query) => !!query[KeyType.PATH];
+
+const isLeaf = (query) =>
+ !isArray(query) && isObject(query) && !isExpression(query);
+
+const convertToExplicit = (query) => ({
+ [LogicalOperator.AND]: Object.keys(query).map((key) => ({
+ [key]: query[key]
+ }))
+});
+
+// When `auto` is `true`, the parse function will infer and initialize and add
+// the appropriate `Searcher` instance
+function parse(query, options, { auto = true } = {}) {
+ const next = (query) => {
+ let keys = Object.keys(query);
+
+ const isQueryPath = isPath(query);
+
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
+ return next(convertToExplicit(query))
+ }
+
+ if (isLeaf(query)) {
+ const key = isQueryPath ? query[KeyType.PATH] : keys[0];
+
+ const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
+
+ if (!isString(pattern)) {
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
+ }
+
+ const obj = {
+ keyId: createKeyId(key),
+ pattern
+ };
+
+ if (auto) {
+ obj.searcher = createSearcher(pattern, options);
+ }
+
+ return obj
+ }
+
+ let node = {
+ children: [],
+ operator: keys[0]
+ };
+
+ keys.forEach((key) => {
+ const value = query[key];
+
+ if (isArray(value)) {
+ value.forEach((item) => {
+ node.children.push(next(item));
+ });
+ }
+ });
+
+ return node
+ };
+
+ if (!isExpression(query)) {
+ query = convertToExplicit(query);
+ }
+
+ return next(query)
+}
+
+// Practical scoring function
+function computeScore(
+ results,
+ { ignoreFieldNorm = Config.ignoreFieldNorm }
+) {
+ results.forEach((result) => {
+ let totalScore = 1;
+
+ result.matches.forEach(({ key, norm, score }) => {
+ const weight = key ? key.weight : null;
+
+ totalScore *= Math.pow(
+ score === 0 && weight ? Number.EPSILON : score,
+ (weight || 1) * (ignoreFieldNorm ? 1 : norm)
+ );
+ });
+
+ result.score = totalScore;
+ });
+}
+
+function transformMatches(result, data) {
+ const matches = result.matches;
+ data.matches = [];
+
+ if (!isDefined(matches)) {
+ return
+ }
+
+ matches.forEach((match) => {
+ if (!isDefined(match.indices) || !match.indices.length) {
+ return
+ }
+
+ const { indices, value } = match;
+
+ let obj = {
+ indices,
+ value
+ };
+
+ if (match.key) {
+ obj.key = match.key.src;
+ }
+
+ if (match.idx > -1) {
+ obj.refIndex = match.idx;
+ }
+
+ data.matches.push(obj);
+ });
+}
+
+function transformScore(result, data) {
+ data.score = result.score;
+}
+
+function format(
+ results,
+ docs,
+ {
+ includeMatches = Config.includeMatches,
+ includeScore = Config.includeScore
+ } = {}
+) {
+ const transformers = [];
+
+ if (includeMatches) transformers.push(transformMatches);
+ if (includeScore) transformers.push(transformScore);
+
+ return results.map((result) => {
+ const { idx } = result;
+
+ const data = {
+ item: docs[idx],
+ refIndex: idx
+ };
+
+ if (transformers.length) {
+ transformers.forEach((transformer) => {
+ transformer(result, data);
+ });
+ }
+
+ return data
+ })
+}
+
+class Fuse {
+ constructor(docs, options = {}, index) {
+ this.options = { ...Config, ...options };
+
+ if (
+ this.options.useExtendedSearch &&
+ !false
+ ) {
+ throw new Error(EXTENDED_SEARCH_UNAVAILABLE)
+ }
+
+ this._keyStore = new KeyStore(this.options.keys);
+
+ this.setCollection(docs, index);
+ }
+
+ setCollection(docs, index) {
+ this._docs = docs;
+
+ if (index && !(index instanceof FuseIndex)) {
+ throw new Error(INCORRECT_INDEX_TYPE)
+ }
+
+ this._myIndex =
+ index ||
+ createIndex(this.options.keys, this._docs, {
+ getFn: this.options.getFn,
+ fieldNormWeight: this.options.fieldNormWeight
+ });
+ }
+
+ add(doc) {
+ if (!isDefined(doc)) {
+ return
+ }
+
+ this._docs.push(doc);
+ this._myIndex.add(doc);
+ }
+
+ remove(predicate = (/* doc, idx */) => false) {
+ const results = [];
+
+ for (let i = 0, len = this._docs.length; i < len; i += 1) {
+ const doc = this._docs[i];
+ if (predicate(doc, i)) {
+ this.removeAt(i);
+ i -= 1;
+ len -= 1;
+
+ results.push(doc);
+ }
+ }
+
+ return results
+ }
+
+ removeAt(idx) {
+ this._docs.splice(idx, 1);
+ this._myIndex.removeAt(idx);
+ }
+
+ getIndex() {
+ return this._myIndex
+ }
+
+ search(query, { limit = -1 } = {}) {
+ const {
+ includeMatches,
+ includeScore,
+ shouldSort,
+ sortFn,
+ ignoreFieldNorm
+ } = this.options;
+
+ let results = isString(query)
+ ? isString(this._docs[0])
+ ? this._searchStringList(query)
+ : this._searchObjectList(query)
+ : this._searchLogical(query);
+
+ computeScore(results, { ignoreFieldNorm });
+
+ if (shouldSort) {
+ results.sort(sortFn);
+ }
+
+ if (isNumber(limit) && limit > -1) {
+ results = results.slice(0, limit);
+ }
+
+ return format(results, this._docs, {
+ includeMatches,
+ includeScore
+ })
+ }
+
+ _searchStringList(query) {
+ const searcher = createSearcher(query, this.options);
+ const { records } = this._myIndex;
+ const results = [];
+
+ // Iterate over every string in the index
+ records.forEach(({ v: text, i: idx, n: norm }) => {
+ if (!isDefined(text)) {
+ return
+ }
+
+ const { isMatch, score, indices } = searcher.searchIn(text);
+
+ if (isMatch) {
+ results.push({
+ item: text,
+ idx,
+ matches: [{ score, value: text, norm, indices }]
+ });
+ }
+ });
+
+ return results
+ }
+
+ _searchLogical(query) {
+ {
+ throw new Error(LOGICAL_SEARCH_UNAVAILABLE)
+ }
+ }
+
+ _searchObjectList(query) {
+ const searcher = createSearcher(query, this.options);
+ const { keys, records } = this._myIndex;
+ const results = [];
+
+ // List is Array<Object>
+ records.forEach(({ $: item, i: idx }) => {
+ if (!isDefined(item)) {
+ return
+ }
+
+ let matches = [];
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ keys.forEach((key, keyIndex) => {
+ matches.push(
+ ...this._findMatches({
+ key,
+ value: item[keyIndex],
+ searcher
+ })
+ );
+ });
+
+ if (matches.length) {
+ results.push({
+ idx,
+ item,
+ matches
+ });
+ }
+ });
+
+ return results
+ }
+ _findMatches({ key, value, searcher }) {
+ if (!isDefined(value)) {
+ return []
+ }
+
+ let matches = [];
+
+ if (isArray(value)) {
+ value.forEach(({ v: text, i: idx, n: norm }) => {
+ if (!isDefined(text)) {
+ return
+ }
+
+ const { isMatch, score, indices } = searcher.searchIn(text);
+
+ if (isMatch) {
+ matches.push({
+ score,
+ key,
+ value: text,
+ idx,
+ norm,
+ indices
+ });
+ }
+ });
+ } else {
+ const { v: text, n: norm } = value;
+
+ const { isMatch, score, indices } = searcher.searchIn(text);
+
+ if (isMatch) {
+ matches.push({ score, key, value: text, norm, indices });
+ }
+ }
+
+ return matches
+ }
+}
+
+Fuse.version = '7.0.0';
+Fuse.createIndex = createIndex;
+Fuse.parseIndex = parseIndex;
+Fuse.config = Config;
+
+{
+ Fuse.parseQuery = parse;
+}
+
+export { Fuse as default };
diff --git a/includes/node_modules/fuse.js/dist/fuse.cjs b/includes/node_modules/fuse.js/dist/fuse.cjs
new file mode 100644
index 0000000..e288aa6
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.cjs
@@ -0,0 +1,2004 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+'use strict';
+
+function ownKeys(object, enumerableOnly) {
+ var keys = Object.keys(object);
+ if (Object.getOwnPropertySymbols) {
+ var symbols = Object.getOwnPropertySymbols(object);
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
+ })), keys.push.apply(keys, symbols);
+ }
+ return keys;
+}
+function _objectSpread2(target) {
+ for (var i = 1; i < arguments.length; i++) {
+ var source = null != arguments[i] ? arguments[i] : {};
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
+ _defineProperty(target, key, source[key]);
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
+ });
+ }
+ return target;
+}
+function _typeof(obj) {
+ "@babel/helpers - typeof";
+
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
+ return typeof obj;
+ } : function (obj) {
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
+ }, _typeof(obj);
+}
+function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+}
+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, _toPropertyKey(descriptor.key), descriptor);
+ }
+}
+function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ Object.defineProperty(Constructor, "prototype", {
+ writable: false
+ });
+ return Constructor;
+}
+function _defineProperty(obj, key, value) {
+ key = _toPropertyKey(key);
+ if (key in obj) {
+ Object.defineProperty(obj, key, {
+ value: value,
+ enumerable: true,
+ configurable: true,
+ writable: true
+ });
+ } else {
+ obj[key] = value;
+ }
+ return obj;
+}
+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
+ }
+ });
+ Object.defineProperty(subClass, "prototype", {
+ writable: false
+ });
+ if (superClass) _setPrototypeOf(subClass, superClass);
+}
+function _getPrototypeOf(o) {
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
+ return o.__proto__ || Object.getPrototypeOf(o);
+ };
+ return _getPrototypeOf(o);
+}
+function _setPrototypeOf(o, p) {
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
+ o.__proto__ = p;
+ return o;
+ };
+ return _setPrototypeOf(o, p);
+}
+function _isNativeReflectConstruct() {
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
+ if (Reflect.construct.sham) return false;
+ if (typeof Proxy === "function") return true;
+ try {
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+function _assertThisInitialized(self) {
+ if (self === void 0) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
+ return self;
+}
+function _possibleConstructorReturn(self, call) {
+ if (call && (typeof call === "object" || typeof call === "function")) {
+ return call;
+ } else if (call !== void 0) {
+ throw new TypeError("Derived constructors may only return object or undefined");
+ }
+ return _assertThisInitialized(self);
+}
+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);
+ };
+}
+function _toConsumableArray(arr) {
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
+}
+function _arrayWithoutHoles(arr) {
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+}
+function _iterableToArray(iter) {
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
+}
+function _unsupportedIterableToArray(o, minLen) {
+ if (!o) return;
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+ var n = Object.prototype.toString.call(o).slice(8, -1);
+ if (n === "Object" && o.constructor) n = o.constructor.name;
+ if (n === "Map" || n === "Set") return Array.from(o);
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
+}
+function _arrayLikeToArray(arr, len) {
+ if (len == null || len > arr.length) len = arr.length;
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+ return arr2;
+}
+function _nonIterableSpread() {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+}
+function _toPrimitive(input, hint) {
+ if (typeof input !== "object" || input === null) return input;
+ var prim = input[Symbol.toPrimitive];
+ if (prim !== undefined) {
+ var res = prim.call(input, hint || "default");
+ if (typeof res !== "object") return res;
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return (hint === "string" ? String : Number)(input);
+}
+function _toPropertyKey(arg) {
+ var key = _toPrimitive(arg, "string");
+ return typeof key === "symbol" ? key : String(key);
+}
+
+function isArray(value) {
+ return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value);
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
+var INFINITY = 1 / 0;
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ var result = value + '';
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result;
+}
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+function isString(value) {
+ return typeof value === 'string';
+}
+function isNumber(value) {
+ return typeof value === 'number';
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
+function isBoolean(value) {
+ return value === true || value === false || isObjectLike(value) && getTag(value) == '[object Boolean]';
+}
+function isObject(value) {
+ return _typeof(value) === 'object';
+}
+
+// Checks if `value` is object-like.
+function isObjectLike(value) {
+ return isObject(value) && value !== null;
+}
+function isDefined(value) {
+ return value !== undefined && value !== null;
+}
+function isBlank(value) {
+ return !value.trim().length;
+}
+
+// Gets the `toStringTag` of `value`.
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
+function getTag(value) {
+ return value == null ? value === undefined ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(value);
+}
+
+var EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
+var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
+var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = function LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key) {
+ return "Invalid value for key ".concat(key);
+};
+var PATTERN_LENGTH_TOO_LARGE = function PATTERN_LENGTH_TOO_LARGE(max) {
+ return "Pattern length exceeds max of ".concat(max, ".");
+};
+var MISSING_KEY_PROPERTY = function MISSING_KEY_PROPERTY(name) {
+ return "Missing ".concat(name, " property in key");
+};
+var INVALID_KEY_WEIGHT_VALUE = function INVALID_KEY_WEIGHT_VALUE(key) {
+ return "Property 'weight' in key '".concat(key, "' must be a positive integer");
+};
+
+var hasOwn = Object.prototype.hasOwnProperty;
+var KeyStore = /*#__PURE__*/function () {
+ function KeyStore(keys) {
+ var _this = this;
+ _classCallCheck(this, KeyStore);
+ this._keys = [];
+ this._keyMap = {};
+ var totalWeight = 0;
+ keys.forEach(function (key) {
+ var obj = createKey(key);
+ _this._keys.push(obj);
+ _this._keyMap[obj.id] = obj;
+ totalWeight += obj.weight;
+ });
+
+ // Normalize weights so that their sum is equal to 1
+ this._keys.forEach(function (key) {
+ key.weight /= totalWeight;
+ });
+ }
+ _createClass(KeyStore, [{
+ key: "get",
+ value: function get(keyId) {
+ return this._keyMap[keyId];
+ }
+ }, {
+ key: "keys",
+ value: function keys() {
+ return this._keys;
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return JSON.stringify(this._keys);
+ }
+ }]);
+ return KeyStore;
+}();
+function createKey(key) {
+ var path = null;
+ var id = null;
+ var src = null;
+ var weight = 1;
+ var getFn = null;
+ if (isString(key) || isArray(key)) {
+ src = key;
+ path = createKeyPath(key);
+ id = createKeyId(key);
+ } else {
+ if (!hasOwn.call(key, 'name')) {
+ throw new Error(MISSING_KEY_PROPERTY('name'));
+ }
+ var name = key.name;
+ src = name;
+ if (hasOwn.call(key, 'weight')) {
+ weight = key.weight;
+ if (weight <= 0) {
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
+ }
+ }
+ path = createKeyPath(name);
+ id = createKeyId(name);
+ getFn = key.getFn;
+ }
+ return {
+ path: path,
+ id: id,
+ weight: weight,
+ src: src,
+ getFn: getFn
+ };
+}
+function createKeyPath(key) {
+ return isArray(key) ? key : key.split('.');
+}
+function createKeyId(key) {
+ return isArray(key) ? key.join('.') : key;
+}
+
+function get(obj, path) {
+ var list = [];
+ var arr = false;
+ var deepGet = function deepGet(obj, path, index) {
+ if (!isDefined(obj)) {
+ return;
+ }
+ if (!path[index]) {
+ // If there's no path left, we've arrived at the object we care about.
+ list.push(obj);
+ } else {
+ var key = path[index];
+ var value = obj[key];
+ if (!isDefined(value)) {
+ return;
+ }
+
+ // If we're at the last value in the path, and if it's a string/number/bool,
+ // add it to the list
+ if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
+ list.push(toString(value));
+ } else if (isArray(value)) {
+ arr = true;
+ // Search each item in the array.
+ for (var i = 0, len = value.length; i < len; i += 1) {
+ deepGet(value[i], path, index + 1);
+ }
+ } else if (path.length) {
+ // An object. Recurse further.
+ deepGet(value, path, index + 1);
+ }
+ }
+ };
+
+ // Backwards compatibility (since path used to be a string)
+ deepGet(obj, isString(path) ? path.split('.') : path, 0);
+ return arr ? list : list[0];
+}
+
+var MatchOptions = {
+ // Whether the matches should be included in the result set. When `true`, each record in the result
+ // set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
+ includeMatches: false,
+ // When `true`, the matching function will continue to the end of a search pattern even if
+ // a perfect match has already been located in the string.
+ findAllMatches: false,
+ // Minimum number of characters that must be matched before a result is considered a match
+ minMatchCharLength: 1
+};
+var BasicOptions = {
+ // When `true`, the algorithm continues searching to the end of the input even if a perfect
+ // match is found before the end of the same input.
+ isCaseSensitive: false,
+ // When true, the matching function will continue to the end of a search pattern even if
+ includeScore: false,
+ // List of properties that will be searched. This also supports nested properties.
+ keys: [],
+ // Whether to sort the result list, by score
+ shouldSort: true,
+ // Default sort function: sort by ascending score, ascending index
+ sortFn: function sortFn(a, b) {
+ return a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1;
+ }
+};
+var FuzzyOptions = {
+ // Approximately where in the text is the pattern expected to be found?
+ location: 0,
+ // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
+ // (of both letters and location), a threshold of '1.0' would match anything.
+ threshold: 0.6,
+ // Determines how close the match must be to the fuzzy location (specified above).
+ // An exact letter match which is 'distance' characters away from the fuzzy location
+ // would score as a complete mismatch. A distance of '0' requires the match be at
+ // the exact location specified, a threshold of '1000' would require a perfect match
+ // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
+ distance: 100
+};
+var AdvancedOptions = {
+ // When `true`, it enables the use of unix-like search commands
+ useExtendedSearch: false,
+ // The get function to use when fetching an object's properties.
+ // The default will search nested paths *ie foo.bar.baz*
+ getFn: get,
+ // When `true`, search will ignore `location` and `distance`, so it won't matter
+ // where in the string the pattern appears.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
+ ignoreLocation: false,
+ // When `true`, the calculation for the relevance score (used for sorting) will
+ // ignore the field-length norm.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
+ ignoreFieldNorm: false,
+ // The weight to determine how much field length norm effects scoring.
+ fieldNormWeight: 1
+};
+var Config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, BasicOptions), MatchOptions), FuzzyOptions), AdvancedOptions);
+
+var SPACE = /[^ ]+/g;
+
+// Field-length norm: the shorter the field, the higher the weight.
+// Set to 3 decimals to reduce index size.
+function norm() {
+ var weight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
+ var mantissa = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
+ var cache = new Map();
+ var m = Math.pow(10, mantissa);
+ return {
+ get: function get(value) {
+ var numTokens = value.match(SPACE).length;
+ if (cache.has(numTokens)) {
+ return cache.get(numTokens);
+ }
+
+ // Default function is 1/sqrt(x), weight makes that variable
+ var norm = 1 / Math.pow(numTokens, 0.5 * weight);
+
+ // In place of `toFixed(mantissa)`, for faster computation
+ var n = parseFloat(Math.round(norm * m) / m);
+ cache.set(numTokens, n);
+ return n;
+ },
+ clear: function clear() {
+ cache.clear();
+ }
+ };
+}
+
+var FuseIndex = /*#__PURE__*/function () {
+ function FuseIndex() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$getFn = _ref.getFn,
+ getFn = _ref$getFn === void 0 ? Config.getFn : _ref$getFn,
+ _ref$fieldNormWeight = _ref.fieldNormWeight,
+ fieldNormWeight = _ref$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref$fieldNormWeight;
+ _classCallCheck(this, FuseIndex);
+ this.norm = norm(fieldNormWeight, 3);
+ this.getFn = getFn;
+ this.isCreated = false;
+ this.setIndexRecords();
+ }
+ _createClass(FuseIndex, [{
+ key: "setSources",
+ value: function setSources() {
+ var docs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.docs = docs;
+ }
+ }, {
+ key: "setIndexRecords",
+ value: function setIndexRecords() {
+ var records = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.records = records;
+ }
+ }, {
+ key: "setKeys",
+ value: function setKeys() {
+ var _this = this;
+ var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.keys = keys;
+ this._keysMap = {};
+ keys.forEach(function (key, idx) {
+ _this._keysMap[key.id] = idx;
+ });
+ }
+ }, {
+ key: "create",
+ value: function create() {
+ var _this2 = this;
+ if (this.isCreated || !this.docs.length) {
+ return;
+ }
+ this.isCreated = true;
+
+ // List is Array<String>
+ if (isString(this.docs[0])) {
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addString(doc, docIndex);
+ });
+ } else {
+ // List is Array<Object>
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addObject(doc, docIndex);
+ });
+ }
+ this.norm.clear();
+ }
+ // Adds a doc to the end of the index
+ }, {
+ key: "add",
+ value: function add(doc) {
+ var idx = this.size();
+ if (isString(doc)) {
+ this._addString(doc, idx);
+ } else {
+ this._addObject(doc, idx);
+ }
+ }
+ // Removes the doc at the specified index of the index
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this.records.splice(idx, 1);
+
+ // Change ref index of every subsquent doc
+ for (var i = idx, len = this.size(); i < len; i += 1) {
+ this.records[i].i -= 1;
+ }
+ }
+ }, {
+ key: "getValueForItemAtKeyId",
+ value: function getValueForItemAtKeyId(item, keyId) {
+ return item[this._keysMap[keyId]];
+ }
+ }, {
+ key: "size",
+ value: function size() {
+ return this.records.length;
+ }
+ }, {
+ key: "_addString",
+ value: function _addString(doc, docIndex) {
+ if (!isDefined(doc) || isBlank(doc)) {
+ return;
+ }
+ var record = {
+ v: doc,
+ i: docIndex,
+ n: this.norm.get(doc)
+ };
+ this.records.push(record);
+ }
+ }, {
+ key: "_addObject",
+ value: function _addObject(doc, docIndex) {
+ var _this3 = this;
+ var record = {
+ i: docIndex,
+ $: {}
+ };
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ this.keys.forEach(function (key, keyIndex) {
+ var value = key.getFn ? key.getFn(doc) : _this3.getFn(doc, key.path);
+ if (!isDefined(value)) {
+ return;
+ }
+ if (isArray(value)) {
+ var subRecords = [];
+ var stack = [{
+ nestedArrIndex: -1,
+ value: value
+ }];
+ while (stack.length) {
+ var _stack$pop = stack.pop(),
+ nestedArrIndex = _stack$pop.nestedArrIndex,
+ _value = _stack$pop.value;
+ if (!isDefined(_value)) {
+ continue;
+ }
+ if (isString(_value) && !isBlank(_value)) {
+ var subRecord = {
+ v: _value,
+ i: nestedArrIndex,
+ n: _this3.norm.get(_value)
+ };
+ subRecords.push(subRecord);
+ } else if (isArray(_value)) {
+ _value.forEach(function (item, k) {
+ stack.push({
+ nestedArrIndex: k,
+ value: item
+ });
+ });
+ } else ;
+ }
+ record.$[keyIndex] = subRecords;
+ } else if (isString(value) && !isBlank(value)) {
+ var _subRecord = {
+ v: value,
+ n: _this3.norm.get(value)
+ };
+ record.$[keyIndex] = _subRecord;
+ }
+ });
+ this.records.push(record);
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return {
+ keys: this.keys,
+ records: this.records
+ };
+ }
+ }]);
+ return FuseIndex;
+}();
+function createIndex(keys, docs) {
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref2$getFn = _ref2.getFn,
+ getFn = _ref2$getFn === void 0 ? Config.getFn : _ref2$getFn,
+ _ref2$fieldNormWeight = _ref2.fieldNormWeight,
+ fieldNormWeight = _ref2$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref2$fieldNormWeight;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys.map(createKey));
+ myIndex.setSources(docs);
+ myIndex.create();
+ return myIndex;
+}
+function parseIndex(data) {
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref3$getFn = _ref3.getFn,
+ getFn = _ref3$getFn === void 0 ? Config.getFn : _ref3$getFn,
+ _ref3$fieldNormWeight = _ref3.fieldNormWeight,
+ fieldNormWeight = _ref3$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref3$fieldNormWeight;
+ var keys = data.keys,
+ records = data.records;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys);
+ myIndex.setIndexRecords(records);
+ return myIndex;
+}
+
+function computeScore$1(pattern) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$errors = _ref.errors,
+ errors = _ref$errors === void 0 ? 0 : _ref$errors,
+ _ref$currentLocation = _ref.currentLocation,
+ currentLocation = _ref$currentLocation === void 0 ? 0 : _ref$currentLocation,
+ _ref$expectedLocation = _ref.expectedLocation,
+ expectedLocation = _ref$expectedLocation === void 0 ? 0 : _ref$expectedLocation,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ var accuracy = errors / pattern.length;
+ if (ignoreLocation) {
+ return accuracy;
+ }
+ var proximity = Math.abs(expectedLocation - currentLocation);
+ if (!distance) {
+ // Dodge divide by zero error.
+ return proximity ? 1.0 : accuracy;
+ }
+ return accuracy + proximity / distance;
+}
+
+function convertMaskToIndices() {
+ var matchmask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ var minMatchCharLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Config.minMatchCharLength;
+ var indices = [];
+ var start = -1;
+ var end = -1;
+ var i = 0;
+ for (var len = matchmask.length; i < len; i += 1) {
+ var match = matchmask[i];
+ if (match && start === -1) {
+ start = i;
+ } else if (!match && start !== -1) {
+ end = i - 1;
+ if (end - start + 1 >= minMatchCharLength) {
+ indices.push([start, end]);
+ }
+ start = -1;
+ }
+ }
+
+ // (i-1 - start) + 1 => i - start
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
+ indices.push([start, i - 1]);
+ }
+ return indices;
+}
+
+// Machine word size
+var MAX_BITS = 32;
+
+function search(text, pattern, patternAlphabet) {
+ var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ if (pattern.length > MAX_BITS) {
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
+ }
+ var patternLen = pattern.length;
+ // Set starting location at beginning text and initialize the alphabet.
+ var textLen = text.length;
+ // Handle the case when location > text.length
+ var expectedLocation = Math.max(0, Math.min(location, textLen));
+ // Highest score beyond which we give up.
+ var currentThreshold = threshold;
+ // Is there a nearby exact match? (speedup)
+ var bestLocation = expectedLocation;
+
+ // Performance: only computer matches when the minMatchCharLength > 1
+ // OR if `includeMatches` is true.
+ var computeMatches = minMatchCharLength > 1 || includeMatches;
+ // A mask of the matches, used for building the indices
+ var matchMask = computeMatches ? Array(textLen) : [];
+ var index;
+
+ // Get all exact matches, here for speed up
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
+ var score = computeScore$1(pattern, {
+ currentLocation: index,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ currentThreshold = Math.min(score, currentThreshold);
+ bestLocation = index + patternLen;
+ if (computeMatches) {
+ var i = 0;
+ while (i < patternLen) {
+ matchMask[index + i] = 1;
+ i += 1;
+ }
+ }
+ }
+
+ // Reset the best location
+ bestLocation = -1;
+ var lastBitArr = [];
+ var finalScore = 1;
+ var binMax = patternLen + textLen;
+ var mask = 1 << patternLen - 1;
+ for (var _i = 0; _i < patternLen; _i += 1) {
+ // Scan for the best match; each iteration allows for one more error.
+ // Run a binary search to determine how far from the match location we can stray
+ // at this error level.
+ var binMin = 0;
+ var binMid = binMax;
+ while (binMin < binMid) {
+ var _score = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: expectedLocation + binMid,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score <= currentThreshold) {
+ binMin = binMid;
+ } else {
+ binMax = binMid;
+ }
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
+ }
+
+ // Use the result from this iteration as the maximum for the next.
+ binMax = binMid;
+ var start = Math.max(1, expectedLocation - binMid + 1);
+ var finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
+
+ // Initialize the bit array
+ var bitArr = Array(finish + 2);
+ bitArr[finish + 1] = (1 << _i) - 1;
+ for (var j = finish; j >= start; j -= 1) {
+ var currentLocation = j - 1;
+ var charMatch = patternAlphabet[text.charAt(currentLocation)];
+ if (computeMatches) {
+ // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
+ matchMask[currentLocation] = +!!charMatch;
+ }
+
+ // First pass: exact match
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
+
+ // Subsequent passes: fuzzy match
+ if (_i) {
+ bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
+ }
+ if (bitArr[j] & mask) {
+ finalScore = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: currentLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+
+ // This match will almost certainly be better than any existing match.
+ // But check anyway.
+ if (finalScore <= currentThreshold) {
+ // Indeed it is
+ currentThreshold = finalScore;
+ bestLocation = currentLocation;
+
+ // Already passed `loc`, downhill from here on in.
+ if (bestLocation <= expectedLocation) {
+ break;
+ }
+
+ // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
+ }
+ }
+ }
+
+ // No hope for a (better) match at greater error levels.
+ var _score2 = computeScore$1(pattern, {
+ errors: _i + 1,
+ currentLocation: expectedLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score2 > currentThreshold) {
+ break;
+ }
+ lastBitArr = bitArr;
+ }
+ var result = {
+ isMatch: bestLocation >= 0,
+ // Count exact matches (those with a score of 0) to be "almost" exact
+ score: Math.max(0.001, finalScore)
+ };
+ if (computeMatches) {
+ var indices = convertMaskToIndices(matchMask, minMatchCharLength);
+ if (!indices.length) {
+ result.isMatch = false;
+ } else if (includeMatches) {
+ result.indices = indices;
+ }
+ }
+ return result;
+}
+
+function createPatternAlphabet(pattern) {
+ var mask = {};
+ for (var i = 0, len = pattern.length; i < len; i += 1) {
+ var _char = pattern.charAt(i);
+ mask[_char] = (mask[_char] || 0) | 1 << len - i - 1;
+ }
+ return mask;
+}
+
+var BitapSearch = /*#__PURE__*/function () {
+ function BitapSearch(pattern) {
+ var _this = this;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ _classCallCheck(this, BitapSearch);
+ this.options = {
+ location: location,
+ threshold: threshold,
+ distance: distance,
+ includeMatches: includeMatches,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ isCaseSensitive: isCaseSensitive,
+ ignoreLocation: ignoreLocation
+ };
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.chunks = [];
+ if (!this.pattern.length) {
+ return;
+ }
+ var addChunk = function addChunk(pattern, startIndex) {
+ _this.chunks.push({
+ pattern: pattern,
+ alphabet: createPatternAlphabet(pattern),
+ startIndex: startIndex
+ });
+ };
+ var len = this.pattern.length;
+ if (len > MAX_BITS) {
+ var i = 0;
+ var remainder = len % MAX_BITS;
+ var end = len - remainder;
+ while (i < end) {
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
+ i += MAX_BITS;
+ }
+ if (remainder) {
+ var startIndex = len - MAX_BITS;
+ addChunk(this.pattern.substr(startIndex), startIndex);
+ }
+ } else {
+ addChunk(this.pattern, 0);
+ }
+ }
+ _createClass(BitapSearch, [{
+ key: "searchIn",
+ value: function searchIn(text) {
+ var _this$options = this.options,
+ isCaseSensitive = _this$options.isCaseSensitive,
+ includeMatches = _this$options.includeMatches;
+ if (!isCaseSensitive) {
+ text = text.toLowerCase();
+ }
+
+ // Exact match
+ if (this.pattern === text) {
+ var _result = {
+ isMatch: true,
+ score: 0
+ };
+ if (includeMatches) {
+ _result.indices = [[0, text.length - 1]];
+ }
+ return _result;
+ }
+
+ // Otherwise, use Bitap algorithm
+ var _this$options2 = this.options,
+ location = _this$options2.location,
+ distance = _this$options2.distance,
+ threshold = _this$options2.threshold,
+ findAllMatches = _this$options2.findAllMatches,
+ minMatchCharLength = _this$options2.minMatchCharLength,
+ ignoreLocation = _this$options2.ignoreLocation;
+ var allIndices = [];
+ var totalScore = 0;
+ var hasMatches = false;
+ this.chunks.forEach(function (_ref2) {
+ var pattern = _ref2.pattern,
+ alphabet = _ref2.alphabet,
+ startIndex = _ref2.startIndex;
+ var _search = search(text, pattern, alphabet, {
+ location: location + startIndex,
+ distance: distance,
+ threshold: threshold,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ includeMatches: includeMatches,
+ ignoreLocation: ignoreLocation
+ }),
+ isMatch = _search.isMatch,
+ score = _search.score,
+ indices = _search.indices;
+ if (isMatch) {
+ hasMatches = true;
+ }
+ totalScore += score;
+ if (isMatch && indices) {
+ allIndices = [].concat(_toConsumableArray(allIndices), _toConsumableArray(indices));
+ }
+ });
+ var result = {
+ isMatch: hasMatches,
+ score: hasMatches ? totalScore / this.chunks.length : 1
+ };
+ if (hasMatches && includeMatches) {
+ result.indices = allIndices;
+ }
+ return result;
+ }
+ }]);
+ return BitapSearch;
+}();
+
+var BaseMatch = /*#__PURE__*/function () {
+ function BaseMatch(pattern) {
+ _classCallCheck(this, BaseMatch);
+ this.pattern = pattern;
+ }
+ _createClass(BaseMatch, [{
+ key: "search",
+ value: function search( /*text*/) {}
+ }], [{
+ key: "isMultiMatch",
+ value: function isMultiMatch(pattern) {
+ return getMatch(pattern, this.multiRegex);
+ }
+ }, {
+ key: "isSingleMatch",
+ value: function isSingleMatch(pattern) {
+ return getMatch(pattern, this.singleRegex);
+ }
+ }]);
+ return BaseMatch;
+}();
+function getMatch(pattern, exp) {
+ var matches = pattern.match(exp);
+ return matches ? matches[1] : null;
+}
+
+var ExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(ExactMatch, _BaseMatch);
+ var _super = _createSuper(ExactMatch);
+ function ExactMatch(pattern) {
+ _classCallCheck(this, ExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(ExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = text === this.pattern;
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, this.pattern.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^="(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^=(.*)$/;
+ }
+ }]);
+ return ExactMatch;
+}(BaseMatch);
+
+var InverseExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(InverseExactMatch, _BaseMatch);
+ var _super = _createSuper(InverseExactMatch);
+ function InverseExactMatch(pattern) {
+ _classCallCheck(this, InverseExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(InverseExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var index = text.indexOf(this.pattern);
+ var isMatch = index === -1;
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'inverse-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^!"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^!(.*)$/;
+ }
+ }]);
+ return InverseExactMatch;
+}(BaseMatch);
+
+var PrefixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(PrefixExactMatch, _BaseMatch);
+ var _super = _createSuper(PrefixExactMatch);
+ function PrefixExactMatch(pattern) {
+ _classCallCheck(this, PrefixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(PrefixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = text.startsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, this.pattern.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'prefix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^\^"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^\^(.*)$/;
+ }
+ }]);
+ return PrefixExactMatch;
+}(BaseMatch);
+
+var InversePrefixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(InversePrefixExactMatch, _BaseMatch);
+ var _super = _createSuper(InversePrefixExactMatch);
+ function InversePrefixExactMatch(pattern) {
+ _classCallCheck(this, InversePrefixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(InversePrefixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = !text.startsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'inverse-prefix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^!\^"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^!\^(.*)$/;
+ }
+ }]);
+ return InversePrefixExactMatch;
+}(BaseMatch);
+
+var SuffixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(SuffixExactMatch, _BaseMatch);
+ var _super = _createSuper(SuffixExactMatch);
+ function SuffixExactMatch(pattern) {
+ _classCallCheck(this, SuffixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(SuffixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = text.endsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [text.length - this.pattern.length, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'suffix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^"(.*)"\$$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^(.*)\$$/;
+ }
+ }]);
+ return SuffixExactMatch;
+}(BaseMatch);
+
+var InverseSuffixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(InverseSuffixExactMatch, _BaseMatch);
+ var _super = _createSuper(InverseSuffixExactMatch);
+ function InverseSuffixExactMatch(pattern) {
+ _classCallCheck(this, InverseSuffixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(InverseSuffixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = !text.endsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'inverse-suffix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^!"(.*)"\$$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^!(.*)\$$/;
+ }
+ }]);
+ return InverseSuffixExactMatch;
+}(BaseMatch);
+
+var FuzzyMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(FuzzyMatch, _BaseMatch);
+ var _super = _createSuper(FuzzyMatch);
+ function FuzzyMatch(pattern) {
+ var _this;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ _classCallCheck(this, FuzzyMatch);
+ _this = _super.call(this, pattern);
+ _this._bitapSearch = new BitapSearch(pattern, {
+ location: location,
+ threshold: threshold,
+ distance: distance,
+ includeMatches: includeMatches,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ isCaseSensitive: isCaseSensitive,
+ ignoreLocation: ignoreLocation
+ });
+ return _this;
+ }
+ _createClass(FuzzyMatch, [{
+ key: "search",
+ value: function search(text) {
+ return this._bitapSearch.searchIn(text);
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'fuzzy';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^(.*)$/;
+ }
+ }]);
+ return FuzzyMatch;
+}(BaseMatch);
+
+var IncludeMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(IncludeMatch, _BaseMatch);
+ var _super = _createSuper(IncludeMatch);
+ function IncludeMatch(pattern) {
+ _classCallCheck(this, IncludeMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(IncludeMatch, [{
+ key: "search",
+ value: function search(text) {
+ var location = 0;
+ var index;
+ var indices = [];
+ var patternLen = this.pattern.length;
+
+ // Get all exact matches
+ while ((index = text.indexOf(this.pattern, location)) > -1) {
+ location = index + patternLen;
+ indices.push([index, location - 1]);
+ }
+ var isMatch = !!indices.length;
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: indices
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'include';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^'"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^'(.*)$/;
+ }
+ }]);
+ return IncludeMatch;
+}(BaseMatch);
+
+// ❗Order is important. DO NOT CHANGE.
+var searchers = [ExactMatch, IncludeMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch];
+var searchersLen = searchers.length;
+
+// Regex to split by spaces, but keep anything in quotes together
+var SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
+var OR_TOKEN = '|';
+
+// Return a 2D array representation of the query, for simpler parsing.
+// Example:
+// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
+function parseQuery(pattern) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ return pattern.split(OR_TOKEN).map(function (item) {
+ var query = item.trim().split(SPACE_RE).filter(function (item) {
+ return item && !!item.trim();
+ });
+ var results = [];
+ for (var i = 0, len = query.length; i < len; i += 1) {
+ var queryItem = query[i];
+
+ // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
+ var found = false;
+ var idx = -1;
+ while (!found && ++idx < searchersLen) {
+ var searcher = searchers[idx];
+ var token = searcher.isMultiMatch(queryItem);
+ if (token) {
+ results.push(new searcher(token, options));
+ found = true;
+ }
+ }
+ if (found) {
+ continue;
+ }
+
+ // 2. Handle single query matches (i.e, once that are *not* quoted)
+ idx = -1;
+ while (++idx < searchersLen) {
+ var _searcher = searchers[idx];
+ var _token = _searcher.isSingleMatch(queryItem);
+ if (_token) {
+ results.push(new _searcher(_token, options));
+ break;
+ }
+ }
+ }
+ return results;
+ });
+}
+
+// These extended matchers can return an array of matches, as opposed
+// to a singl match
+var MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
+
+/**
+ * Command-like searching
+ * ======================
+ *
+ * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
+ * search in a given text.
+ *
+ * Search syntax:
+ *
+ * | Token | Match type | Description |
+ * | ----------- | -------------------------- | -------------------------------------- |
+ * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
+ * | `=scheme` | exact-match | Items that are `scheme` |
+ * | `'python` | include-match | Items that include `python` |
+ * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
+ * | `^java` | prefix-exact-match | Items that start with `java` |
+ * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
+ * | `.js$` | suffix-exact-match | Items that end with `.js` |
+ * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
+ *
+ * A single pipe character acts as an OR operator. For example, the following
+ * query matches entries that start with `core` and end with either`go`, `rb`,
+ * or`py`.
+ *
+ * ```
+ * ^core go$ | rb$ | py$
+ * ```
+ */
+var ExtendedSearch = /*#__PURE__*/function () {
+ function ExtendedSearch(pattern) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance;
+ _classCallCheck(this, ExtendedSearch);
+ this.query = null;
+ this.options = {
+ isCaseSensitive: isCaseSensitive,
+ includeMatches: includeMatches,
+ minMatchCharLength: minMatchCharLength,
+ findAllMatches: findAllMatches,
+ ignoreLocation: ignoreLocation,
+ location: location,
+ threshold: threshold,
+ distance: distance
+ };
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.query = parseQuery(this.pattern, this.options);
+ }
+ _createClass(ExtendedSearch, [{
+ key: "searchIn",
+ value: function searchIn(text) {
+ var query = this.query;
+ if (!query) {
+ return {
+ isMatch: false,
+ score: 1
+ };
+ }
+ var _this$options = this.options,
+ includeMatches = _this$options.includeMatches,
+ isCaseSensitive = _this$options.isCaseSensitive;
+ text = isCaseSensitive ? text : text.toLowerCase();
+ var numMatches = 0;
+ var allIndices = [];
+ var totalScore = 0;
+
+ // ORs
+ for (var i = 0, qLen = query.length; i < qLen; i += 1) {
+ var searchers = query[i];
+
+ // Reset indices
+ allIndices.length = 0;
+ numMatches = 0;
+
+ // ANDs
+ for (var j = 0, pLen = searchers.length; j < pLen; j += 1) {
+ var searcher = searchers[j];
+ var _searcher$search = searcher.search(text),
+ isMatch = _searcher$search.isMatch,
+ indices = _searcher$search.indices,
+ score = _searcher$search.score;
+ if (isMatch) {
+ numMatches += 1;
+ totalScore += score;
+ if (includeMatches) {
+ var type = searcher.constructor.type;
+ if (MultiMatchSet.has(type)) {
+ allIndices = [].concat(_toConsumableArray(allIndices), _toConsumableArray(indices));
+ } else {
+ allIndices.push(indices);
+ }
+ }
+ } else {
+ totalScore = 0;
+ numMatches = 0;
+ allIndices.length = 0;
+ break;
+ }
+ }
+
+ // OR condition, so if TRUE, return
+ if (numMatches) {
+ var result = {
+ isMatch: true,
+ score: totalScore / numMatches
+ };
+ if (includeMatches) {
+ result.indices = allIndices;
+ }
+ return result;
+ }
+ }
+
+ // Nothing was matched
+ return {
+ isMatch: false,
+ score: 1
+ };
+ }
+ }], [{
+ key: "condition",
+ value: function condition(_, options) {
+ return options.useExtendedSearch;
+ }
+ }]);
+ return ExtendedSearch;
+}();
+
+var registeredSearchers = [];
+function register() {
+ registeredSearchers.push.apply(registeredSearchers, arguments);
+}
+function createSearcher(pattern, options) {
+ for (var i = 0, len = registeredSearchers.length; i < len; i += 1) {
+ var searcherClass = registeredSearchers[i];
+ if (searcherClass.condition(pattern, options)) {
+ return new searcherClass(pattern, options);
+ }
+ }
+ return new BitapSearch(pattern, options);
+}
+
+var LogicalOperator = {
+ AND: '$and',
+ OR: '$or'
+};
+var KeyType = {
+ PATH: '$path',
+ PATTERN: '$val'
+};
+var isExpression = function isExpression(query) {
+ return !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
+};
+var isPath = function isPath(query) {
+ return !!query[KeyType.PATH];
+};
+var isLeaf = function isLeaf(query) {
+ return !isArray(query) && isObject(query) && !isExpression(query);
+};
+var convertToExplicit = function convertToExplicit(query) {
+ return _defineProperty({}, LogicalOperator.AND, Object.keys(query).map(function (key) {
+ return _defineProperty({}, key, query[key]);
+ }));
+};
+
+// When `auto` is `true`, the parse function will infer and initialize and add
+// the appropriate `Searcher` instance
+function parse(query, options) {
+ var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref3$auto = _ref3.auto,
+ auto = _ref3$auto === void 0 ? true : _ref3$auto;
+ var next = function next(query) {
+ var keys = Object.keys(query);
+ var isQueryPath = isPath(query);
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
+ return next(convertToExplicit(query));
+ }
+ if (isLeaf(query)) {
+ var key = isQueryPath ? query[KeyType.PATH] : keys[0];
+ var pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
+ if (!isString(pattern)) {
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
+ }
+ var obj = {
+ keyId: createKeyId(key),
+ pattern: pattern
+ };
+ if (auto) {
+ obj.searcher = createSearcher(pattern, options);
+ }
+ return obj;
+ }
+ var node = {
+ children: [],
+ operator: keys[0]
+ };
+ keys.forEach(function (key) {
+ var value = query[key];
+ if (isArray(value)) {
+ value.forEach(function (item) {
+ node.children.push(next(item));
+ });
+ }
+ });
+ return node;
+ };
+ if (!isExpression(query)) {
+ query = convertToExplicit(query);
+ }
+ return next(query);
+}
+
+// Practical scoring function
+function computeScore(results, _ref) {
+ var _ref$ignoreFieldNorm = _ref.ignoreFieldNorm,
+ ignoreFieldNorm = _ref$ignoreFieldNorm === void 0 ? Config.ignoreFieldNorm : _ref$ignoreFieldNorm;
+ results.forEach(function (result) {
+ var totalScore = 1;
+ result.matches.forEach(function (_ref2) {
+ var key = _ref2.key,
+ norm = _ref2.norm,
+ score = _ref2.score;
+ var weight = key ? key.weight : null;
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
+ });
+ result.score = totalScore;
+ });
+}
+
+function transformMatches(result, data) {
+ var matches = result.matches;
+ data.matches = [];
+ if (!isDefined(matches)) {
+ return;
+ }
+ matches.forEach(function (match) {
+ if (!isDefined(match.indices) || !match.indices.length) {
+ return;
+ }
+ var indices = match.indices,
+ value = match.value;
+ var obj = {
+ indices: indices,
+ value: value
+ };
+ if (match.key) {
+ obj.key = match.key.src;
+ }
+ if (match.idx > -1) {
+ obj.refIndex = match.idx;
+ }
+ data.matches.push(obj);
+ });
+}
+
+function transformScore(result, data) {
+ data.score = result.score;
+}
+
+function format(results, docs) {
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$includeScore = _ref.includeScore,
+ includeScore = _ref$includeScore === void 0 ? Config.includeScore : _ref$includeScore;
+ var transformers = [];
+ if (includeMatches) transformers.push(transformMatches);
+ if (includeScore) transformers.push(transformScore);
+ return results.map(function (result) {
+ var idx = result.idx;
+ var data = {
+ item: docs[idx],
+ refIndex: idx
+ };
+ if (transformers.length) {
+ transformers.forEach(function (transformer) {
+ transformer(result, data);
+ });
+ }
+ return data;
+ });
+}
+
+var Fuse$1 = /*#__PURE__*/function () {
+ function Fuse(docs) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ var index = arguments.length > 2 ? arguments[2] : undefined;
+ _classCallCheck(this, Fuse);
+ this.options = _objectSpread2(_objectSpread2({}, Config), options);
+ if (this.options.useExtendedSearch && !true) {
+ throw new Error(EXTENDED_SEARCH_UNAVAILABLE);
+ }
+ this._keyStore = new KeyStore(this.options.keys);
+ this.setCollection(docs, index);
+ }
+ _createClass(Fuse, [{
+ key: "setCollection",
+ value: function setCollection(docs, index) {
+ this._docs = docs;
+ if (index && !(index instanceof FuseIndex)) {
+ throw new Error(INCORRECT_INDEX_TYPE);
+ }
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
+ getFn: this.options.getFn,
+ fieldNormWeight: this.options.fieldNormWeight
+ });
+ }
+ }, {
+ key: "add",
+ value: function add(doc) {
+ if (!isDefined(doc)) {
+ return;
+ }
+ this._docs.push(doc);
+ this._myIndex.add(doc);
+ }
+ }, {
+ key: "remove",
+ value: function remove() {
+ var predicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function /* doc, idx */ () {
+ return false;
+ };
+ var results = [];
+ for (var i = 0, len = this._docs.length; i < len; i += 1) {
+ var doc = this._docs[i];
+ if (predicate(doc, i)) {
+ this.removeAt(i);
+ i -= 1;
+ len -= 1;
+ results.push(doc);
+ }
+ }
+ return results;
+ }
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this._docs.splice(idx, 1);
+ this._myIndex.removeAt(idx);
+ }
+ }, {
+ key: "getIndex",
+ value: function getIndex() {
+ return this._myIndex;
+ }
+ }, {
+ key: "search",
+ value: function search(query) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$limit = _ref.limit,
+ limit = _ref$limit === void 0 ? -1 : _ref$limit;
+ var _this$options = this.options,
+ includeMatches = _this$options.includeMatches,
+ includeScore = _this$options.includeScore,
+ shouldSort = _this$options.shouldSort,
+ sortFn = _this$options.sortFn,
+ ignoreFieldNorm = _this$options.ignoreFieldNorm;
+ var results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
+ computeScore(results, {
+ ignoreFieldNorm: ignoreFieldNorm
+ });
+ if (shouldSort) {
+ results.sort(sortFn);
+ }
+ if (isNumber(limit) && limit > -1) {
+ results = results.slice(0, limit);
+ }
+ return format(results, this._docs, {
+ includeMatches: includeMatches,
+ includeScore: includeScore
+ });
+ }
+ }, {
+ key: "_searchStringList",
+ value: function _searchStringList(query) {
+ var searcher = createSearcher(query, this.options);
+ var records = this._myIndex.records;
+ var results = [];
+
+ // Iterate over every string in the index
+ records.forEach(function (_ref2) {
+ var text = _ref2.v,
+ idx = _ref2.i,
+ norm = _ref2.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn = searcher.searchIn(text),
+ isMatch = _searcher$searchIn.isMatch,
+ score = _searcher$searchIn.score,
+ indices = _searcher$searchIn.indices;
+ if (isMatch) {
+ results.push({
+ item: text,
+ idx: idx,
+ matches: [{
+ score: score,
+ value: text,
+ norm: norm,
+ indices: indices
+ }]
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_searchLogical",
+ value: function _searchLogical(query) {
+ var _this = this;
+ var expression = parse(query, this.options);
+ var evaluate = function evaluate(node, item, idx) {
+ if (!node.children) {
+ var keyId = node.keyId,
+ searcher = node.searcher;
+ var matches = _this._findMatches({
+ key: _this._keyStore.get(keyId),
+ value: _this._myIndex.getValueForItemAtKeyId(item, keyId),
+ searcher: searcher
+ });
+ if (matches && matches.length) {
+ return [{
+ idx: idx,
+ item: item,
+ matches: matches
+ }];
+ }
+ return [];
+ }
+ var res = [];
+ for (var i = 0, len = node.children.length; i < len; i += 1) {
+ var child = node.children[i];
+ var result = evaluate(child, item, idx);
+ if (result.length) {
+ res.push.apply(res, _toConsumableArray(result));
+ } else if (node.operator === LogicalOperator.AND) {
+ return [];
+ }
+ }
+ return res;
+ };
+ var records = this._myIndex.records;
+ var resultMap = {};
+ var results = [];
+ records.forEach(function (_ref3) {
+ var item = _ref3.$,
+ idx = _ref3.i;
+ if (isDefined(item)) {
+ var expResults = evaluate(expression, item, idx);
+ if (expResults.length) {
+ // Dedupe when adding
+ if (!resultMap[idx]) {
+ resultMap[idx] = {
+ idx: idx,
+ item: item,
+ matches: []
+ };
+ results.push(resultMap[idx]);
+ }
+ expResults.forEach(function (_ref4) {
+ var _resultMap$idx$matche;
+ var matches = _ref4.matches;
+ (_resultMap$idx$matche = resultMap[idx].matches).push.apply(_resultMap$idx$matche, _toConsumableArray(matches));
+ });
+ }
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_searchObjectList",
+ value: function _searchObjectList(query) {
+ var _this2 = this;
+ var searcher = createSearcher(query, this.options);
+ var _this$_myIndex = this._myIndex,
+ keys = _this$_myIndex.keys,
+ records = _this$_myIndex.records;
+ var results = [];
+
+ // List is Array<Object>
+ records.forEach(function (_ref5) {
+ var item = _ref5.$,
+ idx = _ref5.i;
+ if (!isDefined(item)) {
+ return;
+ }
+ var matches = [];
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ keys.forEach(function (key, keyIndex) {
+ matches.push.apply(matches, _toConsumableArray(_this2._findMatches({
+ key: key,
+ value: item[keyIndex],
+ searcher: searcher
+ })));
+ });
+ if (matches.length) {
+ results.push({
+ idx: idx,
+ item: item,
+ matches: matches
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_findMatches",
+ value: function _findMatches(_ref6) {
+ var key = _ref6.key,
+ value = _ref6.value,
+ searcher = _ref6.searcher;
+ if (!isDefined(value)) {
+ return [];
+ }
+ var matches = [];
+ if (isArray(value)) {
+ value.forEach(function (_ref7) {
+ var text = _ref7.v,
+ idx = _ref7.i,
+ norm = _ref7.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn2 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn2.isMatch,
+ score = _searcher$searchIn2.score,
+ indices = _searcher$searchIn2.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ idx: idx,
+ norm: norm,
+ indices: indices
+ });
+ }
+ });
+ } else {
+ var text = value.v,
+ norm = value.n;
+ var _searcher$searchIn3 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn3.isMatch,
+ score = _searcher$searchIn3.score,
+ indices = _searcher$searchIn3.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ norm: norm,
+ indices: indices
+ });
+ }
+ }
+ return matches;
+ }
+ }]);
+ return Fuse;
+}();
+
+Fuse$1.version = '7.0.0';
+Fuse$1.createIndex = createIndex;
+Fuse$1.parseIndex = parseIndex;
+Fuse$1.config = Config;
+{
+ Fuse$1.parseQuery = parse;
+}
+{
+ register(ExtendedSearch);
+}
+var Fuse = Fuse$1;
+
+module.exports = Fuse;
diff --git a/includes/node_modules/fuse.js/dist/fuse.d.ts b/includes/node_modules/fuse.js/dist/fuse.d.ts
new file mode 100644
index 0000000..4abfb90
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.d.ts
@@ -0,0 +1,368 @@
+// Type definitions for Fuse.js v7.0.0
+// TypeScript v4.9.5
+declare class Fuse<T> {
+ public constructor(
+ list: ReadonlyArray<T>,
+ options?: IFuseOptions<T>,
+ index?: FuseIndex<T>
+ )
+ /**
+ * Search function for the Fuse instance.
+ *
+ * ```typescript
+ * const list: MyType[] = [myType1, myType2, etc...]
+
+ * const options: Fuse.IFuseOptions<MyType> = {
+ * keys: ['key1', 'key2']
+ * }
+ *
+ * const myFuse = new Fuse(list, options)
+ * let result = myFuse.search('pattern')
+ * ```
+ *
+ * @param pattern The pattern to search
+ * @param options `Fuse.FuseSearchOptions`
+ * @returns An array of search results
+ */
+ public search<R = T>(
+ pattern: string | Expression,
+ options?: FuseSearchOptions
+ ): FuseResult<R>[]
+
+ public setCollection(docs: ReadonlyArray<T>, index?: FuseIndex<T>): void
+
+ /**
+ * Adds a doc to the end the list.
+ */
+ public add(doc: T): void
+
+ /**
+ * Removes all documents from the list which the predicate returns truthy for,
+ * and returns an array of the removed docs.
+ * The predicate is invoked with two arguments: (doc, index).
+ */
+ public remove(predicate: (doc: T, idx: number) => boolean): T[]
+
+ /**
+ * Removes the doc at the specified index.
+ */
+ public removeAt(idx: number): void
+
+ /**
+ * Returns the generated Fuse index
+ */
+ public getIndex(): FuseIndex<T>
+
+ /**
+ * Return the current version.
+ */
+ public static version: string
+
+ /**
+ * Use this method to pre-generate the index from the list, and pass it
+ * directly into the Fuse instance.
+ *
+ * _Note that Fuse will automatically index the table if one isn't provided
+ * during instantiation._
+ *
+ * ```typescript
+ * const list: MyType[] = [myType1, myType2, etc...]
+ *
+ * const index = Fuse.createIndex<MyType>(
+ * keys: ['key1', 'key2']
+ * list: list
+ * )
+ *
+ * const options: Fuse.IFuseOptions<MyType> = {
+ * keys: ['key1', 'key2']
+ * }
+ *
+ * const myFuse = new Fuse(list, options, index)
+ * ```
+ * @param keys The keys to index
+ * @param list The list from which to create an index
+ * @param options?
+ * @returns An indexed list
+ */
+ public static createIndex<U>(
+ keys: Array<FuseOptionKey<U>>,
+ list: ReadonlyArray<U>,
+ options?: FuseIndexOptions<U>
+ ): FuseIndex<U>
+
+ public static parseIndex<U>(
+ index: any,
+ options?: FuseIndexOptions<U>
+ ): FuseIndex<U>
+
+ public static config: Required<IFuseOptions<any>>
+}
+
+declare class FuseIndex<T> {
+ public constructor(options?: FuseIndexOptions<T>)
+ public setSources(docs: ReadonlyArray<T>): void
+ public setKeys(keys: ReadonlyArray<string>): void
+ public setIndexRecords(records: FuseIndexRecords): void
+ public create(): void
+ public add(doc: T): void
+ public toJSON(): {
+ keys: ReadonlyArray<string>
+ records: FuseIndexRecords
+ }
+}
+
+type FuseGetFunction<T> = (
+ obj: T,
+ path: string | string[]
+) => ReadonlyArray<string> | string
+
+type FuseIndexOptions<T> = {
+ getFn: FuseGetFunction<T>
+}
+
+/**
+ * @example
+ * ```ts
+ * {
+ * title: { '$': "Old Man's War" },
+ * 'author.firstName': { '$': 'Codenar' }
+ * }
+ * ```
+ * @example
+ * ```ts
+ * {
+ * tags: [
+ * { $: 'nonfiction', idx: 0 },
+ * { $: 'web development', idx: 1 },
+ * ]
+ * }
+ * ```
+ */
+type FuseSortFunctionItem = {
+ [key: string]: { $: string } | { $: string; idx: number }[]
+}
+
+/**
+ * @example
+ * ```ts
+ * {
+ * score: 0.001,
+ * key: 'author.firstName',
+ * value: 'Codenar',
+ * indices: [ [ 0, 3 ] ]
+ * }
+ * ```
+ */
+type FuseSortFunctionMatch = {
+ score: number
+ key: string
+ value: string
+ indices: ReadonlyArray<number>[]
+}
+
+/**
+ * @example
+ * ```ts
+ * {
+ * score: 0,
+ * key: 'tags',
+ * value: 'nonfiction',
+ * idx: 1,
+ * indices: [ [ 0, 9 ] ]
+ * }
+ * ```
+ */
+type FuseSortFunctionMatchList = FuseSortFunctionMatch & {
+ idx: number
+}
+
+type FuseSortFunctionArg = {
+ idx: number
+ item: FuseSortFunctionItem
+ score: number
+ matches?: (FuseSortFunctionMatch | FuseSortFunctionMatchList)[]
+}
+
+type FuseSortFunction = (
+ a: FuseSortFunctionArg,
+ b: FuseSortFunctionArg
+) => number
+
+/**
+ * @example
+ * ```ts
+ * title: {
+ * '$': "Old Man's War",
+ * 'n': 0.5773502691896258
+ * }
+ * ```
+ */
+type RecordEntryObject = {
+ /** The text value */
+ v: string
+ /** The field-length norm */
+ n: number
+}
+
+/**
+ * @example
+ * ```ts
+ * 'author.tags.name': [{
+ * 'v': 'pizza lover',
+ * 'i': 2,
+ * 'n: 0.7071067811865475
+ * }
+ * ```
+ */
+type RecordEntryArrayItem = ReadonlyArray<
+ RecordEntryObject & { i: number }
+>
+
+// TODO: this makes it difficult to infer the type. Need to think more about this
+type RecordEntry = {
+ [key: string]: RecordEntryObject | RecordEntryArrayItem
+}
+
+/**
+ * @example
+ * ```ts
+ * {
+ * i: 0,
+ * '$': {
+ * '0': { v: "Old Man's War", n: 0.5773502691896258 },
+ * '1': { v: 'Codenar', n: 1 },
+ * '2': [
+ * { v: 'pizza lover', i: 2, n: 0.7071067811865475 },
+ * { v: 'helo wold', i: 1, n: 0.7071067811865475 },
+ * { v: 'hello world', i: 0, n: 0.7071067811865475 }
+ * ]
+ * }
+ * }
+ * ```
+ */
+type FuseIndexObjectRecord = {
+ /** The index of the record in the source list */
+ i: number
+ $: RecordEntry
+}
+
+/**
+ * @example
+ * ```ts
+ * {
+ * keys: null,
+ * list: [
+ * { v: 'one', i: 0, n: 1 },
+ * { v: 'two', i: 1, n: 1 },
+ * { v: 'three', i: 2, n: 1 }
+ * ]
+ * }
+ * ```
+ */
+type FuseIndexStringRecord = {
+ /** The index of the record in the source list */
+ i: number
+ /** The text value */
+ v: string
+ /** The field-length norm */
+ n: number
+}
+
+type FuseIndexRecords =
+ | ReadonlyArray<FuseIndexObjectRecord>
+ | ReadonlyArray<FuseIndexStringRecord>
+
+/**
+ * @example
+ * ```ts
+ * {
+ * name: 'title',
+ * weight: 0.7
+ * }
+ * ```
+ */
+type FuseOptionKeyObject<T> = {
+ name: string | string[]
+ weight?: number
+ getFn?: (obj: T) => ReadonlyArray<string> | string
+}
+
+type FuseOptionKey<T> = FuseOptionKeyObject<T> | string | string[]
+
+interface IFuseOptions<T> {
+ /** Indicates whether comparisons should be case sensitive. */
+ isCaseSensitive?: boolean
+ /** Determines how close the match must be to the fuzzy location (specified by `location`). An exact letter match which is `distance` characters away from the fuzzy location would score as a complete mismatch. A `distance` of `0` requires the match be at the exact `location` specified. A distance of `1000` would require a perfect match to be within `800` characters of the `location` to be found using a `threshold` of `0.8`. */
+ distance?: number
+ /** When true, the matching function will continue to the end of a search pattern even if a perfect match has already been located in the string. */
+ findAllMatches?: boolean
+ /** The function to use to retrieve an object's value at the provided path. The default will also search nested paths. */
+ getFn?: FuseGetFunction<T>
+ /** When `true`, search will ignore `location` and `distance`, so it won't matter where in the string the pattern appears. */
+ ignoreLocation?: boolean
+ /** When `true`, the calculation for the relevance score (used for sorting) will ignore the `field-length norm`. */
+ ignoreFieldNorm?: boolean
+ /** Determines how much the `field-length norm` affects scoring. A value of `0` is equivalent to ignoring the field-length norm. A value of `0.5` will greatly reduce the effect of field-length norm, while a value of `2.0` will greatly increase it. */
+ fieldNormWeight?: number
+ /** Whether the matches should be included in the result set. When `true`, each record in the result set will include the indices of the matched characters. These can consequently be used for highlighting purposes. */
+ includeMatches?: boolean
+ /** Whether the score should be included in the result set. A score of `0`indicates a perfect match, while a score of `1` indicates a complete mismatch. */
+ includeScore?: boolean
+ /** List of keys that will be searched. This supports nested paths, weighted search, searching in arrays of `strings` and `objects`. */
+ keys?: Array<FuseOptionKey<T>>
+ /** Determines approximately where in the text is the pattern expected to be found. */
+ location?: number
+ /** Only the matches whose length exceeds this value will be returned. (For instance, if you want to ignore single character matches in the result, set it to `2`). */
+ minMatchCharLength?: number
+ /** Whether to sort the result list, by score. */
+ shouldSort?: boolean
+ /** The function to use to sort all the results. The default will sort by ascending relevance score, ascending index. */
+ sortFn?: FuseSortFunction
+ /** At what point does the match algorithm give up. A threshold of `0.0` requires a perfect match (of both letters and location), a threshold of `1.0` would match anything. */
+ threshold?: number
+ /** When `true`, it enables the use of unix-like search commands. See [example](/examples.html#extended-search). */
+ useExtendedSearch?: boolean
+}
+
+/**
+ * Denotes the start/end indices of a match
+ *
+ * @example
+ *
+ * ```ts
+ * const startIndex = 0;
+ * const endIndex = 5;
+ *
+ * const range: RangeTuple = [startIndex, endIndex];
+ * ```
+ */
+type RangeTuple = [number, number]
+
+type FuseResultMatch = {
+ indices: ReadonlyArray<RangeTuple>
+ key?: string
+ refIndex?: number
+ value?: string
+}
+
+type FuseSearchOptions = {
+ limit: number
+}
+
+type FuseResult<T> = {
+ item: T
+ refIndex: number
+ score?: number
+ matches?: ReadonlyArray<FuseResultMatch>
+}
+
+type Expression =
+ | { [key: string]: string }
+ | {
+ $path: ReadonlyArray<string>
+ $val: string
+ }
+ | { $and?: Expression[] }
+ | { $or?: Expression[] }
+
+export { Expression, FuseGetFunction, FuseIndex, FuseIndexObjectRecord, FuseIndexOptions, FuseIndexRecords, FuseIndexStringRecord, FuseOptionKey, FuseOptionKeyObject, FuseResult, FuseResultMatch, FuseSearchOptions, FuseSortFunction, FuseSortFunctionArg, FuseSortFunctionItem, FuseSortFunctionMatch, FuseSortFunctionMatchList, IFuseOptions, RangeTuple, RecordEntry, RecordEntryArrayItem, RecordEntryObject, Fuse as default };
diff --git a/includes/node_modules/fuse.js/dist/fuse.js b/includes/node_modules/fuse.js/dist/fuse.js
new file mode 100644
index 0000000..c984b28
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.js
@@ -0,0 +1,2010 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Fuse = factory());
+})(this, (function () { 'use strict';
+
+ function ownKeys(object, enumerableOnly) {
+ var keys = Object.keys(object);
+ if (Object.getOwnPropertySymbols) {
+ var symbols = Object.getOwnPropertySymbols(object);
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
+ })), keys.push.apply(keys, symbols);
+ }
+ return keys;
+ }
+ function _objectSpread2(target) {
+ for (var i = 1; i < arguments.length; i++) {
+ var source = null != arguments[i] ? arguments[i] : {};
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
+ _defineProperty(target, key, source[key]);
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
+ });
+ }
+ return target;
+ }
+ function _typeof(obj) {
+ "@babel/helpers - typeof";
+
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
+ return typeof obj;
+ } : function (obj) {
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
+ }, _typeof(obj);
+ }
+ function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+ }
+ 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, _toPropertyKey(descriptor.key), descriptor);
+ }
+ }
+ function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ Object.defineProperty(Constructor, "prototype", {
+ writable: false
+ });
+ return Constructor;
+ }
+ function _defineProperty(obj, key, value) {
+ key = _toPropertyKey(key);
+ if (key in obj) {
+ Object.defineProperty(obj, key, {
+ value: value,
+ enumerable: true,
+ configurable: true,
+ writable: true
+ });
+ } else {
+ obj[key] = value;
+ }
+ return obj;
+ }
+ 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
+ }
+ });
+ Object.defineProperty(subClass, "prototype", {
+ writable: false
+ });
+ if (superClass) _setPrototypeOf(subClass, superClass);
+ }
+ function _getPrototypeOf(o) {
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
+ return o.__proto__ || Object.getPrototypeOf(o);
+ };
+ return _getPrototypeOf(o);
+ }
+ function _setPrototypeOf(o, p) {
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
+ o.__proto__ = p;
+ return o;
+ };
+ return _setPrototypeOf(o, p);
+ }
+ function _isNativeReflectConstruct() {
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
+ if (Reflect.construct.sham) return false;
+ if (typeof Proxy === "function") return true;
+ try {
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+ function _assertThisInitialized(self) {
+ if (self === void 0) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
+ return self;
+ }
+ function _possibleConstructorReturn(self, call) {
+ if (call && (typeof call === "object" || typeof call === "function")) {
+ return call;
+ } else if (call !== void 0) {
+ throw new TypeError("Derived constructors may only return object or undefined");
+ }
+ return _assertThisInitialized(self);
+ }
+ 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);
+ };
+ }
+ function _toConsumableArray(arr) {
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
+ }
+ function _arrayWithoutHoles(arr) {
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
+ }
+ function _iterableToArray(iter) {
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
+ }
+ function _unsupportedIterableToArray(o, minLen) {
+ if (!o) return;
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
+ var n = Object.prototype.toString.call(o).slice(8, -1);
+ if (n === "Object" && o.constructor) n = o.constructor.name;
+ if (n === "Map" || n === "Set") return Array.from(o);
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
+ }
+ function _arrayLikeToArray(arr, len) {
+ if (len == null || len > arr.length) len = arr.length;
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
+ return arr2;
+ }
+ function _nonIterableSpread() {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+ }
+ function _toPrimitive(input, hint) {
+ if (typeof input !== "object" || input === null) return input;
+ var prim = input[Symbol.toPrimitive];
+ if (prim !== undefined) {
+ var res = prim.call(input, hint || "default");
+ if (typeof res !== "object") return res;
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return (hint === "string" ? String : Number)(input);
+ }
+ function _toPropertyKey(arg) {
+ var key = _toPrimitive(arg, "string");
+ return typeof key === "symbol" ? key : String(key);
+ }
+
+ function isArray(value) {
+ return !Array.isArray ? getTag(value) === '[object Array]' : Array.isArray(value);
+ }
+
+ // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
+ var INFINITY = 1 / 0;
+ function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ var result = value + '';
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result;
+ }
+ function toString(value) {
+ return value == null ? '' : baseToString(value);
+ }
+ function isString(value) {
+ return typeof value === 'string';
+ }
+ function isNumber(value) {
+ return typeof value === 'number';
+ }
+
+ // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
+ function isBoolean(value) {
+ return value === true || value === false || isObjectLike(value) && getTag(value) == '[object Boolean]';
+ }
+ function isObject(value) {
+ return _typeof(value) === 'object';
+ }
+
+ // Checks if `value` is object-like.
+ function isObjectLike(value) {
+ return isObject(value) && value !== null;
+ }
+ function isDefined(value) {
+ return value !== undefined && value !== null;
+ }
+ function isBlank(value) {
+ return !value.trim().length;
+ }
+
+ // Gets the `toStringTag` of `value`.
+ // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
+ function getTag(value) {
+ return value == null ? value === undefined ? '[object Undefined]' : '[object Null]' : Object.prototype.toString.call(value);
+ }
+
+ var EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
+ var INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
+ var LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = function LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key) {
+ return "Invalid value for key ".concat(key);
+ };
+ var PATTERN_LENGTH_TOO_LARGE = function PATTERN_LENGTH_TOO_LARGE(max) {
+ return "Pattern length exceeds max of ".concat(max, ".");
+ };
+ var MISSING_KEY_PROPERTY = function MISSING_KEY_PROPERTY(name) {
+ return "Missing ".concat(name, " property in key");
+ };
+ var INVALID_KEY_WEIGHT_VALUE = function INVALID_KEY_WEIGHT_VALUE(key) {
+ return "Property 'weight' in key '".concat(key, "' must be a positive integer");
+ };
+
+ var hasOwn = Object.prototype.hasOwnProperty;
+ var KeyStore = /*#__PURE__*/function () {
+ function KeyStore(keys) {
+ var _this = this;
+ _classCallCheck(this, KeyStore);
+ this._keys = [];
+ this._keyMap = {};
+ var totalWeight = 0;
+ keys.forEach(function (key) {
+ var obj = createKey(key);
+ _this._keys.push(obj);
+ _this._keyMap[obj.id] = obj;
+ totalWeight += obj.weight;
+ });
+
+ // Normalize weights so that their sum is equal to 1
+ this._keys.forEach(function (key) {
+ key.weight /= totalWeight;
+ });
+ }
+ _createClass(KeyStore, [{
+ key: "get",
+ value: function get(keyId) {
+ return this._keyMap[keyId];
+ }
+ }, {
+ key: "keys",
+ value: function keys() {
+ return this._keys;
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return JSON.stringify(this._keys);
+ }
+ }]);
+ return KeyStore;
+ }();
+ function createKey(key) {
+ var path = null;
+ var id = null;
+ var src = null;
+ var weight = 1;
+ var getFn = null;
+ if (isString(key) || isArray(key)) {
+ src = key;
+ path = createKeyPath(key);
+ id = createKeyId(key);
+ } else {
+ if (!hasOwn.call(key, 'name')) {
+ throw new Error(MISSING_KEY_PROPERTY('name'));
+ }
+ var name = key.name;
+ src = name;
+ if (hasOwn.call(key, 'weight')) {
+ weight = key.weight;
+ if (weight <= 0) {
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
+ }
+ }
+ path = createKeyPath(name);
+ id = createKeyId(name);
+ getFn = key.getFn;
+ }
+ return {
+ path: path,
+ id: id,
+ weight: weight,
+ src: src,
+ getFn: getFn
+ };
+ }
+ function createKeyPath(key) {
+ return isArray(key) ? key : key.split('.');
+ }
+ function createKeyId(key) {
+ return isArray(key) ? key.join('.') : key;
+ }
+
+ function get(obj, path) {
+ var list = [];
+ var arr = false;
+ var deepGet = function deepGet(obj, path, index) {
+ if (!isDefined(obj)) {
+ return;
+ }
+ if (!path[index]) {
+ // If there's no path left, we've arrived at the object we care about.
+ list.push(obj);
+ } else {
+ var key = path[index];
+ var value = obj[key];
+ if (!isDefined(value)) {
+ return;
+ }
+
+ // If we're at the last value in the path, and if it's a string/number/bool,
+ // add it to the list
+ if (index === path.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) {
+ list.push(toString(value));
+ } else if (isArray(value)) {
+ arr = true;
+ // Search each item in the array.
+ for (var i = 0, len = value.length; i < len; i += 1) {
+ deepGet(value[i], path, index + 1);
+ }
+ } else if (path.length) {
+ // An object. Recurse further.
+ deepGet(value, path, index + 1);
+ }
+ }
+ };
+
+ // Backwards compatibility (since path used to be a string)
+ deepGet(obj, isString(path) ? path.split('.') : path, 0);
+ return arr ? list : list[0];
+ }
+
+ var MatchOptions = {
+ // Whether the matches should be included in the result set. When `true`, each record in the result
+ // set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
+ includeMatches: false,
+ // When `true`, the matching function will continue to the end of a search pattern even if
+ // a perfect match has already been located in the string.
+ findAllMatches: false,
+ // Minimum number of characters that must be matched before a result is considered a match
+ minMatchCharLength: 1
+ };
+ var BasicOptions = {
+ // When `true`, the algorithm continues searching to the end of the input even if a perfect
+ // match is found before the end of the same input.
+ isCaseSensitive: false,
+ // When true, the matching function will continue to the end of a search pattern even if
+ includeScore: false,
+ // List of properties that will be searched. This also supports nested properties.
+ keys: [],
+ // Whether to sort the result list, by score
+ shouldSort: true,
+ // Default sort function: sort by ascending score, ascending index
+ sortFn: function sortFn(a, b) {
+ return a.score === b.score ? a.idx < b.idx ? -1 : 1 : a.score < b.score ? -1 : 1;
+ }
+ };
+ var FuzzyOptions = {
+ // Approximately where in the text is the pattern expected to be found?
+ location: 0,
+ // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
+ // (of both letters and location), a threshold of '1.0' would match anything.
+ threshold: 0.6,
+ // Determines how close the match must be to the fuzzy location (specified above).
+ // An exact letter match which is 'distance' characters away from the fuzzy location
+ // would score as a complete mismatch. A distance of '0' requires the match be at
+ // the exact location specified, a threshold of '1000' would require a perfect match
+ // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
+ distance: 100
+ };
+ var AdvancedOptions = {
+ // When `true`, it enables the use of unix-like search commands
+ useExtendedSearch: false,
+ // The get function to use when fetching an object's properties.
+ // The default will search nested paths *ie foo.bar.baz*
+ getFn: get,
+ // When `true`, search will ignore `location` and `distance`, so it won't matter
+ // where in the string the pattern appears.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
+ ignoreLocation: false,
+ // When `true`, the calculation for the relevance score (used for sorting) will
+ // ignore the field-length norm.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
+ ignoreFieldNorm: false,
+ // The weight to determine how much field length norm effects scoring.
+ fieldNormWeight: 1
+ };
+ var Config = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, BasicOptions), MatchOptions), FuzzyOptions), AdvancedOptions);
+
+ var SPACE = /[^ ]+/g;
+
+ // Field-length norm: the shorter the field, the higher the weight.
+ // Set to 3 decimals to reduce index size.
+ function norm() {
+ var weight = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
+ var mantissa = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
+ var cache = new Map();
+ var m = Math.pow(10, mantissa);
+ return {
+ get: function get(value) {
+ var numTokens = value.match(SPACE).length;
+ if (cache.has(numTokens)) {
+ return cache.get(numTokens);
+ }
+
+ // Default function is 1/sqrt(x), weight makes that variable
+ var norm = 1 / Math.pow(numTokens, 0.5 * weight);
+
+ // In place of `toFixed(mantissa)`, for faster computation
+ var n = parseFloat(Math.round(norm * m) / m);
+ cache.set(numTokens, n);
+ return n;
+ },
+ clear: function clear() {
+ cache.clear();
+ }
+ };
+ }
+
+ var FuseIndex = /*#__PURE__*/function () {
+ function FuseIndex() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$getFn = _ref.getFn,
+ getFn = _ref$getFn === void 0 ? Config.getFn : _ref$getFn,
+ _ref$fieldNormWeight = _ref.fieldNormWeight,
+ fieldNormWeight = _ref$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref$fieldNormWeight;
+ _classCallCheck(this, FuseIndex);
+ this.norm = norm(fieldNormWeight, 3);
+ this.getFn = getFn;
+ this.isCreated = false;
+ this.setIndexRecords();
+ }
+ _createClass(FuseIndex, [{
+ key: "setSources",
+ value: function setSources() {
+ var docs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.docs = docs;
+ }
+ }, {
+ key: "setIndexRecords",
+ value: function setIndexRecords() {
+ var records = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.records = records;
+ }
+ }, {
+ key: "setKeys",
+ value: function setKeys() {
+ var _this = this;
+ var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ this.keys = keys;
+ this._keysMap = {};
+ keys.forEach(function (key, idx) {
+ _this._keysMap[key.id] = idx;
+ });
+ }
+ }, {
+ key: "create",
+ value: function create() {
+ var _this2 = this;
+ if (this.isCreated || !this.docs.length) {
+ return;
+ }
+ this.isCreated = true;
+
+ // List is Array<String>
+ if (isString(this.docs[0])) {
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addString(doc, docIndex);
+ });
+ } else {
+ // List is Array<Object>
+ this.docs.forEach(function (doc, docIndex) {
+ _this2._addObject(doc, docIndex);
+ });
+ }
+ this.norm.clear();
+ }
+ // Adds a doc to the end of the index
+ }, {
+ key: "add",
+ value: function add(doc) {
+ var idx = this.size();
+ if (isString(doc)) {
+ this._addString(doc, idx);
+ } else {
+ this._addObject(doc, idx);
+ }
+ }
+ // Removes the doc at the specified index of the index
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this.records.splice(idx, 1);
+
+ // Change ref index of every subsquent doc
+ for (var i = idx, len = this.size(); i < len; i += 1) {
+ this.records[i].i -= 1;
+ }
+ }
+ }, {
+ key: "getValueForItemAtKeyId",
+ value: function getValueForItemAtKeyId(item, keyId) {
+ return item[this._keysMap[keyId]];
+ }
+ }, {
+ key: "size",
+ value: function size() {
+ return this.records.length;
+ }
+ }, {
+ key: "_addString",
+ value: function _addString(doc, docIndex) {
+ if (!isDefined(doc) || isBlank(doc)) {
+ return;
+ }
+ var record = {
+ v: doc,
+ i: docIndex,
+ n: this.norm.get(doc)
+ };
+ this.records.push(record);
+ }
+ }, {
+ key: "_addObject",
+ value: function _addObject(doc, docIndex) {
+ var _this3 = this;
+ var record = {
+ i: docIndex,
+ $: {}
+ };
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ this.keys.forEach(function (key, keyIndex) {
+ var value = key.getFn ? key.getFn(doc) : _this3.getFn(doc, key.path);
+ if (!isDefined(value)) {
+ return;
+ }
+ if (isArray(value)) {
+ var subRecords = [];
+ var stack = [{
+ nestedArrIndex: -1,
+ value: value
+ }];
+ while (stack.length) {
+ var _stack$pop = stack.pop(),
+ nestedArrIndex = _stack$pop.nestedArrIndex,
+ _value = _stack$pop.value;
+ if (!isDefined(_value)) {
+ continue;
+ }
+ if (isString(_value) && !isBlank(_value)) {
+ var subRecord = {
+ v: _value,
+ i: nestedArrIndex,
+ n: _this3.norm.get(_value)
+ };
+ subRecords.push(subRecord);
+ } else if (isArray(_value)) {
+ _value.forEach(function (item, k) {
+ stack.push({
+ nestedArrIndex: k,
+ value: item
+ });
+ });
+ } else ;
+ }
+ record.$[keyIndex] = subRecords;
+ } else if (isString(value) && !isBlank(value)) {
+ var _subRecord = {
+ v: value,
+ n: _this3.norm.get(value)
+ };
+ record.$[keyIndex] = _subRecord;
+ }
+ });
+ this.records.push(record);
+ }
+ }, {
+ key: "toJSON",
+ value: function toJSON() {
+ return {
+ keys: this.keys,
+ records: this.records
+ };
+ }
+ }]);
+ return FuseIndex;
+ }();
+ function createIndex(keys, docs) {
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref2$getFn = _ref2.getFn,
+ getFn = _ref2$getFn === void 0 ? Config.getFn : _ref2$getFn,
+ _ref2$fieldNormWeight = _ref2.fieldNormWeight,
+ fieldNormWeight = _ref2$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref2$fieldNormWeight;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys.map(createKey));
+ myIndex.setSources(docs);
+ myIndex.create();
+ return myIndex;
+ }
+ function parseIndex(data) {
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref3$getFn = _ref3.getFn,
+ getFn = _ref3$getFn === void 0 ? Config.getFn : _ref3$getFn,
+ _ref3$fieldNormWeight = _ref3.fieldNormWeight,
+ fieldNormWeight = _ref3$fieldNormWeight === void 0 ? Config.fieldNormWeight : _ref3$fieldNormWeight;
+ var keys = data.keys,
+ records = data.records;
+ var myIndex = new FuseIndex({
+ getFn: getFn,
+ fieldNormWeight: fieldNormWeight
+ });
+ myIndex.setKeys(keys);
+ myIndex.setIndexRecords(records);
+ return myIndex;
+ }
+
+ function computeScore$1(pattern) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$errors = _ref.errors,
+ errors = _ref$errors === void 0 ? 0 : _ref$errors,
+ _ref$currentLocation = _ref.currentLocation,
+ currentLocation = _ref$currentLocation === void 0 ? 0 : _ref$currentLocation,
+ _ref$expectedLocation = _ref.expectedLocation,
+ expectedLocation = _ref$expectedLocation === void 0 ? 0 : _ref$expectedLocation,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ var accuracy = errors / pattern.length;
+ if (ignoreLocation) {
+ return accuracy;
+ }
+ var proximity = Math.abs(expectedLocation - currentLocation);
+ if (!distance) {
+ // Dodge divide by zero error.
+ return proximity ? 1.0 : accuracy;
+ }
+ return accuracy + proximity / distance;
+ }
+
+ function convertMaskToIndices() {
+ var matchmask = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+ var minMatchCharLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Config.minMatchCharLength;
+ var indices = [];
+ var start = -1;
+ var end = -1;
+ var i = 0;
+ for (var len = matchmask.length; i < len; i += 1) {
+ var match = matchmask[i];
+ if (match && start === -1) {
+ start = i;
+ } else if (!match && start !== -1) {
+ end = i - 1;
+ if (end - start + 1 >= minMatchCharLength) {
+ indices.push([start, end]);
+ }
+ start = -1;
+ }
+ }
+
+ // (i-1 - start) + 1 => i - start
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
+ indices.push([start, i - 1]);
+ }
+ return indices;
+ }
+
+ // Machine word size
+ var MAX_BITS = 32;
+
+ function search(text, pattern, patternAlphabet) {
+ var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ if (pattern.length > MAX_BITS) {
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS));
+ }
+ var patternLen = pattern.length;
+ // Set starting location at beginning text and initialize the alphabet.
+ var textLen = text.length;
+ // Handle the case when location > text.length
+ var expectedLocation = Math.max(0, Math.min(location, textLen));
+ // Highest score beyond which we give up.
+ var currentThreshold = threshold;
+ // Is there a nearby exact match? (speedup)
+ var bestLocation = expectedLocation;
+
+ // Performance: only computer matches when the minMatchCharLength > 1
+ // OR if `includeMatches` is true.
+ var computeMatches = minMatchCharLength > 1 || includeMatches;
+ // A mask of the matches, used for building the indices
+ var matchMask = computeMatches ? Array(textLen) : [];
+ var index;
+
+ // Get all exact matches, here for speed up
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
+ var score = computeScore$1(pattern, {
+ currentLocation: index,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ currentThreshold = Math.min(score, currentThreshold);
+ bestLocation = index + patternLen;
+ if (computeMatches) {
+ var i = 0;
+ while (i < patternLen) {
+ matchMask[index + i] = 1;
+ i += 1;
+ }
+ }
+ }
+
+ // Reset the best location
+ bestLocation = -1;
+ var lastBitArr = [];
+ var finalScore = 1;
+ var binMax = patternLen + textLen;
+ var mask = 1 << patternLen - 1;
+ for (var _i = 0; _i < patternLen; _i += 1) {
+ // Scan for the best match; each iteration allows for one more error.
+ // Run a binary search to determine how far from the match location we can stray
+ // at this error level.
+ var binMin = 0;
+ var binMid = binMax;
+ while (binMin < binMid) {
+ var _score = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: expectedLocation + binMid,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score <= currentThreshold) {
+ binMin = binMid;
+ } else {
+ binMax = binMid;
+ }
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
+ }
+
+ // Use the result from this iteration as the maximum for the next.
+ binMax = binMid;
+ var start = Math.max(1, expectedLocation - binMid + 1);
+ var finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen;
+
+ // Initialize the bit array
+ var bitArr = Array(finish + 2);
+ bitArr[finish + 1] = (1 << _i) - 1;
+ for (var j = finish; j >= start; j -= 1) {
+ var currentLocation = j - 1;
+ var charMatch = patternAlphabet[text.charAt(currentLocation)];
+ if (computeMatches) {
+ // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
+ matchMask[currentLocation] = +!!charMatch;
+ }
+
+ // First pass: exact match
+ bitArr[j] = (bitArr[j + 1] << 1 | 1) & charMatch;
+
+ // Subsequent passes: fuzzy match
+ if (_i) {
+ bitArr[j] |= (lastBitArr[j + 1] | lastBitArr[j]) << 1 | 1 | lastBitArr[j + 1];
+ }
+ if (bitArr[j] & mask) {
+ finalScore = computeScore$1(pattern, {
+ errors: _i,
+ currentLocation: currentLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+
+ // This match will almost certainly be better than any existing match.
+ // But check anyway.
+ if (finalScore <= currentThreshold) {
+ // Indeed it is
+ currentThreshold = finalScore;
+ bestLocation = currentLocation;
+
+ // Already passed `loc`, downhill from here on in.
+ if (bestLocation <= expectedLocation) {
+ break;
+ }
+
+ // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
+ }
+ }
+ }
+
+ // No hope for a (better) match at greater error levels.
+ var _score2 = computeScore$1(pattern, {
+ errors: _i + 1,
+ currentLocation: expectedLocation,
+ expectedLocation: expectedLocation,
+ distance: distance,
+ ignoreLocation: ignoreLocation
+ });
+ if (_score2 > currentThreshold) {
+ break;
+ }
+ lastBitArr = bitArr;
+ }
+ var result = {
+ isMatch: bestLocation >= 0,
+ // Count exact matches (those with a score of 0) to be "almost" exact
+ score: Math.max(0.001, finalScore)
+ };
+ if (computeMatches) {
+ var indices = convertMaskToIndices(matchMask, minMatchCharLength);
+ if (!indices.length) {
+ result.isMatch = false;
+ } else if (includeMatches) {
+ result.indices = indices;
+ }
+ }
+ return result;
+ }
+
+ function createPatternAlphabet(pattern) {
+ var mask = {};
+ for (var i = 0, len = pattern.length; i < len; i += 1) {
+ var _char = pattern.charAt(i);
+ mask[_char] = (mask[_char] || 0) | 1 << len - i - 1;
+ }
+ return mask;
+ }
+
+ var BitapSearch = /*#__PURE__*/function () {
+ function BitapSearch(pattern) {
+ var _this = this;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ _classCallCheck(this, BitapSearch);
+ this.options = {
+ location: location,
+ threshold: threshold,
+ distance: distance,
+ includeMatches: includeMatches,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ isCaseSensitive: isCaseSensitive,
+ ignoreLocation: ignoreLocation
+ };
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.chunks = [];
+ if (!this.pattern.length) {
+ return;
+ }
+ var addChunk = function addChunk(pattern, startIndex) {
+ _this.chunks.push({
+ pattern: pattern,
+ alphabet: createPatternAlphabet(pattern),
+ startIndex: startIndex
+ });
+ };
+ var len = this.pattern.length;
+ if (len > MAX_BITS) {
+ var i = 0;
+ var remainder = len % MAX_BITS;
+ var end = len - remainder;
+ while (i < end) {
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
+ i += MAX_BITS;
+ }
+ if (remainder) {
+ var startIndex = len - MAX_BITS;
+ addChunk(this.pattern.substr(startIndex), startIndex);
+ }
+ } else {
+ addChunk(this.pattern, 0);
+ }
+ }
+ _createClass(BitapSearch, [{
+ key: "searchIn",
+ value: function searchIn(text) {
+ var _this$options = this.options,
+ isCaseSensitive = _this$options.isCaseSensitive,
+ includeMatches = _this$options.includeMatches;
+ if (!isCaseSensitive) {
+ text = text.toLowerCase();
+ }
+
+ // Exact match
+ if (this.pattern === text) {
+ var _result = {
+ isMatch: true,
+ score: 0
+ };
+ if (includeMatches) {
+ _result.indices = [[0, text.length - 1]];
+ }
+ return _result;
+ }
+
+ // Otherwise, use Bitap algorithm
+ var _this$options2 = this.options,
+ location = _this$options2.location,
+ distance = _this$options2.distance,
+ threshold = _this$options2.threshold,
+ findAllMatches = _this$options2.findAllMatches,
+ minMatchCharLength = _this$options2.minMatchCharLength,
+ ignoreLocation = _this$options2.ignoreLocation;
+ var allIndices = [];
+ var totalScore = 0;
+ var hasMatches = false;
+ this.chunks.forEach(function (_ref2) {
+ var pattern = _ref2.pattern,
+ alphabet = _ref2.alphabet,
+ startIndex = _ref2.startIndex;
+ var _search = search(text, pattern, alphabet, {
+ location: location + startIndex,
+ distance: distance,
+ threshold: threshold,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ includeMatches: includeMatches,
+ ignoreLocation: ignoreLocation
+ }),
+ isMatch = _search.isMatch,
+ score = _search.score,
+ indices = _search.indices;
+ if (isMatch) {
+ hasMatches = true;
+ }
+ totalScore += score;
+ if (isMatch && indices) {
+ allIndices = [].concat(_toConsumableArray(allIndices), _toConsumableArray(indices));
+ }
+ });
+ var result = {
+ isMatch: hasMatches,
+ score: hasMatches ? totalScore / this.chunks.length : 1
+ };
+ if (hasMatches && includeMatches) {
+ result.indices = allIndices;
+ }
+ return result;
+ }
+ }]);
+ return BitapSearch;
+ }();
+
+ var BaseMatch = /*#__PURE__*/function () {
+ function BaseMatch(pattern) {
+ _classCallCheck(this, BaseMatch);
+ this.pattern = pattern;
+ }
+ _createClass(BaseMatch, [{
+ key: "search",
+ value: function search( /*text*/) {}
+ }], [{
+ key: "isMultiMatch",
+ value: function isMultiMatch(pattern) {
+ return getMatch(pattern, this.multiRegex);
+ }
+ }, {
+ key: "isSingleMatch",
+ value: function isSingleMatch(pattern) {
+ return getMatch(pattern, this.singleRegex);
+ }
+ }]);
+ return BaseMatch;
+ }();
+ function getMatch(pattern, exp) {
+ var matches = pattern.match(exp);
+ return matches ? matches[1] : null;
+ }
+
+ var ExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(ExactMatch, _BaseMatch);
+ var _super = _createSuper(ExactMatch);
+ function ExactMatch(pattern) {
+ _classCallCheck(this, ExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(ExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = text === this.pattern;
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, this.pattern.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^="(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^=(.*)$/;
+ }
+ }]);
+ return ExactMatch;
+ }(BaseMatch);
+
+ var InverseExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(InverseExactMatch, _BaseMatch);
+ var _super = _createSuper(InverseExactMatch);
+ function InverseExactMatch(pattern) {
+ _classCallCheck(this, InverseExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(InverseExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var index = text.indexOf(this.pattern);
+ var isMatch = index === -1;
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'inverse-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^!"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^!(.*)$/;
+ }
+ }]);
+ return InverseExactMatch;
+ }(BaseMatch);
+
+ var PrefixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(PrefixExactMatch, _BaseMatch);
+ var _super = _createSuper(PrefixExactMatch);
+ function PrefixExactMatch(pattern) {
+ _classCallCheck(this, PrefixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(PrefixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = text.startsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, this.pattern.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'prefix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^\^"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^\^(.*)$/;
+ }
+ }]);
+ return PrefixExactMatch;
+ }(BaseMatch);
+
+ var InversePrefixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(InversePrefixExactMatch, _BaseMatch);
+ var _super = _createSuper(InversePrefixExactMatch);
+ function InversePrefixExactMatch(pattern) {
+ _classCallCheck(this, InversePrefixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(InversePrefixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = !text.startsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'inverse-prefix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^!\^"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^!\^(.*)$/;
+ }
+ }]);
+ return InversePrefixExactMatch;
+ }(BaseMatch);
+
+ var SuffixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(SuffixExactMatch, _BaseMatch);
+ var _super = _createSuper(SuffixExactMatch);
+ function SuffixExactMatch(pattern) {
+ _classCallCheck(this, SuffixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(SuffixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = text.endsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [text.length - this.pattern.length, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'suffix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^"(.*)"\$$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^(.*)\$$/;
+ }
+ }]);
+ return SuffixExactMatch;
+ }(BaseMatch);
+
+ var InverseSuffixExactMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(InverseSuffixExactMatch, _BaseMatch);
+ var _super = _createSuper(InverseSuffixExactMatch);
+ function InverseSuffixExactMatch(pattern) {
+ _classCallCheck(this, InverseSuffixExactMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(InverseSuffixExactMatch, [{
+ key: "search",
+ value: function search(text) {
+ var isMatch = !text.endsWith(this.pattern);
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'inverse-suffix-exact';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^!"(.*)"\$$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^!(.*)\$$/;
+ }
+ }]);
+ return InverseSuffixExactMatch;
+ }(BaseMatch);
+
+ var FuzzyMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(FuzzyMatch, _BaseMatch);
+ var _super = _createSuper(FuzzyMatch);
+ function FuzzyMatch(pattern) {
+ var _this;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation;
+ _classCallCheck(this, FuzzyMatch);
+ _this = _super.call(this, pattern);
+ _this._bitapSearch = new BitapSearch(pattern, {
+ location: location,
+ threshold: threshold,
+ distance: distance,
+ includeMatches: includeMatches,
+ findAllMatches: findAllMatches,
+ minMatchCharLength: minMatchCharLength,
+ isCaseSensitive: isCaseSensitive,
+ ignoreLocation: ignoreLocation
+ });
+ return _this;
+ }
+ _createClass(FuzzyMatch, [{
+ key: "search",
+ value: function search(text) {
+ return this._bitapSearch.searchIn(text);
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'fuzzy';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^(.*)$/;
+ }
+ }]);
+ return FuzzyMatch;
+ }(BaseMatch);
+
+ var IncludeMatch = /*#__PURE__*/function (_BaseMatch) {
+ _inherits(IncludeMatch, _BaseMatch);
+ var _super = _createSuper(IncludeMatch);
+ function IncludeMatch(pattern) {
+ _classCallCheck(this, IncludeMatch);
+ return _super.call(this, pattern);
+ }
+ _createClass(IncludeMatch, [{
+ key: "search",
+ value: function search(text) {
+ var location = 0;
+ var index;
+ var indices = [];
+ var patternLen = this.pattern.length;
+
+ // Get all exact matches
+ while ((index = text.indexOf(this.pattern, location)) > -1) {
+ location = index + patternLen;
+ indices.push([index, location - 1]);
+ }
+ var isMatch = !!indices.length;
+ return {
+ isMatch: isMatch,
+ score: isMatch ? 0 : 1,
+ indices: indices
+ };
+ }
+ }], [{
+ key: "type",
+ get: function get() {
+ return 'include';
+ }
+ }, {
+ key: "multiRegex",
+ get: function get() {
+ return /^'"(.*)"$/;
+ }
+ }, {
+ key: "singleRegex",
+ get: function get() {
+ return /^'(.*)$/;
+ }
+ }]);
+ return IncludeMatch;
+ }(BaseMatch);
+
+ // ❗Order is important. DO NOT CHANGE.
+ var searchers = [ExactMatch, IncludeMatch, PrefixExactMatch, InversePrefixExactMatch, InverseSuffixExactMatch, SuffixExactMatch, InverseExactMatch, FuzzyMatch];
+ var searchersLen = searchers.length;
+
+ // Regex to split by spaces, but keep anything in quotes together
+ var SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
+ var OR_TOKEN = '|';
+
+ // Return a 2D array representation of the query, for simpler parsing.
+ // Example:
+ // "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
+ function parseQuery(pattern) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ return pattern.split(OR_TOKEN).map(function (item) {
+ var query = item.trim().split(SPACE_RE).filter(function (item) {
+ return item && !!item.trim();
+ });
+ var results = [];
+ for (var i = 0, len = query.length; i < len; i += 1) {
+ var queryItem = query[i];
+
+ // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
+ var found = false;
+ var idx = -1;
+ while (!found && ++idx < searchersLen) {
+ var searcher = searchers[idx];
+ var token = searcher.isMultiMatch(queryItem);
+ if (token) {
+ results.push(new searcher(token, options));
+ found = true;
+ }
+ }
+ if (found) {
+ continue;
+ }
+
+ // 2. Handle single query matches (i.e, once that are *not* quoted)
+ idx = -1;
+ while (++idx < searchersLen) {
+ var _searcher = searchers[idx];
+ var _token = _searcher.isSingleMatch(queryItem);
+ if (_token) {
+ results.push(new _searcher(_token, options));
+ break;
+ }
+ }
+ }
+ return results;
+ });
+ }
+
+ // These extended matchers can return an array of matches, as opposed
+ // to a singl match
+ var MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
+
+ /**
+ * Command-like searching
+ * ======================
+ *
+ * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
+ * search in a given text.
+ *
+ * Search syntax:
+ *
+ * | Token | Match type | Description |
+ * | ----------- | -------------------------- | -------------------------------------- |
+ * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
+ * | `=scheme` | exact-match | Items that are `scheme` |
+ * | `'python` | include-match | Items that include `python` |
+ * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
+ * | `^java` | prefix-exact-match | Items that start with `java` |
+ * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
+ * | `.js$` | suffix-exact-match | Items that end with `.js` |
+ * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
+ *
+ * A single pipe character acts as an OR operator. For example, the following
+ * query matches entries that start with `core` and end with either`go`, `rb`,
+ * or`py`.
+ *
+ * ```
+ * ^core go$ | rb$ | py$
+ * ```
+ */
+ var ExtendedSearch = /*#__PURE__*/function () {
+ function ExtendedSearch(pattern) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$isCaseSensitive = _ref.isCaseSensitive,
+ isCaseSensitive = _ref$isCaseSensitive === void 0 ? Config.isCaseSensitive : _ref$isCaseSensitive,
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$minMatchCharLeng = _ref.minMatchCharLength,
+ minMatchCharLength = _ref$minMatchCharLeng === void 0 ? Config.minMatchCharLength : _ref$minMatchCharLeng,
+ _ref$ignoreLocation = _ref.ignoreLocation,
+ ignoreLocation = _ref$ignoreLocation === void 0 ? Config.ignoreLocation : _ref$ignoreLocation,
+ _ref$findAllMatches = _ref.findAllMatches,
+ findAllMatches = _ref$findAllMatches === void 0 ? Config.findAllMatches : _ref$findAllMatches,
+ _ref$location = _ref.location,
+ location = _ref$location === void 0 ? Config.location : _ref$location,
+ _ref$threshold = _ref.threshold,
+ threshold = _ref$threshold === void 0 ? Config.threshold : _ref$threshold,
+ _ref$distance = _ref.distance,
+ distance = _ref$distance === void 0 ? Config.distance : _ref$distance;
+ _classCallCheck(this, ExtendedSearch);
+ this.query = null;
+ this.options = {
+ isCaseSensitive: isCaseSensitive,
+ includeMatches: includeMatches,
+ minMatchCharLength: minMatchCharLength,
+ findAllMatches: findAllMatches,
+ ignoreLocation: ignoreLocation,
+ location: location,
+ threshold: threshold,
+ distance: distance
+ };
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.query = parseQuery(this.pattern, this.options);
+ }
+ _createClass(ExtendedSearch, [{
+ key: "searchIn",
+ value: function searchIn(text) {
+ var query = this.query;
+ if (!query) {
+ return {
+ isMatch: false,
+ score: 1
+ };
+ }
+ var _this$options = this.options,
+ includeMatches = _this$options.includeMatches,
+ isCaseSensitive = _this$options.isCaseSensitive;
+ text = isCaseSensitive ? text : text.toLowerCase();
+ var numMatches = 0;
+ var allIndices = [];
+ var totalScore = 0;
+
+ // ORs
+ for (var i = 0, qLen = query.length; i < qLen; i += 1) {
+ var searchers = query[i];
+
+ // Reset indices
+ allIndices.length = 0;
+ numMatches = 0;
+
+ // ANDs
+ for (var j = 0, pLen = searchers.length; j < pLen; j += 1) {
+ var searcher = searchers[j];
+ var _searcher$search = searcher.search(text),
+ isMatch = _searcher$search.isMatch,
+ indices = _searcher$search.indices,
+ score = _searcher$search.score;
+ if (isMatch) {
+ numMatches += 1;
+ totalScore += score;
+ if (includeMatches) {
+ var type = searcher.constructor.type;
+ if (MultiMatchSet.has(type)) {
+ allIndices = [].concat(_toConsumableArray(allIndices), _toConsumableArray(indices));
+ } else {
+ allIndices.push(indices);
+ }
+ }
+ } else {
+ totalScore = 0;
+ numMatches = 0;
+ allIndices.length = 0;
+ break;
+ }
+ }
+
+ // OR condition, so if TRUE, return
+ if (numMatches) {
+ var result = {
+ isMatch: true,
+ score: totalScore / numMatches
+ };
+ if (includeMatches) {
+ result.indices = allIndices;
+ }
+ return result;
+ }
+ }
+
+ // Nothing was matched
+ return {
+ isMatch: false,
+ score: 1
+ };
+ }
+ }], [{
+ key: "condition",
+ value: function condition(_, options) {
+ return options.useExtendedSearch;
+ }
+ }]);
+ return ExtendedSearch;
+ }();
+
+ var registeredSearchers = [];
+ function register() {
+ registeredSearchers.push.apply(registeredSearchers, arguments);
+ }
+ function createSearcher(pattern, options) {
+ for (var i = 0, len = registeredSearchers.length; i < len; i += 1) {
+ var searcherClass = registeredSearchers[i];
+ if (searcherClass.condition(pattern, options)) {
+ return new searcherClass(pattern, options);
+ }
+ }
+ return new BitapSearch(pattern, options);
+ }
+
+ var LogicalOperator = {
+ AND: '$and',
+ OR: '$or'
+ };
+ var KeyType = {
+ PATH: '$path',
+ PATTERN: '$val'
+ };
+ var isExpression = function isExpression(query) {
+ return !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
+ };
+ var isPath = function isPath(query) {
+ return !!query[KeyType.PATH];
+ };
+ var isLeaf = function isLeaf(query) {
+ return !isArray(query) && isObject(query) && !isExpression(query);
+ };
+ var convertToExplicit = function convertToExplicit(query) {
+ return _defineProperty({}, LogicalOperator.AND, Object.keys(query).map(function (key) {
+ return _defineProperty({}, key, query[key]);
+ }));
+ };
+
+ // When `auto` is `true`, the parse function will infer and initialize and add
+ // the appropriate `Searcher` instance
+ function parse(query, options) {
+ var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref3$auto = _ref3.auto,
+ auto = _ref3$auto === void 0 ? true : _ref3$auto;
+ var next = function next(query) {
+ var keys = Object.keys(query);
+ var isQueryPath = isPath(query);
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
+ return next(convertToExplicit(query));
+ }
+ if (isLeaf(query)) {
+ var key = isQueryPath ? query[KeyType.PATH] : keys[0];
+ var pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
+ if (!isString(pattern)) {
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key));
+ }
+ var obj = {
+ keyId: createKeyId(key),
+ pattern: pattern
+ };
+ if (auto) {
+ obj.searcher = createSearcher(pattern, options);
+ }
+ return obj;
+ }
+ var node = {
+ children: [],
+ operator: keys[0]
+ };
+ keys.forEach(function (key) {
+ var value = query[key];
+ if (isArray(value)) {
+ value.forEach(function (item) {
+ node.children.push(next(item));
+ });
+ }
+ });
+ return node;
+ };
+ if (!isExpression(query)) {
+ query = convertToExplicit(query);
+ }
+ return next(query);
+ }
+
+ // Practical scoring function
+ function computeScore(results, _ref) {
+ var _ref$ignoreFieldNorm = _ref.ignoreFieldNorm,
+ ignoreFieldNorm = _ref$ignoreFieldNorm === void 0 ? Config.ignoreFieldNorm : _ref$ignoreFieldNorm;
+ results.forEach(function (result) {
+ var totalScore = 1;
+ result.matches.forEach(function (_ref2) {
+ var key = _ref2.key,
+ norm = _ref2.norm,
+ score = _ref2.score;
+ var weight = key ? key.weight : null;
+ totalScore *= Math.pow(score === 0 && weight ? Number.EPSILON : score, (weight || 1) * (ignoreFieldNorm ? 1 : norm));
+ });
+ result.score = totalScore;
+ });
+ }
+
+ function transformMatches(result, data) {
+ var matches = result.matches;
+ data.matches = [];
+ if (!isDefined(matches)) {
+ return;
+ }
+ matches.forEach(function (match) {
+ if (!isDefined(match.indices) || !match.indices.length) {
+ return;
+ }
+ var indices = match.indices,
+ value = match.value;
+ var obj = {
+ indices: indices,
+ value: value
+ };
+ if (match.key) {
+ obj.key = match.key.src;
+ }
+ if (match.idx > -1) {
+ obj.refIndex = match.idx;
+ }
+ data.matches.push(obj);
+ });
+ }
+
+ function transformScore(result, data) {
+ data.score = result.score;
+ }
+
+ function format(results, docs) {
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
+ _ref$includeMatches = _ref.includeMatches,
+ includeMatches = _ref$includeMatches === void 0 ? Config.includeMatches : _ref$includeMatches,
+ _ref$includeScore = _ref.includeScore,
+ includeScore = _ref$includeScore === void 0 ? Config.includeScore : _ref$includeScore;
+ var transformers = [];
+ if (includeMatches) transformers.push(transformMatches);
+ if (includeScore) transformers.push(transformScore);
+ return results.map(function (result) {
+ var idx = result.idx;
+ var data = {
+ item: docs[idx],
+ refIndex: idx
+ };
+ if (transformers.length) {
+ transformers.forEach(function (transformer) {
+ transformer(result, data);
+ });
+ }
+ return data;
+ });
+ }
+
+ var Fuse$1 = /*#__PURE__*/function () {
+ function Fuse(docs) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ var index = arguments.length > 2 ? arguments[2] : undefined;
+ _classCallCheck(this, Fuse);
+ this.options = _objectSpread2(_objectSpread2({}, Config), options);
+ if (this.options.useExtendedSearch && !true) {
+ throw new Error(EXTENDED_SEARCH_UNAVAILABLE);
+ }
+ this._keyStore = new KeyStore(this.options.keys);
+ this.setCollection(docs, index);
+ }
+ _createClass(Fuse, [{
+ key: "setCollection",
+ value: function setCollection(docs, index) {
+ this._docs = docs;
+ if (index && !(index instanceof FuseIndex)) {
+ throw new Error(INCORRECT_INDEX_TYPE);
+ }
+ this._myIndex = index || createIndex(this.options.keys, this._docs, {
+ getFn: this.options.getFn,
+ fieldNormWeight: this.options.fieldNormWeight
+ });
+ }
+ }, {
+ key: "add",
+ value: function add(doc) {
+ if (!isDefined(doc)) {
+ return;
+ }
+ this._docs.push(doc);
+ this._myIndex.add(doc);
+ }
+ }, {
+ key: "remove",
+ value: function remove() {
+ var predicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function /* doc, idx */ () {
+ return false;
+ };
+ var results = [];
+ for (var i = 0, len = this._docs.length; i < len; i += 1) {
+ var doc = this._docs[i];
+ if (predicate(doc, i)) {
+ this.removeAt(i);
+ i -= 1;
+ len -= 1;
+ results.push(doc);
+ }
+ }
+ return results;
+ }
+ }, {
+ key: "removeAt",
+ value: function removeAt(idx) {
+ this._docs.splice(idx, 1);
+ this._myIndex.removeAt(idx);
+ }
+ }, {
+ key: "getIndex",
+ value: function getIndex() {
+ return this._myIndex;
+ }
+ }, {
+ key: "search",
+ value: function search(query) {
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$limit = _ref.limit,
+ limit = _ref$limit === void 0 ? -1 : _ref$limit;
+ var _this$options = this.options,
+ includeMatches = _this$options.includeMatches,
+ includeScore = _this$options.includeScore,
+ shouldSort = _this$options.shouldSort,
+ sortFn = _this$options.sortFn,
+ ignoreFieldNorm = _this$options.ignoreFieldNorm;
+ var results = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query);
+ computeScore(results, {
+ ignoreFieldNorm: ignoreFieldNorm
+ });
+ if (shouldSort) {
+ results.sort(sortFn);
+ }
+ if (isNumber(limit) && limit > -1) {
+ results = results.slice(0, limit);
+ }
+ return format(results, this._docs, {
+ includeMatches: includeMatches,
+ includeScore: includeScore
+ });
+ }
+ }, {
+ key: "_searchStringList",
+ value: function _searchStringList(query) {
+ var searcher = createSearcher(query, this.options);
+ var records = this._myIndex.records;
+ var results = [];
+
+ // Iterate over every string in the index
+ records.forEach(function (_ref2) {
+ var text = _ref2.v,
+ idx = _ref2.i,
+ norm = _ref2.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn = searcher.searchIn(text),
+ isMatch = _searcher$searchIn.isMatch,
+ score = _searcher$searchIn.score,
+ indices = _searcher$searchIn.indices;
+ if (isMatch) {
+ results.push({
+ item: text,
+ idx: idx,
+ matches: [{
+ score: score,
+ value: text,
+ norm: norm,
+ indices: indices
+ }]
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_searchLogical",
+ value: function _searchLogical(query) {
+ var _this = this;
+ var expression = parse(query, this.options);
+ var evaluate = function evaluate(node, item, idx) {
+ if (!node.children) {
+ var keyId = node.keyId,
+ searcher = node.searcher;
+ var matches = _this._findMatches({
+ key: _this._keyStore.get(keyId),
+ value: _this._myIndex.getValueForItemAtKeyId(item, keyId),
+ searcher: searcher
+ });
+ if (matches && matches.length) {
+ return [{
+ idx: idx,
+ item: item,
+ matches: matches
+ }];
+ }
+ return [];
+ }
+ var res = [];
+ for (var i = 0, len = node.children.length; i < len; i += 1) {
+ var child = node.children[i];
+ var result = evaluate(child, item, idx);
+ if (result.length) {
+ res.push.apply(res, _toConsumableArray(result));
+ } else if (node.operator === LogicalOperator.AND) {
+ return [];
+ }
+ }
+ return res;
+ };
+ var records = this._myIndex.records;
+ var resultMap = {};
+ var results = [];
+ records.forEach(function (_ref3) {
+ var item = _ref3.$,
+ idx = _ref3.i;
+ if (isDefined(item)) {
+ var expResults = evaluate(expression, item, idx);
+ if (expResults.length) {
+ // Dedupe when adding
+ if (!resultMap[idx]) {
+ resultMap[idx] = {
+ idx: idx,
+ item: item,
+ matches: []
+ };
+ results.push(resultMap[idx]);
+ }
+ expResults.forEach(function (_ref4) {
+ var _resultMap$idx$matche;
+ var matches = _ref4.matches;
+ (_resultMap$idx$matche = resultMap[idx].matches).push.apply(_resultMap$idx$matche, _toConsumableArray(matches));
+ });
+ }
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_searchObjectList",
+ value: function _searchObjectList(query) {
+ var _this2 = this;
+ var searcher = createSearcher(query, this.options);
+ var _this$_myIndex = this._myIndex,
+ keys = _this$_myIndex.keys,
+ records = _this$_myIndex.records;
+ var results = [];
+
+ // List is Array<Object>
+ records.forEach(function (_ref5) {
+ var item = _ref5.$,
+ idx = _ref5.i;
+ if (!isDefined(item)) {
+ return;
+ }
+ var matches = [];
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ keys.forEach(function (key, keyIndex) {
+ matches.push.apply(matches, _toConsumableArray(_this2._findMatches({
+ key: key,
+ value: item[keyIndex],
+ searcher: searcher
+ })));
+ });
+ if (matches.length) {
+ results.push({
+ idx: idx,
+ item: item,
+ matches: matches
+ });
+ }
+ });
+ return results;
+ }
+ }, {
+ key: "_findMatches",
+ value: function _findMatches(_ref6) {
+ var key = _ref6.key,
+ value = _ref6.value,
+ searcher = _ref6.searcher;
+ if (!isDefined(value)) {
+ return [];
+ }
+ var matches = [];
+ if (isArray(value)) {
+ value.forEach(function (_ref7) {
+ var text = _ref7.v,
+ idx = _ref7.i,
+ norm = _ref7.n;
+ if (!isDefined(text)) {
+ return;
+ }
+ var _searcher$searchIn2 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn2.isMatch,
+ score = _searcher$searchIn2.score,
+ indices = _searcher$searchIn2.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ idx: idx,
+ norm: norm,
+ indices: indices
+ });
+ }
+ });
+ } else {
+ var text = value.v,
+ norm = value.n;
+ var _searcher$searchIn3 = searcher.searchIn(text),
+ isMatch = _searcher$searchIn3.isMatch,
+ score = _searcher$searchIn3.score,
+ indices = _searcher$searchIn3.indices;
+ if (isMatch) {
+ matches.push({
+ score: score,
+ key: key,
+ value: text,
+ norm: norm,
+ indices: indices
+ });
+ }
+ }
+ return matches;
+ }
+ }]);
+ return Fuse;
+ }();
+
+ Fuse$1.version = '7.0.0';
+ Fuse$1.createIndex = createIndex;
+ Fuse$1.parseIndex = parseIndex;
+ Fuse$1.config = Config;
+ {
+ Fuse$1.parseQuery = parse;
+ }
+ {
+ register(ExtendedSearch);
+ }
+ var Fuse = Fuse$1;
+
+ return Fuse;
+
+}));
diff --git a/includes/node_modules/fuse.js/dist/fuse.min.cjs b/includes/node_modules/fuse.js/dist/fuse.min.cjs
new file mode 100644
index 0000000..8824782
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.min.cjs
@@ -0,0 +1,9 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){c(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,v(r.key),r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=s(e);if(t){var i=s(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return h(this,n)}}function f(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function v(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function g(e){return Array.isArray?Array.isArray(e):"[object Array]"===S(e)}var y=1/0;function p(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-y?"-0":t}(e)}function m(e){return"string"==typeof e}function k(e){return"number"==typeof e}function M(e){return!0===e||!1===e||function(e){return b(e)&&null!==e}(e)&&"[object Boolean]"==S(e)}function b(e){return"object"===n(e)}function x(e){return null!=e}function w(e){return!e.trim().length}function S(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var L=function(e){return"Missing ".concat(e," property in key")},_=function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")},O=Object.prototype.hasOwnProperty,j=function(){function e(t){var n=this;r(this,e),this._keys=[],this._keyMap={};var i=0;t.forEach((function(e){var t=A(e);n._keys.push(t),n._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return o(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function A(e){var t=null,n=null,r=null,i=1,o=null;if(m(e)||g(e))r=e,t=I(e),n=C(e);else{if(!O.call(e,"name"))throw new Error(L("name"));var c=e.name;if(r=c,O.call(e,"weight")&&(i=e.weight)<=0)throw new Error(_(c));t=I(c),n=C(c),o=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:o}}function I(e){return g(e)?e:e.split(".")}function C(e){return g(e)?e.join("."):e}var E={useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(x(t))if(i[o]){var c=t[i[o]];if(!x(c))return;if(o===i.length-1&&(m(c)||k(c)||M(c)))n.push(p(c));else if(g(c)){r=!0;for(var a=0,s=c.length;a<s;a+=1)e(c[a],i,o+1)}else i.length&&e(c,i,o+1)}else n.push(t)}(e,m(t)?t.split("."):t,0),r?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=t(t(t(t({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),E),F=/[^ ]+/g;var R=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?$.getFn:n,o=t.fieldNormWeight,c=void 0===o?$.fieldNormWeight:o;r(this,e),this.norm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(F).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),c=parseFloat(Math.round(o*r)/r);return n.set(i,c),c},clear:function(){n.clear()}}}(c,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,m(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();m(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,t){if(x(e)&&!w(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(e,t){var n=this,r={i:t,$:{}};this.keys.forEach((function(t,i){var o=t.getFn?t.getFn(e):n.getFn(e,t.path);if(x(o))if(g(o)){for(var c=[],a=[{nestedArrIndex:-1,value:o}];a.length;){var s=a.pop(),u=s.nestedArrIndex,h=s.value;if(x(h))if(m(h)&&!w(h)){var l={v:h,i:u,n:n.norm.get(h)};c.push(l)}else g(h)&&h.forEach((function(e,t){a.push({nestedArrIndex:t,value:e})}))}r.$[i]=c}else if(m(o)&&!w(o)){var f={v:o,n:n.norm.get(o)};r.$[i]=f}})),this.records.push(r)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),e}();function P(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?$.getFn:r,o=n.fieldNormWeight,c=void 0===o?$.fieldNormWeight:o,a=new R({getFn:i,fieldNormWeight:c});return a.setKeys(e.map(A)),a.setSources(t),a.create(),a}function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,c=t.expectedLocation,a=void 0===c?0:c,s=t.distance,u=void 0===s?$.distance:s,h=t.ignoreLocation,l=void 0===h?$.ignoreLocation:h,f=r/e.length;if(l)return f;var d=Math.abs(a-o);return u?f+d/u:d?1:f}var W=32;function z(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?$.location:i,c=r.distance,a=void 0===c?$.distance:c,s=r.threshold,u=void 0===s?$.threshold:s,h=r.findAllMatches,l=void 0===h?$.findAllMatches:h,f=r.minMatchCharLength,d=void 0===f?$.minMatchCharLength:f,v=r.includeMatches,g=void 0===v?$.includeMatches:v,y=r.ignoreLocation,p=void 0===y?$.ignoreLocation:y;if(t.length>W)throw new Error("Pattern length exceeds max of ".concat(W,"."));for(var m,k=t.length,M=e.length,b=Math.max(0,Math.min(o,M)),x=u,w=b,S=d>1||g,L=S?Array(M):[];(m=e.indexOf(t,w))>-1;){var _=N(t,{currentLocation:m,expectedLocation:b,distance:a,ignoreLocation:p});if(x=Math.min(_,x),w=m+k,S)for(var O=0;O<k;)L[m+O]=1,O+=1}w=-1;for(var j=[],A=1,I=k+M,C=1<<k-1,E=0;E<k;E+=1){for(var F=0,R=I;F<R;){N(t,{errors:E,currentLocation:b+R,expectedLocation:b,distance:a,ignoreLocation:p})<=x?F=R:I=R,R=Math.floor((I-F)/2+F)}I=R;var P=Math.max(1,b-R+1),z=l?M:Math.min(b+R,M)+k,D=Array(z+2);D[z+1]=(1<<E)-1;for(var K=z;K>=P;K-=1){var T=K-1,q=n[e.charAt(T)];if(S&&(L[T]=+!!q),D[K]=(D[K+1]<<1|1)&q,E&&(D[K]|=(j[K+1]|j[K])<<1|1|j[K+1]),D[K]&C&&(A=N(t,{errors:E,currentLocation:T,expectedLocation:b,distance:a,ignoreLocation:p}))<=x){if(x=A,(w=T)<=b)break;P=Math.max(1,2*b-w)}}if(N(t,{errors:E+1,currentLocation:b,expectedLocation:b,distance:a,ignoreLocation:p})>x)break;j=D}var B={isMatch:w>=0,score:Math.max(.001,A)};if(S){var J=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$.minMatchCharLength,n=[],r=-1,i=-1,o=0,c=e.length;o<c;o+=1){var a=e[o];a&&-1===r?r=o:a||-1===r||((i=o-1)-r+1>=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}(L,d);J.length?g&&(B.indices=J):B.isMatch=!1}return B}function D(e){for(var t={},n=0,r=e.length;n<r;n+=1){var i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}var K=function(){function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,c=void 0===o?$.location:o,a=i.threshold,s=void 0===a?$.threshold:a,u=i.distance,h=void 0===u?$.distance:u,l=i.includeMatches,f=void 0===l?$.includeMatches:l,d=i.findAllMatches,v=void 0===d?$.findAllMatches:d,g=i.minMatchCharLength,y=void 0===g?$.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?$.isCaseSensitive:p,k=i.ignoreLocation,M=void 0===k?$.ignoreLocation:k;if(r(this,e),this.options={location:c,threshold:s,distance:h,includeMatches:f,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:M},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var b=function(e,t){n.chunks.push({pattern:e,alphabet:D(e),startIndex:t})},x=this.pattern.length;if(x>W){for(var w=0,S=x%W,L=x-S;w<L;)b(this.pattern.substr(w,W),w),w+=W;if(S){var _=x-W;b(this.pattern.substr(_),_)}}else b(this.pattern,0)}}return o(e,[{key:"searchIn",value:function(e){var t=this.options,n=t.isCaseSensitive,r=t.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var i={isMatch:!0,score:0};return r&&(i.indices=[[0,e.length-1]]),i}var o=this.options,c=o.location,a=o.distance,s=o.threshold,u=o.findAllMatches,h=o.minMatchCharLength,l=o.ignoreLocation,d=[],v=0,g=!1;this.chunks.forEach((function(t){var n=t.pattern,i=t.alphabet,o=t.startIndex,y=z(e,n,i,{location:c+o,distance:a,threshold:s,findAllMatches:u,minMatchCharLength:h,includeMatches:r,ignoreLocation:l}),p=y.isMatch,m=y.score,k=y.indices;p&&(g=!0),v+=m,p&&k&&(d=[].concat(f(d),f(k)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=d),y}}]),e}(),T=function(){function e(t){r(this,e),this.pattern=t}return o(e,[{key:"search",value:function(){}}],[{key:"isMultiMatch",value:function(e){return q(e,this.multiRegex)}},{key:"isSingleMatch",value:function(e){return q(e,this.singleRegex)}}]),e}();function q(e,t){var n=e.match(t);return n?n[1]:null}var B=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"multiRegex",get:function(){return/^="(.*)"$/}},{key:"singleRegex",get:function(){return/^=(.*)$/}}]),n}(),J=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"$/}},{key:"singleRegex",get:function(){return/^!(.*)$/}}]),n}(),U=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"prefix-exact"}},{key:"multiRegex",get:function(){return/^\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^\^(.*)$/}}]),n}(),V=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-prefix-exact"}},{key:"multiRegex",get:function(){return/^!\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^!\^(.*)$/}}]),n}(),G=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}],[{key:"type",get:function(){return"suffix-exact"}},{key:"multiRegex",get:function(){return/^"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^(.*)\$$/}}]),n}(),H=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-suffix-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^!(.*)\$$/}}]),n}(),Q=function(e){a(n,T);var t=l(n);function n(e){var i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=o.location,a=void 0===c?$.location:c,s=o.threshold,u=void 0===s?$.threshold:s,h=o.distance,l=void 0===h?$.distance:h,f=o.includeMatches,d=void 0===f?$.includeMatches:f,v=o.findAllMatches,g=void 0===v?$.findAllMatches:v,y=o.minMatchCharLength,p=void 0===y?$.minMatchCharLength:y,m=o.isCaseSensitive,k=void 0===m?$.isCaseSensitive:m,M=o.ignoreLocation,b=void 0===M?$.ignoreLocation:M;return r(this,n),(i=t.call(this,e))._bitapSearch=new K(e,{location:a,threshold:u,distance:l,includeMatches:d,findAllMatches:g,minMatchCharLength:p,isCaseSensitive:k,ignoreLocation:b}),i}return o(n,[{key:"search",value:function(e){return this._bitapSearch.searchIn(e)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"multiRegex",get:function(){return/^"(.*)"$/}},{key:"singleRegex",get:function(){return/^(.*)$/}}]),n}(),X=function(e){a(n,T);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){for(var t,n=0,r=[],i=this.pattern.length;(t=e.indexOf(this.pattern,n))>-1;)n=t+i,r.push([t,n-1]);var o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),n}(),Y=[B,X,U,V,H,G,J,Q],Z=Y.length,ee=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;var te=new Set([Q.type,X.type]),ne=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isCaseSensitive,o=void 0===i?$.isCaseSensitive:i,c=n.includeMatches,a=void 0===c?$.includeMatches:c,s=n.minMatchCharLength,u=void 0===s?$.minMatchCharLength:s,h=n.ignoreLocation,l=void 0===h?$.ignoreLocation:h,f=n.findAllMatches,d=void 0===f?$.findAllMatches:f,v=n.location,g=void 0===v?$.location:v,y=n.threshold,p=void 0===y?$.threshold:y,m=n.distance,k=void 0===m?$.distance:m;r(this,e),this.query=null,this.options={isCaseSensitive:o,includeMatches:a,minMatchCharLength:u,findAllMatches:d,ignoreLocation:l,location:g,threshold:p,distance:k},this.pattern=o?t:t.toLowerCase(),this.query=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.split("|").map((function(e){for(var n=e.trim().split(ee).filter((function(e){return e&&!!e.trim()})),r=[],i=0,o=n.length;i<o;i+=1){for(var c=n[i],a=!1,s=-1;!a&&++s<Z;){var u=Y[s],h=u.isMultiMatch(c);h&&(r.push(new u(h,t)),a=!0)}if(!a)for(s=-1;++s<Z;){var l=Y[s],f=l.isSingleMatch(c);if(f){r.push(new l(f,t));break}}}return r}))}(this.pattern,this.options)}return o(e,[{key:"searchIn",value:function(e){var t=this.query;if(!t)return{isMatch:!1,score:1};var n=this.options,r=n.includeMatches;e=n.isCaseSensitive?e:e.toLowerCase();for(var i=0,o=[],c=0,a=0,s=t.length;a<s;a+=1){var u=t[a];o.length=0,i=0;for(var h=0,l=u.length;h<l;h+=1){var d=u[h],v=d.search(e),g=v.isMatch,y=v.indices,p=v.score;if(!g){c=0,i=0,o.length=0;break}if(i+=1,c+=p,r){var m=d.constructor.type;te.has(m)?o=[].concat(f(o),f(y)):o.push(y)}}if(i){var k={isMatch:!0,score:c/i};return r&&(k.indices=o),k}}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(e,t){return t.useExtendedSearch}}]),e}(),re=[];function ie(e,t){for(var n=0,r=re.length;n<r;n+=1){var i=re[n];if(i.condition(e,t))return new i(e,t)}return new K(e,t)}var oe="$and",ce="$or",ae="$path",se="$val",ue=function(e){return!(!e[oe]&&!e[ce])},he=function(e){return c({},oe,Object.keys(e).map((function(t){return c({},t,e[t])})))};function le(e,t){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).auto,r=void 0===n||n;return ue(e)||(e=he(e)),function e(n){var i=Object.keys(n),o=function(e){return!!e[ae]}(n);if(!o&&i.length>1&&!ue(n))return e(he(n));if(function(e){return!g(e)&&b(e)&&!ue(e)}(n)){var c=o?n[ae]:i[0],a=o?n[se]:n[c];if(!m(a))throw new Error(function(e){return"Invalid value for key ".concat(e)}(c));var s={keyId:C(c),pattern:a};return r&&(s.searcher=ie(a,t)),s}var u={children:[],operator:i[0]};return i.forEach((function(t){var r=n[t];g(r)&&r.forEach((function(t){u.children.push(e(t))}))})),u}(e)}function fe(e,t){var n=e.matches;t.matches=[],x(n)&&n.forEach((function(e){if(x(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function de(e,t){t.score=e.score}var ve=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;r(this,e),this.options=t(t({},$),i),this.options.useExtendedSearch,this._keyStore=new j(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof R))throw new Error("Incorrect 'index' type");this._myIndex=t||P(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){x(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n<r;n+=1){var i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,t.push(i))}return t}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).limit,n=void 0===t?-1:t,r=this.options,i=r.includeMatches,o=r.includeScore,c=r.shouldSort,a=r.sortFn,s=r.ignoreFieldNorm,u=m(e)?m(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,t){var n=t.ignoreFieldNorm,r=void 0===n?$.ignoreFieldNorm:n;e.forEach((function(e){var t=1;e.matches.forEach((function(e){var n=e.key,i=e.norm,o=e.score,c=n?n.weight:null;t*=Math.pow(0===o&&c?Number.EPSILON:o,(c||1)*(r?1:i))})),e.score=t}))}(u,{ignoreFieldNorm:s}),c&&u.sort(a),k(n)&&n>-1&&(u=u.slice(0,n)),function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?$.includeMatches:r,o=n.includeScore,c=void 0===o?$.includeScore:o,a=[];return i&&a.push(fe),c&&a.push(de),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return a.length&&a.forEach((function(t){t(e,r)})),r}))}(u,this._docs,{includeMatches:i,includeScore:o})}},{key:"_searchStringList",value:function(e){var t=ie(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(x(n)){var c=t.searchIn(n),a=c.isMatch,s=c.score,u=c.indices;a&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:u}]})}})),r}},{key:"_searchLogical",value:function(e){var t=this,n=le(e,this.options),r=function e(n,r,i){if(!n.children){var o=n.keyId,c=n.searcher,a=t._findMatches({key:t._keyStore.get(o),value:t._myIndex.getValueForItemAtKeyId(r,o),searcher:c});return a&&a.length?[{idx:i,item:r,matches:a}]:[]}for(var s=[],u=0,h=n.children.length;u<h;u+=1){var l=e(n.children[u],r,i);if(l.length)s.push.apply(s,f(l));else if(n.operator===oe)return[]}return s},i=this._myIndex.records,o={},c=[];return i.forEach((function(e){var t=e.$,i=e.i;if(x(t)){var a=r(n,t,i);a.length&&(o[i]||(o[i]={idx:i,item:t,matches:[]},c.push(o[i])),a.forEach((function(e){var t,n=e.matches;(t=o[i].matches).push.apply(t,f(n))})))}})),c}},{key:"_searchObjectList",value:function(e){var t=this,n=ie(e,this.options),r=this._myIndex,i=r.keys,o=r.records,c=[];return o.forEach((function(e){var r=e.$,o=e.i;if(x(r)){var a=[];i.forEach((function(e,i){a.push.apply(a,f(t._findMatches({key:e,value:r[i],searcher:n})))})),a.length&&c.push({idx:o,item:r,matches:a})}})),c}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!x(n))return[];var i=[];if(g(n))n.forEach((function(e){var n=e.v,o=e.i,c=e.n;if(x(n)){var a=r.searchIn(n),s=a.isMatch,u=a.score,h=a.indices;s&&i.push({score:u,key:t,value:n,idx:o,norm:c,indices:h})}}));else{var o=n.v,c=n.n,a=r.searchIn(o),s=a.isMatch,u=a.score,h=a.indices;s&&i.push({score:u,key:t,value:o,norm:c,indices:h})}return i}}]),e}();ve.version="7.0.0",ve.createIndex=P,ve.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?$.getFn:n,i=t.fieldNormWeight,o=void 0===i?$.fieldNormWeight:i,c=e.keys,a=e.records,s=new R({getFn:r,fieldNormWeight:o});return s.setKeys(c),s.setIndexRecords(a),s},ve.config=$,function(){re.push.apply(re,arguments)}(ne);var ge=ve;module.exports=ge; \ No newline at end of file
diff --git a/includes/node_modules/fuse.js/dist/fuse.min.js b/includes/node_modules/fuse.js/dist/fuse.min.js
new file mode 100644
index 0000000..1f534ad
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.min.js
@@ -0,0 +1,9 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){c(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,v(r.key),r)}}function o(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function h(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=s(e);if(t){var i=s(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return h(this,n)}}function f(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function v(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function g(e){return Array.isArray?Array.isArray(e):"[object Array]"===S(e)}var y=1/0;function p(e){return null==e?"":function(e){if("string"==typeof e)return e;var t=e+"";return"0"==t&&1/e==-y?"-0":t}(e)}function m(e){return"string"==typeof e}function k(e){return"number"==typeof e}function M(e){return!0===e||!1===e||function(e){return b(e)&&null!==e}(e)&&"[object Boolean]"==S(e)}function b(e){return"object"===n(e)}function x(e){return null!=e}function w(e){return!e.trim().length}function S(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var L=function(e){return"Missing ".concat(e," property in key")},_=function(e){return"Property 'weight' in key '".concat(e,"' must be a positive integer")},O=Object.prototype.hasOwnProperty,j=function(){function e(t){var n=this;r(this,e),this._keys=[],this._keyMap={};var i=0;t.forEach((function(e){var t=A(e);n._keys.push(t),n._keyMap[t.id]=t,i+=t.weight})),this._keys.forEach((function(e){e.weight/=i}))}return o(e,[{key:"get",value:function(e){return this._keyMap[e]}},{key:"keys",value:function(){return this._keys}},{key:"toJSON",value:function(){return JSON.stringify(this._keys)}}]),e}();function A(e){var t=null,n=null,r=null,i=1,o=null;if(m(e)||g(e))r=e,t=I(e),n=C(e);else{if(!O.call(e,"name"))throw new Error(L("name"));var c=e.name;if(r=c,O.call(e,"weight")&&(i=e.weight)<=0)throw new Error(_(c));t=I(c),n=C(c),o=e.getFn}return{path:t,id:n,weight:i,src:r,getFn:o}}function I(e){return g(e)?e:e.split(".")}function C(e){return g(e)?e.join("."):e}var E={useExtendedSearch:!1,getFn:function(e,t){var n=[],r=!1;return function e(t,i,o){if(x(t))if(i[o]){var c=t[i[o]];if(!x(c))return;if(o===i.length-1&&(m(c)||k(c)||M(c)))n.push(p(c));else if(g(c)){r=!0;for(var a=0,s=c.length;a<s;a+=1)e(c[a],i,o+1)}else i.length&&e(c,i,o+1)}else n.push(t)}(e,m(t)?t.split("."):t,0),r?n:n[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},$=t(t(t(t({},{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:function(e,t){return e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1}}),{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1}),{location:0,threshold:.6,distance:100}),E),F=/[^ ]+/g,R=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?$.getFn:n,o=t.fieldNormWeight,c=void 0===o?$.fieldNormWeight:o;r(this,e),this.norm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(F).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),c=parseFloat(Math.round(o*r)/r);return n.set(i,c),c},clear:function(){n.clear()}}}(c,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,m(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();m(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t<n;t+=1)this.records[t].i-=1}},{key:"getValueForItemAtKeyId",value:function(e,t){return e[this._keysMap[t]]}},{key:"size",value:function(){return this.records.length}},{key:"_addString",value:function(e,t){if(x(e)&&!w(e)){var n={v:e,i:t,n:this.norm.get(e)};this.records.push(n)}}},{key:"_addObject",value:function(e,t){var n=this,r={i:t,$:{}};this.keys.forEach((function(t,i){var o=t.getFn?t.getFn(e):n.getFn(e,t.path);if(x(o))if(g(o)){for(var c=[],a=[{nestedArrIndex:-1,value:o}];a.length;){var s=a.pop(),u=s.nestedArrIndex,h=s.value;if(x(h))if(m(h)&&!w(h)){var l={v:h,i:u,n:n.norm.get(h)};c.push(l)}else g(h)&&h.forEach((function(e,t){a.push({nestedArrIndex:t,value:e})}))}r.$[i]=c}else if(m(o)&&!w(o)){var f={v:o,n:n.norm.get(o)};r.$[i]=f}})),this.records.push(r)}},{key:"toJSON",value:function(){return{keys:this.keys,records:this.records}}}]),e}();function P(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?$.getFn:r,o=n.fieldNormWeight,c=void 0===o?$.fieldNormWeight:o,a=new R({getFn:i,fieldNormWeight:c});return a.setKeys(e.map(A)),a.setSources(t),a.create(),a}function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,c=t.expectedLocation,a=void 0===c?0:c,s=t.distance,u=void 0===s?$.distance:s,h=t.ignoreLocation,l=void 0===h?$.ignoreLocation:h,f=r/e.length;if(l)return f;var d=Math.abs(a-o);return u?f+d/u:d?1:f}var W=32;function T(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?$.location:i,c=r.distance,a=void 0===c?$.distance:c,s=r.threshold,u=void 0===s?$.threshold:s,h=r.findAllMatches,l=void 0===h?$.findAllMatches:h,f=r.minMatchCharLength,d=void 0===f?$.minMatchCharLength:f,v=r.includeMatches,g=void 0===v?$.includeMatches:v,y=r.ignoreLocation,p=void 0===y?$.ignoreLocation:y;if(t.length>W)throw new Error("Pattern length exceeds max of ".concat(W,"."));for(var m,k=t.length,M=e.length,b=Math.max(0,Math.min(o,M)),x=u,w=b,S=d>1||g,L=S?Array(M):[];(m=e.indexOf(t,w))>-1;){var _=N(t,{currentLocation:m,expectedLocation:b,distance:a,ignoreLocation:p});if(x=Math.min(_,x),w=m+k,S)for(var O=0;O<k;)L[m+O]=1,O+=1}w=-1;for(var j=[],A=1,I=k+M,C=1<<k-1,E=0;E<k;E+=1){for(var F=0,R=I;F<R;)N(t,{errors:E,currentLocation:b+R,expectedLocation:b,distance:a,ignoreLocation:p})<=x?F=R:I=R,R=Math.floor((I-F)/2+F);I=R;var P=Math.max(1,b-R+1),T=l?M:Math.min(b+R,M)+k,z=Array(T+2);z[T+1]=(1<<E)-1;for(var D=T;D>=P;D-=1){var K=D-1,q=n[e.charAt(K)];if(S&&(L[K]=+!!q),z[D]=(z[D+1]<<1|1)&q,E&&(z[D]|=(j[D+1]|j[D])<<1|1|j[D+1]),z[D]&C&&(A=N(t,{errors:E,currentLocation:K,expectedLocation:b,distance:a,ignoreLocation:p}))<=x){if(x=A,(w=K)<=b)break;P=Math.max(1,2*b-w)}}if(N(t,{errors:E+1,currentLocation:b,expectedLocation:b,distance:a,ignoreLocation:p})>x)break;j=z}var B={isMatch:w>=0,score:Math.max(.001,A)};if(S){var J=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$.minMatchCharLength,n=[],r=-1,i=-1,o=0,c=e.length;o<c;o+=1){var a=e[o];a&&-1===r?r=o:a||-1===r||((i=o-1)-r+1>=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}(L,d);J.length?g&&(B.indices=J):B.isMatch=!1}return B}function z(e){for(var t={},n=0,r=e.length;n<r;n+=1){var i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}var D=function(){function e(t){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,c=void 0===o?$.location:o,a=i.threshold,s=void 0===a?$.threshold:a,u=i.distance,h=void 0===u?$.distance:u,l=i.includeMatches,f=void 0===l?$.includeMatches:l,d=i.findAllMatches,v=void 0===d?$.findAllMatches:d,g=i.minMatchCharLength,y=void 0===g?$.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?$.isCaseSensitive:p,k=i.ignoreLocation,M=void 0===k?$.ignoreLocation:k;if(r(this,e),this.options={location:c,threshold:s,distance:h,includeMatches:f,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:M},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var b=function(e,t){n.chunks.push({pattern:e,alphabet:z(e),startIndex:t})},x=this.pattern.length;if(x>W){for(var w=0,S=x%W,L=x-S;w<L;)b(this.pattern.substr(w,W),w),w+=W;if(S){var _=x-W;b(this.pattern.substr(_),_)}}else b(this.pattern,0)}}return o(e,[{key:"searchIn",value:function(e){var t=this.options,n=t.isCaseSensitive,r=t.includeMatches;if(n||(e=e.toLowerCase()),this.pattern===e){var i={isMatch:!0,score:0};return r&&(i.indices=[[0,e.length-1]]),i}var o=this.options,c=o.location,a=o.distance,s=o.threshold,u=o.findAllMatches,h=o.minMatchCharLength,l=o.ignoreLocation,d=[],v=0,g=!1;this.chunks.forEach((function(t){var n=t.pattern,i=t.alphabet,o=t.startIndex,y=T(e,n,i,{location:c+o,distance:a,threshold:s,findAllMatches:u,minMatchCharLength:h,includeMatches:r,ignoreLocation:l}),p=y.isMatch,m=y.score,k=y.indices;p&&(g=!0),v+=m,p&&k&&(d=[].concat(f(d),f(k)))}));var y={isMatch:g,score:g?v/this.chunks.length:1};return g&&r&&(y.indices=d),y}}]),e}(),K=function(){function e(t){r(this,e),this.pattern=t}return o(e,[{key:"search",value:function(){}}],[{key:"isMultiMatch",value:function(e){return q(e,this.multiRegex)}},{key:"isSingleMatch",value:function(e){return q(e,this.singleRegex)}}]),e}();function q(e,t){var n=e.match(t);return n?n[1]:null}var B=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"exact"}},{key:"multiRegex",get:function(){return/^="(.*)"$/}},{key:"singleRegex",get:function(){return/^=(.*)$/}}]),n}(K),J=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"$/}},{key:"singleRegex",get:function(){return/^!(.*)$/}}]),n}(K),U=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}}],[{key:"type",get:function(){return"prefix-exact"}},{key:"multiRegex",get:function(){return/^\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^\^(.*)$/}}]),n}(K),V=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-prefix-exact"}},{key:"multiRegex",get:function(){return/^!\^"(.*)"$/}},{key:"singleRegex",get:function(){return/^!\^(.*)$/}}]),n}(K),G=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}],[{key:"type",get:function(){return"suffix-exact"}},{key:"multiRegex",get:function(){return/^"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^(.*)\$$/}}]),n}(K),H=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){var t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}}],[{key:"type",get:function(){return"inverse-suffix-exact"}},{key:"multiRegex",get:function(){return/^!"(.*)"\$$/}},{key:"singleRegex",get:function(){return/^!(.*)\$$/}}]),n}(K),Q=function(e){a(n,e);var t=l(n);function n(e){var i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=o.location,a=void 0===c?$.location:c,s=o.threshold,u=void 0===s?$.threshold:s,h=o.distance,l=void 0===h?$.distance:h,f=o.includeMatches,d=void 0===f?$.includeMatches:f,v=o.findAllMatches,g=void 0===v?$.findAllMatches:v,y=o.minMatchCharLength,p=void 0===y?$.minMatchCharLength:y,m=o.isCaseSensitive,k=void 0===m?$.isCaseSensitive:m,M=o.ignoreLocation,b=void 0===M?$.ignoreLocation:M;return r(this,n),(i=t.call(this,e))._bitapSearch=new D(e,{location:a,threshold:u,distance:l,includeMatches:d,findAllMatches:g,minMatchCharLength:p,isCaseSensitive:k,ignoreLocation:b}),i}return o(n,[{key:"search",value:function(e){return this._bitapSearch.searchIn(e)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"multiRegex",get:function(){return/^"(.*)"$/}},{key:"singleRegex",get:function(){return/^(.*)$/}}]),n}(K),X=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){for(var t,n=0,r=[],i=this.pattern.length;(t=e.indexOf(this.pattern,n))>-1;)n=t+i,r.push([t,n-1]);var o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),n}(K),Y=[B,X,U,V,H,G,J,Q],Z=Y.length,ee=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,te=new Set([Q.type,X.type]),ne=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isCaseSensitive,o=void 0===i?$.isCaseSensitive:i,c=n.includeMatches,a=void 0===c?$.includeMatches:c,s=n.minMatchCharLength,u=void 0===s?$.minMatchCharLength:s,h=n.ignoreLocation,l=void 0===h?$.ignoreLocation:h,f=n.findAllMatches,d=void 0===f?$.findAllMatches:f,v=n.location,g=void 0===v?$.location:v,y=n.threshold,p=void 0===y?$.threshold:y,m=n.distance,k=void 0===m?$.distance:m;r(this,e),this.query=null,this.options={isCaseSensitive:o,includeMatches:a,minMatchCharLength:u,findAllMatches:d,ignoreLocation:l,location:g,threshold:p,distance:k},this.pattern=o?t:t.toLowerCase(),this.query=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.split("|").map((function(e){for(var n=e.trim().split(ee).filter((function(e){return e&&!!e.trim()})),r=[],i=0,o=n.length;i<o;i+=1){for(var c=n[i],a=!1,s=-1;!a&&++s<Z;){var u=Y[s],h=u.isMultiMatch(c);h&&(r.push(new u(h,t)),a=!0)}if(!a)for(s=-1;++s<Z;){var l=Y[s],f=l.isSingleMatch(c);if(f){r.push(new l(f,t));break}}}return r}))}(this.pattern,this.options)}return o(e,[{key:"searchIn",value:function(e){var t=this.query;if(!t)return{isMatch:!1,score:1};var n=this.options,r=n.includeMatches;e=n.isCaseSensitive?e:e.toLowerCase();for(var i=0,o=[],c=0,a=0,s=t.length;a<s;a+=1){var u=t[a];o.length=0,i=0;for(var h=0,l=u.length;h<l;h+=1){var d=u[h],v=d.search(e),g=v.isMatch,y=v.indices,p=v.score;if(!g){c=0,i=0,o.length=0;break}if(i+=1,c+=p,r){var m=d.constructor.type;te.has(m)?o=[].concat(f(o),f(y)):o.push(y)}}if(i){var k={isMatch:!0,score:c/i};return r&&(k.indices=o),k}}return{isMatch:!1,score:1}}}],[{key:"condition",value:function(e,t){return t.useExtendedSearch}}]),e}(),re=[];function ie(e,t){for(var n=0,r=re.length;n<r;n+=1){var i=re[n];if(i.condition(e,t))return new i(e,t)}return new D(e,t)}var oe="$and",ce="$or",ae="$path",se="$val",ue=function(e){return!(!e[oe]&&!e[ce])},he=function(e){return c({},oe,Object.keys(e).map((function(t){return c({},t,e[t])})))};function le(e,t){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).auto,r=void 0===n||n;return ue(e)||(e=he(e)),function e(n){var i=Object.keys(n),o=function(e){return!!e[ae]}(n);if(!o&&i.length>1&&!ue(n))return e(he(n));if(function(e){return!g(e)&&b(e)&&!ue(e)}(n)){var c=o?n[ae]:i[0],a=o?n[se]:n[c];if(!m(a))throw new Error(function(e){return"Invalid value for key ".concat(e)}(c));var s={keyId:C(c),pattern:a};return r&&(s.searcher=ie(a,t)),s}var u={children:[],operator:i[0]};return i.forEach((function(t){var r=n[t];g(r)&&r.forEach((function(t){u.children.push(e(t))}))})),u}(e)}function fe(e,t){var n=e.matches;t.matches=[],x(n)&&n.forEach((function(e){if(x(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function de(e,t){t.score=e.score}var ve=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;r(this,e),this.options=t(t({},$),i),this.options.useExtendedSearch,this._keyStore=new j(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof R))throw new Error("Incorrect 'index' type");this._myIndex=t||P(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){x(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n<r;n+=1){var i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,t.push(i))}return t}},{key:"removeAt",value:function(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}},{key:"getIndex",value:function(){return this._myIndex}},{key:"search",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).limit,n=void 0===t?-1:t,r=this.options,i=r.includeMatches,o=r.includeScore,c=r.shouldSort,a=r.sortFn,s=r.ignoreFieldNorm,u=m(e)?m(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,t){var n=t.ignoreFieldNorm,r=void 0===n?$.ignoreFieldNorm:n;e.forEach((function(e){var t=1;e.matches.forEach((function(e){var n=e.key,i=e.norm,o=e.score,c=n?n.weight:null;t*=Math.pow(0===o&&c?Number.EPSILON:o,(c||1)*(r?1:i))})),e.score=t}))}(u,{ignoreFieldNorm:s}),c&&u.sort(a),k(n)&&n>-1&&(u=u.slice(0,n)),function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?$.includeMatches:r,o=n.includeScore,c=void 0===o?$.includeScore:o,a=[];return i&&a.push(fe),c&&a.push(de),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return a.length&&a.forEach((function(t){t(e,r)})),r}))}(u,this._docs,{includeMatches:i,includeScore:o})}},{key:"_searchStringList",value:function(e){var t=ie(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(x(n)){var c=t.searchIn(n),a=c.isMatch,s=c.score,u=c.indices;a&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:u}]})}})),r}},{key:"_searchLogical",value:function(e){var t=this,n=le(e,this.options),r=function e(n,r,i){if(!n.children){var o=n.keyId,c=n.searcher,a=t._findMatches({key:t._keyStore.get(o),value:t._myIndex.getValueForItemAtKeyId(r,o),searcher:c});return a&&a.length?[{idx:i,item:r,matches:a}]:[]}for(var s=[],u=0,h=n.children.length;u<h;u+=1){var l=e(n.children[u],r,i);if(l.length)s.push.apply(s,f(l));else if(n.operator===oe)return[]}return s},i=this._myIndex.records,o={},c=[];return i.forEach((function(e){var t=e.$,i=e.i;if(x(t)){var a=r(n,t,i);a.length&&(o[i]||(o[i]={idx:i,item:t,matches:[]},c.push(o[i])),a.forEach((function(e){var t,n=e.matches;(t=o[i].matches).push.apply(t,f(n))})))}})),c}},{key:"_searchObjectList",value:function(e){var t=this,n=ie(e,this.options),r=this._myIndex,i=r.keys,o=r.records,c=[];return o.forEach((function(e){var r=e.$,o=e.i;if(x(r)){var a=[];i.forEach((function(e,i){a.push.apply(a,f(t._findMatches({key:e,value:r[i],searcher:n})))})),a.length&&c.push({idx:o,item:r,matches:a})}})),c}},{key:"_findMatches",value:function(e){var t=e.key,n=e.value,r=e.searcher;if(!x(n))return[];var i=[];if(g(n))n.forEach((function(e){var n=e.v,o=e.i,c=e.n;if(x(n)){var a=r.searchIn(n),s=a.isMatch,u=a.score,h=a.indices;s&&i.push({score:u,key:t,value:n,idx:o,norm:c,indices:h})}}));else{var o=n.v,c=n.n,a=r.searchIn(o),s=a.isMatch,u=a.score,h=a.indices;s&&i.push({score:u,key:t,value:o,norm:c,indices:h})}return i}}]),e}();return ve.version="7.0.0",ve.createIndex=P,ve.parseIndex=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?$.getFn:n,i=t.fieldNormWeight,o=void 0===i?$.fieldNormWeight:i,c=e.keys,a=e.records,s=new R({getFn:r,fieldNormWeight:o});return s.setKeys(c),s.setIndexRecords(a),s},ve.config=$,function(){re.push.apply(re,arguments)}(ne),ve},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t(); \ No newline at end of file
diff --git a/includes/node_modules/fuse.js/dist/fuse.min.mjs b/includes/node_modules/fuse.js/dist/fuse.min.mjs
new file mode 100644
index 0000000..9ea5dd7
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.min.mjs
@@ -0,0 +1,9 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+function t(t){return Array.isArray?Array.isArray(t):"[object Array]"===a(t)}const e=1/0;function n(t){return null==t?"":function(t){if("string"==typeof t)return t;let n=t+"";return"0"==n&&1/t==-e?"-0":n}(t)}function s(t){return"string"==typeof t}function i(t){return"number"==typeof t}function r(t){return!0===t||!1===t||function(t){return c(t)&&null!==t}(t)&&"[object Boolean]"==a(t)}function c(t){return"object"==typeof t}function o(t){return null!=t}function h(t){return!t.trim().length}function a(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const l=t=>`Missing ${t} property in key`,u=t=>`Property 'weight' in key '${t}' must be a positive integer`,d=Object.prototype.hasOwnProperty;class g{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach((t=>{let n=f(t);this._keys.push(n),this._keyMap[n.id]=n,e+=n.weight})),this._keys.forEach((t=>{t.weight/=e}))}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function f(e){let n=null,i=null,r=null,c=1,o=null;if(s(e)||t(e))r=e,n=p(e),i=m(e);else{if(!d.call(e,"name"))throw new Error(l("name"));const t=e.name;if(r=t,d.call(e,"weight")&&(c=e.weight,c<=0))throw new Error(u(t));n=p(t),i=m(t),o=e.getFn}return{path:n,id:i,weight:c,src:r,getFn:o}}function p(e){return t(e)?e:e.split(".")}function m(e){return t(e)?e.join("."):e}var M={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...{useExtendedSearch:!1,getFn:function(e,c){let h=[],a=!1;const l=(e,c,u)=>{if(o(e))if(c[u]){const d=e[c[u]];if(!o(d))return;if(u===c.length-1&&(s(d)||i(d)||r(d)))h.push(n(d));else if(t(d)){a=!0;for(let t=0,e=d.length;t<e;t+=1)l(d[t],c,u+1)}else c.length&&l(d,c,u+1)}else h.push(e)};return l(e,s(c)?c.split("."):c,0),a?h:h[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const x=/[^ ]+/g;class y{constructor({getFn:t=M.getFn,fieldNormWeight:e=M.fieldNormWeight}={}){this.norm=function(t=1,e=3){const n=new Map,s=Math.pow(10,e);return{get(e){const i=e.match(x).length;if(n.has(i))return n.get(i);const r=1/Math.pow(i,.5*t),c=parseFloat(Math.round(r*s)/s);return n.set(i,c),c},clear(){n.clear()}}}(e,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach(((t,e)=>{this._keysMap[t.id]=e}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,s(this.docs[0])?this.docs.forEach(((t,e)=>{this._addString(t,e)})):this.docs.forEach(((t,e)=>{this._addObject(t,e)})),this.norm.clear())}add(t){const e=this.size();s(t)?this._addString(t,e):this._addObject(t,e)}removeAt(t){this.records.splice(t,1);for(let e=t,n=this.size();e<n;e+=1)this.records[e].i-=1}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_addString(t,e){if(!o(t)||h(t))return;let n={v:t,i:e,n:this.norm.get(t)};this.records.push(n)}_addObject(e,n){let i={i:n,$:{}};this.keys.forEach(((n,r)=>{let c=n.getFn?n.getFn(e):this.getFn(e,n.path);if(o(c))if(t(c)){let e=[];const n=[{nestedArrIndex:-1,value:c}];for(;n.length;){const{nestedArrIndex:i,value:r}=n.pop();if(o(r))if(s(r)&&!h(r)){let t={v:r,i:i,n:this.norm.get(r)};e.push(t)}else t(r)&&r.forEach(((t,e)=>{n.push({nestedArrIndex:e,value:t})}))}i.$[r]=e}else if(s(c)&&!h(c)){let t={v:c,n:this.norm.get(c)};i.$[r]=t}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function L(t,e,{getFn:n=M.getFn,fieldNormWeight:s=M.fieldNormWeight}={}){const i=new y({getFn:n,fieldNormWeight:s});return i.setKeys(t.map(f)),i.setSources(e),i.create(),i}function k(t,{errors:e=0,currentLocation:n=0,expectedLocation:s=0,distance:i=M.distance,ignoreLocation:r=M.ignoreLocation}={}){const c=e/t.length;if(r)return c;const o=Math.abs(s-n);return i?c+o/i:o?1:c}const _=32;function v(t,e,n,{location:s=M.location,distance:i=M.distance,threshold:r=M.threshold,findAllMatches:c=M.findAllMatches,minMatchCharLength:o=M.minMatchCharLength,includeMatches:h=M.includeMatches,ignoreLocation:a=M.ignoreLocation}={}){if(e.length>_)throw new Error(`Pattern length exceeds max of ${_}.`);const l=e.length,u=t.length,d=Math.max(0,Math.min(s,u));let g=r,f=d;const p=o>1||h,m=p?Array(u):[];let x;for(;(x=t.indexOf(e,f))>-1;){let t=k(e,{currentLocation:x,expectedLocation:d,distance:i,ignoreLocation:a});if(g=Math.min(t,g),f=x+l,p){let t=0;for(;t<l;)m[x+t]=1,t+=1}}f=-1;let y=[],L=1,v=l+u;const S=1<<l-1;for(let s=0;s<l;s+=1){let r=0,o=v;for(;r<o;){k(e,{errors:s,currentLocation:d+o,expectedLocation:d,distance:i,ignoreLocation:a})<=g?r=o:v=o,o=Math.floor((v-r)/2+r)}v=o;let h=Math.max(1,d-o+1),M=c?u:Math.min(d+o,u)+l,x=Array(M+2);x[M+1]=(1<<s)-1;for(let r=M;r>=h;r-=1){let c=r-1,o=n[t.charAt(c)];if(p&&(m[c]=+!!o),x[r]=(x[r+1]<<1|1)&o,s&&(x[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),x[r]&S&&(L=k(e,{errors:s,currentLocation:c,expectedLocation:d,distance:i,ignoreLocation:a}),L<=g)){if(g=L,f=c,f<=d)break;h=Math.max(1,2*d-f)}}if(k(e,{errors:s+1,currentLocation:d,expectedLocation:d,distance:i,ignoreLocation:a})>g)break;y=x}const C={isMatch:f>=0,score:Math.max(.001,L)};if(p){const t=function(t=[],e=M.minMatchCharLength){let n=[],s=-1,i=-1,r=0;for(let c=t.length;r<c;r+=1){let c=t[r];c&&-1===s?s=r:c||-1===s||(i=r-1,i-s+1>=e&&n.push([s,i]),s=-1)}return t[r-1]&&r-s>=e&&n.push([s,r-1]),n}(m,o);t.length?h&&(C.indices=t):C.isMatch=!1}return C}function S(t){let e={};for(let n=0,s=t.length;n<s;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<s-n-1}return e}class C{constructor(t,{location:e=M.location,threshold:n=M.threshold,distance:s=M.distance,includeMatches:i=M.includeMatches,findAllMatches:r=M.findAllMatches,minMatchCharLength:c=M.minMatchCharLength,isCaseSensitive:o=M.isCaseSensitive,ignoreLocation:h=M.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:s,includeMatches:i,findAllMatches:r,minMatchCharLength:c,isCaseSensitive:o,ignoreLocation:h},this.pattern=o?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const a=(t,e)=>{this.chunks.push({pattern:t,alphabet:S(t),startIndex:e})},l=this.pattern.length;if(l>_){let t=0;const e=l%_,n=l-e;for(;t<n;)a(this.pattern.substr(t,_),t),t+=_;if(e){const t=l-_;a(this.pattern.substr(t),t)}}else a(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:n}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let e={isMatch:!0,score:0};return n&&(e.indices=[[0,t.length-1]]),e}const{location:s,distance:i,threshold:r,findAllMatches:c,minMatchCharLength:o,ignoreLocation:h}=this.options;let a=[],l=0,u=!1;this.chunks.forEach((({pattern:e,alphabet:d,startIndex:g})=>{const{isMatch:f,score:p,indices:m}=v(t,e,d,{location:s+g,distance:i,threshold:r,findAllMatches:c,minMatchCharLength:o,includeMatches:n,ignoreLocation:h});f&&(u=!0),l+=p,f&&m&&(a=[...a,...m])}));let d={isMatch:u,score:u?l/this.chunks.length:1};return u&&n&&(d.indices=a),d}}class I{constructor(t){this.pattern=t}static isMultiMatch(t){return w(t,this.multiRegex)}static isSingleMatch(t){return w(t,this.singleRegex)}search(){}}function w(t,e){const n=t.match(e);return n?n[1]:null}class $ extends I{constructor(t,{location:e=M.location,threshold:n=M.threshold,distance:s=M.distance,includeMatches:i=M.includeMatches,findAllMatches:r=M.findAllMatches,minMatchCharLength:c=M.minMatchCharLength,isCaseSensitive:o=M.isCaseSensitive,ignoreLocation:h=M.ignoreLocation}={}){super(t),this._bitapSearch=new C(t,{location:e,threshold:n,distance:s,includeMatches:i,findAllMatches:r,minMatchCharLength:c,isCaseSensitive:o,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class A extends I{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e,n=0;const s=[],i=this.pattern.length;for(;(e=t.indexOf(this.pattern,n))>-1;)n=e+i,s.push([e,n-1]);const r=!!s.length;return{isMatch:r,score:r?0:1,indices:s}}}const E=[class extends I{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const e=t===this.pattern;return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},A,class extends I{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const e=t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,this.pattern.length-1]}}},class extends I{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const e=!t.startsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends I{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const e=!t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},class extends I{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const e=t.endsWith(this.pattern);return{isMatch:e,score:e?0:1,indices:[t.length-this.pattern.length,t.length-1]}}},class extends I{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const e=-1===t.indexOf(this.pattern);return{isMatch:e,score:e?0:1,indices:[0,t.length-1]}}},$],b=E.length,F=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const N=new Set([$.type,A.type]);class R{constructor(t,{isCaseSensitive:e=M.isCaseSensitive,includeMatches:n=M.includeMatches,minMatchCharLength:s=M.minMatchCharLength,ignoreLocation:i=M.ignoreLocation,findAllMatches:r=M.findAllMatches,location:c=M.location,threshold:o=M.threshold,distance:h=M.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:n,minMatchCharLength:s,findAllMatches:r,ignoreLocation:i,location:c,threshold:o,distance:h},this.pattern=e?t:t.toLowerCase(),this.query=function(t,e={}){return t.split("|").map((t=>{let n=t.trim().split(F).filter((t=>t&&!!t.trim())),s=[];for(let t=0,i=n.length;t<i;t+=1){const i=n[t];let r=!1,c=-1;for(;!r&&++c<b;){const t=E[c];let n=t.isMultiMatch(i);n&&(s.push(new t(n,e)),r=!0)}if(!r)for(c=-1;++c<b;){const t=E[c];let n=t.isSingleMatch(i);if(n){s.push(new t(n,e));break}}}return s}))}(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:s}=this.options;t=s?t:t.toLowerCase();let i=0,r=[],c=0;for(let s=0,o=e.length;s<o;s+=1){const o=e[s];r.length=0,i=0;for(let e=0,s=o.length;e<s;e+=1){const s=o[e],{isMatch:h,indices:a,score:l}=s.search(t);if(!h){c=0,i=0,r.length=0;break}if(i+=1,c+=l,n){const t=s.constructor.type;N.has(t)?r=[...r,...a]:r.push(a)}}if(i){let t={isMatch:!0,score:c/i};return n&&(t.indices=r),t}}return{isMatch:!1,score:1}}}const O=[];function j(t,e){for(let n=0,s=O.length;n<s;n+=1){let s=O[n];if(s.condition(t,e))return new s(t,e)}return new C(t,e)}const W="$and",z="$or",K="$path",P="$val",q=t=>!(!t[W]&&!t[z]),J=t=>({[W]:Object.keys(t).map((e=>({[e]:t[e]})))});function V(e,n,{auto:i=!0}={}){const r=e=>{let o=Object.keys(e);const h=(t=>!!t[K])(e);if(!h&&o.length>1&&!q(e))return r(J(e));if((e=>!t(e)&&c(e)&&!q(e))(e)){const t=h?e[K]:o[0],r=h?e[P]:e[t];if(!s(r))throw new Error((t=>`Invalid value for key ${t}`)(t));const c={keyId:m(t),pattern:r};return i&&(c.searcher=j(r,n)),c}let a={children:[],operator:o[0]};return o.forEach((n=>{const s=e[n];t(s)&&s.forEach((t=>{a.children.push(r(t))}))})),a};return q(e)||(e=J(e)),r(e)}function B(t,e){const n=t.matches;e.matches=[],o(n)&&n.forEach((t=>{if(!o(t.indices)||!t.indices.length)return;const{indices:n,value:s}=t;let i={indices:n,value:s};t.key&&(i.key=t.key.src),t.idx>-1&&(i.refIndex=t.idx),e.matches.push(i)}))}function U(t,e){e.score=t.score}class D{constructor(t,e={},n){this.options={...M,...e},this.options.useExtendedSearch,this._keyStore=new g(this.options.keys),this.setCollection(t,n)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof y))throw new Error("Incorrect 'index' type");this._myIndex=e||L(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){o(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=(()=>!1)){const e=[];for(let n=0,s=this._docs.length;n<s;n+=1){const i=this._docs[n];t(i,n)&&(this.removeAt(n),n-=1,s-=1,e.push(i))}return e}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:e=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:c,sortFn:o,ignoreFieldNorm:h}=this.options;let a=s(t)?s(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return function(t,{ignoreFieldNorm:e=M.ignoreFieldNorm}){t.forEach((t=>{let n=1;t.matches.forEach((({key:t,norm:s,score:i})=>{const r=t?t.weight:null;n*=Math.pow(0===i&&r?Number.EPSILON:i,(r||1)*(e?1:s))})),t.score=n}))}(a,{ignoreFieldNorm:h}),c&&a.sort(o),i(e)&&e>-1&&(a=a.slice(0,e)),function(t,e,{includeMatches:n=M.includeMatches,includeScore:s=M.includeScore}={}){const i=[];return n&&i.push(B),s&&i.push(U),t.map((t=>{const{idx:n}=t,s={item:e[n],refIndex:n};return i.length&&i.forEach((e=>{e(t,s)})),s}))}(a,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(t){const e=j(t,this.options),{records:n}=this._myIndex,s=[];return n.forEach((({v:t,i:n,n:i})=>{if(!o(t))return;const{isMatch:r,score:c,indices:h}=e.searchIn(t);r&&s.push({item:t,idx:n,matches:[{score:c,value:t,norm:i,indices:h}]})})),s}_searchLogical(t){const e=V(t,this.options),n=(t,e,s)=>{if(!t.children){const{keyId:n,searcher:i}=t,r=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(e,n),searcher:i});return r&&r.length?[{idx:s,item:e,matches:r}]:[]}const i=[];for(let r=0,c=t.children.length;r<c;r+=1){const c=t.children[r],o=n(c,e,s);if(o.length)i.push(...o);else if(t.operator===W)return[]}return i},s=this._myIndex.records,i={},r=[];return s.forEach((({$:t,i:s})=>{if(o(t)){let c=n(e,t,s);c.length&&(i[s]||(i[s]={idx:s,item:t,matches:[]},r.push(i[s])),c.forEach((({matches:t})=>{i[s].matches.push(...t)})))}})),r}_searchObjectList(t){const e=j(t,this.options),{keys:n,records:s}=this._myIndex,i=[];return s.forEach((({$:t,i:s})=>{if(!o(t))return;let r=[];n.forEach(((n,s)=>{r.push(...this._findMatches({key:n,value:t[s],searcher:e}))})),r.length&&i.push({idx:s,item:t,matches:r})})),i}_findMatches({key:e,value:n,searcher:s}){if(!o(n))return[];let i=[];if(t(n))n.forEach((({v:t,i:n,n:r})=>{if(!o(t))return;const{isMatch:c,score:h,indices:a}=s.searchIn(t);c&&i.push({score:h,key:e,value:t,idx:n,norm:r,indices:a})}));else{const{v:t,n:r}=n,{isMatch:c,score:o,indices:h}=s.searchIn(t);c&&i.push({score:o,key:e,value:t,norm:r,indices:h})}return i}}D.version="7.0.0",D.createIndex=L,D.parseIndex=function(t,{getFn:e=M.getFn,fieldNormWeight:n=M.fieldNormWeight}={}){const{keys:s,records:i}=t,r=new y({getFn:e,fieldNormWeight:n});return r.setKeys(s),r.setIndexRecords(i),r},D.config=M,function(...t){O.push(...t)}(R);export{D as default}; \ No newline at end of file
diff --git a/includes/node_modules/fuse.js/dist/fuse.mjs b/includes/node_modules/fuse.js/dist/fuse.mjs
new file mode 100644
index 0000000..4a9d254
--- /dev/null
+++ b/includes/node_modules/fuse.js/dist/fuse.mjs
@@ -0,0 +1,1778 @@
+/**
+ * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io)
+ *
+ * Copyright (c) 2023 Kiro Risk (http://kiro.me)
+ * All Rights Reserved. Apache Software License 2.0
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+function isArray(value) {
+ return !Array.isArray
+ ? getTag(value) === '[object Array]'
+ : Array.isArray(value)
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
+const INFINITY = 1 / 0;
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value
+ }
+ let result = value + '';
+ return result == '0' && 1 / value == -INFINITY ? '-0' : result
+}
+
+function toString(value) {
+ return value == null ? '' : baseToString(value)
+}
+
+function isString(value) {
+ return typeof value === 'string'
+}
+
+function isNumber(value) {
+ return typeof value === 'number'
+}
+
+// Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
+function isBoolean(value) {
+ return (
+ value === true ||
+ value === false ||
+ (isObjectLike(value) && getTag(value) == '[object Boolean]')
+ )
+}
+
+function isObject(value) {
+ return typeof value === 'object'
+}
+
+// Checks if `value` is object-like.
+function isObjectLike(value) {
+ return isObject(value) && value !== null
+}
+
+function isDefined(value) {
+ return value !== undefined && value !== null
+}
+
+function isBlank(value) {
+ return !value.trim().length
+}
+
+// Gets the `toStringTag` of `value`.
+// Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
+function getTag(value) {
+ return value == null
+ ? value === undefined
+ ? '[object Undefined]'
+ : '[object Null]'
+ : Object.prototype.toString.call(value)
+}
+
+const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
+
+const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
+
+const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
+ `Invalid value for key ${key}`;
+
+const PATTERN_LENGTH_TOO_LARGE = (max) =>
+ `Pattern length exceeds max of ${max}.`;
+
+const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
+
+const INVALID_KEY_WEIGHT_VALUE = (key) =>
+ `Property 'weight' in key '${key}' must be a positive integer`;
+
+const hasOwn = Object.prototype.hasOwnProperty;
+
+class KeyStore {
+ constructor(keys) {
+ this._keys = [];
+ this._keyMap = {};
+
+ let totalWeight = 0;
+
+ keys.forEach((key) => {
+ let obj = createKey(key);
+
+ this._keys.push(obj);
+ this._keyMap[obj.id] = obj;
+
+ totalWeight += obj.weight;
+ });
+
+ // Normalize weights so that their sum is equal to 1
+ this._keys.forEach((key) => {
+ key.weight /= totalWeight;
+ });
+ }
+ get(keyId) {
+ return this._keyMap[keyId]
+ }
+ keys() {
+ return this._keys
+ }
+ toJSON() {
+ return JSON.stringify(this._keys)
+ }
+}
+
+function createKey(key) {
+ let path = null;
+ let id = null;
+ let src = null;
+ let weight = 1;
+ let getFn = null;
+
+ if (isString(key) || isArray(key)) {
+ src = key;
+ path = createKeyPath(key);
+ id = createKeyId(key);
+ } else {
+ if (!hasOwn.call(key, 'name')) {
+ throw new Error(MISSING_KEY_PROPERTY('name'))
+ }
+
+ const name = key.name;
+ src = name;
+
+ if (hasOwn.call(key, 'weight')) {
+ weight = key.weight;
+
+ if (weight <= 0) {
+ throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
+ }
+ }
+
+ path = createKeyPath(name);
+ id = createKeyId(name);
+ getFn = key.getFn;
+ }
+
+ return { path, id, weight, src, getFn }
+}
+
+function createKeyPath(key) {
+ return isArray(key) ? key : key.split('.')
+}
+
+function createKeyId(key) {
+ return isArray(key) ? key.join('.') : key
+}
+
+function get(obj, path) {
+ let list = [];
+ let arr = false;
+
+ const deepGet = (obj, path, index) => {
+ if (!isDefined(obj)) {
+ return
+ }
+ if (!path[index]) {
+ // If there's no path left, we've arrived at the object we care about.
+ list.push(obj);
+ } else {
+ let key = path[index];
+
+ const value = obj[key];
+
+ if (!isDefined(value)) {
+ return
+ }
+
+ // If we're at the last value in the path, and if it's a string/number/bool,
+ // add it to the list
+ if (
+ index === path.length - 1 &&
+ (isString(value) || isNumber(value) || isBoolean(value))
+ ) {
+ list.push(toString(value));
+ } else if (isArray(value)) {
+ arr = true;
+ // Search each item in the array.
+ for (let i = 0, len = value.length; i < len; i += 1) {
+ deepGet(value[i], path, index + 1);
+ }
+ } else if (path.length) {
+ // An object. Recurse further.
+ deepGet(value, path, index + 1);
+ }
+ }
+ };
+
+ // Backwards compatibility (since path used to be a string)
+ deepGet(obj, isString(path) ? path.split('.') : path, 0);
+
+ return arr ? list : list[0]
+}
+
+const MatchOptions = {
+ // Whether the matches should be included in the result set. When `true`, each record in the result
+ // set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
+ includeMatches: false,
+ // When `true`, the matching function will continue to the end of a search pattern even if
+ // a perfect match has already been located in the string.
+ findAllMatches: false,
+ // Minimum number of characters that must be matched before a result is considered a match
+ minMatchCharLength: 1
+};
+
+const BasicOptions = {
+ // When `true`, the algorithm continues searching to the end of the input even if a perfect
+ // match is found before the end of the same input.
+ isCaseSensitive: false,
+ // When true, the matching function will continue to the end of a search pattern even if
+ includeScore: false,
+ // List of properties that will be searched. This also supports nested properties.
+ keys: [],
+ // Whether to sort the result list, by score
+ shouldSort: true,
+ // Default sort function: sort by ascending score, ascending index
+ sortFn: (a, b) =>
+ a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
+};
+
+const FuzzyOptions = {
+ // Approximately where in the text is the pattern expected to be found?
+ location: 0,
+ // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
+ // (of both letters and location), a threshold of '1.0' would match anything.
+ threshold: 0.6,
+ // Determines how close the match must be to the fuzzy location (specified above).
+ // An exact letter match which is 'distance' characters away from the fuzzy location
+ // would score as a complete mismatch. A distance of '0' requires the match be at
+ // the exact location specified, a threshold of '1000' would require a perfect match
+ // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
+ distance: 100
+};
+
+const AdvancedOptions = {
+ // When `true`, it enables the use of unix-like search commands
+ useExtendedSearch: false,
+ // The get function to use when fetching an object's properties.
+ // The default will search nested paths *ie foo.bar.baz*
+ getFn: get,
+ // When `true`, search will ignore `location` and `distance`, so it won't matter
+ // where in the string the pattern appears.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
+ ignoreLocation: false,
+ // When `true`, the calculation for the relevance score (used for sorting) will
+ // ignore the field-length norm.
+ // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
+ ignoreFieldNorm: false,
+ // The weight to determine how much field length norm effects scoring.
+ fieldNormWeight: 1
+};
+
+var Config = {
+ ...BasicOptions,
+ ...MatchOptions,
+ ...FuzzyOptions,
+ ...AdvancedOptions
+};
+
+const SPACE = /[^ ]+/g;
+
+// Field-length norm: the shorter the field, the higher the weight.
+// Set to 3 decimals to reduce index size.
+function norm(weight = 1, mantissa = 3) {
+ const cache = new Map();
+ const m = Math.pow(10, mantissa);
+
+ return {
+ get(value) {
+ const numTokens = value.match(SPACE).length;
+
+ if (cache.has(numTokens)) {
+ return cache.get(numTokens)
+ }
+
+ // Default function is 1/sqrt(x), weight makes that variable
+ const norm = 1 / Math.pow(numTokens, 0.5 * weight);
+
+ // In place of `toFixed(mantissa)`, for faster computation
+ const n = parseFloat(Math.round(norm * m) / m);
+
+ cache.set(numTokens, n);
+
+ return n
+ },
+ clear() {
+ cache.clear();
+ }
+ }
+}
+
+class FuseIndex {
+ constructor({
+ getFn = Config.getFn,
+ fieldNormWeight = Config.fieldNormWeight
+ } = {}) {
+ this.norm = norm(fieldNormWeight, 3);
+ this.getFn = getFn;
+ this.isCreated = false;
+
+ this.setIndexRecords();
+ }
+ setSources(docs = []) {
+ this.docs = docs;
+ }
+ setIndexRecords(records = []) {
+ this.records = records;
+ }
+ setKeys(keys = []) {
+ this.keys = keys;
+ this._keysMap = {};
+ keys.forEach((key, idx) => {
+ this._keysMap[key.id] = idx;
+ });
+ }
+ create() {
+ if (this.isCreated || !this.docs.length) {
+ return
+ }
+
+ this.isCreated = true;
+
+ // List is Array<String>
+ if (isString(this.docs[0])) {
+ this.docs.forEach((doc, docIndex) => {
+ this._addString(doc, docIndex);
+ });
+ } else {
+ // List is Array<Object>
+ this.docs.forEach((doc, docIndex) => {
+ this._addObject(doc, docIndex);
+ });
+ }
+
+ this.norm.clear();
+ }
+ // Adds a doc to the end of the index
+ add(doc) {
+ const idx = this.size();
+
+ if (isString(doc)) {
+ this._addString(doc, idx);
+ } else {
+ this._addObject(doc, idx);
+ }
+ }
+ // Removes the doc at the specified index of the index
+ removeAt(idx) {
+ this.records.splice(idx, 1);
+
+ // Change ref index of every subsquent doc
+ for (let i = idx, len = this.size(); i < len; i += 1) {
+ this.records[i].i -= 1;
+ }
+ }
+ getValueForItemAtKeyId(item, keyId) {
+ return item[this._keysMap[keyId]]
+ }
+ size() {
+ return this.records.length
+ }
+ _addString(doc, docIndex) {
+ if (!isDefined(doc) || isBlank(doc)) {
+ return
+ }
+
+ let record = {
+ v: doc,
+ i: docIndex,
+ n: this.norm.get(doc)
+ };
+
+ this.records.push(record);
+ }
+ _addObject(doc, docIndex) {
+ let record = { i: docIndex, $: {} };
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ this.keys.forEach((key, keyIndex) => {
+ let value = key.getFn ? key.getFn(doc) : this.getFn(doc, key.path);
+
+ if (!isDefined(value)) {
+ return
+ }
+
+ if (isArray(value)) {
+ let subRecords = [];
+ const stack = [{ nestedArrIndex: -1, value }];
+
+ while (stack.length) {
+ const { nestedArrIndex, value } = stack.pop();
+
+ if (!isDefined(value)) {
+ continue
+ }
+
+ if (isString(value) && !isBlank(value)) {
+ let subRecord = {
+ v: value,
+ i: nestedArrIndex,
+ n: this.norm.get(value)
+ };
+
+ subRecords.push(subRecord);
+ } else if (isArray(value)) {
+ value.forEach((item, k) => {
+ stack.push({
+ nestedArrIndex: k,
+ value: item
+ });
+ });
+ } else ;
+ }
+ record.$[keyIndex] = subRecords;
+ } else if (isString(value) && !isBlank(value)) {
+ let subRecord = {
+ v: value,
+ n: this.norm.get(value)
+ };
+
+ record.$[keyIndex] = subRecord;
+ }
+ });
+
+ this.records.push(record);
+ }
+ toJSON() {
+ return {
+ keys: this.keys,
+ records: this.records
+ }
+ }
+}
+
+function createIndex(
+ keys,
+ docs,
+ { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
+) {
+ const myIndex = new FuseIndex({ getFn, fieldNormWeight });
+ myIndex.setKeys(keys.map(createKey));
+ myIndex.setSources(docs);
+ myIndex.create();
+ return myIndex
+}
+
+function parseIndex(
+ data,
+ { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}
+) {
+ const { keys, records } = data;
+ const myIndex = new FuseIndex({ getFn, fieldNormWeight });
+ myIndex.setKeys(keys);
+ myIndex.setIndexRecords(records);
+ return myIndex
+}
+
+function computeScore$1(
+ pattern,
+ {
+ errors = 0,
+ currentLocation = 0,
+ expectedLocation = 0,
+ distance = Config.distance,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+) {
+ const accuracy = errors / pattern.length;
+
+ if (ignoreLocation) {
+ return accuracy
+ }
+
+ const proximity = Math.abs(expectedLocation - currentLocation);
+
+ if (!distance) {
+ // Dodge divide by zero error.
+ return proximity ? 1.0 : accuracy
+ }
+
+ return accuracy + proximity / distance
+}
+
+function convertMaskToIndices(
+ matchmask = [],
+ minMatchCharLength = Config.minMatchCharLength
+) {
+ let indices = [];
+ let start = -1;
+ let end = -1;
+ let i = 0;
+
+ for (let len = matchmask.length; i < len; i += 1) {
+ let match = matchmask[i];
+ if (match && start === -1) {
+ start = i;
+ } else if (!match && start !== -1) {
+ end = i - 1;
+ if (end - start + 1 >= minMatchCharLength) {
+ indices.push([start, end]);
+ }
+ start = -1;
+ }
+ }
+
+ // (i-1 - start) + 1 => i - start
+ if (matchmask[i - 1] && i - start >= minMatchCharLength) {
+ indices.push([start, i - 1]);
+ }
+
+ return indices
+}
+
+// Machine word size
+const MAX_BITS = 32;
+
+function search(
+ text,
+ pattern,
+ patternAlphabet,
+ {
+ location = Config.location,
+ distance = Config.distance,
+ threshold = Config.threshold,
+ findAllMatches = Config.findAllMatches,
+ minMatchCharLength = Config.minMatchCharLength,
+ includeMatches = Config.includeMatches,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+) {
+ if (pattern.length > MAX_BITS) {
+ throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
+ }
+
+ const patternLen = pattern.length;
+ // Set starting location at beginning text and initialize the alphabet.
+ const textLen = text.length;
+ // Handle the case when location > text.length
+ const expectedLocation = Math.max(0, Math.min(location, textLen));
+ // Highest score beyond which we give up.
+ let currentThreshold = threshold;
+ // Is there a nearby exact match? (speedup)
+ let bestLocation = expectedLocation;
+
+ // Performance: only computer matches when the minMatchCharLength > 1
+ // OR if `includeMatches` is true.
+ const computeMatches = minMatchCharLength > 1 || includeMatches;
+ // A mask of the matches, used for building the indices
+ const matchMask = computeMatches ? Array(textLen) : [];
+
+ let index;
+
+ // Get all exact matches, here for speed up
+ while ((index = text.indexOf(pattern, bestLocation)) > -1) {
+ let score = computeScore$1(pattern, {
+ currentLocation: index,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ currentThreshold = Math.min(score, currentThreshold);
+ bestLocation = index + patternLen;
+
+ if (computeMatches) {
+ let i = 0;
+ while (i < patternLen) {
+ matchMask[index + i] = 1;
+ i += 1;
+ }
+ }
+ }
+
+ // Reset the best location
+ bestLocation = -1;
+
+ let lastBitArr = [];
+ let finalScore = 1;
+ let binMax = patternLen + textLen;
+
+ const mask = 1 << (patternLen - 1);
+
+ for (let i = 0; i < patternLen; i += 1) {
+ // Scan for the best match; each iteration allows for one more error.
+ // Run a binary search to determine how far from the match location we can stray
+ // at this error level.
+ let binMin = 0;
+ let binMid = binMax;
+
+ while (binMin < binMid) {
+ const score = computeScore$1(pattern, {
+ errors: i,
+ currentLocation: expectedLocation + binMid,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ if (score <= currentThreshold) {
+ binMin = binMid;
+ } else {
+ binMax = binMid;
+ }
+
+ binMid = Math.floor((binMax - binMin) / 2 + binMin);
+ }
+
+ // Use the result from this iteration as the maximum for the next.
+ binMax = binMid;
+
+ let start = Math.max(1, expectedLocation - binMid + 1);
+ let finish = findAllMatches
+ ? textLen
+ : Math.min(expectedLocation + binMid, textLen) + patternLen;
+
+ // Initialize the bit array
+ let bitArr = Array(finish + 2);
+
+ bitArr[finish + 1] = (1 << i) - 1;
+
+ for (let j = finish; j >= start; j -= 1) {
+ let currentLocation = j - 1;
+ let charMatch = patternAlphabet[text.charAt(currentLocation)];
+
+ if (computeMatches) {
+ // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
+ matchMask[currentLocation] = +!!charMatch;
+ }
+
+ // First pass: exact match
+ bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
+
+ // Subsequent passes: fuzzy match
+ if (i) {
+ bitArr[j] |=
+ ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
+ }
+
+ if (bitArr[j] & mask) {
+ finalScore = computeScore$1(pattern, {
+ errors: i,
+ currentLocation,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ // This match will almost certainly be better than any existing match.
+ // But check anyway.
+ if (finalScore <= currentThreshold) {
+ // Indeed it is
+ currentThreshold = finalScore;
+ bestLocation = currentLocation;
+
+ // Already passed `loc`, downhill from here on in.
+ if (bestLocation <= expectedLocation) {
+ break
+ }
+
+ // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
+ start = Math.max(1, 2 * expectedLocation - bestLocation);
+ }
+ }
+ }
+
+ // No hope for a (better) match at greater error levels.
+ const score = computeScore$1(pattern, {
+ errors: i + 1,
+ currentLocation: expectedLocation,
+ expectedLocation,
+ distance,
+ ignoreLocation
+ });
+
+ if (score > currentThreshold) {
+ break
+ }
+
+ lastBitArr = bitArr;
+ }
+
+ const result = {
+ isMatch: bestLocation >= 0,
+ // Count exact matches (those with a score of 0) to be "almost" exact
+ score: Math.max(0.001, finalScore)
+ };
+
+ if (computeMatches) {
+ const indices = convertMaskToIndices(matchMask, minMatchCharLength);
+ if (!indices.length) {
+ result.isMatch = false;
+ } else if (includeMatches) {
+ result.indices = indices;
+ }
+ }
+
+ return result
+}
+
+function createPatternAlphabet(pattern) {
+ let mask = {};
+
+ for (let i = 0, len = pattern.length; i < len; i += 1) {
+ const char = pattern.charAt(i);
+ mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
+ }
+
+ return mask
+}
+
+class BitapSearch {
+ constructor(
+ pattern,
+ {
+ location = Config.location,
+ threshold = Config.threshold,
+ distance = Config.distance,
+ includeMatches = Config.includeMatches,
+ findAllMatches = Config.findAllMatches,
+ minMatchCharLength = Config.minMatchCharLength,
+ isCaseSensitive = Config.isCaseSensitive,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+ ) {
+ this.options = {
+ location,
+ threshold,
+ distance,
+ includeMatches,
+ findAllMatches,
+ minMatchCharLength,
+ isCaseSensitive,
+ ignoreLocation
+ };
+
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+
+ this.chunks = [];
+
+ if (!this.pattern.length) {
+ return
+ }
+
+ const addChunk = (pattern, startIndex) => {
+ this.chunks.push({
+ pattern,
+ alphabet: createPatternAlphabet(pattern),
+ startIndex
+ });
+ };
+
+ const len = this.pattern.length;
+
+ if (len > MAX_BITS) {
+ let i = 0;
+ const remainder = len % MAX_BITS;
+ const end = len - remainder;
+
+ while (i < end) {
+ addChunk(this.pattern.substr(i, MAX_BITS), i);
+ i += MAX_BITS;
+ }
+
+ if (remainder) {
+ const startIndex = len - MAX_BITS;
+ addChunk(this.pattern.substr(startIndex), startIndex);
+ }
+ } else {
+ addChunk(this.pattern, 0);
+ }
+ }
+
+ searchIn(text) {
+ const { isCaseSensitive, includeMatches } = this.options;
+
+ if (!isCaseSensitive) {
+ text = text.toLowerCase();
+ }
+
+ // Exact match
+ if (this.pattern === text) {
+ let result = {
+ isMatch: true,
+ score: 0
+ };
+
+ if (includeMatches) {
+ result.indices = [[0, text.length - 1]];
+ }
+
+ return result
+ }
+
+ // Otherwise, use Bitap algorithm
+ const {
+ location,
+ distance,
+ threshold,
+ findAllMatches,
+ minMatchCharLength,
+ ignoreLocation
+ } = this.options;
+
+ let allIndices = [];
+ let totalScore = 0;
+ let hasMatches = false;
+
+ this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
+ const { isMatch, score, indices } = search(text, pattern, alphabet, {
+ location: location + startIndex,
+ distance,
+ threshold,
+ findAllMatches,
+ minMatchCharLength,
+ includeMatches,
+ ignoreLocation
+ });
+
+ if (isMatch) {
+ hasMatches = true;
+ }
+
+ totalScore += score;
+
+ if (isMatch && indices) {
+ allIndices = [...allIndices, ...indices];
+ }
+ });
+
+ let result = {
+ isMatch: hasMatches,
+ score: hasMatches ? totalScore / this.chunks.length : 1
+ };
+
+ if (hasMatches && includeMatches) {
+ result.indices = allIndices;
+ }
+
+ return result
+ }
+}
+
+class BaseMatch {
+ constructor(pattern) {
+ this.pattern = pattern;
+ }
+ static isMultiMatch(pattern) {
+ return getMatch(pattern, this.multiRegex)
+ }
+ static isSingleMatch(pattern) {
+ return getMatch(pattern, this.singleRegex)
+ }
+ search(/*text*/) {}
+}
+
+function getMatch(pattern, exp) {
+ const matches = pattern.match(exp);
+ return matches ? matches[1] : null
+}
+
+// Token: 'file
+
+class ExactMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'exact'
+ }
+ static get multiRegex() {
+ return /^="(.*)"$/
+ }
+ static get singleRegex() {
+ return /^=(.*)$/
+ }
+ search(text) {
+ const isMatch = text === this.pattern;
+
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, this.pattern.length - 1]
+ }
+ }
+}
+
+// Token: !fire
+
+class InverseExactMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'inverse-exact'
+ }
+ static get multiRegex() {
+ return /^!"(.*)"$/
+ }
+ static get singleRegex() {
+ return /^!(.*)$/
+ }
+ search(text) {
+ const index = text.indexOf(this.pattern);
+ const isMatch = index === -1;
+
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ }
+ }
+}
+
+// Token: ^file
+
+class PrefixExactMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'prefix-exact'
+ }
+ static get multiRegex() {
+ return /^\^"(.*)"$/
+ }
+ static get singleRegex() {
+ return /^\^(.*)$/
+ }
+ search(text) {
+ const isMatch = text.startsWith(this.pattern);
+
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, this.pattern.length - 1]
+ }
+ }
+}
+
+// Token: !^fire
+
+class InversePrefixExactMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'inverse-prefix-exact'
+ }
+ static get multiRegex() {
+ return /^!\^"(.*)"$/
+ }
+ static get singleRegex() {
+ return /^!\^(.*)$/
+ }
+ search(text) {
+ const isMatch = !text.startsWith(this.pattern);
+
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ }
+ }
+}
+
+// Token: .file$
+
+class SuffixExactMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'suffix-exact'
+ }
+ static get multiRegex() {
+ return /^"(.*)"\$$/
+ }
+ static get singleRegex() {
+ return /^(.*)\$$/
+ }
+ search(text) {
+ const isMatch = text.endsWith(this.pattern);
+
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [text.length - this.pattern.length, text.length - 1]
+ }
+ }
+}
+
+// Token: !.file$
+
+class InverseSuffixExactMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'inverse-suffix-exact'
+ }
+ static get multiRegex() {
+ return /^!"(.*)"\$$/
+ }
+ static get singleRegex() {
+ return /^!(.*)\$$/
+ }
+ search(text) {
+ const isMatch = !text.endsWith(this.pattern);
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices: [0, text.length - 1]
+ }
+ }
+}
+
+class FuzzyMatch extends BaseMatch {
+ constructor(
+ pattern,
+ {
+ location = Config.location,
+ threshold = Config.threshold,
+ distance = Config.distance,
+ includeMatches = Config.includeMatches,
+ findAllMatches = Config.findAllMatches,
+ minMatchCharLength = Config.minMatchCharLength,
+ isCaseSensitive = Config.isCaseSensitive,
+ ignoreLocation = Config.ignoreLocation
+ } = {}
+ ) {
+ super(pattern);
+ this._bitapSearch = new BitapSearch(pattern, {
+ location,
+ threshold,
+ distance,
+ includeMatches,
+ findAllMatches,
+ minMatchCharLength,
+ isCaseSensitive,
+ ignoreLocation
+ });
+ }
+ static get type() {
+ return 'fuzzy'
+ }
+ static get multiRegex() {
+ return /^"(.*)"$/
+ }
+ static get singleRegex() {
+ return /^(.*)$/
+ }
+ search(text) {
+ return this._bitapSearch.searchIn(text)
+ }
+}
+
+// Token: 'file
+
+class IncludeMatch extends BaseMatch {
+ constructor(pattern) {
+ super(pattern);
+ }
+ static get type() {
+ return 'include'
+ }
+ static get multiRegex() {
+ return /^'"(.*)"$/
+ }
+ static get singleRegex() {
+ return /^'(.*)$/
+ }
+ search(text) {
+ let location = 0;
+ let index;
+
+ const indices = [];
+ const patternLen = this.pattern.length;
+
+ // Get all exact matches
+ while ((index = text.indexOf(this.pattern, location)) > -1) {
+ location = index + patternLen;
+ indices.push([index, location - 1]);
+ }
+
+ const isMatch = !!indices.length;
+
+ return {
+ isMatch,
+ score: isMatch ? 0 : 1,
+ indices
+ }
+ }
+}
+
+// ❗Order is important. DO NOT CHANGE.
+const searchers = [
+ ExactMatch,
+ IncludeMatch,
+ PrefixExactMatch,
+ InversePrefixExactMatch,
+ InverseSuffixExactMatch,
+ SuffixExactMatch,
+ InverseExactMatch,
+ FuzzyMatch
+];
+
+const searchersLen = searchers.length;
+
+// Regex to split by spaces, but keep anything in quotes together
+const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;
+const OR_TOKEN = '|';
+
+// Return a 2D array representation of the query, for simpler parsing.
+// Example:
+// "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
+function parseQuery(pattern, options = {}) {
+ return pattern.split(OR_TOKEN).map((item) => {
+ let query = item
+ .trim()
+ .split(SPACE_RE)
+ .filter((item) => item && !!item.trim());
+
+ let results = [];
+ for (let i = 0, len = query.length; i < len; i += 1) {
+ const queryItem = query[i];
+
+ // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
+ let found = false;
+ let idx = -1;
+ while (!found && ++idx < searchersLen) {
+ const searcher = searchers[idx];
+ let token = searcher.isMultiMatch(queryItem);
+ if (token) {
+ results.push(new searcher(token, options));
+ found = true;
+ }
+ }
+
+ if (found) {
+ continue
+ }
+
+ // 2. Handle single query matches (i.e, once that are *not* quoted)
+ idx = -1;
+ while (++idx < searchersLen) {
+ const searcher = searchers[idx];
+ let token = searcher.isSingleMatch(queryItem);
+ if (token) {
+ results.push(new searcher(token, options));
+ break
+ }
+ }
+ }
+
+ return results
+ })
+}
+
+// These extended matchers can return an array of matches, as opposed
+// to a singl match
+const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
+
+/**
+ * Command-like searching
+ * ======================
+ *
+ * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
+ * search in a given text.
+ *
+ * Search syntax:
+ *
+ * | Token | Match type | Description |
+ * | ----------- | -------------------------- | -------------------------------------- |
+ * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
+ * | `=scheme` | exact-match | Items that are `scheme` |
+ * | `'python` | include-match | Items that include `python` |
+ * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
+ * | `^java` | prefix-exact-match | Items that start with `java` |
+ * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
+ * | `.js$` | suffix-exact-match | Items that end with `.js` |
+ * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
+ *
+ * A single pipe character acts as an OR operator. For example, the following
+ * query matches entries that start with `core` and end with either`go`, `rb`,
+ * or`py`.
+ *
+ * ```
+ * ^core go$ | rb$ | py$
+ * ```
+ */
+class ExtendedSearch {
+ constructor(
+ pattern,
+ {
+ isCaseSensitive = Config.isCaseSensitive,
+ includeMatches = Config.includeMatches,
+ minMatchCharLength = Config.minMatchCharLength,
+ ignoreLocation = Config.ignoreLocation,
+ findAllMatches = Config.findAllMatches,
+ location = Config.location,
+ threshold = Config.threshold,
+ distance = Config.distance
+ } = {}
+ ) {
+ this.query = null;
+ this.options = {
+ isCaseSensitive,
+ includeMatches,
+ minMatchCharLength,
+ findAllMatches,
+ ignoreLocation,
+ location,
+ threshold,
+ distance
+ };
+
+ this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
+ this.query = parseQuery(this.pattern, this.options);
+ }
+
+ static condition(_, options) {
+ return options.useExtendedSearch
+ }
+
+ searchIn(text) {
+ const query = this.query;
+
+ if (!query) {
+ return {
+ isMatch: false,
+ score: 1
+ }
+ }
+
+ const { includeMatches, isCaseSensitive } = this.options;
+
+ text = isCaseSensitive ? text : text.toLowerCase();
+
+ let numMatches = 0;
+ let allIndices = [];
+ let totalScore = 0;
+
+ // ORs
+ for (let i = 0, qLen = query.length; i < qLen; i += 1) {
+ const searchers = query[i];
+
+ // Reset indices
+ allIndices.length = 0;
+ numMatches = 0;
+
+ // ANDs
+ for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
+ const searcher = searchers[j];
+ const { isMatch, indices, score } = searcher.search(text);
+
+ if (isMatch) {
+ numMatches += 1;
+ totalScore += score;
+ if (includeMatches) {
+ const type = searcher.constructor.type;
+ if (MultiMatchSet.has(type)) {
+ allIndices = [...allIndices, ...indices];
+ } else {
+ allIndices.push(indices);
+ }
+ }
+ } else {
+ totalScore = 0;
+ numMatches = 0;
+ allIndices.length = 0;
+ break
+ }
+ }
+
+ // OR condition, so if TRUE, return
+ if (numMatches) {
+ let result = {
+ isMatch: true,
+ score: totalScore / numMatches
+ };
+
+ if (includeMatches) {
+ result.indices = allIndices;
+ }
+
+ return result
+ }
+ }
+
+ // Nothing was matched
+ return {
+ isMatch: false,
+ score: 1
+ }
+ }
+}
+
+const registeredSearchers = [];
+
+function register(...args) {
+ registeredSearchers.push(...args);
+}
+
+function createSearcher(pattern, options) {
+ for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
+ let searcherClass = registeredSearchers[i];
+ if (searcherClass.condition(pattern, options)) {
+ return new searcherClass(pattern, options)
+ }
+ }
+
+ return new BitapSearch(pattern, options)
+}
+
+const LogicalOperator = {
+ AND: '$and',
+ OR: '$or'
+};
+
+const KeyType = {
+ PATH: '$path',
+ PATTERN: '$val'
+};
+
+const isExpression = (query) =>
+ !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
+
+const isPath = (query) => !!query[KeyType.PATH];
+
+const isLeaf = (query) =>
+ !isArray(query) && isObject(query) && !isExpression(query);
+
+const convertToExplicit = (query) => ({
+ [LogicalOperator.AND]: Object.keys(query).map((key) => ({
+ [key]: query[key]
+ }))
+});
+
+// When `auto` is `true`, the parse function will infer and initialize and add
+// the appropriate `Searcher` instance
+function parse(query, options, { auto = true } = {}) {
+ const next = (query) => {
+ let keys = Object.keys(query);
+
+ const isQueryPath = isPath(query);
+
+ if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
+ return next(convertToExplicit(query))
+ }
+
+ if (isLeaf(query)) {
+ const key = isQueryPath ? query[KeyType.PATH] : keys[0];
+
+ const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
+
+ if (!isString(pattern)) {
+ throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
+ }
+
+ const obj = {
+ keyId: createKeyId(key),
+ pattern
+ };
+
+ if (auto) {
+ obj.searcher = createSearcher(pattern, options);
+ }
+
+ return obj
+ }
+
+ let node = {
+ children: [],
+ operator: keys[0]
+ };
+
+ keys.forEach((key) => {
+ const value = query[key];
+
+ if (isArray(value)) {
+ value.forEach((item) => {
+ node.children.push(next(item));
+ });
+ }
+ });
+
+ return node
+ };
+
+ if (!isExpression(query)) {
+ query = convertToExplicit(query);
+ }
+
+ return next(query)
+}
+
+// Practical scoring function
+function computeScore(
+ results,
+ { ignoreFieldNorm = Config.ignoreFieldNorm }
+) {
+ results.forEach((result) => {
+ let totalScore = 1;
+
+ result.matches.forEach(({ key, norm, score }) => {
+ const weight = key ? key.weight : null;
+
+ totalScore *= Math.pow(
+ score === 0 && weight ? Number.EPSILON : score,
+ (weight || 1) * (ignoreFieldNorm ? 1 : norm)
+ );
+ });
+
+ result.score = totalScore;
+ });
+}
+
+function transformMatches(result, data) {
+ const matches = result.matches;
+ data.matches = [];
+
+ if (!isDefined(matches)) {
+ return
+ }
+
+ matches.forEach((match) => {
+ if (!isDefined(match.indices) || !match.indices.length) {
+ return
+ }
+
+ const { indices, value } = match;
+
+ let obj = {
+ indices,
+ value
+ };
+
+ if (match.key) {
+ obj.key = match.key.src;
+ }
+
+ if (match.idx > -1) {
+ obj.refIndex = match.idx;
+ }
+
+ data.matches.push(obj);
+ });
+}
+
+function transformScore(result, data) {
+ data.score = result.score;
+}
+
+function format(
+ results,
+ docs,
+ {
+ includeMatches = Config.includeMatches,
+ includeScore = Config.includeScore
+ } = {}
+) {
+ const transformers = [];
+
+ if (includeMatches) transformers.push(transformMatches);
+ if (includeScore) transformers.push(transformScore);
+
+ return results.map((result) => {
+ const { idx } = result;
+
+ const data = {
+ item: docs[idx],
+ refIndex: idx
+ };
+
+ if (transformers.length) {
+ transformers.forEach((transformer) => {
+ transformer(result, data);
+ });
+ }
+
+ return data
+ })
+}
+
+class Fuse {
+ constructor(docs, options = {}, index) {
+ this.options = { ...Config, ...options };
+
+ if (
+ this.options.useExtendedSearch &&
+ !true
+ ) {
+ throw new Error(EXTENDED_SEARCH_UNAVAILABLE)
+ }
+
+ this._keyStore = new KeyStore(this.options.keys);
+
+ this.setCollection(docs, index);
+ }
+
+ setCollection(docs, index) {
+ this._docs = docs;
+
+ if (index && !(index instanceof FuseIndex)) {
+ throw new Error(INCORRECT_INDEX_TYPE)
+ }
+
+ this._myIndex =
+ index ||
+ createIndex(this.options.keys, this._docs, {
+ getFn: this.options.getFn,
+ fieldNormWeight: this.options.fieldNormWeight
+ });
+ }
+
+ add(doc) {
+ if (!isDefined(doc)) {
+ return
+ }
+
+ this._docs.push(doc);
+ this._myIndex.add(doc);
+ }
+
+ remove(predicate = (/* doc, idx */) => false) {
+ const results = [];
+
+ for (let i = 0, len = this._docs.length; i < len; i += 1) {
+ const doc = this._docs[i];
+ if (predicate(doc, i)) {
+ this.removeAt(i);
+ i -= 1;
+ len -= 1;
+
+ results.push(doc);
+ }
+ }
+
+ return results
+ }
+
+ removeAt(idx) {
+ this._docs.splice(idx, 1);
+ this._myIndex.removeAt(idx);
+ }
+
+ getIndex() {
+ return this._myIndex
+ }
+
+ search(query, { limit = -1 } = {}) {
+ const {
+ includeMatches,
+ includeScore,
+ shouldSort,
+ sortFn,
+ ignoreFieldNorm
+ } = this.options;
+
+ let results = isString(query)
+ ? isString(this._docs[0])
+ ? this._searchStringList(query)
+ : this._searchObjectList(query)
+ : this._searchLogical(query);
+
+ computeScore(results, { ignoreFieldNorm });
+
+ if (shouldSort) {
+ results.sort(sortFn);
+ }
+
+ if (isNumber(limit) && limit > -1) {
+ results = results.slice(0, limit);
+ }
+
+ return format(results, this._docs, {
+ includeMatches,
+ includeScore
+ })
+ }
+
+ _searchStringList(query) {
+ const searcher = createSearcher(query, this.options);
+ const { records } = this._myIndex;
+ const results = [];
+
+ // Iterate over every string in the index
+ records.forEach(({ v: text, i: idx, n: norm }) => {
+ if (!isDefined(text)) {
+ return
+ }
+
+ const { isMatch, score, indices } = searcher.searchIn(text);
+
+ if (isMatch) {
+ results.push({
+ item: text,
+ idx,
+ matches: [{ score, value: text, norm, indices }]
+ });
+ }
+ });
+
+ return results
+ }
+
+ _searchLogical(query) {
+
+ const expression = parse(query, this.options);
+
+ const evaluate = (node, item, idx) => {
+ if (!node.children) {
+ const { keyId, searcher } = node;
+
+ const matches = this._findMatches({
+ key: this._keyStore.get(keyId),
+ value: this._myIndex.getValueForItemAtKeyId(item, keyId),
+ searcher
+ });
+
+ if (matches && matches.length) {
+ return [
+ {
+ idx,
+ item,
+ matches
+ }
+ ]
+ }
+
+ return []
+ }
+
+ const res = [];
+ for (let i = 0, len = node.children.length; i < len; i += 1) {
+ const child = node.children[i];
+ const result = evaluate(child, item, idx);
+ if (result.length) {
+ res.push(...result);
+ } else if (node.operator === LogicalOperator.AND) {
+ return []
+ }
+ }
+ return res
+ };
+
+ const records = this._myIndex.records;
+ const resultMap = {};
+ const results = [];
+
+ records.forEach(({ $: item, i: idx }) => {
+ if (isDefined(item)) {
+ let expResults = evaluate(expression, item, idx);
+
+ if (expResults.length) {
+ // Dedupe when adding
+ if (!resultMap[idx]) {
+ resultMap[idx] = { idx, item, matches: [] };
+ results.push(resultMap[idx]);
+ }
+ expResults.forEach(({ matches }) => {
+ resultMap[idx].matches.push(...matches);
+ });
+ }
+ }
+ });
+
+ return results
+ }
+
+ _searchObjectList(query) {
+ const searcher = createSearcher(query, this.options);
+ const { keys, records } = this._myIndex;
+ const results = [];
+
+ // List is Array<Object>
+ records.forEach(({ $: item, i: idx }) => {
+ if (!isDefined(item)) {
+ return
+ }
+
+ let matches = [];
+
+ // Iterate over every key (i.e, path), and fetch the value at that key
+ keys.forEach((key, keyIndex) => {
+ matches.push(
+ ...this._findMatches({
+ key,
+ value: item[keyIndex],
+ searcher
+ })
+ );
+ });
+
+ if (matches.length) {
+ results.push({
+ idx,
+ item,
+ matches
+ });
+ }
+ });
+
+ return results
+ }
+ _findMatches({ key, value, searcher }) {
+ if (!isDefined(value)) {
+ return []
+ }
+
+ let matches = [];
+
+ if (isArray(value)) {
+ value.forEach(({ v: text, i: idx, n: norm }) => {
+ if (!isDefined(text)) {
+ return
+ }
+
+ const { isMatch, score, indices } = searcher.searchIn(text);
+
+ if (isMatch) {
+ matches.push({
+ score,
+ key,
+ value: text,
+ idx,
+ norm,
+ indices
+ });
+ }
+ });
+ } else {
+ const { v: text, n: norm } = value;
+
+ const { isMatch, score, indices } = searcher.searchIn(text);
+
+ if (isMatch) {
+ matches.push({ score, key, value: text, norm, indices });
+ }
+ }
+
+ return matches
+ }
+}
+
+Fuse.version = '7.0.0';
+Fuse.createIndex = createIndex;
+Fuse.parseIndex = parseIndex;
+Fuse.config = Config;
+
+{
+ Fuse.parseQuery = parse;
+}
+
+{
+ register(ExtendedSearch);
+}
+
+export { Fuse as default };
diff --git a/includes/node_modules/fuse.js/package.json b/includes/node_modules/fuse.js/package.json
new file mode 100644
index 0000000..7a3bca0
--- /dev/null
+++ b/includes/node_modules/fuse.js/package.json
@@ -0,0 +1,118 @@
+{
+ "name": "fuse.js",
+ "author": {
+ "name": "Kiro Risk",
+ "email": "kirollos@gmail.com",
+ "url": "http://kiro.me"
+ },
+ "type": "module",
+ "main": "./dist/fuse.cjs",
+ "module": "./dist/fuse.mjs",
+ "unpkg": "./dist/fuse.js",
+ "jsdelivr": "./dist/fuse.js",
+ "types": "./dist/fuse.d.ts",
+ "exports": {
+ ".": {
+ "types": "./dist/fuse.d.ts",
+ "import": "./dist/fuse.mjs",
+ "require": "./dist/fuse.cjs"
+ },
+ "./min": {
+ "types": "./dist/fuse.d.ts",
+ "import": "./dist/fuse.min.mjs",
+ "require": "./dist/fuse.min.cjs"
+ },
+ "./basic": {
+ "types": "./dist/fuse.d.ts",
+ "import": "./dist/fuse.basic.mjs",
+ "require": "./dist/fuse.basic.cjs"
+ },
+ "./min-basic": {
+ "types": "./dist/fuse.d.ts",
+ "import": "./dist/fuse.basic.min.mjs",
+ "require": "./dist/fuse.basic.min.cjs"
+ }
+ },
+ "sideEffects": false,
+ "files": [
+ "dist"
+ ],
+ "version": "7.0.0",
+ "description": "Lightweight fuzzy-search",
+ "license": "Apache-2.0",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/krisk/Fuse.git"
+ },
+ "homepage": "http://fusejs.io",
+ "keywords": [
+ "fuzzy",
+ "search",
+ "bitap"
+ ],
+ "scripts": {
+ "dev": "rollup -w -c scripts/configs.cjs --environment TARGET:umd-dev-full",
+ "dev:cjs": "rollup -w -c scripts/configs.cjs --environment TARGET:commonjs-full",
+ "dev:esm": "rollup -w -c scripts/configs.cjs --environment TARGET:esm-dev-full",
+ "build": "rm -r dist && mkdir dist && node ./scripts/build.main.cjs",
+ "test": "vitest run",
+ "lint": "eslint src test",
+ "release": "./scripts/release.sh",
+ "docs:bump": "node ./scripts/bump-docs.cjs",
+ "docs:dev": "vuepress dev docs",
+ "docs:build": "vuepress build docs",
+ "docs:release": "./scripts/deploy-docs.sh",
+ "prepare": "husky install"
+ },
+ "standard-version": {
+ "scripts": {
+ "postbump": "npm run build && npm run lint && npm run test 2>/dev/null",
+ "precommit": "git add dist/*.js dist/*.cjs dist/*.mjs dist/*.d.ts"
+ }
+ },
+ "commitlint": {
+ "extends": [
+ "@commitlint/config-conventional"
+ ]
+ },
+ "devDependencies": {
+ "@babel/cli": "^7.20.7",
+ "@babel/core": "^7.20.12",
+ "@babel/eslint-parser": "^7.19.1",
+ "@babel/plugin-proposal-object-rest-spread": "7.20.7",
+ "@babel/plugin-syntax-import-assertions": "^7.22.5",
+ "@babel/preset-env": "7.20.2",
+ "@babel/preset-typescript": "7.18.6",
+ "@commitlint/cli": "^17.4.2",
+ "@commitlint/config-conventional": "^17.4.2",
+ "@monaco-editor/loader": "^1.3.2",
+ "@rollup/plugin-babel": "^6.0.3",
+ "@rollup/plugin-node-resolve": "^15.0.1",
+ "@rollup/plugin-replace": "^5.0.2",
+ "@sapphire/stopwatch": "^1.5.0",
+ "@sapphire/utilities": "^3.11.0",
+ "@snippetors/vuepress-plugin-tabs": "1.2.3",
+ "@vuepress/plugin-google-analytics": "2.0.0-beta.60",
+ "@vuepress/plugin-pwa": "2.0.0-beta.60",
+ "@vuepress/plugin-register-components": "2.0.0-beta.60",
+ "@vuepress/plugin-search": "2.0.0-beta.60",
+ "babel-loader": "^9.1.2",
+ "eslint": "8.32.0",
+ "eslint-config-prettier": "8.6.0",
+ "husky": "^8.0.3",
+ "monaco-editor": "^0.34.1",
+ "prettier": "2.8.3",
+ "replace-in-file": "^6.3.5",
+ "rollup": "^2.79.1",
+ "rollup-plugin-dts": "^5.3.0",
+ "standard-version": "^9.5.0",
+ "terser": "^5.16.1",
+ "typescript": "^4.9.4",
+ "vitest": "^0.28.3",
+ "vuepress": "2.0.0-beta.60",
+ "vuepress-plugin-google-adsense2": "1.0.2"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+}
diff --git a/includes/node_modules/has-flag/index.d.ts b/includes/node_modules/has-flag/index.d.ts
new file mode 100644
index 0000000..a0a48c8
--- /dev/null
+++ b/includes/node_modules/has-flag/index.d.ts
@@ -0,0 +1,39 @@
+/**
+Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
+
+@param flag - CLI flag to look for. The `--` prefix is optional.
+@param argv - CLI arguments. Default: `process.argv`.
+@returns Whether the flag exists.
+
+@example
+```
+// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
+
+// foo.ts
+import hasFlag = require('has-flag');
+
+hasFlag('unicorn');
+//=> true
+
+hasFlag('--unicorn');
+//=> true
+
+hasFlag('f');
+//=> true
+
+hasFlag('-f');
+//=> true
+
+hasFlag('foo=bar');
+//=> true
+
+hasFlag('foo');
+//=> false
+
+hasFlag('rainbow');
+//=> false
+```
+*/
+declare function hasFlag(flag: string, argv?: string[]): boolean;
+
+export = hasFlag;
diff --git a/includes/node_modules/has-flag/index.js b/includes/node_modules/has-flag/index.js
new file mode 100644
index 0000000..b6f80b1
--- /dev/null
+++ b/includes/node_modules/has-flag/index.js
@@ -0,0 +1,8 @@
+'use strict';
+
+module.exports = (flag, argv = process.argv) => {
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
+ const position = argv.indexOf(prefix + flag);
+ const terminatorPosition = argv.indexOf('--');
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
+};
diff --git a/includes/node_modules/has-flag/license b/includes/node_modules/has-flag/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/includes/node_modules/has-flag/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/node_modules/has-flag/package.json b/includes/node_modules/has-flag/package.json
new file mode 100644
index 0000000..a9cba4b
--- /dev/null
+++ b/includes/node_modules/has-flag/package.json
@@ -0,0 +1,46 @@
+{
+ "name": "has-flag",
+ "version": "4.0.0",
+ "description": "Check if argv has a specific flag",
+ "license": "MIT",
+ "repository": "sindresorhus/has-flag",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "test": "xo && ava && tsd"
+ },
+ "files": [
+ "index.js",
+ "index.d.ts"
+ ],
+ "keywords": [
+ "has",
+ "check",
+ "detect",
+ "contains",
+ "find",
+ "flag",
+ "cli",
+ "command-line",
+ "argv",
+ "process",
+ "arg",
+ "args",
+ "argument",
+ "arguments",
+ "getopt",
+ "minimist",
+ "optimist"
+ ],
+ "devDependencies": {
+ "ava": "^1.4.1",
+ "tsd": "^0.7.2",
+ "xo": "^0.24.0"
+ }
+}
diff --git a/includes/node_modules/has-flag/readme.md b/includes/node_modules/has-flag/readme.md
new file mode 100644
index 0000000..3f72dff
--- /dev/null
+++ b/includes/node_modules/has-flag/readme.md
@@ -0,0 +1,89 @@
+# has-flag [![Build Status](https://travis-ci.org/sindresorhus/has-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/has-flag)
+
+> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
+
+Correctly stops looking after an `--` argument terminator.
+
+---
+
+<div align="center">
+ <b>
+ <a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
+ </b>
+ <br>
+ <sub>
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
+ </sub>
+</div>
+
+---
+
+
+## Install
+
+```
+$ npm install has-flag
+```
+
+
+## Usage
+
+```js
+// foo.js
+const hasFlag = require('has-flag');
+
+hasFlag('unicorn');
+//=> true
+
+hasFlag('--unicorn');
+//=> true
+
+hasFlag('f');
+//=> true
+
+hasFlag('-f');
+//=> true
+
+hasFlag('foo=bar');
+//=> true
+
+hasFlag('foo');
+//=> false
+
+hasFlag('rainbow');
+//=> false
+```
+
+```
+$ node foo.js -f --unicorn --foo=bar -- --rainbow
+```
+
+
+## API
+
+### hasFlag(flag, [argv])
+
+Returns a boolean for whether the flag exists.
+
+#### flag
+
+Type: `string`
+
+CLI flag to look for. The `--` prefix is optional.
+
+#### argv
+
+Type: `string[]`<br>
+Default: `process.argv`
+
+CLI arguments.
+
+
+## Security
+
+To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/includes/node_modules/kleur/index.js b/includes/node_modules/kleur/index.js
new file mode 100644
index 0000000..0bc6ec9
--- /dev/null
+++ b/includes/node_modules/kleur/index.js
@@ -0,0 +1,104 @@
+'use strict';
+
+const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
+
+const $ = {
+ enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0',
+
+ // modifiers
+ reset: init(0, 0),
+ bold: init(1, 22),
+ dim: init(2, 22),
+ italic: init(3, 23),
+ underline: init(4, 24),
+ inverse: init(7, 27),
+ hidden: init(8, 28),
+ strikethrough: init(9, 29),
+
+ // colors
+ black: init(30, 39),
+ red: init(31, 39),
+ green: init(32, 39),
+ yellow: init(33, 39),
+ blue: init(34, 39),
+ magenta: init(35, 39),
+ cyan: init(36, 39),
+ white: init(37, 39),
+ gray: init(90, 39),
+ grey: init(90, 39),
+
+ // background colors
+ bgBlack: init(40, 49),
+ bgRed: init(41, 49),
+ bgGreen: init(42, 49),
+ bgYellow: init(43, 49),
+ bgBlue: init(44, 49),
+ bgMagenta: init(45, 49),
+ bgCyan: init(46, 49),
+ bgWhite: init(47, 49)
+};
+
+function run(arr, str) {
+ let i=0, tmp, beg='', end='';
+ for (; i < arr.length; i++) {
+ tmp = arr[i];
+ beg += tmp.open;
+ end += tmp.close;
+ if (str.includes(tmp.close)) {
+ str = str.replace(tmp.rgx, tmp.close + tmp.open);
+ }
+ }
+ return beg + str + end;
+}
+
+function chain(has, keys) {
+ let ctx = { has, keys };
+
+ ctx.reset = $.reset.bind(ctx);
+ ctx.bold = $.bold.bind(ctx);
+ ctx.dim = $.dim.bind(ctx);
+ ctx.italic = $.italic.bind(ctx);
+ ctx.underline = $.underline.bind(ctx);
+ ctx.inverse = $.inverse.bind(ctx);
+ ctx.hidden = $.hidden.bind(ctx);
+ ctx.strikethrough = $.strikethrough.bind(ctx);
+
+ ctx.black = $.black.bind(ctx);
+ ctx.red = $.red.bind(ctx);
+ ctx.green = $.green.bind(ctx);
+ ctx.yellow = $.yellow.bind(ctx);
+ ctx.blue = $.blue.bind(ctx);
+ ctx.magenta = $.magenta.bind(ctx);
+ ctx.cyan = $.cyan.bind(ctx);
+ ctx.white = $.white.bind(ctx);
+ ctx.gray = $.gray.bind(ctx);
+ ctx.grey = $.grey.bind(ctx);
+
+ ctx.bgBlack = $.bgBlack.bind(ctx);
+ ctx.bgRed = $.bgRed.bind(ctx);
+ ctx.bgGreen = $.bgGreen.bind(ctx);
+ ctx.bgYellow = $.bgYellow.bind(ctx);
+ ctx.bgBlue = $.bgBlue.bind(ctx);
+ ctx.bgMagenta = $.bgMagenta.bind(ctx);
+ ctx.bgCyan = $.bgCyan.bind(ctx);
+ ctx.bgWhite = $.bgWhite.bind(ctx);
+
+ return ctx;
+}
+
+function init(open, close) {
+ let blk = {
+ open: `\x1b[${open}m`,
+ close: `\x1b[${close}m`,
+ rgx: new RegExp(`\\x1b\\[${close}m`, 'g')
+ };
+ return function (txt) {
+ if (this !== void 0 && this.has !== void 0) {
+ this.has.includes(open) || (this.has.push(open),this.keys.push(blk));
+ return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';
+ }
+ return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';
+ };
+}
+
+module.exports = $;
diff --git a/includes/node_modules/kleur/kleur.d.ts b/includes/node_modules/kleur/kleur.d.ts
new file mode 100644
index 0000000..fdc26ca
--- /dev/null
+++ b/includes/node_modules/kleur/kleur.d.ts
@@ -0,0 +1,45 @@
+// Originally by: Rogier Schouten <https://github.com/rogierschouten>
+// Adapted by: Madhav Varshney <https://github.com/madhavarshney>
+declare namespace kleur {
+ interface Color {
+ (x: string | number): string;
+ (): Kleur;
+ }
+
+ interface Kleur {
+ // Colors
+ black: Color;
+ red: Color;
+ green: Color;
+ yellow: Color;
+ blue: Color;
+ magenta: Color;
+ cyan: Color;
+ white: Color;
+ gray: Color;
+ grey: Color;
+
+ // Backgrounds
+ bgBlack: Color;
+ bgRed: Color;
+ bgGreen: Color;
+ bgYellow: Color;
+ bgBlue: Color;
+ bgMagenta: Color;
+ bgCyan: Color;
+ bgWhite: Color;
+
+ // Modifiers
+ reset: Color;
+ bold: Color;
+ dim: Color;
+ italic: Color;
+ underline: Color;
+ inverse: Color;
+ hidden: Color;
+ strikethrough: Color;
+ }
+}
+
+declare let kleur: kleur.Kleur & { enabled: boolean };
+export = kleur;
diff --git a/includes/node_modules/kleur/license b/includes/node_modules/kleur/license
new file mode 100644
index 0000000..a3f96f8
--- /dev/null
+++ b/includes/node_modules/kleur/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/includes/node_modules/kleur/package.json b/includes/node_modules/kleur/package.json
new file mode 100644
index 0000000..a81931e
--- /dev/null
+++ b/includes/node_modules/kleur/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "kleur",
+ "version": "3.0.3",
+ "repository": "lukeed/kleur",
+ "description": "The fastest Node.js library for formatting terminal text with ANSI colors~!",
+ "license": "MIT",
+ "files": [
+ "*.js",
+ "*.d.ts"
+ ],
+ "author": {
+ "name": "Luke Edwards",
+ "email": "luke.edwards05@gmail.com",
+ "url": "lukeed.com"
+ },
+ "scripts": {
+ "test": "tape test/*.js | tap-spec"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "keywords": [
+ "ansi",
+ "cli",
+ "color",
+ "colors",
+ "console",
+ "terminal"
+ ],
+ "types": "kleur.d.ts",
+ "devDependencies": {
+ "tap-spec": "^5.0.0",
+ "tape": "^4.9.1"
+ }
+}
diff --git a/includes/node_modules/kleur/readme.md b/includes/node_modules/kleur/readme.md
new file mode 100644
index 0000000..6926f1e
--- /dev/null
+++ b/includes/node_modules/kleur/readme.md
@@ -0,0 +1,172 @@
+<div align="center">
+ <img src="shots/logo.png" alt="kleur" height="120" />
+</div>
+
+<div align="center">
+ <a href="https://npmjs.org/package/kleur">
+ <img src="https://badgen.now.sh/npm/v/kleur" alt="version" />
+ </a>
+ <a href="https://travis-ci.org/lukeed/kleur">
+ <img src="https://badgen.now.sh/travis/lukeed/kleur" alt="travis" />
+ </a>
+ <a href="https://npmjs.org/package/kleur">
+ <img src="https://badgen.now.sh/npm/dm/kleur" alt="downloads" />
+ </a>
+ <a href="https://packagephobia.now.sh/result?p=kleur">
+ <img src="https://packagephobia.now.sh/badge?p=kleur" alt="install size" />
+ </a>
+</div>
+
+<div align="center">The fastest Node.js library for formatting terminal text with ANSI colors~!</div>
+
+## Features
+
+* No dependencies
+* Super [lightweight](#load-time) & [performant](#performance)
+* Supports [nested](#nested-methods) & [chained](#chained-methods) colors
+* No `String.prototype` modifications
+* Conditional [color support](#conditional-support)
+* Familiar [API](#api)
+
+---
+
+As of `v3.0` the Chalk-style syntax (magical getter) is no longer used.<br>If you need or require that syntax, consider using [`ansi-colors`](https://github.com/doowb/ansi-colors), which maintains `chalk` parity.
+
+---
+
+
+## Install
+
+```
+$ npm install --save kleur
+```
+
+
+## Usage
+
+```js
+const { red, white, blue, bold } = require('kleur');
+
+// basic usage
+red('red text');
+
+// chained methods
+blue().bold().underline('howdy partner');
+
+// nested methods
+bold(`${ white().bgRed('[ERROR]') } ${ red().italic('Something happened')}`);
+```
+
+### Chained Methods
+
+```js
+console.log(bold().red('this is a bold red message'));
+console.log(bold().italic('this is a bold italicized message'));
+console.log(bold().yellow().bgRed().italic('this is a bold yellow italicized message'));
+console.log(green().bold().underline('this is a bold green underlined message'));
+```
+
+<img src="shots/1.png" width="300" />
+
+### Nested Methods
+
+```js
+const { yellow, red, cyan } = require('kleur');
+
+console.log(yellow(`foo ${red().bold('red')} bar ${cyan('cyan')} baz`));
+console.log(yellow('foo ' + red().bold('red') + ' bar ' + cyan('cyan') + ' baz'));
+```
+
+<img src="shots/2.png" width="300" />
+
+
+### Conditional Support
+
+Toggle color support as needed; `kleur` includes simple auto-detection which may not cover all cases.
+
+```js
+const kleur = require('kleur');
+
+// manually disable
+kleur.enabled = false;
+
+// or use another library to detect support
+kleur.enabled = require('color-support').level;
+
+console.log(kleur.red('I will only be colored red if the terminal supports colors'));
+```
+
+
+## API
+
+Any `kleur` method returns a `String` when invoked with input; otherwise chaining is expected.
+
+> It's up to the developer to pass the output to destinations like `console.log`, `process.stdout.write`, etc.
+
+The methods below are grouped by type for legibility purposes only. They each can be [chained](#chained-methods) or [nested](#nested-methods) with one another.
+
+***Colors:***
+> black &mdash; red &mdash; green &mdash; yellow &mdash; blue &mdash; magenta &mdash; cyan &mdash; white &mdash; gray &mdash; grey
+
+***Backgrounds:***
+> bgBlack &mdash; bgRed &mdash; bgGreen &mdash; bgYellow &mdash; bgBlue &mdash; bgMagenta &mdash; bgCyan &mdash; bgWhite
+
+***Modifiers:***
+> reset &mdash; bold &mdash; dim &mdash; italic* &mdash; underline &mdash; inverse &mdash; hidden &mdash; strikethrough*
+
+<sup>* <em>Not widely supported</em></sup>
+
+
+## Benchmarks
+
+> Using Node v10.13.0
+
+### Load time
+
+```
+chalk :: 14.543ms
+kleur :: 0.474ms
+ansi-colors :: 1.923ms
+```
+
+### Performance
+
+```
+# All Colors
+ ansi-colors x 199,381 ops/sec ±1.04% (96 runs sampled)
+ chalk x 12,107 ops/sec ±2.07% (87 runs sampled)
+ kleur x 715,334 ops/sec ±0.30% (93 runs sampled)
+
+# Stacked colors
+ ansi-colors x 24,494 ops/sec ±1.03% (93 runs sampled)
+ chalk x 2,650 ops/sec ±2.06% (85 runs sampled)
+ kleur x 75,798 ops/sec ±0.19% (97 runs sampled)
+
+# Nested colors
+ ansi-colors x 77,766 ops/sec ±0.32% (94 runs sampled)
+ chalk x 5,596 ops/sec ±1.85% (86 runs sampled)
+ kleur x 137,660 ops/sec ±0.31% (93 runs sampled)
+```
+
+
+## Credits
+
+This project originally forked [Brian Woodward](https://github.com/doowb)'s awesome [`ansi-colors`](https://github.com/doowb/ansi-colors) library.
+
+Beginning with `kleur@3.0`, the Chalk-style syntax (magical getter) has been replaced with function calls per key:
+
+```js
+// Old:
+c.red.bold.underline('old');
+
+// New:
+c.red().bold().underline('new');
+```
+> <sup><em>As I work more with Rust, the newer syntax feels so much better & more natural!</em></sup>
+
+If you prefer the old syntax, you may migrate to `ansi-colors`. Versions below `kleur@3.0` have been deprecated.
+
+
+## License
+
+MIT © [Luke Edwards](https://lukeed.com)
diff --git a/includes/node_modules/prompts/dist/dateparts/datepart.js b/includes/node_modules/prompts/dist/dateparts/datepart.js
new file mode 100644
index 0000000..b954c5e
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/datepart.js
@@ -0,0 +1,39 @@
+'use strict';
+
+class DatePart {
+ constructor({
+ token,
+ date,
+ parts,
+ locales
+ }) {
+ this.token = token;
+ this.date = date || new Date();
+ this.parts = parts || [this];
+ this.locales = locales || {};
+ }
+
+ up() {}
+
+ down() {}
+
+ next() {
+ const currentIdx = this.parts.indexOf(this);
+ return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ setTo(val) {}
+
+ prev() {
+ let parts = [].concat(this.parts).reverse();
+ const currentIdx = parts.indexOf(this);
+ return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ toString() {
+ return String(this.date);
+ }
+
+}
+
+module.exports = DatePart; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/day.js b/includes/node_modules/prompts/dist/dateparts/day.js
new file mode 100644
index 0000000..a525e92
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/day.js
@@ -0,0 +1,35 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+const pos = n => {
+ n = n % 10;
+ return n === 1 ? 'st' : n === 2 ? 'nd' : n === 3 ? 'rd' : 'th';
+};
+
+class Day extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setDate(this.date.getDate() + 1);
+ }
+
+ down() {
+ this.date.setDate(this.date.getDate() - 1);
+ }
+
+ setTo(val) {
+ this.date.setDate(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let date = this.date.getDate();
+ let day = this.date.getDay();
+ return this.token === 'DD' ? String(date).padStart(2, '0') : this.token === 'Do' ? date + pos(date) : this.token === 'd' ? day + 1 : this.token === 'ddd' ? this.locales.weekdaysShort[day] : this.token === 'dddd' ? this.locales.weekdays[day] : date;
+ }
+
+}
+
+module.exports = Day; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/hours.js b/includes/node_modules/prompts/dist/dateparts/hours.js
new file mode 100644
index 0000000..7743632
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/hours.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Hours extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours(this.date.getHours() + 1);
+ }
+
+ down() {
+ this.date.setHours(this.date.getHours() - 1);
+ }
+
+ setTo(val) {
+ this.date.setHours(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let hours = this.date.getHours();
+ if (/h/.test(this.token)) hours = hours % 12 || 12;
+ return this.token.length > 1 ? String(hours).padStart(2, '0') : hours;
+ }
+
+}
+
+module.exports = Hours; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/index.js b/includes/node_modules/prompts/dist/dateparts/index.js
new file mode 100644
index 0000000..754516e
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ DatePart: require('./datepart'),
+ Meridiem: require('./meridiem'),
+ Day: require('./day'),
+ Hours: require('./hours'),
+ Milliseconds: require('./milliseconds'),
+ Minutes: require('./minutes'),
+ Month: require('./month'),
+ Seconds: require('./seconds'),
+ Year: require('./year')
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/meridiem.js b/includes/node_modules/prompts/dist/dateparts/meridiem.js
new file mode 100644
index 0000000..5bc8dd7
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/meridiem.js
@@ -0,0 +1,25 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Meridiem extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours((this.date.getHours() + 12) % 24);
+ }
+
+ down() {
+ this.up();
+ }
+
+ toString() {
+ let meridiem = this.date.getHours() > 12 ? 'pm' : 'am';
+ return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
+ }
+
+}
+
+module.exports = Meridiem; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/milliseconds.js b/includes/node_modules/prompts/dist/dateparts/milliseconds.js
new file mode 100644
index 0000000..3440e3a
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/milliseconds.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Milliseconds extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMilliseconds(this.date.getMilliseconds() + 1);
+ }
+
+ down() {
+ this.date.setMilliseconds(this.date.getMilliseconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMilliseconds(parseInt(val.substr(-this.token.length)));
+ }
+
+ toString() {
+ return String(this.date.getMilliseconds()).padStart(4, '0').substr(0, this.token.length);
+ }
+
+}
+
+module.exports = Milliseconds; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/minutes.js b/includes/node_modules/prompts/dist/dateparts/minutes.js
new file mode 100644
index 0000000..2b8ef1f
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/minutes.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Minutes extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMinutes(this.date.getMinutes() + 1);
+ }
+
+ down() {
+ this.date.setMinutes(this.date.getMinutes() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMinutes(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let m = this.date.getMinutes();
+ return this.token.length > 1 ? String(m).padStart(2, '0') : m;
+ }
+
+}
+
+module.exports = Minutes; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/month.js b/includes/node_modules/prompts/dist/dateparts/month.js
new file mode 100644
index 0000000..f9d4e13
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/month.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Month extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMonth(this.date.getMonth() + 1);
+ }
+
+ down() {
+ this.date.setMonth(this.date.getMonth() - 1);
+ }
+
+ setTo(val) {
+ val = parseInt(val.substr(-2)) - 1;
+ this.date.setMonth(val < 0 ? 0 : val);
+ }
+
+ toString() {
+ let month = this.date.getMonth();
+ let tl = this.token.length;
+ return tl === 2 ? String(month + 1).padStart(2, '0') : tl === 3 ? this.locales.monthsShort[month] : tl === 4 ? this.locales.months[month] : String(month + 1);
+ }
+
+}
+
+module.exports = Month; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/seconds.js b/includes/node_modules/prompts/dist/dateparts/seconds.js
new file mode 100644
index 0000000..e16f030
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/seconds.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Seconds extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setSeconds(this.date.getSeconds() + 1);
+ }
+
+ down() {
+ this.date.setSeconds(this.date.getSeconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setSeconds(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let s = this.date.getSeconds();
+ return this.token.length > 1 ? String(s).padStart(2, '0') : s;
+ }
+
+}
+
+module.exports = Seconds; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/dateparts/year.js b/includes/node_modules/prompts/dist/dateparts/year.js
new file mode 100644
index 0000000..cd62677
--- /dev/null
+++ b/includes/node_modules/prompts/dist/dateparts/year.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Year extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setFullYear(this.date.getFullYear() + 1);
+ }
+
+ down() {
+ this.date.setFullYear(this.date.getFullYear() - 1);
+ }
+
+ setTo(val) {
+ this.date.setFullYear(val.substr(-4));
+ }
+
+ toString() {
+ let year = String(this.date.getFullYear()).padStart(4, '0');
+ return this.token.length === 2 ? year.substr(-2) : year;
+ }
+
+}
+
+module.exports = Year; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/autocomplete.js b/includes/node_modules/prompts/dist/elements/autocomplete.js
new file mode 100644
index 0000000..60e41bc
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/autocomplete.js
@@ -0,0 +1,285 @@
+'use strict';
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('sisteransi'),
+ erase = _require.erase,
+ cursor = _require.cursor;
+
+const _require2 = require('../util'),
+ style = _require2.style,
+ clear = _require2.clear,
+ figures = _require2.figures,
+ wrap = _require2.wrap,
+ entriesToDisplay = _require2.entriesToDisplay;
+
+const getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
+
+const getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
+
+const getIndex = (arr, valOrTitle) => {
+ const index = arr.findIndex(el => el.value === valOrTitle || el.title === valOrTitle);
+ return index > -1 ? index : undefined;
+};
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of auto-complete choices objects
+ * @param {Function} [opts.suggest] Filter function. Defaults to sort by title
+ * @param {Number} [opts.limit=10] Max number of results to show
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.fallback] Fallback message - initial to default value
+ * @param {String} [opts.initial] Index of the default value
+ * @param {Boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.noMatches] The no matches found label
+ */
+
+
+class AutocompletePrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.suggest = opts.suggest;
+ this.choices = opts.choices;
+ this.initial = typeof opts.initial === 'number' ? opts.initial : getIndex(opts.choices, opts.initial);
+ this.select = this.initial || opts.cursor || 0;
+ this.i18n = {
+ noMatches: opts.noMatches || 'no matches found'
+ };
+ this.fallback = opts.fallback || this.initial;
+ this.clearFirst = opts.clearFirst || false;
+ this.suggestions = [];
+ this.input = '';
+ this.limit = opts.limit || 10;
+ this.cursor = 0;
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.render = this.render.bind(this);
+ this.complete = this.complete.bind(this);
+ this.clear = clear('', this.out.columns);
+ this.complete(this.render);
+ this.render();
+ }
+
+ set fallback(fb) {
+ this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
+ }
+
+ get fallback() {
+ let choice;
+ if (typeof this._fb === 'number') choice = this.choices[this._fb];else if (typeof this._fb === 'string') choice = {
+ title: this._fb
+ };
+ return choice || this._fb || {
+ title: this.i18n.noMatches
+ };
+ }
+
+ moveSelect(i) {
+ this.select = i;
+ if (this.suggestions.length > 0) this.value = getVal(this.suggestions, i);else this.value = this.fallback.value;
+ this.fire();
+ }
+
+ complete(cb) {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ const p = _this.completing = _this.suggest(_this.input, _this.choices);
+
+ const suggestions = yield p;
+ if (_this.completing !== p) return;
+ _this.suggestions = suggestions.map((s, i, arr) => ({
+ title: getTitle(arr, i),
+ value: getVal(arr, i),
+ description: s.description
+ }));
+ _this.completing = false;
+ const l = Math.max(suggestions.length - 1, 0);
+
+ _this.moveSelect(Math.min(l, _this.select));
+
+ cb && cb();
+ })();
+ }
+
+ reset() {
+ this.input = '';
+ this.complete(() => {
+ this.moveSelect(this.initial !== void 0 ? this.initial : 0);
+ this.render();
+ });
+ this.render();
+ }
+
+ exit() {
+ if (this.clearFirst && this.input.length > 0) {
+ this.reset();
+ } else {
+ this.done = this.exited = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${c}${s2}`;
+ this.cursor = s1.length + 1;
+ this.complete(this.render);
+ this.render();
+ }
+
+ delete() {
+ if (this.cursor === 0) return this.bell();
+ let s1 = this.input.slice(0, this.cursor - 1);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.cursor = this.cursor - 1;
+ this.render();
+ }
+
+ deleteForward() {
+ if (this.cursor * this.scale >= this.rendered.length) return this.bell();
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor + 1);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.render();
+ }
+
+ first() {
+ this.moveSelect(0);
+ this.render();
+ }
+
+ last() {
+ this.moveSelect(this.suggestions.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.select === 0) {
+ this.moveSelect(this.suggestions.length - 1);
+ } else {
+ this.moveSelect(this.select - 1);
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else {
+ this.moveSelect(this.select + 1);
+ }
+
+ this.render();
+ }
+
+ next() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else this.moveSelect(this.select + 1);
+
+ this.render();
+ }
+
+ nextPage() {
+ this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
+ this.render();
+ }
+
+ prevPage() {
+ this.moveSelect(Math.max(this.select - this.limit, 0));
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0) return this.bell();
+ this.cursor = this.cursor - 1;
+ this.render();
+ }
+
+ right() {
+ if (this.cursor * this.scale >= this.rendered.length) return this.bell();
+ this.cursor = this.cursor + 1;
+ this.render();
+ }
+
+ renderOption(v, hovered, isStart, isEnd) {
+ let desc;
+ let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : ' ';
+ let title = hovered ? color.cyan().underline(v.title) : v.title;
+ prefix = (hovered ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+
+ if (v.description) {
+ desc = ` - ${v.description}`;
+
+ if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, {
+ margin: 3,
+ width: this.out.columns
+ });
+ }
+ }
+
+ return prefix + ' ' + title + color.gray(desc || '');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let _entriesToDisplay = entriesToDisplay(this.select, this.choices.length, this.limit),
+ startIndex = _entriesToDisplay.startIndex,
+ endIndex = _entriesToDisplay.endIndex;
+
+ this.outputText = [style.symbol(this.done, this.aborted, this.exited), color.bold(this.msg), style.delimiter(this.completing), this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)].join(' ');
+
+ if (!this.done) {
+ const suggestions = this.suggestions.slice(startIndex, endIndex).map((item, i) => this.renderOption(item, this.select === i + startIndex, i === 0 && startIndex > 0, i + startIndex === endIndex - 1 && endIndex < this.choices.length)).join('\n');
+ this.outputText += `\n` + (suggestions || color.gray(this.fallback.title));
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = AutocompletePrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/autocompleteMultiselect.js b/includes/node_modules/prompts/dist/elements/autocompleteMultiselect.js
new file mode 100644
index 0000000..ac4af0d
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/autocompleteMultiselect.js
@@ -0,0 +1,201 @@
+'use strict';
+
+const color = require('kleur');
+
+const _require = require('sisteransi'),
+ cursor = _require.cursor;
+
+const MultiselectPrompt = require('./multiselect');
+
+const _require2 = require('../util'),
+ clear = _require2.clear,
+ style = _require2.style,
+ figures = _require2.figures;
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class AutocompleteMultiselectPrompt extends MultiselectPrompt {
+ constructor(opts = {}) {
+ opts.overrideRender = true;
+ super(opts);
+ this.inputValue = '';
+ this.clear = clear('', this.out.columns);
+ this.filteredOptions = this.value;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.filteredOptions.length - 1;
+ this.render();
+ }
+
+ next() {
+ this.cursor = (this.cursor + 1) % this.filteredOptions.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.filteredOptions.length - 1;
+ } else {
+ this.cursor--;
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.filteredOptions.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+
+ this.render();
+ }
+
+ left() {
+ this.filteredOptions[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.filteredOptions[this.cursor].selected = true;
+ this.render();
+ }
+
+ delete() {
+ if (this.inputValue.length) {
+ this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
+ this.updateFilteredOptions();
+ }
+ }
+
+ updateFilteredOptions() {
+ const currentHighlight = this.filteredOptions[this.cursor];
+ this.filteredOptions = this.value.filter(v => {
+ if (this.inputValue) {
+ if (typeof v.title === 'string') {
+ if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+
+ if (typeof v.value === 'string') {
+ if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ return true;
+ });
+ const newHighlightIndex = this.filteredOptions.findIndex(v => v === currentHighlight);
+ this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.filteredOptions[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ handleInputChange(c) {
+ this.inputValue = this.inputValue + c;
+ this.updateFilteredOptions();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else {
+ this.handleInputChange(c);
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+
+ return `
+Instructions:
+ ${figures.arrowUp}/${figures.arrowDown}: Highlight option
+ ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
+ [a,b,c]/delete: Filter choices
+ enter/return: Complete answer
+`;
+ }
+
+ return '';
+ }
+
+ renderCurrentInput() {
+ return `
+Filtered results for: ${this.inputValue ? this.inputValue : color.gray('Enter something to filter')}\n`;
+ }
+
+ renderOption(cursor, v, i) {
+ let title;
+ if (v.disabled) title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);else title = cursor === i ? color.cyan().underline(v.title) : v.title;
+ return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + title;
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value.filter(e => e.selected).map(v => v.title).join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
+
+ if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render(); // print prompt
+
+ let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.renderDoneOrInstructions()].join(' ');
+
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+
+ prompt += this.renderOptions(this.filteredOptions);
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+
+}
+
+module.exports = AutocompleteMultiselectPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/confirm.js b/includes/node_modules/prompts/dist/elements/confirm.js
new file mode 100644
index 0000000..6c342d2
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/confirm.js
@@ -0,0 +1,93 @@
+"use strict";
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear;
+
+const _require2 = require('sisteransi'),
+ erase = _require2.erase,
+ cursor = _require2.cursor;
+/**
+ * ConfirmPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial] Default value (true/false)
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.yes] The "Yes" label
+ * @param {String} [opts.yesOption] The "Yes" option when choosing between yes/no
+ * @param {String} [opts.no] The "No" label
+ * @param {String} [opts.noOption] The "No" option when choosing between yes/no
+ */
+
+
+class ConfirmPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = opts.initial;
+ this.initialValue = !!opts.initial;
+ this.yesMsg = opts.yes || 'yes';
+ this.yesOption = opts.yesOption || '(Y/n)';
+ this.noMsg = opts.no || 'no';
+ this.noOption = opts.noOption || '(y/N)';
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.value = this.value || false;
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ if (c.toLowerCase() === 'y') {
+ this.value = true;
+ return this.submit();
+ }
+
+ if (c.toLowerCase() === 'n') {
+ this.value = false;
+ return this.submit();
+ }
+
+ return this.bell();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.done ? this.value ? this.yesMsg : this.noMsg : color.gray(this.initialValue ? this.yesOption : this.noOption)].join(' ');
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = ConfirmPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/date.js b/includes/node_modules/prompts/dist/elements/date.js
new file mode 100644
index 0000000..0b254f8
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/date.js
@@ -0,0 +1,250 @@
+'use strict';
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear,
+ figures = _require.figures;
+
+const _require2 = require('sisteransi'),
+ erase = _require2.erase,
+ cursor = _require2.cursor;
+
+const _require3 = require('../dateparts'),
+ DatePart = _require3.DatePart,
+ Meridiem = _require3.Meridiem,
+ Day = _require3.Day,
+ Hours = _require3.Hours,
+ Milliseconds = _require3.Milliseconds,
+ Minutes = _require3.Minutes,
+ Month = _require3.Month,
+ Seconds = _require3.Seconds,
+ Year = _require3.Year;
+
+const regex = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g;
+const regexGroups = {
+ 1: ({
+ token
+ }) => token.replace(/\\(.)/g, '$1'),
+ 2: opts => new Day(opts),
+ // Day // TODO
+ 3: opts => new Month(opts),
+ // Month
+ 4: opts => new Year(opts),
+ // Year
+ 5: opts => new Meridiem(opts),
+ // AM/PM // TODO (special)
+ 6: opts => new Hours(opts),
+ // Hours
+ 7: opts => new Minutes(opts),
+ // Minutes
+ 8: opts => new Seconds(opts),
+ // Seconds
+ 9: opts => new Milliseconds(opts) // Fractional seconds
+
+};
+const dfltLocales = {
+ months: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(','),
+ monthsShort: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
+ weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
+ weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(',')
+};
+/**
+ * DatePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Number} [opts.initial] Index of default value
+ * @param {String} [opts.mask] The format mask
+ * @param {object} [opts.locales] The date locales
+ * @param {String} [opts.error] The error message shown on invalid value
+ * @param {Function} [opts.validate] Function to validate the submitted value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+class DatePrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = 0;
+ this.typed = '';
+ this.locales = Object.assign(dfltLocales, opts.locales);
+ this._date = opts.initial || new Date();
+ this.errorMsg = opts.error || 'Please Enter A Valid Value';
+
+ this.validator = opts.validate || (() => true);
+
+ this.mask = opts.mask || 'YYYY-MM-DD HH:mm:ss';
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ get value() {
+ return this.date;
+ }
+
+ get date() {
+ return this._date;
+ }
+
+ set date(date) {
+ if (date) this._date.setTime(date.getTime());
+ }
+
+ set mask(mask) {
+ let result;
+ this.parts = [];
+
+ while (result = regex.exec(mask)) {
+ let match = result.shift();
+ let idx = result.findIndex(gr => gr != null);
+ this.parts.push(idx in regexGroups ? regexGroups[idx]({
+ token: result[idx] || match,
+ date: this.date,
+ parts: this.parts,
+ locales: this.locales
+ }) : result[idx] || match);
+ }
+
+ let parts = this.parts.reduce((arr, i) => {
+ if (typeof i === 'string' && typeof arr[arr.length - 1] === 'string') arr[arr.length - 1] += i;else arr.push(i);
+ return arr;
+ }, []);
+ this.parts.splice(0);
+ this.parts.push(...parts);
+ this.reset();
+ }
+
+ moveCursor(n) {
+ this.typed = '';
+ this.cursor = n;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(this.parts.findIndex(p => p instanceof DatePart));
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ validate() {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ let valid = yield _this.validator(_this.value);
+
+ if (typeof valid === 'string') {
+ _this.errorMsg = valid;
+ valid = false;
+ }
+
+ _this.error = !valid;
+ })();
+ }
+
+ submit() {
+ var _this2 = this;
+
+ return _asyncToGenerator(function* () {
+ yield _this2.validate();
+
+ if (_this2.error) {
+ _this2.color = 'red';
+
+ _this2.fire();
+
+ _this2.render();
+
+ return;
+ }
+
+ _this2.done = true;
+ _this2.aborted = false;
+
+ _this2.fire();
+
+ _this2.render();
+
+ _this2.out.write('\n');
+
+ _this2.close();
+ })();
+ }
+
+ up() {
+ this.typed = '';
+ this.parts[this.cursor].up();
+ this.render();
+ }
+
+ down() {
+ this.typed = '';
+ this.parts[this.cursor].down();
+ this.render();
+ }
+
+ left() {
+ let prev = this.parts[this.cursor].prev();
+ if (prev == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(prev));
+ this.render();
+ }
+
+ right() {
+ let next = this.parts[this.cursor].next();
+ if (next == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(next));
+ this.render();
+ }
+
+ next() {
+ let next = this.parts[this.cursor].next();
+ this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex(part => part instanceof DatePart));
+ this.render();
+ }
+
+ _(c) {
+ if (/\d/.test(c)) {
+ this.typed += c;
+ this.parts[this.cursor].setTo(this.typed);
+ this.render();
+ }
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render(); // Print prompt
+
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join('')].join(' '); // Print error
+
+ if (this.error) {
+ this.outputText += this.errorMsg.split('\n').reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = DatePrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/index.js b/includes/node_modules/prompts/dist/elements/index.js
new file mode 100644
index 0000000..cf0ccc1
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ TextPrompt: require('./text'),
+ SelectPrompt: require('./select'),
+ TogglePrompt: require('./toggle'),
+ DatePrompt: require('./date'),
+ NumberPrompt: require('./number'),
+ MultiselectPrompt: require('./multiselect'),
+ AutocompletePrompt: require('./autocomplete'),
+ AutocompleteMultiselectPrompt: require('./autocompleteMultiselect'),
+ ConfirmPrompt: require('./confirm')
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/multiselect.js b/includes/node_modules/prompts/dist/elements/multiselect.js
new file mode 100644
index 0000000..2d129ea
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/multiselect.js
@@ -0,0 +1,289 @@
+'use strict';
+
+const color = require('kleur');
+
+const _require = require('sisteransi'),
+ cursor = _require.cursor;
+
+const Prompt = require('./prompt');
+
+const _require2 = require('../util'),
+ clear = _require2.clear,
+ figures = _require2.figures,
+ style = _require2.style,
+ wrap = _require2.wrap,
+ entriesToDisplay = _require2.entriesToDisplay;
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class MultiselectPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = opts.cursor || 0;
+ this.scrollIndex = opts.cursor || 0;
+ this.hint = opts.hint || '';
+ this.warn = opts.warn || '- This option is disabled -';
+ this.minSelected = opts.min;
+ this.showMinError = false;
+ this.maxChoices = opts.max;
+ this.instructions = opts.instructions;
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string') ch = {
+ title: ch,
+ value: idx
+ };
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ description: ch && ch.description,
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.clear = clear('', this.out.columns);
+
+ if (!opts.overrideRender) {
+ this.render();
+ }
+ }
+
+ reset() {
+ this.value.map(v => !v.selected);
+ this.cursor = 0;
+ this.fire();
+ this.render();
+ }
+
+ selected() {
+ return this.value.filter(v => v.selected);
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ const selected = this.value.filter(e => e.selected);
+
+ if (this.minSelected && selected.length < this.minSelected) {
+ this.showMinError = true;
+ this.render();
+ } else {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length - 1;
+ this.render();
+ }
+
+ next() {
+ this.cursor = (this.cursor + 1) % this.value.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.value.length - 1;
+ } else {
+ this.cursor--;
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.value.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+
+ this.render();
+ }
+
+ left() {
+ this.value[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.value[this.cursor].selected = true;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.value[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ toggleAll() {
+ if (this.maxChoices !== undefined || this.value[this.cursor].disabled) {
+ return this.bell();
+ }
+
+ const newSelected = !this.value[this.cursor].selected;
+ this.value.filter(v => !v.disabled).forEach(v => v.selected = newSelected);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else if (c === 'a') {
+ this.toggleAll();
+ } else {
+ return this.bell();
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+
+ return '\nInstructions:\n' + ` ${figures.arrowUp}/${figures.arrowDown}: Highlight option\n` + ` ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection\n` + (this.maxChoices === undefined ? ` a: Toggle all\n` : '') + ` enter/return: Complete answer`;
+ }
+
+ return '';
+ }
+
+ renderOption(cursor, v, i, arrowIndicator) {
+ const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + arrowIndicator + ' ';
+ let title, desc;
+
+ if (v.disabled) {
+ title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ } else {
+ title = cursor === i ? color.cyan().underline(v.title) : v.title;
+
+ if (cursor === i && v.description) {
+ desc = ` - ${v.description}`;
+
+ if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, {
+ margin: prefix.length,
+ width: this.out.columns
+ });
+ }
+ }
+ }
+
+ return prefix + title + color.gray(desc || '');
+ } // shared with autocompleteMultiselect
+
+
+ paginateOptions(options) {
+ if (options.length === 0) {
+ return color.red('No matches for this query.');
+ }
+
+ let _entriesToDisplay = entriesToDisplay(this.cursor, options.length, this.optionsPerPage),
+ startIndex = _entriesToDisplay.startIndex,
+ endIndex = _entriesToDisplay.endIndex;
+
+ let prefix,
+ styledOptions = [];
+
+ for (let i = startIndex; i < endIndex; i++) {
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < options.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+
+ styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
+ }
+
+ return '\n' + styledOptions.join('\n');
+ } // shared with autocomleteMultiselect
+
+
+ renderOptions(options) {
+ if (!this.done) {
+ return this.paginateOptions(options);
+ }
+
+ return '';
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value.filter(e => e.selected).map(v => v.title).join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions()];
+
+ if (this.value[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render(); // print prompt
+
+ let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.renderDoneOrInstructions()].join(' ');
+
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+
+ prompt += this.renderOptions(this.value);
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+
+}
+
+module.exports = MultiselectPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/number.js b/includes/node_modules/prompts/dist/elements/number.js
new file mode 100644
index 0000000..fd144af
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/number.js
@@ -0,0 +1,250 @@
+"use strict";
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('sisteransi'),
+ cursor = _require.cursor,
+ erase = _require.erase;
+
+const _require2 = require('../util'),
+ style = _require2.style,
+ figures = _require2.figures,
+ clear = _require2.clear,
+ lines = _require2.lines;
+
+const isNumber = /[0-9]/;
+
+const isDef = any => any !== undefined;
+
+const round = (number, precision) => {
+ let factor = Math.pow(10, precision);
+ return Math.round(number * factor) / factor;
+};
+/**
+ * NumberPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {Number} [opts.initial] Default value
+ * @param {Number} [opts.max=+Infinity] Max value
+ * @param {Number} [opts.min=-Infinity] Min value
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+
+
+class NumberPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.msg = opts.message;
+ this.initial = isDef(opts.initial) ? opts.initial : '';
+ this.float = !!opts.float;
+ this.round = opts.round || 2;
+ this.inc = opts.increment || 1;
+ this.min = isDef(opts.min) ? opts.min : -Infinity;
+ this.max = isDef(opts.max) ? opts.max : Infinity;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+
+ this.validator = opts.validate || (() => true);
+
+ this.color = `cyan`;
+ this.value = ``;
+ this.typed = ``;
+ this.lastHit = 0;
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && v !== 0) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(`${this.initial}`));
+ this._value = ``;
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(`${round(v, this.round)}`);
+ this._value = round(v, this.round);
+ }
+
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ parse(x) {
+ return this.float ? parseFloat(x) : parseInt(x);
+ }
+
+ valid(c) {
+ return c === `-` || c === `.` && this.float || isNumber.test(c);
+ }
+
+ reset() {
+ this.typed = ``;
+ this.value = ``;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ let x = this.value;
+ this.value = x !== `` ? x : this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write(`\n`);
+ this.close();
+ }
+
+ validate() {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ let valid = yield _this.validator(_this.value);
+
+ if (typeof valid === `string`) {
+ _this.errorMsg = valid;
+ valid = false;
+ }
+
+ _this.error = !valid;
+ })();
+ }
+
+ submit() {
+ var _this2 = this;
+
+ return _asyncToGenerator(function* () {
+ yield _this2.validate();
+
+ if (_this2.error) {
+ _this2.color = `red`;
+
+ _this2.fire();
+
+ _this2.render();
+
+ return;
+ }
+
+ let x = _this2.value;
+ _this2.value = x !== `` ? x : _this2.initial;
+ _this2.done = true;
+ _this2.aborted = false;
+ _this2.error = false;
+
+ _this2.fire();
+
+ _this2.render();
+
+ _this2.out.write(`\n`);
+
+ _this2.close();
+ })();
+ }
+
+ up() {
+ this.typed = ``;
+
+ if (this.value === '') {
+ this.value = this.min - this.inc;
+ }
+
+ if (this.value >= this.max) return this.bell();
+ this.value += this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ down() {
+ this.typed = ``;
+
+ if (this.value === '') {
+ this.value = this.min + this.inc;
+ }
+
+ if (this.value <= this.min) return this.bell();
+ this.value -= this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ delete() {
+ let val = this.value.toString();
+ if (val.length === 0) return this.bell();
+ this.value = this.parse(val = val.slice(0, -1)) || ``;
+
+ if (this.value !== '' && this.value < this.min) {
+ this.value = this.min;
+ }
+
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ next() {
+ this.value = this.initial;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (!this.valid(c)) return this.bell();
+ const now = Date.now();
+ if (now - this.lastHit > 1000) this.typed = ``; // 1s elapsed
+
+ this.typed += c;
+ this.lastHit = now;
+ this.color = `cyan`;
+ if (c === `.`) return this.fire();
+ this.value = Math.min(this.parse(this.typed), this.max);
+ if (this.value > this.max) this.value = this.max;
+ if (this.value < this.min) this.value = this.min;
+ this.fire();
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+
+ if (!this.firstRender) {
+ if (this.outputError) this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+
+ super.render();
+ this.outputError = ''; // Print prompt
+
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), !this.done || !this.done && !this.placeholder ? color[this.color]().underline(this.rendered) : this.rendered].join(` `); // Print error
+
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`).reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
+ }
+
+}
+
+module.exports = NumberPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/prompt.js b/includes/node_modules/prompts/dist/elements/prompt.js
new file mode 100644
index 0000000..7deef04
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/prompt.js
@@ -0,0 +1,82 @@
+'use strict';
+
+const readline = require('readline');
+
+const _require = require('../util'),
+ action = _require.action;
+
+const EventEmitter = require('events');
+
+const _require2 = require('sisteransi'),
+ beep = _require2.beep,
+ cursor = _require2.cursor;
+
+const color = require('kleur');
+/**
+ * Base prompt skeleton
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class Prompt extends EventEmitter {
+ constructor(opts = {}) {
+ super();
+ this.firstRender = true;
+ this.in = opts.stdin || process.stdin;
+ this.out = opts.stdout || process.stdout;
+
+ this.onRender = (opts.onRender || (() => void 0)).bind(this);
+
+ const rl = readline.createInterface({
+ input: this.in,
+ escapeCodeTimeout: 50
+ });
+ readline.emitKeypressEvents(this.in, rl);
+ if (this.in.isTTY) this.in.setRawMode(true);
+ const isSelect = ['SelectPrompt', 'MultiselectPrompt'].indexOf(this.constructor.name) > -1;
+
+ const keypress = (str, key) => {
+ let a = action(key, isSelect);
+
+ if (a === false) {
+ this._ && this._(str, key);
+ } else if (typeof this[a] === 'function') {
+ this[a](key);
+ } else {
+ this.bell();
+ }
+ };
+
+ this.close = () => {
+ this.out.write(cursor.show);
+ this.in.removeListener('keypress', keypress);
+ if (this.in.isTTY) this.in.setRawMode(false);
+ rl.close();
+ this.emit(this.aborted ? 'abort' : this.exited ? 'exit' : 'submit', this.value);
+ this.closed = true;
+ };
+
+ this.in.on('keypress', keypress);
+ }
+
+ fire() {
+ this.emit('state', {
+ value: this.value,
+ aborted: !!this.aborted,
+ exited: !!this.exited
+ });
+ }
+
+ bell() {
+ this.out.write(beep);
+ }
+
+ render() {
+ this.onRender(color);
+ if (this.firstRender) this.firstRender = false;
+ }
+
+}
+
+module.exports = Prompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/select.js b/includes/node_modules/prompts/dist/elements/select.js
new file mode 100644
index 0000000..5e27c69
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/select.js
@@ -0,0 +1,190 @@
+'use strict';
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear,
+ figures = _require.figures,
+ wrap = _require.wrap,
+ entriesToDisplay = _require.entriesToDisplay;
+
+const _require2 = require('sisteransi'),
+ cursor = _require2.cursor;
+/**
+ * SelectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {Number} [opts.initial] Index of default value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ */
+
+
+class SelectPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.hint = opts.hint || '- Use arrow-keys. Return to submit.';
+ this.warn = opts.warn || '- This option is disabled';
+ this.cursor = opts.initial || 0;
+ this.choices = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string') ch = {
+ title: ch,
+ value: idx
+ };
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ description: ch && ch.description,
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = (this.choices[this.cursor] || {}).value;
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ moveCursor(n) {
+ this.cursor = n;
+ this.value = this.choices[n].value;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(0);
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ if (!this.selection.disabled) {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ } else this.bell();
+ }
+
+ first() {
+ this.moveCursor(0);
+ this.render();
+ }
+
+ last() {
+ this.moveCursor(this.choices.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.moveCursor(this.choices.length - 1);
+ } else {
+ this.moveCursor(this.cursor - 1);
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.choices.length - 1) {
+ this.moveCursor(0);
+ } else {
+ this.moveCursor(this.cursor + 1);
+ }
+
+ this.render();
+ }
+
+ next() {
+ this.moveCursor((this.cursor + 1) % this.choices.length);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') return this.submit();
+ }
+
+ get selection() {
+ return this.choices[this.cursor];
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let _entriesToDisplay = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage),
+ startIndex = _entriesToDisplay.startIndex,
+ endIndex = _entriesToDisplay.endIndex; // Print prompt
+
+
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.done ? this.selection.title : this.selection.disabled ? color.yellow(this.warn) : color.gray(this.hint)].join(' '); // Print choices
+
+ if (!this.done) {
+ this.outputText += '\n';
+
+ for (let i = startIndex; i < endIndex; i++) {
+ let title,
+ prefix,
+ desc = '',
+ v = this.choices[i]; // Determine whether to display "more choices" indicators
+
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < this.choices.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+
+ if (v.disabled) {
+ title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + ' ' : ' ') + prefix;
+ } else {
+ title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
+ prefix = (this.cursor === i ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+
+ if (v.description && this.cursor === i) {
+ desc = ` - ${v.description}`;
+
+ if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, {
+ margin: 3,
+ width: this.out.columns
+ });
+ }
+ }
+ }
+
+ this.outputText += `${prefix} ${title}${color.gray(desc)}\n`;
+ }
+ }
+
+ this.out.write(this.outputText);
+ }
+
+}
+
+module.exports = SelectPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/text.js b/includes/node_modules/prompts/dist/elements/text.js
new file mode 100644
index 0000000..c38a070
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/text.js
@@ -0,0 +1,245 @@
+"use strict";
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('sisteransi'),
+ erase = _require.erase,
+ cursor = _require.cursor;
+
+const _require2 = require('../util'),
+ style = _require2.style,
+ clear = _require2.clear,
+ lines = _require2.lines,
+ figures = _require2.figures;
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.initial] Default value
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+
+
+class TextPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.msg = opts.message;
+ this.initial = opts.initial || ``;
+
+ this.validator = opts.validate || (() => true);
+
+ this.value = ``;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.clear = clear(``, this.out.columns);
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && this.initial) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(this.initial));
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(v);
+ }
+
+ this._value = v;
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ reset() {
+ this.value = ``;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.value = this.value || this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.red = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ validate() {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ let valid = yield _this.validator(_this.value);
+
+ if (typeof valid === `string`) {
+ _this.errorMsg = valid;
+ valid = false;
+ }
+
+ _this.error = !valid;
+ })();
+ }
+
+ submit() {
+ var _this2 = this;
+
+ return _asyncToGenerator(function* () {
+ _this2.value = _this2.value || _this2.initial;
+ _this2.cursorOffset = 0;
+ _this2.cursor = _this2.rendered.length;
+ yield _this2.validate();
+
+ if (_this2.error) {
+ _this2.red = true;
+
+ _this2.fire();
+
+ _this2.render();
+
+ return;
+ }
+
+ _this2.done = true;
+ _this2.aborted = false;
+
+ _this2.fire();
+
+ _this2.render();
+
+ _this2.out.write('\n');
+
+ _this2.close();
+ })();
+ }
+
+ next() {
+ if (!this.placeholder) return this.bell();
+ this.value = this.initial;
+ this.cursor = this.rendered.length;
+ this.fire();
+ this.render();
+ }
+
+ moveCursor(n) {
+ if (this.placeholder) return;
+ this.cursor = this.cursor + n;
+ this.cursorOffset += n;
+ }
+
+ _(c, key) {
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${c}${s2}`;
+ this.red = false;
+ this.cursor = this.placeholder ? 0 : s1.length + 1;
+ this.render();
+ }
+
+ delete() {
+ if (this.isCursorAtStart()) return this.bell();
+ let s1 = this.value.slice(0, this.cursor - 1);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+
+ if (this.isCursorAtStart()) {
+ this.cursorOffset = 0;
+ } else {
+ this.cursorOffset++;
+ this.moveCursor(-1);
+ }
+
+ this.render();
+ }
+
+ deleteForward() {
+ if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor + 1);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+
+ if (this.isCursorAtEnd()) {
+ this.cursorOffset = 0;
+ } else {
+ this.cursorOffset++;
+ }
+
+ this.render();
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length;
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0 || this.placeholder) return this.bell();
+ this.moveCursor(-1);
+ this.render();
+ }
+
+ right() {
+ if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ this.moveCursor(1);
+ this.render();
+ }
+
+ isCursorAtStart() {
+ return this.cursor === 0 || this.placeholder && this.cursor === 1;
+ }
+
+ isCursorAtEnd() {
+ return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
+ }
+
+ render() {
+ if (this.closed) return;
+
+ if (!this.firstRender) {
+ if (this.outputError) this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+
+ super.render();
+ this.outputError = '';
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.red ? color.red(this.rendered) : this.rendered].join(` `);
+
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`).reduce((a, l, i) => a + `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
+ }
+
+}
+
+module.exports = TextPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/elements/toggle.js b/includes/node_modules/prompts/dist/elements/toggle.js
new file mode 100644
index 0000000..d942f60
--- /dev/null
+++ b/includes/node_modules/prompts/dist/elements/toggle.js
@@ -0,0 +1,124 @@
+"use strict";
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear;
+
+const _require2 = require('sisteransi'),
+ cursor = _require2.cursor,
+ erase = _require2.erase;
+/**
+ * TogglePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial=false] Default value
+ * @param {String} [opts.active='no'] Active label
+ * @param {String} [opts.inactive='off'] Inactive label
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class TogglePrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = !!opts.initial;
+ this.active = opts.active || 'on';
+ this.inactive = opts.inactive || 'off';
+ this.initialValue = this.value;
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ deactivate() {
+ if (this.value === false) return this.bell();
+ this.value = false;
+ this.render();
+ }
+
+ activate() {
+ if (this.value === true) return this.bell();
+ this.value = true;
+ this.render();
+ }
+
+ delete() {
+ this.deactivate();
+ }
+
+ left() {
+ this.deactivate();
+ }
+
+ right() {
+ this.activate();
+ }
+
+ down() {
+ this.deactivate();
+ }
+
+ up() {
+ this.activate();
+ }
+
+ next() {
+ this.value = !this.value;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.value = !this.value;
+ } else if (c === '1') {
+ this.value = true;
+ } else if (c === '0') {
+ this.value = false;
+ } else return this.bell();
+
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.value ? this.inactive : color.cyan().underline(this.inactive), color.gray('/'), this.value ? color.cyan().underline(this.active) : this.active].join(' ');
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = TogglePrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/index.js b/includes/node_modules/prompts/dist/index.js
new file mode 100644
index 0000000..f30e9e7
--- /dev/null
+++ b/includes/node_modules/prompts/dist/index.js
@@ -0,0 +1,154 @@
+'use strict';
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const prompts = require('./prompts');
+
+const passOn = ['suggest', 'format', 'onState', 'validate', 'onRender', 'type'];
+
+const noop = () => {};
+/**
+ * Prompt for a series of questions
+ * @param {Array|Object} questions Single question object or Array of question objects
+ * @param {Function} [onSubmit] Callback function called on prompt submit
+ * @param {Function} [onCancel] Callback function called on cancel/abort
+ * @returns {Object} Object with values from user input
+ */
+
+
+function prompt() {
+ return _prompt.apply(this, arguments);
+}
+
+function _prompt() {
+ _prompt = _asyncToGenerator(function* (questions = [], {
+ onSubmit = noop,
+ onCancel = noop
+ } = {}) {
+ const answers = {};
+ const override = prompt._override || {};
+ questions = [].concat(questions);
+ let answer, question, quit, name, type, lastPrompt;
+
+ const getFormattedAnswer = /*#__PURE__*/function () {
+ var _ref = _asyncToGenerator(function* (question, answer, skipValidation = false) {
+ if (!skipValidation && question.validate && question.validate(answer) !== true) {
+ return;
+ }
+
+ return question.format ? yield question.format(answer, answers) : answer;
+ });
+
+ return function getFormattedAnswer(_x, _x2) {
+ return _ref.apply(this, arguments);
+ };
+ }();
+
+ var _iterator = _createForOfIteratorHelper(questions),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ question = _step.value;
+ var _question = question;
+ name = _question.name;
+ type = _question.type;
+
+ // evaluate type first and skip if type is a falsy value
+ if (typeof type === 'function') {
+ type = yield type(answer, _objectSpread({}, answers), question);
+ question['type'] = type;
+ }
+
+ if (!type) continue; // if property is a function, invoke it unless it's a special function
+
+ for (let key in question) {
+ if (passOn.includes(key)) continue;
+ let value = question[key];
+ question[key] = typeof value === 'function' ? yield value(answer, _objectSpread({}, answers), lastPrompt) : value;
+ }
+
+ lastPrompt = question;
+
+ if (typeof question.message !== 'string') {
+ throw new Error('prompt message is required');
+ } // update vars in case they changed
+
+
+ var _question2 = question;
+ name = _question2.name;
+ type = _question2.type;
+
+ if (prompts[type] === void 0) {
+ throw new Error(`prompt type (${type}) is not defined`);
+ }
+
+ if (override[question.name] !== undefined) {
+ answer = yield getFormattedAnswer(question, override[question.name]);
+
+ if (answer !== undefined) {
+ answers[name] = answer;
+ continue;
+ }
+ }
+
+ try {
+ // Get the injected answer if there is one or prompt the user
+ answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield prompts[type](question);
+ answers[name] = answer = yield getFormattedAnswer(question, answer, true);
+ quit = yield onSubmit(question, answer, answers);
+ } catch (err) {
+ quit = !(yield onCancel(question, answers));
+ }
+
+ if (quit) return answers;
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ return answers;
+ });
+ return _prompt.apply(this, arguments);
+}
+
+function getInjectedAnswer(injected, deafultValue) {
+ const answer = injected.shift();
+
+ if (answer instanceof Error) {
+ throw answer;
+ }
+
+ return answer === undefined ? deafultValue : answer;
+}
+
+function inject(answers) {
+ prompt._injected = (prompt._injected || []).concat(answers);
+}
+
+function override(answers) {
+ prompt._override = Object.assign({}, answers);
+}
+
+module.exports = Object.assign(prompt, {
+ prompt,
+ prompts,
+ inject,
+ override
+}); \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/prompts.js b/includes/node_modules/prompts/dist/prompts.js
new file mode 100644
index 0000000..31f2648
--- /dev/null
+++ b/includes/node_modules/prompts/dist/prompts.js
@@ -0,0 +1,222 @@
+'use strict';
+
+const $ = exports;
+
+const el = require('./elements');
+
+const noop = v => v;
+
+function toPrompt(type, args, opts = {}) {
+ return new Promise((res, rej) => {
+ const p = new el[type](args);
+ const onAbort = opts.onAbort || noop;
+ const onSubmit = opts.onSubmit || noop;
+ const onExit = opts.onExit || noop;
+ p.on('state', args.onState || noop);
+ p.on('submit', x => res(onSubmit(x)));
+ p.on('exit', x => res(onExit(x)));
+ p.on('abort', x => rej(onAbort(x)));
+ });
+}
+/**
+ * Text prompt
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.text = args => toPrompt('TextPrompt', args);
+/**
+ * Password prompt with masked input
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.password = args => {
+ args.style = 'password';
+ return $.text(args);
+};
+/**
+ * Prompt where input is invisible, like sudo
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.invisible = args => {
+ args.style = 'invisible';
+ return $.text(args);
+};
+/**
+ * Number prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.number = args => toPrompt('NumberPrompt', args);
+/**
+ * Date prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.date = args => toPrompt('DatePrompt', args);
+/**
+ * Classic yes/no prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.confirm = args => toPrompt('ConfirmPrompt', args);
+/**
+ * List prompt, split intput string by `seperator`
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {string} [args.separator] String separator
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input, in form of an `Array`
+ */
+
+
+$.list = args => {
+ const sep = args.separator || ',';
+ return toPrompt('TextPrompt', args, {
+ onSubmit: str => str.split(sep).map(s => s.trim())
+ });
+};
+/**
+ * Toggle/switch prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {string} [args.active="on"] Text for `active` state
+ * @param {string} [args.inactive="off"] Text for `inactive` state
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.toggle = args => toPrompt('TogglePrompt', args);
+/**
+ * Interactive select prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value }, ...]`
+ * @param {number} [args.initial] Index of default value
+ * @param {String} [args.hint] Hint to display
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.select = args => toPrompt('SelectPrompt', args);
+/**
+ * Interactive multi-select / autocompleteMultiselect prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value, [selected] }, ...]`
+ * @param {number} [args.max] Max select
+ * @param {string} [args.hint] Hint to display user
+ * @param {Number} [args.cursor=0] Cursor start position
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.multiselect = args => {
+ args.choices = [].concat(args.choices || []);
+
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+
+ return toPrompt('MultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+$.autocompleteMultiselect = args => {
+ args.choices = [].concat(args.choices || []);
+
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+
+ return toPrompt('AutocompleteMultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+const byTitle = (input, choices) => Promise.resolve(choices.filter(item => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase()));
+/**
+ * Interactive auto-complete prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of auto-complete choices objects `[{ title, value }, ...]`
+ * @param {Function} [args.suggest] Function to filter results based on user input. Defaults to sort by `title`
+ * @param {number} [args.limit=10] Max number of results to show
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {String} [args.initial] Index of the default value
+ * @param {boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {String} [args.fallback] Fallback message - defaults to initial value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.autocomplete = args => {
+ args.suggest = args.suggest || byTitle;
+ args.choices = [].concat(args.choices || []);
+ return toPrompt('AutocompletePrompt', args);
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/action.js b/includes/node_modules/prompts/dist/util/action.js
new file mode 100644
index 0000000..c36b7db
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/action.js
@@ -0,0 +1,38 @@
+'use strict';
+
+module.exports = (key, isSelect) => {
+ if (key.meta && key.name !== 'escape') return;
+
+ if (key.ctrl) {
+ if (key.name === 'a') return 'first';
+ if (key.name === 'c') return 'abort';
+ if (key.name === 'd') return 'abort';
+ if (key.name === 'e') return 'last';
+ if (key.name === 'g') return 'reset';
+ }
+
+ if (isSelect) {
+ if (key.name === 'j') return 'down';
+ if (key.name === 'k') return 'up';
+ }
+
+ if (key.name === 'return') return 'submit';
+ if (key.name === 'enter') return 'submit'; // ctrl + J
+
+ if (key.name === 'backspace') return 'delete';
+ if (key.name === 'delete') return 'deleteForward';
+ if (key.name === 'abort') return 'abort';
+ if (key.name === 'escape') return 'exit';
+ if (key.name === 'tab') return 'next';
+ if (key.name === 'pagedown') return 'nextPage';
+ if (key.name === 'pageup') return 'prevPage'; // TODO create home() in prompt types (e.g. TextPrompt)
+
+ if (key.name === 'home') return 'home'; // TODO create end() in prompt types (e.g. TextPrompt)
+
+ if (key.name === 'end') return 'end';
+ if (key.name === 'up') return 'up';
+ if (key.name === 'down') return 'down';
+ if (key.name === 'right') return 'right';
+ if (key.name === 'left') return 'left';
+ return false;
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/clear.js b/includes/node_modules/prompts/dist/util/clear.js
new file mode 100644
index 0000000..5a313be
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/clear.js
@@ -0,0 +1,42 @@
+'use strict';
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+
+const strip = require('./strip');
+
+const _require = require('sisteransi'),
+ erase = _require.erase,
+ cursor = _require.cursor;
+
+const width = str => [...strip(str)].length;
+/**
+ * @param {string} prompt
+ * @param {number} perLine
+ */
+
+
+module.exports = function (prompt, perLine) {
+ if (!perLine) return erase.line + cursor.to(0);
+ let rows = 0;
+ const lines = prompt.split(/\r?\n/);
+
+ var _iterator = _createForOfIteratorHelper(lines),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ let line = _step.value;
+ rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ return erase.lines(rows);
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/entriesToDisplay.js b/includes/node_modules/prompts/dist/util/entriesToDisplay.js
new file mode 100644
index 0000000..fbb963a
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/entriesToDisplay.js
@@ -0,0 +1,21 @@
+'use strict';
+/**
+ * Determine what entries should be displayed on the screen, based on the
+ * currently selected index and the maximum visible. Used in list-based
+ * prompts like `select` and `multiselect`.
+ *
+ * @param {number} cursor the currently selected entry
+ * @param {number} total the total entries available to display
+ * @param {number} [maxVisible] the number of entries that can be displayed
+ */
+
+module.exports = (cursor, total, maxVisible) => {
+ maxVisible = maxVisible || total;
+ let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));
+ if (startIndex < 0) startIndex = 0;
+ let endIndex = Math.min(startIndex + maxVisible, total);
+ return {
+ startIndex,
+ endIndex
+ };
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/figures.js b/includes/node_modules/prompts/dist/util/figures.js
new file mode 100644
index 0000000..036ec50
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/figures.js
@@ -0,0 +1,32 @@
+'use strict';
+
+const main = {
+ arrowUp: '↑',
+ arrowDown: '↓',
+ arrowLeft: '←',
+ arrowRight: '→',
+ radioOn: '◉',
+ radioOff: '◯',
+ tick: '✔',
+ cross: '✖',
+ ellipsis: '…',
+ pointerSmall: '›',
+ line: '─',
+ pointer: '❯'
+};
+const win = {
+ arrowUp: main.arrowUp,
+ arrowDown: main.arrowDown,
+ arrowLeft: main.arrowLeft,
+ arrowRight: main.arrowRight,
+ radioOn: '(*)',
+ radioOff: '( )',
+ tick: '√',
+ cross: '×',
+ ellipsis: '...',
+ pointerSmall: '»',
+ line: '─',
+ pointer: '>'
+};
+const figures = process.platform === 'win32' ? win : main;
+module.exports = figures; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/index.js b/includes/node_modules/prompts/dist/util/index.js
new file mode 100644
index 0000000..dbfe75e
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/index.js
@@ -0,0 +1,12 @@
+'use strict';
+
+module.exports = {
+ action: require('./action'),
+ clear: require('./clear'),
+ style: require('./style'),
+ strip: require('./strip'),
+ figures: require('./figures'),
+ lines: require('./lines'),
+ wrap: require('./wrap'),
+ entriesToDisplay: require('./entriesToDisplay')
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/lines.js b/includes/node_modules/prompts/dist/util/lines.js
new file mode 100644
index 0000000..54a939a
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/lines.js
@@ -0,0 +1,14 @@
+'use strict';
+
+const strip = require('./strip');
+/**
+ * @param {string} msg
+ * @param {number} perLine
+ */
+
+
+module.exports = function (msg, perLine) {
+ let lines = String(strip(msg) || '').split(/\r?\n/);
+ if (!perLine) return lines.length;
+ return lines.map(l => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/strip.js b/includes/node_modules/prompts/dist/util/strip.js
new file mode 100644
index 0000000..dd289a0
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/strip.js
@@ -0,0 +1,7 @@
+'use strict';
+
+module.exports = str => {
+ const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'].join('|');
+ const RGX = new RegExp(pattern, 'g');
+ return typeof str === 'string' ? str.replace(RGX, '') : str;
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/style.js b/includes/node_modules/prompts/dist/util/style.js
new file mode 100644
index 0000000..ed1a49b
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/style.js
@@ -0,0 +1,51 @@
+'use strict';
+
+const c = require('kleur');
+
+const figures = require('./figures'); // rendering user input.
+
+
+const styles = Object.freeze({
+ password: {
+ scale: 1,
+ render: input => '*'.repeat(input.length)
+ },
+ emoji: {
+ scale: 2,
+ render: input => '😃'.repeat(input.length)
+ },
+ invisible: {
+ scale: 0,
+ render: input => ''
+ },
+ default: {
+ scale: 1,
+ render: input => `${input}`
+ }
+});
+
+const render = type => styles[type] || styles.default; // icon to signalize a prompt.
+
+
+const symbols = Object.freeze({
+ aborted: c.red(figures.cross),
+ done: c.green(figures.tick),
+ exited: c.yellow(figures.cross),
+ default: c.cyan('?')
+});
+
+const symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default; // between the question and the user's input.
+
+
+const delimiter = completing => c.gray(completing ? figures.ellipsis : figures.pointerSmall);
+
+const item = (expandable, expanded) => c.gray(expandable ? expanded ? figures.pointerSmall : '+' : figures.line);
+
+module.exports = {
+ styles,
+ render,
+ symbols,
+ symbol,
+ delimiter,
+ item
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/dist/util/wrap.js b/includes/node_modules/prompts/dist/util/wrap.js
new file mode 100644
index 0000000..da5e67c
--- /dev/null
+++ b/includes/node_modules/prompts/dist/util/wrap.js
@@ -0,0 +1,16 @@
+'use strict';
+/**
+ * @param {string} msg The message to wrap
+ * @param {object} opts
+ * @param {number|string} [opts.margin] Left margin
+ * @param {number} opts.width Maximum characters per line including the margin
+ */
+
+module.exports = (msg, opts = {}) => {
+ const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(' ').join('') : opts.margin || '';
+ const width = opts.width;
+ return (msg || '').split(/\r?\n/g).map(line => line.split(/\s+/g).reduce((arr, w) => {
+ if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width) arr[arr.length - 1] += ` ${w}`;else arr.push(`${tab}${w}`);
+ return arr;
+ }, [tab]).join('\n')).join('\n');
+}; \ No newline at end of file
diff --git a/includes/node_modules/prompts/index.js b/includes/node_modules/prompts/index.js
new file mode 100644
index 0000000..3479956
--- /dev/null
+++ b/includes/node_modules/prompts/index.js
@@ -0,0 +1,14 @@
+function isNodeLT(tar) {
+ tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
+ let i=0, src=process.versions.node.split('.').map(Number);
+ for (; i < tar.length; i++) {
+ if (src[i] > tar[i]) return false;
+ if (tar[i] > src[i]) return true;
+ }
+ return false;
+}
+
+module.exports =
+ isNodeLT('8.6.0')
+ ? require('./dist/index.js')
+ : require('./lib/index.js');
diff --git a/includes/node_modules/prompts/lib/dateparts/datepart.js b/includes/node_modules/prompts/lib/dateparts/datepart.js
new file mode 100644
index 0000000..62b893b
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/datepart.js
@@ -0,0 +1,35 @@
+'use strict';
+
+class DatePart {
+ constructor({token, date, parts, locales}) {
+ this.token = token;
+ this.date = date || new Date();
+ this.parts = parts || [this];
+ this.locales = locales || {};
+ }
+
+ up() {}
+
+ down() {}
+
+ next() {
+ const currentIdx = this.parts.indexOf(this);
+ return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ setTo(val) {}
+
+ prev() {
+ let parts = [].concat(this.parts).reverse();
+ const currentIdx = parts.indexOf(this);
+ return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ toString() {
+ return String(this.date);
+ }
+}
+
+module.exports = DatePart;
+
+
diff --git a/includes/node_modules/prompts/lib/dateparts/day.js b/includes/node_modules/prompts/lib/dateparts/day.js
new file mode 100644
index 0000000..5db84fe
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/day.js
@@ -0,0 +1,42 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+const pos = n => {
+ n = n % 10;
+ return n === 1 ? 'st'
+ : n === 2 ? 'nd'
+ : n === 3 ? 'rd'
+ : 'th';
+}
+
+class Day extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setDate(this.date.getDate() + 1);
+ }
+
+ down() {
+ this.date.setDate(this.date.getDate() - 1);
+ }
+
+ setTo(val) {
+ this.date.setDate(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let date = this.date.getDate();
+ let day = this.date.getDay();
+ return this.token === 'DD' ? String(date).padStart(2, '0')
+ : this.token === 'Do' ? date + pos(date)
+ : this.token === 'd' ? day + 1
+ : this.token === 'ddd' ? this.locales.weekdaysShort[day]
+ : this.token === 'dddd' ? this.locales.weekdays[day]
+ : date;
+ }
+}
+
+module.exports = Day;
diff --git a/includes/node_modules/prompts/lib/dateparts/hours.js b/includes/node_modules/prompts/lib/dateparts/hours.js
new file mode 100644
index 0000000..171b3d2
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/hours.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Hours extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours(this.date.getHours() + 1);
+ }
+
+ down() {
+ this.date.setHours(this.date.getHours() - 1);
+ }
+
+ setTo(val) {
+ this.date.setHours(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let hours = this.date.getHours();
+ if (/h/.test(this.token))
+ hours = (hours % 12) || 12;
+ return this.token.length > 1 ? String(hours).padStart(2, '0') : hours;
+ }
+}
+
+module.exports = Hours;
diff --git a/includes/node_modules/prompts/lib/dateparts/index.js b/includes/node_modules/prompts/lib/dateparts/index.js
new file mode 100644
index 0000000..dc0cc95
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ DatePart: require('./datepart'),
+ Meridiem: require('./meridiem'),
+ Day: require('./day'),
+ Hours: require('./hours'),
+ Milliseconds: require('./milliseconds'),
+ Minutes: require('./minutes'),
+ Month: require('./month'),
+ Seconds: require('./seconds'),
+ Year: require('./year'),
+}
diff --git a/includes/node_modules/prompts/lib/dateparts/meridiem.js b/includes/node_modules/prompts/lib/dateparts/meridiem.js
new file mode 100644
index 0000000..8488677
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/meridiem.js
@@ -0,0 +1,24 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Meridiem extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours((this.date.getHours() + 12) % 24);
+ }
+
+ down() {
+ this.up();
+ }
+
+ toString() {
+ let meridiem = this.date.getHours() > 12 ? 'pm' : 'am';
+ return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
+ }
+}
+
+module.exports = Meridiem;
diff --git a/includes/node_modules/prompts/lib/dateparts/milliseconds.js b/includes/node_modules/prompts/lib/dateparts/milliseconds.js
new file mode 100644
index 0000000..8984270
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/milliseconds.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Milliseconds extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMilliseconds(this.date.getMilliseconds() + 1);
+ }
+
+ down() {
+ this.date.setMilliseconds(this.date.getMilliseconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMilliseconds(parseInt(val.substr(-(this.token.length))));
+ }
+
+ toString() {
+ return String(this.date.getMilliseconds()).padStart(4, '0')
+ .substr(0, this.token.length);
+ }
+}
+
+module.exports = Milliseconds;
diff --git a/includes/node_modules/prompts/lib/dateparts/minutes.js b/includes/node_modules/prompts/lib/dateparts/minutes.js
new file mode 100644
index 0000000..aa1d8f7
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/minutes.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Minutes extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMinutes(this.date.getMinutes() + 1);
+ }
+
+ down() {
+ this.date.setMinutes(this.date.getMinutes() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMinutes(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let m = this.date.getMinutes();
+ return this.token.length > 1 ? String(m).padStart(2, '0') : m;
+ }
+}
+
+module.exports = Minutes;
diff --git a/includes/node_modules/prompts/lib/dateparts/month.js b/includes/node_modules/prompts/lib/dateparts/month.js
new file mode 100644
index 0000000..f656455
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/month.js
@@ -0,0 +1,33 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Month extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMonth(this.date.getMonth() + 1);
+ }
+
+ down() {
+ this.date.setMonth(this.date.getMonth() - 1);
+ }
+
+ setTo(val) {
+ val = parseInt(val.substr(-2)) - 1;
+ this.date.setMonth(val < 0 ? 0 : val);
+ }
+
+ toString() {
+ let month = this.date.getMonth();
+ let tl = this.token.length;
+ return tl === 2 ? String(month + 1).padStart(2, '0')
+ : tl === 3 ? this.locales.monthsShort[month]
+ : tl === 4 ? this.locales.months[month]
+ : String(month + 1);
+ }
+}
+
+module.exports = Month;
diff --git a/includes/node_modules/prompts/lib/dateparts/seconds.js b/includes/node_modules/prompts/lib/dateparts/seconds.js
new file mode 100644
index 0000000..0c1a1a4
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/seconds.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Seconds extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setSeconds(this.date.getSeconds() + 1);
+ }
+
+ down() {
+ this.date.setSeconds(this.date.getSeconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setSeconds(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let s = this.date.getSeconds();
+ return this.token.length > 1 ? String(s).padStart(2, '0') : s;
+ }
+}
+
+module.exports = Seconds;
diff --git a/includes/node_modules/prompts/lib/dateparts/year.js b/includes/node_modules/prompts/lib/dateparts/year.js
new file mode 100644
index 0000000..f068e43
--- /dev/null
+++ b/includes/node_modules/prompts/lib/dateparts/year.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Year extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setFullYear(this.date.getFullYear() + 1);
+ }
+
+ down() {
+ this.date.setFullYear(this.date.getFullYear() - 1);
+ }
+
+ setTo(val) {
+ this.date.setFullYear(val.substr(-4));
+ }
+
+ toString() {
+ let year = String(this.date.getFullYear()).padStart(4, '0');
+ return this.token.length === 2 ? year.substr(-2) : year;
+ }
+}
+
+module.exports = Year;
diff --git a/includes/node_modules/prompts/lib/elements/autocomplete.js b/includes/node_modules/prompts/lib/elements/autocomplete.js
new file mode 100644
index 0000000..8e06da2
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/autocomplete.js
@@ -0,0 +1,264 @@
+'use strict';
+
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { erase, cursor } = require('sisteransi');
+const { style, clear, figures, wrap, entriesToDisplay } = require('../util');
+
+const getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
+const getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
+const getIndex = (arr, valOrTitle) => {
+ const index = arr.findIndex(el => el.value === valOrTitle || el.title === valOrTitle);
+ return index > -1 ? index : undefined;
+};
+
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of auto-complete choices objects
+ * @param {Function} [opts.suggest] Filter function. Defaults to sort by title
+ * @param {Number} [opts.limit=10] Max number of results to show
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.fallback] Fallback message - initial to default value
+ * @param {String} [opts.initial] Index of the default value
+ * @param {Boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.noMatches] The no matches found label
+ */
+class AutocompletePrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.suggest = opts.suggest;
+ this.choices = opts.choices;
+ this.initial = typeof opts.initial === 'number'
+ ? opts.initial
+ : getIndex(opts.choices, opts.initial);
+ this.select = this.initial || opts.cursor || 0;
+ this.i18n = { noMatches: opts.noMatches || 'no matches found' };
+ this.fallback = opts.fallback || this.initial;
+ this.clearFirst = opts.clearFirst || false;
+ this.suggestions = [];
+ this.input = '';
+ this.limit = opts.limit || 10;
+ this.cursor = 0;
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.render = this.render.bind(this);
+ this.complete = this.complete.bind(this);
+ this.clear = clear('', this.out.columns);
+ this.complete(this.render);
+ this.render();
+ }
+
+ set fallback(fb) {
+ this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
+ }
+
+ get fallback() {
+ let choice;
+ if (typeof this._fb === 'number')
+ choice = this.choices[this._fb];
+ else if (typeof this._fb === 'string')
+ choice = { title: this._fb };
+ return choice || this._fb || { title: this.i18n.noMatches };
+ }
+
+ moveSelect(i) {
+ this.select = i;
+ if (this.suggestions.length > 0)
+ this.value = getVal(this.suggestions, i);
+ else this.value = this.fallback.value;
+ this.fire();
+ }
+
+ async complete(cb) {
+ const p = (this.completing = this.suggest(this.input, this.choices));
+ const suggestions = await p;
+
+ if (this.completing !== p) return;
+ this.suggestions = suggestions
+ .map((s, i, arr) => ({ title: getTitle(arr, i), value: getVal(arr, i), description: s.description }));
+ this.completing = false;
+ const l = Math.max(suggestions.length - 1, 0);
+ this.moveSelect(Math.min(l, this.select));
+
+ cb && cb();
+ }
+
+ reset() {
+ this.input = '';
+ this.complete(() => {
+ this.moveSelect(this.initial !== void 0 ? this.initial : 0);
+ this.render();
+ });
+ this.render();
+ }
+
+ exit() {
+ if (this.clearFirst && this.input.length > 0) {
+ this.reset();
+ } else {
+ this.done = this.exited = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${c}${s2}`;
+ this.cursor = s1.length+1;
+ this.complete(this.render);
+ this.render();
+ }
+
+ delete() {
+ if (this.cursor === 0) return this.bell();
+ let s1 = this.input.slice(0, this.cursor-1);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.cursor = this.cursor-1;
+ this.render();
+ }
+
+ deleteForward() {
+ if(this.cursor*this.scale >= this.rendered.length) return this.bell();
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor+1);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.render();
+ }
+
+ first() {
+ this.moveSelect(0);
+ this.render();
+ }
+
+ last() {
+ this.moveSelect(this.suggestions.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.select === 0) {
+ this.moveSelect(this.suggestions.length - 1);
+ } else {
+ this.moveSelect(this.select - 1);
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else {
+ this.moveSelect(this.select + 1);
+ }
+ this.render();
+ }
+
+ next() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else this.moveSelect(this.select + 1);
+ this.render();
+ }
+
+ nextPage() {
+ this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
+ this.render();
+ }
+
+ prevPage() {
+ this.moveSelect(Math.max(this.select - this.limit, 0));
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0) return this.bell();
+ this.cursor = this.cursor-1;
+ this.render();
+ }
+
+ right() {
+ if (this.cursor*this.scale >= this.rendered.length) return this.bell();
+ this.cursor = this.cursor+1;
+ this.render();
+ }
+
+ renderOption(v, hovered, isStart, isEnd) {
+ let desc;
+ let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : ' ';
+ let title = hovered ? color.cyan().underline(v.title) : v.title;
+ prefix = (hovered ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+ if (v.description) {
+ desc = ` - ${v.description}`;
+ if (prefix.length + title.length + desc.length >= this.out.columns
+ || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, { margin: 3, width: this.out.columns })
+ }
+ }
+ return prefix + ' ' + title + color.gray(desc || '');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let { startIndex, endIndex } = entriesToDisplay(this.select, this.choices.length, this.limit);
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted, this.exited),
+ color.bold(this.msg),
+ style.delimiter(this.completing),
+ this.done && this.suggestions[this.select]
+ ? this.suggestions[this.select].title
+ : this.rendered = this.transform.render(this.input)
+ ].join(' ');
+
+ if (!this.done) {
+ const suggestions = this.suggestions
+ .slice(startIndex, endIndex)
+ .map((item, i) => this.renderOption(item,
+ this.select === i + startIndex,
+ i === 0 && startIndex > 0,
+ i + startIndex === endIndex - 1 && endIndex < this.choices.length))
+ .join('\n');
+ this.outputText += `\n` + (suggestions || color.gray(this.fallback.title));
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = AutocompletePrompt;
diff --git a/includes/node_modules/prompts/lib/elements/autocompleteMultiselect.js b/includes/node_modules/prompts/lib/elements/autocompleteMultiselect.js
new file mode 100644
index 0000000..b64510f
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/autocompleteMultiselect.js
@@ -0,0 +1,194 @@
+'use strict';
+
+const color = require('kleur');
+const { cursor } = require('sisteransi');
+const MultiselectPrompt = require('./multiselect');
+const { clear, style, figures } = require('../util');
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class AutocompleteMultiselectPrompt extends MultiselectPrompt {
+ constructor(opts={}) {
+ opts.overrideRender = true;
+ super(opts);
+ this.inputValue = '';
+ this.clear = clear('', this.out.columns);
+ this.filteredOptions = this.value;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.filteredOptions.length - 1;
+ this.render();
+ }
+ next() {
+ this.cursor = (this.cursor + 1) % this.filteredOptions.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.filteredOptions.length - 1;
+ } else {
+ this.cursor--;
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.filteredOptions.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+ this.render();
+ }
+
+ left() {
+ this.filteredOptions[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.filteredOptions[this.cursor].selected = true;
+ this.render();
+ }
+
+ delete() {
+ if (this.inputValue.length) {
+ this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
+ this.updateFilteredOptions();
+ }
+ }
+
+ updateFilteredOptions() {
+ const currentHighlight = this.filteredOptions[this.cursor];
+ this.filteredOptions = this.value
+ .filter(v => {
+ if (this.inputValue) {
+ if (typeof v.title === 'string') {
+ if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+ if (typeof v.value === 'string') {
+ if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ });
+ const newHighlightIndex = this.filteredOptions.findIndex(v => v === currentHighlight)
+ this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.filteredOptions[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ handleInputChange(c) {
+ this.inputValue = this.inputValue + c;
+ this.updateFilteredOptions();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else {
+ this.handleInputChange(c);
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+ return `
+Instructions:
+ ${figures.arrowUp}/${figures.arrowDown}: Highlight option
+ ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
+ [a,b,c]/delete: Filter choices
+ enter/return: Complete answer
+`;
+ }
+ return '';
+ }
+
+ renderCurrentInput() {
+ return `
+Filtered results for: ${this.inputValue ? this.inputValue : color.gray('Enter something to filter')}\n`;
+ }
+
+ renderOption(cursor, v, i) {
+ let title;
+ if (v.disabled) title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ else title = cursor === i ? color.cyan().underline(v.title) : v.title;
+ return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + title
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value
+ .filter(e => e.selected)
+ .map(v => v.title)
+ .join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
+
+ if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render();
+
+ // print prompt
+
+ let prompt = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.renderDoneOrInstructions()
+ ].join(' ');
+
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+ prompt += this.renderOptions(this.filteredOptions);
+
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+}
+
+module.exports = AutocompleteMultiselectPrompt;
diff --git a/includes/node_modules/prompts/lib/elements/confirm.js b/includes/node_modules/prompts/lib/elements/confirm.js
new file mode 100644
index 0000000..7a9173f
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/confirm.js
@@ -0,0 +1,89 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear } = require('../util');
+const { erase, cursor } = require('sisteransi');
+
+/**
+ * ConfirmPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial] Default value (true/false)
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.yes] The "Yes" label
+ * @param {String} [opts.yesOption] The "Yes" option when choosing between yes/no
+ * @param {String} [opts.no] The "No" label
+ * @param {String} [opts.noOption] The "No" option when choosing between yes/no
+ */
+class ConfirmPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = opts.initial;
+ this.initialValue = !!opts.initial;
+ this.yesMsg = opts.yes || 'yes';
+ this.yesOption = opts.yesOption || '(Y/n)';
+ this.noMsg = opts.no || 'no';
+ this.noOption = opts.noOption || '(y/N)';
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.value = this.value || false;
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ if (c.toLowerCase() === 'y') {
+ this.value = true;
+ return this.submit();
+ }
+ if (c.toLowerCase() === 'n') {
+ this.value = false;
+ return this.submit();
+ }
+ return this.bell();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ this.done ? (this.value ? this.yesMsg : this.noMsg)
+ : color.gray(this.initialValue ? this.yesOption : this.noOption)
+ ].join(' ');
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = ConfirmPrompt;
diff --git a/includes/node_modules/prompts/lib/elements/date.js b/includes/node_modules/prompts/lib/elements/date.js
new file mode 100644
index 0000000..71ff608
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/date.js
@@ -0,0 +1,209 @@
+'use strict';
+
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear, figures } = require('../util');
+const { erase, cursor } = require('sisteransi');
+const { DatePart, Meridiem, Day, Hours, Milliseconds, Minutes, Month, Seconds, Year } = require('../dateparts');
+
+const regex = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g;
+const regexGroups = {
+ 1: ({token}) => token.replace(/\\(.)/g, '$1'),
+ 2: (opts) => new Day(opts), // Day // TODO
+ 3: (opts) => new Month(opts), // Month
+ 4: (opts) => new Year(opts), // Year
+ 5: (opts) => new Meridiem(opts), // AM/PM // TODO (special)
+ 6: (opts) => new Hours(opts), // Hours
+ 7: (opts) => new Minutes(opts), // Minutes
+ 8: (opts) => new Seconds(opts), // Seconds
+ 9: (opts) => new Milliseconds(opts), // Fractional seconds
+}
+
+const dfltLocales = {
+ months: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(','),
+ monthsShort: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
+ weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
+ weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(',')
+}
+
+
+/**
+ * DatePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Number} [opts.initial] Index of default value
+ * @param {String} [opts.mask] The format mask
+ * @param {object} [opts.locales] The date locales
+ * @param {String} [opts.error] The error message shown on invalid value
+ * @param {Function} [opts.validate] Function to validate the submitted value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class DatePrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = 0;
+ this.typed = '';
+ this.locales = Object.assign(dfltLocales, opts.locales);
+ this._date = opts.initial || new Date();
+ this.errorMsg = opts.error || 'Please Enter A Valid Value';
+ this.validator = opts.validate || (() => true);
+ this.mask = opts.mask || 'YYYY-MM-DD HH:mm:ss';
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ get value() {
+ return this.date
+ }
+
+ get date() {
+ return this._date;
+ }
+
+ set date(date) {
+ if (date) this._date.setTime(date.getTime());
+ }
+
+ set mask(mask) {
+ let result;
+ this.parts = [];
+ while(result = regex.exec(mask)) {
+ let match = result.shift();
+ let idx = result.findIndex(gr => gr != null);
+ this.parts.push(idx in regexGroups
+ ? regexGroups[idx]({ token: result[idx] || match, date: this.date, parts: this.parts, locales: this.locales })
+ : result[idx] || match);
+ }
+
+ let parts = this.parts.reduce((arr, i) => {
+ if (typeof i === 'string' && typeof arr[arr.length - 1] === 'string')
+ arr[arr.length - 1] += i;
+ else arr.push(i);
+ return arr;
+ }, []);
+
+ this.parts.splice(0);
+ this.parts.push(...parts);
+ this.reset();
+ }
+
+ moveCursor(n) {
+ this.typed = '';
+ this.cursor = n;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(this.parts.findIndex(p => p instanceof DatePart));
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ async validate() {
+ let valid = await this.validator(this.value);
+ if (typeof valid === 'string') {
+ this.errorMsg = valid;
+ valid = false;
+ }
+ this.error = !valid;
+ }
+
+ async submit() {
+ await this.validate();
+ if (this.error) {
+ this.color = 'red';
+ this.fire();
+ this.render();
+ return;
+ }
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ up() {
+ this.typed = '';
+ this.parts[this.cursor].up();
+ this.render();
+ }
+
+ down() {
+ this.typed = '';
+ this.parts[this.cursor].down();
+ this.render();
+ }
+
+ left() {
+ let prev = this.parts[this.cursor].prev();
+ if (prev == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(prev));
+ this.render();
+ }
+
+ right() {
+ let next = this.parts[this.cursor].next();
+ if (next == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(next));
+ this.render();
+ }
+
+ next() {
+ let next = this.parts[this.cursor].next();
+ this.moveCursor(next
+ ? this.parts.indexOf(next)
+ : this.parts.findIndex((part) => part instanceof DatePart));
+ this.render();
+ }
+
+ _(c) {
+ if (/\d/.test(c)) {
+ this.typed += c;
+ this.parts[this.cursor].setTo(this.typed);
+ this.render();
+ }
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ // Print prompt
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), [])
+ .join('')
+ ].join(' ');
+
+ // Print error
+ if (this.error) {
+ this.outputText += this.errorMsg.split('\n').reduce(
+ (a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = DatePrompt;
diff --git a/includes/node_modules/prompts/lib/elements/index.js b/includes/node_modules/prompts/lib/elements/index.js
new file mode 100644
index 0000000..2556dd0
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ TextPrompt: require('./text'),
+ SelectPrompt: require('./select'),
+ TogglePrompt: require('./toggle'),
+ DatePrompt: require('./date'),
+ NumberPrompt: require('./number'),
+ MultiselectPrompt: require('./multiselect'),
+ AutocompletePrompt: require('./autocomplete'),
+ AutocompleteMultiselectPrompt: require('./autocompleteMultiselect'),
+ ConfirmPrompt: require('./confirm')
+};
diff --git a/includes/node_modules/prompts/lib/elements/multiselect.js b/includes/node_modules/prompts/lib/elements/multiselect.js
new file mode 100644
index 0000000..99b393f
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/multiselect.js
@@ -0,0 +1,271 @@
+'use strict';
+
+const color = require('kleur');
+const { cursor } = require('sisteransi');
+const Prompt = require('./prompt');
+const { clear, figures, style, wrap, entriesToDisplay } = require('../util');
+
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class MultiselectPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = opts.cursor || 0;
+ this.scrollIndex = opts.cursor || 0;
+ this.hint = opts.hint || '';
+ this.warn = opts.warn || '- This option is disabled -';
+ this.minSelected = opts.min;
+ this.showMinError = false;
+ this.maxChoices = opts.max;
+ this.instructions = opts.instructions;
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string')
+ ch = {title: ch, value: idx};
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ description: ch && ch.description,
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.clear = clear('', this.out.columns);
+ if (!opts.overrideRender) {
+ this.render();
+ }
+ }
+
+ reset() {
+ this.value.map(v => !v.selected);
+ this.cursor = 0;
+ this.fire();
+ this.render();
+ }
+
+ selected() {
+ return this.value.filter(v => v.selected);
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ const selected = this.value
+ .filter(e => e.selected);
+ if (this.minSelected && selected.length < this.minSelected) {
+ this.showMinError = true;
+ this.render();
+ } else {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length - 1;
+ this.render();
+ }
+ next() {
+ this.cursor = (this.cursor + 1) % this.value.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.value.length - 1;
+ } else {
+ this.cursor--;
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.value.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+ this.render();
+ }
+
+ left() {
+ this.value[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.value[this.cursor].selected = true;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.value[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ toggleAll() {
+ if (this.maxChoices !== undefined || this.value[this.cursor].disabled) {
+ return this.bell();
+ }
+
+ const newSelected = !this.value[this.cursor].selected;
+ this.value.filter(v => !v.disabled).forEach(v => v.selected = newSelected);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else if (c === 'a') {
+ this.toggleAll();
+ } else {
+ return this.bell();
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+ return '\nInstructions:\n'
+ + ` ${figures.arrowUp}/${figures.arrowDown}: Highlight option\n`
+ + ` ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection\n`
+ + (this.maxChoices === undefined ? ` a: Toggle all\n` : '')
+ + ` enter/return: Complete answer`;
+ }
+ return '';
+ }
+
+ renderOption(cursor, v, i, arrowIndicator) {
+ const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + arrowIndicator + ' ';
+ let title, desc;
+
+ if (v.disabled) {
+ title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ } else {
+ title = cursor === i ? color.cyan().underline(v.title) : v.title;
+ if (cursor === i && v.description) {
+ desc = ` - ${v.description}`;
+ if (prefix.length + title.length + desc.length >= this.out.columns
+ || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, { margin: prefix.length, width: this.out.columns });
+ }
+ }
+ }
+
+ return prefix + title + color.gray(desc || '');
+ }
+
+ // shared with autocompleteMultiselect
+ paginateOptions(options) {
+ if (options.length === 0) {
+ return color.red('No matches for this query.');
+ }
+
+ let { startIndex, endIndex } = entriesToDisplay(this.cursor, options.length, this.optionsPerPage);
+ let prefix, styledOptions = [];
+
+ for (let i = startIndex; i < endIndex; i++) {
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < options.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+ styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
+ }
+
+ return '\n' + styledOptions.join('\n');
+ }
+
+ // shared with autocomleteMultiselect
+ renderOptions(options) {
+ if (!this.done) {
+ return this.paginateOptions(options);
+ }
+ return '';
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value
+ .filter(e => e.selected)
+ .map(v => v.title)
+ .join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions()];
+
+ if (this.value[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render();
+
+ // print prompt
+ let prompt = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.renderDoneOrInstructions()
+ ].join(' ');
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+ prompt += this.renderOptions(this.value);
+
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+}
+
+module.exports = MultiselectPrompt;
diff --git a/includes/node_modules/prompts/lib/elements/number.js b/includes/node_modules/prompts/lib/elements/number.js
new file mode 100644
index 0000000..dc3efe9
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/number.js
@@ -0,0 +1,213 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { cursor, erase } = require('sisteransi');
+const { style, figures, clear, lines } = require('../util');
+
+const isNumber = /[0-9]/;
+const isDef = any => any !== undefined;
+const round = (number, precision) => {
+ let factor = Math.pow(10, precision);
+ return Math.round(number * factor) / factor;
+}
+
+/**
+ * NumberPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {Number} [opts.initial] Default value
+ * @param {Number} [opts.max=+Infinity] Max value
+ * @param {Number} [opts.min=-Infinity] Min value
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+class NumberPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.msg = opts.message;
+ this.initial = isDef(opts.initial) ? opts.initial : '';
+ this.float = !!opts.float;
+ this.round = opts.round || 2;
+ this.inc = opts.increment || 1;
+ this.min = isDef(opts.min) ? opts.min : -Infinity;
+ this.max = isDef(opts.max) ? opts.max : Infinity;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+ this.validator = opts.validate || (() => true);
+ this.color = `cyan`;
+ this.value = ``;
+ this.typed = ``;
+ this.lastHit = 0;
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && v !== 0) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(`${this.initial}`));
+ this._value = ``;
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(`${round(v, this.round)}`);
+ this._value = round(v, this.round);
+ }
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ parse(x) {
+ return this.float ? parseFloat(x) : parseInt(x);
+ }
+
+ valid(c) {
+ return c === `-` || c === `.` && this.float || isNumber.test(c)
+ }
+
+ reset() {
+ this.typed = ``;
+ this.value = ``;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ let x = this.value;
+ this.value = x !== `` ? x : this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write(`\n`);
+ this.close();
+ }
+
+ async validate() {
+ let valid = await this.validator(this.value);
+ if (typeof valid === `string`) {
+ this.errorMsg = valid;
+ valid = false;
+ }
+ this.error = !valid;
+ }
+
+ async submit() {
+ await this.validate();
+ if (this.error) {
+ this.color = `red`;
+ this.fire();
+ this.render();
+ return;
+ }
+ let x = this.value;
+ this.value = x !== `` ? x : this.initial;
+ this.done = true;
+ this.aborted = false;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write(`\n`);
+ this.close();
+ }
+
+ up() {
+ this.typed = ``;
+ if(this.value === '') {
+ this.value = this.min - this.inc;
+ }
+ if (this.value >= this.max) return this.bell();
+ this.value += this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ down() {
+ this.typed = ``;
+ if(this.value === '') {
+ this.value = this.min + this.inc;
+ }
+ if (this.value <= this.min) return this.bell();
+ this.value -= this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ delete() {
+ let val = this.value.toString();
+ if (val.length === 0) return this.bell();
+ this.value = this.parse((val = val.slice(0, -1))) || ``;
+ if (this.value !== '' && this.value < this.min) {
+ this.value = this.min;
+ }
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ next() {
+ this.value = this.initial;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (!this.valid(c)) return this.bell();
+
+ const now = Date.now();
+ if (now - this.lastHit > 1000) this.typed = ``; // 1s elapsed
+ this.typed += c;
+ this.lastHit = now;
+ this.color = `cyan`;
+
+ if (c === `.`) return this.fire();
+
+ this.value = Math.min(this.parse(this.typed), this.max);
+ if (this.value > this.max) this.value = this.max;
+ if (this.value < this.min) this.value = this.min;
+ this.fire();
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (!this.firstRender) {
+ if (this.outputError)
+ this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+ super.render();
+ this.outputError = '';
+
+ // Print prompt
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ !this.done || (!this.done && !this.placeholder)
+ ? color[this.color]().underline(this.rendered) : this.rendered
+ ].join(` `);
+
+ // Print error
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`)
+ .reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
+ }
+}
+
+module.exports = NumberPrompt;
diff --git a/includes/node_modules/prompts/lib/elements/prompt.js b/includes/node_modules/prompts/lib/elements/prompt.js
new file mode 100644
index 0000000..b793330
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/prompt.js
@@ -0,0 +1,68 @@
+'use strict';
+
+const readline = require('readline');
+const { action } = require('../util');
+const EventEmitter = require('events');
+const { beep, cursor } = require('sisteransi');
+const color = require('kleur');
+
+/**
+ * Base prompt skeleton
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class Prompt extends EventEmitter {
+ constructor(opts={}) {
+ super();
+
+ this.firstRender = true;
+ this.in = opts.stdin || process.stdin;
+ this.out = opts.stdout || process.stdout;
+ this.onRender = (opts.onRender || (() => void 0)).bind(this);
+ const rl = readline.createInterface({ input:this.in, escapeCodeTimeout:50 });
+ readline.emitKeypressEvents(this.in, rl);
+
+ if (this.in.isTTY) this.in.setRawMode(true);
+ const isSelect = [ 'SelectPrompt', 'MultiselectPrompt' ].indexOf(this.constructor.name) > -1;
+ const keypress = (str, key) => {
+ let a = action(key, isSelect);
+ if (a === false) {
+ this._ && this._(str, key);
+ } else if (typeof this[a] === 'function') {
+ this[a](key);
+ } else {
+ this.bell();
+ }
+ };
+
+ this.close = () => {
+ this.out.write(cursor.show);
+ this.in.removeListener('keypress', keypress);
+ if (this.in.isTTY) this.in.setRawMode(false);
+ rl.close();
+ this.emit(this.aborted ? 'abort' : this.exited ? 'exit' : 'submit', this.value);
+ this.closed = true;
+ };
+
+ this.in.on('keypress', keypress);
+ }
+
+ fire() {
+ this.emit('state', {
+ value: this.value,
+ aborted: !!this.aborted,
+ exited: !!this.exited
+ });
+ }
+
+ bell() {
+ this.out.write(beep);
+ }
+
+ render() {
+ this.onRender(color);
+ if (this.firstRender) this.firstRender = false;
+ }
+}
+
+module.exports = Prompt;
diff --git a/includes/node_modules/prompts/lib/elements/select.js b/includes/node_modules/prompts/lib/elements/select.js
new file mode 100644
index 0000000..6d6727f
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/select.js
@@ -0,0 +1,175 @@
+'use strict';
+
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear, figures, wrap, entriesToDisplay } = require('../util');
+const { cursor } = require('sisteransi');
+
+/**
+ * SelectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {Number} [opts.initial] Index of default value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ */
+class SelectPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.hint = opts.hint || '- Use arrow-keys. Return to submit.';
+ this.warn = opts.warn || '- This option is disabled';
+ this.cursor = opts.initial || 0;
+ this.choices = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string')
+ ch = {title: ch, value: idx};
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ description: ch && ch.description,
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = (this.choices[this.cursor] || {}).value;
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ moveCursor(n) {
+ this.cursor = n;
+ this.value = this.choices[n].value;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(0);
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ if (!this.selection.disabled) {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ } else
+ this.bell();
+ }
+
+ first() {
+ this.moveCursor(0);
+ this.render();
+ }
+
+ last() {
+ this.moveCursor(this.choices.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.moveCursor(this.choices.length - 1);
+ } else {
+ this.moveCursor(this.cursor - 1);
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.choices.length - 1) {
+ this.moveCursor(0);
+ } else {
+ this.moveCursor(this.cursor + 1);
+ }
+ this.render();
+ }
+
+ next() {
+ this.moveCursor((this.cursor + 1) % this.choices.length);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') return this.submit();
+ }
+
+ get selection() {
+ return this.choices[this.cursor];
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let { startIndex, endIndex } = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage);
+
+ // Print prompt
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.done ? this.selection.title : this.selection.disabled
+ ? color.yellow(this.warn) : color.gray(this.hint)
+ ].join(' ');
+
+ // Print choices
+ if (!this.done) {
+ this.outputText += '\n';
+ for (let i = startIndex; i < endIndex; i++) {
+ let title, prefix, desc = '', v = this.choices[i];
+
+ // Determine whether to display "more choices" indicators
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < this.choices.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+
+ if (v.disabled) {
+ title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + ' ' : ' ') + prefix;
+ } else {
+ title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
+ prefix = (this.cursor === i ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+ if (v.description && this.cursor === i) {
+ desc = ` - ${v.description}`;
+ if (prefix.length + title.length + desc.length >= this.out.columns
+ || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, { margin: 3, width: this.out.columns });
+ }
+ }
+ }
+
+ this.outputText += `${prefix} ${title}${color.gray(desc)}\n`;
+ }
+ }
+
+ this.out.write(this.outputText);
+ }
+}
+
+module.exports = SelectPrompt;
diff --git a/includes/node_modules/prompts/lib/elements/text.js b/includes/node_modules/prompts/lib/elements/text.js
new file mode 100644
index 0000000..ee78181
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/text.js
@@ -0,0 +1,208 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { erase, cursor } = require('sisteransi');
+const { style, clear, lines, figures } = require('../util');
+
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.initial] Default value
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+class TextPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.msg = opts.message;
+ this.initial = opts.initial || ``;
+ this.validator = opts.validate || (() => true);
+ this.value = ``;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.clear = clear(``, this.out.columns);
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && this.initial) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(this.initial));
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(v);
+ }
+ this._value = v;
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ reset() {
+ this.value = ``;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.value = this.value || this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.red = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ async validate() {
+ let valid = await this.validator(this.value);
+ if (typeof valid === `string`) {
+ this.errorMsg = valid;
+ valid = false;
+ }
+ this.error = !valid;
+ }
+
+ async submit() {
+ this.value = this.value || this.initial;
+ this.cursorOffset = 0;
+ this.cursor = this.rendered.length;
+ await this.validate();
+ if (this.error) {
+ this.red = true;
+ this.fire();
+ this.render();
+ return;
+ }
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ next() {
+ if (!this.placeholder) return this.bell();
+ this.value = this.initial;
+ this.cursor = this.rendered.length;
+ this.fire();
+ this.render();
+ }
+
+ moveCursor(n) {
+ if (this.placeholder) return;
+ this.cursor = this.cursor+n;
+ this.cursorOffset += n;
+ }
+
+ _(c, key) {
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${c}${s2}`;
+ this.red = false;
+ this.cursor = this.placeholder ? 0 : s1.length+1;
+ this.render();
+ }
+
+ delete() {
+ if (this.isCursorAtStart()) return this.bell();
+ let s1 = this.value.slice(0, this.cursor-1);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+ if (this.isCursorAtStart()) {
+ this.cursorOffset = 0
+ } else {
+ this.cursorOffset++;
+ this.moveCursor(-1);
+ }
+ this.render();
+ }
+
+ deleteForward() {
+ if(this.cursor*this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor+1);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+ if (this.isCursorAtEnd()) {
+ this.cursorOffset = 0;
+ } else {
+ this.cursorOffset++;
+ }
+ this.render();
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length;
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0 || this.placeholder) return this.bell();
+ this.moveCursor(-1);
+ this.render();
+ }
+
+ right() {
+ if (this.cursor*this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ this.moveCursor(1);
+ this.render();
+ }
+
+ isCursorAtStart() {
+ return this.cursor === 0 || (this.placeholder && this.cursor === 1);
+ }
+
+ isCursorAtEnd() {
+ return this.cursor === this.rendered.length || (this.placeholder && this.cursor === this.rendered.length + 1)
+ }
+
+ render() {
+ if (this.closed) return;
+ if (!this.firstRender) {
+ if (this.outputError)
+ this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+ super.render();
+ this.outputError = '';
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ this.red ? color.red(this.rendered) : this.rendered
+ ].join(` `);
+
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`)
+ .reduce((a, l, i) => a + `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
+ }
+}
+
+module.exports = TextPrompt; \ No newline at end of file
diff --git a/includes/node_modules/prompts/lib/elements/toggle.js b/includes/node_modules/prompts/lib/elements/toggle.js
new file mode 100644
index 0000000..bad612c
--- /dev/null
+++ b/includes/node_modules/prompts/lib/elements/toggle.js
@@ -0,0 +1,118 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear } = require('../util');
+const { cursor, erase } = require('sisteransi');
+
+/**
+ * TogglePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial=false] Default value
+ * @param {String} [opts.active='no'] Active label
+ * @param {String} [opts.inactive='off'] Inactive label
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class TogglePrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = !!opts.initial;
+ this.active = opts.active || 'on';
+ this.inactive = opts.inactive || 'off';
+ this.initialValue = this.value;
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ deactivate() {
+ if (this.value === false) return this.bell();
+ this.value = false;
+ this.render();
+ }
+
+ activate() {
+ if (this.value === true) return this.bell();
+ this.value = true;
+ this.render();
+ }
+
+ delete() {
+ this.deactivate();
+ }
+ left() {
+ this.deactivate();
+ }
+ right() {
+ this.activate();
+ }
+ down() {
+ this.deactivate();
+ }
+ up() {
+ this.activate();
+ }
+
+ next() {
+ this.value = !this.value;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.value = !this.value;
+ } else if (c === '1') {
+ this.value = true;
+ } else if (c === '0') {
+ this.value = false;
+ } else return this.bell();
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ this.value ? this.inactive : color.cyan().underline(this.inactive),
+ color.gray('/'),
+ this.value ? color.cyan().underline(this.active) : this.active
+ ].join(' ');
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = TogglePrompt;
diff --git a/includes/node_modules/prompts/lib/index.js b/includes/node_modules/prompts/lib/index.js
new file mode 100644
index 0000000..a5374d5
--- /dev/null
+++ b/includes/node_modules/prompts/lib/index.js
@@ -0,0 +1,98 @@
+'use strict';
+
+const prompts = require('./prompts');
+
+const passOn = ['suggest', 'format', 'onState', 'validate', 'onRender', 'type'];
+const noop = () => {};
+
+/**
+ * Prompt for a series of questions
+ * @param {Array|Object} questions Single question object or Array of question objects
+ * @param {Function} [onSubmit] Callback function called on prompt submit
+ * @param {Function} [onCancel] Callback function called on cancel/abort
+ * @returns {Object} Object with values from user input
+ */
+async function prompt(questions=[], { onSubmit=noop, onCancel=noop }={}) {
+ const answers = {};
+ const override = prompt._override || {};
+ questions = [].concat(questions);
+ let answer, question, quit, name, type, lastPrompt;
+
+ const getFormattedAnswer = async (question, answer, skipValidation = false) => {
+ if (!skipValidation && question.validate && question.validate(answer) !== true) {
+ return;
+ }
+ return question.format ? await question.format(answer, answers) : answer
+ };
+
+ for (question of questions) {
+ ({ name, type } = question);
+
+ // evaluate type first and skip if type is a falsy value
+ if (typeof type === 'function') {
+ type = await type(answer, { ...answers }, question)
+ question['type'] = type
+ }
+ if (!type) continue;
+
+ // if property is a function, invoke it unless it's a special function
+ for (let key in question) {
+ if (passOn.includes(key)) continue;
+ let value = question[key];
+ question[key] = typeof value === 'function' ? await value(answer, { ...answers }, lastPrompt) : value;
+ }
+
+ lastPrompt = question;
+
+ if (typeof question.message !== 'string') {
+ throw new Error('prompt message is required');
+ }
+
+ // update vars in case they changed
+ ({ name, type } = question);
+
+ if (prompts[type] === void 0) {
+ throw new Error(`prompt type (${type}) is not defined`);
+ }
+
+ if (override[question.name] !== undefined) {
+ answer = await getFormattedAnswer(question, override[question.name]);
+ if (answer !== undefined) {
+ answers[name] = answer;
+ continue;
+ }
+ }
+
+ try {
+ // Get the injected answer if there is one or prompt the user
+ answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts[type](question);
+ answers[name] = answer = await getFormattedAnswer(question, answer, true);
+ quit = await onSubmit(question, answer, answers);
+ } catch (err) {
+ quit = !(await onCancel(question, answers));
+ }
+
+ if (quit) return answers;
+ }
+
+ return answers;
+}
+
+function getInjectedAnswer(injected, deafultValue) {
+ const answer = injected.shift();
+ if (answer instanceof Error) {
+ throw answer;
+ }
+
+ return (answer === undefined) ? deafultValue : answer;
+}
+
+function inject(answers) {
+ prompt._injected = (prompt._injected || []).concat(answers);
+}
+
+function override(answers) {
+ prompt._override = Object.assign({}, answers);
+}
+
+module.exports = Object.assign(prompt, { prompt, prompts, inject, override });
diff --git a/includes/node_modules/prompts/lib/prompts.js b/includes/node_modules/prompts/lib/prompts.js
new file mode 100644
index 0000000..9f62556
--- /dev/null
+++ b/includes/node_modules/prompts/lib/prompts.js
@@ -0,0 +1,206 @@
+'use strict';
+const $ = exports;
+const el = require('./elements');
+const noop = v => v;
+
+function toPrompt(type, args, opts={}) {
+ return new Promise((res, rej) => {
+ const p = new el[type](args);
+ const onAbort = opts.onAbort || noop;
+ const onSubmit = opts.onSubmit || noop;
+ const onExit = opts.onExit || noop;
+ p.on('state', args.onState || noop);
+ p.on('submit', x => res(onSubmit(x)));
+ p.on('exit', x => res(onExit(x)));
+ p.on('abort', x => rej(onAbort(x)));
+ });
+}
+
+/**
+ * Text prompt
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.text = args => toPrompt('TextPrompt', args);
+
+/**
+ * Password prompt with masked input
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.password = args => {
+ args.style = 'password';
+ return $.text(args);
+};
+
+/**
+ * Prompt where input is invisible, like sudo
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.invisible = args => {
+ args.style = 'invisible';
+ return $.text(args);
+};
+
+/**
+ * Number prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.number = args => toPrompt('NumberPrompt', args);
+
+/**
+ * Date prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.date = args => toPrompt('DatePrompt', args);
+
+/**
+ * Classic yes/no prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.confirm = args => toPrompt('ConfirmPrompt', args);
+
+/**
+ * List prompt, split intput string by `seperator`
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {string} [args.separator] String separator
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input, in form of an `Array`
+ */
+$.list = args => {
+ const sep = args.separator || ',';
+ return toPrompt('TextPrompt', args, {
+ onSubmit: str => str.split(sep).map(s => s.trim())
+ });
+};
+
+/**
+ * Toggle/switch prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {string} [args.active="on"] Text for `active` state
+ * @param {string} [args.inactive="off"] Text for `inactive` state
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.toggle = args => toPrompt('TogglePrompt', args);
+
+/**
+ * Interactive select prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value }, ...]`
+ * @param {number} [args.initial] Index of default value
+ * @param {String} [args.hint] Hint to display
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.select = args => toPrompt('SelectPrompt', args);
+
+/**
+ * Interactive multi-select / autocompleteMultiselect prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value, [selected] }, ...]`
+ * @param {number} [args.max] Max select
+ * @param {string} [args.hint] Hint to display user
+ * @param {Number} [args.cursor=0] Cursor start position
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.multiselect = args => {
+ args.choices = [].concat(args.choices || []);
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+ return toPrompt('MultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+$.autocompleteMultiselect = args => {
+ args.choices = [].concat(args.choices || []);
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+ return toPrompt('AutocompleteMultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+const byTitle = (input, choices) => Promise.resolve(
+ choices.filter(item => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase())
+);
+
+/**
+ * Interactive auto-complete prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of auto-complete choices objects `[{ title, value }, ...]`
+ * @param {Function} [args.suggest] Function to filter results based on user input. Defaults to sort by `title`
+ * @param {number} [args.limit=10] Max number of results to show
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {String} [args.initial] Index of the default value
+ * @param {boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {String} [args.fallback] Fallback message - defaults to initial value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.autocomplete = args => {
+ args.suggest = args.suggest || byTitle;
+ args.choices = [].concat(args.choices || []);
+ return toPrompt('AutocompletePrompt', args);
+};
diff --git a/includes/node_modules/prompts/lib/util/action.js b/includes/node_modules/prompts/lib/util/action.js
new file mode 100644
index 0000000..fefbd94
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/action.js
@@ -0,0 +1,39 @@
+'use strict';
+
+module.exports = (key, isSelect) => {
+ if (key.meta && key.name !== 'escape') return;
+
+ if (key.ctrl) {
+ if (key.name === 'a') return 'first';
+ if (key.name === 'c') return 'abort';
+ if (key.name === 'd') return 'abort';
+ if (key.name === 'e') return 'last';
+ if (key.name === 'g') return 'reset';
+ }
+
+ if (isSelect) {
+ if (key.name === 'j') return 'down';
+ if (key.name === 'k') return 'up';
+ }
+
+ if (key.name === 'return') return 'submit';
+ if (key.name === 'enter') return 'submit'; // ctrl + J
+ if (key.name === 'backspace') return 'delete';
+ if (key.name === 'delete') return 'deleteForward';
+ if (key.name === 'abort') return 'abort';
+ if (key.name === 'escape') return 'exit';
+ if (key.name === 'tab') return 'next';
+ if (key.name === 'pagedown') return 'nextPage';
+ if (key.name === 'pageup') return 'prevPage';
+ // TODO create home() in prompt types (e.g. TextPrompt)
+ if (key.name === 'home') return 'home';
+ // TODO create end() in prompt types (e.g. TextPrompt)
+ if (key.name === 'end') return 'end';
+
+ if (key.name === 'up') return 'up';
+ if (key.name === 'down') return 'down';
+ if (key.name === 'right') return 'right';
+ if (key.name === 'left') return 'left';
+
+ return false;
+};
diff --git a/includes/node_modules/prompts/lib/util/clear.js b/includes/node_modules/prompts/lib/util/clear.js
new file mode 100644
index 0000000..e4772d5
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/clear.js
@@ -0,0 +1,22 @@
+'use strict';
+
+const strip = require('./strip');
+const { erase, cursor } = require('sisteransi');
+
+const width = str => [...strip(str)].length;
+
+/**
+ * @param {string} prompt
+ * @param {number} perLine
+ */
+module.exports = function(prompt, perLine) {
+ if (!perLine) return erase.line + cursor.to(0);
+
+ let rows = 0;
+ const lines = prompt.split(/\r?\n/);
+ for (let line of lines) {
+ rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
+ }
+
+ return erase.lines(rows);
+};
diff --git a/includes/node_modules/prompts/lib/util/entriesToDisplay.js b/includes/node_modules/prompts/lib/util/entriesToDisplay.js
new file mode 100644
index 0000000..5f6efbb
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/entriesToDisplay.js
@@ -0,0 +1,21 @@
+'use strict';
+
+/**
+ * Determine what entries should be displayed on the screen, based on the
+ * currently selected index and the maximum visible. Used in list-based
+ * prompts like `select` and `multiselect`.
+ *
+ * @param {number} cursor the currently selected entry
+ * @param {number} total the total entries available to display
+ * @param {number} [maxVisible] the number of entries that can be displayed
+ */
+module.exports = (cursor, total, maxVisible) => {
+ maxVisible = maxVisible || total;
+
+ let startIndex = Math.min(total- maxVisible, cursor - Math.floor(maxVisible / 2));
+ if (startIndex < 0) startIndex = 0;
+
+ let endIndex = Math.min(startIndex + maxVisible, total);
+
+ return { startIndex, endIndex };
+};
diff --git a/includes/node_modules/prompts/lib/util/figures.js b/includes/node_modules/prompts/lib/util/figures.js
new file mode 100644
index 0000000..cd31b88
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/figures.js
@@ -0,0 +1,33 @@
+'use strict';
+
+ const main = {
+ arrowUp: '↑',
+ arrowDown: '↓',
+ arrowLeft: '←',
+ arrowRight: '→',
+ radioOn: '◉',
+ radioOff: '◯',
+ tick: '✔',
+ cross: '✖',
+ ellipsis: '…',
+ pointerSmall: '›',
+ line: '─',
+ pointer: '❯'
+};
+const win = {
+ arrowUp: main.arrowUp,
+ arrowDown: main.arrowDown,
+ arrowLeft: main.arrowLeft,
+ arrowRight: main.arrowRight,
+ radioOn: '(*)',
+ radioOff: '( )',
+ tick: '√',
+ cross: '×',
+ ellipsis: '...',
+ pointerSmall: '»',
+ line: '─',
+ pointer: '>'
+};
+const figures = process.platform === 'win32' ? win : main;
+
+ module.exports = figures;
diff --git a/includes/node_modules/prompts/lib/util/index.js b/includes/node_modules/prompts/lib/util/index.js
new file mode 100644
index 0000000..f815986
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/index.js
@@ -0,0 +1,12 @@
+'use strict';
+
+module.exports = {
+ action: require('./action'),
+ clear: require('./clear'),
+ style: require('./style'),
+ strip: require('./strip'),
+ figures: require('./figures'),
+ lines: require('./lines'),
+ wrap: require('./wrap'),
+ entriesToDisplay: require('./entriesToDisplay')
+};
diff --git a/includes/node_modules/prompts/lib/util/lines.js b/includes/node_modules/prompts/lib/util/lines.js
new file mode 100644
index 0000000..de30419
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/lines.js
@@ -0,0 +1,15 @@
+'use strict';
+
+const strip = require('./strip');
+
+/**
+ * @param {string} msg
+ * @param {number} perLine
+ */
+module.exports = function (msg, perLine) {
+ let lines = String(strip(msg) || '').split(/\r?\n/);
+
+ if (!perLine) return lines.length;
+ return lines.map(l => Math.ceil(l.length / perLine))
+ .reduce((a, b) => a + b);
+};
diff --git a/includes/node_modules/prompts/lib/util/strip.js b/includes/node_modules/prompts/lib/util/strip.js
new file mode 100644
index 0000000..8ebf4cb
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/strip.js
@@ -0,0 +1,11 @@
+'use strict';
+
+module.exports = str => {
+ const pattern = [
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'
+ ].join('|');
+
+ const RGX = new RegExp(pattern, 'g');
+ return typeof str === 'string' ? str.replace(RGX, '') : str;
+};
diff --git a/includes/node_modules/prompts/lib/util/style.js b/includes/node_modules/prompts/lib/util/style.js
new file mode 100644
index 0000000..1851cc7
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/style.js
@@ -0,0 +1,40 @@
+'use strict';
+
+const c = require('kleur');
+const figures = require('./figures');
+
+// rendering user input.
+const styles = Object.freeze({
+ password: { scale: 1, render: input => '*'.repeat(input.length) },
+ emoji: { scale: 2, render: input => '😃'.repeat(input.length) },
+ invisible: { scale: 0, render: input => '' },
+ default: { scale: 1, render: input => `${input}` }
+});
+const render = type => styles[type] || styles.default;
+
+// icon to signalize a prompt.
+const symbols = Object.freeze({
+ aborted: c.red(figures.cross),
+ done: c.green(figures.tick),
+ exited: c.yellow(figures.cross),
+ default: c.cyan('?')
+});
+
+const symbol = (done, aborted, exited) =>
+ aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default;
+
+// between the question and the user's input.
+const delimiter = completing =>
+ c.gray(completing ? figures.ellipsis : figures.pointerSmall);
+
+const item = (expandable, expanded) =>
+ c.gray(expandable ? (expanded ? figures.pointerSmall : '+') : figures.line);
+
+module.exports = {
+ styles,
+ render,
+ symbols,
+ symbol,
+ delimiter,
+ item
+};
diff --git a/includes/node_modules/prompts/lib/util/wrap.js b/includes/node_modules/prompts/lib/util/wrap.js
new file mode 100644
index 0000000..43b5399
--- /dev/null
+++ b/includes/node_modules/prompts/lib/util/wrap.js
@@ -0,0 +1,27 @@
+'use strict';
+
+/**
+ * @param {string} msg The message to wrap
+ * @param {object} opts
+ * @param {number|string} [opts.margin] Left margin
+ * @param {number} opts.width Maximum characters per line including the margin
+ */
+module.exports = (msg, opts = {}) => {
+ const tab = Number.isSafeInteger(parseInt(opts.margin))
+ ? new Array(parseInt(opts.margin)).fill(' ').join('')
+ : (opts.margin || '');
+
+ const width = opts.width;
+
+ return (msg || '').split(/\r?\n/g)
+ .map(line => line
+ .split(/\s+/g)
+ .reduce((arr, w) => {
+ if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width)
+ arr[arr.length - 1] += ` ${w}`;
+ else arr.push(`${tab}${w}`);
+ return arr;
+ }, [ tab ])
+ .join('\n'))
+ .join('\n');
+};
diff --git a/includes/node_modules/prompts/license b/includes/node_modules/prompts/license
new file mode 100644
index 0000000..13dc83c
--- /dev/null
+++ b/includes/node_modules/prompts/license
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Terkel Gjervig Nielsen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/includes/node_modules/prompts/package.json b/includes/node_modules/prompts/package.json
new file mode 100644
index 0000000..f7ba84b
--- /dev/null
+++ b/includes/node_modules/prompts/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "prompts",
+ "version": "2.4.2",
+ "description": "Lightweight, beautiful and user-friendly prompts",
+ "license": "MIT",
+ "repository": "terkelg/prompts",
+ "main": "index.js",
+ "author": {
+ "name": "Terkel Gjervig",
+ "email": "terkel@terkel.com",
+ "url": "https://terkel.com"
+ },
+ "files": [
+ "lib",
+ "dist",
+ "index.js"
+ ],
+ "scripts": {
+ "start": "node lib/index.js",
+ "build": "babel lib -d dist",
+ "prepublishOnly": "npm run build",
+ "test": "tape test/*.js | tap-spec"
+ },
+ "keywords": [
+ "ui",
+ "prompts",
+ "cli",
+ "prompt",
+ "interface",
+ "command-line",
+ "input",
+ "command",
+ "stdin",
+ "menu",
+ "ask",
+ "interact"
+ ],
+ "dependencies": {
+ "kleur": "^3.0.3",
+ "sisteransi": "^1.0.5"
+ },
+ "devDependencies": {
+ "@babel/cli": "^7.12.1",
+ "@babel/core": "^7.12.3",
+ "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
+ "@babel/preset-env": "^7.12.1",
+ "tap-spec": "^2.2.2",
+ "tape": "^4.13.3"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+}
diff --git a/includes/node_modules/prompts/readme.md b/includes/node_modules/prompts/readme.md
new file mode 100755
index 0000000..4a8b065
--- /dev/null
+++ b/includes/node_modules/prompts/readme.md
@@ -0,0 +1,882 @@
+<p align="center">
+ <img src="https://github.com/terkelg/prompts/raw/master/prompts.png" alt="Prompts" width="500" />
+</p>
+
+<h1 align="center">❯ Prompts</h1>
+
+<p align="center">
+ <a href="https://npmjs.org/package/prompts">
+ <img src="https://img.shields.io/npm/v/prompts.svg" alt="version" />
+ </a>
+ <a href="https://travis-ci.org/terkelg/prompts">
+ <img src="https://img.shields.io/travis/terkelg/prompts.svg" alt="travis" />
+ </a>
+ <a href="https://npmjs.org/package/prompts">
+ <img src="https://img.shields.io/npm/dm/prompts.svg" alt="downloads" />
+ </a>
+ <!---
+ <a href="https://packagephobia.now.sh/result?p=prompts">
+ <img src="https://packagephobia.now.sh/badge?p=prompts" alt="install size" />
+ </a>
+ --->
+</p>
+
+<p align="center">
+ <b>Lightweight, beautiful and user-friendly interactive prompts</b><br />
+ <sub>>_ Easy to use CLI prompts to enquire users for information▌</sub>
+</p>
+
+<br />
+
+* **Simple**: prompts has [no big dependencies](http://npm.anvaka.com/#/view/2d/prompts) nor is it broken into a [dozen](http://npm.anvaka.com/#/view/2d/inquirer) tiny modules that only work well together.
+* **User friendly**: prompt uses layout and colors to create beautiful cli interfaces.
+* **Promised**: uses promises and `async`/`await`. No callback hell.
+* **Flexible**: all prompts are independent and can be used on their own.
+* **Testable**: provides a way to submit answers programmatically.
+* **Unified**: consistent experience across all [prompts](#-types).
+
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+
+## ❯ Install
+
+```
+$ npm install --save prompts
+```
+
+> This package supports Node 6 and above
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+## ❯ Usage
+
+<img src="https://github.com/terkelg/prompts/raw/master/media/example.gif" alt="example prompt" width="499" height="103" />
+
+```js
+const prompts = require('prompts');
+
+(async () => {
+ const response = await prompts({
+ type: 'number',
+ name: 'value',
+ message: 'How old are you?',
+ validate: value => value < 18 ? `Nightclub is 18+ only` : true
+ });
+
+ console.log(response); // => { value: 24 }
+})();
+```
+
+> See [`example.js`](https://github.com/terkelg/prompts/blob/master/example.js) for more options.
+
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+
+## ❯ Examples
+
+### Single Prompt
+
+Prompt with a single prompt object. Returns an object with the response.
+
+```js
+const prompts = require('prompts');
+
+(async () => {
+ const response = await prompts({
+ type: 'text',
+ name: 'meaning',
+ message: 'What is the meaning of life?'
+ });
+
+ console.log(response.meaning);
+})();
+```
+
+### Prompt Chain
+
+Prompt with a list of prompt objects. Returns an object with the responses.
+Make sure to give each prompt a unique `name` property to prevent overwriting values.
+
+```js
+const prompts = require('prompts');
+
+const questions = [
+ {
+ type: 'text',
+ name: 'username',
+ message: 'What is your GitHub username?'
+ },
+ {
+ type: 'number',
+ name: 'age',
+ message: 'How old are you?'
+ },
+ {
+ type: 'text',
+ name: 'about',
+ message: 'Tell something about yourself',
+ initial: 'Why should I?'
+ }
+];
+
+(async () => {
+ const response = await prompts(questions);
+
+ // => response => { username, age, about }
+})();
+```
+
+### Dynamic Prompts
+
+Prompt properties can be functions too.
+Prompt Objects with `type` set to `falsy` values are skipped.
+
+```js
+const prompts = require('prompts');
+
+const questions = [
+ {
+ type: 'text',
+ name: 'dish',
+ message: 'Do you like pizza?'
+ },
+ {
+ type: prev => prev == 'pizza' ? 'text' : null,
+ name: 'topping',
+ message: 'Name a topping'
+ }
+];
+
+(async () => {
+ const response = await prompts(questions);
+})();
+```
+
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+
+## ❯ API
+
+### prompts(prompts, options)
+
+Type: `Function`<br>
+Returns: `Object`
+
+Prompter function which takes your [prompt objects](#-prompt-objects) and returns an object with responses.
+
+
+#### prompts
+
+Type: `Array|Object`<br>
+
+Array of [prompt objects](#-prompt-objects).
+ These are the questions the user will be prompted. You can see the list of supported [prompt types here](#-types).
+
+Prompts can be submitted (<kbd>return</kbd>, <kbd>enter</kbd>) or canceled (<kbd>esc</kbd>, <kbd>abort</kbd>, <kbd>ctrl</kbd>+<kbd>c</kbd>, <kbd>ctrl</kbd>+<kbd>d</kbd>). No property is being defined on the returned response object when a prompt is canceled.
+
+#### options.onSubmit
+
+Type: `Function`<br>
+Default: `() => {}`
+
+Callback that's invoked after each prompt submission.
+Its signature is `(prompt, answer, answers)` where `prompt` is the current prompt object, `answer` the user answer to the current question and `answers` the user answers so far. Async functions are supported.
+
+Return `true` to quit the prompt chain and return all collected responses so far, otherwise continue to iterate prompt objects.
+
+**Example:**
+```js
+(async () => {
+ const questions = [{ ... }];
+ const onSubmit = (prompt, answer) => console.log(`Thanks I got ${answer} from ${prompt.name}`);
+ const response = await prompts(questions, { onSubmit });
+})();
+```
+
+#### options.onCancel
+
+Type: `Function`<br>
+Default: `() => {}`
+
+Callback that's invoked when the user cancels/exits the prompt.
+Its signature is `(prompt, answers)` where `prompt` is the current prompt object and `answers` the user answers so far. Async functions are supported.
+
+Return `true` to continue and prevent the prompt loop from aborting.
+On cancel responses collected so far are returned.
+
+**Example:**
+```js
+(async () => {
+ const questions = [{ ... }];
+ const onCancel = prompt => {
+ console.log('Never stop prompting!');
+ return true;
+ }
+ const response = await prompts(questions, { onCancel });
+})();
+```
+
+### override
+
+Type: `Function`
+
+Preanswer questions by passing an object with answers to `prompts.override`.
+Powerful when combined with arguments of process.
+
+**Example**
+```js
+const prompts = require('prompts');
+prompts.override(require('yargs').argv);
+
+(async () => {
+ const response = await prompts([
+ {
+ type: 'text',
+ name: 'twitter',
+ message: `What's your twitter handle?`
+ },
+ {
+ type: 'multiselect',
+ name: 'color',
+ message: 'Pick colors',
+ choices: [
+ { title: 'Red', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00' },
+ { title: 'Blue', value: '#0000ff' }
+ ],
+ }
+ ]);
+
+ console.log(response);
+})();
+```
+
+### inject(values)
+
+Type: `Function`<br>
+
+Programmatically inject responses. This enables you to prepare the responses ahead of time.
+If any injected value is found the prompt is immediately resolved with the injected value.
+This feature is intended for testing only.
+
+#### values
+
+Type: `Array`
+
+Array with values to inject. Resolved values are removed from the internal inject array.
+Each value can be an array of values in order to provide answers for a question asked multiple times.
+If a value is an instance of `Error` it will simulate the user cancelling/exiting the prompt.
+
+**Example:**
+```js
+const prompts = require('prompts');
+
+prompts.inject([ '@terkelg', ['#ff0000', '#0000ff'] ]);
+
+(async () => {
+ const response = await prompts([
+ {
+ type: 'text',
+ name: 'twitter',
+ message: `What's your twitter handle?`
+ },
+ {
+ type: 'multiselect',
+ name: 'color',
+ message: 'Pick colors',
+ choices: [
+ { title: 'Red', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00' },
+ { title: 'Blue', value: '#0000ff' }
+ ],
+ }
+ ]);
+
+ // => { twitter: 'terkelg', color: [ '#ff0000', '#0000ff' ] }
+})();
+```
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+
+## ❯ Prompt Objects
+
+Prompts Objects are JavaScript objects that define the "questions" and the [type of prompt](#-types).
+Almost all prompt objects have the following properties:
+
+```js
+{
+ type: String | Function,
+ name: String | Function,
+ message: String | Function,
+ initial: String | Function | Async Function
+ format: Function | Async Function,
+ onRender: Function
+ onState: Function
+ stdin: Readable
+ stdout: Writeable
+}
+```
+
+Each property be of type `function` and will be invoked right before prompting the user.
+
+The function signature is `(prev, values, prompt)`, where `prev` is the value from the previous prompt,
+`values` is the response object with all values collected so far and `prompt` is the previous prompt object.
+
+**Function example:**
+```js
+{
+ type: prev => prev > 3 ? 'confirm' : null,
+ name: 'confirm',
+ message: (prev, values) => `Please confirm that you eat ${values.dish} times ${prev} a day?`
+}
+```
+
+The above prompt will be skipped if the value of the previous prompt is less than 3.
+
+### type
+
+Type: `String|Function`
+
+Defines the type of prompt to display. See the list of [prompt types](#-types) for valid values.
+
+If `type` is a falsy value the prompter will skip that question.
+```js
+{
+ type: null,
+ name: 'forgetme',
+ message: `I'll never be shown anyway`,
+}
+```
+
+### name
+
+Type: `String|Function`
+
+The response will be saved under this key/property in the returned response object.
+In case you have multiple prompts with the same name only the latest response will be stored.
+
+> Make sure to give prompts unique names if you don't want to overwrite previous values.
+
+### message
+
+Type: `String|Function`
+
+The message to be displayed to the user.
+
+### initial
+
+Type: `String|Function`
+
+Optional default prompt value. Async functions are supported too.
+
+### format
+
+Type: `Function`
+
+Receive the user input and return the formatted value to be used inside the program.
+The value returned will be added to the response object.
+
+The function signature is `(val, values)`, where `val` is the value from the current prompt and
+`values` is the current response object in case you need to format based on previous responses.
+
+**Example:**
+```js
+{
+ type: 'number',
+ name: 'price',
+ message: 'Enter price',
+ format: val => Intl.NumberFormat(undefined, { style: 'currency', currency: 'USD' }).format(val);
+}
+```
+
+### onRender
+
+Type: `Function`
+
+Callback for when the prompt is rendered.
+The function receives [kleur](https://github.com/lukeed/kleur) as its first argument and `this` refers to the current prompt.
+
+**Example:**
+```js
+{
+ type: 'number',
+ message: 'This message will be overridden',
+ onRender(kleur) {
+ this.msg = kleur.cyan('Enter a number');
+ }
+}
+```
+
+### onState
+
+Type: `Function`
+
+Callback for when the state of the current prompt changes.
+The function signature is `(state)` where `state` is an object with a snapshot of the current state.
+The state object has two properties `value` and `aborted`. E.g `{ value: 'This is ', aborted: false }`
+
+### stdin and stdout
+
+Type: `Stream`
+
+By default, prompts uses `process.stdin` for receiving input and `process.stdout` for writing output.
+If you need to use different streams, for instance `process.stderr`, you can set these with the `stdin` and `stdout` properties.
+
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+
+## ❯ Types
+
+* [text](#textmessage-initial-style)
+* [password](#passwordmessage-initial)
+* [invisible](#invisiblemessage-initial)
+* [number](#numbermessage-initial-max-min-style)
+* [confirm](#confirmmessage-initial)
+* [list](#listmessage-initial)
+* [toggle](#togglemessage-initial-active-inactive)
+* [select](#selectmessage-choices-initial-hint-warn)
+* [multiselect](#multiselectmessage-choices-initial-max-hint-warn)
+* [autocompleteMultiselect](#multiselectmessage-choices-initial-max-hint-warn)
+* [autocomplete](#autocompletemessage-choices-initial-suggest-limit-style)
+* [date](#datemessage-initial-warn)
+
+***
+
+### text(message, [initial], [style])
+> Text prompt for free text input.
+
+Hit <kbd>tab</kbd> to autocomplete to `initial` value when provided.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/text.gif" alt="text prompt" width="499" height="103" />
+
+```js
+{
+ type: 'text',
+ name: 'value',
+ message: `What's your twitter handle?`
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `string` | Default string value |
+| style | `string` | Render style (`default`, `password`, `invisible`, `emoji`). Defaults to `default` |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### password(message, [initial])
+> Password prompt with masked input.
+
+This prompt is a similar to a prompt of type `'text'` with `style` set to `'password'`.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/password.gif" alt="password prompt" width="499" height="103" />
+
+```js
+{
+ type: 'password',
+ name: 'value',
+ message: 'Tell me a secret'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `string` | Default string value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### invisible(message, [initial])
+> Prompts user for invisible text input.
+
+This prompt is working like `sudo` where the input is invisible.
+This prompt is a similar to a prompt of type `'text'` with style set to `'invisible'`.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/invisible.gif" alt="invisible prompt" width="499" height="103" />
+
+```js
+{
+ type: 'invisible',
+ name: 'value',
+ message: 'Enter password'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `string` | Default string value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### number(message, initial, [max], [min], [style])
+> Prompts user for number input.
+
+You can type in numbers and use <kbd>up</kbd>/<kbd>down</kbd> to increase/decrease the value. Only numbers are allowed as input. Hit <kbd>tab</kbd> to autocomplete to `initial` value when provided.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/number.gif" alt="number prompt" width="499" height="103" />
+
+```js
+{
+ type: 'number',
+ name: 'value',
+ message: 'How old are you?',
+ initial: 0,
+ style: 'default',
+ min: 2,
+ max: 10
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `number` | Default number value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| max | `number` | Max value. Defaults to `Infinity` |
+| min | `number` | Min value. Defaults to `-infinity` |
+| float | `boolean` | Allow floating point inputs. Defaults to `false` |
+| round | `number` | Round `float` values to x decimals. Defaults to `2` |
+| increment | `number` | Increment step when using <kbd>arrow</kbd> keys. Defaults to `1` |
+| style | `string` | Render style (`default`, `password`, `invisible`, `emoji`). Defaults to `default` |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### confirm(message, [initial])
+> Classic yes/no prompt.
+
+Hit <kbd>y</kbd> or <kbd>n</kbd> to confirm/reject.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/confirm.gif" alt="confirm prompt" width="499" height="103" />
+
+```js
+{
+ type: 'confirm',
+ name: 'value',
+ message: 'Can you confirm?',
+ initial: true
+}
+```
+
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `boolean` | Default value. Default is `false` |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### list(message, [initial])
+> List prompt that return an array.
+
+Similar to the `text` prompt, but the output is an `Array` containing the
+string separated by `separator`.
+
+```js
+{
+ type: 'list',
+ name: 'value',
+ message: 'Enter keywords',
+ initial: '',
+ separator: ','
+}
+```
+
+<img src="https://github.com/terkelg/prompts/raw/master/media/list.gif" alt="list prompt" width="499" height="103" />
+
+
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `boolean` | Default value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| separator | `string` | String separator. Will trim all white-spaces from start and end of string. Defaults to `','` |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### toggle(message, [initial], [active], [inactive])
+> Interactive toggle/switch prompt.
+
+Use tab or <kbd>arrow keys</kbd>/<kbd>tab</kbd>/<kbd>space</kbd> to switch between options.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/toggle.gif" alt="toggle prompt" width="499" height="103" />
+
+```js
+{
+ type: 'toggle',
+ name: 'value',
+ message: 'Can you confirm?',
+ initial: true,
+ active: 'yes',
+ inactive: 'no'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `boolean` | Default value. Defaults to `false` |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| active | `string` | Text for `active` state. Defaults to `'on'` |
+| inactive | `string` | Text for `inactive` state. Defaults to `'off'` |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### select(message, choices, [initial], [hint], [warn])
+> Interactive select prompt.
+
+Use <kbd>up</kbd>/<kbd>down</kbd> to navigate. Use <kbd>tab</kbd> to cycle the list.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/select.gif" alt="select prompt" width="499" height="130" />
+
+```js
+{
+ type: 'select',
+ name: 'value',
+ message: 'Pick a color',
+ choices: [
+ { title: 'Red', description: 'This option has a description', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00', disabled: true },
+ { title: 'Blue', value: '#0000ff' }
+ ],
+ initial: 1
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `number` | Index of default value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| hint | `string` | Hint to display to the user |
+| warn | `string` | Message to display when selecting a disabled option |
+| choices | `Array` | Array of strings or choices objects `[{ title, description, value, disabled }, ...]`. The choice's index in the array will be used as its value if it is not specified. |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### multiselect(message, choices, [initial], [max], [hint], [warn])
+### autocompleteMultiselect(same)
+> Interactive multi-select prompt.
+> Autocomplete is a searchable multiselect prompt with the same options. Useful for long lists.
+
+Use <kbd>space</kbd> to toggle select/unselect and <kbd>up</kbd>/<kbd>down</kbd> to navigate. Use <kbd>tab</kbd> to cycle the list. You can also use <kbd>right</kbd> to select and <kbd>left</kbd> to deselect.
+By default this prompt returns an `array` containing the **values** of the selected items - not their display title.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/multiselect.gif" alt="multiselect prompt" width="499" height="130" />
+
+```js
+{
+ type: 'multiselect',
+ name: 'value',
+ message: 'Pick colors',
+ choices: [
+ { title: 'Red', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00', disabled: true },
+ { title: 'Blue', value: '#0000ff', selected: true }
+ ],
+ max: 2,
+ hint: '- Space to select. Return to submit'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| instructions | `string` or `boolean` | Prompt instructions to display |
+| choices | `Array` | Array of strings or choices objects `[{ title, value, disabled }, ...]`. The choice's index in the array will be used as its value if it is not specified. |
+| optionsPerPage | `number` | Number of options displayed per page (default: 10) |
+| min | `number` | Min select - will display error |
+| max | `number` | Max select |
+| hint | `string` | Hint to display to the user |
+| warn | `string` | Message to display when selecting a disabled option |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+This is one of the few prompts that don't take a initial value.
+If you want to predefine selected values, give the choice object an `selected` property of `true`.
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### autocomplete(message, choices, [initial], [suggest], [limit], [style])
+> Interactive auto complete prompt.
+
+The prompt will list options based on user input. Type to filter the list.
+Use <kbd>⇧</kbd>/<kbd>⇩</kbd> to navigate. Use <kbd>tab</kbd> to cycle the result. Use <kbd>Page Up</kbd>/<kbd>Page Down</kbd> (on Mac: <kbd>fn</kbd> + <kbd>⇧</kbd> / <kbd>⇩</kbd>) to change page. Hit <kbd>enter</kbd> to select the highlighted item below the prompt.
+
+The default suggests function is sorting based on the `title` property of the choices.
+You can overwrite how choices are being filtered by passing your own suggest function.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/autocomplete.gif" alt="auto complete prompt" width="499" height="163" />
+
+```js
+{
+ type: 'autocomplete',
+ name: 'value',
+ message: 'Pick your favorite actor',
+ choices: [
+ { title: 'Cage' },
+ { title: 'Clooney', value: 'silver-fox' },
+ { title: 'Gyllenhaal' },
+ { title: 'Gibson' },
+ { title: 'Grant' }
+ ]
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| choices | `Array` | Array of auto-complete choices objects `[{ title, value }, ...]` |
+| suggest | `function` | Filter function. Defaults to sort by `title` property. `suggest` should always return a promise. Filters using `title` by default |
+| limit | `number` | Max number of results to show. Defaults to `10` |
+| style | `string` | Render style (`default`, `password`, `invisible`, `emoji`). Defaults to `'default'` |
+| initial | `string \| number` | Default initial value |
+| clearFirst | `boolean` | The first ESCAPE keypress will clear the input |
+| fallback | `string` | Fallback message when no match is found. Defaults to `initial` value if provided |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with three properties: `value`, `aborted` and `exited` |
+
+Example on what a `suggest` function might look like:
+```js
+const suggestByTitle = (input, choices) =>
+ Promise.resolve(choices.filter(i => i.title.slice(0, input.length) === input))
+```
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### date(message, [initial], [warn])
+> Interactive date prompt.
+
+Use <kbd>left</kbd>/<kbd>right</kbd>/<kbd>tab</kbd> to navigate. Use <kbd>up</kbd>/<kbd>down</kbd> to change date.
+
+#### Example
+<img src="https://github.com/terkelg/prompts/raw/master/media/date.gif" alt="date prompt" width="499" height="103" />
+
+```js
+{
+ type: 'date',
+ name: 'value',
+ message: 'Pick a date',
+ initial: new Date(1997, 09, 12),
+ validate: date => date > Date.now() ? 'Not in the future' : true
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `date` | Default date |
+| locales | `object` | Use to define custom locales. See below for an example. |
+| mask | `string` | The format mask of the date. See below for more information.<br />Default: `YYYY-MM-DD HH:mm:ss` |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+Default locales:
+
+```javascript
+{
+ months: [
+ 'January', 'February', 'March', 'April',
+ 'May', 'June', 'July', 'August',
+ 'September', 'October', 'November', 'December'
+ ],
+ monthsShort: [
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ ],
+ weekdays: [
+ 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
+ 'Thursday', 'Friday', 'Saturday'
+ ],
+ weekdaysShort: [
+ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
+ ]
+}
+```
+>**Formatting**: See full list of formatting options in the [wiki](https://github.com/terkelg/prompts/wiki/Date-Time-Formatting)
+
+![split](https://github.com/terkelg/prompts/raw/master/media/split.png)
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+## ❯ Credit
+Many of the prompts are based on the work of [derhuerst](https://github.com/derhuerst).
+
+
+## ❯ License
+
+MIT © [Terkel Gjervig](https://terkel.com)
diff --git a/includes/node_modules/sisteransi/license b/includes/node_modules/sisteransi/license
new file mode 100644
index 0000000..13dc83c
--- /dev/null
+++ b/includes/node_modules/sisteransi/license
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Terkel Gjervig Nielsen
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/includes/node_modules/sisteransi/package.json b/includes/node_modules/sisteransi/package.json
new file mode 100755
index 0000000..55a6476
--- /dev/null
+++ b/includes/node_modules/sisteransi/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "sisteransi",
+ "version": "1.0.5",
+ "description": "ANSI escape codes for some terminal swag",
+ "main": "src/index.js",
+ "license": "MIT",
+ "author": {
+ "name": "Terkel Gjervig",
+ "email": "terkel@terkel.com",
+ "url": "https://terkel.com"
+ },
+ "scripts": {
+ "test": "tape test/*.js | tap-spec"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/terkelg/sisteransi"
+ },
+ "files": [
+ "src"
+ ],
+ "types": "./src/sisteransi.d.ts",
+ "keywords": [
+ "ansi",
+ "escape codes",
+ "escape",
+ "terminal",
+ "style"
+ ],
+ "devDependencies": {
+ "tap-spec": "^5.0.0",
+ "tape": "^4.13.2"
+ }
+}
diff --git a/includes/node_modules/sisteransi/readme.md b/includes/node_modules/sisteransi/readme.md
new file mode 100755
index 0000000..632f0d7
--- /dev/null
+++ b/includes/node_modules/sisteransi/readme.md
@@ -0,0 +1,113 @@
+# sister ANSI [![Version](https://img.shields.io/npm/v/sisteransi.svg)](https://www.npmjs.com/package/sisteransi) [![Build Status](https://travis-ci.org/terkelg/sisteransi.svg?branch=master)](https://travis-ci.org/terkelg/sisteransi) [![Downloads](https://img.shields.io/npm/dm/sisteransi.svg)](https://www.npmjs.com/package/sisteransi)
+
+> Ansi escape codes faster than you can say "[Bam bam](https://www.youtube.com/watch?v=OcaPu9JPenU)".
+
+## Installation
+
+```
+npm install sisteransi
+```
+
+
+## Usage
+
+```js
+const ansi = require('sisteransi');
+// or const { cursor } = require('sisteransi');
+
+const p = str => process.stdout.write(str);
+
+// move cursor to 2, 1
+p(ansi.cursor.to(2, 1));
+
+// to up, one down
+p(ansi.cursor.up(2)+ansi.cursor.down(1));
+```
+
+## API
+
+### cursor
+
+#### to(x, y)
+Set the absolute position of the cursor. `x0` `y0` is the top left of the screen.
+
+#### move(x, y)
+Set the position of the cursor relative to its current position.
+
+#### up(count = 1)
+Move cursor up a specific amount of rows. Default is `1`.
+
+#### down(count = 1)
+Move cursor down a specific amount of rows. Default is `1`.
+
+#### forward(count = 1)
+Move cursor forward a specific amount of rows. Default is `1`.
+
+#### backward(count = 1)
+Move cursor backward a specific amount of rows. Default is `1`.
+
+#### nextLine(count = 1)
+Move cursor to the next line a specific amount of lines. Default is `1`.
+
+#### prevLine(count = 1)
+Move cursor to the previous a specific amount of lines. Default is `1`.
+
+#### left
+Move cursor to the left side.
+
+#### hide
+Hide cursor.
+
+#### show
+Show cursor.
+
+#### save
+
+Save cursor position.
+
+#### restore
+
+Restore cursor position.
+
+
+### scroll
+
+#### up(count = 1)
+Scroll display up a specific amount of lines. Default to `1`.
+
+#### down(count = 1)
+Scroll display down a specific amount of lines. Default to `1`.
+
+
+### erase
+
+#### screen
+Erase the screen and move the cursor the top left position.
+
+#### up(count = 1)
+Erase the screen from the current line up to the top of the screen. Default to `1`.
+
+#### down(count = 2)
+Erase the screen from the current line down to the bottom of the screen. Default to `1`.
+
+#### line
+Erase the entire current line.
+
+#### lineEnd
+Erase from the current cursor position to the end of the current line.
+
+#### lineStart
+Erase from the current cursor position to the start of the current line.
+
+#### lines(count)
+Erase from the current cursor position up the specified amount of rows.
+
+
+## Credit
+
+This is a fork of [ansi-escapes](https://github.com/sindresorhus/ansi-escapes).
+
+
+## License
+
+MIT © [Terkel Gjervig](https://terkel.com)
diff --git a/includes/node_modules/sisteransi/src/index.js b/includes/node_modules/sisteransi/src/index.js
new file mode 100644
index 0000000..7034e2e
--- /dev/null
+++ b/includes/node_modules/sisteransi/src/index.js
@@ -0,0 +1,58 @@
+'use strict';
+
+const ESC = '\x1B';
+const CSI = `${ESC}[`;
+const beep = '\u0007';
+
+const cursor = {
+ to(x, y) {
+ if (!y) return `${CSI}${x + 1}G`;
+ return `${CSI}${y + 1};${x + 1}H`;
+ },
+ move(x, y) {
+ let ret = '';
+
+ if (x < 0) ret += `${CSI}${-x}D`;
+ else if (x > 0) ret += `${CSI}${x}C`;
+
+ if (y < 0) ret += `${CSI}${-y}A`;
+ else if (y > 0) ret += `${CSI}${y}B`;
+
+ return ret;
+ },
+ up: (count = 1) => `${CSI}${count}A`,
+ down: (count = 1) => `${CSI}${count}B`,
+ forward: (count = 1) => `${CSI}${count}C`,
+ backward: (count = 1) => `${CSI}${count}D`,
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
+ left: `${CSI}G`,
+ hide: `${CSI}?25l`,
+ show: `${CSI}?25h`,
+ save: `${ESC}7`,
+ restore: `${ESC}8`
+}
+
+const scroll = {
+ up: (count = 1) => `${CSI}S`.repeat(count),
+ down: (count = 1) => `${CSI}T`.repeat(count)
+}
+
+const erase = {
+ screen: `${CSI}2J`,
+ up: (count = 1) => `${CSI}1J`.repeat(count),
+ down: (count = 1) => `${CSI}J`.repeat(count),
+ line: `${CSI}2K`,
+ lineEnd: `${CSI}K`,
+ lineStart: `${CSI}1K`,
+ lines(count) {
+ let clear = '';
+ for (let i = 0; i < count; i++)
+ clear += this.line + (i < count - 1 ? cursor.up() : '');
+ if (count)
+ clear += cursor.left;
+ return clear;
+ }
+}
+
+module.exports = { cursor, scroll, erase, beep };
diff --git a/includes/node_modules/sisteransi/src/sisteransi.d.ts b/includes/node_modules/sisteransi/src/sisteransi.d.ts
new file mode 100644
index 0000000..113da2f
--- /dev/null
+++ b/includes/node_modules/sisteransi/src/sisteransi.d.ts
@@ -0,0 +1,35 @@
+export const beep: string;
+export const clear: string;
+
+export namespace cursor {
+ export const left: string;
+ export const hide: string;
+ export const show: string;
+ export const save: string;
+ export const restore: string;
+
+ export function to(x: number, y?: number): string;
+ export function move(x: number, y: number): string;
+ export function up(count?: number): string;
+ export function down(count?: number): string;
+ export function forward(count?: number): string;
+ export function backward(count?: number): string;
+ export function nextLine(count?: number): string;
+ export function prevLine(count?: number): string;
+}
+
+export namespace scroll {
+ export function up(count?: number): string;
+ export function down(count?: number): string;
+}
+
+export namespace erase {
+ export const screen: string;
+ export const line: string;
+ export const lineEnd: string;
+ export const lineStart: string;
+
+ export function up(count?: number): string;
+ export function down(count?: number): string;
+ export function lines(count: number): string;
+}
diff --git a/includes/node_modules/supports-color/browser.js b/includes/node_modules/supports-color/browser.js
new file mode 100644
index 0000000..62afa3a
--- /dev/null
+++ b/includes/node_modules/supports-color/browser.js
@@ -0,0 +1,5 @@
+'use strict';
+module.exports = {
+ stdout: false,
+ stderr: false
+};
diff --git a/includes/node_modules/supports-color/index.js b/includes/node_modules/supports-color/index.js
new file mode 100644
index 0000000..6fada39
--- /dev/null
+++ b/includes/node_modules/supports-color/index.js
@@ -0,0 +1,135 @@
+'use strict';
+const os = require('os');
+const tty = require('tty');
+const hasFlag = require('has-flag');
+
+const {env} = process;
+
+let forceColor;
+if (hasFlag('no-color') ||
+ hasFlag('no-colors') ||
+ hasFlag('color=false') ||
+ hasFlag('color=never')) {
+ forceColor = 0;
+} else if (hasFlag('color') ||
+ hasFlag('colors') ||
+ hasFlag('color=true') ||
+ hasFlag('color=always')) {
+ forceColor = 1;
+}
+
+if ('FORCE_COLOR' in env) {
+ if (env.FORCE_COLOR === 'true') {
+ forceColor = 1;
+ } else if (env.FORCE_COLOR === 'false') {
+ forceColor = 0;
+ } else {
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
+ }
+}
+
+function translateLevel(level) {
+ if (level === 0) {
+ return false;
+ }
+
+ return {
+ level,
+ hasBasic: true,
+ has256: level >= 2,
+ has16m: level >= 3
+ };
+}
+
+function supportsColor(haveStream, streamIsTTY) {
+ if (forceColor === 0) {
+ return 0;
+ }
+
+ if (hasFlag('color=16m') ||
+ hasFlag('color=full') ||
+ hasFlag('color=truecolor')) {
+ return 3;
+ }
+
+ if (hasFlag('color=256')) {
+ return 2;
+ }
+
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
+ return 0;
+ }
+
+ const min = forceColor || 0;
+
+ if (env.TERM === 'dumb') {
+ return min;
+ }
+
+ if (process.platform === 'win32') {
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
+ const osRelease = os.release().split('.');
+ if (
+ Number(osRelease[0]) >= 10 &&
+ Number(osRelease[2]) >= 10586
+ ) {
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
+ }
+
+ return 1;
+ }
+
+ if ('CI' in env) {
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
+ return 1;
+ }
+
+ return min;
+ }
+
+ if ('TEAMCITY_VERSION' in env) {
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
+ }
+
+ if (env.COLORTERM === 'truecolor') {
+ return 3;
+ }
+
+ if ('TERM_PROGRAM' in env) {
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
+
+ switch (env.TERM_PROGRAM) {
+ case 'iTerm.app':
+ return version >= 3 ? 3 : 2;
+ case 'Apple_Terminal':
+ return 2;
+ // No default
+ }
+ }
+
+ if (/-256(color)?$/i.test(env.TERM)) {
+ return 2;
+ }
+
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
+ return 1;
+ }
+
+ if ('COLORTERM' in env) {
+ return 1;
+ }
+
+ return min;
+}
+
+function getSupportLevel(stream) {
+ const level = supportsColor(stream, stream && stream.isTTY);
+ return translateLevel(level);
+}
+
+module.exports = {
+ supportsColor: getSupportLevel,
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
+};
diff --git a/includes/node_modules/supports-color/license b/includes/node_modules/supports-color/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/includes/node_modules/supports-color/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/includes/node_modules/supports-color/package.json b/includes/node_modules/supports-color/package.json
new file mode 100644
index 0000000..f7182ed
--- /dev/null
+++ b/includes/node_modules/supports-color/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "supports-color",
+ "version": "7.2.0",
+ "description": "Detect whether a terminal supports color",
+ "license": "MIT",
+ "repository": "chalk/supports-color",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js",
+ "browser.js"
+ ],
+ "keywords": [
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "ansi",
+ "styles",
+ "tty",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "command-line",
+ "support",
+ "supports",
+ "capability",
+ "detect",
+ "truecolor",
+ "16m"
+ ],
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "devDependencies": {
+ "ava": "^1.4.1",
+ "import-fresh": "^3.0.0",
+ "xo": "^0.24.0"
+ },
+ "browser": "browser.js"
+}
diff --git a/includes/node_modules/supports-color/readme.md b/includes/node_modules/supports-color/readme.md
new file mode 100644
index 0000000..3654228
--- /dev/null
+++ b/includes/node_modules/supports-color/readme.md
@@ -0,0 +1,76 @@
+# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)
+
+> Detect whether a terminal supports color
+
+
+## Install
+
+```
+$ npm install supports-color
+```
+
+
+## Usage
+
+```js
+const supportsColor = require('supports-color');
+
+if (supportsColor.stdout) {
+ console.log('Terminal stdout supports color');
+}
+
+if (supportsColor.stdout.has256) {
+ console.log('Terminal stdout supports 256 colors');
+}
+
+if (supportsColor.stderr.has16m) {
+ console.log('Terminal stderr supports 16 million colors (truecolor)');
+}
+```
+
+
+## API
+
+Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
+
+The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
+
+- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
+- `.level = 2` and `.has256 = true`: 256 color support
+- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
+
+
+## Info
+
+It obeys the `--color` and `--no-color` CLI flags.
+
+For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
+
+Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
+
+
+## Related
+
+- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
+- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
+
+
+## Maintainers
+
+- [Sindre Sorhus](https://github.com/sindresorhus)
+- [Josh Junon](https://github.com/qix-)
+
+
+---
+
+<div align="center">
+ <b>
+ <a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
+ </b>
+ <br>
+ <sub>
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
+ </sub>
+</div>
+
+---
diff --git a/includes/package-lock.json b/includes/package-lock.json
index 3d2e640..95550f7 100644
--- a/includes/package-lock.json
+++ b/includes/package-lock.json
@@ -5,7 +5,79 @@
"packages": {
"": {
"dependencies": {
- "node-watch": "^0.7.4"
+ "chalk": "^4.1.2",
+ "fuse.js": "^7.0.0",
+ "node-watch": "^0.7.4",
+ "prompts": "^2.4.2"
+ }
+ },
+ "node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
+ },
+ "node_modules/fuse.js": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz",
+ "integrity": "sha512-14F4hBIxqKvD4Zz/XjDc3y94mNZN6pRv3U13Udo0lNLCWRBUsrMv2xwcF/y/Z5sV6+FQW+/ow68cHpm4sunt8Q==",
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/kleur": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
+ "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
+ "engines": {
+ "node": ">=6"
}
},
"node_modules/node-watch": {
@@ -15,6 +87,34 @@
"engines": {
"node": ">=6"
}
+ },
+ "node_modules/prompts": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",
+ "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==",
+ "dependencies": {
+ "kleur": "^3.0.3",
+ "sisteransi": "^1.0.5"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/sisteransi": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz",
+ "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="
+ },
+ "node_modules/supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
}
}
}
diff --git a/includes/package.json b/includes/package.json
index d176c9b..3c648ce 100644
--- a/includes/package.json
+++ b/includes/package.json
@@ -1,5 +1,8 @@
{
"dependencies": {
- "node-watch": "^0.7.4"
+ "chalk": "^4.1.2",
+ "fuse.js": "^7.0.0",
+ "node-watch": "^0.7.4",
+ "prompts": "^2.4.2"
}
}
diff --git a/includes/process.js b/includes/process.js
index 0a1798f..88a477b 100644
--- a/includes/process.js
+++ b/includes/process.js
@@ -4,22 +4,44 @@ const path = require('path');
const uuid = require('crypto').randomUUID;
const substitutes = [
- ["illenium", "ILLENIUM"]
+ ["illenium", "ILLENIUM"],
+ ["SueCo", "Sueco"],
+ ["Illenium", "ILLENIUM"],
+ ["Princewhateverer", "PrinceWhateverer"],
+ ["Kennyoung", "kennyoung"],
+ ["4EverfreeBrony", "4everfreebrony"],
+ ["4Everfreebrony", "4everfreebrony"]
];
+if (!fs.existsSync("../assets/content/_")) fs.mkdirSync("../assets/content/_");
+if (!fs.existsSync("../assets/content/songs.json")) fs.writeFileSync("../assets/content/songs.json", "{}");
+if (!fs.existsSync("../assets/content/albums.json")) fs.writeFileSync("../assets/content/albums.json", "{}");
+
const songs = require('../assets/content/songs.json');
const albums = require('../assets/content/albums.json');
function scandir(dir) {
+ let count = 0;
+
+ function updateScandirDisplay() {
+ process.stdout.clearLine(null);
+ process.stdout.cursorTo(0);
+ process.stdout.write("Scanning... " + count);
+ }
+
return new Promise((res, rej) => {
const walk = (dir, done) => {
let results = [];
fs.readdir(dir, function(err, list) {
+ count++;
+ updateScandirDisplay();
if (err) return done(err);
let pending = list.length;
if (!pending) return done(null, results);
list.forEach(function(file) {
+ count++;
+ updateScandirDisplay();
file = path.resolve(dir, file);
fs.stat(file, function(err, stat) {
if (stat && stat.isDirectory()) {
@@ -48,25 +70,77 @@ function scandir(dir) {
function substitute(text) {
for (let sub of substitutes) {
- if (text.trim() === sub[0].trim()) {
- return sub[1].trim();
- }
+ text = text.replaceAll(sub[0], sub[1]);
+ }
+
+ return text;
+}
+
+function timeToString(time) {
+ if (!isNaN(parseInt(time))) {
+ time = new Date(time).getTime();
}
+
+ let periods = ["second", "minute", "hour", "day", "week", "month", "year", "age"];
+
+ let lengths = ["60", "60", "24", "7", "4.35", "12", "100"];
+
+ let now = new Date().getTime();
+
+ let difference = time / 1000;
+ let period;
+
+ let j;
+
+ for (j = 0; difference >= lengths[j] && j < lengths.length - 1; j++) {
+ difference /= lengths[j];
+ }
+
+ difference = Math.round(difference);
+
+ period = periods[j];
+
+ return `${difference} ${period}${difference > 1 ? "s" : ""}`;
}
(async () => {
- for (let file of (await scandir("../assets/content/_")).filter(i => i.endsWith(".flac"))) {
+ let timePerOp = [];
+ let list = (await scandir("../assets/content/_")).filter(i => i.endsWith(".flac"));
+ process.stdout.write(" files found, " + list.length + " to process\n");
+ let index = 0;
+
+ function updateETA() {
+ if (timePerOp.length > 5) {
+ process.stdout.write("(" + timeToString((list.length - index) * (timePerOp.reduce((a, b) => a + b) / timePerOp.length)) + ")");
+ } else {
+ process.stdout.write("");
+ }
+ }
+
+ for (let file of list) {
+ let start = new Date().getTime();
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(file);
+ updateETA();
let id = uuid();
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Gathering metadata...");
+ updateETA();
let metadata = JSON.parse(cp.execFileSync("ffprobe", ["-v", "quiet", "-print_format", "json", "-show_format", "-show_streams", file]).toString());
+ if (!metadata['format']['tags']) continue;
songs[id] = {
- title: substitute(metadata['format']['tags']['TITLE'] ?? path.basename(file, ".flac")),
+ title: substitute(metadata['format']['tags']['TITLE'] ?? metadata['format']['tags']['title'] ?? path.basename(file, ".flac")),
length: parseInt(metadata['format']['duration']),
- album: substitute(metadata['format']['tags']['ALBUM'] ?? "Unknown album"),
- artist: substitute(metadata['format']['tags']['ARTIST'] ?? "Unknown artist"),
- albumArtist: substitute(metadata['format']['tags']['album_artist'] ?? metadata['format']['tags']['ARTIST'] ?? "Unknown artist"),
- date: parseInt(metadata['format']['tags']['DATE']) ?? 0,
+ album: substitute(metadata['format']['tags']['ALBUM'] ?? metadata['format']['tags']['album'] ?? "Unknown album"),
+ artist: (substitute(metadata['format']['tags']['ARTIST'] ?? metadata['format']['tags']['artist'] ?? "Unknown artist")).replaceAll(";", ", ").replaceAll(" & ", ", ").replaceAll("&", ", ").replaceAll(", and ", ", "),
+ albumArtist: (substitute(metadata['format']['tags']['album_artist'] ?? metadata['format']['tags']['ARTIST'] ?? metadata['format']['tags']['artist'] ?? "Unknown artist")).replaceAll(";", ", ").replaceAll("&", ", ").replaceAll(", and ", ", "),
+ date: parseInt(((metadata['format']['tags']['DATE'] ?? metadata['format']['tags']['date']).split("-")[0]).substring(0, 4)) ?? 0,
track: parseInt(metadata['format']['tags']['track']) ?? 0,
+ disc: parseInt(metadata['format']['tags']['disc']) ?? 1,
+ copyright: metadata['format']['tags']['COPYRIGHT'] ?? metadata['format']['tags']['copyright'] ?? "",
size: parseInt(metadata['format']['size']),
bitRate: parseInt(metadata['format']['bit_rate']),
bitDepth: parseInt(metadata['streams'][0]['bits_per_raw_sample']),
@@ -75,37 +149,163 @@ function substitute(text) {
channels: parseInt(metadata['streams'][0]['channels']),
}
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Writing songs list...");
+ updateETA();
fs.writeFileSync("../assets/content/songs.json", JSON.stringify(songs));
- cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-b:a", "256k", "../assets/content/" + id + ".m4a"]);
- cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "../assets/content/" + id + ".flac"]);
- cp.execFileSync("ffmpeg", ["-i", file, "-an", "../assets/content/" + id + ".jpg"]);
+
+ if (fs.existsSync("/opt/mist")) {
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Encoding AAC version...");
+ updateETA();
+ cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-b:a", "256k", "/opt/mist/aac/" + id + ".m4a"], { stdio: "ignore" });
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Encoding FLAC version...");
+ updateETA();
+ cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-c:a", "copy", "/opt/mist/flac/" + id + ".flac"], { stdio: "ignore" });
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Extracting album art...");
+ updateETA();
+ cp.execFileSync("ffmpeg", ["-i", file, "-an", "/opt/mist/jpeg/" + id + ".jpg"], { stdio: "ignore" });
+ } else {
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Encoding AAC version...");
+ updateETA();
+ cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-b:a", "256k", "../assets/content/" + id + ".m4a"], { stdio: "ignore" });
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Encoding FLAC version...");
+ updateETA();
+ cp.execFileSync("ffmpeg", ["-i", file, "-map", "0", "-map", "-0:v?", "-c:a", "copy", "../assets/content/" + id + ".flac"], { stdio: "ignore" });
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Extracting album art...");
+ updateETA();
+ cp.execFileSync("ffmpeg", ["-i", file, "-an", "../assets/content/" + id + ".jpg"], { stdio: "ignore" });
+ }
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Removing original file...");
+ updateETA();
fs.unlinkSync(file);
+
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log(" Done: " + id);
+ updateETA();
+
+ timePerOp.push(new Date().getTime() - start);
+ index++;
}
+ process.stdout.clearLine(null); process.stdout.cursorTo(0);
+ console.log("Collecting albums...");
+
for (let song of Object.keys(songs)) {
if (Object.values(albums).filter(i => i.title === songs[song].album).length > 0) {
Object.values(albums).filter(i => i.title === songs[song].album)[0].tracks.push(song);
Object.values(albums).filter(i => i.title === songs[song].album)[0].hiRes = Object.values(albums).filter(i => i.title === songs[song].album)[0].hiRes || songs[song].hiRes;
} else {
let albumID = uuid();
- fs.copyFileSync("../assets/content/" + song + ".jpg", "../assets/content/" + albumID + ".jpg")
+
+ if (fs.existsSync("/opt/mist")) {
+ fs.copyFileSync("/opt/mist/jpeg/" + song + ".jpg", "/opt/mist/jpeg/" + albumID + ".jpg")
+ } else {
+ fs.copyFileSync("../assets/content/" + song + ".jpg", "../assets/content/" + albumID + ".jpg")
+ }
albums[albumID] = {
title: songs[song].album,
artist: songs[song].albumArtist,
date: songs[song].date,
hiRes: songs[song].hiRes,
+ copyright: songs[song].copyright,
tracks: [song]
}
}
}
+ console.log("Cleaning up...");
+
+ for (let songID of Object.keys(songs)) {
+ if (fs.existsSync("/opt/mist")) {
+ if (!fs.existsSync("/opt/mist/flac/" + songID + ".flac") || !fs.existsSync("/opt/mist/aac/" + songID + ".m4a") || !fs.existsSync("/opt/mist/jpeg/" + songID + ".jpg")) {
+ delete songs[songID];
+ }
+ } else {
+ if (!fs.existsSync("../assets/content/" + songID + ".flac") || !fs.existsSync("../assets/content/" + songID + ".m4a") || !fs.existsSync("../assets/content/" + songID + ".jpg")) {
+ delete songs[songID];
+ }
+ }
+ }
+
+ let idList = [...Object.keys(songs), ...Object.keys(albums)];
+
+ if (fs.existsSync("/opt/mist")) {
+ for (let file of fs.readdirSync("/opt/mist/flac")) {
+ if (fs.lstatSync("/opt/mist/flac/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("/opt/mist/flac/" + file);
+ if (fs.existsSync("../assets/content/" + file)) fs.unlinkSync("../assets/content/" + file);
+ } else {
+ if (!fs.existsSync("../assets/content/" + file)) fs.symlinkSync("/opt/mist/flac/" + file, "../assets/content/" + file);
+ }
+ }
+ }
+
+ for (let file of fs.readdirSync("/opt/mist/aac")) {
+ if (fs.lstatSync("/opt/mist/aac/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("/opt/mist/aac/" + file);
+ if (fs.existsSync("../assets/content/" + file)) fs.unlinkSync("../assets/content/" + file);
+ } else {
+ if (!fs.existsSync("../assets/content/" + file)) fs.symlinkSync("/opt/mist/aac/" + file, "../assets/content/" + file);
+ }
+ }
+ }
+
+ for (let file of fs.readdirSync("/opt/mist/jpeg")) {
+ if (fs.lstatSync("/opt/mist/jpeg/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("/opt/mist/jpeg/" + file);
+ if (fs.existsSync("../assets/content/" + file)) fs.unlinkSync("../assets/content/" + file);
+ } else {
+ if (!fs.existsSync("../assets/content/" + file)) fs.symlinkSync("/opt/mist/jpeg/" + file, "../assets/content/" + file);
+ }
+ }
+ }
+ } else {
+ for (let file of fs.readdirSync("../assets/content")) {
+ if (fs.lstatSync("../assets/content/" + file).isFile()) {
+ let id = path.basename(file, path.extname(file));
+
+ if (!idList.includes(id) && !file.endsWith(".json")) {
+ fs.unlinkSync("../assets/content/" + file);
+ }
+ }
+ }
+ }
+
+ console.log("Adding tracks to albums...");
+
for (let albumID of Object.keys(albums)) {
let album = albums[albumID];
- album["tracks"] = album["tracks"].sort((a, b) => {
+ album["tracks"] = [...new Set(album["tracks"])].filter(i => songs[i]).sort((a, b) => {
return songs[a]['track'] - songs[b]['track'];
});
}
+ console.log("Writing metadata...");
+
+ fs.writeFileSync("../assets/content/songs.json", JSON.stringify(songs));
fs.writeFileSync("../assets/content/albums.json", JSON.stringify(albums));
+
+ console.log("Done!");
})() \ No newline at end of file
diff --git a/includes/reset.js b/includes/reset.js
new file mode 100644
index 0000000..ef395d1
--- /dev/null
+++ b/includes/reset.js
@@ -0,0 +1,12 @@
+console.log("Don't use this script.");
+return;
+
+const fs = require('fs');
+fs.rmSync('../assets/content', { recursive: true });
+fs.rmSync('./users', { recursive: true });
+fs.symlinkSync('/pool', '../assets/content');
+//fs.mkdirSync('./users');
+fs.mkdirSync('../assets/content');
+fs.mkdirSync('../assets/content/_');
+fs.writeFileSync('../assets/content/songs.json', '{}');
+fs.writeFileSync('../assets/content/albums.json', '{}');
diff --git a/includes/session.php b/includes/session.php
index 8427fc2..36c5216 100644
--- a/includes/session.php
+++ b/includes/session.php
@@ -28,11 +28,18 @@ global $albums; global $songs;
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/users")) mkdir($_SERVER['DOCUMENT_ROOT'] . "/includes/users");
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-favorites.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-favorites.json", "[]");
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-library.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-library.json", "[]");
+if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-history.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-history.json", "[]");
$albums = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/content/albums.json"), true);
$songs = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/assets/content/songs.json"), true);
$favorites = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-favorites.json"), true);
$library = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-library.json"), true);
+$history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $_PROFILE["id"] . "-history.json"), true);
+
+$albums = array_map(function ($i) {
+ $i["artist"] = str_replace(";", ", ", $i["artist"]);
+ return $i;
+}, $albums);
function displayList($list, $hasAlbum = false) { global $albums; global $favorites; ?>
<div class="list-group" style="margin-left: 10px; margin-top: 20px;" id="main-list">
@@ -42,26 +49,90 @@ function displayList($list, $hasAlbum = false) { global $albums; global $favorit
<?php if (!$hasAlbum): ?>
<div style="display: grid; grid-template-columns: 48px 1fr; grid-gap: 10px;">
<img src="/assets/content/<?= $id ?>.jpg" style="width: 48px; height: 48px;">
- <?php endif; ?>
- <div style="height: 3em; display: flex; align-items: center; justify-content: left;">
+ <?php endif; ?>
+ <div style="width: <?php if (!$hasAlbum): ?>50<?php else: ?>55<?php endif; ?>vw; height: 3em; display: flex; align-items: center; justify-content: left;">
<?php if ($hasAlbum && $song["artist"] === $albums[$_GET["a"]]["artist"]): ?>
- <div><?= $song["title"] ?></div>
+ <div style="max-width: 100%;"><div style="max-width: 100%; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;"><?= $song["title"] ?></div></div>
<?php else: ?>
- <div><?= $song["title"] ?><br><span style="opacity: .5;"><?= $song["artist"] ?></span></div>
+ <div style="max-width: 100%;"><div style="max-width: 100%; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis;"><?= $song["title"] ?></div><div style="max-width: 100%; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis; opacity: .5;"><?= $song["artist"] ?></div></div>
<?php endif; ?>
</div>
- <?php if (!$hasAlbum): ?>
+ <?php if (!$hasAlbum): ?>
</div>
<?php endif; ?>
<div class="list-actions">
- <span onclick="<?= in_array($id, $favorites) ? "un" : "" ?>favoriteSong('<?= $id ?>');" class="player-btn" style="border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; height: 48px; width: 48px;" id="btn-favorite-<?= $id ?>">
+ <!--<span onclick="<?= in_array($id, $favorites) ? "un" : "" ?>favoriteSong('<?= $id ?>');" class="player-btn" style="border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; height: 48px; width: 48px;" id="btn-favorite-<?= $id ?>">
<img class="icon" alt="" src="/assets/icons/favorite-<?= in_array($id, $favorites) ? "on" : "off" ?>.svg" style="pointer-events: none; width: 32px; height: 32px;" id="btn-favorite-<?= $id ?>-icon">
- </span>
+ </span>-->
<span onclick="window.parent.playSong('<?= $id ?>'<?php if ($hasAlbum): ?>, 'album:<?= $_GET["a"] ?>'<?php endif; ?>);" class="player-btn" style="border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; height: 48px; width: 48px;" id="btn-play-<?= $id ?>">
<img class="icon" alt="" src="/assets/icons/play.svg" style="pointer-events: none; width: 32px; height: 32px;" id="btn-play-<?= $id ?>-icon">
</span>
+ <span class="dropdown">
+ <span class="player-btn" style="border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; height: 48px; width: 48px;" id="btn-menu-<?= $id ?>" data-bs-toggle="dropdown">
+ <img class="icon" alt="" src="/assets/icons/menu.svg" style="pointer-events: none; width: 32px; height: 32px;" id="btn-menu-<?= $id ?>-icon">
+ </span>
+ <ul class="dropdown-menu">
+ <li><a onclick="playNext('<?= $id ?>');" class="dropdown-item" href="#"><img alt="" src="/assets/icons/playnext.svg" style="pointer-events: none; width: 24px; height: 24px; margin-right: 5px;">Play next</a></li>
+ <li><a onclick="enqueue('<?= $id ?>');" class="dropdown-item" href="#"><img alt="" src="/assets/icons/add.svg" style="pointer-events: none; width: 24px; height: 24px; margin-right: 5px;">Add to queue</a></li>
+ <li><hr class="dropdown-divider"></hr></li>
+ <li><a id="btn-favorite-<?= $id ?>" onclick="<?= in_array($id, $favorites) ? "un" : "" ?>favoriteSong('<?= $id ?>');" class="dropdown-item" href="#"><img id="btn-favorite-<?= $id ?>-icon" alt="" src="/assets/icons/favorite-<?= in_array($id, $favorites) ? "on" : "off" ?>.svg" style="pointer-events: none; width: 24px; height: 24px; margin-right: 5px;"><span id="btn-favorite-<?= $id ?>-text"><?= in_array($id, $favorites) ? "Remove from favorites" : "Add to favorites" ?></span></a></li>
+ <li><a onclick="downloadSong('<?= $id ?>');" class="dropdown-item" href="#"><img alt="" src="/assets/icons/download.svg" style="pointer-events: none; width: 24px; height: 24px; margin-right: 5px;">Download</a></li>
+ <li><a onclick="getInfo('<?= $id ?>');" class="dropdown-item" href="#"><img alt="" src="/assets/icons/info.svg" style="pointer-events: none; width: 24px; height: 24px; margin-right: 5px;">Get info</a></li>
+ </ul>
+ </span>
</div>
</div>
<?php endforeach; ?>
</div>
+ <script>
+ async function favoriteSong(id) {
+ document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-on.svg";
+ document.getElementById("btn-favorite-" + id + "-text").innerText = "Remove from favorites";
+ document.getElementById("btn-favorite-" + id).onclick = () => {
+ unfavoriteSong(id);
+ }
+ await fetch("/api/addFavorite.php?i=" + id);
+
+ window.parent.redownloadFavorites();
+ }
+
+ function playNext(id) {
+ if (window.parent.playlist.length === 0) {
+ window.parent.playSong(id);
+ } else {
+ window.parent.playlist.splice(window.parent.currentPlaylistPosition, 0, id);
+ }
+ }
+
+ function downloadSong(id) {
+ window.parent.openModal("Download song", "download.php?i=" + id);
+ }
+
+ function getInfo(id) {
+ window.parent.openModal((window.parent.songs[id]?.artist ?? "Unknown artist") + " - " + (window.parent.songs[id]?.title ?? "Unknown song"), "info.php?i=" + id);
+ }
+
+ function enqueue(id) {
+ if (window.parent.playlist.length === 0) {
+ window.parent.playSong(id);
+ } else {
+ window.parent.playlist.push(id);
+ }
+ }
+
+ async function unfavoriteSong(id) {
+ document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-off.svg";
+ document.getElementById("btn-favorite-" + id + "-text").innerText = "Add to favorites";
+ document.getElementById("btn-favorite-" + id).onclick = () => {
+ favoriteSong(id);
+ }
+ await fetch("/api/removeFavorite.php?i=" + id);
+
+ <?php if (isset($favoritesList)): ?>
+ location.reload();
+ <?php endif; ?>
+
+ window.parent.redownloadFavorites();
+ }
+ </script>
<?php } \ No newline at end of file
diff --git a/version b/version
index b8deab8..d3475ef 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-0.1.0|Public Beta \ No newline at end of file
+0.2.0|Public Beta \ No newline at end of file