From a5f1c66dceae0b55e4cec47acb53a5a14d674212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Eura=C5=A1?= Date: Sun, 17 Mar 2019 21:06:15 +0100 Subject: [PATCH 01/11] Downgrade parcel and upgrade webamp to beta build with types --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d362fca..2910df6 100644 --- a/package.json +++ b/package.json @@ -38,12 +38,12 @@ "electron-debug": "^2.1.0", "eslint": "^5.15.2", "jest": "^24.5.0", - "parcel-bundler": "^1.12.2", + "parcel-bundler": "~1.11.0", "spectron": "^5.0.0", "ts-jest": "^24.0.0", "tslint": "^5.14.0", "typescript": "^3.2.4", - "webamp": "^1.3.0" + "webamp": "1.3.2-beta.1" }, "browserslist": [ "Chrome 69" From fe503d68a9c08f6950f15d735a0be8ec559969be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Eura=C5=A1?= Date: Sun, 17 Mar 2019 21:07:41 +0100 Subject: [PATCH 02/11] Remove custom webamp bundle and add macos media keys support --- src/node/mediaKeys.js | 16 + src/node/preload.js | 2 + src/renderer.ts | 4 +- src/webamp/webamp.bundle.d.ts | 174 - src/webamp/webamp.bundle.js | 57102 -------------------------------- yarn.lock | 933 +- 6 files changed, 496 insertions(+), 57735 deletions(-) create mode 100644 src/node/mediaKeys.js delete mode 100644 src/webamp/webamp.bundle.d.ts delete mode 100644 src/webamp/webamp.bundle.js diff --git a/src/node/mediaKeys.js b/src/node/mediaKeys.js new file mode 100644 index 0000000..11d03d3 --- /dev/null +++ b/src/node/mediaKeys.js @@ -0,0 +1,16 @@ +const os = require('os') + +function registerMediaKeys(onPause, onPrevious, onNext) { + // According to https://electronjs.org/docs/api/global-shortcut + // + // > The following accelerators will not be registered successfully on macOS + // > 10.14 Mojave (Darwin 18.x.y) unless the app has been authorized as a trusted + // > accessibility client: + if (process.platform === 'darwin' && os.release().indexOf('18') !== 0) { + electron.globalShortcut.register('MediaPlayPause', onPause) + electron.globalShortcut.register('MediaNextTrack', onNext) + electron.globalShortcut.register('MediaPreviousTrack', onPrevious) + } +} + +module.exports = registerMediaKeys diff --git a/src/node/preload.js b/src/node/preload.js index fcef0c5..2a62354 100644 --- a/src/node/preload.js +++ b/src/node/preload.js @@ -2,6 +2,7 @@ const { remote } = require('electron') const handleTransparency = require('./transparency.js') const handleThumbnail = require('./thumbnail.js') const handleThumbar = require('./thumbar.js') +const registerMediaKeys = require('./mediaKeys.js') // We want to completely disable the eval() for security reasons // ESLint will warn about any use of eval(), even this one @@ -41,6 +42,7 @@ window.webampRendered = function () { window.webampPrevious, window.webampNext, ) + registerMediaKeys(window.webampPause, window.webampPrevious, window.webampNext) } window.webampOnTrackDidChange = function(track) { diff --git a/src/renderer.ts b/src/renderer.ts index 09eab63..ed438d0 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -1,6 +1,4 @@ -// Temporary switch to custom webamp build -// import Webamp from 'webamp' -import Webamp from './webamp/webamp.bundle.js' +import Webamp from 'webamp' const DEFAULT_DOCUMENT_TITLE = document.title diff --git a/src/webamp/webamp.bundle.d.ts b/src/webamp/webamp.bundle.d.ts deleted file mode 100644 index c232db2..0000000 --- a/src/webamp/webamp.bundle.d.ts +++ /dev/null @@ -1,174 +0,0 @@ -interface TrackInfo { - /** - * Name to be used until ID3 tags can be resolved. - * - * If the track has a `url`, and this property is not given, - * the filename will be used instead. - * - * Example: `'My Song'` - */ - defaultName?: string; - - /** - * Data to be used _instead_ of trying to fetch ID3 tags. - * - * Example: `{ artist: 'Jordan Eldredge', title: "Jordan's Song" }` - */ - metaData?: { - artist: string, - title: string, - }, - - /** - * Duration (in seconds) to be used instead of fetching enough of the file to measure its length. - * - * Example: 95 - */ - duration?: number; -} - -interface URLTrack extends TrackInfo { - /** - * Source URL of the track - * - * Note: This URL must be served the with correct CORs headers. - * - * Example: `'https://example.com/song.mp3'` - */ - url: string; -} - -interface BlobTrack extends TrackInfo { - /** - * Blob source of the track - */ - blob: Blob; -} - -/** - * Many methods on the webamp instance deal with track. - * - * Either `url` or `blob` must be specified - */ -type Track = URLTrack | BlobTrack; - -interface Options { - /** - * An object representing the initial skin to use. - * - * If omitted, the default skin, included in the bundle, will be used. - * Note: This URL must be served the with correct CORs headers. - * - * Example: `{ url: './path/to/skin.wsz' }` - */ - initialSkin?: { - url: string, - }; - - /** - * An array of `Track`s to prepopulate the playlist with. - */ - initialTracks?: Track[]; - - /** - * An array of objects representing available skins. - * - * These will appear in the "Options" menu under "Skins". - * Note: These URLs must be served with the correct CORs headers. - * - * Example: `[ { url: "./green.wsz", name: "Green Dimension V2" } ]` - */ - availableSkins?: { url: string, name: string }[]; - - /** - * Should global hotkeys be enabled? - * - * Default: `false` - */ - enableHotkeys?: boolean; - - /** - * An array of additional file pickers. - * - * These will appear in the "Options" menu under "Play". - * - * In the offical version, this option is used to provide a "Dropbox" file picker. - */ - filePickers?: [{ - /** - * The name that will appear in the context menu. - * - * Example: `"My File Picker..."` - */ - contextMenuName: string, - - /** - * A function which returns a Promise that resolves to an array of `Track`s - * - * Example: `() => Promise.resolve([{ url: './rick_roll.mp3' }])` - */ - filePicker: () => Promise, - - /** - * Indicates if this options should be made available when the user is offline. - */ - requiresNetwork: boolean, - }]; -} - -export default class Webamp { - constructor(options: Options); - - /** - * Returns a true if the current browser supports the features that Webamp depends upon. - * - * It is recommended to check this before you attempt to instantiate an instance of Winamp. - */ - public static browserIsSupported(): boolean; - - /** - * Add an array of `Track`s to the end of the playlist. - */ - public appendTracks(tracks: Track[]): void; - - /** - * Replace the playlist with an array of `Track`s and begin playing the first track. - */ - public setTracksToPlay(tracks: Track[]): void; - - /** - * Webamp will wait until it has fetched the skin and fully parsed it and then render itself. - * - * Webamp is rendered into a new DOM node at the end of the tag with the id `#webamp`. - * - * If a domNode is passed, Webamp will place itself in the center of that DOM node. - * - * @returns A promise is returned which will resolve after the render is complete. - */ - public renderWhenReady(domNode: HTMLElement): Promise; - - /** - * A callback which will be called when a new track starts loading. - * - * This can happen on startup when the first track starts buffering, or when a subsequent track starts playing. - * The callback will be called with an object `({url: 'https://example.com/track.mp3'})` containing the URL of the track. - * Note: If the user drags in a track, the URL may be an ObjectURL. - * - * @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events. - */ - public onTrackDidChange(callback: (track: Track) => any): () => void; - - /** - * A callback which will be called when Webamp is closed. - * - * @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events. - */ - public onClose(callback: () => any): () => void; - - /** - * A callback which will be called when Webamp is minimized. - * - * @returns An "unsubscribe" function. Useful if at some point in the future you want to stop listening to these events. - */ - public onMinimize(callback: () => any): () => void; -} diff --git a/src/webamp/webamp.bundle.js b/src/webamp/webamp.bundle.js deleted file mode 100644 index 69e44a6..0000000 --- a/src/webamp/webamp.bundle.js +++ /dev/null @@ -1,57102 +0,0 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["Webamp"] = factory(); - else - root["Webamp"] = factory(); -})(window, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 295); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -if (true) { - module.exports = __webpack_require__(159); -} else {} - - -/***/ }), -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ADD_TRACK_FROM_URL; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return CLOSE_WINAMP; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return OPEN_WINAMP; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return MINIMIZE_WINAMP; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return IS_PLAYING; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return IS_STOPPED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return PAUSE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return PLAY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return SEEK_TO_PERCENT_COMPLETE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return SET_BALANCE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return SET_BAND_VALUE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return SET_FOCUS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return SET_BAND_FOCUS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return SET_FOCUSED_WINDOW; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return SET_MEDIA; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gb", function() { return SET_SCRUB_POSITION; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hb", function() { return SET_SKIN_DATA; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kb", function() { return SET_VOLUME; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ob", function() { return START_WORKING; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pb", function() { return STEP_MARQUEE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "qb", function() { return STOP; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rb", function() { return STOP_WORKING; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sb", function() { return TOGGLE_DOUBLESIZE_MODE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return SET_EQ_AUTO; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return SET_EQ_ON; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return SET_EQ_OFF; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tb", function() { return TOGGLE_LLAMA_MODE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "xb", function() { return TOGGLE_REPEAT; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yb", function() { return TOGGLE_SHUFFLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "zb", function() { return TOGGLE_TIME_MODE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ab", function() { return TOGGLE_VISUALIZER_STYLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Db", function() { return UNSET_FOCUS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Fb", function() { return UPDATE_TIME_ELAPSED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jb", function() { return SET_USER_MESSAGE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Eb", function() { return UNSET_USER_MESSAGE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fb", function() { return SET_PLAYLIST_SCROLL_POSITION; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return CLICKED_TRACK; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return CTRL_CLICKED_TRACK; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "nb", function() { return SHIFT_CLICKED_TRACK; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return SELECT_ALL; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return SELECT_ZERO; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return INVERT_SELECTION; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return REMOVE_ALL_TRACKS; }); -/* unused harmony export CROP_TRACKS */ -/* unused harmony export FILE_INFO */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return REMOVE_TRACKS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return SET_AVAILABLE_SKINS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return REVERSE_LIST; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return RANDOMIZE_LIST; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ib", function() { return SET_TRACK_ORDER; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return PLAY_TRACK; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return BUFFER_TRACK; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return DRAG_SELECTED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cb", function() { return SET_MEDIA_TAGS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bb", function() { return SET_MEDIA_DURATION; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bb", function() { return TOGGLE_WINDOW; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return CLOSE_WINDOW; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return MEDIA_TAG_REQUEST_INITIALIZED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return MEDIA_TAG_REQUEST_FAILED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return NETWORK_CONNECTED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return NETWORK_DISCONNECTED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gb", function() { return UPDATE_WINDOW_POSITIONS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hb", function() { return WINDOW_SIZE_CHANGED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Cb", function() { return TOGGLE_WINDOW_SHADE_MODE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return LOADED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mb", function() { return SET_Z_INDEX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return DISABLE_MARQUEE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return SET_DUMMY_VIZ_DATA; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lb", function() { return SET_WINDOW_VISIBILITY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return LOADING; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return CLOSE_REQUESTED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return LOAD_SERIALIZED_STATE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return RESET_WINDOW_SIZES; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return BROWSER_WINDOW_SIZE_CHANGED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return LOAD_DEFAULT_SKIN; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return ENABLE_MEDIA_LIBRARY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return ENABLE_MILKDROP; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "db", function() { return SET_MILKDROP_DESKTOP; }); -/* unused harmony export SET_VISUALIZER_STYLE */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return GOT_BUTTERCHURN_PRESETS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return GOT_BUTTERCHURN; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return RESOLVE_PRESET_AT_INDEX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return SELECT_PRESET_AT_INDEX; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vb", function() { return TOGGLE_PRESET_OVERLAY; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return PRESET_REQUESTED; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wb", function() { return TOGGLE_RANDOMIZE_PRESETS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ub", function() { return TOGGLE_PRESET_CYCLING; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return SCHEDULE_MILKDROP_MESSAGE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "eb", function() { return SET_MILKDROP_FULLSCREEN; }); -const ADD_TRACK_FROM_URL = "ADD_TRACK_FROM_URL"; -const CLOSE_WINAMP = "CLOSE_WINAMP"; -const OPEN_WINAMP = "OPEN_WINAMP"; -const MINIMIZE_WINAMP = "MINIMIZE_WINAMP"; -const IS_PLAYING = "IS_PLAYING"; -const IS_STOPPED = "IS_STOPPED"; -const PAUSE = "PAUSE"; -const PLAY = "PLAY"; -const SEEK_TO_PERCENT_COMPLETE = "SEEK_TO_PERCENT_COMPLETE"; -const SET_BALANCE = "SET_BALANCE"; -const SET_BAND_VALUE = "SET_BAND_VALUE"; -const SET_FOCUS = "SET_FOCUS"; -const SET_BAND_FOCUS = "SET_BAND_FOCUS"; -const SET_FOCUSED_WINDOW = "SET_FOCUSED_WINDOW"; -const SET_MEDIA = "SET_MEDIA"; -const SET_SCRUB_POSITION = "SET_SCRUB_POSITION"; -const SET_SKIN_DATA = "SET_SKIN_DATA"; -const SET_VOLUME = "SET_VOLUME"; -const START_WORKING = "START_WORKING"; -const STEP_MARQUEE = "STEP_MARQUEE"; -const STOP = "STOP"; -const STOP_WORKING = "STOP_WORKING"; -const TOGGLE_DOUBLESIZE_MODE = "TOGGLE_DOUBLESIZE_MODE"; -const SET_EQ_AUTO = "SET_EQ_AUTO"; -const SET_EQ_ON = "SET_EQ_ON"; -const SET_EQ_OFF = "SET_EQ_OFF"; -const TOGGLE_LLAMA_MODE = "TOGGLE_LLAMA_MODE"; -const TOGGLE_REPEAT = "TOGGLE_REPEAT"; -const TOGGLE_SHUFFLE = "TOGGLE_SHUFFLE"; -const TOGGLE_TIME_MODE = "TOGGLE_TIME_MODE"; -const TOGGLE_VISUALIZER_STYLE = "TOGGLE_VISUALIZER_STYLE"; -const UNSET_FOCUS = "UNSET_FOCUS"; -const UPDATE_TIME_ELAPSED = "UPDATE_TIME_ELAPSED"; -const SET_USER_MESSAGE = "SET_USER_MESSAGE"; -const UNSET_USER_MESSAGE = "UNSET_USER_MESSAGE"; -const SET_PLAYLIST_SCROLL_POSITION = "SET_PLAYLIST_SCROLL_POSITION"; -const CLICKED_TRACK = "CLICKED_TRACK"; -const CTRL_CLICKED_TRACK = "CTRL_CLICKED_TRACK"; -const SHIFT_CLICKED_TRACK = "SHIFT_CLICKED_TRACK"; -const SELECT_ALL = "SELECT_ALL"; -const SELECT_ZERO = "SELECT_ZERO"; -const INVERT_SELECTION = "INVERT_SELECTION"; -const REMOVE_ALL_TRACKS = "REMOVE_ALL_TRACKS"; -const CROP_TRACKS = "CROP_TRACKS"; -const FILE_INFO = "FILE_INFO"; -const REMOVE_TRACKS = "REMOVE_TRACKS"; -const SET_AVAILABLE_SKINS = "SET_AVAILABLE_SKINS"; -const REVERSE_LIST = "REVERSE_LIST"; -const RANDOMIZE_LIST = "RANDOMIZE_LIST"; -const SET_TRACK_ORDER = "SET_TRACK_ORDER"; -const PLAY_TRACK = "PLAY_TRACK"; -const BUFFER_TRACK = "BUFFER_TRACK"; -const DRAG_SELECTED = "DRAG_SELECTED"; -const SET_MEDIA_TAGS = "SET_MEDIA_TAGS"; -const SET_MEDIA_DURATION = "SET_MEDIA_DURATION"; -const TOGGLE_WINDOW = "TOGGLE_WINDOW"; -const CLOSE_WINDOW = "CLOSE_WINDOW"; -const MEDIA_TAG_REQUEST_INITIALIZED = "MEDIA_TAG_REQUEST_INITIALIZED"; -const MEDIA_TAG_REQUEST_FAILED = "MEDIA_TAG_REQUEST_FAILED"; -const NETWORK_CONNECTED = "NETWORK_CONNECTED"; -const NETWORK_DISCONNECTED = "NETWORK_DISCONNECTED"; -const UPDATE_WINDOW_POSITIONS = "UPDATE_WINDOW_POSITIONS"; -const WINDOW_SIZE_CHANGED = "WINDOW_SIZE_CHANGED"; -const TOGGLE_WINDOW_SHADE_MODE = "TOGGLE_WINDOW_SHADE_MODE"; -const LOADED = "LOADED"; -const SET_Z_INDEX = "SET_Z_INDEX"; -const DISABLE_MARQUEE = "DISABLE_MARQUEE"; -const SET_DUMMY_VIZ_DATA = "SET_DUMMY_VIZ_DATA"; -const SET_WINDOW_VISIBILITY = "SET_WINDOW_VISIBILITY"; -const LOADING = "LOADING"; -const CLOSE_REQUESTED = "CLOSE_REQUESTED"; -const LOAD_SERIALIZED_STATE = "LOAD_SERIALIZED_STATE"; -const RESET_WINDOW_SIZES = "RESET_WINDOW_SIZES"; -const BROWSER_WINDOW_SIZE_CHANGED = "BROWSER_WINDOW_SIZE_CHANGED"; -const LOAD_DEFAULT_SKIN = "LOAD_DEFAULT_SKIN"; -const ENABLE_MEDIA_LIBRARY = "ENABLE_MEDIA_LIBRARY"; -const ENABLE_MILKDROP = "ENABLE_MILKDROP"; -const SET_MILKDROP_DESKTOP = "SET_MILKDROP_DESKTOP"; -const SET_VISUALIZER_STYLE = "SET_VISUALIZER_STYLE"; -const GOT_BUTTERCHURN_PRESETS = "GOT_BUTTERCHURN_PRESETS"; -const GOT_BUTTERCHURN = "GOT_BUTTERCHURN"; -const RESOLVE_PRESET_AT_INDEX = "RESOLVE_PRESET_AT_INDEX"; -const SELECT_PRESET_AT_INDEX = "SELECT_PRESET_AT_INDEX"; -const TOGGLE_PRESET_OVERLAY = "TOGGLE_PRESET_OVERLAY"; -const PRESET_REQUESTED = "PRESET_REQUESTED"; -const TOGGLE_RANDOMIZE_PRESETS = "TOGGLE_RANDOMIZE_PRESETS"; -const TOGGLE_PRESET_CYCLING = "TOGGLE_PRESET_CYCLING"; -const SCHEDULE_MILKDROP_MESSAGE = "SCHEDULE_MILKDROP_MESSAGE"; -const SET_MILKDROP_FULLSCREEN = "SET_MILKDROP_FULLSCREEN"; - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -if (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else { - // By explicitly using `prop-types` you are opting into new production behavior. - // http://fb.me/prop-types-in-prod - module.exports = __webpack_require__(172)(); -} - - -/***/ }), -/* 3 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; - -// EXTERNAL MODULE: ./js/actionTypes.ts -var actionTypes = __webpack_require__(1); - -// EXTERNAL MODULE: ./js/constants.ts -var constants = __webpack_require__(5); - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectSpread.js -var objectSpread = __webpack_require__(6); -var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread); - -// EXTERNAL MODULE: ./js/selectors.ts + 2 modules -var selectors = __webpack_require__(4); - -// EXTERNAL MODULE: ./js/utils.ts -var utils = __webpack_require__(8); - -// EXTERNAL MODULE: ./js/resizeUtils.ts -var resizeUtils = __webpack_require__(72); - -// EXTERNAL MODULE: ./js/snapUtils.ts -var snapUtils = __webpack_require__(24); - -// CONCATENATED MODULE: ./js/actionCreators/windows.ts - - - - - - - -// Dispatch an action and, if needed rearrange the windows to preserve -// the existing edge relationship. -// -// Works by checking the edges before the action is dispatched. Then, -// after disatching, calculating what position change would be required -// to restore those relationships. -function withWindowGraphIntegrity(action) { - return (dispatch, getState) => { - const state = getState(); - const graph = selectors["db" /* getWindowGraph */](state); - const originalSizes = selectors["kb" /* getWindowSizes */](state); - dispatch(action); - const newSizes = selectors["kb" /* getWindowSizes */](getState()); - const sizeDiff = {}; - - for (const window of Object.keys(newSizes)) { - const original = originalSizes[window]; - const current = newSizes[window]; - sizeDiff[window] = { - height: current.height - original.height, - width: current.width - original.width - }; - } - - const positionDiff = Object(resizeUtils["b" /* getPositionDiff */])(graph, sizeDiff); - const windowPositions = selectors["hb" /* getWindowPositions */](state); - const newPositions = utils["s" /* objectMap */](windowPositions, (position, key) => Object(snapUtils["a" /* applyDiff */])(position, positionDiff[key])); - dispatch(updateWindowPositions(newPositions)); - }; -} - -function toggleDoubleSizeMode() { - return withWindowGraphIntegrity({ - type: actionTypes["sb" /* TOGGLE_DOUBLESIZE_MODE */] - }); -} -function toggleLlamaMode() { - return { - type: actionTypes["tb" /* TOGGLE_LLAMA_MODE */] - }; -} -function toggleEqualizerShadeMode() { - return withWindowGraphIntegrity({ - type: actionTypes["Cb" /* TOGGLE_WINDOW_SHADE_MODE */], - windowId: "equalizer" - }); -} -function toggleMainWindowShadeMode() { - return withWindowGraphIntegrity({ - type: actionTypes["Cb" /* TOGGLE_WINDOW_SHADE_MODE */], - windowId: "main" - }); -} -function togglePlaylistShadeMode() { - return withWindowGraphIntegrity({ - type: actionTypes["Cb" /* TOGGLE_WINDOW_SHADE_MODE */], - windowId: "playlist" - }); -} -function closeWindow(windowId) { - return { - type: actionTypes["g" /* CLOSE_WINDOW */], - windowId - }; -} -function hideWindow(windowId) { - return { - type: actionTypes["lb" /* SET_WINDOW_VISIBILITY */], - windowId, - hidden: true - }; -} -function showWindow(windowId) { - return { - type: actionTypes["lb" /* SET_WINDOW_VISIBILITY */], - windowId, - hidden: false - }; -} -function setFocusedWindow(window) { - return { - type: actionTypes["Z" /* SET_FOCUSED_WINDOW */], - window - }; -} -function setWindowSize(windowId, size) { - return { - type: actionTypes["Hb" /* WINDOW_SIZE_CHANGED */], - windowId, - size - }; -} -function toggleWindow(windowId) { - return { - type: actionTypes["Bb" /* TOGGLE_WINDOW */], - windowId - }; -} -function updateWindowPositions(positions, absolute) { - return { - type: actionTypes["Gb" /* UPDATE_WINDOW_POSITIONS */], - positions, - absolute - }; -} -function centerWindowsInContainer(container) { - return (dispatch, getState) => { - if (!selectors["C" /* getPositionsAreRelative */](getState())) { - return; - } - - const _container$getBoundin = container.getBoundingClientRect(), - left = _container$getBoundin.left, - top = _container$getBoundin.top; - - const width = container.scrollWidth, - height = container.scrollHeight; - dispatch(centerWindows({ - left, - top, - width, - height - })); - }; -} -function centerWindowsInView() { - return centerWindows({ - left: window.scrollX, - top: window.scrollY, - width: window.innerWidth, - height: window.innerHeight - }); -} -function centerWindows(box) { - return (dispatch, getState) => { - const state = getState(); - const windowsInfo = selectors["lb" /* getWindowsInfo */](state); - const getOpen = selectors["fb" /* getWindowOpen */](state); - const top = box.top, - left = box.left, - width = box.width, - height = box.height; - const offsetLeft = left + window.scrollX; - const offsetTop = top + window.scrollY; // A layout has been suplied. We will compute the bounding box and - // center the given layout. - - const bounding = utils["c" /* calculateBoundingBox */](windowsInfo.filter(w => getOpen(w.key))); - const boxHeight = bounding.bottom - bounding.top; - const boxWidth = bounding.right - bounding.left; - const move = { - x: Math.ceil(offsetLeft - bounding.left + (width - boxWidth) / 2), - y: Math.ceil(offsetTop - bounding.top + (height - boxHeight) / 2) - }; - const newPositions = windowsInfo.reduce((pos, w) => objectSpread_default()({}, pos, { - [w.key]: { - x: move.x + w.x, - y: move.y + w.y - } - }), {}); - dispatch(updateWindowPositions(newPositions, true)); - }; -} -function browserWindowSizeChanged(size) { - return dispatch => { - dispatch(objectSpread_default()({ - type: actionTypes["b" /* BROWSER_WINDOW_SIZE_CHANGED */] - }, size)); - dispatch(ensureWindowsAreOnScreen()); - }; -} -function resetWindowSizes() { - return { - type: actionTypes["I" /* RESET_WINDOW_SIZES */] - }; -} -function stackWindows() { - return (dispatch, getState) => { - dispatch(updateWindowPositions(selectors["P" /* getStackedLayoutPositions */](getState()))); - }; -} -function ensureWindowsAreOnScreen() { - return (dispatch, getState) => { - const state = getState(); - const windowsInfo = selectors["lb" /* getWindowsInfo */](state); - const getOpen = selectors["fb" /* getWindowOpen */](state); - - const _Utils$getWindowSize = utils["l" /* getWindowSize */](), - height = _Utils$getWindowSize.height, - width = _Utils$getWindowSize.width; - - const bounding = utils["c" /* calculateBoundingBox */](windowsInfo.filter(w => getOpen(w.key))); - const positions = selectors["hb" /* getWindowPositions */](state); // Are we good? - - if (bounding.left >= 0 && bounding.top >= 0 && bounding.right <= width && bounding.bottom <= height) { - // My work here is done. - return; - } - - const boundingHeight = bounding.bottom - bounding.top; - const boundingWidth = bounding.right - bounding.left; // Could we simply shift all the windows by a constant offset? - - if (boundingWidth <= width && boundingHeight <= height) { - let moveY = 0; - let moveX = 0; - - if (bounding.top <= 0) { - moveY = bounding.top; - } else if (bounding.bottom > height) { - moveY = bounding.bottom - height; - } - - if (bounding.left <= 0) { - moveX = bounding.left; - } else if (bounding.right > width) { - moveX = bounding.right - width; - } - - const newPositions = utils["s" /* objectMap */](positions, position => ({ - x: position.x - moveX, - y: position.y - moveY - })); - dispatch(updateWindowPositions(newPositions)); - return; - } // TODO: Try moving the individual groups to try to fit them in - // I give up. Just reset everything. - - - dispatch(resetWindowSizes()); - dispatch(stackWindows()); - dispatch(centerWindowsInView()); - }; -} -// CONCATENATED MODULE: ./js/actionCreators/media.ts - - - - - - - -function playRandomTrack() { - return (dispatch, getState) => { - const _getState = getState(), - _getState$playlist = _getState.playlist, - trackOrder = _getState$playlist.trackOrder, - currentTrack = _getState$playlist.currentTrack; - - if (trackOrder.length === 0) { - return; - } - - let nextId; - - do { - nextId = trackOrder[Math.floor(trackOrder.length * Math.random())]; - } while (nextId === currentTrack && trackOrder.length > 1); // TODO: Sigh... Technically, we should detect if we are looping only repeat if we are. - // I think this would require pre-computing the "random" order of a playlist. - - - dispatch({ - type: actionTypes["D" /* PLAY_TRACK */], - id: nextId - }); - }; -} - -function play() { - return (dispatch, getState) => { - const state = getState(); - - if (state.media.status === constants["f" /* MEDIA_STATUS */].STOPPED && state.playlist.currentTrack == null && state.playlist.trackOrder.length === 0) { - dispatch(openMediaFileDialog()); - } else { - dispatch({ - type: actionTypes["C" /* PLAY */] - }); - } - }; -} -function pause() { - return (dispatch, getState) => { - const status = getState().media.status; - - if (status === constants["f" /* MEDIA_STATUS */].PLAYING) { - dispatch({ - type: actionTypes["B" /* PAUSE */] - }); - } else { - dispatch({ - type: actionTypes["C" /* PLAY */] - }); - } - }; -} -function stop() { - return { - type: actionTypes["qb" /* STOP */] - }; -} -function nextN(n) { - return (dispatch, getState) => { - const state = getState(); - - if (state.media.shuffle) { - dispatch(playRandomTrack()); - return; - } - - const nextTrackId = Object(selectors["mb" /* nextTrack */])(state, n); - - if (nextTrackId == null) { - return; - } - - dispatch({ - type: actionTypes["D" /* PLAY_TRACK */], - id: nextTrackId - }); - }; -} -function next() { - return nextN(1); -} -function previous() { - return nextN(-1); -} -function seekForward(seconds) { - return function (dispatch, getState) { - const state = getState(); - const timeElapsed = selectors["Q" /* getTimeElapsed */](state); - const duration = selectors["l" /* getDuration */](state); - - if (duration == null) { - return; - } - - const newTimeElapsed = timeElapsed + seconds; - dispatch({ - type: actionTypes["M" /* SEEK_TO_PERCENT_COMPLETE */], - percent: newTimeElapsed / duration * 100 - }); - }; -} -function seekBackward(seconds) { - return seekForward(-seconds); -} -function setVolume(volume) { - return { - type: actionTypes["kb" /* SET_VOLUME */], - volume: Object(utils["d" /* clamp */])(volume, 0, 100) - }; -} -function adjustVolume(volumeDiff) { - return (dispatch, getState) => { - const currentVolume = getState().media.volume; - return dispatch(setVolume(currentVolume + volumeDiff)); - }; -} -function scrollVolume(e) { - e.preventDefault(); - return (dispatch, getState) => { - const currentVolume = getState().media.volume; // Using pixels as percentage difference here is a bit arbirary, but... oh well. - - return dispatch(setVolume(currentVolume + e.deltaY)); - }; -} -function setBalance(balance) { - balance = Object(utils["d" /* clamp */])(balance, -100, 100); // The balance clips to the center - - if (Math.abs(balance) < 25) { - balance = 0; - } - - return { - type: actionTypes["R" /* SET_BALANCE */], - balance - }; -} -function toggleRepeat() { - return { - type: actionTypes["xb" /* TOGGLE_REPEAT */] - }; -} -function toggleShuffle() { - return { - type: actionTypes["yb" /* TOGGLE_SHUFFLE */] - }; -} -function toggleTimeMode() { - return { - type: actionTypes["zb" /* TOGGLE_TIME_MODE */] - }; -} -// CONCATENATED MODULE: ./js/actionCreators/equalizer.ts - - -const BAND_SNAP_DISTANCE = 5; -const BAND_MID_POINT_VALUE = 50; - -function _snapBandValue(value) { - if (value < BAND_MID_POINT_VALUE + BAND_SNAP_DISTANCE && value > BAND_MID_POINT_VALUE - BAND_SNAP_DISTANCE) { - return BAND_MID_POINT_VALUE; - } - - return value; -} - -function setEqBand(band, value) { - return { - type: actionTypes["T" /* SET_BAND_VALUE */], - band, - value: _snapBandValue(value) - }; -} - -function _setEqTo(value) { - return dispatch => { - Object.values(constants["a" /* BANDS */]).forEach(band => { - dispatch({ - type: actionTypes["T" /* SET_BAND_VALUE */], - value, - band: band - }); - }); - }; -} - -function setEqToMax() { - return _setEqTo(100); -} -function setEqToMid() { - return _setEqTo(50); -} -function setEqToMin() { - return _setEqTo(0); -} -function setPreamp(value) { - return { - type: actionTypes["T" /* SET_BAND_VALUE */], - band: "preamp", - value: _snapBandValue(value) - }; -} -function toggleEq() { - return (dispatch, getState) => { - if (getState().equalizer.on) { - dispatch({ - type: actionTypes["W" /* SET_EQ_OFF */] - }); - } else { - dispatch({ - type: actionTypes["X" /* SET_EQ_ON */] - }); - } - }; -} -function toggleEqAuto() { - return (dispatch, getState) => { - dispatch({ - type: actionTypes["V" /* SET_EQ_AUTO */], - value: !getState().equalizer.auto - }); - }; -} -// EXTERNAL MODULE: ./node_modules/winamp-eqf/index.js -var winamp_eqf = __webpack_require__(97); - -// EXTERNAL MODULE: ./js/fileUtils.ts -var fileUtils = __webpack_require__(19); - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js -var slicedToArray = __webpack_require__(18); -var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); - -// EXTERNAL MODULE: ./js/skinSprites.ts -var skinSprites = __webpack_require__(53); - -// CONCATENATED MODULE: ./js/regionParser.ts - -function pointPairs(arr) { - const pairedValues = []; - - for (let i = 0; i < arr.length; i += 2) { - pairedValues.push(`${arr[i]},${arr[i + 1]}`); - } - - return pairedValues; -} -function regionParser(regionStr) { - const iniData = Object(utils["t" /* parseIni */])(regionStr); - const data = {}; - Object.keys(iniData).forEach(section => { - const _iniData$section = iniData[section], - numpoints = _iniData$section.numpoints, - pointlist = _iniData$section.pointlist; - - if (!numpoints || !pointlist) { - return; - } - - const pointCounts = numpoints.split(/\s*,\s*/).filter(val => val !== ""); - const points = pointPairs( // points can be separated by spaces, or by commas - pointlist.split(/\s*[, ]\s*/).filter(val => val !== "")); - let pointIndex = 0; - const polygons = pointCounts.map(numStr => { - const num = Number(numStr); - const polygon = points.slice(pointIndex, pointIndex + num).join(" "); - - if (!polygon.length) { - // It's possible that the skin author specified more polygons than provided points. - return null; - } - - pointIndex += num; - return polygon; - }); - const validPolygons = polygons.filter(polygon => polygon != null); - - if (validPolygons.length) { - data[section] = validPolygons; - } - }); - return data; -} -// CONCATENATED MODULE: ./js/skinParser.js - - - - - - - -const shallowMerge = objs => objs.reduce((prev, img) => Object.assign(prev, img), {}); - -const CURSORS = ["CLOSE", "EQCLOSE", "EQNORMAL", "EQSLID", "EQTITLE", "MAINMENU", "MMENU", "MIN", "NORMAL", "PCLOSE", "PNORMAL", "POSBAR", "PSIZE", "PTBAR", "PVSCROLL", "PWINBUT", "PWSNORM", "PWSSIZE", "SONGNAME", "TITLEBAR", "VOLBAL", "WINBUT", "WSNORMAL", "WSPOSBAR" -/* - * > There are usually 4 more cursors in the skins: volbar.cur, wsclose.cur, - * > wswinbut.cur, wsmin.cur, but they are never used, at least in the last - * > versions of winamp, so there's no need of including them. The cursors - * > shown when the mouse is over the app-buttons are the same in normal and - * > winshade mode, except for the main menu button. You can make animated - * > cursors, but you have to name them with the extension .cur (animated - * > cursors are usually .ani files). - * - * -- Skinners Atlas - * - * "VOLBAR", - * "WSCLOSE", - * "WSWINBUT", - * "WSMIN", - * - */ -]; - -const _genImgFromBlob = async blob => new Promise((resolve, reject) => { - const img = new Image(); - - img.onload = () => { - // Schedule cleanup of object url? - // Maybe on next tick, or with requestidlecallback - resolve(img); - }; - - img.onerror = () => reject("Failed to decode image"); - - img.src = URL.createObjectURL(blob); -}); - -const genImgFromBlob = async blob => { - if (window.createImageBitmap) { - try { - // Use this faster native browser API if available. - return await window.createImageBitmap(blob); - } catch (e) { - console.warn("Encountered an error with createImageBitmap. Falling back to Image approach."); // There are some bugs in the new API. In case something goes wrong, we call fall back. - - return _genImgFromBlob(blob); - } - } - - return _genImgFromBlob(blob); -}; - -async function genFileFromZip(zip, fileName, ext, mode) { - const regex = new RegExp(`^(.*/)?${fileName}(\.${ext})?$`, "i"); - const files = zip.file(regex); - - if (!files.length) { - return null; - } // Return a promise (awaitable). - - - return { - contents: await files[0].async(mode), - name: files[0].name - }; -} - -function getSpriteUrisFromImg(img, sprites) { - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - return sprites.reduce((images, sprite) => { - canvas.height = sprite.height; - canvas.width = sprite.width; - context.drawImage(img, -sprite.x, -sprite.y); - const image = canvas.toDataURL(); - images[sprite.name] = image; - return images; - }, {}); -} - -async function genImgFromFilename(zip, fileName) { - // Winamp only supports .bmp images, but WACUP set a precidence of supporting - // .png as well to reduce size. Since we care about size as well, we follow - // suit. Our default skin uses .png to save 14kb. - const file = await genFileFromZip(zip, fileName, "(png|bmp)", "blob"); - - if (!file) { - return null; - } - - const mimeType = `image/${Object(utils["h" /* getFileExtension */])(file.name) || "*"}`; // The spec for createImageBitmap() says the browser should try to sniff the - // mime type, but it looks like Firefox does not. So we specify it here - // explicitly. - - const typedBlob = new Blob([file.contents], { - type: mimeType - }); - return genImgFromBlob(typedBlob); -} - -async function genSpriteUrisFromFilename(zip, fileName) { - const img = await genImgFromFilename(zip, fileName); - - if (img == null) { - return {}; - } - - return getSpriteUrisFromImg(img, skinSprites["b" /* default */][fileName]); -} - -async function getCursorFromFilename(zip, fileName) { - const file = await genFileFromZip(zip, fileName, "CUR", "base64"); - return file && `data:image/x-win-bitmap;base64,${file.contents}`; -} - -async function genPlaylistStyle(zip) { - const pledit = await genFileFromZip(zip, "PLEDIT", "txt", "text"); - const data = pledit && Object(utils["t" /* parseIni */])(pledit.contents).text; - - if (!data) { - // Corrupt or missing PLEDIT.txt file. - return constants["c" /* DEFAULT_SKIN */].playlistStyle; - } // Winamp seems to permit colors that contain too many characters. - // For compatibility with existing skins, we normalize them here. - - - ["normal", "current", "normalbg", "selectedbg", "mbFG", "mbBG"].forEach(colorKey => { - let color = data[colorKey]; - - if (!color) { - return; - } - - if (color[0] !== "#") { - color = `#${color}`; - } - - data[colorKey] = color.slice(0, 7); - }); - return objectSpread_default()({}, constants["c" /* DEFAULT_SKIN */].playlistStyle, data); -} - -async function genVizColors(zip) { - const viscolor = await genFileFromZip(zip, "VISCOLOR", "txt", "text"); - return viscolor ? Object(utils["u" /* parseViscolors */])(viscolor.contents) : constants["c" /* DEFAULT_SKIN */].colors; -} - -async function genImages(zip) { - const imageObjs = await Promise.all(Object.keys(skinSprites["b" /* default */]).map(async fileName => genSpriteUrisFromFilename(zip, fileName))); // Merge all the objects into a single object. Tests assert that sprite keys are unique. - - return shallowMerge(imageObjs); -} - -async function genCursors(zip) { - const cursorObjs = await Promise.all(CURSORS.map(async cursorName => ({ - [cursorName]: await getCursorFromFilename(zip, cursorName) - }))); - return shallowMerge(cursorObjs); -} - -async function genRegion(zip) { - const region = await genFileFromZip(zip, "REGION", "txt", "text"); - return region ? regionParser(region.contents) : {}; -} - -async function genGenTextSprites(zip) { - const img = await genImgFromFilename(zip, "GEN"); - - if (img == null) { - return null; - } - - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - canvas.width = img.width; - canvas.height = img.height; - context.drawImage(img, 0, 0); - - const getLetters = (y, prefix) => { - const getColorAt = x => context.getImageData(x, y, 1, 1).data.join(","); - - let x = 1; - const backgroundColor = getColorAt(0); - const height = 7; - return constants["d" /* LETTERS */].map(letter => { - let nextBackground = x; - - while (getColorAt(nextBackground) !== backgroundColor && nextBackground < canvas.width) { - nextBackground++; - } - - const width = nextBackground - x; - const name = `${prefix}_${letter}`; - const sprite = { - x, - y, - height, - width, - name - }; - x = nextBackground + 1; - return sprite; - }); - }; - - const letterWidths = {}; - const sprites = [...getLetters(88, "GEN_TEXT_SELECTED"), ...getLetters(96, "GEN_TEXT")]; - sprites.forEach(sprite => { - letterWidths[sprite.name] = sprite.width; - }); - return [letterWidths, getSpriteUrisFromImg(img, sprites)]; -} - -async function genGenExColors(zip) { - const img = await genImgFromFilename(zip, "GENEX"); - - if (img == null) { - return null; - } - - const canvas = document.createElement("canvas"); - const context = canvas.getContext("2d"); - canvas.width = img.width; - canvas.height = img.height; - context.drawImage(img, 0, 0); - - const getColorAt = x => `rgb(${context.getImageData(x, 0, 1, 1) // Discard the alpha channel - .data.slice(0, 3).join(",")})`; - - const colors = { - // (1) x=48: item background (background to edits, listviews, etc.) - itemBackground: 48, - // (2) x=50: item foreground (text colour of edits, listviews, etc.) - itemForeground: 50, - // (3) x=52: window background (used to set the bg color for the dialog) - windowBackground: 52, - // (4) x=54: button text colour - buttonText: 54, - // (5) x=56: window text colour - windowText: 56, - // (6) x=58: colour of dividers and sunken borders - divider: 58, - // (7) x=60: selection colour for entries inside playlists (nothing else yet) - playlistSelection: 60, - // (8) x=62: listview header background colour - listHeaderBackground: 62, - // (9) x=64: listview header text colour - listHeaderText: 64, - // (10) x=66: listview header frame top and left colour - listHeaderFrameTopAndLeft: 66, - // (11) x=68: listview header frame bottom and right colour - listHeaderFrameBottomAndRight: 68, - // (12) x=70: listview header frame colour, when pressed - listHeaderFramePressed: 70, - // (13) x=72: listview header dead area colour - listHeaderDeadArea: 72, - // (14) x=74: scrollbar colour #1 - scrollbarOne: 74, - // (15) x=76: scrollbar colour #2 - scrollbarTwo: 76, - // (16) x=78: pressed scrollbar colour #1 - pressedScrollbarOne: 78, - // (17) x=80: pressed scrollbar colour #2 - pressedScrollbarTwo: 80, - // (18) x=82: scrollbar dead area colour - scrollbarDeadArea: 82, - // (19) x=84 List view text colour highlighted - listTextHighlighted: 84, - // (20) x=86 List view background colour highlighted - listTextHighlightedBackground: 86, - // (21) x=88 List view text colour selected - listTextSelected: 88, - // (22) x=90 List view background colour selected - listTextSelectedBackground: 90 - }; - return Object(utils["s" /* objectMap */])(colors, getColorAt); -} // A promise that, given an array buffer returns a skin style object - - -async function skinParser(zipFileBuffer, JSZip) { - const zip = await JSZip.loadAsync(zipFileBuffer); - - const _ref = await Promise.all([genVizColors(zip), genPlaylistStyle(zip), genImages(zip), genCursors(zip), genRegion(zip), genGenTextSprites(zip), genGenExColors(zip)]), - _ref2 = slicedToArray_default()(_ref, 7), - colors = _ref2[0], - playlistStyle = _ref2[1], - images = _ref2[2], - cursors = _ref2[3], - region = _ref2[4], - genTextSprites = _ref2[5], - genExColors = _ref2[6]; - - const _ref3 = genTextSprites || [null, {}], - _ref4 = slicedToArray_default()(_ref3, 2), - genLetterWidths = _ref4[0], - genTextImages = _ref4[1]; - - return { - colors, - playlistStyle, - images: objectSpread_default()({}, images, genTextImages), - genLetterWidths, - cursors, - region, - genExColors - }; -} - -/* harmony default export */ var js_skinParser = (skinParser); -// EXTERNAL MODULE: ./node_modules/invariant/browser.js -var browser = __webpack_require__(52); -var browser_default = /*#__PURE__*/__webpack_require__.n(browser); - -// EXTERNAL MODULE: ./node_modules/tinyqueue/index.js -var tinyqueue = __webpack_require__(127); -var tinyqueue_default = /*#__PURE__*/__webpack_require__.n(tinyqueue); - -// CONCATENATED MODULE: ./js/loadQueue.js - - // Push promises onto a queue with a priority. -// Run a given number of jobs in parallel -// Useful for prioritizing network requests - -class loadQueue_LoadQueue { - constructor(_ref) { - let threads = _ref.threads; - // TODO: Consider not running items with zero priority - // Priority is a function so that items can change their priority between - // when their priority is evaluated. - // For example, we might add a track to the playlist and then scroll to/away - // from it before it gets processed. - this._queue = new tinyqueue_default.a([], (a, b) => a.priority() - b.priority()); - this._availableThreads = threads; - } - - push(task, priority) { - const t = { - task, - priority - }; - - this._queue.push(t); // Wait until the next event loop to pick a task to run. This way, we can - // enqueue multiple items in an event loop, and be sure they will be run in - // priority order. - - - setTimeout(() => { - this._run(); - }, 0); - return () => { - // TODO: Could return a boolean representing if the task has already been - // kicked off. - this._queue = this._queue.filter(t1 => t1 !== t); - }; - } - - _run() { - while (this._availableThreads > 0) { - if (this._queue.length === 0) { - return; - } - - this._availableThreads--; - - const t = this._queue.pop(); - - const promise = t.task(); - browser_default()(typeof promise.then === "function", `LoadQueue only supports loading Promises. Got ${promise}`); - promise.then(() => { - this._availableThreads++; - - this._run(); - }); - } - } - -} -// CONCATENATED MODULE: ./js/actionCreators/playlist.ts - - - - -function cropPlaylist() { - return (dispatch, getState) => { - const state = getState(); - - if (selectors["L" /* getSelectedTrackObjects */](state).length === 0) { - return; - } - - const selectedTrackIds = selectors["K" /* getSelectedTrackIds */](state); - const trackOrder = state.playlist.trackOrder; - dispatch({ - type: actionTypes["H" /* REMOVE_TRACKS */], - // @ts-ignore The keys are numbers, but TypeScript does not trust us. - // https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208 - ids: trackOrder.filter(id => !selectedTrackIds.has(id)) - }); - }; -} -function removeSelectedTracks() { - return (dispatch, getState) => { - dispatch({ - type: actionTypes["H" /* REMOVE_TRACKS */], - // @ts-ignore The keys are numbers, but TypeScript does not trust us. - // https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208 - ids: Array.from(selectors["K" /* getSelectedTrackIds */](getState())) - }); - }; -} -function removeAllTracks() { - return dispatch => { - // It's a bit funky that we need to do both of these. - dispatch({ - type: actionTypes["qb" /* STOP */] - }); - dispatch({ - type: actionTypes["G" /* REMOVE_ALL_TRACKS */] - }); - }; -} -function reverseList() { - return { - type: actionTypes["K" /* REVERSE_LIST */] - }; -} -function randomizeList() { - return { - type: actionTypes["F" /* RANDOMIZE_LIST */] - }; -} -function sortListByTitle() { - return (dispatch, getState) => { - const state = getState(); - const tracks = selectors["W" /* getTracks */](state); - const trackOrder = Object(utils["A" /* sort */])(selectors["U" /* getTrackOrder */](state), i => `${tracks[i].title}`.toLowerCase()); - return dispatch({ - type: actionTypes["ib" /* SET_TRACK_ORDER */], - trackOrder - }); - }; -} -function setPlaylistScrollPosition(position) { - return { - type: actionTypes["fb" /* SET_PLAYLIST_SCROLL_POSITION */], - position - }; -} -function scrollNTracks(n) { - return (dispatch, getState) => { - const state = getState(); - const overflow = selectors["z" /* getOverflowTrackCount */](state); - const currentOffset = selectors["J" /* getScrollOffset */](state); - const position = overflow ? Object(utils["d" /* clamp */])((currentOffset + n) / overflow, 0, 1) : 0; - return dispatch({ - type: actionTypes["fb" /* SET_PLAYLIST_SCROLL_POSITION */], - position: position * 100 - }); - }; -} -function scrollPlaylistByDelta(e) { - e.preventDefault(); - return (dispatch, getState) => { - const state = getState(); - - if (selectors["z" /* getOverflowTrackCount */](state)) { - e.stopPropagation(); - } - - const totalPixelHeight = state.playlist.trackOrder.length * constants["i" /* TRACK_HEIGHT */]; - const percentDelta = e.deltaY / totalPixelHeight * 100; - dispatch({ - type: actionTypes["fb" /* SET_PLAYLIST_SCROLL_POSITION */], - position: Object(utils["d" /* clamp */])(state.display.playlistScrollPosition + percentDelta, 0, 100) - }); - }; -} -function scrollUpFourTracks() { - return scrollNTracks(-4); -} -function scrollDownFourTracks() { - return scrollNTracks(4); -} -function dragSelected(offset) { - return (dispatch, getState) => { - const state = getState(); - const tracks = selectors["W" /* getTracks */](state); - const trackOrder = selectors["U" /* getTrackOrder */](state); - const selectedIds = selectors["K" /* getSelectedTrackIds */](state); - const firstSelected = trackOrder.findIndex(trackId => tracks[trackId] && selectedIds.has(trackId)); - - if (firstSelected === -1) { - return; - } - - const lastSelected = Object(utils["g" /* findLastIndex */])(trackOrder, trackId => tracks[trackId] && selectedIds.has(trackId)); - - if (lastSelected === -1) { - throw new Error("We found a first selected, but not a last selected."); - } // Ensure we don't try to drag off either end. - - - const min = -firstSelected; - const max = trackOrder.length - 1 - lastSelected; - const normalizedOffset = Object(utils["d" /* clamp */])(offset, min, max); - - if (normalizedOffset !== 0) { - dispatch({ - type: actionTypes["j" /* DRAG_SELECTED */], - offset: normalizedOffset - }); - } - }; -} -// CONCATENATED MODULE: ./js/actionCreators/files.ts - - - - - - - - - - -// Lower is better -const DURATION_VISIBLE_PRIORITY = 5; -const META_DATA_VISIBLE_PRIORITY = 10; -const DURATION_PRIORITY = 15; -const META_DATA_PRIORITY = 20; -const loadQueue = new loadQueue_LoadQueue({ - threads: 4 -}); -function addTracksFromReferences(fileReferences, loadStyle, atIndex) { - const tracks = Array.from(fileReferences).map(file => ({ - blob: file, - defaultName: file.name - })); - return loadMediaFiles(tracks, loadStyle, atIndex); -} -const SKIN_FILENAME_MATCHER = new RegExp("(wsz|zip)$", "i"); -const EQF_FILENAME_MATCHER = new RegExp("eqf$", "i"); -function loadFilesFromReferences(fileReferences) { - let loadStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : constants["e" /* LOAD_STYLE */].PLAY; - let atIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; - return dispatch => { - if (fileReferences.length < 1) { - return; - } else if (fileReferences.length === 1) { - const fileReference = fileReferences[0]; - - if (SKIN_FILENAME_MATCHER.test(fileReference.name)) { - dispatch(setSkinFromFileReference(fileReference)); - return; - } else if (EQF_FILENAME_MATCHER.test(fileReference.name)) { - dispatch(setEqFromFileReference(fileReference)); - return; - } - } - - dispatch(addTracksFromReferences(fileReferences, loadStyle, atIndex)); - }; -} -function setSkinFromArrayBuffer(arrayBuffer) { - return async (dispatch, getState, _ref) => { - let requireJSZip = _ref.requireJSZip; - - if (!requireJSZip) { - alert("Webamp has not been configured to support custom skins."); - return; - } - - dispatch({ - type: actionTypes["s" /* LOADING */] - }); - let JSZip; - - try { - JSZip = await requireJSZip(); - } catch (e) { - console.error(e); - dispatch({ - type: actionTypes["r" /* LOADED */] - }); - alert("Failed to load the skin parser."); - return; - } - - try { - const skinData = await js_skinParser(arrayBuffer, JSZip); // @ts-ignore TODO: We still need to type skinParser. - - dispatch({ - type: actionTypes["hb" /* SET_SKIN_DATA */], - data: { - skinImages: skinData.images, - skinColors: skinData.colors, - skinPlaylistStyle: skinData.playlistStyle, - skinCursors: skinData.cursors, - skinRegion: skinData.region, - skinGenLetterWidths: skinData.genLetterWidths, - skinGenExColors: skinData.genExColors - } - }); - } catch (e) { - console.error(e); - dispatch({ - type: actionTypes["r" /* LOADED */] - }); - alert(`Failed to parse skin`); - } - }; -} -function setSkinFromFileReference(skinFileReference) { - return async dispatch => { - dispatch({ - type: actionTypes["s" /* LOADING */] - }); - const arrayBuffer = await Object(fileUtils["b" /* genArrayBufferFromFileReference */])(skinFileReference); - dispatch(setSkinFromArrayBuffer(arrayBuffer)); - }; -} -function setSkinFromUrl(url) { - return async dispatch => { - dispatch({ - type: actionTypes["s" /* LOADING */] - }); - - try { - const response = await fetch(url); - - if (!response.ok) { - throw new Error(response.statusText); - } - - dispatch(setSkinFromArrayBuffer(response.arrayBuffer())); - } catch (e) { - console.error(e); - dispatch({ - type: actionTypes["r" /* LOADED */] - }); - alert(`Failed to download skin from ${url}`); - } - }; -} // This function is private, since Winamp consumers can provide means for -// opening files via other methods. Only use the file type specific -// versions below, since they can defer to the user-defined behavior. - -function _openFileDialog(accept) { - return async dispatch => { - const fileReferences = await Object(fileUtils["f" /* promptForFileReferences */])({ - accept - }); - dispatch(loadFilesFromReferences(fileReferences)); - }; -} - -function openEqfFileDialog() { - return _openFileDialog(".eqf"); -} -function openMediaFileDialog() { - return _openFileDialog(null); -} -function openSkinFileDialog() { - return _openFileDialog(".zip, .wsz"); -} -function fetchMediaDuration(url, id) { - return (dispatch, getState) => { - loadQueue.push(async () => { - try { - const duration = await Object(fileUtils["c" /* genMediaDuration */])(url); - dispatch({ - type: actionTypes["bb" /* SET_MEDIA_DURATION */], - duration, - id - }); - } catch (e) {// TODO: Should we update the state to indicate that we don't know the length? - } - }, () => { - const trackIsVisible = Object(selectors["T" /* getTrackIsVisibleFunction */])(getState()); - return trackIsVisible(id) ? DURATION_VISIBLE_PRIORITY : DURATION_PRIORITY; - }); - }; -} -function loadMediaFiles(tracks) { - let loadStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : constants["e" /* LOAD_STYLE */].NONE; - let atIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - return dispatch => { - if (loadStyle === constants["e" /* LOAD_STYLE */].PLAY) { - // I'm the worst. It just so happens that in every case that we autoPlay, - // we should also clear all tracks. - dispatch(removeAllTracks()); - } - - tracks.forEach((track, i) => { - const priority = i === 0 ? loadStyle : constants["e" /* LOAD_STYLE */].NONE; - dispatch(loadMediaFile(track, priority, atIndex + i)); - }); - }; -} -function loadMediaFile(track) { - let priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : constants["e" /* LOAD_STYLE */].NONE; - let atIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - return dispatch => { - const id = utils["C" /* uniqueId */](); - const defaultName = track.defaultName, - metaData = track.metaData, - duration = track.duration; - let canonicalUrl; - - if ("url" in track) { - canonicalUrl = track.url.toString(); - } else if ("blob" in track) { - canonicalUrl = URL.createObjectURL(track.blob); - } else { - throw new Error("Expected track to have either a blob or a url"); - } - - dispatch({ - type: actionTypes["a" /* ADD_TRACK_FROM_URL */], - url: canonicalUrl, - duration: track.duration, - defaultName, - id, - atIndex - }); - - switch (priority) { - case constants["e" /* LOAD_STYLE */].BUFFER: - dispatch({ - type: actionTypes["c" /* BUFFER_TRACK */], - id - }); - break; - - case constants["e" /* LOAD_STYLE */].PLAY: - dispatch({ - type: actionTypes["D" /* PLAY_TRACK */], - id - }); - break; - - case constants["e" /* LOAD_STYLE */].NONE: - default: - // If we're not going to load this right away, - // we should set duration on our own - if (duration != null) { - dispatch({ - type: actionTypes["bb" /* SET_MEDIA_DURATION */], - duration, - id - }); - } else { - dispatch(fetchMediaDuration(canonicalUrl, id)); - } - - } - - if (metaData != null) { - const artist = metaData.artist, - title = metaData.title, - album = metaData.album; - dispatch({ - type: actionTypes["cb" /* SET_MEDIA_TAGS */], - artist, - title, - album, - // For now, we lie about these next three things. - // TODO: Ideally we would leave these as null and force a media data - // fetch when the user starts playing. - sampleRate: 44000, - bitrate: 192000, - numberOfChannels: 2, - id - }); - } else if ("blob" in track) { - // Blobs can be loaded quickly - dispatch(fetchMediaTags(track.blob, id)); - } else { - dispatch(queueFetchingMediaTags(id)); - } - }; -} - -function queueFetchingMediaTags(id) { - return (dispatch, getState) => { - const track = Object(selectors["W" /* getTracks */])(getState())[id]; - loadQueue.push(() => dispatch(fetchMediaTags(track.url, id)), () => { - const trackIsVisible = Object(selectors["T" /* getTrackIsVisibleFunction */])(getState()); - return trackIsVisible(id) ? META_DATA_VISIBLE_PRIORITY : META_DATA_PRIORITY; - }); - }; -} - -function fetchMediaTags(file, id) { - return async (dispatch, getState, _ref2) => { - let requireMusicMetadata = _ref2.requireMusicMetadata; - dispatch({ - type: actionTypes["w" /* MEDIA_TAG_REQUEST_INITIALIZED */], - id - }); - - try { - const metadata = await Object(fileUtils["d" /* genMediaTags */])(file, (await requireMusicMetadata())); // There's more data here, but we don't have a use for it yet: - - const _metadata$common = metadata.common, - artist = _metadata$common.artist, - title = _metadata$common.title, - album = _metadata$common.album, - picture = _metadata$common.picture; - const _metadata$format = metadata.format, - numberOfChannels = _metadata$format.numberOfChannels, - bitrate = _metadata$format.bitrate, - sampleRate = _metadata$format.sampleRate; - let albumArtUrl = null; - - if (picture && picture.length >= 1) { - const byteArray = new Uint8Array(picture[0].data); - const blob = new Blob([byteArray], { - type: picture[0].format - }); - albumArtUrl = URL.createObjectURL(blob); - } - - dispatch({ - type: actionTypes["cb" /* SET_MEDIA_TAGS */], - artist: artist ? artist : "", - title: title ? title : "", - album, - albumArtUrl, - numberOfChannels, - bitrate, - sampleRate, - id - }); - } catch (e) { - dispatch({ - type: actionTypes["v" /* MEDIA_TAG_REQUEST_FAILED */], - id - }); - } - }; -} -function setEqFromFileReference(fileReference) { - return async dispatch => { - const arrayBuffer = await Object(fileUtils["b" /* genArrayBufferFromFileReference */])(fileReference); - const eqf = Object(winamp_eqf["parser"])(arrayBuffer); - const preset = eqf.presets[0]; - dispatch(setEqFromObject(preset)); - }; -} -function setEqFromObject(preset) { - return dispatch => { - dispatch(setPreamp(utils["p" /* normalizeEqBand */](preset.preamp))); - constants["a" /* BANDS */].forEach(band => { - // @ts-ignore band and EqfPreset align - dispatch(setEqBand(band, utils["p" /* normalizeEqBand */](preset[`hz${band}`]))); - }); - }; -} -function downloadPreset() { - return (dispatch, getState) => { - const state = getState(); - const data = Object(selectors["m" /* getEqfData */])(state); - const arrayBuffer = Object(winamp_eqf["creator"])(data); - const base64 = utils["b" /* base64FromArrayBuffer */](arrayBuffer); - const dataURI = `data:application/zip;base64,${base64}`; - utils["f" /* downloadURI */](dataURI, "entry.eqf"); - }; -} -function downloadHtmlPlaylist() { - return (dispatch, getState) => { - const uri = Object(selectors["B" /* getPlaylistURL */])(getState()); - utils["f" /* downloadURI */](uri, "Winamp Playlist.html"); - }; -} -// EXTERNAL MODULE: ./js/types.ts -var types = __webpack_require__(21); - -// CONCATENATED MODULE: ./js/actionCreators/milkdrop.ts - - - - - -function normalizePresetTypes(preset) { - const name = preset.name; - - if ("butterchurnPresetObject" in preset) { - return { - type: "RESOLVED", - name, - preset: preset.butterchurnPresetObject - }; - } else if ("getButterchrunPresetObject" in preset) { - return { - type: "UNRESOLVED", - name, - getPreset: preset.getButterchrunPresetObject - }; - } else if ("butterchurnPresetUrl" in preset) { - return { - type: "UNRESOLVED", - name, - getPreset: async () => { - const resp = await fetch(preset.butterchurnPresetUrl); - return resp.json(); - } - }; - } - - throw new Error("Invalid preset object"); -} - -function initializePresets(presetOptions) { - return async dispatch => { - const getPresets = presetOptions.getPresets, - importButterchurn = presetOptions.importButterchurn; - importButterchurn().then(butterchurn => { - dispatch({ - type: actionTypes["m" /* GOT_BUTTERCHURN */], - butterchurn: butterchurn.default - }); - }); - const presets = await getPresets(); - const normalizePresets = presets.map(normalizePresetTypes); - dispatch(loadPresets(normalizePresets)); - }; -} -function loadPresets(presets) { - return (dispatch, getState) => { - const state = getState(); - const presetsLength = state.milkdrop.presets.length; - dispatch({ - type: actionTypes["n" /* GOT_BUTTERCHURN_PRESETS */], - presets - }); - - if (presetsLength === 0 && selectors["H" /* getRandomizePresets */](state)) { - dispatch(selectRandomPreset()); - } else { - dispatch(requestPresetAtIndex(presetsLength, types["a" /* TransitionType */].IMMEDIATE, true)); - } - }; -} -function appendPresetFileList(fileList) { - return async (dispatch, getState, _ref) => { - let convertPreset = _ref.convertPreset; - const presets = Array.from(fileList).map(file => { - const JSON_EXT = ".json"; - const MILK_EXT = ".milk"; - const filename = file.name.toLowerCase(); - - if (filename.endsWith(MILK_EXT)) { - if (convertPreset == null) { - throw new Error("Invalid type"); - } - - return { - type: "UNRESOLVED", - name: file.name.slice(0, file.name.length - MILK_EXT.length), - getPreset: () => convertPreset(file) - }; - } else if (filename.endsWith(JSON_EXT)) { - return { - type: "UNRESOLVED", - name: file.name.slice(0, file.name.length - JSON_EXT.length), - getPreset: async () => { - const str = await fileUtils["e" /* genStringFromFileReference */](file); // TODO: How should we handle the case where json parsing fails? - - return JSON.parse(str); - } - }; - } else { - throw new Error("Invalid type"); - } - - return null; - }).filter(Boolean); - dispatch(loadPresets(presets)); - }; -} -function selectNextPreset() { - let transitionType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : types["a" /* TransitionType */].DEFAULT; - return (dispatch, getState) => { - const state = getState(); - - if (selectors["H" /* getRandomizePresets */](state)) { - return dispatch(selectRandomPreset(transitionType)); - } - - const currentPresetIndex = selectors["f" /* getCurrentPresetIndex */](state); - - if (currentPresetIndex == null) { - return; - } - - const nextPresetIndex = currentPresetIndex + 1; - dispatch(requestPresetAtIndex(nextPresetIndex, transitionType, true)); - }; -} -function selectPreviousPreset() { - let transitionType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : types["a" /* TransitionType */].DEFAULT; - return (dispatch, getState) => { - const state = getState(); - const presetHistory = state.milkdrop.presetHistory; - - if (presetHistory.length < 1) { - return; - } // Awkward. We do -2 becuase the the last track is the current track. - - - const lastPresetIndex = presetHistory[presetHistory.length - 2]; - dispatch(requestPresetAtIndex(lastPresetIndex, transitionType, false)); - }; -} -function selectRandomPreset() { - let transitionType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : types["a" /* TransitionType */].DEFAULT; - return (dispatch, getState) => { - const state = getState(); // TODO: Make this a selector. - - const randomIndex = Math.floor(Math.random() * state.milkdrop.presets.length); - dispatch(requestPresetAtIndex(randomIndex, transitionType, true)); - }; -} // TODO: Technically there's a race here. If you request two presets in a row, the -// first one may resolve before the second. - -function requestPresetAtIndex(index, transitionType, addToHistory) { - return async (dispatch, getState) => { - const state = getState(); - const preset = state.milkdrop.presets[index]; - - if (preset == null) { - // Index might be out of range. - return; - } - - dispatch({ - type: actionTypes["E" /* PRESET_REQUESTED */], - index, - addToHistory - }); - - switch (preset.type) { - case "RESOLVED": - dispatch({ - type: actionTypes["O" /* SELECT_PRESET_AT_INDEX */], - index, - transitionType - }); - return; - - case "UNRESOLVED": - const json = await preset.getPreset(); // TODO: Ensure that this works correctly even if requests resolve out of order - - dispatch({ - type: actionTypes["J" /* RESOLVE_PRESET_AT_INDEX */], - index, - json - }); - dispatch({ - type: actionTypes["O" /* SELECT_PRESET_AT_INDEX */], - index, - transitionType - }); - return; - } - }; -} -function handlePresetDrop(e) { - return appendPresetFileList(e.dataTransfer.files); -} -function togglePresetOverlay() { - return { - type: actionTypes["vb" /* TOGGLE_PRESET_OVERLAY */] - }; -} -function toggleRandomizePresets() { - return { - type: actionTypes["wb" /* TOGGLE_RANDOMIZE_PRESETS */] - }; -} -function togglePresetCycling() { - return { - type: actionTypes["ub" /* TOGGLE_PRESET_CYCLING */] - }; -} -function scheduleMilkdropMessage(message) { - return { - type: actionTypes["L" /* SCHEDULE_MILKDROP_MESSAGE */], - message - }; -} -// CONCATENATED MODULE: ./js/actionCreators/index.ts -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return actionCreators_close; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return actionCreators_open; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tb", function() { return toggleVisualizerStyle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return minimize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return setFocus; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vb", function() { return unsetFocus; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return loadSerializedState; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return loadDefaultSkin; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kb", function() { return toggleMilkdropDesktop; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return setMilkdropFullscreen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lb", function() { return toggleMilkdropFullscreen; }); -/* concated harmony reexport toggleDoubleSizeMode */__webpack_require__.d(__webpack_exports__, "gb", function() { return toggleDoubleSizeMode; }); -/* concated harmony reexport toggleEqualizerShadeMode */__webpack_require__.d(__webpack_exports__, "ib", function() { return toggleEqualizerShadeMode; }); -/* concated harmony reexport togglePlaylistShadeMode */__webpack_require__.d(__webpack_exports__, "mb", function() { return togglePlaylistShadeMode; }); -/* concated harmony reexport closeWindow */__webpack_require__.d(__webpack_exports__, "g", function() { return closeWindow; }); -/* unused concated harmony import hideWindow */ -/* unused concated harmony import showWindow */ -/* concated harmony reexport setWindowSize */__webpack_require__.d(__webpack_exports__, "cb", function() { return setWindowSize; }); -/* concated harmony reexport toggleWindow */__webpack_require__.d(__webpack_exports__, "ub", function() { return toggleWindow; }); -/* concated harmony reexport updateWindowPositions */__webpack_require__.d(__webpack_exports__, "wb", function() { return updateWindowPositions; }); -/* concated harmony reexport toggleMainWindowShadeMode */__webpack_require__.d(__webpack_exports__, "jb", function() { return toggleMainWindowShadeMode; }); -/* concated harmony reexport centerWindowsInContainer */__webpack_require__.d(__webpack_exports__, "e", function() { return centerWindowsInContainer; }); -/* unused concated harmony import centerWindowsInView */ -/* unused concated harmony import resetWindowSizes */ -/* concated harmony reexport browserWindowSizeChanged */__webpack_require__.d(__webpack_exports__, "d", function() { return browserWindowSizeChanged; }); -/* unused concated harmony import ensureWindowsAreOnScreen */ -/* concated harmony reexport stackWindows */__webpack_require__.d(__webpack_exports__, "eb", function() { return stackWindows; }); -/* unused concated harmony import toggleLlamaMode */ -/* unused concated harmony import setFocusedWindow */ -/* concated harmony reexport play */__webpack_require__.d(__webpack_exports__, "z", function() { return play; }); -/* concated harmony reexport pause */__webpack_require__.d(__webpack_exports__, "y", function() { return pause; }); -/* concated harmony reexport stop */__webpack_require__.d(__webpack_exports__, "fb", function() { return stop; }); -/* concated harmony reexport nextN */__webpack_require__.d(__webpack_exports__, "t", function() { return nextN; }); -/* concated harmony reexport next */__webpack_require__.d(__webpack_exports__, "s", function() { return next; }); -/* concated harmony reexport previous */__webpack_require__.d(__webpack_exports__, "A", function() { return previous; }); -/* concated harmony reexport seekForward */__webpack_require__.d(__webpack_exports__, "M", function() { return seekForward; }); -/* concated harmony reexport seekBackward */__webpack_require__.d(__webpack_exports__, "L", function() { return seekBackward; }); -/* concated harmony reexport setVolume */__webpack_require__.d(__webpack_exports__, "bb", function() { return setVolume; }); -/* concated harmony reexport adjustVolume */__webpack_require__.d(__webpack_exports__, "b", function() { return adjustVolume; }); -/* concated harmony reexport scrollVolume */__webpack_require__.d(__webpack_exports__, "K", function() { return scrollVolume; }); -/* concated harmony reexport setBalance */__webpack_require__.d(__webpack_exports__, "Q", function() { return setBalance; }); -/* concated harmony reexport toggleRepeat */__webpack_require__.d(__webpack_exports__, "qb", function() { return toggleRepeat; }); -/* concated harmony reexport toggleShuffle */__webpack_require__.d(__webpack_exports__, "rb", function() { return toggleShuffle; }); -/* concated harmony reexport toggleTimeMode */__webpack_require__.d(__webpack_exports__, "sb", function() { return toggleTimeMode; }); -/* concated harmony reexport setEqBand */__webpack_require__.d(__webpack_exports__, "R", function() { return setEqBand; }); -/* concated harmony reexport setEqToMax */__webpack_require__.d(__webpack_exports__, "T", function() { return setEqToMax; }); -/* concated harmony reexport setEqToMid */__webpack_require__.d(__webpack_exports__, "U", function() { return setEqToMid; }); -/* concated harmony reexport setEqToMin */__webpack_require__.d(__webpack_exports__, "V", function() { return setEqToMin; }); -/* concated harmony reexport setPreamp */__webpack_require__.d(__webpack_exports__, "Z", function() { return setPreamp; }); -/* concated harmony reexport toggleEq */__webpack_require__.d(__webpack_exports__, "hb", function() { return toggleEq; }); -/* unused concated harmony import toggleEqAuto */ -/* concated harmony reexport addTracksFromReferences */__webpack_require__.d(__webpack_exports__, "a", function() { return addTracksFromReferences; }); -/* concated harmony reexport loadFilesFromReferences */__webpack_require__.d(__webpack_exports__, "o", function() { return loadFilesFromReferences; }); -/* unused concated harmony import setSkinFromArrayBuffer */ -/* unused concated harmony import setSkinFromFileReference */ -/* concated harmony reexport setSkinFromUrl */__webpack_require__.d(__webpack_exports__, "ab", function() { return setSkinFromUrl; }); -/* concated harmony reexport openEqfFileDialog */__webpack_require__.d(__webpack_exports__, "v", function() { return openEqfFileDialog; }); -/* concated harmony reexport openMediaFileDialog */__webpack_require__.d(__webpack_exports__, "w", function() { return openMediaFileDialog; }); -/* concated harmony reexport openSkinFileDialog */__webpack_require__.d(__webpack_exports__, "x", function() { return openSkinFileDialog; }); -/* unused concated harmony import fetchMediaDuration */ -/* concated harmony reexport loadMediaFiles */__webpack_require__.d(__webpack_exports__, "p", function() { return loadMediaFiles; }); -/* unused concated harmony import loadMediaFile */ -/* unused concated harmony import fetchMediaTags */ -/* unused concated harmony import setEqFromFileReference */ -/* concated harmony reexport downloadPreset */__webpack_require__.d(__webpack_exports__, "j", function() { return downloadPreset; }); -/* concated harmony reexport setEqFromObject */__webpack_require__.d(__webpack_exports__, "S", function() { return setEqFromObject; }); -/* concated harmony reexport downloadHtmlPlaylist */__webpack_require__.d(__webpack_exports__, "i", function() { return downloadHtmlPlaylist; }); -/* concated harmony reexport cropPlaylist */__webpack_require__.d(__webpack_exports__, "h", function() { return cropPlaylist; }); -/* concated harmony reexport removeSelectedTracks */__webpack_require__.d(__webpack_exports__, "D", function() { return removeSelectedTracks; }); -/* concated harmony reexport removeAllTracks */__webpack_require__.d(__webpack_exports__, "C", function() { return removeAllTracks; }); -/* concated harmony reexport reverseList */__webpack_require__.d(__webpack_exports__, "F", function() { return reverseList; }); -/* concated harmony reexport randomizeList */__webpack_require__.d(__webpack_exports__, "B", function() { return randomizeList; }); -/* concated harmony reexport sortListByTitle */__webpack_require__.d(__webpack_exports__, "db", function() { return sortListByTitle; }); -/* concated harmony reexport setPlaylistScrollPosition */__webpack_require__.d(__webpack_exports__, "Y", function() { return setPlaylistScrollPosition; }); -/* unused concated harmony import scrollNTracks */ -/* concated harmony reexport scrollPlaylistByDelta */__webpack_require__.d(__webpack_exports__, "I", function() { return scrollPlaylistByDelta; }); -/* concated harmony reexport scrollUpFourTracks */__webpack_require__.d(__webpack_exports__, "J", function() { return scrollUpFourTracks; }); -/* concated harmony reexport scrollDownFourTracks */__webpack_require__.d(__webpack_exports__, "H", function() { return scrollDownFourTracks; }); -/* concated harmony reexport dragSelected */__webpack_require__.d(__webpack_exports__, "k", function() { return dragSelected; }); -/* concated harmony reexport initializePresets */__webpack_require__.d(__webpack_exports__, "m", function() { return initializePresets; }); -/* concated harmony reexport requestPresetAtIndex */__webpack_require__.d(__webpack_exports__, "E", function() { return requestPresetAtIndex; }); -/* concated harmony reexport selectRandomPreset */__webpack_require__.d(__webpack_exports__, "P", function() { return selectRandomPreset; }); -/* concated harmony reexport selectNextPreset */__webpack_require__.d(__webpack_exports__, "N", function() { return selectNextPreset; }); -/* concated harmony reexport selectPreviousPreset */__webpack_require__.d(__webpack_exports__, "O", function() { return selectPreviousPreset; }); -/* concated harmony reexport togglePresetOverlay */__webpack_require__.d(__webpack_exports__, "ob", function() { return togglePresetOverlay; }); -/* concated harmony reexport appendPresetFileList */__webpack_require__.d(__webpack_exports__, "c", function() { return appendPresetFileList; }); -/* concated harmony reexport handlePresetDrop */__webpack_require__.d(__webpack_exports__, "l", function() { return handlePresetDrop; }); -/* unused concated harmony import loadPresets */ -/* concated harmony reexport toggleRandomizePresets */__webpack_require__.d(__webpack_exports__, "pb", function() { return toggleRandomizePresets; }); -/* concated harmony reexport togglePresetCycling */__webpack_require__.d(__webpack_exports__, "nb", function() { return togglePresetCycling; }); -/* concated harmony reexport scheduleMilkdropMessage */__webpack_require__.d(__webpack_exports__, "G", function() { return scheduleMilkdropMessage; }); - - - - - - - - - - -function actionCreators_close() { - return dispatch => { - // TODO: This could probably be improved by adding a "PREVENT_CLOSE" action - // or something, but this works okay for now. - let defaultPrevented = false; - - const cancel = () => { - defaultPrevented = true; - }; - - dispatch({ - type: actionTypes["e" /* CLOSE_REQUESTED */], - cancel - }); - - if (!defaultPrevented) { - dispatch({ - type: actionTypes["qb" /* STOP */] - }); - dispatch({ - type: actionTypes["f" /* CLOSE_WINAMP */] - }); - } - }; -} -function actionCreators_open() { - return { - type: actionTypes["A" /* OPEN_WINAMP */] - }; -} -function toggleVisualizerStyle() { - return { - type: actionTypes["Ab" /* TOGGLE_VISUALIZER_STYLE */] - }; -} -function minimize() { - return { - type: actionTypes["x" /* MINIMIZE_WINAMP */] - }; -} -function setFocus(input) { - return { - type: actionTypes["Y" /* SET_FOCUS */], - input - }; -} -function unsetFocus() { - return { - type: actionTypes["Db" /* UNSET_FOCUS */] - }; -} -function loadSerializedState( // In the future this type should be the union of all versioned types. -serializedState) { - return dispatch => { - dispatch({ - type: actionTypes["u" /* LOAD_SERIALIZED_STATE */], - serializedState - }); - dispatch(ensureWindowsAreOnScreen()); - }; -} -function loadDefaultSkin() { - return { - type: actionTypes["t" /* LOAD_DEFAULT_SKIN */] - }; -} -function toggleMilkdropDesktop() { - return (dispatch, getState) => { - if (selectors["u" /* getMilkdropDesktopEnabled */](getState())) { - dispatch(showWindow(constants["m" /* WINDOWS */].MILKDROP)); - dispatch({ - type: actionTypes["db" /* SET_MILKDROP_DESKTOP */], - enabled: false - }); - } else { - dispatch(hideWindow(constants["m" /* WINDOWS */].MILKDROP)); - dispatch({ - type: actionTypes["db" /* SET_MILKDROP_DESKTOP */], - enabled: true - }); - } - }; -} -function setMilkdropFullscreen(enabled) { - return { - type: actionTypes["eb" /* SET_MILKDROP_FULLSCREEN */], - enabled - }; -} -function toggleMilkdropFullscreen() { - return (dispatch, getState) => { - dispatch(setMilkdropFullscreen(!selectors["v" /* getMilkdropFullscreenEnabled */](getState()))); - }; -} - -/***/ }), -/* 4 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/objectSpread.js -var objectSpread = __webpack_require__(6); -var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread); - -// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js -var slicedToArray = __webpack_require__(18); -var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray); - -// EXTERNAL MODULE: ./node_modules/reselect/lib/index.js -var lib = __webpack_require__(14); - -// EXTERNAL MODULE: ./js/utils.ts -var utils = __webpack_require__(8); - -// EXTERNAL MODULE: ./js/constants.ts -var constants = __webpack_require__(5); - -// EXTERNAL MODULE: ./node_modules/react/index.js -var react = __webpack_require__(0); -var react_default = /*#__PURE__*/__webpack_require__.n(react); - -// EXTERNAL MODULE: ./node_modules/react-dom/index.js -var react_dom = __webpack_require__(13); - -// CONCATENATED MODULE: ./js/playlistHtml.tsx - - -const getAsDataURI = text => `data:text/html;base64,${window.btoa(text)}`; // Replaces deprecated "noshade" attribute - -const noshadeStyle = { - height: "2px", - borderWidth: 0, - color: "gray", - backgroundColor: "gray" -}; // We use all kinds of non-standard attributes and tags. So we create these fake -// components to trick Typescript. - -const Body = props => { - // @ts-ignore - return react_default.a.createElement("body", props); -}; - -const Font = props => { - // @ts-ignore - return react_default.a.createElement("font", props); -}; - -const Hr = props => { - // @ts-ignore - return react_default.a.createElement("hr", props); -}; - -const Div = props => { - // @ts-ignore - return react_default.a.createElement("div", props); -}; - -const Table = props => { - // @ts-ignore - return react_default.a.createElement("table", props); -}; // TODO: Move tag out to the string creation step in order -// to avoid the warning. - - -const Playlist = props => react_default.a.createElement("html", null, react_default.a.createElement("head", null, react_default.a.createElement("link", { - rel: "stylesheet", - href: "null" -}), react_default.a.createElement("style", { - type: "text/css" -}, ` - body { background: #000040; } - .para1 { margin-top: -42px; margin-left: 145px; margin-right: 10px; font-family: "font2, Arial"; font-size: 30px; line-height: 35px; text-align: left; color: #E1E1E1; } - .para2 { margin-top: 15px; margin-left: 15px; margin-right: 50px; font-family: "font1, Arial Black"; font-size: 50px; line-height: 40px; text-align: left; color: #004080; } - `), react_default.a.createElement("title", null, "Winamp Generated PlayList")), react_default.a.createElement(Body, { - bgcolor: "#000080", - topmargin: "0", - leftmargin: "0", - text: "#FFFFFF" -}, react_default.a.createElement(Div, { - align: "center" -}, react_default.a.createElement(Div, { - className: "para2", - align: "center" -}, react_default.a.createElement("p", null, "WINAMP")), react_default.a.createElement(Div, { - className: "para1", - align: "center" -}, react_default.a.createElement("p", null, "playlist"))), react_default.a.createElement(Hr, { - align: "left", - width: "90%", - size: "1", - color: "#FFBF00", - style: noshadeStyle -}), react_default.a.createElement(Div, { - align: "right" -}, react_default.a.createElement(Table, { - border: "0", - cellSpacing: "0", - cellPadding: "0", - width: "98%" -}, react_default.a.createElement("tbody", null, react_default.a.createElement("tr", null, react_default.a.createElement("td", null, react_default.a.createElement("small", null, react_default.a.createElement("small", null, react_default.a.createElement(Font, { - face: "Arial", - color: "#FFBF00" -}, props.numberOfTracks), react_default.a.createElement(Font, { - color: "#409FFF", - face: "Arial" -}, " track in playlist, average track length: "), react_default.a.createElement(Font, { - face: "Arial", - color: "#FFBF00" -}, props.averageTrackLength))), react_default.a.createElement("br", null), react_default.a.createElement("small", null, react_default.a.createElement("small", null, react_default.a.createElement(Font, { - color: "#409FFF", - face: "Arial" -}, "Playlist length: "), react_default.a.createElement(Font, { - face: "Arial", - color: "#FFBF00" -}, props.playlistLengthMinutes), react_default.a.createElement(Font, { - color: "#409FFF", - face: "Arial" -}, " minutes "), react_default.a.createElement(Font, { - face: "Arial", - color: "#FFBF00" -}, props.playlistLengthSeconds), react_default.a.createElement(Font, { - color: "#409FFF", - face: "Arial" -}, " second "), react_default.a.createElement("br", null), react_default.a.createElement(Font, { - color: "#409FFF", - face: "Arial" -}, "Right-click ", react_default.a.createElement("a", { - href: "./" -}, "here"), " to save this HTML file.")))))))), react_default.a.createElement("blockquote", null, react_default.a.createElement("p", null, react_default.a.createElement(Font, { - color: "#FFBF00", - face: "Arial" -}, react_default.a.createElement("big", null, "Playlist files:"))), react_default.a.createElement("ul", null, react_default.a.createElement(Font, { - face: "Arial", - color: "#FFFFFF" -}, react_default.a.createElement("small", null, props.tracks.map(track => react_default.a.createElement("span", { - key: track -}, track, react_default.a.createElement("br", null))))))), react_default.a.createElement(Hr, { - align: "left", - width: "90%", - size: "1", - color: "#FFBF00", - style: noshadeStyle -}))); - -const createPlaylistHTML = props => { - const node = document.createElement("div"); - Object(react_dom["render"])(react_default.a.createElement(Playlist, props), node); - return node.innerHTML; -}; - -const createPlaylistURL = props => getAsDataURI(createPlaylistHTML(props)); -// EXTERNAL MODULE: ./js/reducers/tracks.ts -var reducers_tracks = __webpack_require__(70); - -// EXTERNAL MODULE: ./js/reducers/display.ts -var display = __webpack_require__(58); - -// EXTERNAL MODULE: ./js/reducers/equalizer.ts -var equalizer = __webpack_require__(69); - -// EXTERNAL MODULE: ./js/reducers/media.ts -var media = __webpack_require__(68); - -// EXTERNAL MODULE: ./js/reducers/windows.ts -var reducers_windows = __webpack_require__(30); - -// EXTERNAL MODULE: ./js/trackUtils.ts -var trackUtils = __webpack_require__(71); - -// CONCATENATED MODULE: ./js/marqueeUtils.tsx - -const getBalanceText = balance => { - if (balance === 0) { - return "Balance: Center"; - } - - const direction = balance > 0 ? "Right" : "Left"; - return `Balance: ${Math.abs(balance)}% ${direction}`; -}; -const getVolumeText = volume => `Volume: ${volume}%`; -const getPositionText = (duration, seekToPercent) => { - const newElapsedStr = utils["k" /* getTimeStr */](duration * seekToPercent / 100, false); - const durationStr = utils["k" /* getTimeStr */](duration, false); - return `Seek to: ${newElapsedStr}/${durationStr} (${seekToPercent}%)`; -}; -const getDoubleSizeModeText = enabled => `${enabled ? "Disable" : "Enable"} doublesize mode`; - -const formatHz = hz => hz < 1000 ? `${hz}HZ` : `${hz / 1000}KHZ`; // Format a number as a string, ensuring it has a + or - sign - - -const ensureSign = num => num > 0 ? `+${num}` : num.toString(); // Round to 1 and exactly 1 decimal point - - -const roundToTenths = num => (Math.round(num * 10) / 10).toFixed(1); - -const getEqText = (band, level) => { - const db = roundToTenths((level - 50) / 50 * 12); - const label = band === "preamp" ? "Preamp" : formatHz(band); - return `EQ: ${label} ${ensureSign(db)} DB`; -}; -// EXTERNAL MODULE: ./js/resizeUtils.ts -var resizeUtils = __webpack_require__(72); - -// CONCATENATED MODULE: ./js/selectors.ts -/* unused harmony export getSliders */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return getEqfData; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return getTracks; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return getTracksMatchingFilter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return getTrackUrl; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return getTrackOrder; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return getTrackCount; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return getOrderedTracks; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return getSelectedTrackIds; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return getSelectedTrackObjects; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return getRunningTimeMessage; }); -/* unused harmony export getCurrentTrackIndex */ -/* unused harmony export getCurrentTrackNumber */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return getCurrentTrackId; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mb", function() { return selectors_nextTrack; }); -/* unused harmony export getNumberOfVisibleTracks */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return getOverflowTrackCount; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return getPlaylistScrollPosition; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return getScrollOffset; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return getVisibleTrackIds; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return getTrackIsVisibleFunction; }); -/* unused harmony export getVisibleTracks */ -/* unused harmony export getPlaylist */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return getDuration; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return getTrackDisplayName; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return getCurrentTrackDisplayName; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return getMediaIsPlaying; }); -/* unused harmony export getCurrentTrack */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return getCurrentlyPlayingTrackIdIfLoaded; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return getCurrentTrackInfo; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return getMinimalMediaText; }); -/* unused harmony export getMediaText */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return getNumberOfTracks; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return getPlaylistURL; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jb", function() { return getWindowSize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fb", function() { return getWindowOpen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ib", function() { return getWindowShade; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "eb", function() { return getWindowHidden; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return getFocusedWindow; }); -/* unused harmony export getWindowPosition */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return getPositionsAreRelative; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return getGenWindows; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hb", function() { return getWindowPositions; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return getDoubled; }); -/* unused harmony export getLlamaMode */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kb", function() { return getWindowSizes; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gb", function() { return getWindowPixelSize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lb", function() { return getWindowsInfo; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "db", function() { return getWindowGraph; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return getSkinPlaylistStyle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return getSkinGenExColors; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bb", function() { return getVisualizerStyle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cb", function() { return getVolume; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return getBalance; }); -/* unused harmony export getShuffle */ -/* unused harmony export getRepeat */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getChannels; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return getTimeElapsed; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return getSerlializedState; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return getEqualizerEnabled; }); -/* unused harmony export getEqualizerAuto */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getBrowserWindowSize; }); -/* unused harmony export getOpenWindows */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return getStackedLayoutPositions; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return getUserInputFocus; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return getUserInputScrubPosition; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return getMarqueeText; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return getKbps; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return getKhz; }); -/* unused harmony export getDebugData */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return getMilkdropDesktopEnabled; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return getMilkdropFullscreenEnabled; }); -/* unused harmony export getPresets */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getButterchurn; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return getPresetTransitionType; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return getCurrentPresetIndex; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getCurrentPreset; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return getPresetNames; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return getPresetOverlayOpen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return getPresetsAreCycling; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return getRandomizePresets; }); - - - - - - - - - - - - - - -const getSliders = state => state.equalizer.sliders; -const getEqfData = Object(lib["createSelector"])(getSliders, sliders => { - const preset = { - name: "Entry1", - preamp: utils["e" /* denormalizeEqBand */](sliders.preamp) - }; - constants["a" /* BANDS */].forEach(band => { - preset[`hz${band}`] = utils["e" /* denormalizeEqBand */](sliders[band]); - }); - const eqfData = { - presets: [preset], - type: "Winamp EQ library file v1.1" - }; - return eqfData; -}); -const getTracks = state => state.tracks; -const getTracksMatchingFilter = Object(lib["createSelector"])(getTracks, tracks => { - const tracksArray = Object.values(tracks); - const filter = utils["m" /* makeCachingFilterFunction */](tracksArray, (track, query) => trackUtils["a" /* trackFilterContents */](track).includes(query)); - return filterString => { - return filter(filterString.toLowerCase()); - }; -}); -const getTrackUrl = state => { - return id => { - const track = state.tracks[id]; - return track == null ? null : track.url; - }; -}; -const getTrackOrder = state => state.playlist.trackOrder; -const getTrackCount = Object(lib["createSelector"])(getTrackOrder, trackOrder => trackOrder.length); -const getOrderedTracks = Object(lib["createSelector"])(getTracks, getTrackOrder, (tracks, trackOrder) => trackOrder.filter(id => tracks[id])); -const getOrderedTrackObjects = Object(lib["createSelector"])(getTracks, getOrderedTracks, (tracks, trackOrder) => trackOrder.map(id => tracks[id])); -const getSelectedTrackIds = state => { - return state.playlist.selectedTracks; -}; -const getSelectedTrackObjects = Object(lib["createSelector"])(getOrderedTrackObjects, getSelectedTrackIds, (tracks, selectedIds) => tracks.filter(track => selectedIds.has(track.id))); // If a duration is `null`, it counts as zero, which seems fine enough. - -const runningTimeFromTracks = tracks => tracks.reduce((time, track) => time + Number(track.duration), 0); - -const getTotalRunningTime = Object(lib["createSelector"])(getOrderedTrackObjects, runningTimeFromTracks); -const getSelectedRunningTime = Object(lib["createSelector"])(getSelectedTrackObjects, runningTimeFromTracks); // Note: We should append "+" to these values if some of the tracks are of unknown time. - -const getRunningTimeMessage = Object(lib["createSelector"])(getTotalRunningTime, getSelectedRunningTime, (totalRunningTime, selectedRunningTime) => `${utils["k" /* getTimeStr */](selectedRunningTime)}/${utils["k" /* getTimeStr */](totalRunningTime)}`); // TODO: use slectors to get memoization - -const getCurrentTrackIndex = state => { - const playlist = state.playlist; - - if (playlist.currentTrack == null) { - return -1; - } - - return playlist.trackOrder.indexOf(playlist.currentTrack); -}; -const getCurrentTrackNumber = Object(lib["createSelector"])(getCurrentTrackIndex, currentTrackIndex => currentTrackIndex + 1); -const getCurrentTrackId = state => state.playlist.currentTrack; -const selectors_nextTrack = function nextTrack(state) { - let n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - const trackOrder = state.playlist.trackOrder, - repeat = state.media.repeat; - const trackCount = getTrackCount(state); - - if (trackCount === 0) { - return null; - } - - const currentIndex = getCurrentTrackIndex(state); - let nextIndex = currentIndex + n; - - if (repeat) { - nextIndex = nextIndex % trackCount; - - if (nextIndex < 0) { - // Handle wrapping around backwards - nextIndex += trackCount; - } - - return trackOrder[nextIndex]; - } - - if (currentIndex === trackCount - 1 && n > 0) { - return null; - } else if (currentIndex === 0 && n < 0) { - return null; - } - - nextIndex = utils["d" /* clamp */](nextIndex, 0, trackCount - 1); - return trackOrder[nextIndex]; -}; -const BASE_WINDOW_HEIGHT = 58; -const getNumberOfVisibleTracks = state => { - const playlistSize = getWindowSize(state)("playlist"); - return Math.floor((BASE_WINDOW_HEIGHT + constants["n" /* WINDOW_RESIZE_SEGMENT_HEIGHT */] * playlistSize[1]) / constants["i" /* TRACK_HEIGHT */]); -}; -const getOverflowTrackCount = Object(lib["createSelector"])(getTrackCount, getNumberOfVisibleTracks, (trackCount, numberOfVisibleTracks) => Math.max(0, trackCount - numberOfVisibleTracks)); - -const _getPlaylistScrollPosition = state => state.display.playlistScrollPosition; - -const getPlaylistScrollPosition = Object(lib["createSelector"])(getOverflowTrackCount, _getPlaylistScrollPosition, (overflowTrackCount, playlistScrollPosition) => { - if (overflowTrackCount === 0) { - return 0; - } - - return Math.round(Math.round(overflowTrackCount * playlistScrollPosition / 100) / overflowTrackCount * 100); -}); -const getScrollOffset = Object(lib["createSelector"])(_getPlaylistScrollPosition, getTrackCount, getNumberOfVisibleTracks, (playlistScrollPosition, trackCount, numberOfVisibleTracks) => { - const overflow = Math.max(0, trackCount - numberOfVisibleTracks); - return utils["v" /* percentToIndex */](playlistScrollPosition / 100, overflow + 1); -}); -const getVisibleTrackIds = Object(lib["createSelector"])(getScrollOffset, getTrackOrder, getNumberOfVisibleTracks, (offset, trackOrder, numberOfVisibleTracks) => trackOrder.slice(offset, offset + numberOfVisibleTracks)); -const getTrackIsVisibleFunction = Object(lib["createSelector"])(getVisibleTrackIds, visibleTrackIds => { - return id => visibleTrackIds.includes(id); -}); -const getVisibleTracks = Object(lib["createSelector"])(getVisibleTrackIds, getTracks, (visibleTrackIds, tracks) => visibleTrackIds.map(id => tracks[id])); -const getPlaylist = state => state.playlist; -const getDuration = state => { - const playlist = state.playlist, - tracks = state.tracks; - - if (playlist.currentTrack == null) { - return null; - } - - const currentTrack = tracks[playlist.currentTrack]; - return currentTrack && currentTrack.duration; -}; -const getTrackDisplayName = Object(lib["createSelector"])(getTracks, tracks => { - return trackId => reducers_tracks["b" /* getTrackDisplayName */](tracks, trackId); -}); -const getCurrentTrackDisplayName = Object(lib["createSelector"])(getCurrentTrackId, getTrackDisplayName, (id, getName) => { - return getName(id); -}); -const getMediaIsPlaying = state => state.media.status === constants["f" /* MEDIA_STATUS */].PLAYING; -const getCurrentTrack = Object(lib["createSelector"])(getCurrentTrackId, getTracks, (trackId, tracks) => { - return trackId == null ? null : tracks[trackId]; -}); -const getCurrentlyPlayingTrackIdIfLoaded = Object(lib["createSelector"])(getMediaIsPlaying, getCurrentTrack, (mediaIsPlaying, currentTrack) => { - if (!mediaIsPlaying || !currentTrack || currentTrack.mediaTagsRequestStatus === constants["g" /* MEDIA_TAG_REQUEST_STATUS */].INITIALIZED) { - return null; - } - - return currentTrack.id; -}); -const getCurrentTrackInfo = Object(lib["createSelector"])(getCurrentTrack, track => { - if (track == null) { - return null; - } - - return { - url: track.url, - metaData: { - title: track.title || null, - artist: track.artist || null, - album: track.album || null, - albumArtUrl: track.albumArtUrl || null - } - }; -}); -const getMinimalMediaText = Object(lib["createSelector"])(getCurrentTrackNumber, getCurrentTrackDisplayName, (trackNumber, name) => name == null ? null : `${trackNumber}. ${name}`); -const getMediaText = Object(lib["createSelector"])(getMinimalMediaText, getDuration, (minimalMediaText, duration) => minimalMediaText == null ? null : `${minimalMediaText} (${utils["k" /* getTimeStr */](duration)})`); -const getNumberOfTracks = state => getTrackOrder(state).length; -const getPlaylistDuration = Object(lib["createSelector"])(getTracks, tracks => Object.values(tracks).reduce((total, track) => total + (track.duration || 0), 0)); -const getPlaylistURL = Object(lib["createSelector"])(getNumberOfTracks, getPlaylistDuration, getTrackOrder, getTracks, getTrackDisplayName, (numberOfTracks, playlistDuration, trackOrder, tracks, getDisplayName) => createPlaylistURL({ - numberOfTracks, - averageTrackLength: utils["k" /* getTimeStr */](playlistDuration / numberOfTracks), - // TODO: Handle hours - playlistLengthMinutes: Math.floor(playlistDuration / 60), - playlistLengthSeconds: Math.floor(playlistDuration % 60), - tracks: trackOrder.map((id, i) => `${i + 1}. ${getDisplayName(id)} (${utils["k" /* getTimeStr */](tracks[id].duration)})`) -})); -const WINDOW_HEIGHT = 116; -const SHADE_WINDOW_HEIGHT = 14; - -function getWPixelSize(w, doubled) { - const _w$size = slicedToArray_default()(w.size, 2), - width = _w$size[0], - height = _w$size[1]; - - const doubledMultiplier = doubled && w.canDouble ? 2 : 1; - const pix = { - height: WINDOW_HEIGHT + height * constants["n" /* WINDOW_RESIZE_SEGMENT_HEIGHT */], - width: constants["p" /* WINDOW_WIDTH */] + width * constants["o" /* WINDOW_RESIZE_SEGMENT_WIDTH */] - }; - return { - height: (w.shade ? SHADE_WINDOW_HEIGHT : pix.height) * doubledMultiplier, - width: pix.width * doubledMultiplier - }; -} - -function getWindowSize(state) { - return windowId => state.windows.genWindows[windowId].size; -} -function getWindowOpen(state) { - return windowId => state.windows.genWindows[windowId].open; -} -function getWindowShade(state) { - return windowId => state.windows.genWindows[windowId].shade; -} -function getWindowHidden(state) { - return windowId => state.windows.genWindows[windowId].hidden; -} -function getFocusedWindow(state) { - return state.windows.focused; -} -function getWindowPosition(state) { - return windowId => state.windows.genWindows[windowId].position; -} -function getPositionsAreRelative(state) { - return state.windows.positionsAreRelative; -} -const getGenWindows = state => { - return state.windows.genWindows; -}; -const getWindowPositions = Object(lib["createSelector"])(getGenWindows, windows => utils["s" /* objectMap */](windows, w => w.position)); -function getDoubled(state) { - return state.display.doubled; -} -function getLlamaMode(state) { - return state.display.llama; -} -const getWindowSizes = Object(lib["createSelector"])(getGenWindows, getDoubled, (windows, doubled) => { - return utils["s" /* objectMap */](windows, w => getWPixelSize(w, doubled)); -}); -const getWindowPixelSize = Object(lib["createSelector"])(getWindowSizes, sizes => { - return windowId => sizes[windowId]; -}); // TODO: Now that both size and position are stored on genWindows this seems a bit silly. - -const getWindowsInfo = Object(lib["createSelector"])(getWindowSizes, getWindowPositions, (sizes, positions) => Object.keys(sizes).map(key => objectSpread_default()({ - key -}, sizes[key], positions[key]))); -const getWindowGraph = Object(lib["createSelector"])(getWindowsInfo, resizeUtils["a" /* generateGraph */]); -const getSkinPlaylistStyle = state => { - return state.display.skinPlaylistStyle || { - normal: "#00FF00", - current: "#FFFFFF", - normalbg: "#000000", - selectedbg: "#0000C6", - font: "Arial" - }; -}; -const getSkinGenExColors = state => { - return state.display.skinGenExColors; -}; -const getVisualizerStyle = state => { - const milkdrop = state.windows.genWindows[constants["m" /* WINDOWS */].MILKDROP]; - - if (milkdrop != null && milkdrop.open) { - return constants["k" /* VISUALIZERS */].MILKDROP; - } - - return display["c" /* getVisualizerStyle */](state.display); -}; -const getVolume = state => state.media.volume; -const getBalance = state => state.media.balance; -const getShuffle = state => state.media.shuffle; -const getRepeat = state => state.media.repeat; -const getChannels = Object(lib["createSelector"])(getCurrentTrack, track => { - return track != null ? track.channels || null : null; -}); -const getTimeElapsed = state => { - return state.media.timeElapsed; -}; -function getSerlializedState(state) { - return { - version: 1, - media: media["b" /* getSerializedState */](state.media), - equalizer: equalizer["b" /* getSerializedState */](state.equalizer), - display: display["b" /* getSerializedState */](state.display), - windows: reducers_windows["b" /* getSerializedState */](state.windows) - }; -} -function getEqualizerEnabled(state) { - return state.equalizer.on; -} -function getEqualizerAuto(state) { - return state.equalizer.auto; -} -function getBrowserWindowSize(state) { - return state.windows.browserWindowSize; -} -const getOpenWindows = Object(lib["createSelector"])(getGenWindows, genWindows => utils["q" /* objectFilter */](genWindows, w => w.open)); -const getStackedLayoutPositions = Object(lib["createSelector"])(getOpenWindows, getDoubled, (openWindows, doubled) => { - let offset = 0; - return utils["s" /* objectMap */](openWindows, w => { - const position = { - x: 0, - y: offset - }; - offset += getWPixelSize(w, doubled).height; - return position; - }); -}); -const getUserInputFocus = state => { - return state.userInput.focus; -}; -const getUserInputScrubPosition = state => { - return state.userInput.scrubPosition; -}; // TODO: Make this a reselect selector - -const getMarqueeText = state => { - const defaultText = "Winamp 2.91"; - - if (state.userInput.userMessage != null) { - return state.userInput.userMessage; - } - - switch (getUserInputFocus(state)) { - case "balance": - return getBalanceText(state.media.balance); - - case "volume": - return getVolumeText(state.media.volume); - - case "position": - const duration = getDuration(state); - - if (duration == null) { - // This probably can't ever happen. - return defaultText; - } - - return getPositionText(duration, getUserInputScrubPosition(state)); - - case "double": - return getDoubleSizeModeText(state.display.doubled); - - case "eq": - const band = state.userInput.bandFocused; - - if (band == null) { - // This probably can't ever happen. - return defaultText; - } - - return getEqText(band, state.equalizer.sliders[band]); - - default: - break; - } - - if (state.playlist.currentTrack != null) { - const mediaText = getMediaText(state); - - if (mediaText == null) { - // This probably can't ever happen. - return defaultText; - } - - return mediaText; - } - - return defaultText; -}; -const getKbps = Object(lib["createSelector"])(getCurrentTrack, track => { - return track != null ? track.kbps || null : null; -}); -const getKhz = Object(lib["createSelector"])(getCurrentTrack, track => { - return track != null ? track.khz || null : null; -}); -function getDebugData(state) { - return objectSpread_default()({}, state, { - display: objectSpread_default()({}, state.display, { - skinGenLetterWidths: "[[REDACTED]]", - skinImages: "[[REDACTED]]", - skinCursors: "[[REDACTED]]", - skinRegion: "[[REDACTED]]" - }) - }); -} -function getMilkdropDesktopEnabled(state) { - return state.milkdrop.display === "DESKTOP"; -} -function getMilkdropFullscreenEnabled(state) { - return state.milkdrop.display === "FULLSCREEN"; -} -function getPresets(state) { - return state.milkdrop.presets; -} -function getButterchurn(state) { - return state.milkdrop.butterchurn; -} -function getPresetTransitionType(state) { - return state.milkdrop.transitionType; -} -function getCurrentPresetIndex(state) { - return state.milkdrop.currentPresetIndex; -} -function getCurrentPreset(state) { - const index = getCurrentPresetIndex(state); - - if (index == null) { - return null; - } - - const preset = state.milkdrop.presets[index]; - - if (preset == null || preset.type === "UNRESOLVED") { - return null; - } - - return preset.preset; -} -function getPresetNames(state) { - return state.milkdrop.presets.map(preset => preset.name); -} -function getPresetOverlayOpen(state) { - return state.milkdrop.overlay; -} -function getPresetsAreCycling(state) { - return state.milkdrop.cycling; -} -function getRandomizePresets(state) { - return state.milkdrop.randomize; -} - -/***/ }), -/* 5 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return BANDS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return WINDOWS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return LOAD_STYLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return MEDIA_TAG_REQUEST_STATUS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return UTF8_ELLIPSIS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return CHARACTER_WIDTH; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return WINDOW_RESIZE_SEGMENT_WIDTH; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return WINDOW_RESIZE_SEGMENT_HEIGHT; }); -/* unused harmony export WINDOW_HEIGHT */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return WINDOW_WIDTH; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return TRACK_HEIGHT; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return LETTERS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return DEFAULT_SKIN; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return VISUALIZERS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return VISUALIZER_ORDER; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return TIME_MODE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return MEDIA_STATUS; }); -/* harmony import */ var _baseSkin_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(126); -var _baseSkin_json__WEBPACK_IMPORTED_MODULE_0___namespace = /*#__PURE__*/__webpack_require__.t(126, 1); - -const BANDS = [60, 170, 310, 600, 1000, 3000, 6000, 12000, 14000, 16000]; -const WINDOWS = { - MAIN: "main", - PLAYLIST: "playlist", - EQUALIZER: "equalizer", - MEDIA_LIBRARY: "mediaLibrary", - MILKDROP: "milkdrop" -}; -const LOAD_STYLE = { - BUFFER: "BUFFER", - PLAY: "PLAY", - NONE: "NONE" -}; // TODO: Make this an enum? - -const MEDIA_TAG_REQUEST_STATUS = { - INITIALIZED: "INITIALIZED", - FAILED: "FAILED", - COMPLETE: "COMPLETE", - NOT_REQUESTED: "NOT_REQUESTED" -}; -const UTF8_ELLIPSIS = "\u2026"; -const CHARACTER_WIDTH = 5; -const WINDOW_RESIZE_SEGMENT_WIDTH = 25; -const WINDOW_RESIZE_SEGMENT_HEIGHT = 29; -const WINDOW_HEIGHT = 116; -const WINDOW_WIDTH = 275; -const TRACK_HEIGHT = 13; -const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); -const DEFAULT_SKIN = _baseSkin_json__WEBPACK_IMPORTED_MODULE_0__; -const VISUALIZERS = { - OSCILLOSCOPE: "OSCILLOSCOPE", - BAR: "BAR", - NONE: "NONE", - MILKDROP: "MILKDROP" -}; -const VISUALIZER_ORDER = [VISUALIZERS.BAR, VISUALIZERS.OSCILLOSCOPE, // TODO: Verify the order -VISUALIZERS.NONE]; -const TIME_MODE = { - ELAPSED: "ELAPSED", - REMAINING: "REMAINING" -}; // TODO: Convert to enum once we are fully Typescript - -const MEDIA_STATUS = { - PLAYING: "PLAYING", - STOPPED: "STOPPED", - PAUSED: "PAUSED" -}; - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -var defineProperty = __webpack_require__(9); - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); - - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - - ownKeys.forEach(function (key) { - defineProperty(target, key, source[key]); - }); - } - - return target; -} - -module.exports = _objectSpread; - -/***/ }), -/* 7 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; - -// CONCATENATED MODULE: ./node_modules/react-redux/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js -function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - subClass.__proto__ = superClass; -} -// EXTERNAL MODULE: ./node_modules/react/index.js -var react = __webpack_require__(0); -var react_default = /*#__PURE__*/__webpack_require__.n(react); - -// EXTERNAL MODULE: ./node_modules/react-redux/node_modules/prop-types/index.js -var prop_types = __webpack_require__(44); -var prop_types_default = /*#__PURE__*/__webpack_require__.n(prop_types); - -// CONCATENATED MODULE: ./node_modules/react-redux/es/components/Context.js - -var ReactReduxContext = react_default.a.createContext(null); -/* harmony default export */ var components_Context = (ReactReduxContext); -// CONCATENATED MODULE: ./node_modules/react-redux/es/components/Provider.js - - - - - -var Provider_Provider = -/*#__PURE__*/ -function (_Component) { - _inheritsLoose(Provider, _Component); - - function Provider(props) { - var _this; - - _this = _Component.call(this, props) || this; - var store = props.store; - _this.state = { - storeState: store.getState(), - store: store - }; - return _this; - } - - var _proto = Provider.prototype; - - _proto.componentDidMount = function componentDidMount() { - this._isMounted = true; - this.subscribe(); - }; - - _proto.componentWillUnmount = function componentWillUnmount() { - if (this.unsubscribe) this.unsubscribe(); - this._isMounted = false; - }; - - _proto.componentDidUpdate = function componentDidUpdate(prevProps) { - if (this.props.store !== prevProps.store) { - if (this.unsubscribe) this.unsubscribe(); - this.subscribe(); - } - }; - - _proto.subscribe = function subscribe() { - var _this2 = this; - - var store = this.props.store; - this.unsubscribe = store.subscribe(function () { - var newStoreState = store.getState(); - - if (!_this2._isMounted) { - return; - } - - _this2.setState(function (providerState) { - // If the value is the same, skip the unnecessary state update. - if (providerState.storeState === newStoreState) { - return null; - } - - return { - storeState: newStoreState - }; - }); - }); // Actions might have been dispatched between render and mount - handle those - - var postMountStoreState = store.getState(); - - if (postMountStoreState !== this.state.storeState) { - this.setState({ - storeState: postMountStoreState - }); - } - }; - - _proto.render = function render() { - var Context = this.props.context || ReactReduxContext; - return react_default.a.createElement(Context.Provider, { - value: this.state - }, this.props.children); - }; - - return Provider; -}(react["Component"]); - -Provider_Provider.propTypes = { - store: prop_types_default.a.shape({ - subscribe: prop_types_default.a.func.isRequired, - dispatch: prop_types_default.a.func.isRequired, - getState: prop_types_default.a.func.isRequired - }), - context: prop_types_default.a.object, - children: prop_types_default.a.any -}; -/* harmony default export */ var components_Provider = (Provider_Provider); -// CONCATENATED MODULE: ./node_modules/react-redux/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js -function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; -} -// CONCATENATED MODULE: ./node_modules/react-redux/node_modules/@babel/runtime/helpers/esm/extends.js -function _extends() { - _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); -} -// CONCATENATED MODULE: ./node_modules/react-redux/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js -function _objectWithoutPropertiesLoose(source, excluded) { - if (source == null) return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key, i; - - for (i = 0; i < sourceKeys.length; i++) { - key = sourceKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - target[key] = source[key]; - } - - return target; -} -// EXTERNAL MODULE: ./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js -var hoist_non_react_statics_cjs = __webpack_require__(95); -var hoist_non_react_statics_cjs_default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics_cjs); - -// EXTERNAL MODULE: ./node_modules/react-redux/node_modules/invariant/browser.js -var browser = __webpack_require__(54); -var browser_default = /*#__PURE__*/__webpack_require__.n(browser); - -// EXTERNAL MODULE: ./node_modules/react-is/index.js -var react_is = __webpack_require__(107); - -// CONCATENATED MODULE: ./node_modules/react-redux/es/components/connectAdvanced.js - - - - - - - - - -function connectAdvanced( -/* - selectorFactory is a func that is responsible for returning the selector function used to - compute new props from state, props, and dispatch. For example: - export default connectAdvanced((dispatch, options) => (state, props) => ({ - thing: state.things[props.thingId], - saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)), - }))(YourComponent) - Access to dispatch is provided to the factory so selectorFactories can bind actionCreators - outside of their selector as an optimization. Options passed to connectAdvanced are passed to - the selectorFactory, along with displayName and WrappedComponent, as the second argument. - Note that selectorFactory is responsible for all caching/memoization of inbound and outbound - props. Do not use connectAdvanced directly without memoizing results between calls to your - selector, otherwise the Connect component will re-render on every state or props change. -*/ -selectorFactory, // options object: -_ref) { - if (_ref === void 0) { - _ref = {}; - } - - var _ref2 = _ref, - _ref2$getDisplayName = _ref2.getDisplayName, - getDisplayName = _ref2$getDisplayName === void 0 ? function (name) { - return "ConnectAdvanced(" + name + ")"; - } : _ref2$getDisplayName, - _ref2$methodName = _ref2.methodName, - methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName, - _ref2$renderCountProp = _ref2.renderCountProp, - renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp, - _ref2$shouldHandleSta = _ref2.shouldHandleStateChanges, - shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta, - _ref2$storeKey = _ref2.storeKey, - storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey, - _ref2$withRef = _ref2.withRef, - withRef = _ref2$withRef === void 0 ? false : _ref2$withRef, - _ref2$forwardRef = _ref2.forwardRef, - forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef, - _ref2$context = _ref2.context, - context = _ref2$context === void 0 ? ReactReduxContext : _ref2$context, - connectOptions = _objectWithoutPropertiesLoose(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]); - - browser_default()(renderCountProp === undefined, "renderCountProp is removed. render counting is built into the latest React dev tools profiling extension"); - browser_default()(!withRef, 'withRef is removed. To access the wrapped instance, use a ref on the connected component'); - var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React-Redux's Provider and specific components" + ' like: . ' + 'You may also pass a {context : MyContext} option to connect'; - browser_default()(storeKey === 'store', 'storeKey has been removed and does not do anything. ' + customStoreWarningMessage); - var Context = context; - return function wrapWithConnect(WrappedComponent) { - if (false) {} - - var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; - var displayName = getDisplayName(wrappedComponentName); - - var selectorFactoryOptions = _extends({}, connectOptions, { - getDisplayName: getDisplayName, - methodName: methodName, - renderCountProp: renderCountProp, - shouldHandleStateChanges: shouldHandleStateChanges, - storeKey: storeKey, - displayName: displayName, - wrappedComponentName: wrappedComponentName, - WrappedComponent: WrappedComponent - }); - - var pure = connectOptions.pure; - var OuterBaseComponent = react["Component"]; - var FinalWrappedComponent = WrappedComponent; - - if (pure) { - OuterBaseComponent = react["PureComponent"]; - } - - function makeDerivedPropsSelector() { - var lastProps; - var lastState; - var lastDerivedProps; - var lastStore; - var sourceSelector; - return function selectDerivedProps(state, props, store) { - if (pure && lastProps === props && lastState === state) { - return lastDerivedProps; - } - - if (store !== lastStore) { - lastStore = store; - sourceSelector = selectorFactory(store.dispatch, selectorFactoryOptions); - } - - lastProps = props; - lastState = state; - var nextProps = sourceSelector(state, props); - - if (lastDerivedProps === nextProps) { - return lastDerivedProps; - } - - lastDerivedProps = nextProps; - return lastDerivedProps; - }; - } - - function makeChildElementSelector() { - var lastChildProps, lastForwardRef, lastChildElement; - return function selectChildElement(childProps, forwardRef) { - if (childProps !== lastChildProps || forwardRef !== lastForwardRef) { - lastChildProps = childProps; - lastForwardRef = forwardRef; - lastChildElement = react_default.a.createElement(FinalWrappedComponent, _extends({}, childProps, { - ref: forwardRef - })); - } - - return lastChildElement; - }; - } - - var Connect = - /*#__PURE__*/ - function (_OuterBaseComponent) { - _inheritsLoose(Connect, _OuterBaseComponent); - - function Connect(props) { - var _this; - - _this = _OuterBaseComponent.call(this, props) || this; - browser_default()(forwardRef ? !props.wrapperProps[storeKey] : !props[storeKey], 'Passing redux store in props has been removed and does not do anything. ' + customStoreWarningMessage); - _this.selectDerivedProps = makeDerivedPropsSelector(); - _this.selectChildElement = makeChildElementSelector(); - _this.renderWrappedComponent = _this.renderWrappedComponent.bind(_assertThisInitialized(_assertThisInitialized(_this))); - return _this; - } - - var _proto = Connect.prototype; - - _proto.renderWrappedComponent = function renderWrappedComponent(value) { - browser_default()(value, "Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a , ") + "or pass a custom React context provider to and the corresponding " + ("React context consumer to " + displayName + " in connect options.")); - var storeState = value.storeState, - store = value.store; - var wrapperProps = this.props; - var forwardedRef; - - if (forwardRef) { - wrapperProps = this.props.wrapperProps; - forwardedRef = this.props.forwardedRef; - } - - var derivedProps = this.selectDerivedProps(storeState, wrapperProps, store); - return this.selectChildElement(derivedProps, forwardedRef); - }; - - _proto.render = function render() { - var ContextToUse = this.props.context || Context; - return react_default.a.createElement(ContextToUse.Consumer, null, this.renderWrappedComponent); - }; - - return Connect; - }(OuterBaseComponent); - - Connect.WrappedComponent = WrappedComponent; - Connect.displayName = displayName; - - if (forwardRef) { - var forwarded = react_default.a.forwardRef(function forwardConnectRef(props, ref) { - return react_default.a.createElement(Connect, { - wrapperProps: props, - forwardedRef: ref - }); - }); - forwarded.displayName = displayName; - forwarded.WrappedComponent = WrappedComponent; - return hoist_non_react_statics_cjs_default()(forwarded, WrappedComponent); - } - - return hoist_non_react_statics_cjs_default()(Connect, WrappedComponent); - }; -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/utils/shallowEqual.js -var hasOwn = Object.prototype.hasOwnProperty; - -function is(x, y) { - if (x === y) { - return x !== 0 || y !== 0 || 1 / x === 1 / y; - } else { - return x !== x && y !== y; - } -} - -function shallowEqual(objA, objB) { - if (is(objA, objB)) return true; - - if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { - return false; - } - - var keysA = Object.keys(objA); - var keysB = Object.keys(objB); - if (keysA.length !== keysB.length) return false; - - for (var i = 0; i < keysA.length; i++) { - if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { - return false; - } - } - - return true; -} -// EXTERNAL MODULE: ./node_modules/redux/es/redux.js -var redux = __webpack_require__(32); - -// CONCATENATED MODULE: ./node_modules/react-redux/es/utils/isPlainObject.js -/** - * @param {any} obj The object to inspect. - * @returns {boolean} True if the argument appears to be a plain object. - */ -function isPlainObject(obj) { - if (typeof obj !== 'object' || obj === null) return false; - var proto = Object.getPrototypeOf(obj); - if (proto === null) return true; - var baseProto = proto; - - while (Object.getPrototypeOf(baseProto) !== null) { - baseProto = Object.getPrototypeOf(baseProto); - } - - return proto === baseProto; -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/utils/warning.js -/** - * Prints a warning in the console if it exists. - * - * @param {String} message The warning message. - * @returns {void} - */ -function warning(message) { - /* eslint-disable no-console */ - if (typeof console !== 'undefined' && typeof console.error === 'function') { - console.error(message); - } - /* eslint-enable no-console */ - - - try { - // This error was thrown as a convenience so that if you enable - // "break on all exceptions" in your console, - // it would pause the execution at this line. - throw new Error(message); - /* eslint-disable no-empty */ - } catch (e) {} - /* eslint-enable no-empty */ - -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/utils/verifyPlainObject.js - - -function verifyPlainObject(value, displayName, methodName) { - if (!isPlainObject(value)) { - warning(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + "."); - } -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/wrapMapToProps.js - -function wrapMapToPropsConstant(getConstant) { - return function initConstantSelector(dispatch, options) { - var constant = getConstant(dispatch, options); - - function constantSelector() { - return constant; - } - - constantSelector.dependsOnOwnProps = false; - return constantSelector; - }; -} // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args -// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine -// whether mapToProps needs to be invoked when props have changed. -// -// A length of one signals that mapToProps does not depend on props from the parent component. -// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and -// therefore not reporting its length accurately.. - -function getDependsOnOwnProps(mapToProps) { - return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1; -} // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction, -// this function wraps mapToProps in a proxy function which does several things: -// -// * Detects whether the mapToProps function being called depends on props, which -// is used by selectorFactory to decide if it should reinvoke on props changes. -// -// * On first call, handles mapToProps if returns another function, and treats that -// new function as the true mapToProps for subsequent calls. -// -// * On first call, verifies the first result is a plain object, in order to warn -// the developer that their mapToProps function is not returning a valid result. -// - -function wrapMapToPropsFunc(mapToProps, methodName) { - return function initProxySelector(dispatch, _ref) { - var displayName = _ref.displayName; - - var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) { - return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch); - }; // allow detectFactoryAndVerify to get ownProps - - - proxy.dependsOnOwnProps = true; - - proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) { - proxy.mapToProps = mapToProps; - proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps); - var props = proxy(stateOrDispatch, ownProps); - - if (typeof props === 'function') { - proxy.mapToProps = props; - proxy.dependsOnOwnProps = getDependsOnOwnProps(props); - props = proxy(stateOrDispatch, ownProps); - } - - if (false) {} - return props; - }; - - return proxy; - }; -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/mapDispatchToProps.js - - -function whenMapDispatchToPropsIsFunction(mapDispatchToProps) { - return typeof mapDispatchToProps === 'function' ? wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : undefined; -} -function whenMapDispatchToPropsIsMissing(mapDispatchToProps) { - return !mapDispatchToProps ? wrapMapToPropsConstant(function (dispatch) { - return { - dispatch: dispatch - }; - }) : undefined; -} -function whenMapDispatchToPropsIsObject(mapDispatchToProps) { - return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(function (dispatch) { - return Object(redux["bindActionCreators"])(mapDispatchToProps, dispatch); - }) : undefined; -} -/* harmony default export */ var connect_mapDispatchToProps = ([whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject]); -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/mapStateToProps.js - -function whenMapStateToPropsIsFunction(mapStateToProps) { - return typeof mapStateToProps === 'function' ? wrapMapToPropsFunc(mapStateToProps, 'mapStateToProps') : undefined; -} -function whenMapStateToPropsIsMissing(mapStateToProps) { - return !mapStateToProps ? wrapMapToPropsConstant(function () { - return {}; - }) : undefined; -} -/* harmony default export */ var connect_mapStateToProps = ([whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]); -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/mergeProps.js - - -function defaultMergeProps(stateProps, dispatchProps, ownProps) { - return _extends({}, ownProps, stateProps, dispatchProps); -} -function wrapMergePropsFunc(mergeProps) { - return function initMergePropsProxy(dispatch, _ref) { - var displayName = _ref.displayName, - pure = _ref.pure, - areMergedPropsEqual = _ref.areMergedPropsEqual; - var hasRunOnce = false; - var mergedProps; - return function mergePropsProxy(stateProps, dispatchProps, ownProps) { - var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps); - - if (hasRunOnce) { - if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps; - } else { - hasRunOnce = true; - mergedProps = nextMergedProps; - if (false) {} - } - - return mergedProps; - }; - }; -} -function whenMergePropsIsFunction(mergeProps) { - return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined; -} -function whenMergePropsIsOmitted(mergeProps) { - return !mergeProps ? function () { - return defaultMergeProps; - } : undefined; -} -/* harmony default export */ var connect_mergeProps = ([whenMergePropsIsFunction, whenMergePropsIsOmitted]); -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/verifySubselectors.js - - -function verify(selector, methodName, displayName) { - if (!selector) { - throw new Error("Unexpected value for " + methodName + " in " + displayName + "."); - } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') { - if (!selector.hasOwnProperty('dependsOnOwnProps')) { - warning("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps."); - } - } -} - -function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) { - verify(mapStateToProps, 'mapStateToProps', displayName); - verify(mapDispatchToProps, 'mapDispatchToProps', displayName); - verify(mergeProps, 'mergeProps', displayName); -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/selectorFactory.js - - -function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) { - return function impureFinalPropsSelector(state, ownProps) { - return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps); - }; -} -function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) { - var areStatesEqual = _ref.areStatesEqual, - areOwnPropsEqual = _ref.areOwnPropsEqual, - areStatePropsEqual = _ref.areStatePropsEqual; - var hasRunAtLeastOnce = false; - var state; - var ownProps; - var stateProps; - var dispatchProps; - var mergedProps; - - function handleFirstCall(firstState, firstOwnProps) { - state = firstState; - ownProps = firstOwnProps; - stateProps = mapStateToProps(state, ownProps); - dispatchProps = mapDispatchToProps(dispatch, ownProps); - mergedProps = mergeProps(stateProps, dispatchProps, ownProps); - hasRunAtLeastOnce = true; - return mergedProps; - } - - function handleNewPropsAndNewState() { - stateProps = mapStateToProps(state, ownProps); - if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps); - mergedProps = mergeProps(stateProps, dispatchProps, ownProps); - return mergedProps; - } - - function handleNewProps() { - if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps); - if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps); - mergedProps = mergeProps(stateProps, dispatchProps, ownProps); - return mergedProps; - } - - function handleNewState() { - var nextStateProps = mapStateToProps(state, ownProps); - var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps); - stateProps = nextStateProps; - if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps); - return mergedProps; - } - - function handleSubsequentCalls(nextState, nextOwnProps) { - var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps); - var stateChanged = !areStatesEqual(nextState, state); - state = nextState; - ownProps = nextOwnProps; - if (propsChanged && stateChanged) return handleNewPropsAndNewState(); - if (propsChanged) return handleNewProps(); - if (stateChanged) return handleNewState(); - return mergedProps; - } - - return function pureFinalPropsSelector(nextState, nextOwnProps) { - return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps); - }; -} // TODO: Add more comments -// If pure is true, the selector returned by selectorFactory will memoize its results, -// allowing connectAdvanced's shouldComponentUpdate to return false if final -// props have not changed. If false, the selector will always return a new -// object and shouldComponentUpdate will always return true. - -function finalPropsSelectorFactory(dispatch, _ref2) { - var initMapStateToProps = _ref2.initMapStateToProps, - initMapDispatchToProps = _ref2.initMapDispatchToProps, - initMergeProps = _ref2.initMergeProps, - options = _objectWithoutPropertiesLoose(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]); - - var mapStateToProps = initMapStateToProps(dispatch, options); - var mapDispatchToProps = initMapDispatchToProps(dispatch, options); - var mergeProps = initMergeProps(dispatch, options); - - if (false) {} - - var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory; - return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options); -} -// CONCATENATED MODULE: ./node_modules/react-redux/es/connect/connect.js - - - - - - - - -/* - connect is a facade over connectAdvanced. It turns its args into a compatible - selectorFactory, which has the signature: - - (dispatch, options) => (nextState, nextOwnProps) => nextFinalProps - - connect passes its args to connectAdvanced as options, which will in turn pass them to - selectorFactory each time a Connect component instance is instantiated or hot reloaded. - - selectorFactory returns a final props selector from its mapStateToProps, - mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps, - mergePropsFactories, and pure args. - - The resulting final props selector is called by the Connect component instance whenever - it receives new props or store state. - */ - -function match(arg, factories, name) { - for (var i = factories.length - 1; i >= 0; i--) { - var result = factories[i](arg); - if (result) return result; - } - - return function (dispatch, options) { - throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + "."); - }; -} - -function strictEqual(a, b) { - return a === b; -} // createConnect with default args builds the 'official' connect behavior. Calling it with -// different options opens up some testing and extensibility scenarios - - -function createConnect(_temp) { - var _ref = _temp === void 0 ? {} : _temp, - _ref$connectHOC = _ref.connectHOC, - connectHOC = _ref$connectHOC === void 0 ? connectAdvanced : _ref$connectHOC, - _ref$mapStateToPropsF = _ref.mapStateToPropsFactories, - mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? connect_mapStateToProps : _ref$mapStateToPropsF, - _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, - mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? connect_mapDispatchToProps : _ref$mapDispatchToPro, - _ref$mergePropsFactor = _ref.mergePropsFactories, - mergePropsFactories = _ref$mergePropsFactor === void 0 ? connect_mergeProps : _ref$mergePropsFactor, - _ref$selectorFactory = _ref.selectorFactory, - selectorFactory = _ref$selectorFactory === void 0 ? finalPropsSelectorFactory : _ref$selectorFactory; - - return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) { - if (_ref2 === void 0) { - _ref2 = {}; - } - - var _ref3 = _ref2, - _ref3$pure = _ref3.pure, - pure = _ref3$pure === void 0 ? true : _ref3$pure, - _ref3$areStatesEqual = _ref3.areStatesEqual, - areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual, - _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual, - areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? shallowEqual : _ref3$areOwnPropsEqua, - _ref3$areStatePropsEq = _ref3.areStatePropsEqual, - areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? shallowEqual : _ref3$areStatePropsEq, - _ref3$areMergedPropsE = _ref3.areMergedPropsEqual, - areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? shallowEqual : _ref3$areMergedPropsE, - extraOptions = _objectWithoutPropertiesLoose(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]); - - var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); - var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); - var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps'); - return connectHOC(selectorFactory, _extends({ - // used in error messages - methodName: 'connect', - // used to compute Connect's displayName from the wrapped component's displayName. - getDisplayName: function getDisplayName(name) { - return "Connect(" + name + ")"; - }, - // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes - shouldHandleStateChanges: Boolean(mapStateToProps), - // passed through to selectorFactory - initMapStateToProps: initMapStateToProps, - initMapDispatchToProps: initMapDispatchToProps, - initMergeProps: initMergeProps, - pure: pure, - areStatesEqual: areStatesEqual, - areOwnPropsEqual: areOwnPropsEqual, - areStatePropsEqual: areStatePropsEqual, - areMergedPropsEqual: areMergedPropsEqual - }, extraOptions)); - }; -} -/* harmony default export */ var connect_connect = (createConnect()); -// CONCATENATED MODULE: ./node_modules/react-redux/es/index.js -/* concated harmony reexport Provider */__webpack_require__.d(__webpack_exports__, "a", function() { return components_Provider; }); -/* unused concated harmony import connectAdvanced */ -/* unused concated harmony import ReactReduxContext */ -/* concated harmony reexport connect */__webpack_require__.d(__webpack_exports__, "b", function() { return connect_connect; }); - - - - - - -/***/ }), -/* 8 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return getTimeObj; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return getTimeStr; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return getFileExtension; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return parseViscolors; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return parseIni; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return clamp; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return base64FromArrayBuffer; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return downloadURI; }); -/* unused harmony export toPercent */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return percentToRange; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return percentToIndex; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return normalizeEqBand; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return denormalizeEqBand; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return merge; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return segment; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return arraysAreEqual; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return shuffle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return sort; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return moveSelected; }); -/* unused harmony export spliceIn */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return replaceAtIndex; }); -/* unused harmony export debounce */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return throttle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return uniqueId; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return objectForEach; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return objectMap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return objectFilter; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return calculateBoundingBox; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return findLastIndex; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return getWindowSize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return getScreenSize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return weakMapMemoize; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return makeCachingFilterFunction; }); -/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5); - -const getTimeObj = time => { - if (time == null) { - // If we clean up `` we don't need to do this any more. - return { - minutesFirstDigit: " ", - minutesSecondDigit: " ", - secondsFirstDigit: " ", - secondsSecondDigit: " " - }; - } - - const minutes = Math.floor(time / 60); - const seconds = time % 60; - const digits = time == null ? [" ", " ", " ", " "] : [String(Math.floor(minutes / 10)), String(Math.floor(minutes % 10)), String(Math.floor(seconds / 10)), String(Math.floor(seconds % 10))]; - const minutesFirstDigit = digits[0], - minutesSecondDigit = digits[1], - secondsFirstDigit = digits[2], - secondsSecondDigit = digits[3]; - return { - minutesFirstDigit, - minutesSecondDigit, - secondsFirstDigit, - secondsSecondDigit - }; -}; -const getTimeStr = function getTimeStr(time) { - let truncate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - - if (time == null) { - return ""; - } - - const _getTimeObj = getTimeObj(time), - minutesFirstDigit = _getTimeObj.minutesFirstDigit, - minutesSecondDigit = _getTimeObj.minutesSecondDigit, - secondsFirstDigit = _getTimeObj.secondsFirstDigit, - secondsSecondDigit = _getTimeObj.secondsSecondDigit; - - return [truncate && minutesFirstDigit === "0" ? "" : minutesFirstDigit, minutesSecondDigit, ":", secondsFirstDigit, secondsSecondDigit].join(""); -}; -const getFileExtension = fileName => { - const matches = /\.([a-z]{3,4})$/i.exec(fileName); - return matches ? matches[1].toLowerCase() : null; -}; -const parseViscolors = text => { - const entries = text.split("\n"); - const regex = /^\s*(\d+)\s*,?\s*(\d+)\s*,?\s*(\d+)/; - const colors = [..._constants__WEBPACK_IMPORTED_MODULE_0__[/* DEFAULT_SKIN */ "c"].colors]; - entries.map(line => regex.exec(line)).filter(Boolean).map(matches => matches.slice(1, 4).join(",")).map((rgb, i) => { - colors[i] = `rgb(${rgb})`; - }); - return colors; -}; -const SECTION_REGEX = /^\s*\[(.+?)\]\s*$/; -const PROPERTY_REGEX = /^\s*([^;].*)\s*=\s*(.*)\s*$/; -const parseIni = text => { - let section, match; - return text.split(/[\r\n]+/g).reduce((data, line) => { - if ((match = line.match(PROPERTY_REGEX)) && section != null) { - const value = match[2].replace(/(^")|("$)|(^')|('$)/gi, ""); - data[section][match[1].trim().toLowerCase()] = value; - } else if (match = line.match(SECTION_REGEX)) { - section = match[1].trim().toLowerCase(); - data[section] = {}; - } - - return data; - }, {}); -}; -const clamp = (value, min, max) => Math.min(Math.max(value, min), max); -const base64FromArrayBuffer = arrayBuffer => { - const dataView = new Uint8Array(arrayBuffer); - return window.btoa(String.fromCharCode(...dataView)); -}; // https://stackoverflow.com/a/15832662/1263117 - -function downloadURI(uri, name) { - const link = document.createElement("a"); - link.download = name; - link.href = uri; - window.document.body.appendChild(link); - link.click(); - window.document.body.removeChild(link); -} -const toPercent = (min, max, value) => (value - min) / (max - min); -const percentToRange = (percent, min, max) => min + Math.round(percent * (max - min)); -const percentToIndex = (percent, length) => percentToRange(percent, 0, length - 1); - -const rebound = (oldMin, oldMax, newMin, newMax) => oldValue => percentToRange(toPercent(oldMin, oldMax, oldValue), newMin, newMax); // Convert an .eqf value to a 0-100 - - -const normalizeEqBand = rebound(1, 64, 0, 100); // Convert a 0-100 to an .eqf value - -const denormalizeEqBand = rebound(0, 100, 1, 64); // Merge a `source` object to a `target` recursively -// TODO: The typing here is a bit of a disaster. - -function merge(target, source) { - const s = source; - const t = target; // Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties - - for (const key of Object.keys(s)) { - if (s[key] instanceof Object) Object.assign(s[key], merge(t[key], s[key])); - } // Join `target` and modified `source` - - - Object.assign(target || {}, source); - return target; -} // Maps a value in a range (defined my min/max) to a value in an array (options). - -function segment(min, max, value, newValues) { - const ratio = toPercent(min, max, value); - /* - | 0 | 1 | 2 | - 0 1 2 3 - */ - - return newValues[percentToIndex(ratio, newValues.length)]; -} -const arraysAreEqual = (a, b) => a.length === b.length && a.every((value, i) => value === b[i]); // https://bost.ocks.org/mike/shuffle/ -// Shuffle an array in O(n) - -function shuffle(array) { - const sorted = [...array]; - let m = sorted.length; // While there remain elements to shuffle… - - while (m) { - // Pick a remaining element… - const i = Math.floor(Math.random() * m--); // And swap it with the current element. - - const val = sorted[m]; - sorted[m] = sorted[i]; - sorted[i] = val; - } - - return sorted; -} -function sort(array, iteratee) { - return [...array].sort((a, b) => { - const aKey = iteratee(a); - const bKey = iteratee(b); - - if (aKey < bKey) { - return -1; - } else if (aKey > bKey) { - return 1; - } - - return 0; - }); -} -function moveSelected(arr, isSelected, offset) { - const newArr = new Array(arr.length); - let next = 0; - - for (let i = 0; i < newArr.length; i++) { - const from = i - offset; // Is a value supposed to move here? - - if (from >= 0 && from < arr.length && isSelected(from)) { - newArr[i] = arr[from]; - } else { - while (next < arr.length && isSelected(next)) { - next++; - } - - newArr[i] = arr[next]; - next++; - } - } - - return newArr; -} -function spliceIn(original, start, newValues) { - const newArr = [...original]; - newArr.splice(start, 0, ...newValues); - return newArr; -} -function replaceAtIndex(arr, index, newValue) { - return [...arr.slice(0, index), newValue, ...arr.slice(index + 1)]; -} -function debounce(func, delay) { - let timeout; - let callbackArgs = []; - return function (context) { - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - callbackArgs = args; - - if (timeout != null) { - clearTimeout(timeout); - } - - timeout = window.setTimeout(() => { - func.apply(context, callbackArgs); - }, delay); - }; -} // Trailing edge only throttle - -function throttle(func, delay) { - let timeout = null; - let callbackArgs = []; - return function (context) { - for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - args[_key2 - 1] = arguments[_key2]; - } - - callbackArgs = args; - - if (!timeout) { - timeout = window.setTimeout(() => { - func.apply(context, callbackArgs); - timeout = null; - }, delay); - } - }; -} -let counter = 0; -function uniqueId() { - return counter++; -} -function objectForEach(obj, cb) { - Object.keys(obj).forEach(key => cb(obj[key], key)); -} -function objectMap(obj, cb) { - const modified = {}; - Object.keys(obj).forEach(key => modified[key] = cb(obj[key], key)); - return modified; -} -function objectFilter(obj, predicate) { - // TODO: Could return the original reference if no values change - return Object.keys(obj).reduce((newObj, key) => { - if (predicate(obj[key], key)) { - newObj[key] = obj[key]; - } - - return newObj; - }, {}); -} -const calculateBoundingBox = windows => windows.map(w => ({ - left: w.x, - top: w.y, - bottom: w.y + w.height, - right: w.x + w.width -})).reduce((b, w) => ({ - left: Math.min(b.left, w.left), - top: Math.min(b.top, w.top), - bottom: Math.max(b.bottom, w.bottom), - right: Math.max(b.right, w.right) -})); -function findLastIndex(arr, cb) { - for (let i = arr.length - 1; i >= 0; i--) { - if (cb(arr[i])) { - return i; - } - } - - return -1; -} -function getWindowSize() { - // Aparently this is crazy across browsers. - return { - width: Math.max(document.body.scrollWidth, document.documentElement.scrollWidth, document.body.offsetWidth, document.documentElement.offsetWidth, document.body.clientWidth, document.documentElement.clientWidth), - height: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - }; -} -function getScreenSize() { - return { - width: window.screen.width, - height: window.screen.height - }; -} -function weakMapMemoize(func) { - const cache = new WeakMap(); - return value => { - if (!cache.has(value)) { - cache.set(value, func(value)); - } - - return cache.get(value); - }; -} -// Is this a premature optimizaiton? Probably. But it's my side-project so I can -// do what I like. :P -function makeCachingFilterFunction(values, includes) { - const cache = { - results: values, - subCaches: {} - }; - return query => { - let queryCache = cache; - let lastResults = values; - - for (const char of query) { - let letterCaches = queryCache.subCaches[char]; - - if (!letterCaches) { - letterCaches = queryCache.subCaches[char] = { - subCaches: {} - }; - } else if (letterCaches.results) { - lastResults = letterCaches.results; - } - - queryCache = letterCaches; - } - - if (!queryCache.results) { - queryCache.results = lastResults.filter(v => includes(v, query)); - } - - return queryCache.results; - }; -} - -/***/ }), -/* 9 */ -/***/ (function(module, exports) { - -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; -} - -module.exports = _defineProperty; - -/***/ }), -/* 10 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Hr; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return Parent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return LinkNode; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Node; }); -/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20); -/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22); -/* harmony import */ var _babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(13); -/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7); -/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(11); -/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _css_context_menu_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(182); -/* harmony import */ var _css_context_menu_css__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_css_context_menu_css__WEBPACK_IMPORTED_MODULE_6__); - - - - - - - - -const Portal = props => { - const node = Object(react__WEBPACK_IMPORTED_MODULE_2__["useMemo"])(() => { - const node = document.createElement("div"); - node.id = "webamp-context-menu"; - node.style.position = "absolute"; - node.style.top = "0"; - node.style.left = "0"; - node.style.zIndex = String(props.zIndex + 1); - return node; - }, [props.zIndex]); - Object(react__WEBPACK_IMPORTED_MODULE_2__["useEffect"])(() => { - document.body.appendChild(node); - return () => { - document.body.removeChild(node); - }; - }, [node]); - const style = { - top: props.top, - left: props.left, - position: "absolute" - }; - return Object(react_dom__WEBPACK_IMPORTED_MODULE_3__["createPortal"])(react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("div", { - style: style - }, props.children), node); -}; - -const Hr = () => react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("li", { - className: "hr" -}, react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("hr", null)); -const Parent = (_ref) => { - let children = _ref.children, - label = _ref.label; - return react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("li", { - className: "parent" - }, react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("ul", null, children), label); -}; -const LinkNode = props => react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("li", null, react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("a", props, props.label)); -const Node = props => { - const label = props.label, - checked = props.checked, - _props$className = props.className, - className = _props$className === void 0 ? "" : _props$className, - passThroughProps = _babel_runtime_helpers_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1___default()(props, ["label", "checked", "className"]); - - return react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("li", _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({ - className: classnames__WEBPACK_IMPORTED_MODULE_5___default()(className, { - checked - }) - }, passThroughProps), label); -}; - -class ContextMenu extends react__WEBPACK_IMPORTED_MODULE_2___default.a.Component { - render() { - const _this$props = this.props, - children = _this$props.children, - offsetTop = _this$props.offsetTop, - offsetLeft = _this$props.offsetLeft, - top = _this$props.top, - bottom = _this$props.bottom, - selected = _this$props.selected, - zIndex = _this$props.zIndex; - return selected && react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(Portal, { - top: offsetTop, - left: offsetLeft, - zIndex: zIndex - }, react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("ul", { - className: classnames__WEBPACK_IMPORTED_MODULE_5___default()("context-menu", { - top, - bottom - }) - }, children)); - } - -} - -const mapStateToProps = state => ({ - zIndex: state.display.zIndex -}); - -/* harmony default export */ __webpack_exports__["e"] = (Object(react_redux__WEBPACK_IMPORTED_MODULE_4__[/* connect */ "b"])(mapStateToProps)(ContextMenu)); - -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { - -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! - Copyright (c) 2016 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/ -/* global define */ - -(function () { - 'use strict'; - - var hasOwn = {}.hasOwnProperty; - - function classNames () { - var classes = []; - - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) continue; - - var argType = typeof arg; - - if (argType === 'string' || argType === 'number') { - classes.push(arg); - } else if (Array.isArray(arg)) { - classes.push(classNames.apply(null, arg)); - } else if (argType === 'object') { - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes.push(key); - } - } - } - } - - return classes.join(' '); - } - - if ( true && module.exports) { - module.exports = classNames; - } else if (true) { - // register as 'classnames', consistent with npm package name - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { - return classNames; - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else {} -}()); - - -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; - -var _assign = __webpack_require__(201); - -var _assign2 = _interopRequireDefault(_assign); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.default = _assign2.default || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; -}; - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -function checkDCE() { - /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' || - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function' - ) { - return; - } - if (false) {} - try { - // Verify that the code above has been dead code eliminated (DCE'd). - __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE); - } catch (err) { - // DevTools shouldn't crash React, no matter what. - // We should still report in case we break this code. - console.error(err); - } -} - -if (true) { - // DCE check should happen before ReactDOM bundle executes so that - // DevTools can report bad minification during injection. - checkDCE(); - module.exports = __webpack_require__(160); -} else {} - - -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; -exports.defaultMemoize = defaultMemoize; -exports.createSelectorCreator = createSelectorCreator; -exports.createStructuredSelector = createStructuredSelector; -function defaultEqualityCheck(a, b) { - return a === b; -} - -function areArgumentsShallowlyEqual(equalityCheck, prev, next) { - if (prev === null || next === null || prev.length !== next.length) { - return false; - } - - // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible. - var length = prev.length; - for (var i = 0; i < length; i++) { - if (!equalityCheck(prev[i], next[i])) { - return false; - } - } - - return true; -} - -function defaultMemoize(func) { - var equalityCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultEqualityCheck; - - var lastArgs = null; - var lastResult = null; - // we reference arguments instead of spreading them for performance reasons - return function () { - if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { - // apply arguments instead of spreading for performance. - lastResult = func.apply(null, arguments); - } - - lastArgs = arguments; - return lastResult; - }; -} - -function getDependencies(funcs) { - var dependencies = Array.isArray(funcs[0]) ? funcs[0] : funcs; - - if (!dependencies.every(function (dep) { - return typeof dep === 'function'; - })) { - var dependencyTypes = dependencies.map(function (dep) { - return typeof dep; - }).join(', '); - throw new Error('Selector creators expect all input-selectors to be functions, ' + ('instead received the following types: [' + dependencyTypes + ']')); - } - - return dependencies; -} - -function createSelectorCreator(memoize) { - for (var _len = arguments.length, memoizeOptions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - memoizeOptions[_key - 1] = arguments[_key]; - } - - return function () { - for (var _len2 = arguments.length, funcs = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - funcs[_key2] = arguments[_key2]; - } - - var recomputations = 0; - var resultFunc = funcs.pop(); - var dependencies = getDependencies(funcs); - - var memoizedResultFunc = memoize.apply(undefined, [function () { - recomputations++; - // apply arguments instead of spreading for performance. - return resultFunc.apply(null, arguments); - }].concat(memoizeOptions)); - - // If a selector is called with the exact same arguments we don't need to traverse our dependencies again. - var selector = defaultMemoize(function () { - var params = []; - var length = dependencies.length; - - for (var i = 0; i < length; i++) { - // apply arguments instead of spreading and mutate a local list of params for performance. - params.push(dependencies[i].apply(null, arguments)); - } - - // apply arguments instead of spreading for performance. - return memoizedResultFunc.apply(null, params); - }); - - selector.resultFunc = resultFunc; - selector.recomputations = function () { - return recomputations; - }; - selector.resetRecomputations = function () { - return recomputations = 0; - }; - return selector; - }; -} - -var createSelector = exports.createSelector = createSelectorCreator(defaultMemoize); - -function createStructuredSelector(selectors) { - var selectorCreator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createSelector; - - if (typeof selectors !== 'object') { - throw new Error('createStructuredSelector expects first argument to be an object ' + ('where each property is a selector, instead received a ' + typeof selectors)); - } - var objectKeys = Object.keys(selectors); - return selectorCreator(objectKeys.map(function (key) { - return selectors[key]; - }), function () { - for (var _len3 = arguments.length, values = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - values[_key3] = arguments[_key3]; - } - - return values.reduce(function (composition, value, index) { - composition[objectKeys[index]] = value; - return composition; - }, {}); - }); -} - -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; - -var _typeof2 = __webpack_require__(50); - -var _typeof3 = _interopRequireDefault(_typeof2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.default = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; -}; - -/***/ }), -/* 16 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; - -exports.default = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -}; - -/***/ }), -/* 17 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; - -var _setPrototypeOf = __webpack_require__(231); - -var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf); - -var _create = __webpack_require__(235); - -var _create2 = _interopRequireDefault(_create); - -var _typeof2 = __webpack_require__(50); - -var _typeof3 = _interopRequireDefault(_typeof2); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -exports.default = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); - } - - subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; -}; - -/***/ }), -/* 18 */ -/***/ (function(module, exports, __webpack_require__) { - -var arrayWithHoles = __webpack_require__(167); - -var iterableToArrayLimit = __webpack_require__(168); - -var nonIterableRest = __webpack_require__(169); - -function _slicedToArray(arr, i) { - return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest(); -} - -module.exports = _slicedToArray; - -/***/ }), -/* 19 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return genMediaTags; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return genMediaDuration; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return genArrayBufferFromFileReference; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return genStringFromFileReference; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return promptForFileReferences; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return filenameFromUrl; }); -/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(52); -/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_0__); - -function genMediaTags(file, musicMetadata) { - invariant__WEBPACK_IMPORTED_MODULE_0___default()(file != null, "Attempted to get the tags of media file without passing a file"); - const options = { - duration: true, - skipPostHeaders: true // avoid unnecessary data to be read - - }; - - if (typeof file === "string") { - return musicMetadata.fetchFromUrl(file, options); - } // Assume Blob - - - return musicMetadata.parseBlob(file, options); -} -function genMediaDuration(url) { - invariant__WEBPACK_IMPORTED_MODULE_0___default()(typeof url === "string", "Attempted to get the duration of media file without passing a url"); - return new Promise((resolve, reject) => { - // TODO: Does this actually stop downloading the file once it's - // got the duration? - const audio = document.createElement("audio"); - audio.crossOrigin = "anonymous"; - - const durationChange = () => { - resolve(audio.duration); - audio.removeEventListener("durationchange", durationChange); - audio.src = ""; // TODO: Not sure if this really gets cleaned up. - }; - - audio.addEventListener("durationchange", durationChange); - audio.addEventListener("error", e => { - reject(e); - }); - audio.src = url; - }); -} -async function genArrayBufferFromFileReference(fileReference) { - invariant__WEBPACK_IMPORTED_MODULE_0___default()(fileReference != null, "Attempt to get an ArrayBuffer without assigning a fileReference"); - return new Promise((resolve, reject) => { - const reader = new FileReader(); - - reader.onload = () => { - resolve(reader.result); - }; - - reader.onerror = reject; - reader.readAsArrayBuffer(fileReference); - }); -} -async function genStringFromFileReference(fileReference) { - return new Promise((resolve, reject) => { - const reader = new FileReader(); - - reader.onload = () => { - resolve(reader.result); - }; - - reader.onerror = reject; - reader.readAsText(fileReference); - }); -} -async function promptForFileReferences() { - let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { - accept: null, - directory: false - }, - accept = _ref.accept, - _ref$directory = _ref.directory, - directory = _ref$directory === void 0 ? false : _ref$directory; - - return new Promise(resolve => { - // Does this represent a memory leak somehow? - // Can this fail? Do we ever reject? - const fileInput = document.createElement("input"); - if (accept) fileInput.setAttribute("accept", accept); - fileInput.type = "file"; - fileInput.multiple = true; // @ts-ignore Non-standard - - fileInput.webkitdirectory = directory; // @ts-ignore Non-standard - - fileInput.directory = directory; // @ts-ignore Non-standard - - fileInput.mozdirectory = directory; // Not entirely sure why this is needed, since the input - // was just created, but somehow this helps prevent change - // events from getting swallowed. - // https://stackoverflow.com/a/12102992/1263117 - // @ts-ignore Technically you can't set this to null, it has to be a string. - // But I don't feel like retesting it, so I'll leave it as null - - fileInput.value = null; - fileInput.addEventListener("change", e => { - const files = e.target.files; - resolve(files); - }); - fileInput.click(); - }); -} - -function urlIsBlobUrl(url) { - return /^blob:/.test(url); -} // This is not perfect, but... meh: https://stackoverflow.com/a/36756650/1263117 - - -function filenameFromUrl(url) { - if (urlIsBlobUrl(url)) { - return null; - } - - const lastSegment = url.split("/").pop(); - - if (lastSegment == null) { - return null; - } - - return lastSegment.split("#")[0].split("?")[0]; -} - -/***/ }), -/* 20 */ -/***/ (function(module, exports) { - -function _extends() { - module.exports = _extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; - }; - - return _extends.apply(this, arguments); -} - -module.exports = _extends; - -/***/ }), -/* 21 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TransitionType; }); -/* harmony import */ var _reducers_windows__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(30); - - -let TransitionType; - -(function (TransitionType) { - TransitionType[TransitionType["IMMEDIATE"] = 0] = "IMMEDIATE"; - TransitionType[TransitionType["DEFAULT"] = 1] = "DEFAULT"; - TransitionType[TransitionType["USER_PRESET"] = 2] = "USER_PRESET"; -})(TransitionType || (TransitionType = {})); - -/***/ }), -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { - -var objectWithoutPropertiesLoose = __webpack_require__(179); - -function _objectWithoutProperties(source, excluded) { - if (source == null) return {}; - var target = objectWithoutPropertiesLoose(source, excluded); - var key, i; - - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - - for (i = 0; i < sourceSymbolKeys.length; i++) { - key = sourceSymbolKeys[i]; - if (excluded.indexOf(key) >= 0) continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; - target[key] = source[key]; - } - } - - return target; -} - -module.exports = _objectWithoutProperties; - -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; - -exports.default = function (obj, keys) { - var target = {}; - - for (var i in obj) { - if (keys.indexOf(i) >= 0) continue; - if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; - target[i] = obj[i]; - } - - return target; -}; - -/***/ }), -/* 24 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* unused harmony export SNAP_DISTANCE */ -/* unused harmony export top */ -/* unused harmony export bottom */ -/* unused harmony export left */ -/* unused harmony export right */ -/* unused harmony export near */ -/* unused harmony export overlapX */ -/* unused harmony export overlapY */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return snap; }); -/* unused harmony export snapDiff */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return snapDiffManyToMany; }); -/* unused harmony export snapToMany */ -/* unused harmony export snapWithin */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return snapWithinDiff; }); -/* unused harmony export applySnap */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return boundingBox; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return traceConnection; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return applyDiff; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return applyMultipleDiffs; }); -/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6); -/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__); - -const SNAP_DISTANCE = 15; -const top = box => box.y; -const bottom = box => box.y + box.height; -const left = box => box.x; -const right = box => box.x + box.width; -const near = (a, b) => Math.abs(a - b) < SNAP_DISTANCE; // http://stackoverflow.com/a/3269471/1263117 - -const overlapX = (a, b) => left(a) <= right(b) + SNAP_DISTANCE && left(b) <= right(a) + SNAP_DISTANCE; -const overlapY = (a, b) => top(a) <= bottom(b) + SNAP_DISTANCE && top(b) <= bottom(a) + SNAP_DISTANCE; // Give a new position for `boxA` that snaps it to `boxB` if neede. - -const snap = (boxA, boxB) => { - let x, y; // TODO: Refactor/simplify this code - - if (overlapY(boxA, boxB)) { - if (near(left(boxA), right(boxB))) { - x = right(boxB); - } else if (near(right(boxA), left(boxB))) { - x = left(boxB) - boxA.width; - } else if (near(left(boxA), left(boxB))) { - x = left(boxB); - } else if (near(right(boxA), right(boxB))) { - x = right(boxB) - boxA.width; - } - } - - if (overlapX(boxA, boxB)) { - if (near(top(boxA), bottom(boxB))) { - y = bottom(boxB); - } else if (near(bottom(boxA), top(boxB))) { - y = top(boxB) - boxA.height; - } else if (near(top(boxA), top(boxB))) { - y = top(boxB); - } else if (near(bottom(boxA), bottom(boxB))) { - y = bottom(boxB) - boxA.height; - } - } - - return { - x, - y - }; -}; -const snapDiff = (a, b) => { - const newPos = snap(a, b); - return { - x: newPos.x === undefined ? 0 : newPos.x - a.x, - y: newPos.y === undefined ? 0 : newPos.y - a.y - }; -}; // TODO: Use the first x and y combo - -const snapDiffManyToMany = (as, bs) => { - let x = 0; - let y = 0; - - for (const a of as) { - for (const b of bs) { - const diff = snapDiff(a, b); - x = x || diff.x; - y = y || diff.y; - - if (x !== undefined && x > 0 && y !== undefined && y > 0) { - break; - } - } - } - - return { - x, - y - }; -}; -const snapToMany = (boxA, otherBoxes) => { - let x; - let y; - otherBoxes.forEach(boxB => { - const newPos = snap(boxA, boxB); - x = newPos.x || x; - y = newPos.y || y; - }); - return { - x, - y - }; -}; -const snapWithin = (boxA, boundingBox) => { - let x, y; - - if (boxA.x - SNAP_DISTANCE < 0) { - x = 0; - } else if (boxA.x + boxA.width + SNAP_DISTANCE > boundingBox.width) { - x = boundingBox.width - boxA.width; - } - - if (boxA.y - SNAP_DISTANCE < 0) { - y = 0; - } else if (boxA.y + boxA.height + SNAP_DISTANCE > boundingBox.height) { - y = boundingBox.height - boxA.height; - } - - return { - x, - y - }; -}; -const snapWithinDiff = (a, b) => { - const newPos = snapWithin(a, b); - return { - x: newPos.x === undefined ? 0 : newPos.x - a.x, - y: newPos.y === undefined ? 0 : newPos.y - a.y - }; -}; -const applySnap = function applySnap(original) { - for (var _len = arguments.length, snaps = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - snaps[_key - 1] = arguments[_key]; - } - - return snaps.reduce((previous, snapped) => _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({}, previous, { - x: typeof snapped.x !== "undefined" ? snapped.x : previous.x, - y: typeof snapped.y !== "undefined" ? snapped.y : previous.y - }), original); -}; -const boundingBox = nodes => { - const boxes = nodes.slice(); - const firstNode = boxes.pop(); - - if (firstNode == null) { - throw new Error("boundingBox must be called with at least one node"); - } - - const bounding = { - top: top(firstNode), - right: right(firstNode), - bottom: bottom(firstNode), - left: left(firstNode) - }; - boxes.forEach(node => { - bounding.top = Math.min(bounding.top, top(node)); - bounding.right = Math.max(bounding.right, right(node)); - bounding.bottom = Math.max(bounding.bottom, bottom(node)); - bounding.left = Math.min(bounding.left, left(node)); - }); - return { - x: bounding.left, - y: bounding.top, - width: bounding.right - bounding.left, - height: bounding.bottom - bounding.top - }; -}; -const traceConnection = areConnected => (candidates, node) => { - const connected = new Set(); - - const checkNode = n => { - for (const candidate of candidates) { - if (!connected.has(candidate) && areConnected(candidate, n)) { - connected.add(candidate); - checkNode(candidate); - } - } - }; - - checkNode(node); - return connected; -}; -const applyDiff = (a, b) => ({ - x: a.x + b.x, - y: a.y + b.y -}); // TODO: This should not - -const applyMultipleDiffs = function applyMultipleDiffs(initial) { - for (var _len2 = arguments.length, diffs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - diffs[_key2 - 1] = arguments[_key2]; - } - - const metaDiff = diffs.reduce((m, diff) => ({ - // Use the smallest non-zero diff for each axis. - // TODO: Min should be the absolute value - x: m.x === 0 || diff.x === 0 ? m.x + diff.x : Math.min(m.x, diff.x), - y: m.y === 0 || diff.y === 0 ? m.y + diff.y : Math.min(m.y, diff.y) - })); - return applyDiff(initial, metaDiff); -}; - -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -// A fast streaming parser library. -Object.defineProperty(exports, "__esModule", { value: true }); -const assert = __webpack_require__(103); -// Possibly call flush() -const maybeFlush = (b, o, len, flush) => { - if (o + len > b.length) { - if (typeof (flush) !== "function") { - throw new Error("Buffer out of space and no valid flush() function found"); - } - flush(b, o); - return 0; - } - return o; -}; -// Primitive types -/** - * 8-bit unsigned integer - */ -exports.UINT8 = { - len: 1, - get(buf, off) { - return buf.readUInt8(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUInt8(v, no); - return (no - o) + this.len; - } -}; -/** - * 16-bit unsigned integer, Little Endian byte order - */ -exports.UINT16_LE = { - len: 2, - get(buf, off) { - return buf.readUInt16LE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUInt16LE(v, no); - return (no - o) + this.len; - } -}; -/** - * 16-bit unsigned integer, Big Endian byte order - */ -exports.UINT16_BE = { - len: 2, - get(buf, off) { - return buf.readUInt16BE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUInt16BE(v, no); - return (no - o) + this.len; - } -}; -/** - * 24-bit unsigned integer, Little Endian byte order - */ -exports.UINT24_LE = { - len: 3, - get(buf, off) { - return buf.readUIntLE(off, 3); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xffffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUIntLE(v, no, 3); - return (no - o) + this.len; - } -}; -/** - * 24-bit unsigned integer, Big Endian byte order - */ -exports.UINT24_BE = { - len: 3, - get(buf, off) { - return buf.readUIntBE(off, 3); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xffffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUIntBE(v, no, 3); - return (no - o) + this.len; - } -}; -/** - * 32-bit unsigned integer, Little Endian byte order - */ -exports.UINT32_LE = { - len: 4, - get(buf, off) { - return buf.readUInt32LE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xffffffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUInt32LE(v, no); - return (no - o) + this.len; - } -}; -/** - * 32-bit unsigned integer, Big Endian byte order - */ -exports.UINT32_BE = { - len: 4, - get(buf, off) { - return buf.readUInt32BE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= 0 && v <= 0xffffffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeUInt32BE(v, no); - return (no - o) + this.len; - } -}; -/** - * 8-bit signed integer - */ -exports.INT8 = { - len: 1, - get(buf, off) { - return buf.readInt8(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -128 && v <= 127); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeInt8(v, no); - return (no - o) + this.len; - } -}; -/** - * 16-bit signed integer, Big Endian byte order - */ -exports.INT16_BE = { - len: 2, - get(buf, off) { - return buf.readInt16BE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -32768 && v <= 32767); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeInt16BE(v, no); - return (no - o) + this.len; - } -}; -/** - * 16-bit signed integer, Little Endian byte order - */ -exports.INT16_LE = { - len: 2, - get(buf, off) { - return buf.readInt16LE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -32768 && v <= 32767); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeInt16LE(v, no); - return (no - o) + this.len; - } -}; -/** - * 24-bit signed integer, Little Endian byte order - */ -exports.INT24_LE = { - len: 3, - get(buf, off) { - return buf.readIntLE(off, 3); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -0x800000 && v <= 0x7fffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeIntLE(v, no, 3); - return (no - o) + this.len; - } -}; -/** - * 24-bit signed integer, Big Endian byte order - */ -exports.INT24_BE = { - len: 3, - get(buf, off) { - return buf.readIntBE(off, 3); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -0x800000 && v <= 0x7fffff); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeIntBE(v, no, 3); - return (no - o) + this.len; - } -}; -/** - * 32-bit signed integer, Big Endian byte order - */ -exports.INT32_BE = { - len: 4, - get(buf, off) { - return buf.readInt32BE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -2147483648 && v <= 2147483647); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeInt32BE(v, no); - return (no - o) + this.len; - } -}; -/** - * 32-bit signed integer, Big Endian byte order - */ -exports.INT32_LE = { - len: 4, - get(buf, off) { - return buf.readInt32LE(off); - }, - put(b, o, v, flush) { - assert.equal(typeof o, "number"); - assert.equal(typeof v, "number"); - assert.ok(v >= -2147483648 && v <= 2147483647); - assert.ok(o >= 0); - assert.ok(this.len <= b.length); - const no = maybeFlush(b, o, this.len, flush); - b.writeInt32LE(v, no); - return (no - o) + this.len; - } -}; -/** - * 64-bit unsigned integer, Little Endian byte order - */ -exports.UINT64_LE = { - len: 8, - get(buf, off) { - return readUIntLE(buf, off, this.len); - }, - put(b, o, v) { - return writeUIntLE(b, v, o, this.len); - } -}; -/** - * 64-bit signed integer, Little Endian byte order - */ -exports.INT64_LE = { - len: 8, - get(buf, off) { - return readIntLE(buf, off, this.len); - }, - put(b, off, v) { - return writeIntLE(b, v, off, this.len); - } -}; -/** - * 64-bit unsigned integer, Big Endian byte order - */ -exports.UINT64_BE = { - len: 8, - get(buf, off) { - return readUIntBE(buf, off, this.len); - }, - put(b, o, v) { - return writeUIntBE(b, v, o, this.len); - } -}; -/** - * 64-bit signed integer, Big Endian byte order - */ -exports.INT64_BE = { - len: 8, - get(buf, off) { - return readIntBE(buf, off, this.len); - }, - put(b, off, v) { - return writeIntBE(b, v, off, this.len); - } -}; -/** - * Ignore a given number of bytes - */ -class IgnoreType { - /** - * @param len number of bytes to ignore - */ - constructor(len) { - this.len = len; - } - // ToDo: don't read, but skip data - get(buf, off) { - return null; - } -} -exports.IgnoreType = IgnoreType; -class BufferType { - constructor(len) { - this.len = len; - } - get(buf, off) { - return buf.slice(off, off + this.len); - } -} -exports.BufferType = BufferType; -/** - * Consume a fixed number of bytes from the stream and return a string with a specified encoding. - */ -class StringType { - constructor(len, encoding) { - this.len = len; - this.encoding = encoding; - } - get(buf, off) { - return buf.toString(this.encoding, off, off + this.len); - } -} -exports.StringType = StringType; -/** - * ANSI Latin 1 String - * Using windows-1252 / ISO 8859-1 decoding - */ -class AnsiStringType { - constructor(len) { - this.len = len; - } - static decode(buffer, off, until) { - let str = ""; - for (let i = off; i < until; ++i) { - str += AnsiStringType.codePointToString(AnsiStringType.singleByteDecoder(buffer[i])); - } - return str; - } - static inRange(a, min, max) { - return min <= a && a <= max; - } - static codePointToString(cp) { - if (cp <= 0xFFFF) { - return String.fromCharCode(cp); - } - else { - cp -= 0x10000; - return String.fromCharCode((cp >> 10) + 0xD800, (cp & 0x3FF) + 0xDC00); - } - } - static singleByteDecoder(bite) { - if (AnsiStringType.inRange(bite, 0x00, 0x7F)) { - return bite; - } - const codePoint = AnsiStringType.windows1252[bite - 0x80]; - if (codePoint === null) { - throw Error("invaliding encoding"); - } - return codePoint; - } - get(buf, off = 0) { - return AnsiStringType.decode(buf, off, off + this.len); - } -} -AnsiStringType.windows1252 = [8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, - 8249, 338, 141, 381, 143, 144, 8216, 8217, 8220, 8221, 8226, 8211, 8212, 732, - 8482, 353, 8250, 339, 157, 382, 376, 160, 161, 162, 163, 164, 165, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, - 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, - 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 254, 255]; -exports.AnsiStringType = AnsiStringType; -/** - * Best effort approach to read up to 64 bit unsigned integer, little endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function readUIntLE(buf, offset, byteLength) { - offset = offset >>> 0; - byteLength = byteLength >>> 0; - let val = buf[offset]; - let mul = 1; - let i = 0; - while (++i < byteLength && (mul *= 0x100)) { - val += buf[offset + i] * mul; - } - return val; -} -/** - * Best effort approach to write up to 64 bit unsigned integer, little endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function writeUIntLE(buf, value, offset, byteLength) { - value = +value; - offset = offset >>> 0; - byteLength = byteLength >>> 0; - let mul = 1; - let i = 0; - buf[offset] = value & 0xFF; - while (++i < byteLength && (mul *= 0x100)) { - buf[offset + i] = (value / mul) & 0xFF; - } - return offset + byteLength; -} -/** - * Best effort approach to read 64 but signed integer, little endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function readIntLE(buf, offset, byteLength) { - offset = offset >>> 0; - byteLength = byteLength >>> 0; - let val = buf[offset]; - let mul = 1; - let i = 0; - while (++i < byteLength && (mul *= 0x100)) { - val += buf[offset + i] * mul; - } - mul *= 0x80; - if (val >= mul) - val -= Math.pow(2, 8 * byteLength); - return val; -} -/** - * Best effort approach to write 64 but signed integer, little endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function writeIntLE(buf, value, offset, byteLength) { - value = +value; - offset = offset >>> 0; - let i = 0; - let mul = 1; - let sub = 0; - buf[offset] = value & 0xFF; - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && buf[offset + i - 1] !== 0) { - sub = 1; - } - buf[offset + i] = ((value / mul) >> 0) - sub & 0xFF; - } - return offset + byteLength; -} -exports.writeIntLE = writeIntLE; -/** - * Best effort approach to read up to 64 bit unsigned integer, big endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function readUIntBE(buf, offset, byteLength) { - offset = offset >>> 0; - byteLength = byteLength >>> 0; - let val = buf[offset + --byteLength]; - let mul = 1; - while (byteLength > 0 && (mul *= 0x100)) { - val += buf[offset + --byteLength] * mul; - } - return val; -} -exports.readUIntBE = readUIntBE; -/** - * Best effort approach to write up to 64 bit unsigned integer, big endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function writeUIntBE(buf, value, offset, byteLength) { - value = +value; - offset = offset >>> 0; - byteLength = byteLength >>> 0; - let i = byteLength - 1; - let mul = 1; - buf[offset + i] = value & 0xFF; - while (--i >= 0 && (mul *= 0x100)) { - buf[offset + i] = (value / mul) & 0xFF; - } - return offset + byteLength; -} -exports.writeUIntBE = writeUIntBE; -/** - * Best effort approach to read 64 but signed integer, big endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function readIntBE(buf, offset, byteLength) { - offset = offset >>> 0; - byteLength = byteLength >>> 0; - let i = byteLength; - let mul = 1; - let val = buf[offset + --i]; - while (i > 0 && (mul *= 0x100)) { - val += buf[offset + --i] * mul; - } - mul *= 0x80; - if (val >= mul) - val -= Math.pow(2, 8 * byteLength); - return val; -} -exports.readIntBE = readIntBE; -/** - * Best effort approach to write 64 but signed integer, big endian. - * Note that JavasScript is limited to 2^53 - 1 bit. - */ -function writeIntBE(buf, value, offset, byteLength) { - value = +value; - offset = offset >>> 0; - let i = byteLength - 1; - let mul = 1; - let sub = 0; - buf[offset + i] = value & 0xFF; - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && buf[offset + i + 1] !== 0) { - sub = 1; - } - buf[offset + i] = ((value / mul) >> 0) - sub & 0xFF; - } - return offset + byteLength; -} -exports.writeIntBE = writeIntBE; - - -/***/ }), -/* 26 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var support = __webpack_require__(76); -var base64 = __webpack_require__(266); -var nodejsUtils = __webpack_require__(142); -var setImmediate = __webpack_require__(309); -var external = __webpack_require__(105); - - -/** - * Convert a string that pass as a "binary string": it should represent a byte - * array but may have > 255 char codes. Be sure to take only the first byte - * and returns the byte array. - * @param {String} str the string to transform. - * @return {Array|Uint8Array} the string in a binary format. - */ -function string2binary(str) { - var result = null; - if (support.uint8array) { - result = new Uint8Array(str.length); - } else { - result = new Array(str.length); - } - return stringToArrayLike(str, result); -} - -/** - * Create a new blob with the given content and the given type. - * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use - * an Uint8Array because the stock browser of android 4 won't accept it (it - * will be silently converted to a string, "[object Uint8Array]"). - * - * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge: - * when a large amount of Array is used to create the Blob, the amount of - * memory consumed is nearly 100 times the original data amount. - * - * @param {String} type the mime type of the blob. - * @return {Blob} the created blob. - */ -exports.newBlob = function(part, type) { - exports.checkSupport("blob"); - - try { - // Blob constructor - return new Blob([part], { - type: type - }); - } - catch (e) { - - try { - // deprecated, browser only, old way - var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder; - var builder = new Builder(); - builder.append(part); - return builder.getBlob(type); - } - catch (e) { - - // well, fuck ?! - throw new Error("Bug : can't construct the Blob."); - } - } - - -}; -/** - * The identity function. - * @param {Object} input the input. - * @return {Object} the same input. - */ -function identity(input) { - return input; -} - -/** - * Fill in an array with a string. - * @param {String} str the string to use. - * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated). - * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array. - */ -function stringToArrayLike(str, array) { - for (var i = 0; i < str.length; ++i) { - array[i] = str.charCodeAt(i) & 0xFF; - } - return array; -} - -/** - * An helper for the function arrayLikeToString. - * This contains static informations and functions that - * can be optimized by the browser JIT compiler. - */ -var arrayToStringHelper = { - /** - * Transform an array of int into a string, chunk by chunk. - * See the performances notes on arrayLikeToString. - * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform. - * @param {String} type the type of the array. - * @param {Integer} chunk the chunk size. - * @return {String} the resulting string. - * @throws Error if the chunk is too big for the stack. - */ - stringifyByChunk: function(array, type, chunk) { - var result = [], k = 0, len = array.length; - // shortcut - if (len <= chunk) { - return String.fromCharCode.apply(null, array); - } - while (k < len) { - if (type === "array" || type === "nodebuffer") { - result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len)))); - } - else { - result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len)))); - } - k += chunk; - } - return result.join(""); - }, - /** - * Call String.fromCharCode on every item in the array. - * This is the naive implementation, which generate A LOT of intermediate string. - * This should be used when everything else fail. - * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform. - * @return {String} the result. - */ - stringifyByChar: function(array){ - var resultStr = ""; - for(var i = 0; i < array.length; i++) { - resultStr += String.fromCharCode(array[i]); - } - return resultStr; - }, - applyCanBeUsed : { - /** - * true if the browser accepts to use String.fromCharCode on Uint8Array - */ - uint8array : (function () { - try { - return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1; - } catch (e) { - return false; - } - })(), - /** - * true if the browser accepts to use String.fromCharCode on nodejs Buffer. - */ - nodebuffer : (function () { - try { - return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1; - } catch (e) { - return false; - } - })() - } -}; - -/** - * Transform an array-like object to a string. - * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform. - * @return {String} the result. - */ -function arrayLikeToString(array) { - // Performances notes : - // -------------------- - // String.fromCharCode.apply(null, array) is the fastest, see - // see http://jsperf.com/converting-a-uint8array-to-a-string/2 - // but the stack is limited (and we can get huge arrays !). - // - // result += String.fromCharCode(array[i]); generate too many strings ! - // - // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2 - // TODO : we now have workers that split the work. Do we still need that ? - var chunk = 65536, - type = exports.getTypeOf(array), - canUseApply = true; - if (type === "uint8array") { - canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array; - } else if (type === "nodebuffer") { - canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer; - } - - if (canUseApply) { - while (chunk > 1) { - try { - return arrayToStringHelper.stringifyByChunk(array, type, chunk); - } catch (e) { - chunk = Math.floor(chunk / 2); - } - } - } - - // no apply or chunk error : slow and painful algorithm - // default browser on android 4.* - return arrayToStringHelper.stringifyByChar(array); -} - -exports.applyFromCharCode = arrayLikeToString; - - -/** - * Copy the data from an array-like to an other array-like. - * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array. - * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated. - * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array. - */ -function arrayLikeToArrayLike(arrayFrom, arrayTo) { - for (var i = 0; i < arrayFrom.length; i++) { - arrayTo[i] = arrayFrom[i]; - } - return arrayTo; -} - -// a matrix containing functions to transform everything into everything. -var transform = {}; - -// string to ? -transform["string"] = { - "string": identity, - "array": function(input) { - return stringToArrayLike(input, new Array(input.length)); - }, - "arraybuffer": function(input) { - return transform["string"]["uint8array"](input).buffer; - }, - "uint8array": function(input) { - return stringToArrayLike(input, new Uint8Array(input.length)); - }, - "nodebuffer": function(input) { - return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length)); - } -}; - -// array to ? -transform["array"] = { - "string": arrayLikeToString, - "array": identity, - "arraybuffer": function(input) { - return (new Uint8Array(input)).buffer; - }, - "uint8array": function(input) { - return new Uint8Array(input); - }, - "nodebuffer": function(input) { - return nodejsUtils.newBufferFrom(input); - } -}; - -// arraybuffer to ? -transform["arraybuffer"] = { - "string": function(input) { - return arrayLikeToString(new Uint8Array(input)); - }, - "array": function(input) { - return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength)); - }, - "arraybuffer": identity, - "uint8array": function(input) { - return new Uint8Array(input); - }, - "nodebuffer": function(input) { - return nodejsUtils.newBufferFrom(new Uint8Array(input)); - } -}; - -// uint8array to ? -transform["uint8array"] = { - "string": arrayLikeToString, - "array": function(input) { - return arrayLikeToArrayLike(input, new Array(input.length)); - }, - "arraybuffer": function(input) { - return input.buffer; - }, - "uint8array": identity, - "nodebuffer": function(input) { - return nodejsUtils.newBufferFrom(input); - } -}; - -// nodebuffer to ? -transform["nodebuffer"] = { - "string": arrayLikeToString, - "array": function(input) { - return arrayLikeToArrayLike(input, new Array(input.length)); - }, - "arraybuffer": function(input) { - return transform["nodebuffer"]["uint8array"](input).buffer; - }, - "uint8array": function(input) { - return arrayLikeToArrayLike(input, new Uint8Array(input.length)); - }, - "nodebuffer": identity -}; - -/** - * Transform an input into any type. - * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer. - * If no output type is specified, the unmodified input will be returned. - * @param {String} outputType the output type. - * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert. - * @throws {Error} an Error if the browser doesn't support the requested output type. - */ -exports.transformTo = function(outputType, input) { - if (!input) { - // undefined, null, etc - // an empty string won't harm. - input = ""; - } - if (!outputType) { - return input; - } - exports.checkSupport(outputType); - var inputType = exports.getTypeOf(input); - var result = transform[inputType][outputType](input); - return result; -}; - -/** - * Return the type of the input. - * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer. - * @param {Object} input the input to identify. - * @return {String} the (lowercase) type of the input. - */ -exports.getTypeOf = function(input) { - if (typeof input === "string") { - return "string"; - } - if (Object.prototype.toString.call(input) === "[object Array]") { - return "array"; - } - if (support.nodebuffer && nodejsUtils.isBuffer(input)) { - return "nodebuffer"; - } - if (support.uint8array && input instanceof Uint8Array) { - return "uint8array"; - } - if (support.arraybuffer && input instanceof ArrayBuffer) { - return "arraybuffer"; - } -}; - -/** - * Throw an exception if the type is not supported. - * @param {String} type the type to check. - * @throws {Error} an Error if the browser doesn't support the requested type. - */ -exports.checkSupport = function(type) { - var supported = support[type.toLowerCase()]; - if (!supported) { - throw new Error(type + " is not supported by this platform"); - } -}; - -exports.MAX_VALUE_16BITS = 65535; -exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1 - -/** - * Prettify a string read as binary. - * @param {string} str the string to prettify. - * @return {string} a pretty string. - */ -exports.pretty = function(str) { - var res = '', - code, i; - for (i = 0; i < (str || "").length; i++) { - code = str.charCodeAt(i); - res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase(); - } - return res; -}; - -/** - * Defer the call of a function. - * @param {Function} callback the function to call asynchronously. - * @param {Array} args the arguments to give to the callback. - */ -exports.delay = function(callback, args, self) { - setImmediate(function () { - callback.apply(self || null, args || []); - }); -}; - -/** - * Extends a prototype with an other, without calling a constructor with - * side effects. Inspired by nodejs' `utils.inherits` - * @param {Function} ctor the constructor to augment - * @param {Function} superCtor the parent constructor to use - */ -exports.inherits = function (ctor, superCtor) { - var Obj = function() {}; - Obj.prototype = superCtor.prototype; - ctor.prototype = new Obj(); -}; - -/** - * Merge the objects passed as parameters into a new one. - * @private - * @param {...Object} var_args All objects to merge. - * @return {Object} a new object with the data of the others. - */ -exports.extend = function() { - var result = {}, i, attr; - for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers - for (attr in arguments[i]) { - if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") { - result[attr] = arguments[i][attr]; - } - } - } - return result; -}; - -/** - * Transform arbitrary content into a Promise. - * @param {String} name a name for the content being processed. - * @param {Object} inputData the content to process. - * @param {Boolean} isBinary true if the content is not an unicode string - * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character. - * @param {Boolean} isBase64 true if the string content is encoded with base64. - * @return {Promise} a promise in a format usable by JSZip. - */ -exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) { - - // if inputData is already a promise, this flatten it. - var promise = external.Promise.resolve(inputData).then(function(data) { - - - var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1); - - if (isBlob && typeof FileReader !== "undefined") { - return new external.Promise(function (resolve, reject) { - var reader = new FileReader(); - - reader.onload = function(e) { - resolve(e.target.result); - }; - reader.onerror = function(e) { - reject(e.target.error); - }; - reader.readAsArrayBuffer(data); - }); - } else { - return data; - } - }); - - return promise.then(function(data) { - var dataType = exports.getTypeOf(data); - - if (!dataType) { - return external.Promise.reject( - new Error("Can't read the data of '" + name + "'. Is it " + - "in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?") - ); - } - // special case : it's way easier to work with Uint8Array than with ArrayBuffer - if (dataType === "arraybuffer") { - data = exports.transformTo("uint8array", data); - } else if (dataType === "string") { - if (isBase64) { - data = base64.decode(data); - } - else if (isBinary) { - // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask - if (isOptimizedBinaryString !== true) { - // this is a string, not in a base64 format. - // Be sure that this is a correct "binary string" - data = string2binary(data); - } - } - } - return data; - }); -}; - - -/***/ }), -/* 27 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(global) {/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - - - -var base64 = __webpack_require__(297) -var ieee754 = __webpack_require__(298) -var isArray = __webpack_require__(259) - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Due to various browser bugs, sometimes the Object implementation will be used even - * when the browser supports typed arrays. - * - * Note: - * - * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they - * get the Object implementation, which is slower but behaves correctly. - */ -Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined - ? global.TYPED_ARRAY_SUPPORT - : typedArraySupport() - -/* - * Export kMaxLength after typed array support is determined. - */ -exports.kMaxLength = kMaxLength() - -function typedArraySupport () { - try { - var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } -} - -function kMaxLength () { - return Buffer.TYPED_ARRAY_SUPPORT - ? 0x7fffffff - : 0x3fffffff -} - -function createBuffer (that, length) { - if (kMaxLength() < length) { - throw new RangeError('Invalid typed array length') - } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = new Uint8Array(length) - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - if (that === null) { - that = new Buffer(length) - } - that.length = length - } - - return that -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { - return new Buffer(arg, encodingOrOffset, length) - } - - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' - ) - } - return allocUnsafe(this, arg) - } - return from(this, arg, encodingOrOffset, length) -} - -Buffer.poolSize = 8192 // not used by this implementation - -// TODO: Legacy, not needed anymore. Remove in next major version. -Buffer._augment = function (arr) { - arr.__proto__ = Buffer.prototype - return arr -} - -function from (that, value, encodingOrOffset, length) { - if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') - } - - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - return fromArrayBuffer(that, value, encodingOrOffset, length) - } - - if (typeof value === 'string') { - return fromString(that, value, encodingOrOffset) - } - - return fromObject(that, value) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(null, value, encodingOrOffset, length) -} - -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true - }) - } -} - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be a number') - } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') - } -} - -function alloc (that, size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(that, size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(that, size).fill(fill, encoding) - : createBuffer(that, size).fill(fill) - } - return createBuffer(that, size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(null, size, fill, encoding) -} - -function allocUnsafe (that, size) { - assertSize(size) - that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < size; ++i) { - that[i] = 0 - } - } - return that -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(null, size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(null, size) -} - -function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('"encoding" must be a valid string encoding') - } - - var length = byteLength(string, encoding) | 0 - that = createBuffer(that, length) - - var actual = that.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - that = that.slice(0, actual) - } - - return that -} - -function fromArrayLike (that, array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - that = createBuffer(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that -} - -function fromArrayBuffer (that, array, byteOffset, length) { - array.byteLength // this throws if `array` is not a valid ArrayBuffer - - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('\'offset\' is out of bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('\'length\' is out of bounds') - } - - if (byteOffset === undefined && length === undefined) { - array = new Uint8Array(array) - } else if (length === undefined) { - array = new Uint8Array(array, byteOffset) - } else { - array = new Uint8Array(array, byteOffset, length) - } - - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = array - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - that = fromArrayLike(that, array) - } - return that -} - -function fromObject (that, obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - that = createBuffer(that, len) - - if (that.length === 0) { - return that - } - - obj.copy(that, 0, 0, len) - return that - } - - if (obj) { - if ((typeof ArrayBuffer !== 'undefined' && - obj.buffer instanceof ArrayBuffer) || 'length' in obj) { - if (typeof obj.length !== 'number' || isnan(obj.length)) { - return createBuffer(that, 0) - } - return fromArrayLike(that, obj) - } - - if (obj.type === 'Buffer' && isArray(obj.data)) { - return fromArrayLike(that, obj.data) - } - } - - throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') -} - -function checked (length) { - // Note: cannot use `length < kMaxLength()` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) -} - -Buffer.compare = function compare (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers') - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && - (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - string = '' + string - } - - var len = string.length - if (len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - case undefined: - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect -// Buffer instances. -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length | 0 - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (!Buffer.isBuffer(target)) { - throw new TypeError('Argument must be a Buffer') - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (isNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (Buffer.TYPED_ARRAY_SUPPORT && - typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - // must be an even number of digits - var strLen = string.length - if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset | 0 - if (isFinite(length)) { - length = length | 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - // legacy write(string, encoding, offset, length) - remove in v0.13 - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = this.subarray(start, end) - newBuf.__proto__ = Buffer.prototype - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; ++i) { - newBuf[i] = this[i + start] - } - } - - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - byteLength = byteLength | 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = (value & 0xff) - return offset + 1 -} - -function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset | 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - var i - - if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - // ascending copy from start - for (i = 0; i < len; ++i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, start + len), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if (code < 256) { - val = code - } - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : utf8ToBytes(new Buffer(val, encoding).toString()) - var len = bytes.length - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -function isnan (val) { - return val !== val // eslint-disable-line no-self-compare -} - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(34))) - -/***/ }), -/* 28 */ -/***/ (function(module, exports) { - -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -// css base code, injected by the css-loader -module.exports = function(useSourceMap) { - var list = []; - - // return the list of modules as css string - list.toString = function toString() { - return this.map(function (item) { - var content = cssWithMappingToString(item, useSourceMap); - if(item[2]) { - return "@media " + item[2] + "{" + content + "}"; - } else { - return content; - } - }).join(""); - }; - - // import a list of modules into the list - list.i = function(modules, mediaQuery) { - if(typeof modules === "string") - modules = [[null, modules, ""]]; - var alreadyImportedModules = {}; - for(var i = 0; i < this.length; i++) { - var id = this[i][0]; - if(typeof id === "number") - alreadyImportedModules[id] = true; - } - for(i = 0; i < modules.length; i++) { - var item = modules[i]; - // skip already imported module - // this implementation is not 100% perfect for weird media query combinations - // when a module is imported multiple times with different media queries. - // I hope this will never occur (Hey this way we have smaller bundles) - if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { - if(mediaQuery && !item[2]) { - item[2] = mediaQuery; - } else if(mediaQuery) { - item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; - } - list.push(item); - } - } - }; - return list; -}; - -function cssWithMappingToString(item, useSourceMap) { - var content = item[1] || ''; - var cssMapping = item[3]; - if (!cssMapping) { - return content; - } - - if (useSourceMap && typeof btoa === 'function') { - var sourceMapping = toComment(cssMapping); - var sourceURLs = cssMapping.sources.map(function (source) { - return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' - }); - - return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); - } - - return [content].join('\n'); -} - -// Adapted from convert-source-map (MIT) -function toComment(sourceMap) { - // eslint-disable-next-line no-undef - var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); - var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; - - return '/*# ' + data + ' */'; -} - - -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { - -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -var stylesInDom = {}; - -var memoize = function (fn) { - var memo; - - return function () { - if (typeof memo === "undefined") memo = fn.apply(this, arguments); - return memo; - }; -}; - -var isOldIE = memoize(function () { - // Test for IE <= 9 as proposed by Browserhacks - // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805 - // Tests for existence of standard globals is to allow style-loader - // to operate correctly into non-standard environments - // @see https://github.com/webpack-contrib/style-loader/issues/177 - return window && document && document.all && !window.atob; -}); - -var getTarget = function (target, parent) { - if (parent){ - return parent.querySelector(target); - } - return document.querySelector(target); -}; - -var getElement = (function (fn) { - var memo = {}; - - return function(target, parent) { - // If passing function in options, then use it for resolve "head" element. - // Useful for Shadow Root style i.e - // { - // insertInto: function () { return document.querySelector("#foo").shadowRoot } - // } - if (typeof target === 'function') { - return target(); - } - if (typeof memo[target] === "undefined") { - var styleTarget = getTarget.call(this, target, parent); - // Special case to return head of iframe instead of iframe itself - if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) { - try { - // This will throw an exception if access to iframe is blocked - // due to cross-origin restrictions - styleTarget = styleTarget.contentDocument.head; - } catch(e) { - styleTarget = null; - } - } - memo[target] = styleTarget; - } - return memo[target] - }; -})(); - -var singleton = null; -var singletonCounter = 0; -var stylesInsertedAtTop = []; - -var fixUrls = __webpack_require__(178); - -module.exports = function(list, options) { - if (typeof DEBUG !== "undefined" && DEBUG) { - if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment"); - } - - options = options || {}; - - options.attrs = typeof options.attrs === "object" ? options.attrs : {}; - - // Force single-tag solution on IE6-9, which has a hard limit on the # of