{"version":3,"file":"bundle.js","sources":["../../src/js/modules/socket.js","../../src/js/modules/toasts.js","../../src/js/modules/downloads.js","../../src/js/modules/quality-modal.js","../../src/js/modules/components/artist-tab.js","../../src/js/modules/track-preview.js","../../src/js/modules/components/tracklist-tab.js","../../src/js/modules/utils.js","../../src/js/modules/components/link-analyzer-tab.js","../../src/js/modules/components/home-tab.js","../../src/js/modules/components/charts-tab.js","../../src/js/modules/components/favorites-tab.js","../../src/js/modules/components/settings-tab.js","../../src/js/modules/components/main-search.js","../../src/js/modules/tabs.js","../../src/js/modules/search.js","../../src/js/app.js"],"sourcesContent":["export const socket = io.connect(window.location.href)\r\n\r\nsocket.on('connect', () => {\r\n\tdocument.getElementById('loading_overlay').classList.remove('active')\r\n})\r\n","import { socket } from './socket.js'\r\n\r\nlet toastsWithId = {}\r\n\r\nexport const toast = function (msg, icon = null, dismiss = true, id = null) {\r\n\tif (toastsWithId[id]) {\r\n\t\tlet toastObj = toastsWithId[id]\r\n\t\tlet toastDOM = $(`div.toastify[toast_id=${id}]`)\r\n\t\tif (msg) {\r\n\t\t\ttoastDOM.find('.toast-message').html(msg)\r\n\t\t}\r\n\t\tif (icon) {\r\n\t\t\tif (icon == 'loading') icon = `
`\r\n\t\t\telse icon = `${icon}`\r\n\t\t\ttoastDOM.find('.toast-icon').html(icon)\r\n\t\t}\r\n\t\tif (dismiss !== null && dismiss) {\r\n\t\t\tsetTimeout(function () {\r\n\t\t\t\ttoastObj.hideToast()\r\n\t\t\t\tdelete toastsWithId[id]\r\n\t\t\t}, 3000)\r\n\t\t}\r\n\t} else {\r\n\t\tif (icon == null) icon = ''\r\n\t\telse if (icon == 'loading') icon = ``\r\n\t\telse icon = `${icon}`\r\n\t\tlet toastObj = Toastify({\r\n\t\t\ttext: `${icon}${msg}`,\r\n\t\t\tduration: dismiss ? 3000 : 0,\r\n\t\t\tgravity: 'bottom',\r\n\t\t\tposition: 'left'\r\n\t\t}).showToast()\r\n\t\tif (id) {\r\n\t\t\ttoastsWithId[id] = toastObj\r\n\t\t\t$(toastObj.toastElement).attr('toast_id', id)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nsocket.on('toast', data => {\r\n\ttoast(data.msg, data.icon || null, data.dismiss !== undefined ? data.dismiss : true, data.id || null)\r\n})\r\n","import { socket } from './socket.js'\r\nimport { toast } from './toasts.js'\r\n\r\n/* ===== Locals ===== */\r\nconst tabMinWidth = 250\r\nconst tabMaxWidth = 500\r\n\r\nlet cachedTabWidth = parseInt(localStorage.getItem('downloadTabWidth')) || 300\r\nlet queueList = {}\r\nlet queue = []\r\nlet queueComplete = []\r\nlet tabContainerEl\r\nlet listEl\r\nlet dragHandlerEl\r\n\r\nfunction init() {\r\n\t// Find download DOM elements\r\n\ttabContainerEl = document.getElementById('download_tab_container')\r\n\tlistEl = document.getElementById('download_list')\r\n\tdragHandlerEl = document.getElementById('download_tab_drag_handler')\r\n\r\n\t// Check if download tab should be open\r\n\tif ('true' === localStorage.getItem('downloadTabOpen')) {\r\n\t\ttabContainerEl.classList.remove('tab_hidden')\r\n\r\n\t\tsetTabWidth(cachedTabWidth)\r\n\t}\r\n\r\n\tlinkListeners()\r\n}\r\n\r\nfunction linkListeners() {\r\n\tlistEl.addEventListener('click', handleListClick)\r\n\tdocument.getElementById('toggle_download_tab').addEventListener('click', toggleDownloadTab)\r\n\r\n\t// Queue buttons\r\n\tdocument.getElementById('clean_queue').addEventListener('click', () => {\r\n\t\tsocket.emit('removeFinishedDownloads')\r\n\t})\r\n\r\n\tdocument.getElementById('cancel_queue').addEventListener('click', () => {\r\n\t\tsocket.emit('cancelAllDownloads')\r\n\t})\r\n\r\n\tdragHandlerEl.addEventListener('mousedown', event => {\r\n\t\tevent.preventDefault()\r\n\r\n\t\tdocument.addEventListener('mousemove', handleDrag)\r\n\t})\r\n\r\n\tdocument.addEventListener('mouseup', () => {\r\n\t\tdocument.removeEventListener('mousemove', handleDrag)\r\n\t})\r\n\r\n\ttabContainerEl.addEventListener('transitionend', () => {\r\n\t\ttabContainerEl.style.transition = ''\r\n\t})\r\n\r\n\twindow.addEventListener('beforeunload', () => {\r\n\t\tlocalStorage.setItem('downloadTabWidth', cachedTabWidth)\r\n\t})\r\n}\r\n\r\nfunction setTabWidth(newWidth) {\r\n\tif (undefined === newWidth) {\r\n\t\ttabContainerEl.style.width = ''\r\n\t\tlistEl.style.width = ''\r\n\t} else {\r\n\t\ttabContainerEl.style.width = newWidth + 'px'\r\n\t\tlistEl.style.width = newWidth + 'px'\r\n\t}\r\n}\r\n\r\nfunction handleDrag(event) {\r\n\tlet newWidth = window.innerWidth - event.pageX + 2\r\n\r\n\tif (newWidth < tabMinWidth) {\r\n\t\tnewWidth = tabMinWidth\r\n\t} else if (newWidth > tabMaxWidth) {\r\n\t\tnewWidth = tabMaxWidth\r\n\t}\r\n\r\n\tcachedTabWidth = newWidth\r\n\r\n\tsetTabWidth(newWidth)\r\n}\r\n\r\nfunction sendAddToQueue(url, bitrate = null) {\r\n\tif (url.indexOf(';') !== -1) {\r\n\t\tlet urls = url.split(';')\r\n\t\turls.forEach(url => {\r\n\t\t\tsocket.emit('addToQueue', { url: url, bitrate: bitrate })\r\n\t\t})\r\n\t} else if (url != '') {\r\n\t\tsocket.emit('addToQueue', { url: url, bitrate: bitrate })\r\n\t}\r\n}\r\n\r\nfunction addToQueue(queueItem, current = false) {\r\n\tqueueList[queueItem.uuid] = queueItem\r\n\tif (queueItem.downloaded + queueItem.failed == queueItem.size) {\r\n\t\tqueueComplete.push(queueItem.uuid)\r\n\t} else {\r\n\t\tqueue.push(queueItem.uuid)\r\n\t}\r\n\t$(listEl).append(\r\n\t\t`