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NC,GAAA,EAGJH,GAAA,KACHI,GAAA,CACAH,GAAA,KAAK,CAAC,CAAE,mBAAAI,KAAyBA,EAAmBD,EAAIT,CAAO,CAAC,CACtE,EACSW,GAAA,CACJ,GAAAA,EAAM,SAAW,IACb,gBAAS,OAAO/E,EAAU,MAC3B,CACNoE,EAAQ,KAAK,EACb,MAAMY,EAAQD,EAAM,OACdE,EAAK,SAAS,cAAc,IAAI,EACtCA,EAAG,UAAY,mCACT,MAAAzJ,EAAI,SAAS,cAAc,GAAG,EACpCA,EAAE,UAAY,yBACR,MAAA0J,EAAQ,SAAS,cAAc,OAAO,EACtCA,EAAA,UAAY,cAAcF,CAAK,GAC/B,MAAAG,EAAU/F,EAAe,SAAS,EACxCgG,GAAaD,CAAO,EACZA,EAAA,OAAOD,EAAOD,EAAIzJ,CAAC,EAC5B,CAEF,CACD,CAAC","names":["SingleEventTarget","callback","stack","i","l","event","Deque","capacity","getCapacity","isArray","len","ret","front","j","item","argsLength","length","index","size","oldCapacity","moveItemsCount","arrayMove","src","srcIndex","dst","dstIndex","pow2AtLeast","n","deque","EventAttributes","HTMLAttributes","StyleAttributes","SVGAttributes","HelperTypes","classnames_1","classListFromObject","record","key","value","isTruthy","v","isUnique","a","emptyArray","classnamesToArray","classnames","list","__createBinding","this","o","m","k","k2","desc","__exportStar","exports","p","require$$0","require$$1","require$$2","require$$3","require$$4","require$$5","setAttributes_1","tsx_dom_types_1","transferKnownProperties","source","target","eventAttributeName","setAttributes","element","attrs","name","finalValue","finalName","useCapture","eventName","utils","applyChild","child","applyChildren","children","createDomElement","tag","options","applyTsxTag","finalTag","finalAttrs","createElement_1","utils_1","createElement","createRef","jsxRuntime","jsx","props","defineCustomElement_1","jsx_runtime_1","defineCustomElement","constructor","types","sortPlaylistsPriority","lists","kindToIndex","kind","b","kindA","kindB","diff","makeAlertBubble","type","message","duration","AlertBuilder","alertBubble","showAlert","alert","getElementById","spinningAlert","xhr","text","translateError","done","failure","alertElement","makeAlertBubbleFromXhrError","e","makeErrorText","alertBubbleFromXhrError","LOGIN_PAGE","wrapRequestFailure","wrapRequest","request","queueSong","button","requests","always","queueTranslateError","onQueueButtonClick","sources","promises","description","SingleTimeout","f","ms","time","createFasIcon","icon","_RecencyCalc","state","resourceId","playerSong","delta","RecencyCalc","recencyToClass","createQueueButton","recency","makeSource","timeout","reset","_a","queueFinished","_b","recencyCls","cl","Link","url","h","createTextLink","updateUrlAfterResourceChange","resource","urlFromFfmpegResource","secondsFromMicroSeconds","secondsToDuration","urlFromSpotifyResource","urlFromResource","priority","urlFromUnregisteredResource","createAlsoInHoverText","containingLists","hoverText","playlist","toPrioritySortedLists","playlists","lookup","filterMap","id","makeListResourceSource","sub","ResourcePlayResource","makeUrlResourceSource","UrlResourceSource","createWebsocketBaseUrl","wsShouldReconnect","RECONNECT_DELAYS_MS","ReconnectDelay","Updater","updater","json","delay","call","socket","meRequest","Main","printWelcomeMessage","setUpFavicons","me","onDOMContentLoaded","jqXHR","error","h2","small","loading","emptyElement"],"ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],"sources":["../../src/app/single-event-target.ts","../../node_modules/double-ended-queue/js/deque.js","../../node_modules/tsx-dom-types/dist/EventAttributes.js","../../node_modules/tsx-dom-types/dist/HTMLAttributes.js","../../node_modules/tsx-dom-types/dist/StyleAttributes.js","../../node_modules/tsx-dom-types/dist/SVGAttributes.js","../../node_modules/tsx-dom-types/dist/HelperTypes.js","../../node_modules/tsx-dom-types/dist/classnames.js","../../node_modules/tsx-dom-types/dist/index.js","../../node_modules/tsx-dom/dist/setAttributes.js","../../node_modules/tsx-dom/dist/utils.js","../../node_modules/tsx-dom/dist/createElement.js","../../node_modules/tsx-dom/dist/jsx-runtime.js","../../node_modules/tsx-dom/dist/defineCustomElement.js","../../node_modules/tsx-dom/dist/types.js","../../node_modules/tsx-dom/dist/index.js","../../src/app/main/functions.tsx","../../src/app/main/updater.ts","../../src/app/main/index.ts"],"sourcesContent":["export class SingleEventTarget {\n\tprivate readonly listeners: ((e: T) => void)[];\n\n\tconstructor() {\n\t\tthis.listeners = [];\n\t}\n\n\taddEventListener(callback: (e: T) => void): void {\n\t\tthis.listeners.push(callback);\n\t}\n\n\tremoveEventListener(callback: (e: T) => void): void {\n\t\tconst stack = this.listeners;\n\t\tfor (let i = 0, l = stack.length; i < l; i++) {\n\t\t\tif (stack[i] === callback) {\n\t\t\t\tstack.splice(i, 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tdispatchEvent(event: T): void {\n\t\t// Create a copy of the listeners array.\n\t\tconst stack = this.listeners.slice();\n\n\t\t// Send event to all listeners.\n\t\tfor (let i = 0, l = stack.length; i < l; i++) {\n\t\t\tstack[i](event);\n\t\t}\n\t}\n}\n","/**\n * Copyright (c) 2013 Petka Antonov\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:

\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\"use strict\";\nfunction Deque(capacity) {\n this._capacity = getCapacity(capacity);\n this._length = 0;\n this._front = 0;\n if (isArray(capacity)) {\n var len = capacity.length;\n for (var i = 0; i < len; ++i) {\n this[i] = capacity[i];\n }\n this._length = len;\n }\n}\n\nDeque.prototype.toArray = function Deque$toArray() {\n var len = this._length;\n var ret = new Array(len);\n var front = this._front;\n var capacity = this._capacity;\n for (var j = 0; j < len; ++j) {\n ret[j] = this[(front + j) & (capacity - 1)];\n }\n return ret;\n};\n\nDeque.prototype.push = function Deque$push(item) {\n var argsLength = arguments.length;\n var length = this._length;\n if (argsLength > 1) {\n var capacity = this._capacity;\n if (length + argsLength > capacity) {\n for (var i = 0; i < argsLength; ++i) {\n this._checkCapacity(length + 1);\n var j = (this._front + length) & (this._capacity - 1);\n this[j] = arguments[i];\n length++;\n this._length = length;\n }\n return length;\n }\n else {\n var j = this._front;\n for (var i = 0; i < argsLength; ++i) {\n this[(j + length) & (capacity - 1)] = arguments[i];\n j++;\n }\n this._length = length + argsLength;\n return length + argsLength;\n }\n\n }\n\n if (argsLength === 0) return length;\n\n this._checkCapacity(length + 1);\n var i = (this._front + length) & (this._capacity - 1);\n this[i] = item;\n this._length = length + 1;\n return length + 1;\n};\n\nDeque.prototype.pop = function Deque$pop() {\n var length = this._length;\n if (length === 0) {\n return void 0;\n }\n var i = (this._front + length - 1) & (this._capacity - 1);\n var ret = this[i];\n this[i] = void 0;\n this._length = length - 1;\n return ret;\n};\n\nDeque.prototype.shift = function Deque$shift() {\n var length = this._length;\n if (length === 0) {\n return void 0;\n }\n var front = this._front;\n var ret = this[front];\n this[front] = void 0;\n this._front = (front + 1) & (this._capacity - 1);\n this._length = length - 1;\n return ret;\n};\n\nDeque.prototype.unshift = function Deque$unshift(item) {\n var length = this._length;\n var argsLength = arguments.length;\n\n\n if (argsLength > 1) {\n var capacity = this._capacity;\n if (length + argsLength > capacity) {\n for (var i = argsLength - 1; i >= 0; i--) {\n this._checkCapacity(length + 1);\n var capacity = this._capacity;\n var j = (((( this._front - 1 ) &\n ( capacity - 1) ) ^ capacity ) - capacity );\n this[j] = arguments[i];\n length++;\n this._length = length;\n this._front = j;\n }\n return length;\n }\n else {\n var front = this._front;\n for (var i = argsLength - 1; i >= 0; i--) {\n var j = (((( front - 1 ) &\n ( capacity - 1) ) ^ capacity ) - capacity );\n this[j] = arguments[i];\n front = j;\n }\n this._front = front;\n this._length = length + argsLength;\n return length + argsLength;\n }\n }\n\n if (argsLength === 0) return length;\n\n this._checkCapacity(length + 1);\n var capacity = this._capacity;\n var i = (((( this._front - 1 ) &\n ( capacity - 1) ) ^ capacity ) - capacity );\n this[i] = item;\n this._length = length + 1;\n this._front = i;\n return length + 1;\n};\n\nDeque.prototype.peekBack = function Deque$peekBack() {\n var length = this._length;\n if (length === 0) {\n return void 0;\n }\n var index = (this._front + length - 1) & (this._capacity - 1);\n return this[index];\n};\n\nDeque.prototype.peekFront = function Deque$peekFront() {\n if (this._length === 0) {\n return void 0;\n }\n return this[this._front];\n};\n\nDeque.prototype.get = function Deque$get(index) {\n var i = index;\n if ((i !== (i | 0))) {\n return void 0;\n }\n var len = this._length;\n if (i < 0) {\n i = i + len;\n }\n if (i < 0 || i >= len) {\n return void 0;\n }\n return this[(this._front + i) & (this._capacity - 1)];\n};\n\nDeque.prototype.isEmpty = function Deque$isEmpty() {\n return this._length === 0;\n};\n\nDeque.prototype.clear = function Deque$clear() {\n var len = this._length;\n var front = this._front;\n var capacity = this._capacity;\n for (var j = 0; j < len; ++j) {\n this[(front + j) & (capacity - 1)] = void 0;\n }\n this._length = 0;\n this._front = 0;\n};\n\nDeque.prototype.toString = function Deque$toString() {\n return this.toArray().toString();\n};\n\nDeque.prototype.valueOf = Deque.prototype.toString;\nDeque.prototype.removeFront = Deque.prototype.shift;\nDeque.prototype.removeBack = Deque.prototype.pop;\nDeque.prototype.insertFront = Deque.prototype.unshift;\nDeque.prototype.insertBack = Deque.prototype.push;\nDeque.prototype.enqueue = Deque.prototype.push;\nDeque.prototype.dequeue = Deque.prototype.shift;\nDeque.prototype.toJSON = Deque.prototype.toArray;\n\nObject.defineProperty(Deque.prototype, \"length\", {\n get: function() {\n return this._length;\n },\n set: function() {\n throw new RangeError(\"\");\n }\n});\n\nDeque.prototype._checkCapacity = function Deque$_checkCapacity(size) {\n if (this._capacity < size) {\n this._resizeTo(getCapacity(this._capacity * 1.5 + 16));\n }\n};\n\nDeque.prototype._resizeTo = function Deque$_resizeTo(capacity) {\n var oldCapacity = this._capacity;\n this._capacity = capacity;\n var front = this._front;\n var length = this._length;\n if (front + length > oldCapacity) {\n var moveItemsCount = (front + length) & (oldCapacity - 1);\n arrayMove(this, 0, this, oldCapacity, moveItemsCount);\n }\n};\n\n\nvar isArray = Array.isArray;\n\nfunction arrayMove(src, srcIndex, dst, dstIndex, len) {\n for (var j = 0; j < len; ++j) {\n dst[j + dstIndex] = src[j + srcIndex];\n src[j + srcIndex] = void 0;\n }\n}\n\nfunction pow2AtLeast(n) {\n n = n >>> 0;\n n = n - 1;\n n = n | (n >> 1);\n n = n | (n >> 2);\n n = n | (n >> 4);\n n = n | (n >> 8);\n n = n | (n >> 16);\n return n + 1;\n}\n\nfunction getCapacity(capacity) {\n if (typeof capacity !== \"number\") {\n if (isArray(capacity)) {\n capacity = capacity.length;\n }\n else {\n return 16;\n }\n }\n return pow2AtLeast(\n Math.min(\n Math.max(16, capacity), 1073741824)\n );\n}\n\nmodule.exports = Deque;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.classnames = void 0;\nconst classListFromObject = (record) => Object.entries(record).map(([key, value]) => value && key);\nconst isTruthy = (v) => !!v;\nconst isUnique = (v, i, a) => a.indexOf(v) === i;\nconst emptyArray = [];\nfunction classnamesToArray(value) {\n if (!value)\n return emptyArray;\n if (typeof value === \"string\")\n return [value];\n if (Array.isArray(value))\n return value.flatMap(classnamesToArray).filter(isTruthy);\n return classListFromObject(value).filter(isTruthy);\n}\nfunction classnames(value) {\n const list = classnamesToArray(value).filter(isUnique);\n return list.length > 0 ? list.join(\" \") : undefined;\n}\nexports.classnames = classnames;\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__exportStar(require(\"./EventAttributes\"), exports);\n__exportStar(require(\"./HTMLAttributes\"), exports);\n__exportStar(require(\"./StyleAttributes\"), exports);\n__exportStar(require(\"./SVGAttributes\"), exports);\n__exportStar(require(\"./HelperTypes\"), exports);\n__exportStar(require(\"./classnames\"), exports);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.setAttributes = void 0;\nconst tsx_dom_types_1 = require(\"tsx-dom-types\");\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction transferKnownProperties(source, target) {\n for (const key of Object.keys(source)) {\n if (key in target)\n target[key] = source[key];\n }\n}\n/** \"on\" followed by an uppercase character. Not sure if there are any events with anything other than A-Z. Checking unicode just to be safe */\nconst eventAttributeName = /^on\\p{Lu}/u;\nfunction setAttributes(element, attrs) {\n for (const name of Object.keys(attrs)) {\n // Ignore some debug props that might be added by bundlers\n if (name === \"__source\" || name === \"__self\" || name === \"tsxTag\")\n continue;\n const value = attrs[name];\n if (name === \"class\") {\n const finalValue = (0, tsx_dom_types_1.classnames)(value);\n if (finalValue)\n element.setAttribute(name, finalValue);\n }\n else if (name === \"ref\") {\n value.current = element;\n }\n else if (eventAttributeName.test(name)) {\n const finalName = name.replace(/Capture$/, \"\");\n const useCapture = name !== finalName;\n const eventName = finalName.toLowerCase().substring(2);\n element.addEventListener(eventName, value, useCapture);\n }\n else if (name === \"style\" && typeof value !== \"string\") {\n // Special handler for style with a value of type CSSStyleDeclaration\n transferKnownProperties(value, element.style);\n }\n else if (name === \"dangerouslySetInnerHTML\")\n element.innerHTML = value;\n else if (value === true)\n element.setAttribute(name, name);\n else if (value || value === 0)\n element.setAttribute(name, value.toString());\n }\n}\nexports.setAttributes = setAttributes;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.applyTsxTag = exports.createDomElement = exports.applyChildren = void 0;\nfunction applyChild(element, child) {\n if (child instanceof Element)\n element.appendChild(child);\n else if (typeof child === \"string\" || typeof child === \"number\")\n element.appendChild(document.createTextNode(child.toString()));\n else\n console.warn(\"Unknown type to append: \", child);\n}\nfunction applyChildren(element, children) {\n for (const child of children) {\n if (!child && child !== 0)\n continue;\n if (Array.isArray(child))\n applyChildren(element, child);\n else\n applyChild(element, child);\n }\n}\nexports.applyChildren = applyChildren;\nfunction createDomElement(tag, attrs) {\n const options = attrs?.is ? { is: attrs.is } : undefined;\n if (attrs?.xmlns)\n return document.createElementNS(attrs.xmlns, tag, options);\n return document.createElement(tag, options);\n}\nexports.createDomElement = createDomElement;\nfunction applyTsxTag(tag, attrs) {\n let finalTag = tag;\n let finalAttrs = attrs;\n if (finalAttrs && \"tsxTag\" in finalAttrs) {\n finalTag = finalAttrs.tsxTag;\n if (!finalAttrs.is && tag.includes(\"-\")) {\n finalAttrs = { ...finalAttrs, is: tag };\n }\n }\n return { finalTag, finalAttrs };\n}\nexports.applyTsxTag = applyTsxTag;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.createRef = exports.h = exports.createElement = void 0;\nconst setAttributes_1 = require(\"./setAttributes\");\nconst utils_1 = require(\"./utils\");\nfunction createElement(tag, attrs, ...children) {\n if (typeof tag === \"function\")\n return tag({ ...attrs, children });\n const { finalTag, finalAttrs } = (0, utils_1.applyTsxTag)(tag, attrs);\n const element = (0, utils_1.createDomElement)(finalTag, finalAttrs);\n if (finalAttrs)\n (0, setAttributes_1.setAttributes)(element, finalAttrs);\n (0, utils_1.applyChildren)(element, children);\n return element;\n}\nexports.createElement = createElement;\nexports.h = createElement;\nconst createRef = () => ({ current: null });\nexports.createRef = createRef;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.jsxDEV = exports.jsxs = exports.jsx = void 0;\nconst setAttributes_1 = require(\"./setAttributes\");\nconst utils_1 = require(\"./utils\");\nfunction jsx(tag, props) {\n if (typeof tag === \"function\")\n return tag(props);\n const { children, ...attrs } = props;\n const { finalTag, finalAttrs } = (0, utils_1.applyTsxTag)(tag, attrs);\n const element = (0, utils_1.createDomElement)(finalTag, finalAttrs);\n (0, setAttributes_1.setAttributes)(element, finalAttrs);\n (0, utils_1.applyChildren)(element, [children]);\n return element;\n}\nexports.jsx = jsx;\nexports.jsxs = jsx;\nexports.jsxDEV = jsx;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.defineCustomElement = void 0;\nconst jsx_runtime_1 = require(\"./jsx-runtime\");\nfunction defineCustomElement(name, constructor, options) {\n customElements.define(name, constructor, options);\n return (props) => (0, jsx_runtime_1.jsx)(name, props);\n}\nexports.defineCustomElement = defineCustomElement;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\n__exportStar(require(\"./createElement\"), exports);\n__exportStar(require(\"./defineCustomElement\"), exports);\n__exportStar(require(\"./jsx-runtime\"), exports);\n__exportStar(require(\"./types\"), exports);\n","import { AlertBuilder, AlertType } from \"@app/alert\";\nimport { getElementById } from \"@app/dom\";\nimport { EditResourceModalData } from \"@app/main/edit-resource\";\nimport { Playlists, State } from \"@app/main/state\";\nimport {\n\tFfmpegResource,\n\tListKind,\n\tListShort,\n\tmakeErrorText,\n\tPlayResourceSource,\n\tqueueTranslateError,\n\trequests,\n\tResourcePlayResource,\n\tSpotifyResource,\n\tSubResource,\n\tUnregisteredResource,\n\tUrlFfmpegResource,\n\tUrlResourceSource,\n} from \"@app/requests\";\nimport { always, filterMap, secondsFromMicroSeconds, secondsToDuration } from \"@app/utility\";\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { ComponentChildren, h } from \"tsx-dom\";\n\nexport interface ListResourceSourceProperties {\n\tname: string;\n\tresourceId: string;\n\tpriority: SubResource | null;\n}\n\nfunction sortPlaylistsPriority(lists: ListShort[]) {\n\tfunction kindToIndex(kind: ListKind) {\n\t\tlet value;\n\t\tif (kind === \"normal\") {\n\t\t\tvalue = 1;\n\t\t} else {\n\t\t\tvalue = 0;\n\t\t}\n\t\treturn value;\n\t}\n\n\tlists.sort((a, b) => {\n\t\tconst kindA = kindToIndex(a.kind);\n\t\tconst kindB = kindToIndex(b.kind);\n\t\tconst diff = kindA - kindB;\n\t\tif (diff !== 0) {\n\t\t\treturn diff;\n\t\t}\n\t\treturn a.name.localeCompare(b.name);\n\t});\n}\n\nexport function makeAlertBubble(type: AlertType, message: string, duration = 3000): HTMLDivElement {\n\treturn new AlertBuilder(type).text(message).dismissible().hideAfter(duration).build();\n}\n\nexport function alertBubble(type: AlertType, message: string, duration = 3000): void {\n\tshowAlert(makeAlertBubble(type, message, duration));\n}\n\nexport function showAlert(alert: HTMLDivElement): void {\n\tgetElementById(\"alerts\").appendChild(alert);\n}\n\nexport function spinningAlert(\n\txhr: Promise,\n\ttext: string,\n\ttranslateError: { [key: string]: string },\n\tdone: (value: T) => string,\n\tfailure?: () => string,\n) {\n\tconst alertElement = new AlertBuilder(\"primary\").spinner().text(text).build();\n\tshowAlert(alertElement);\n\treturn xhr.then(\n\t\tvalue => {\n\t\t\talertElement.replaceWith(makeAlertBubble(\"success\", done(value)));\n\t\t},\n\t\txhr => {\n\t\t\treturn makeAlertBubbleFromXhrError(xhr, translateError, failure === undefined ? undefined : failure()).then(\n\t\t\t\te => alertElement.replaceWith(e),\n\t\t\t);\n\t\t},\n\t);\n}\n\nexport async function makeAlertBubbleFromXhrError(\n\txhr: Response,\n\ttranslateError: { [key: string]: string },\n\tmessage = \"Error occurred\",\n): Promise {\n\tconst text = await makeErrorText(xhr, translateError);\n\treturn makeAlertBubble(\"danger\", `${message}: ${text}`);\n}\n\nexport async function alertBubbleFromXhrError(\n\txhr: Response,\n\ttranslateError: { [key: string]: string },\n\tmessage = \"Error occurred\",\n): Promise {\n\tshowAlert(await makeAlertBubbleFromXhrError(xhr, translateError, message));\n}\n\nexport const LOGIN_PAGE = \"login.html\";\n\nexport function wrapRequestFailure(translateError: { [key: string]: string } = {}, message = \"Error occurred\") {\n\treturn (xhr: Response): Promise => {\n\t\tif (xhr.status === 401) {\n\t\t\talertBubble(\n\t\t\t\t\"danger\",\n\t\t\t\t\"You are not authorized to visit this page or use this function, redirecting to login page...\",\n\t\t\t);\n\t\t\tsetTimeout(() => window.location.assign(LOGIN_PAGE), 2000);\n\t\t} else {\n\t\t\talertBubbleFromXhrError(xhr, translateError, message).then();\n\t\t}\n\n\t\treturn Promise.reject(xhr);\n\t};\n}\n\nexport function wrapRequest(\n\trequest: Promise,\n\ttranslateError: { [key: string]: string } = {},\n\tmessage = \"Error occurred\",\n): Promise {\n\treturn request.then(v => v, wrapRequestFailure(translateError, message));\n}\n\nfunction queueSong(button: HTMLElement, front: boolean, source: PlayResourceSource): Promise {\n\tif (button.hasAttribute(\"queueing\")) {\n\t\treturn Promise.reject();\n\t}\n\tbutton.setAttribute(\"queueing\", \"\");\n\n\tlet request;\n\tif (front) {\n\t\trequest = requests.player.front(source);\n\t} else {\n\t\trequest = requests.player.enqueue(source);\n\t}\n\n\treturn always(wrapRequest(request, queueTranslateError), () => button.removeAttribute(\"queueing\"));\n}\n\nexport interface QueueSource {\n\tsource: PlayResourceSource;\n\tdescription: string | PromiseLike;\n}\n\nexport function onQueueButtonClick(front: boolean, sources: QueueSource[]): Promise {\n\tconst promises = sources.map(source => {\n\t\tlet request: Promise;\n\t\tif (front) {\n\t\t\trequest = requests.player.front(source.source);\n\t\t} else {\n\t\t\trequest = requests.player.enqueue(source.source);\n\t\t}\n\n\t\treturn Promise.resolve(source.description).then(description => {\n\t\t\tconst frontString = front ? \"Fronting\" : \"Queueing\";\n\t\t\tconst message = `${frontString} ${description}`;\n\t\t\tspinningAlert(request, message, queueTranslateError, () => {\n\t\t\t\tconst frontString = front ? \"Fronted\" : \"Queued\";\n\t\t\t\treturn `${frontString} ${description}`;\n\t\t\t});\n\t\t});\n\t});\n\treturn Promise.allSettled(promises).then(() => {\n\t\treturn;\n\t});\n}\n\nexport class SingleTimeout {\n\tprivate handle?: number;\n\n\thasTimeout(): boolean {\n\t\treturn this.handle !== undefined;\n\t}\n\n\tclear(): void {\n\t\tif (this.handle !== undefined) {\n\t\t\tclearTimeout(this.handle);\n\t\t\tthis.handle = undefined;\n\t\t}\n\t}\n\n\ttimeout(f: FrameRequestCallback, ms?: number): void {\n\t\tthis.clear();\n\t\tthis.handle = setTimeout(time => {\n\t\t\tthis.handle = undefined;\n\t\t\tf(time);\n\t\t}, ms);\n\t}\n}\n\nexport function createFasIcon(icon: string): HTMLElement {\n\tconst i = document.createElement(\"i\");\n\ti.classList.add(\"fas\", icon);\n\treturn i;\n}\n\nexport type Recency = \"high\" | \"medium\" | \"low\" | \"none\";\n\nexport class RecencyCalc {\n\t// 15 minutes\n\tpublic static HIGH_RECENCY_MS = 15 * 60 * 1000;\n\t// 2 hours\n\tpublic static MEDIUM_RECENCY_MS = 8 * RecencyCalc.HIGH_RECENCY_MS;\n\t// 8 hours\n\tpublic static LOW_RECENCY_MS = 4 * RecencyCalc.MEDIUM_RECENCY_MS;\n\n\tprivate readonly time: number;\n\tprivate readonly state: State;\n\n\tconstructor(state: State) {\n\t\tthis.time = Date.now();\n\t\tthis.state = state;\n\t}\n\n\tget(resourceId: string): Recency {\n\t\tconst playerSong = this.state.player.song;\n\t\tif (playerSong !== null && playerSong.resource.resourceId === resourceId) {\n\t\t\treturn \"high\";\n\t\t}\n\t\tconst queueItem = this.state.queue.resourceIdToItem.get(resourceId);\n\t\tif (queueItem !== undefined) {\n\t\t\treturn \"high\";\n\t\t}\n\t\tconst item = this.state.recentlyPlayed.resourceIdToMostRecent.get(resourceId);\n\t\tif (item === undefined) {\n\t\t\treturn \"none\";\n\t\t}\n\t\tconst delta = Math.max(0, this.time - Date.parse(item.startTime));\n\t\tif (delta <= RecencyCalc.HIGH_RECENCY_MS) {\n\t\t\treturn \"high\";\n\t\t} else if (delta <= RecencyCalc.MEDIUM_RECENCY_MS) {\n\t\t\treturn \"medium\";\n\t\t} else if (delta <= RecencyCalc.LOW_RECENCY_MS) {\n\t\t\treturn \"low\";\n\t\t} else {\n\t\t\treturn \"none\";\n\t\t}\n\t}\n}\n\nconst recencyToClass = {\n\thigh: \"recency-high\",\n\tmedium: \"recency-medium\",\n\tlow: \"recency-low\",\n\tnone: \"recency-none\",\n};\n\nexport function createQueueButton(recency: Recency, makeSource: () => QueueSource | undefined): HTMLButtonElement {\n\tconst button = document.createElement(\"button\");\n\tbutton.appendChild(createFasIcon(\"fa-plus\"));\n\n\tconst timeout = new SingleTimeout();\n\tconst reset = () => {\n\t\tbutton.firstChild?.replaceWith(createFasIcon(\"fa-plus\"));\n\t};\n\tconst queueFinished = (front: boolean) => {\n\t\tif (front) {\n\t\t\tbutton.firstChild?.replaceWith(createFasIcon(\"fa-angle-up\"));\n\t\t} else {\n\t\t\tbutton.firstChild?.replaceWith(createFasIcon(\"fa-check\"));\n\t\t}\n\t\ttimeout.timeout(reset, 2500);\n\t};\n\n\tconst recencyCls = recencyToClass[recency];\n\tbutton.classList.add(\"btn\", \"btn-secondary\", \"btn-line-height\", \"btn-width\", \"queue-button\", recencyCls);\n\tbutton.addEventListener(\"click\", e => {\n\t\tbutton.blur();\n\n\t\tconst source = makeSource();\n\t\tif (source === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tconst front = e.shiftKey;\n\t\talways(\n\t\t\tqueueSong(button, front, source.source).then(() => {\n\t\t\t\tconst cl = button.classList;\n\t\t\t\tcl.add(\"recency-high\");\n\t\t\t\tcl.remove(recencyCls);\n\t\t\t}),\n\t\t\t() => queueFinished(front),\n\t\t);\n\t});\n\treturn button;\n}\n\nexport function Link({ url, children }: { url: string; children?: ComponentChildren }): JSX.Element {\n\treturn (\n\t\t\n\t\t\t{children}\n\t\t\n\t);\n}\n\nexport function extendLink(a: HTMLAnchorElement, url: string): HTMLAnchorElement {\n\ta.setAttribute(\"href\", url);\n\ta.setAttribute(\"target\", \"_blank\");\n\ta.classList.add(\"no-link-format\", \"underline-on-hover\");\n\treturn a;\n}\n\nexport function createTextLink(text: string, url: string): JSX.Element {\n\treturn {text};\n}\n\nexport function updateUrlAfterResourceChange(a: HTMLElement, resource: EditResourceModalData): void {\n\tlet url;\n\tif ((resource.priority === \"ffmpeg\" || resource.spotify === null) && resource.ffmpeg != null) {\n\t\turl = resource.ffmpeg.url;\n\t} else {\n\t\turl = resource.spotify as string;\n\t}\n\ta.setAttribute(\"href\", url);\n}\n\nexport function urlFromFfmpegResource(resource: FfmpegResource): string {\n\tlet url;\n\tif (\"youtube\" in resource) {\n\t\turl = resource.youtube;\n\t\tif (resource.startTimestamp) {\n\t\t\turl += `?t=${secondsFromMicroSeconds(resource.startTimestamp)}`;\n\t\t}\n\t} else {\n\t\turl = (resource as UrlFfmpegResource).url;\n\t\tif (resource.startTimestamp && url.startsWith(\"https://soundcloud.com\")) {\n\t\t\turl += `#t=${secondsToDuration(secondsFromMicroSeconds(resource.startTimestamp))}`;\n\t\t}\n\t}\n\treturn url;\n}\n\nexport function urlFromSpotifyResource(resource: SpotifyResource): string {\n\treturn resource.trackId;\n}\n\nexport function urlFromResource(\n\tresource: { ffmpeg: FfmpegResource | null; spotify: SpotifyResource | null },\n\tpriority: SubResource | null,\n): string {\n\tlet url;\n\tif (resource.ffmpeg !== null && (priority === \"ffmpeg\" || resource.spotify === null)) {\n\t\turl = urlFromFfmpegResource(resource.ffmpeg);\n\t} else {\n\t\turl = urlFromSpotifyResource(resource.spotify as SpotifyResource);\n\t}\n\treturn url;\n}\n\nexport function urlFromUnregisteredResource(resource: UnregisteredResource): string {\n\treturn urlFromResource(resource, resource.priority);\n}\n\nexport function createAlsoInHoverText(containingLists: ListShort[]): string {\n\tlet hoverText = \"\";\n\tif (containingLists.length > 0) {\n\t\thoverText = `Also in:
    `;\n\t\tcontainingLists.forEach(playlist => {\n\t\t\thoverText += `
  • ${playlist.name}
  • `;\n\t\t});\n\t\thoverText += \"
\";\n\t}\n\treturn hoverText;\n}\n\nexport function toPrioritySortedLists(playlists: string[], lookup: Playlists): ListShort[] {\n\tconst containingLists = filterMap(playlists, id => lookup.byId(id));\n\tsortPlaylistsPriority(containingLists);\n\treturn containingLists;\n}\n\nexport function makeListResourceSource(\n\t{ name, priority, resourceId }: ListResourceSourceProperties,\n\tlist: ListShort,\n\tsub?: SubResource,\n): QueueSource {\n\tif (sub === undefined && priority !== null) {\n\t\tsub = priority;\n\t}\n\tconst source = new ResourcePlayResource(resourceId, list.id, sub);\n\tconst description = `'${name}' from playlist '${list.name}'`;\n\treturn {\n\t\tsource,\n\t\tdescription,\n\t};\n}\n\nexport function makeUrlResourceSource(name: string, url: string): QueueSource {\n\tconst source = new UrlResourceSource(url);\n\tconst description = `'${name}'`;\n\treturn {\n\t\tsource,\n\t\tdescription,\n\t};\n}\n","import { SingleEventTarget } from \"@app/single-event-target\";\nimport Deque from \"double-ended-queue\";\n\nimport { SingleTimeout } from \"./functions\";\n\nexport function createWebsocketBaseUrl(): string {\n\treturn `${window.location.protocol.replace(\"http\", \"ws\")}//${window.location.host}/api/`;\n}\n\n/**\n * Checks if the given websocket close event can be safely ignored\n * @param e the event\n * @returns {boolean}\n */\nexport function wsShouldReconnect(e: CloseEvent): boolean {\n\t// Server sends away only when we send it first\n\treturn !(e.wasClean && e.code === 1001);\n}\n\nconst RECONNECT_DELAYS_MS = [0, 500, 1000, 2000, 5000];\n\nexport class ReconnectDelay {\n\tprivate currentDelay = 0;\n\n\tconstructor() {}\n\n\tnext(): number {\n\t\tthis.currentDelay = Math.min(this.currentDelay + 1, RECONNECT_DELAYS_MS.length);\n\t\treturn RECONNECT_DELAYS_MS[this.currentDelay - 1];\n\t}\n\n\treset() {\n\t\tthis.currentDelay = 0;\n\t}\n}\n\nexport class Updater {\n\tprivate updaterWebSocket?: WebSocket;\n\tprivate readonly reconnectDelay: ReconnectDelay;\n\tprivate readonly failedToDisconnectTimeout: SingleTimeout;\n\tpublic readonly failedToConnect: SingleEventTarget>;\n\tprivate target?: (message: any) => void;\n\tprivate readonly queue: Deque;\n\tprivate readonly handlers: {\n\t\topen: (this: WebSocket, event: Event) => void;\n\t\terror: (this: WebSocket, event: Event) => void;\n\t\tclose: (this: WebSocket, event: CloseEvent) => void;\n\t\tmessage: (this: WebSocket, event: MessageEvent) => void;\n\t};\n\n\tconstructor() {\n\t\tthis.failedToConnect = new SingleEventTarget();\n\t\tthis.reconnectDelay = new ReconnectDelay();\n\t\tthis.failedToDisconnectTimeout = new SingleTimeout();\n\t\tthis.queue = new Deque();\n\n\t\tconst updater = this;\n\t\tthis.handlers = {\n\t\t\topen: function (this: WebSocket, event: Event) {\n\t\t\t\tupdater.reconnectDelay.reset();\n\t\t\t\tconsole.log(\"Updates socket opened\", {\n\t\t\t\t\tevent,\n\t\t\t\t\tsocket: this,\n\t\t\t\t});\n\t\t\t},\n\t\t\tmessage: function (this: WebSocket, event: MessageEvent) {\n\t\t\t\tupdater.failedToDisconnectTimeout.clear();\n\t\t\t\tupdater.onSocketMessage(event);\n\t\t\t},\n\t\t\terror: function (this: WebSocket, event: Event) {\n\t\t\t\tconsole.log(\"Updates socket error\", {\n\t\t\t\t\tevent,\n\t\t\t\t\tsocket: this,\n\t\t\t\t});\n\t\t\t\t// No need to do much else, if this error kills the connection we get a closed event anyway.\n\t\t\t\t// The documentation does not contain any errors that are not fatal\n\t\t\t\t// and this event has no information about what actually happened (it's pretty useless imo)\n\t\t\t},\n\t\t\tclose: function (this: WebSocket, event: CloseEvent) {\n\t\t\t\tconsole.log(\"Updates socket opened\", {\n\t\t\t\t\tevent,\n\t\t\t\t\tsocket: this,\n\t\t\t\t});\n\t\t\t\tupdater.stop();\n\n\t\t\t\tif (wsShouldReconnect(event)) {\n\t\t\t\t\tconsole.warn(\"Updates socket closed\", event);\n\t\t\t\t\tupdater.reconnect();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\n\t\tthis.startUpdater();\n\t}\n\n\tsetTarget(target: (message: any) => void): void {\n\t\tthis.target = target;\n\t\twhile (!this.queue.isEmpty()) {\n\t\t\tthis.target(this.queue.pop());\n\t\t}\n\t}\n\n\tprivate onSocketMessage(message: MessageEvent) {\n\t\tif (typeof message.data !== \"string\") {\n\t\t\tconsole.warn(\"Non-string message received over updater websocket.\");\n\t\t\treturn;\n\t\t}\n\n\t\tlet json = null;\n\t\ttry {\n\t\t\tjson = JSON.parse(message.data);\n\t\t} catch (e) {\n\t\t\tconsole.warn(\"Invalid JSON received: \" + message.data);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.target !== undefined) {\n\t\t\tthis.target(json);\n\t\t} else {\n\t\t\tthis.queue.push(json);\n\t\t}\n\t}\n\n\tprivate reconnect() {\n\t\tconsole.assert(this.updaterWebSocket === undefined);\n\t\tconst delay = this.reconnectDelay.next();\n\t\tif (delay === RECONNECT_DELAYS_MS[0]) {\n\t\t\tthis.failedToDisconnectTimeout.timeout(() => {\n\t\t\t\tthis.failedToConnect.dispatchEvent({});\n\t\t\t}, 1000);\n\t\t}\n\n\t\tconsole.log(`Updates socket reconnecting in ${delay}ms`);\n\t\tconst call = () => {\n\t\t\tif (this.updaterWebSocket === undefined) {\n\t\t\t\tthis.startUpdater();\n\t\t\t}\n\t\t};\n\t\tif (delay === 0) {\n\t\t\tcall();\n\t\t} else {\n\t\t\tsetTimeout(call, delay);\n\t\t}\n\t}\n\n\tprivate startUpdater() {\n\t\tconsole.log(\"Updates socket connecting\");\n\t\tconsole.assert(this.updaterWebSocket === undefined);\n\n\t\tlet url = createWebsocketBaseUrl() + \"updates\";\n\t\tif (typeof crypto === \"object\" && typeof crypto[\"randomUUID\"] === \"function\") {\n\t\t\turl += \"/\" + crypto.randomUUID();\n\t\t}\n\n\t\tconst socket = new WebSocket(url);\n\t\tsocket.addEventListener(\"open\", this.handlers.open);\n\t\tsocket.addEventListener(\"message\", this.handlers.message);\n\t\tsocket.addEventListener(\"error\", this.handlers.error);\n\t\tsocket.addEventListener(\"close\", this.handlers.close);\n\n\t\tthis.updaterWebSocket = socket;\n\t}\n\n\tstop() {\n\t\tif (this.updaterWebSocket === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updaterWebSocket.removeEventListener(\"open\", this.handlers.open);\n\t\tthis.updaterWebSocket.removeEventListener(\"message\", this.handlers.message);\n\t\tthis.updaterWebSocket.removeEventListener(\"error\", this.handlers.error);\n\t\tthis.updaterWebSocket.removeEventListener(\"close\", this.handlers.close);\n\t\tthis.updaterWebSocket.close();\n\t\tthis.updaterWebSocket = undefined;\n\t}\n}\n","import { emptyElement, getElementById } from \"@app/dom\";\nimport { Updater } from \"@app/main/updater\";\nimport { requests } from \"@app/requests\";\nimport { printWelcomeMessage, setUpFavicons } from \"@app/utility\";\n\nimport \"bootswatch/dist/darkly/bootstrap.css\";\nimport \"@styles/main/style.scss\";\n\nconst updater = new Updater();\nconst meRequest = requests.me.get();\n\nexport const LOGIN_PAGE = \"login.html\";\n\nconst Main = import(\"@app/main/main\");\n\n// Called when the DOM is ready.\naddEventListener(\"DOMContentLoaded\", () => {\n\tprintWelcomeMessage();\n\tsetUpFavicons();\n\n\t// Check if the user is authenticated. Else, redirect to login.\n\tmeRequest.then(\n\t\tme => {\n\t\t\tMain.then(({ onDOMContentLoaded }) => onDOMContentLoaded(me, updater));\n\t\t},\n\t\tjqXHR => {\n\t\t\tif (jqXHR.status === 401) {\n\t\t\t\twindow.location.assign(LOGIN_PAGE);\n\t\t\t} else {\n\t\t\t\tupdater.stop();\n\t\t\t\tconst error = jqXHR.status;\n\t\t\t\tconst h2 = document.createElement(\"h2\");\n\t\t\t\th2.innerText = \"Could not connect to Leierkasten\";\n\t\t\t\tconst p = document.createElement(\"p\");\n\t\t\t\tp.innerText = \"Please try again later\";\n\t\t\t\tconst small = document.createElement(\"small\");\n\t\t\t\tsmall.innerText = `Error code ${error}`;\n\t\t\t\tconst loading = getElementById(\"loading\");\n\t\t\t\temptyElement(loading);\n\t\t\t\tloading.append(small, h2, p);\n\t\t\t}\n\t\t},\n\t);\n});\n"],"file":"assets/appIndex-TPvymXDk.js"}