From 70b4cc5adcef18d498b539579ecfa626aa5e6c18 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 30 Aug 2018 22:59:28 +0200 Subject: group sequences/checkpoints by folder --- app/client/common/index.js | 3 +- app/client/common/selectGroup.component.js | 66 ++++++++++++++++++++++ app/client/live/live.reducer.js | 9 +++ .../modules/pix2pixhd/views/pix2pixhd.live.js | 49 ++++++++++++++-- app/client/socket/socket.actions.js | 25 +++----- app/client/socket/socket.live.js | 14 ++++- 6 files changed, 141 insertions(+), 25 deletions(-) create mode 100644 app/client/common/selectGroup.component.js (limited to 'app') diff --git a/app/client/common/index.js b/app/client/common/index.js index 3981fa7..025b56c 100644 --- a/app/client/common/index.js +++ b/app/client/common/index.js @@ -13,6 +13,7 @@ import ParamGroup from './paramGroup.component' import Player from './player.component' import Progress from './progress.component' import Select from './select.component' +import SelectGroup from './selectGroup.component' import Slider from './slider.component' import TextInput from './textInput.component' import * as Views from './views' @@ -23,6 +24,6 @@ export { FolderList, FileList, FileRow, FileUpload, Gallery, Player, Group, ParamGroup, Param, - TextInput, Slider, Select, Button, Checkbox, + TextInput, Slider, Select, SelectGroup, Button, Checkbox, CurrentTask, } \ No newline at end of file diff --git a/app/client/common/selectGroup.component.js b/app/client/common/selectGroup.component.js new file mode 100644 index 0000000..b653fdf --- /dev/null +++ b/app/client/common/selectGroup.component.js @@ -0,0 +1,66 @@ +import { h, Component } from 'preact' +import { connect } from 'react-redux' +import { bindActionCreators } from 'redux' + +class SelectGroup extends Component { + constructor(props){ + super(props) + this.handleChange = this.handleChange.bind(this) + } + handleChange(e){ + clearTimeout(this.timeout) + let new_value = e.target.value + if (new_value === 'PLACEHOLDER') return + this.props.onChange && this.props.onChange(this.props.name, new_value) + } + render() { + const currentValue = this.props.live ? this.props.opt[this.props.name] : this.props.value + let lastValue + const options = (this.props.options || []).map((group, i) => { + const groupName = group.name + const children = group.options.map(key => { + let name = key.length < 2 ? key.toUpperCase() : key + let value = key.replace(/_/g, ' ') + lastValue = value + return ( + + ) + }) + return ( + + {children} + + ) + }) + return ( +
+ + {this.props.children} +
+ ) + } +} + +function capitalize(s){ + return (s || "").replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); +} + +const mapStateToProps = (state, props) => ({ + opt: props.opt || state.live.opt, +}) + +const mapDispatchToProps = (dispatch, ownProps) => ({ +}) + +export default connect(mapStateToProps, mapDispatchToProps)(SelectGroup) diff --git a/app/client/live/live.reducer.js b/app/client/live/live.reducer.js index 7fd7667..dfdf7ee 100644 --- a/app/client/live/live.reducer.js +++ b/app/client/live/live.reducer.js @@ -11,6 +11,7 @@ const liveInitialState = { recurse_roll: 0, rotate: 0, scale: 0, process_frac: 0.5, view_mode: 'b', }, + all_checkpoints: [], checkpoints: [], epochs: ['latest'], sequences: [], @@ -57,7 +58,15 @@ const liveReducer = (state = liveInitialState, action) => { epochs: [], } + case types.socket.list_all_checkpoints: + return { + ...state, + all_checkpoints: action.all_checkpoints, + epochs: [], + } + case types.socket.list_epochs: + console.log(action) if (action.epochs === "not found") return { ...state, epochs: [] } return { ...state, diff --git a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js index b127e23..41ff7e5 100644 --- a/app/client/modules/pix2pixhd/views/pix2pixhd.live.js +++ b/app/client/modules/pix2pixhd/views/pix2pixhd.live.js @@ -4,7 +4,7 @@ import { connect } from 'react-redux' import { ParamGroup, Param, Player, Group, - Slider, Select, TextInput, Button, Loading + Slider, SelectGroup, Select, TextInput, Button, Loading } from '../../../common/' import { startRecording, stopRecording, saveFrame, toggleFPS } from '../../../live/player' @@ -39,6 +39,7 @@ class Pix2PixHDLive extends Component { } componentWillUpdate(nextProps) { if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { + console.log('listing epochs') this.props.actions.live.list_epochs('pix2pixhd', nextProps.opt.checkpoint_name) } } @@ -101,6 +102,44 @@ class Pix2PixHDLive extends Component { if (this.props.pix2pixhd.loading) { return } + const { folderLookup, datasetLookup, sequences } = this.props.pix2pixhd.data + + const sequenceLookup = sequences.reduce((a,b) => { + a[b.name] = true + return a + }, {}) + + const sequenceGroups = Object.keys(folderLookup).map(id => { + const folder = this.props.pix2pixhd.data.folderLookup[id] + if (folder.name === 'results') return + const datasets = folder.datasets.map(name => { + const sequence = sequenceLookup[name] + if (sequence) { + return name + } + return null + }).filter(n => !!n) + return { + name: folder.name, + options: datasets.sort(), + } + }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) + + const checkpointGroups = Object.keys(folderLookup).map(id => { + const folder = this.props.pix2pixhd.data.folderLookup[id] + if (folder.name === 'results') return + const datasets = folder.datasets.map(name => { + const dataset = datasetLookup[name] + if (dataset.checkpoints.length) { + return name + } + return null + }).filter(n => !!n) + return { + name: folder.name, + options: datasets.sort(), + } + }).filter(n => !!n && !!n.options.length).sort((a,b) => a.name.localeCompare(b.name)) return (
@@ -116,16 +155,16 @@ class Pix2PixHDLive extends Component { options={['a','b','sequence','recursive']} onChange={this.props.actions.live.set_param} /> - file.name)} + options={checkpointGroups} onChange={this.changeCheckpoint} /> (57:8)\n\n\u001b[0m \u001b[90m 55 | \u001b[39m recursive frames \u001b[36mfor\u001b[39m each one\u001b[33m.\u001b[39m\n \u001b[90m 56 | \u001b[39m these will be added to the current dataset\u001b[33m.\u001b[39m\n\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 57 | \u001b[39m \u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mdiv\u001b[39m\u001b[33m>\u001b[39m\n \u001b[90m | \u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\n \u001b[90m 58 | \u001b[39m \u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m \u001b[36mclass\u001b[39m\u001b[33m=\u001b[39m\u001b[32m'heading'\u001b[39m\u001b[33m>\u001b[39m\n \u001b[90m 59 | \u001b[39m \u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m \u001b[36mclass\u001b[39m\u001b[33m=\u001b[39m\u001b[32m'spaced'\u001b[39m\u001b[33m>\u001b[39m\n \u001b[90m 60 | \u001b[39m \u001b[33m<\u001b[39m\u001b[33mh1\u001b[39m\u001b[33m>\u001b[39m{folder \u001b[33m?\u001b[39m folder\u001b[33m.\u001b[39mname \u001b[33m:\u001b[39m \u001b[33m<\u001b[39m\u001b[33mLoading\u001b[39m \u001b[33m/\u001b[39m\u001b[33m>\u001b[39m}\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mh1\u001b[39m\u001b[33m>\u001b[39m\u001b[0m\n"); + +/***/ }), + +/***/ "./app/client/modules/pix2wav/index.js": +/*!*********************************************!*\ + !*** ./app/client/modules/pix2wav/index.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); + +var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _pix2wav = __webpack_require__(/*! ./views/pix2wav.new */ "./app/client/modules/pix2wav/views/pix2wav.new.js"); + +var _pix2wav2 = _interopRequireDefault(_pix2wav); + +var _pix2wav3 = __webpack_require__(/*! ./views/pix2wav.show */ "./app/client/modules/pix2wav/views/pix2wav.show.js"); + +var _pix2wav4 = _interopRequireDefault(_pix2wav3); + +var _pix2wav5 = __webpack_require__(/*! ./views/pix2wav.live */ "./app/client/modules/pix2wav/views/pix2wav.live.js"); + +var _pix2wav6 = _interopRequireDefault(_pix2wav5); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var router = function () { + function router() { + _classCallCheck(this, router); + } + + _createClass(router, [{ + key: 'componentWillMount', + value: function componentWillMount() { + _actions2.default.system.changeTool('pix2wav'); + document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #bdf, #def)'; + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps() { + _actions2.default.system.changeTool('pix2wav'); + document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #bdf, #def)'; + } + }, { + key: 'render', + value: function render() { + return (0, _preact.h)( + 'section', + null, + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/new/', component: _pix2wav2.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/datasets/', component: _pix2wav4.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/datasets/:id/', component: _pix2wav4.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/pix2wav/live/', component: _pix2wav6.default }) + ); + } + }]); + + return router; +}(); + +function links() { + return [{ url: '/pix2wav/new/', name: 'new' }, { url: '/pix2wav/datasets/', name: 'datasets' }, { url: '/pix2wav/live/', name: 'live' }]; +} + +exports.default = { + name: 'pix2wav', + router: router, links: links +}; + +/***/ }), + +/***/ "./app/client/modules/pix2wav/pix2wav.actions.js": +/*!*******************************************************!*\ + !*** ./app/client/modules/pix2wav/pix2wav.actions.js ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.load_directories = undefined; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); + +var _v2 = _interopRequireDefault(_v); + +var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); + +var _socket2 = _interopRequireDefault(_socket); + +var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _dataset = __webpack_require__(/*! ../../dataset/dataset.loader */ "./app/client/dataset/dataset.loader.js"); + +var datasetLoader = _interopRequireWildcard(_dataset); + +var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _pix2wav = __webpack_require__(/*! ./pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); + +var _pix2wav2 = _interopRequireDefault(_pix2wav); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var load_directories = exports.load_directories = function load_directories(id) { + return function (dispatch) { + var module = _pix2wav2.default.name; + _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'sequences/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'datasets/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'checkpoints/pix2wav/' }), _actions2.default.socket.list_directory({ module: 'pix2pix', dir: 'checkpoints/pix2pix/' })], function (percent, i, n) { + console.log('progress', i, n); + dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); + }).then(function (res) { + var _res = _slicedToArray(res, 5), + datasetApiReport = _res[0], + sequences = _res[1], + datasets = _res[2], + checkpoints = _res[3], + pix2pixCheckpoints = _res[4]; + + var folderLookup = datasetApiReport.folderLookup, + fileLookup = datasetApiReport.fileLookup, + datasetLookup = datasetApiReport.datasetLookup, + folders = datasetApiReport.folders, + files = datasetApiReport.files, + unsortedFolder = datasetApiReport.unsortedFolder; + + + var sequenceDirectories = sequences.filter(function (s) { + return s.dir; + }); + sequenceDirectories.forEach(function (dir) { + var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); + dataset.isBuilt = true; + }); + + datasets.filter(function (s) { + return s.dir; + }).forEach(function (dir) { + var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); + dataset.hasDataset = true; + }); + + var checkpointDirectories = checkpoints.filter(function (s) { + return s.dir; + }); + checkpointDirectories.forEach(function (dir) { + var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); + dataset.hasCheckpoints = true; + dir.module = 'pix2wav'; + }); + + var pix2pixCheckpointDirectories = pix2pixCheckpoints.filter(function (s) { + return s.dir; + }); + pix2pixCheckpointDirectories.forEach(function (dir) { + var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name); + dataset.hasCheckpoints = true; + dir.module = 'pix2pix'; + }); + + console.log(res); + console.log(checkpointDirectories); + console.log(pix2pixCheckpointDirectories); + + dispatch({ + type: _types2.default.dataset.load, + data: { + module: module, + folderLookup: folderLookup, + fileLookup: fileLookup, + datasetLookup: datasetLookup, + folders: folders, files: files, + sequences: sequenceDirectories, + datasets: datasets, + checkpoints: checkpointDirectories.concat(pix2pixCheckpointDirectories) + } + }); + }).catch(function (e) { + console.error(e); + }); + if (id) { + console.log('folder id', id); + dispatch({ + type: _types2.default.dataset.set_folder, + data: { + folder_id: id, + module: module + } + }); + } + }; +}; + +/***/ }), + +/***/ "./app/client/modules/pix2wav/pix2wav.module.js": +/*!******************************************************!*\ + !*** ./app/client/modules/pix2wav/pix2wav.module.js ***! + \******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var pix2wavModule = { + name: 'pix2wav', + displayName: 'Pix2Wav', + datatype: 'spectrogram' +}; + +exports.default = pix2wavModule; + +/***/ }), + +/***/ "./app/client/modules/pix2wav/pix2wav.reducer.js": +/*!*******************************************************!*\ + !*** ./app/client/modules/pix2wav/pix2wav.reducer.js ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/client/dataset/dataset.reducer.js"); + +var _dataset2 = _interopRequireDefault(_dataset); + +var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var pix2wavInitialState = { + loading: true, + progress: { i: 0, n: 0 }, + status: '', + error: null, + folder_id: 0, + data: null +}; + +var pix2wavReducer = function pix2wavReducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : pix2wavInitialState; + var action = arguments[1]; + + if (action.data && action.data.module === 'pix2wav') { + state = (0, _dataset2.default)(state, action); + } + + switch (action.type) { + case _types2.default.wav2pix.load: + return _extends({}, state, { + status: 'Loaded buffer' + }); + case _types2.default.wav2pix.progress: + return _extends({}, state, { + status: 'Rendering frame ' + action.count + }); + case _types2.default.wav2pix.finish: + return _extends({}, state, { + status: action.message || 'Render complete' + }); + case _types2.default.wav2pix.zip: + return _extends({}, state, { + status: 'Built zip file ' + _util2.default.hush_size(state.size)[1] + }); + case _types2.default.wav2pix.uploading: + return _extends({}, state, { + status: 'Uploading zip file' + }); + default: + return state; + } +}; + +exports.default = pix2wavReducer; + +/***/ }), + +/***/ "./app/client/modules/pix2wav/pix2wav.tasks.js": +/*!*****************************************************!*\ + !*** ./app/client/modules/pix2wav/pix2wav.tasks.js ***! + \*****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.live_task = undefined; + +var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); + +var _v2 = _interopRequireDefault(_v); + +var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); + +var _socket2 = _interopRequireDefault(_socket); + +var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var live_task = exports.live_task = function live_task(sequence, checkpoint) { + return function (dispatch) { + var task = { + module: 'pix2wav', + activity: 'live', + dataset: sequence, + checkpoint: checkpoint, + opt: { + poll_delay: 0.2 + } + }; + console.log(task); + console.log('add live task'); + return _actions2.default.queue.add_task(task); + }; +}; + +/***/ }), + +/***/ "./app/client/modules/pix2wav/views/pix2wav.live.js": +/*!**********************************************************!*\ + !*** ./app/client/modules/pix2wav/views/pix2wav.live.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _common = __webpack_require__(/*! ../../../common/ */ "./app/client/common/index.js"); + +var _player = __webpack_require__(/*! ../../../live/player */ "./app/client/live/player.js"); + +var playerActions = _interopRequireWildcard(_player); + +var _live = __webpack_require__(/*! ../../../live/live.actions */ "./app/client/live/live.actions.js"); + +var liveActions = _interopRequireWildcard(_live); + +var _queue = __webpack_require__(/*! ../../../queue/queue.actions */ "./app/client/queue/queue.actions.js"); + +var queueActions = _interopRequireWildcard(_queue); + +var _pix2wav = __webpack_require__(/*! ../pix2wav.tasks */ "./app/client/modules/pix2wav/pix2wav.tasks.js"); + +var pix2wavTasks = _interopRequireWildcard(_pix2wav); + +var _pix2wav2 = __webpack_require__(/*! ../pix2wav.actions */ "./app/client/modules/pix2wav/pix2wav.actions.js"); + +var pix2wavActions = _interopRequireWildcard(_pix2wav2); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Pix2WavLive = function (_Component) { + _inherits(Pix2WavLive, _Component); + + function Pix2WavLive(props) { + _classCallCheck(this, Pix2WavLive); + + var _this = _possibleConstructorReturn(this, (Pix2WavLive.__proto__ || Object.getPrototypeOf(Pix2WavLive)).call(this)); + + props.actions.pix2wav.load_directories(); + props.actions.live.get_params(); + _this.changeCheckpoint = _this.changeCheckpoint.bind(_this); + _this.changeEpoch = _this.changeEpoch.bind(_this); + _this.changeSequence = _this.changeSequence.bind(_this); + _this.seek = _this.seek.bind(_this); + _this.togglePlaying = _this.togglePlaying.bind(_this); + _this.toggleRecording = _this.toggleRecording.bind(_this); + return _this; + } + + _createClass(Pix2WavLive, [{ + key: 'componentWillUpdate', + value: function componentWillUpdate(nextProps) { + if (nextProps.opt.checkpoint_name && nextProps.opt.checkpoint_name !== this.props.opt.checkpoint_name) { + console.log('fetch checkpoint', nextProps.opt.checkpoint_name); + this.props.actions.live.list_epochs('pix2wav', nextProps.opt.checkpoint_name); + } + } + }, { + key: 'changeCheckpoint', + value: function changeCheckpoint(field, checkpoint_name) { + this.props.actions.live.load_epoch(checkpoint_name, 'latest'); + } + }, { + key: 'changeEpoch', + value: function changeEpoch(field, epoch_name) { + this.props.actions.live.load_epoch(this.props.opt.checkpoint_name, epoch_name); + } + }, { + key: 'changeSequence', + value: function changeSequence(field, sequence) { + console.log('got sequence', sequence); + this.props.actions.live.load_sequence(sequence); + } + }, { + key: 'seek', + value: function seek(percentage) { + var frame = Math.floor(percentage * (parseInt(this.props.frame.sequence_len) || 1) + 1); + this.props.actions.live.seek(frame); + } + }, { + key: 'start', + value: function start() { + // console.log(this.props) + console.log(this.props.pix2wav.data); + var sequence = this.props.pix2wav.data.sequences[0].name || ''; + var checkpoint = this.props.pix2wav.data.checkpoints[0].name || ''; + console.log('starting up!', sequence, checkpoint); + this.props.actions.tasks.live_task(sequence, checkpoint); + } + }, { + key: 'interrupt', + value: function interrupt() { + this.props.actions.queue.stop_task('gpu'); + } + }, { + key: 'exit', + value: function exit() { + this.props.actions.queue.stop_task('gpu', { sigkill: true }); + } + }, { + key: 'togglePlaying', + value: function togglePlaying() { + if (this.props.opt.processing) { + this.props.actions.live.pause(); + } else { + this.props.actions.live.play(); + } + } + }, { + key: 'toggleRecording', + value: function toggleRecording() { + if (this.props.opt.recording) { + (0, _player.stopRecording)(); + this.props.actions.live.pause(); + } else { + (0, _player.startRecording)(); + } + } + }, { + key: 'render', + value: function render() { + // console.log(this.props) + if (this.props.pix2wav.loading) { + return (0, _preact.h)(_common.Loading, null); + } + // console.log('sequence', this.props.opt) + return (0, _preact.h)( + 'div', + { className: 'app pix2wav centered' }, + (0, _preact.h)( + 'div', + { className: 'row' }, + (0, _preact.h)( + 'div', + { className: 'column' }, + (0, _preact.h)(_common.Player, { width: 256, height: 256 }) + ), + (0, _preact.h)( + 'div', + { className: 'params column audioParams' }, + (0, _preact.h)( + _common.Group, + { title: 'Audio playback' }, + (0, _preact.h)( + _common.Button, + { title: 'Start playback', + onClick: function onClick() { + return playerActions.startSynthesizing(); + } + }, + 'Start' + ), + (0, _preact.h)( + _common.Button, + { title: 'Stop playback', + onClick: function onClick() { + return playerActions.stopSynthesizing(); + } + }, + 'Stop' + ) + ) + ) + ), + (0, _preact.h)( + 'div', + { className: 'params row' }, + (0, _preact.h)( + 'div', + { className: 'column' }, + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Playback', + noToggle: true + }, + (0, _preact.h)(_common.Select, { + name: 'send_image', + title: 'view mode', + options: ['a', 'b', 'sequence', 'recursive'], + onChange: this.props.actions.live.set_param + }), + (0, _preact.h)(_common.Select, { + name: 'sequence_name', + title: 'sequence', + options: this.props.pix2wav.data.sequences, + onChange: this.changeSequence + }), + (0, _preact.h)(_common.Select, { + name: 'output_format', + title: 'format', + options: ['JPEG', 'PNG'] + }), + (0, _preact.h)(_common.Select, { + name: 'checkpoint_name', + title: 'checkpoint', + options: this.props.pix2wav.data.checkpoints, + onChange: this.changeCheckpoint + }), + (0, _preact.h)(_common.Select, { + name: 'epoch', + title: 'epoch', + options: this.props.epochs, + onChange: this.changeEpoch + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'position', + min: 0.0, max: 1.0, type: 'float', + value: (this.props.frame.sequence_i || 0) / (this.props.frame.sequence_len || 1), + onChange: this.seek + }), + this.renderRestartButton(), + (0, _preact.h)( + _common.Button, + { + title: this.props.opt.savingVideo ? 'Saving video...' : this.props.opt.recording ? 'Recording (' + timeInSeconds(this.props.opt.recordFrames) + ')' : 'Record video', + onClick: this.toggleRecording + }, + this.props.opt.savingVideo ? 'Saving' : this.props.opt.recording ? 'Recording' : 'Record' + ), + (0, _preact.h)( + _common.Button, + { + title: 'Save frame', + onClick: _player.saveFrame + }, + 'Save' + ), + (0, _preact.h)( + 'p', + { 'class': 'last_message' }, + this.props.last_message + ) + ) + ), + (0, _preact.h)( + 'div', + { className: 'column' }, + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Transition', + name: 'transition' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'transition_period', + min: 10, max: 5000, type: 'int' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'transition_min', + min: 0.001, max: 0.2, type: 'float' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'transition_max', + min: 0.1, max: 1.0, type: 'float' + }) + ), + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Recursion', + name: 'recursive' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'recursive_frac', + min: 0.0, max: 0.5, type: 'float' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'recurse_roll', + min: -64, max: 64, type: 'int' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'recurse_roll_axis', + min: 0, max: 1, type: 'int' + }) + ), + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Sequence', + name: 'sequence' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'sequence_frac', + min: 0.0, max: 1, type: 'float' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'process_frac', + min: 0, max: 1, type: 'float' + }) + ) + ), + (0, _preact.h)( + 'div', + { className: 'column' }, + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Clahe', + name: 'clahe' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'clip_limit', + min: 1.0, max: 4.0, type: 'float' + }) + ), + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Posterize', + name: 'posterize' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'spatial_window', + min: 2, max: 128, type: 'int' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'color_window', + min: 2, max: 128, type: 'int' + }) + ), + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Blur', + name: 'blur' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'blur_radius', + min: 3, max: 7, type: 'odd' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'blur_sigma', + min: 0, max: 2, type: 'float' + }) + ), + (0, _preact.h)( + _common.ParamGroup, + { + title: 'Canny Edge Detection', + name: 'canny' + }, + (0, _preact.h)(_common.Slider, { live: true, + name: 'canny_lo', + min: 10, max: 200, type: 'int' + }), + (0, _preact.h)(_common.Slider, { live: true, + name: 'canny_hi', + min: 10, max: 200, type: 'int' + }) + ) + ) + ) + ); + } + }, { + key: 'renderRestartButton', + value: function renderRestartButton() { + var _this2 = this; + + if (this.props.runner.gpu.status === 'IDLE') { + return (0, _preact.h)( + _common.Button, + { + title: 'GPU Idle', + onClick: function onClick() { + return _this2.start(); + } + }, + 'Start' + ); + } + if (this.props.runner.gpu.task.module !== 'pix2pix' && this.props.runner.gpu.task.module !== 'pix2wav') { + return (0, _preact.h)( + _common.Button, + { + title: 'GPU Busy', + onClick: function onClick() { + return _this2.interrupt(); + } + }, + 'Interrupt' + ); + } + if (!this.props.opt.processing) { + return (0, _preact.h)( + 'div', + null, + (0, _preact.h)( + _common.Button, + { + title: 'Not processing', + onClick: this.togglePlaying + }, + 'Restart' + ), + (0, _preact.h)( + _common.Button, + { + title: 'GPU Busy', + onClick: function onClick() { + return _this2.interrupt(); + } + }, + 'Interrupt' + ), + (0, _preact.h)( + _common.Button, + { + title: 'Last resort', + onClick: function onClick() { + return _this2.exit(); + } + }, + 'Exit' + ) + ); + } + return (0, _preact.h)( + 'div', + null, + (0, _preact.h)( + _common.Button, + { + title: 'Processing', + onClick: this.togglePlaying + }, + 'Pause' + ), + (0, _preact.h)( + _common.Button, + { + title: 'GPU Busy', + onClick: function onClick() { + return _this2.interrupt(); + } + }, + 'Interrupt' + ), + (0, _preact.h)( + _common.Button, + { + title: 'Last resort', + onClick: function onClick() { + return _this2.exit(); + } + }, + 'Exit' + ) + ); + } + }]); + + return Pix2WavLive; +}(_preact.Component); + +function timeInSeconds(n) { + return (n / 10).toFixed(1) + ' s.'; +} +var mapStateToProps = function mapStateToProps(state) { + return { + last_message: state.live.last_message, + opt: state.live.opt, + frame: state.live.frame, + checkpoints: state.live.checkpoints, + epochs: state.live.epochs, + sequences: state.live.sequences, + runner: state.system.runner, + pix2wav: state.module.pix2wav + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: { + live: (0, _redux.bindActionCreators)(liveActions, dispatch), + queue: (0, _redux.bindActionCreators)(queueActions, dispatch), + pix2wav: (0, _redux.bindActionCreators)(pix2wavActions, dispatch), + tasks: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch), s: s + } + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2WavLive); + +/***/ }), + +/***/ "./app/client/modules/pix2wav/views/pix2wav.new.js": +/*!*********************************************************!*\ + !*** ./app/client/modules/pix2wav/views/pix2wav.new.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = Pix2WavNew; + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _dataset = __webpack_require__(/*! ../../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); + +var _dataset2 = _interopRequireDefault(_dataset); + +var _pix2wav = __webpack_require__(/*! ../pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); + +var _pix2wav2 = _interopRequireDefault(_pix2wav); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function Pix2WavNew(_ref) { + var history = _ref.history; + + return (0, _preact.h)( + 'div', + { 'class': 'app pix2wav' }, + (0, _preact.h)(_dataset2.default, { module: _pix2wav2.default, history: history }) + ); +} + +/***/ }), + +/***/ "./app/client/modules/pix2wav/views/pix2wav.show.js": +/*!**********************************************************!*\ + !*** ./app/client/modules/pix2wav/views/pix2wav.show.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _pix2wav = __webpack_require__(/*! ../pix2wav.actions */ "./app/client/modules/pix2wav/pix2wav.actions.js"); + +var pix2wavActions = _interopRequireWildcard(_pix2wav); + +var _pix2wav2 = __webpack_require__(/*! ../pix2wav.tasks */ "./app/client/modules/pix2wav/pix2wav.tasks.js"); + +var pix2wavTasks = _interopRequireWildcard(_pix2wav2); + +var _loading = __webpack_require__(/*! ../../../common/loading.component */ "./app/client/common/loading.component.js"); + +var _loading2 = _interopRequireDefault(_loading); + +var _dataset = __webpack_require__(/*! ../../../dataset/dataset.form */ "./app/client/dataset/dataset.form.js"); + +var _dataset2 = _interopRequireDefault(_dataset); + +var _dataset3 = __webpack_require__(/*! ../../../dataset/dataset.new */ "./app/client/dataset/dataset.new.js"); + +var _dataset4 = _interopRequireDefault(_dataset3); + +var _upload = __webpack_require__(/*! ../../../dataset/upload.status */ "./app/client/dataset/upload.status.js"); + +var _upload2 = _interopRequireDefault(_upload); + +var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); + +var _spectrogram = __webpack_require__(/*! ./spectrogram.upload */ "./app/client/modules/pix2wav/views/spectrogram.upload.js"); + +var _spectrogram2 = _interopRequireDefault(_spectrogram); + +var _dataset5 = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); + +var _dataset6 = _interopRequireDefault(_dataset5); + +var _pix2wav3 = __webpack_require__(/*! ../pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); + +var _pix2wav4 = _interopRequireDefault(_pix2wav3); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var Pix2wavShow = function (_Component) { + _inherits(Pix2wavShow, _Component); + + function Pix2wavShow(props) { + _classCallCheck(this, Pix2wavShow); + + var _this = _possibleConstructorReturn(this, (Pix2wavShow.__proto__ || Object.getPrototypeOf(Pix2wavShow)).call(this, props)); + + _this.datasetActions = _this.datasetActions.bind(_this); + return _this; + } + + _createClass(Pix2wavShow, [{ + key: 'componentWillMount', + value: function componentWillMount() { + var id = this.props.match.params.id || localStorage.getItem('pix2wav.last_id'); + console.log('load dataset:', id); + var _props = this.props, + match = _props.match, + pix2wav = _props.pix2wav, + actions = _props.actions; + + if (id === 'new') return; + if (id) { + if (parseInt(id)) localStorage.setItem('pix2wav.last_id', id); + if (!pix2wav.folder || pix2wav.folder.id !== id) { + actions.load_directories(id); + } + } else { + this.props.history.push('/pix2wav/new/'); + } + } + }, { + key: 'render', + value: function render() { + var _props2 = this.props, + pix2wav = _props2.pix2wav, + match = _props2.match, + history = _props2.history; + + var _ref = pix2wav.data || {}, + folderLookup = _ref.folderLookup; + + var folder = (folderLookup || {})[pix2wav.folder_id] || {}; + + return (0, _preact.h)( + 'div', + { className: 'app pix2wav' }, + (0, _preact.h)( + 'div', + { 'class': 'heading' }, + (0, _preact.h)( + 'div', + { 'class': 'spaced' }, + (0, _preact.h)( + 'h1', + null, + folder ? folder.name : (0, _preact.h)(_loading2.default, null) + ), + (0, _preact.h)(_upload2.default, null) + ) + ), + (0, _preact.h)(_spectrogram2.default, { + loading: pix2wav.loading, + progress: pix2wav.progress, + id: pix2wav.folder_id, + module: _pix2wav4.default, + data: pix2wav.data, + folder: folder + }), + (0, _preact.h)(_dataset6.default, { + loading: pix2wav.loading, + progress: pix2wav.progress, + id: pix2wav.folder_id, + module: _pix2wav4.default, + data: pix2wav.data, + folder: folder, + history: history, + onPickFile: function onPickFile(file, e) { + e.preventDefault(); + e.stopPropagation(); + console.log('picked a file', file); + }, + datasetActions: this.datasetActions + }) + ); + } + }, { + key: 'datasetActions', + value: function datasetActions(dataset) { + var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var _props3 = this.props, + pix2wav = _props3.pix2wav, + remote = _props3.remote; + + var input = pix2wav.data.fileLookup[dataset.input[0]]; + if (!input) return null; + if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null; + return (0, _preact.h)( + 'div', + null, + (0, _preact.h)( + 'div', + { 'class': 'actions' }, + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, pix2wav.folder_id, 1); + } }, + 'train' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, pix2wav.folder_id, 2); + } }, + '2x' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, pix2wav.folder_id, 4); + } }, + '4x' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, pix2wav.folder_id, 6); + } }, + '6x' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, pix2wav.folder_id, 18); + } }, + '18x' + ) + ), + dataset.isBuilt ? (0, _preact.h)( + 'div', + { 'class': 'subtext' }, + 'fetched ', + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.clear_cache_task(dataset); + } }, + 'rm' + ) + ) : isFetching ? (0, _preact.h)( + 'div', + { 'class': 'subtext' }, + 'fetching' + ) : (0, _preact.h)( + 'div', + { 'class': 'subtext' }, + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.fetch_task(input.url, input.id, dataset.name); + } }, + 'fetch' + ) + ) + ); + } + }]); + + return Pix2wavShow; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return { + pix2wav: state.module.pix2wav + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: (0, _redux.bindActionCreators)(pix2wavActions, dispatch), + remote: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(Pix2wavShow); + +/***/ }), + +/***/ "./app/client/modules/pix2wav/views/spectrogram.upload.js": +/*!****************************************************************!*\ + !*** ./app/client/modules/pix2wav/views/spectrogram.upload.js ***! + \****************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); + +var _moment2 = _interopRequireDefault(_moment); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _pix2wav = __webpack_require__(/*! ../pix2wav.actions */ "./app/client/modules/pix2wav/pix2wav.actions.js"); + +var pix2wavActions = _interopRequireWildcard(_pix2wav); + +var _pix2wav2 = __webpack_require__(/*! ../pix2wav.tasks */ "./app/client/modules/pix2wav/pix2wav.tasks.js"); + +var pix2wavTasks = _interopRequireWildcard(_pix2wav2); + +var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); + +var _dataset = __webpack_require__(/*! ../../../dataset/dataset.actions */ "./app/client/dataset/dataset.actions.js"); + +var datasetActions = _interopRequireWildcard(_dataset); + +var _wav2pix = __webpack_require__(/*! ../../../audio/wav2pix */ "./app/client/audio/wav2pix.js"); + +var wav2pixActions = _interopRequireWildcard(_wav2pix); + +var _pix2wav3 = __webpack_require__(/*! ../../../audio/pix2wav */ "./app/client/audio/pix2wav.js"); + +var pix2wavPlayer = _interopRequireWildcard(_pix2wav3); + +var _pix2wav4 = __webpack_require__(/*! ../pix2wav.module */ "./app/client/modules/pix2wav/pix2wav.module.js"); + +var _pix2wav5 = _interopRequireDefault(_pix2wav4); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var date_stamp = function date_stamp() { + return (0, _moment2.default)().format("_YYYYMMDD_HHmm"); +}; + +var SpectrogramUpload = function (_Component) { + _inherits(SpectrogramUpload, _Component); + + function SpectrogramUpload(props) { + _classCallCheck(this, SpectrogramUpload); + + var _this = _possibleConstructorReturn(this, (SpectrogramUpload.__proto__ || Object.getPrototypeOf(SpectrogramUpload)).call(this, props)); + + _this.state = { + file: null, + pcm: null, + name: "", + datasetName: "", + frames: [], + frame_start: 0, + max: 1000, + preview_count: 8 * 4, + frame_step: wav2pixActions.FRAME_STEP + }; + var audioElement = document.createElement('audio'); + audioElement.addEventListener('loadedmetadata', function () { + var duration = audioElement.duration; + var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / _this.state.frame_step); + _this.setState({ + duration: duration, + max: Math.min(_this.state.max, total_frame_count, 1000) + }); + }); + _this.audioElement = audioElement; + return _this; + } + + _createClass(SpectrogramUpload, [{ + key: 'pickFile', + value: function pickFile(file) { + var _this2 = this; + + var name = file.name.split('.')[0].replace(/\s+/g, '_').replace(/-/g, '_').replace(/_+/g, '_'); + this.setState({ + file: file, + name: name + date_stamp(), + datasetName: name, + pcm: '' + }, function () { + _this2.rebuildFrames(); + }); + this.audioElement.src = URL.createObjectURL(file); + } + }, { + key: 'rebuildFrames', + value: function rebuildFrames() { + var _this3 = this; + + var _state = this.state, + file = _state.file, + pcm = _state.pcm, + frame_step = _state.frame_step, + frame_start = _state.frame_start, + preview_count = _state.preview_count; + + this.props.wav2pix.renderFrames(pcm || file, { frame_start: frame_start, frame_step: frame_step, max: preview_count }).then(function (data) { + console.log('got frames', data.frames.length); + _this3.setState(_extends({}, _this3.state, { + frames: data.frames, + pcm: data.pcm + })); + }); + } + }, { + key: 'buildZip', + value: function buildZip() { + var _this4 = this; + + var _state2 = this.state, + pcm = _state2.pcm, + file = _state2.file, + max = _state2.max, + frame_step = _state2.frame_step, + frame_start = _state2.frame_start; + + this.props.wav2pix.buildZip(this.state.name, pcm || file, { frame_start: frame_start, frame_step: frame_step, max: max }).then(function (_ref) { + var zip = _ref.zip, + filename = _ref.filename, + count = _ref.count; + + _this4.props.datasetActions.uploadFile(_this4.props.module, _this4.props.folder, zip, filename, { count: count, max: max, frame_step: frame_step, frame_size: wav2pixActions.FRAME_LENGTH / 44100 }); + }); + } + }, { + key: 'playFrame', + value: function playFrame(i) { + var _this5 = this; + + return function () { + var frame = _this5.state.frames[i]; + pix2wavPlayer.play(frame); + }; + } + }, { + key: 'render', + value: function render() { + var _this6 = this; + + // loading={pix2wav.loading} + // progress={pix2wav.progress} + // id={pix2wav.folder_id} + // module={pix2wavModule} + // data={pix2wav.data} + // folder={folder} + var _state3 = this.state, + file = _state3.file, + frames = _state3.frames, + preview_count = _state3.preview_count; + + var canvases = []; + for (var i = 0, _len = preview_count; i < _len; i++) { + canvases.push((0, _preact.h)('canvas', { key: i, onClick: this.playFrame(i) })); + } + return (0, _preact.h)( + 'div', + { className: 'row' }, + (0, _preact.h)( + 'div', + { className: 'col spectrogramBuilder' }, + (0, _preact.h)( + _common.Group, + { title: 'Spectrogram Builder' }, + (0, _preact.h)( + 'p', + null, + "Convert your sounds into spectrograms. ", + "Sound files can be WAV, MP3, AIFF, or FLAC. " + ), + (0, _preact.h)(_common.FileUpload, { + title: 'Choose a sound file', + accept: 'audio/*', + onUpload: function onUpload(file) { + return _this6.pickFile(file); + } + }), + file && this.renderMetadata(file) + ) + ), + (0, _preact.h)( + 'div', + { ref: function ref(c) { + _this6.canvases = c; + }, className: 'thumbs', id: 'pix2wav_canvases' }, + canvases + ) + ); + } + }, { + key: 'renderMetadata', + value: function renderMetadata(file) { + var _this7 = this; + + var _state4 = this.state, + duration = _state4.duration, + preview_count = _state4.preview_count; + + var size = _util2.default.hush_size(file.size); + var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / this.state.frame_step); + var frame_size = Math.round(wav2pixActions.FRAME_LENGTH / 44100 * 1000) + ' ms.'; + var frame_step = Math.round(this.state.frame_step / 44100 * 1000) + ' ms.'; + return (0, _preact.h)( + 'div', + { className: 'fileMetadata' }, + (0, _preact.h)( + _common.Group, + { title: 'Metadata' }, + (0, _preact.h)( + _common.Param, + { title: 'Name' }, + file.name + ), + (0, _preact.h)( + _common.Param, + { title: 'Type' }, + file.type + ), + (0, _preact.h)( + _common.Param, + { title: 'Size' }, + (0, _preact.h)( + 'span', + { className: size[0] }, + size[1] + ) + ), + (0, _preact.h)( + _common.Param, + { title: 'Date' }, + (0, _moment2.default)(file.lastModifiedDate).format("YYYY-MM-DD h:mm a") + ), + (0, _preact.h)( + _common.Param, + { title: 'Duration' }, + Math.floor(duration) + ' s.' + ), + (0, _preact.h)('br', null), + (0, _preact.h)( + _common.Param, + { title: 'Frames' }, + total_frame_count + ), + (0, _preact.h)( + _common.Param, + { title: 'Frame Size' }, + frame_size + ), + (0, _preact.h)( + _common.Param, + { title: 'Frame Step' }, + frame_step + ), + (0, _preact.h)( + _common.Param, + { title: 'FFT Size' }, + wav2pixActions.spectrum.fft_size + ), + (0, _preact.h)('br', null), + (0, _preact.h)( + _common.Param, + { title: 'Status' }, + this.props.pix2wav.status + ), + (0, _preact.h)('br', null) + ), + (0, _preact.h)( + _common.Group, + { title: 'Data settings' }, + (0, _preact.h)(_common.TextInput, { + title: 'Dataset name', + onChange: function onChange(e) { + return _this7.setState({ name: e.target.value }); + }, + value: this.state.name + }), + (0, _preact.h)(_common.Slider, { + name: 'Starting Frame', + min: 0, max: 1, type: 'float', + value: this.state.frame_start, + defaultValue: 0, + onChange: function onChange(frame_start) { + _this7.setState({ + frame_start: frame_start + }, function () { + _this7.rebuildFrames(); + }); + } + }), + (0, _preact.h)(_common.Slider, { + name: 'No. Frames', + min: 10, max: Math.min(total_frame_count, 1000), type: 'int', + value: this.state.max, + defaultValue: Math.min(total_frame_count, 300), + onChange: function onChange(max) { + return _this7.setState({ max: max }); + } + }), + (0, _preact.h)(_common.Slider, { + name: 'Frame step', + min: 10, max: 20000, type: 'int', + value: this.state.frame_step, + defaultValue: wav2pixActions.FRAME_STEP, + onChange: function onChange(frame_step) { + var total_frame_count = Math.floor((duration * 44100 - wav2pixActions.FRAME_LENGTH) / frame_step); + _this7.setState({ + name: _this7.state.datasetName + '_step_' + frame_step + date_stamp(), + frame_step: frame_step, + max: Math.min(_this7.state.max, total_frame_count) + }, function () { + _this7.rebuildFrames(); + }); + } + }), + (0, _preact.h)( + _common.Button, + { + onClick: function onClick() { + return _this7.buildZip(); + } + }, + 'Upload Frames' + ) + ), + (0, _preact.h)(_common.Progress, null) + ); + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate() { + var _this8 = this; + + (this.state.frames || []).map(function (frame, i) { + var canvas = _this8.canvases.children[i]; + var ctx = canvas.getContext('2d-lodpi'); + canvas.width = frame.canvas.width; + canvas.height = frame.canvas.height; + ctx.drawImage(frame.canvas, 0, 0); + }); + } + }]); + + return SpectrogramUpload; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return { + pix2wav: state.module.pix2wav, + upload: state.upload + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + datasetActions: (0, _redux.bindActionCreators)(datasetActions, dispatch), + actions: (0, _redux.bindActionCreators)(pix2wavActions, dispatch), + remote: (0, _redux.bindActionCreators)(pix2wavTasks, dispatch), + wav2pix: (0, _redux.bindActionCreators)(wav2pixActions, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SpectrogramUpload); + +/***/ }), + +/***/ "./app/client/modules/samplernn/index.js": +/*!***********************************************!*\ + !*** ./app/client/modules/samplernn/index.js ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); + +var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _samplernn = __webpack_require__(/*! ./views/samplernn.new */ "./app/client/modules/samplernn/views/samplernn.new.js"); + +var _samplernn2 = _interopRequireDefault(_samplernn); + +var _samplernn3 = __webpack_require__(/*! ./views/samplernn.show */ "./app/client/modules/samplernn/views/samplernn.show.js"); + +var _samplernn4 = _interopRequireDefault(_samplernn3); + +var _samplernn5 = __webpack_require__(/*! ./views/samplernn.import */ "./app/client/modules/samplernn/views/samplernn.import.js"); + +var _samplernn6 = _interopRequireDefault(_samplernn5); + +var _samplernn7 = __webpack_require__(/*! ./views/samplernn.results */ "./app/client/modules/samplernn/views/samplernn.results.js"); + +var _samplernn8 = _interopRequireDefault(_samplernn7); + +var _samplernn9 = __webpack_require__(/*! ./views/samplernn.graph */ "./app/client/modules/samplernn/views/samplernn.graph.js"); + +var _samplernn10 = _interopRequireDefault(_samplernn9); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var router = function () { + function router() { + _classCallCheck(this, router); + } + + _createClass(router, [{ + key: 'componentWillMount', + value: function componentWillMount() { + _actions2.default.system.changeTool('samplernn'); + document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #eef, #fef)'; + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps() { + _actions2.default.system.changeTool('samplernn'); + document.body.style.backgroundImage = 'linear-gradient(' + (_util2.default.randint(40) + 40) + 'deg, #eef, #fef)'; + } + }, { + key: 'render', + value: function render() { + return (0, _preact.h)( + 'section', + null, + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/new', component: _samplernn2.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/datasets', component: _samplernn4.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/datasets/:id', component: _samplernn4.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/import', component: _samplernn6.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/results', component: _samplernn8.default }), + (0, _preact.h)(_reactRouterDom.Route, { exact: true, path: '/samplernn/graph', component: _samplernn10.default }) + ); + } + }]); + + return router; +}(); + +function links() { + return [{ url: '/samplernn/new/', name: 'new' }, { url: '/samplernn/datasets/', name: 'datasets' }, { url: '/samplernn/graph/', name: 'graph' }, { url: '/samplernn/results/', name: 'results' }]; +} + +exports.default = { + name: 'samplernn', + router: router, links: links +}; + +/***/ }), + +/***/ "./app/client/modules/samplernn/samplernn.actions.js": +/*!***********************************************************!*\ + !*** ./app/client/modules/samplernn/samplernn.actions.js ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.import_files = exports.load_loss = exports.load_graph = exports.load_directories = undefined; + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); + +var _v2 = _interopRequireDefault(_v); + +var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); + +var _socket2 = _interopRequireDefault(_socket); + +var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _dataset = __webpack_require__(/*! ../../dataset/dataset.loader */ "./app/client/dataset/dataset.loader.js"); + +var datasetLoader = _interopRequireWildcard(_dataset); + +var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +var _util = __webpack_require__(/*! ../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _samplernn = __webpack_require__(/*! ./samplernn.module */ "./app/client/modules/samplernn/samplernn.module.js"); + +var _samplernn2 = _interopRequireDefault(_samplernn); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } + +var load_directories = exports.load_directories = function load_directories(id) { + return function (dispatch) { + var module = _samplernn2.default.name; + _util2.default.allProgress([datasetLoader.load(module), _actions2.default.socket.list_directory({ module: module, dir: 'datasets' }), _actions2.default.socket.list_directory({ module: module, dir: 'results' }), _actions2.default.socket.list_directory({ module: module, dir: 'output' }), _actions2.default.socket.disk_usage({ module: module, dir: 'datasets' }), load_loss()(dispatch)], function (percent, i, n) { + dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); + }).then(function (res) { + // console.log(res) + var _res = _slicedToArray(res, 6), + datasetApiReport = _res[0], + datasets = _res[1], + results = _res[2], + output = _res[3], + datasetUsage = _res[4], + lossReport = _res[5]; + + var folderLookup = datasetApiReport.folderLookup, + fileLookup = datasetApiReport.fileLookup, + datasetLookup = datasetApiReport.datasetLookup, + folders = datasetApiReport.folders, + files = datasetApiReport.files, + unsortedFolder = datasetApiReport.unsortedFolder; + + console.log(datasetUsage); + + // also show the various flat audio files we have, in the input area.. + var flatDatasets = datasets.filter(function (s) { + return s.name.match(/(wav|aiff?|flac|mp3)$/) && !s.dir; + }); + var builtDatasets = datasets.filter(function (s) { + return s.dir; + }); + builtDatasets.forEach(function (dir) { + var dataset = datasetLoader.getDataset(module, datasetLookup, dir.name, unsortedFolder, dir.date); + dataset.isBuilt = true; + }); + + flatDatasets.forEach(function (file) { + file.uuid = (0, _v2.default)(); + fileLookup[file.uuid] = file; + var name = file.name.split('.')[0]; + var dataset = datasetLoader.getDataset(module, datasetLookup, name, unsortedFolder, file.date); + file.persisted = false; + dataset.input.push(file.uuid); + }); + + // exp:coccokit_3-frame_sizes:8,2-n_rnn:2-dataset:coccokit_3 + var checkpoints = results.filter(function (s) { + return s.dir; + }).map(function (s) { + var checkpoint = s.name.split('-').map(function (s) { + return s.split(':'); + }).filter(function (b) { + return b.length && b[1]; + }).reduce(function (a, b) { + return (a[b[0]] = b[1]) && a; + }, {}); + checkpoint.name = checkpoint.name || checkpoint.dataset || checkpoint.exp; + checkpoint.date = s.date; + checkpoint.dir = s; + checkpoint.persisted = false; + var dataset = datasetLoader.getDataset(module, datasetLookup, checkpoint.name, unsortedFolder, checkpoint.date); + var loss = lossReport[checkpoint.name]; + if (loss) { + dataset.epoch = checkpoint.epoch = loss.length; + checkpoint.training_loss = loss; + } + dataset.checkpoints.push(checkpoint); + return checkpoint; + }); + + output.map(function (file) { + file.uuid = (0, _v2.default)(); + fileLookup[file.uuid] = file; + var pair = file.name.split('.')[0].split('-'); + var dataset = datasetLoader.getDataset(module, datasetLookup, pair[0], unsortedFolder, file.date); + file.persisted = false; + file.epoch = parseInt(file.epoch || pair[1].replace(/^\D+/, '')) || 0; + dataset.epoch = Math.max(file.epoch, dataset.epoch || 0); + // here check if the file exists in dataset, if so just check that it's persisted + var found = dataset.output.some(function (file_id) { + // if (f.name === + if (fileLookup[file_id].name === file.name) { + fileLookup[file_id].persisted = true; + return true; + } + return false; + }); + if (!found) { + dataset.output.push(file.uuid); + } + }); + + dispatch({ + type: _types2.default.dataset.load, + data: { + module: module, + folderLookup: folderLookup, + fileLookup: fileLookup, + datasetLookup: datasetLookup, + folders: folders, files: files, + checkpoints: checkpoints, + output: output + } + }); + }).catch(function (e) { + console.error(e); + }); + if (id) { + dispatch({ + type: _types2.default.dataset.set_folder, + data: { + folder_id: id, + module: module + } + }); + } + }; +}; + +var load_graph = exports.load_graph = function load_graph() { + return function (dispatch) { + var module = _samplernn2.default.name; + _util2.default.allProgress([load_loss()(dispatch), _actions2.default.socket.list_directory({ module: module, dir: 'results' })], function (percent, i, n) { + dispatch({ type: _types2.default.app.load_progress, progress: { i: i, n: n } }); + }).then(function (res) { + var _res2 = _slicedToArray(res, 2), + lossReport = _res2[0], + results = _res2[1]; + + dispatch({ + type: _types2.default.samplernn.load_graph, + lossReport: lossReport, + results: results + }); + }); + }; +}; + +var load_loss = exports.load_loss = function load_loss() { + return function (dispatch) { + return _actions2.default.socket.run_script({ module: 'samplernn', activity: 'report' }).then(function (report) { + var lossReport = {}; + report.stdout.split('\n\n').filter(function (a) { + return !!a; + }).forEach(function (data) { + var _data$split = data.split('\n'), + _data$split2 = _toArray(_data$split), + name = _data$split2[0], + lines = _data$split2.slice(1); + + lossReport[name] = lines.map(function (s) { + return s.split('\t').reduce(function (a, s) { + var b = s.split(': '); + a[b[0]] = b[1]; + return a; + }, {}); + }); + // console.log(data, name, lossReport[name]) + }); + dispatch({ + type: _types2.default.samplernn.load_loss, + lossReport: lossReport + }); + return lossReport; + }); + }; +}; + +var import_files = exports.import_files = function import_files(state, datasetLookup, fileLookup) { + return function (dispatch) { + var selected = state.selected, + folder_id = state.folder_id, + url_base = state.url_base, + import_action = state.import_action; + + var names = Object.keys(selected).filter(function (k) { + return selected[k]; + }); + var promises = void 0; + switch (import_action) { + case 'Hotlink': + // in this case, create a new file for each file we see. + promises = names.reduce(function (a, name) { + return datasetLookup[name].output.map(function (id) { + return fileLookup[id]; + }).map(function (file) { + var partz = file.name.split('.'); + var ext = partz.pop(); + return _actions2.default.file.create({ + folder_id: folder_id, + name: file.name, + url: url_base + file.name, + mime: 'audio/' + ext, + epoch: file.epoch, + size: file.size, + module: 'samplernn', + dataset: name, + activity: 'train', + datatype: 'audio', + generated: true, + created_at: new Date(file.date), + updated_at: new Date(file.date) + }); + }).concat(a); + }, []); + break; + case 'Upload': + promises = names.reduce(function (a, name) { + return datasetLookup[name].input.map(function (id) { + return fileLookup[id]; + }).map(function (file) { + if (file.persisted) return null; + var partz = file.name.split('.'); + var ext = partz.pop(); + if (ext === 'wav' || ext === 'flac') return; + console.log(file); + return _actions2.default.socket.upload_file({ + folder_id: folder_id, + module: 'samplernn', + activity: 'train', + path: 'datasets', + filename: file.name, + generated: false, + processed: false, + datatype: 'audio', + ttl: 60000 + }); + }).concat(a); + }, []).filter(function (a) { + return !!a; + }); + break; + default: + break; + } + console.log(promises); + return Promise.all(promises).then(function (data) { + console.log(data); + window.location.href = '/samplernn/datasets/' + folder_id + '/'; + }).catch(function (e) { + console.error(e); + }); + }; +}; + +/***/ }), + +/***/ "./app/client/modules/samplernn/samplernn.module.js": +/*!**********************************************************!*\ + !*** ./app/client/modules/samplernn/samplernn.module.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var samplernnModule = { + name: 'samplernn', + displayName: 'SampleRNN', + datatype: 'audio' +}; + +exports.default = samplernnModule; + +/***/ }), + +/***/ "./app/client/modules/samplernn/samplernn.reducer.js": +/*!***********************************************************!*\ + !*** ./app/client/modules/samplernn/samplernn.reducer.js ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _dataset = __webpack_require__(/*! ../../dataset/dataset.reducer */ "./app/client/dataset/dataset.reducer.js"); + +var _dataset2 = _interopRequireDefault(_dataset); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var samplernnInitialState = { + loading: true, + progress: { i: 0, n: 0 }, + error: null, + folders: [], + folder_id: 0, + data: null, + lossReport: null, + results: null +}; + +var samplernnReducer = function samplernnReducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : samplernnInitialState; + var action = arguments[1]; + + if (action.data && action.data.module === 'samplernn') { + return (0, _dataset2.default)(state, action); + } + + switch (action.type) { + case _types2.default.samplernn.load_loss: + return _extends({}, state, { + lossReport: action.lossReport + }); + case _types2.default.samplernn.load_graph: + return _extends({}, state, { + lossReport: action.lossReport, + results: action.results + }); + default: + return state; + } +}; + +exports.default = samplernnReducer; + +/***/ }), + +/***/ "./app/client/modules/samplernn/samplernn.tasks.js": +/*!*********************************************************!*\ + !*** ./app/client/modules/samplernn/samplernn.tasks.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.clear_cache_task = exports.log_task = exports.fetch_task = exports.train_task = undefined; + +var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); + +var _v2 = _interopRequireDefault(_v); + +var _socket = __webpack_require__(/*! ../../socket */ "./app/client/socket/index.js"); + +var _socket2 = _interopRequireDefault(_socket); + +var _types = __webpack_require__(/*! ../../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _actions = __webpack_require__(/*! ../../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var train_task = exports.train_task = function train_task(dataset, folder_id) { + var epochs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + return function (dispatch) { + var task = { + module: 'samplernn', + activity: 'train', + dataset: dataset.name, + epoch: dataset.checkpoints.length ? dataset.checkpoints[0].epoch || 0 : 0, + epochs: epochs, + folder_id: folder_id, + opt: { + sample_length: 44100 * 5, + n_samples: 6, + keep_old_checkpoints: false + } + }; + console.log(task); + return _actions2.default.queue.add_task(task); + }; +}; +var fetch_task = exports.fetch_task = function fetch_task(url, folder_id, file_id, dataset) { + return function (dispatch) { + if (!url) return console.log('input file inaccessible (no url)'); + var task = { + module: 'samplernn', + activity: 'fetch', + dataset: dataset, + folder_id: folder_id, + opt: { + url: url, + file_id: file_id, + dataset: dataset + } + }; + return _actions2.default.queue.add_task(task); + }; +}; +var log_task = exports.log_task = function log_task(dataset) { + return function (dispatch) { + var task = { + module: 'samplernn', + activity: 'log', + dataset: dataset.name + }; + return _actions2.default.queue.add_task(task); + }; +}; +var clear_cache_task = exports.clear_cache_task = function clear_cache_task(dataset) { + return function (dispatch) { + var task = { + module: 'samplernn', + activity: 'clear_cache', + dataset: dataset.name + }; + return _actions2.default.queue.add_task(task); + }; +}; + +/***/ }), + +/***/ "./app/client/modules/samplernn/views/samplernn.graph.js": +/*!***************************************************************!*\ + !*** ./app/client/modules/samplernn/views/samplernn.graph.js ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); + +var samplernnActions = _interopRequireWildcard(_samplernn); + +var _group = __webpack_require__(/*! ../../../common/group.component */ "./app/client/common/group.component.js"); + +var _group2 = _interopRequireDefault(_group); + +var _slider = __webpack_require__(/*! ../../../common/slider.component */ "./app/client/common/slider.component.js"); + +var _slider2 = _interopRequireDefault(_slider); + +var _select = __webpack_require__(/*! ../../../common/select.component */ "./app/client/common/select.component.js"); + +var _select2 = _interopRequireDefault(_select); + +var _button = __webpack_require__(/*! ../../../common/button.component */ "./app/client/common/button.component.js"); + +var _button2 = _interopRequireDefault(_button); + +var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); + +var _textInput = __webpack_require__(/*! ../../../common/textInput.component */ "./app/client/common/textInput.component.js"); + +var _textInput2 = _interopRequireDefault(_textInput); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var lerp = _util2.default.lerp, + norm = _util2.default.norm, + randint = _util2.default.randint, + randrange = _util2.default.randrange; + +var SampleRNNGraph = function (_Component) { + _inherits(SampleRNNGraph, _Component); + + function SampleRNNGraph(props) { + _classCallCheck(this, SampleRNNGraph); + + var _this = _possibleConstructorReturn(this, (SampleRNNGraph.__proto__ || Object.getPrototypeOf(SampleRNNGraph)).call(this)); + + props.actions.load_graph(); + return _this; + } + + _createClass(SampleRNNGraph, [{ + key: 'render', + value: function render() { + var _this2 = this; + + this.refs = {}; + return (0, _preact.h)( + 'div', + { className: 'app lossGraph' }, + (0, _preact.h)( + 'div', + { className: 'heading' }, + (0, _preact.h)( + 'h3', + null, + 'SampleRNN Loss Graph' + ), + (0, _preact.h)('canvas', { ref: function ref(_ref) { + return _this2.refs['canvas'] = _ref; + } }) + ) + ); + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate() { + var _props$samplernn = this.props.samplernn, + lossReport = _props$samplernn.lossReport, + results = _props$samplernn.results; + + if (!lossReport || !results) return; + var canvas = this.refs.canvas; + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + canvas.style.width = canvas.width + 'px'; + canvas.style.height = canvas.height + 'px'; + + var ctx = canvas.getContext('2d'); + var w = canvas.width; + var h = canvas.height; + ctx.clearRect(0, 0, w, h); + + var resultsByDate = results.map(function (file) { + if (!file.name.match(/^exp:/)) return null; + var dataset = file.name.split("-")[3].split(":")[1]; + return [+new Date(file.date), dataset]; + }).filter(function (a) { + return !!a; + }).sort(function (a, b) { + return a[0] - a[1]; + }); + + var keys = Object.keys(lossReport).filter(function (k) { + return !!lossReport[k].length; + }); + var scaleMax = 0; + var scaleMin = Infinity; + var epochsMax = 0; + keys.forEach(function (key) { + var loss = lossReport[key]; + epochsMax = Math.max(loss.length, epochsMax); + loss.forEach(function (a) { + var v = parseFloat(a.training_loss); + if (!v) return; + scaleMax = Math.max(v, scaleMax); + scaleMin = Math.min(v, scaleMin); + }); + }); + // scaleMax *= 10 + // console.log(scaleMax, scaleMin, epochsMax) + + scaleMax = 3; + scaleMin = 0; + var margin = 0; + var wmin = 0; + var wmax = w / 2; + var hmin = 0; + var hmax = h / 2; + var epochsScaleFactor = 1; // 3/2 + + ctx.save(); + var X = void 0, + Y = void 0; + for (var ii = 0; ii < epochsMax; ii++) { + X = lerp(ii / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax); + ctx.strokeStyle = 'rgba(0,0,0,0.3)'; + ctx.beginPath(0, 0); + ctx.moveTo(X, 0); + ctx.lineTo(X, h); + ctx.lineWidth = 0.5; + // ctx.stroke() + if ((ii + 1) % 6 === 0) { + ctx.lineWidth = 0.5; + ctx.stroke(); + var fontSize = 12; + ctx.font = 'italic ' + fontSize + 'px "Georgia"'; + ctx.fillStyle = 'rgba(0,12,28,0.6)'; + ctx.fillText(ii / 5 * 6, X + 8, h - (fontSize + 4)); + } + } + for (var ii = scaleMin; ii < scaleMax; ii += 1) { + Y = lerp(ii / scaleMax, hmin, hmax); + // ctx.strokeStyle = 'rgba(255,255,255,1.0)' + ctx.beginPath(0, 0); + ctx.moveTo(0, h - Y); + ctx.lineTo(w, h - Y); + ctx.lineWidth = 1; + // ctx.stroke() + // if ( (ii % 1) < 0.1) { + // ctx.strokeStyle = 'rgba(255,255,255,1.0)' + ctx.lineWidth = 2; + ctx.setLineDash([4, 4]); + ctx.stroke(); + ctx.stroke(); + ctx.stroke(); + ctx.setLineDash([1, 1]); + var _fontSize = 12; + ctx.font = 'italic ' + _fontSize + 'px "Georgia"'; + ctx.fillStyle = 'rgba(0,12,28,0.6)'; + ctx.fillText(ii.toFixed(1), w - 50, h - Y + _fontSize + 10); + // } + } + ctx.lineWidth = 1; + ctx.restore(); + + var min_date = resultsByDate[0][0]; + var max_date = resultsByDate[resultsByDate.length - 1][0]; + resultsByDate.forEach(function (pair) { + var date = pair[0]; + var key = pair[1]; + var loss = lossReport[key]; + if (!key || !loss || !loss.length) return; + var vf = parseFloat(loss[loss.length - 1].training_loss) || 0; + var vg = parseFloat(loss[0].training_loss) || 5; + // console.log(vf) + var vv = 1 - norm(vf, scaleMin, scaleMax / 2); + ctx.lineWidth = (1 - norm(vf, scaleMin, scaleMax)) * 4; + // ctx.lineWidth = norm(date, min_date, max_date) * 3 + // console.log(date, min_date, max_date) + ctx.strokeStyle = 'rgba(' + [randrange(30, 190), randrange(30, 150), randrange(60, 120)].join(',') + ',' + 0.8 + ')'; + var begun = false; + loss.forEach(function (a, i) { + var v = parseFloat(a.training_loss); + if (!v) return; + var x = lerp(i / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax); + var y = lerp(norm(v, scaleMin, scaleMax), hmax, hmin); + if (!begun) { + begun = true; + ctx.beginPath(0, 0); + ctx.moveTo(x, y); + } else { + ctx.lineTo(x, y); + // ctx.stroke() + } + }); + ctx.stroke(); + var i = loss.length - 1; + var v = parseFloat(loss[i].training_loss); + var x = lerp(i / (epochsMax / epochsScaleFactor) * epochsScaleFactor, wmin, wmax); + var y = lerp(norm(v, scaleMin, scaleMax), hmax, hmin); + var fontSize = 9; + ctx.font = 'italic ' + fontSize + 'px "Georgia"'; + ctx.fillStyle = 'rgba(0,12,28,0.6)'; + ctx.fillText(key, x + 4, y + fontSize / 2); + }); + } + }]); + + return SampleRNNGraph; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return { + samplernn: state.module.samplernn + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNGraph); + +/***/ }), + +/***/ "./app/client/modules/samplernn/views/samplernn.import.js": +/*!****************************************************************!*\ + !*** ./app/client/modules/samplernn/views/samplernn.import.js ***! + \****************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); + +var samplernnActions = _interopRequireWildcard(_samplernn); + +var _select = __webpack_require__(/*! ../../../common/select.component */ "./app/client/common/select.component.js"); + +var _select2 = _interopRequireDefault(_select); + +var _textInput = __webpack_require__(/*! ../../../common/textInput.component */ "./app/client/common/textInput.component.js"); + +var _textInput2 = _interopRequireDefault(_textInput); + +var _button = __webpack_require__(/*! ../../../common/button.component */ "./app/client/common/button.component.js"); + +var _button2 = _interopRequireDefault(_button); + +var _dataset = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); + +var _dataset2 = _interopRequireDefault(_dataset); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var samplernnModule = { + name: 'samplernn', + datatype: 'audio' +}; + +var SampleRNNImport = function (_Component) { + _inherits(SampleRNNImport, _Component); + + function SampleRNNImport() { + _classCallCheck(this, SampleRNNImport); + + var _this = _possibleConstructorReturn(this, (SampleRNNImport.__proto__ || Object.getPrototypeOf(SampleRNNImport)).call(this)); + + _this.state = { + folder_id: 1, + import_action: 'Hotlink', + url_base: 'https://s3.amazonaws.com/i.asdf.us/bucky/data/4279/', + selected: {} + }; + return _this; + } + + _createClass(SampleRNNImport, [{ + key: 'componentWillMount', + value: function componentWillMount() { + var id = this.props.match.params.id || localStorage.getItem('samplernn.last_id'); + console.log('load dataset:', id); + var _props = this.props, + match = _props.match, + samplernn = _props.samplernn, + samplernnActions = _props.samplernnActions; + + if (id === 'new') return; + if (id) { + if (parseInt(id)) localStorage.setItem('samplernn.last_id', id); + if (!samplernn.folder || samplernn.folder.id !== id) { + this.props.actions.load_directories(id); + } + } + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var samplernn = this.props.samplernn; + + var datasets = [], + folder = void 0; + if (this.props.samplernn.data) { + datasets = (this.props.samplernn.data.folders || []).map(function (folder) { + return [folder.name, folder.id]; + }); + folder = this.props.samplernn.data.folderLookup.unsorted; + } + return (0, _preact.h)( + 'div', + { className: 'app top' }, + (0, _preact.h)( + 'div', + { 'class': 'heading' }, + (0, _preact.h)( + 'h1', + null, + 'Import' + ) + ), + (0, _preact.h)( + 'div', + { 'class': 'params form row datasets' }, + (0, _preact.h)( + 'div', + { 'class': 'row dataset' }, + (0, _preact.h)('div', { 'class': 'col' }), + (0, _preact.h)('div', { 'class': 'col' }), + (0, _preact.h)('div', { 'class': 'col' }), + (0, _preact.h)( + 'div', + { 'class': 'col' }, + (0, _preact.h)( + 'h2', + null, + 'Import to dataset' + ), + (0, _preact.h)(_select2.default, { + title: 'Destination dataset', + options: datasets, + name: 'folder_id', + opt: this.state, + onChange: function onChange(name, value) { + return _this2.setState({ folder_id: value }); + } + }), + (0, _preact.h)(_select2.default, { + title: 'Import action', + options: ['Hotlink', 'Upload'], + name: 'import_action', + opt: this.state, + onChange: function onChange(name, value) { + return _this2.setState({ import_action: value }); + } + }), + (0, _preact.h)(_textInput2.default, { + title: 'Remote URL base', + value: this.state.url_base, + placeholder: 'http://', + onSave: function onSave(value) { + return _this2.setState({ url_base: value }); + } + }), + (0, _preact.h)( + _button2.default, + { + title: '', + onClick: function onClick() { + return _this2.doImport(); + } + }, + 'Import' + ) + ) + ) + ), + (0, _preact.h)(_dataset2.default, { + loading: samplernn.loading, + progress: samplernn.progress, + module: samplernnModule, + data: samplernn.data, + id: 'unsorted', + folder: folder, + history: this.props.history, + onPickDataset: function onPickDataset(dataset) { + return _this2.toggle(dataset.name, _this2.state.selected[name]); + }, + beforeRow: function beforeRow(dataset) { + return _this2.beforeRow(dataset); + }, + afterRow: function afterRow(dataset) { + return _this2.afterRow(dataset); + } + }) + ); + } + }, { + key: 'toggle', + value: function toggle(name) { + this.setState(_extends({}, this.state, { + selected: _extends({}, this.state.selected, _defineProperty({}, name, !this.state.selected[name])) + })); + } + }, { + key: 'beforeRow', + value: function beforeRow(dataset) { + // console.log(dataset) + } + }, { + key: 'afterRow', + value: function afterRow(dataset) { + var name = dataset.name; + return (0, _preact.h)( + 'div', + null, + (0, _preact.h)('input', { + type: 'checkbox', + value: name, + checked: !!this.state.selected[name] + }) + ); + } + }, { + key: 'doImport', + value: function doImport() { + var samplernn = this.props.samplernn; + + console.log(this.state); + this.props.actions.import_files(this.state, samplernn.data.datasetLookup, samplernn.data.fileLookup); + } + }]); + + return SampleRNNImport; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return { + samplernn: state.module.samplernn, + runner: state.system.runner, + task: state.task + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNImport); + +/***/ }), + +/***/ "./app/client/modules/samplernn/views/samplernn.new.js": +/*!*************************************************************!*\ + !*** ./app/client/modules/samplernn/views/samplernn.new.js ***! + \*************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); + +var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); + +var samplernnActions = _interopRequireWildcard(_samplernn); + +var _samplernn2 = __webpack_require__(/*! ../samplernn.module */ "./app/client/modules/samplernn/samplernn.module.js"); + +var _samplernn3 = _interopRequireDefault(_samplernn2); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function SampleRNNNew(props) { + return (0, _preact.h)(_common.Views.New, { + db: props.samplernn, + path: '/samplernn/datasets/', + actions: props.actions, + module: _samplernn3.default, + history: props.history + }); +} + +var mapStateToProps = function mapStateToProps(state) { + return { + samplernn: state.module.samplernn + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNNew); + +/***/ }), + +/***/ "./app/client/modules/samplernn/views/samplernn.results.js": +/*!*****************************************************************!*\ + !*** ./app/client/modules/samplernn/views/samplernn.results.js ***! + \*****************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRouterDom = __webpack_require__(/*! react-router-dom */ "./node_modules/react-router-dom/es/index.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); + +var samplernnActions = _interopRequireWildcard(_samplernn); + +var _audioPlayer = __webpack_require__(/*! ../../../common/audioPlayer/audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); + +var audioPlayerActions = _interopRequireWildcard(_audioPlayer); + +var _loading = __webpack_require__(/*! ../../../common/loading.component */ "./app/client/common/loading.component.js"); + +var _loading2 = _interopRequireDefault(_loading); + +var _fileList = __webpack_require__(/*! ../../../common/fileList.component */ "./app/client/common/fileList.component.js"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var SampleRNNResults = function (_Component) { + _inherits(SampleRNNResults, _Component); + + function SampleRNNResults(props) { + _classCallCheck(this, SampleRNNResults); + + var _this = _possibleConstructorReturn(this, (SampleRNNResults.__proto__ || Object.getPrototypeOf(SampleRNNResults)).call(this)); + + if (!props.samplernn.data) props.actions.load_directories(); + return _this; + } + + _createClass(SampleRNNResults, [{ + key: 'render', + value: function render() { + var _this2 = this; + + if (this.props.samplernn.loading) return (0, _preact.h)(_loading2.default, { progress: this.props.samplernn.progress }); + var _props$samplernn$data = this.props.samplernn.data, + folderLookup = _props$samplernn$data.folderLookup, + fileLookup = _props$samplernn$data.fileLookup, + datasetLookup = _props$samplernn$data.datasetLookup; + // const { folderLookup } = samplernn + + var renders = Object.keys(folderLookup).sort(_util2.default.sort.stringSort.asc).map(function (key) { + var folder = folderLookup[key]; + + var _util$sort$orderByFn = _util2.default.sort.orderByFn('epoch desc'), + mapFn = _util$sort$orderByFn.mapFn, + sortFn = _util$sort$orderByFn.sortFn; + + var datasetPairs = folder.datasets.map(function (name) { + return datasetLookup[name]; + }).map(mapFn).sort(sortFn); + var bestRenders = datasetPairs.map(function (pair) { + return pair[1]; + }).filter(function (dataset) { + return dataset.output.length; + }).map(function (dataset) { + var output = dataset.output; + + return output.map(function (id) { + return fileLookup[id]; + }).map(mapFn).sort(sortFn)[0][1]; + }); + // console.log(bestRenders.map(r => r.epoch)) + var path = folder.name === 'unsorted' ? "/samplernn/import/" : "/samplernn/datasets/" + folder.id + "/"; + return (0, _preact.h)( + 'div', + { className: 'col bestRenders' }, + (0, _preact.h)( + 'h3', + null, + (0, _preact.h)( + _reactRouterDom.Link, + { to: path }, + folder.name + ) + ), + (0, _preact.h)(_fileList.FileList, { + linkFiles: true, + files: bestRenders, + orderBy: 'date desc', + fields: 'name date epoch size', + onClick: function onClick(file, e) { + e.preventDefault(); + e.stopPropagation(); + console.log('picked a file', file); + _this2.handlePick(file); + } + }) + ); + }); + + return (0, _preact.h)( + 'div', + { className: 'app samplernn' }, + (0, _preact.h)( + 'div', + { className: 'heading row middle' }, + (0, _preact.h)( + 'h1', + null, + 'SampleRNN Results' + ) + ), + (0, _preact.h)( + 'div', + { 'class': 'rows params renders' }, + renders + ) + ); + } + }, { + key: 'handlePick', + value: function handlePick(file) { + this.props.audioPlayer.play(file); + } + }]); + + return SampleRNNResults; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return { + samplernn: state.module.samplernn + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch), + audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNResults); + +/***/ }), + +/***/ "./app/client/modules/samplernn/views/samplernn.show.js": +/*!**************************************************************!*\ + !*** ./app/client/modules/samplernn/views/samplernn.show.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _util = __webpack_require__(/*! ../../../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _samplernn = __webpack_require__(/*! ../samplernn.actions */ "./app/client/modules/samplernn/samplernn.actions.js"); + +var samplernnActions = _interopRequireWildcard(_samplernn); + +var _samplernn2 = __webpack_require__(/*! ../samplernn.tasks */ "./app/client/modules/samplernn/samplernn.tasks.js"); + +var samplernnTasks = _interopRequireWildcard(_samplernn2); + +var _audioPlayer = __webpack_require__(/*! ../../../common/audioPlayer/audioPlayer.actions */ "./app/client/common/audioPlayer/audioPlayer.actions.js"); + +var audioPlayerActions = _interopRequireWildcard(_audioPlayer); + +var _common = __webpack_require__(/*! ../../../common */ "./app/client/common/index.js"); + +var _dataset = __webpack_require__(/*! ../../../dataset/dataset.form */ "./app/client/dataset/dataset.form.js"); + +var _dataset2 = _interopRequireDefault(_dataset); + +var _upload = __webpack_require__(/*! ../../../dataset/upload.status */ "./app/client/dataset/upload.status.js"); + +var _upload2 = _interopRequireDefault(_upload); + +var _dataset3 = __webpack_require__(/*! ../../../dataset/dataset.component */ "./app/client/dataset/dataset.component.js"); + +var _dataset4 = _interopRequireDefault(_dataset3); + +var _samplernn3 = __webpack_require__(/*! ../samplernn.module */ "./app/client/modules/samplernn/samplernn.module.js"); + +var _samplernn4 = _interopRequireDefault(_samplernn3); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var SampleRNNShow = function (_Component) { + _inherits(SampleRNNShow, _Component); + + function SampleRNNShow(props) { + _classCallCheck(this, SampleRNNShow); + + var _this = _possibleConstructorReturn(this, (SampleRNNShow.__proto__ || Object.getPrototypeOf(SampleRNNShow)).call(this, props)); + + _this.datasetActions = _this.datasetActions.bind(_this); + return _this; + } + + _createClass(SampleRNNShow, [{ + key: 'componentWillMount', + value: function componentWillMount() { + var id = this.props.match.params.id || localStorage.getItem('samplernn.last_id'); + console.log('load dataset:', id); + var _props = this.props, + match = _props.match, + samplernn = _props.samplernn, + actions = _props.actions; + + if (id === 'new') return; + if (id) { + if (parseInt(id)) localStorage.setItem('samplernn.last_id', id); + if (!samplernn.folder || samplernn.folder.id !== id) { + // console.log('looooooooooad', id) + actions.load_directories(id); + } + } else { + this.props.history.push('/samplernn/new/'); + } + } + }, { + key: 'render', + value: function render() { + var _this2 = this; + + var _props2 = this.props, + samplernn = _props2.samplernn, + runner = _props2.runner, + match = _props2.match, + history = _props2.history; + + var _ref = samplernn.data || {}, + folderLookup = _ref.folderLookup; + // console.log(runner) + + + var folder = (folderLookup || {})[samplernn.folder_id] || {}; + return (0, _preact.h)( + 'div', + { className: 'app samplernn' }, + (0, _preact.h)( + 'div', + { className: 'heading' }, + (0, _preact.h)( + 'h1', + null, + folder ? folder.name : (0, _preact.h)(_common.Loading, null) + ) + ), + (0, _preact.h)( + 'div', + { className: 'row' }, + folder && folder.name && folder.name !== 'unsorted' && (0, _preact.h)(_dataset2.default, { + title: 'Add Files', + module: _samplernn4.default, + folder: folder, + canUpload: true, canAddURL: true + }), + (0, _preact.h)( + 'div', + null, + (0, _preact.h)(_upload2.default, null), + (0, _preact.h)(_common.CurrentTask, { processor: 'gpu' }) + ) + ), + (0, _preact.h)(_dataset4.default, { + loading: samplernn.loading, + progress: samplernn.progress, + id: samplernn.folder_id, + module: _samplernn4.default, + data: samplernn.data, + folder: folder, + history: history, + onPickFile: function onPickFile(file, e) { + e.preventDefault(); + e.stopPropagation(); + // console.log('picked a file', file) + _this2.handlePick(file); + }, + datasetActions: this.datasetActions + }) + ); + } + }, { + key: 'datasetActions', + value: function datasetActions(dataset) { + var isFetching = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var isProcessing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var _props3 = this.props, + samplernn = _props3.samplernn, + remote = _props3.remote; + + var input = samplernn.data.fileLookup[dataset.input[0]]; + if (!input) return null; + if (input.name && input.name.match(/(gif|jpe?g|png)$/i)) return null; + return (0, _preact.h)( + 'div', + null, + (0, _preact.h)( + 'div', + { 'class': 'actions' }, + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, samplernn.folder_id, 1); + } }, + 'train' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, samplernn.folder_id, 2); + } }, + '2x' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, samplernn.folder_id, 4); + } }, + '4x' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, samplernn.folder_id, 6); + } }, + '6x' + ), + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.train_task(dataset, samplernn.folder_id, 18); + } }, + '18x' + ) + ), + dataset.isBuilt ? (0, _preact.h)( + 'div', + { 'class': 'subtext' }, + 'fetched ', + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.clear_cache_task(dataset); + } }, + 'x' + ) + ) : isFetching ? (0, _preact.h)( + 'div', + { 'class': 'subtext' }, + 'fetching' + ) : (0, _preact.h)( + 'div', + { 'class': 'subtext' }, + (0, _preact.h)( + 'span', + { 'class': 'link', onClick: function onClick() { + return remote.fetch_task(input.url, samplernn.folder_id, input.id, dataset.name); + } }, + 'fetch' + ) + ) + ); + } + }, { + key: 'handlePick', + value: function handlePick(file) { + // console.log(file) + this.props.audioPlayer.play(file); + } + }]); + + return SampleRNNShow; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return { + samplernn: state.module.samplernn, + runner: state.system.runner + }; +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: (0, _redux.bindActionCreators)(samplernnActions, dispatch), + remote: (0, _redux.bindActionCreators)(samplernnTasks, dispatch), + audioPlayer: (0, _redux.bindActionCreators)(audioPlayerActions, dispatch) + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(SampleRNNShow); + +/***/ }), + +/***/ "./app/client/queue/queue.actions.js": +/*!*******************************************!*\ + !*** ./app/client/queue/queue.actions.js ***! + \*******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.stop_queue = exports.start_queue = exports.add_task = exports.stop_task = exports.start_task = undefined; + +var _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; }; + +var _socket = __webpack_require__(/*! ../socket */ "./app/client/socket/index.js"); + +var _socket2 = _interopRequireDefault(_socket); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _actions = __webpack_require__(/*! ../actions */ "./app/client/actions.js"); + +var _actions2 = _interopRequireDefault(_actions); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var start_task = exports.start_task = function start_task(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _socket2.default.task.start_task(task, opt); + return _extends({ type: _types2.default.task.starting_task, task: task }, opt); +}; + +var stop_task = exports.stop_task = function stop_task(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _socket2.default.task.stop_task(task, opt); + return _extends({ type: _types2.default.task.stopping_task, task: task }, opt); +}; + +var add_task = exports.add_task = function add_task(new_task) { + return function (dispatch) { + _actions2.default.task.create(new_task).then(function (task) { + _socket2.default.task.add_task(task); + }); + }; +}; + +var start_queue = exports.start_queue = function start_queue(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _socket2.default.task.start_queue(task, opt); + return _extends({ type: _types2.default.task.starting_queue, task: task }, opt); +}; + +var stop_queue = exports.stop_queue = function stop_queue(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _socket2.default.task.stop_queue(task, opt); + return _extends({ type: _types2.default.task.stopping_queue, task: task }, opt); +}; + +/***/ }), + +/***/ "./app/client/queue/queue.reducer.js": +/*!*******************************************!*\ + !*** ./app/client/queue/queue.reducer.js ***! + \*******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _util = __webpack_require__(/*! ../util */ "./app/client/util/index.js"); + +var _util2 = _interopRequireDefault(_util); + +var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); + +var _moment2 = _interopRequireDefault(_moment); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectWithoutProperties(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; } + +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; } + +var queueInitialState = { + loading: false, + error: null, + tasks: {}, + queue: [], + completed: [] +}; + +var dateSort = _util2.default.sort.orderByFn('updated_at desc'); +var prioritySort = _util2.default.sort.orderByFn('priority asc'); + +var queueReducer = function queueReducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : queueInitialState; + var action = arguments[1]; + + switch (action.type) { + case _types2.default.task.index: + return _extends({}, state, { + tasks: action.data.reduce(function (a, b) { + return a[b.id] = b, a; + }, {}), + queue: action.data.filter(function (a) { + return !a.completed; + }).map(dateSort.mapFn).sort(dateSort.sortFn).map(function (pair) { + return pair[1].id; + }), + completed: action.data.filter(function (a) { + return a.completed; + }).map(prioritySort.mapFn).sort(prioritySort.sortFn).map(function (pair) { + return pair[1].id; + }) + }); + case _types2.default.task.create: + console.log(action.data); + return _extends({}, state, { + tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data)), + queue: state.queue.concat([action.data.id]) + }); + case _types2.default.task.update: + return _extends({}, state, { + tasks: _extends({}, state.tasks, _defineProperty({}, action.data.id, action.data)) + }); + case _types2.default.task.destroy: + var _state$tasks = state.tasks, + deletedTask = _state$tasks[action.data.id], + taskLookup = _objectWithoutProperties(_state$tasks, [action.data.id]); + + return _extends({}, state, { + queue: state.queue.filter(function (id) { + return id !== deletedTask.id; + }), + completed: state.completed.filter(function (id) { + return id !== deletedTask.id; + }), + tasks: taskLookup + }); + case _types2.default.task.task_finish: + return _extends({}, state, { + queue: state.queue.filter(function (a) { + return a !== action.task.id; + }), + completed: [action.task.id].concat(state.completed) + }); + default: + return state; + } +}; + +exports.default = queueReducer; + +/***/ }), + +/***/ "./app/client/socket/index.js": +/*!************************************!*\ + !*** ./app/client/socket/index.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); + +var _socket2 = __webpack_require__(/*! ./socket.actions */ "./app/client/socket/socket.actions.js"); + +var actions = _interopRequireWildcard(_socket2); + +var _socket3 = __webpack_require__(/*! ./socket.system */ "./app/client/socket/socket.system.js"); + +var system = _interopRequireWildcard(_socket3); + +var _socket4 = __webpack_require__(/*! ./socket.live */ "./app/client/socket/socket.live.js"); + +var live = _interopRequireWildcard(_socket4); + +var _socket5 = __webpack_require__(/*! ./socket.task */ "./app/client/socket/socket.task.js"); + +var task = _interopRequireWildcard(_socket5); + +var _socket6 = __webpack_require__(/*! ./socket.api */ "./app/client/socket/socket.api.js"); + +var api = _interopRequireWildcard(_socket6); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = { + socket: _socket.socket, + actions: actions, + system: system, + live: live, + task: task, + api: api +}; + + +_socket.socket.on('status', function (data) { + console.log('got status', data.key, data.value); + _store.store.dispatch(_extends({ type: _types2.default.socket.status }, data)); + switch (data.key) { + case 'processing': + _store.store.dispatch(_extends({ + type: 'SET_PARAM' + }, data)); + break; + default: + break; + } +}); + +/***/ }), + +/***/ "./app/client/socket/socket.actions.js": +/*!*********************************************!*\ + !*** ./app/client/socket/socket.actions.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.syscall_async = exports.upload_file = exports.run_script = exports.list_sequences = exports.list_directory = exports.disk_usage = exports.run_system_command = undefined; + +var _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; }; + +var _v = __webpack_require__(/*! uuid/v1 */ "./node_modules/uuid/v1.js"); + +var _v2 = _interopRequireDefault(_v); + +var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var run_system_command = exports.run_system_command = function run_system_command(opt) { + return syscall_async('run_system_command', opt); +}; +var disk_usage = exports.disk_usage = function disk_usage(opt) { + return syscall_async('run_system_command', _extends({ cmd: 'du' }, opt)); +}; +var list_directory = exports.list_directory = function list_directory(opt) { + return syscall_async('list_directory', opt).then(function (res) { + return res.files; + }); +}; +var list_sequences = exports.list_sequences = function list_sequences(opt) { + return syscall_async('list_sequences', opt).then(function (res) { + return res.sequences; + }); +}; +var run_script = exports.run_script = function run_script(opt) { + return syscall_async('run_script', opt); +}; +var upload_file = exports.upload_file = function upload_file(opt) { + return syscall_async('upload_file', opt); +}; + +var syscall_async = exports.syscall_async = function syscall_async(tag, payload) { + var ttl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000; + + ttl = payload.ttl || ttl; + return new Promise(function (resolve, reject) { + var uuid = (0, _v2.default)(); + var timeout = setTimeout(function () { + _socket.socket.off('system_res', cb); + reject('timeout'); + }, ttl); + var cb = function cb(data) { + if (!data.uuid) return; + if (data.uuid === uuid) { + clearTimeout(timeout); + _socket.socket.off('system_res', cb); + resolve(data); + } + }; + _socket.socket.emit('system', { cmd: tag, payload: payload, uuid: uuid }); + _socket.socket.on('system_res', cb); + }); +}; + +/***/ }), + +/***/ "./app/client/socket/socket.api.js": +/*!*****************************************!*\ + !*** ./app/client/socket/socket.api.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +_socket.socket.on('api_res', function (data) { + // console.log('system response', data) + data = parse(data); + var type = _types2.default[data.datatype]; + console.log('api_res', data.type, data.datatype); + if (!type) return console.error('socket:api_res bad datatype', data.datatype); + switch (data.type) { + case 'create': + return (0, _store.dispatch)({ + type: type.create, + source: 'socket', + data: data.data + }); + case 'update': + return (0, _store.dispatch)({ + type: type.update, + source: 'socket', + data: data.data + }); + case 'destroy': + return (0, _store.dispatch)({ + type: type.destroy, + source: 'socket', + data: data.data + }); + default: + break; + } +}); + +function parse(s) { + if (typeof s === 'string') { + try { + var d = JSON.parse(s); + return d; + } catch (e) { + console.error('not valid json'); + return s; + } + } + return s; +} + +/***/ }), + +/***/ "./app/client/socket/socket.connection.js": +/*!************************************************!*\ + !*** ./app/client/socket/socket.connection.js ***! + \************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.socket = undefined; + +var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var socket = exports.socket = io.connect('/client'); + +// SOCKET ACTIONS + +socket.on('connect', function () { + return _store.store.dispatch({ type: _types2.default.socket.connect }); +}); +socket.on('connect_error', function (error) { + return _store.store.dispatch({ type: _types2.default.socket.connect_error, error: error }); +}); +socket.on('reconnect', function (attempt) { + return _store.store.dispatch({ type: _types2.default.socket.reconnect, attempt: attempt }); +}); +socket.on('reconnecting', function () { + return _store.store.dispatch({ type: _types2.default.socket.reconnecting }); +}); +socket.on('reconnect_error', function (error) { + return _store.store.dispatch({ type: _types2.default.socket.reconnect_error, error: error }); +}); +socket.on('reconnect_failed', function (error) { + return _store.store.dispatch({ type: _types2.default.socket.reconnect_failed, error: error }); +}); +socket.on('disconnect', function () { + return _store.store.dispatch({ type: _types2.default.socket.disconnect }); +}); +socket.on('error', function (error) { + return _store.store.dispatch({ type: _types2.default.socket.error, error: error }); +}); + +/***/ }), + +/***/ "./app/client/socket/socket.live.js": +/*!******************************************!*\ + !*** ./app/client/socket/socket.live.js ***! + \******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.list_checkpoints = list_checkpoints; +exports.list_all_checkpoints = list_all_checkpoints; +exports.list_epochs = list_epochs; +exports.list_sequences = list_sequences; +exports.load_epoch = load_epoch; +exports.load_sequence = load_sequence; +exports.seek = seek; +exports.pause = pause; +exports.play = play; +exports.get_params = get_params; +exports.set_param = set_param; + +var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _player = __webpack_require__(/*! ../live/player */ "./app/client/live/player.js"); + +var player = _interopRequireWildcard(_player); + +var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +_socket.socket.on('res', function (data) { + // console.log('socket:', data.cmd) + switch (data.cmd) { + case 'get_last_frame': + if (data.res !== 'working') { + _socket.socket.emit('cmd', { + cmd: 'get_last_frame' + }); + } + break; + case 'get_params': + data.res && (0, _store.dispatch)({ + type: _types2.default.socket.load_params, + opt: data.res + }); + data.res && player.toggleFPS(data.res.processing); + break; + case 'list_checkpoints': + (0, _store.dispatch)({ + type: _types2.default.socket.list_checkpoints, + checkpoints: data.res + }); + break; + case 'list_all_checkpoints': + (0, _store.dispatch)({ + type: _types2.default.socket.list_all_checkpoints, + checkpoints: data.res + }); + break; + case 'list_epochs': + (0, _store.dispatch)({ + type: _types2.default.socket.list_epochs, + epochs: data.res + }); + break; + case 'list_sequences': + (0, _store.dispatch)({ + type: _types2.default.socket.list_sequences, + sequences: data.res + }); + break; + default: + break; + } + // console.log(data) +}); + +_socket.socket.on('frame', player.onFrame); + +function list_checkpoints(module) { + _socket.socket.emit('cmd', { + cmd: 'list_checkpoints', + payload: module + }); +} +function list_all_checkpoints(module) { + _socket.socket.emit('cmd', { + cmd: 'list_all_checkpoints', + payload: module + }); +} +function list_epochs(module, checkpoint_name) { + _socket.socket.emit('cmd', { + cmd: 'list_epochs', + payload: module === 'pix2pix' || module === 'pix2wav' ? module + '/' + checkpoint_name : checkpoint_name + }); +} +function list_sequences(module) { + _socket.socket.emit('cmd', { + cmd: 'list_sequences', + payload: module + }); +} +function load_epoch(checkpoint_name, epoch) { + console.log(">> SWITCH CHECKPOINT", checkpoint_name, epoch); + _socket.socket.emit('cmd', { + cmd: 'load_epoch', + payload: checkpoint_name + ':' + epoch + }); +} +function load_sequence(sequence) { + _socket.socket.emit('cmd', { + cmd: 'load_sequence', + payload: sequence + }); +} +function seek(frame) { + _socket.socket.emit('cmd', { + cmd: 'seek', + payload: frame + }); +} +function pause(frame) { + _socket.socket.emit('cmd', { + cmd: 'pause' + }); +} +function play(frame) { + _socket.socket.emit('cmd', { + cmd: 'play' + }); +} +function get_params() { + _socket.socket.emit('cmd', { + cmd: 'get_params' + }); +} +function set_param(key, value) { + _socket.socket.emit('cmd', { + cmd: 'set_param', + payload: { + 'key': key, + 'value': value + } + }); +} + +/***/ }), + +/***/ "./app/client/socket/socket.system.js": +/*!********************************************!*\ + !*** ./app/client/socket/socket.system.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +_socket.socket.on('system_res', function (data) { + // console.log('system response', data) + switch (data.type) { + case 'relay_connected': + return (0, _store.dispatch)({ + type: _types2.default.system.relay_connected + }); + case 'relay_disconnected': + return (0, _store.dispatch)({ + type: _types2.default.system.relay_disconnected + }); + case 'rpc_connected': + return (0, _store.dispatch)({ + type: _types2.default.system.rpc_connected, + runner: data.runner + }); + case 'rpc_disconnected': + return (0, _store.dispatch)({ + type: _types2.default.system.rpc_disconnected + }); + case 'relay_status': + return (0, _store.dispatch)({ + type: data.rpc_connected ? _types2.default.system.rpc_connected : _types2.default.system.rpc_disconnected, + runner: data.runner + }); + case 'site': + return (0, _store.dispatch)({ + type: _types2.default.system.load_site, + site: data.site + }); + default: + break; + } +}); + +/***/ }), + +/***/ "./app/client/socket/socket.task.js": +/*!******************************************!*\ + !*** ./app/client/socket/socket.task.js ***! + \******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.stop_queue = exports.start_queue = exports.stop_task = exports.start_task = exports.remove_task = exports.add_task = undefined; + +var _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; }; + +exports.emit = emit; + +var _store = __webpack_require__(/*! ../store */ "./app/client/store.js"); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _socket = __webpack_require__(/*! ./socket.connection */ "./app/client/socket/socket.connection.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var finishTimeout = void 0; + +_socket.socket.on('task_res', function (raw_data) { + // does not like the nested task object for some reason.. + var data = void 0; + try { + if (typeof raw_data === 'string') { + data = JSON.parse(raw_data); + if (typeof data === 'string') { + data = JSON.parse(data); + } + } else { + data = raw_data; + } + } catch (e) { + console.warn('problem with json', e); + return; + } + if (data.task) { + (0, _store.dispatch)({ type: _types2.default.task.update, data: data.task }); + } + // console.log('task', data.type) + switch (data.type) { + case 'start': + // return dispatch({ type: types.system.rpc_connected, runner: data.runner }) + break; + case 'stop': + break; + // begin and finish calls often arrive out of order, if the old task was preempted + case 'task_begin': + (0, _store.dispatch)({ type: _types2.default.task.task_begin, task: data.task }); + break; + case 'task_finish': + (0, _store.dispatch)({ type: _types2.default.task.task_finish, task: data.task }); + break; + case 'kill': + break; + case 'stdout': + return (0, _store.dispatch)({ type: _types2.default.system.stdout, data: data }); + break; + case 'stderr': + return (0, _store.dispatch)({ type: _types2.default.system.stderr, data: data }); + break; + case 'add': + break; + case 'remove': + break; + case 'start_queue': + break; + case 'stop_queue': + break; + case 'list': + break; + case 'set_priority': + break; + case 'progress': + (0, _store.dispatch)({ type: _types2.default.task.progress, task: data.task }); + break; + case 'epoch': + (0, _store.dispatch)({ type: _types2.default.task.epoch, task: data.task }); + break; + case 'task_error': + return console.log('task error', data); + default: + console.log(data); + return console.log('no such task command', data.type); + } +}); + +function emit(type) { + var task = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + _socket.socket.emit('task', _extends({ type: type, task: task }, opt)); +} + +var add_task = exports.add_task = function add_task(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return emit('add', task, opt); +}; +var remove_task = exports.remove_task = function remove_task(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return emit('remove', task, opt); +}; +var start_task = exports.start_task = function start_task(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return emit('start', task, opt); +}; +var stop_task = exports.stop_task = function stop_task(task) { + var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return emit('stop', task, opt); +}; +var start_queue = exports.start_queue = function start_queue() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return emit('start_queue', {}, opt); +}; +var stop_queue = exports.stop_queue = function stop_queue() { + var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return emit('stop_queue', {}, opt); +}; + +/***/ }), + +/***/ "./app/client/store.js": +/*!*****************************!*\ + !*** ./app/client/store.js ***! + \*****************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.dispatch = exports.store = exports.history = undefined; + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRouterRedux = __webpack_require__(/*! react-router-redux */ "./node_modules/react-router-redux/lib/index.js"); + +var _reduxThunk = __webpack_require__(/*! redux-thunk */ "./node_modules/redux-thunk/lib/index.js"); + +var _reduxThunk2 = _interopRequireDefault(_reduxThunk); + +var _createBrowserHistory = __webpack_require__(/*! history/createBrowserHistory */ "./node_modules/history/createBrowserHistory.js"); + +var _createBrowserHistory2 = _interopRequireDefault(_createBrowserHistory); + +var _system = __webpack_require__(/*! ./system/system.reducer */ "./app/client/system/system.reducer.js"); + +var _system2 = _interopRequireDefault(_system); + +var _dashboard = __webpack_require__(/*! ./dashboard/dashboard.reducer */ "./app/client/dashboard/dashboard.reducer.js"); + +var _dashboard2 = _interopRequireDefault(_dashboard); + +var _live = __webpack_require__(/*! ./live/live.reducer */ "./app/client/live/live.reducer.js"); + +var _live2 = _interopRequireDefault(_live); + +var _upload = __webpack_require__(/*! ./dataset/upload.reducer */ "./app/client/dataset/upload.reducer.js"); + +var _upload2 = _interopRequireDefault(_upload); + +var _queue = __webpack_require__(/*! ./queue/queue.reducer */ "./app/client/queue/queue.reducer.js"); + +var _queue2 = _interopRequireDefault(_queue); + +var _audioPlayer = __webpack_require__(/*! ./common/audioPlayer/audioPlayer.reducer */ "./app/client/common/audioPlayer/audioPlayer.reducer.js"); + +var _audioPlayer2 = _interopRequireDefault(_audioPlayer); + +var _module = __webpack_require__(/*! ./modules/module.reducer */ "./app/client/modules/module.reducer.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var appReducer = (0, _redux.combineReducers)({ + system: _system2.default, + dashboard: _dashboard2.default, + live: _live2.default, + upload: _upload2.default, + queue: _queue2.default, + router: _reactRouterRedux.routerReducer, + module: _module.moduleReducer, + audioPlayer: _audioPlayer2.default +}); + +// import navReducer from './nav.reducer' +var history = exports.history = (0, _createBrowserHistory2.default)(); +var store = exports.store = (0, _redux.createStore)(appReducer, (0, _redux.compose)((0, _redux.applyMiddleware)( +// createLogger(), +_reduxThunk2.default, (0, _reactRouterRedux.routerMiddleware)(history)))); + +var dispatch = exports.dispatch = store.dispatch; + +/***/ }), + +/***/ "./app/client/system/system.actions.js": +/*!*********************************************!*\ + !*** ./app/client/system/system.actions.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.enqueue_test_task = exports.changeTool = exports.listDirectory = exports.run = undefined; + +var _socket = __webpack_require__(/*! ../socket */ "./app/client/socket/index.js"); + +var _socket2 = _interopRequireDefault(_socket); + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// import actions from '../actions' + +var run = exports.run = function run(cmd) { + return function (dispatch) { + dispatch({ type: _types2.default.system.running_command, cmd: cmd }); + _socket2.default.actions.run_system_command({ cmd: cmd }).then(function (data) { + dispatch({ + type: _types2.default.system.command_output, + data: data + }); + }); + }; +}; + +var listDirectory = exports.listDirectory = function listDirectory(opt) { + return function (dispatch) { + dispatch({ type: _types2.default.system.listing_directory, opt: opt }); + _socket2.default.actions.list_directory(opt).then(function (data) { + dispatch({ + type: _types2.default.system.list_directory, + data: data + }); + }); + }; +}; + +var changeTool = exports.changeTool = function changeTool(tool) { + localStorage.setItem('system.last_tool', tool); + return { type: _types2.default.app.change_tool, tool: tool }; +}; + +var enqueue_test_task = exports.enqueue_test_task = function enqueue_test_task(dataset) { + return function (dispatch) { + var task = { + module: 'test', + activity: 'cpu', + dataset: dataset + // return actions.queue.add_task(task) + }; + }; +}; + +window.addEventListener('keyDown', function (e) { + if (e.altKey) { + switch (e.keyCode) { + case 192: + // tilde - switch tool + break; + case 49: + // 1 + break; + case 50: + // 2 + break; + case 51: + // 3 + break; + case 52: + // 4 + break; + case 53: + // 5 + break; + case 54: + // 6 + break; + case 55: + // 7 + break; + case 56: + // 8 + break; + case 57: + // 9 + break; + case 48: + // 0 + break; + } + } +}); + +/***/ }), + +/***/ "./app/client/system/system.component.js": +/*!***********************************************!*\ + !*** ./app/client/system/system.component.js ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _preact = __webpack_require__(/*! preact */ "./node_modules/preact/dist/preact.esm.js"); + +var _redux = __webpack_require__(/*! redux */ "./node_modules/redux/es/redux.js"); + +var _reactRedux = __webpack_require__(/*! react-redux */ "./node_modules/react-redux/es/index.js"); + +var _group = __webpack_require__(/*! ../common/group.component */ "./app/client/common/group.component.js"); + +var _group2 = _interopRequireDefault(_group); + +var _param = __webpack_require__(/*! ../common/param.component */ "./app/client/common/param.component.js"); + +var _param2 = _interopRequireDefault(_param); + +var _system = __webpack_require__(/*! ./system.actions */ "./app/client/system/system.actions.js"); + +var systemActions = _interopRequireWildcard(_system); + +var _live = __webpack_require__(/*! ../live/live.actions */ "./app/client/live/live.actions.js"); + +var liveActions = _interopRequireWildcard(_live); + +var _queue = __webpack_require__(/*! ../queue/queue.actions */ "./app/client/queue/queue.actions.js"); + +var queueActions = _interopRequireWildcard(_queue); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +var cpu_test_task = { + activity: 'cpu', + module: 'test', + dataset: 'test', + epochs: 1, + opt: {} +}; +var gpu_test_task = { + activity: 'gpu', + module: 'test', + dataset: 'test', + epochs: 1, + opt: {} +}; +var live_test_task = { + activity: 'live', + module: 'test', + dataset: 'test', + epochs: 1, + opt: {} +}; +var wait_test_task = { + activity: 'wait', + module: 'test', + dataset: 'test', + epochs: 1, + opt: {} +}; +var fruits = ["apple", "pear", "orange", "strawberry"]; +function choice(a) { + return a[Math.floor(Math.random() * a.length)]; +} + +var System = function (_Component) { + _inherits(System, _Component); + + function System(props) { + _classCallCheck(this, System); + + return _possibleConstructorReturn(this, (System.__proto__ || Object.getPrototypeOf(System)).call(this)); + } + + _createClass(System, [{ + key: 'componentDidUpdate', + value: function componentDidUpdate() { + if (this._screen.scrollHeight > this._screen.scrollTop - this._screen.offsetHeight + 100) { + this._screen.scrollTop = this._screen.scrollHeight; + } + } + }, { + key: 'render', + value: function render() { + var _props = this.props, + site = _props.site, + server = _props.server, + relay = _props.relay, + runner = _props.runner, + rpc = _props.rpc, + actions = _props.actions; + + return (0, _preact.h)( + 'div', + { className: 'app system' }, + (0, _preact.h)( + 'div', + { className: 'heading' }, + (0, _preact.h)( + 'h1', + null, + site.name, + ' system' + ) + ), + (0, _preact.h)( + 'div', + { className: 'row params' }, + (0, _preact.h)( + 'div', + { className: 'column' }, + (0, _preact.h)( + _group2.default, + { title: 'Status' }, + (0, _preact.h)( + _param2.default, + { title: 'Server' }, + server.status + ), + server.error && (0, _preact.h)( + _param2.default, + { title: 'Server error' }, + server.error.message + ), + (0, _preact.h)( + _param2.default, + { title: 'Relay' }, + relay.status + ), + (0, _preact.h)( + _param2.default, + { title: 'RPC' }, + rpc.status + ), + (0, _preact.h)( + _param2.default, + { title: 'CPU' }, + this.renderStatus(runner.cpu) + ), + (0, _preact.h)( + _param2.default, + { title: 'GPU' }, + this.renderStatus(runner.gpu) + ) + ), + (0, _preact.h)( + _group2.default, + { title: 'Diagnostics' }, + (0, _preact.h)( + _param2.default, + { title: 'Check GPU' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.system.run('nvidia-smi'); + } }, + 'nvidia-smi' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'List processes' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.system.run('ps'); + } }, + 'ps' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'List users' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.system.run('w'); + } }, + 'w' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'Disk free space' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.system.run('df'); + } }, + 'df' + ) + ) + ), + (0, _preact.h)( + _group2.default, + { title: 'Tasks' }, + (0, _preact.h)( + _param2.default, + { title: 'Kill task' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.stop_task('cpu'); + } }, + 'CPU' + ), + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.stop_task('gpu'); + } }, + 'GPU' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'Queue' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.start_queue(); + } }, + 'Start' + ), + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.stop_queue(); + } }, + 'Stop' + ) + ) + ), + (0, _preact.h)( + _group2.default, + { title: 'Test' }, + (0, _preact.h)( + _param2.default, + { title: 'CPU Test Task' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.start_task(cpu_test_task, { preempt: true, watch: true }); + } }, + 'Start' + ), + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.stop_task(runner.cpu.task); + } }, + 'Stop' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'GPU Test Task' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.start_task(gpu_test_task, { preempt: true, watch: true }); + } }, + 'Start' + ), + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.stop_task(runner.gpu.task); + } }, + 'Stop' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'Live Test Task' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.start_task(live_test_task, { preempt: true, watch: true }); + } }, + 'Start' + ), + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.stop_task(runner.cpu.task); + } }, + 'Stop' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'Test Live RPC' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.live.get_params(); + } }, + 'Get' + ), + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.live.set_param('fruit', choice(fruits)); + } }, + 'Set' + ) + ), + (0, _preact.h)( + _param2.default, + { title: 'Queue Tests' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.system.enqueue_test_task(choice(fruits)); + } }, + '+Add test task' + ) + ), + (0, _preact.h)( + _param2.default, + { title: '' }, + (0, _preact.h)( + 'button', + { onClick: function onClick() { + return actions.queue.start_task(wait_test_task, { preempt: true, watch: true }); + } }, + 'Wait and Buzz' + ) + ) + ) + ), + this.renderCommandOutput() + ) + ); + } + }, { + key: 'renderStatus', + value: function renderStatus(processor) { + if (!processor) { + return 'unknown'; + } + if (processor.status === 'IDLE') { + return 'idle'; + } + var task = processor.task; + return task.activity + ' ' + task.module; + } + }, { + key: 'renderCommandOutput', + value: function renderCommandOutput() { + var _this2 = this; + + var _props2 = this.props, + cmd = _props2.cmd, + stdout = _props2.stdout, + stderr = _props2.stderr; + + var output = void 0; + if (cmd.loading) { + output = 'Loading: ' + cmd.name; + } else if (cmd.loaded) { + if (cmd.error) { + output = 'Error: ' + cmd.name + '\n\n' + JSON.stringify(cmd.error, null, 2); + } else { + output = cmd.stdout; + if (cmd.stderr) { + output += '\n\n_________________________________\n\n'; + output += cmd.stderr; + } + } + } else { + output = stdout; + if (stderr.length) { + output += '\n\n_________________________________\n\n'; + output += stderr; + } + } + return (0, _preact.h)( + 'div', + null, + (0, _preact.h)( + 'div', + { ref: function ref(_ref) { + return _this2._screen = _ref; + }, className: 'screen' }, + output + ) + ); + } + }]); + + return System; +}(_preact.Component); + +var mapStateToProps = function mapStateToProps(state) { + return _extends({}, state.system, state.live); +}; + +var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) { + return { + actions: { + system: (0, _redux.bindActionCreators)(systemActions, dispatch), + queue: (0, _redux.bindActionCreators)(queueActions, dispatch), + live: (0, _redux.bindActionCreators)(liveActions, dispatch) + } + }; +}; + +exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(System); + +/***/ }), + +/***/ "./app/client/system/system.reducer.js": +/*!*********************************************!*\ + !*** ./app/client/system/system.reducer.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _types = __webpack_require__(/*! ../types */ "./app/client/types.js"); + +var _types2 = _interopRequireDefault(_types); + +var _moment = __webpack_require__(/*! moment/min/moment.min */ "./node_modules/moment/min/moment.min.js"); + +var _moment2 = _interopRequireDefault(_moment); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +var FileSaver = __webpack_require__(/*! file-saver */ "./node_modules/file-saver/FileSaver.js"); + +var systemInitialState = { + loading: false, + error: null, + + site: { + name: 'loading' + }, + app: { + tool: localStorage.getItem('system.last_tool') || 'pix2pix' + }, + server: { + connected: false, + status: "disconnected", + error: null + }, + relay: { + connected: false, + status: "unknown", + error: null + }, + rpc: { + connected: false, + status: "disconnected", + error: null + }, + cmd: { + loading: false, + loaded: false, + name: null, + error: null, + stdout: "", + stderr: "" + }, + runner: { + cpu: { status: 'IDLE', task: {} }, + gpu: { status: 'IDLE', task: {} } + }, + stdout: "", + stderr: "" +}; + +var modules = ['pix2pix', 'samplernn', 'pix2wav'].reduce(function (a, b) { + return a[b] = b, a; +}, {}); + +var systemReducer = function systemReducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : systemInitialState; + var action = arguments[1]; + + // console.log(action.type) + var processor = null; + switch (action.type) { + case _types2.default.socket.connect: + case _types2.default.socket.reconnecting: + return _extends({}, state, { + server: { + status: 'connected', + connected: true, + error: null + } + }); + case _types2.default.socket.reconnect: + return _extends({}, state, { + server: { + status: 'reconnecting (attempt ' + action.attempt + ')', + connected: false, + error: null + } + }); + case _types2.default.socket.connect_error: + case _types2.default.socket.reconnect_error: + case _types2.default.socket.disconnect: + case _types2.default.socket.reconnect_failed: + return _extends({}, state, { + server: { + status: 'disconnected', + connected: false, + error: action.error || null + } + }); + case _types2.default.socket.error: + return _extends({}, state, { + server: _extends({}, state.socket, { + error: action.error + }) + }); + case _types2.default.system.relay_connected: + return _extends({}, state, { + relay: { + status: 'connected', + connected: true, + error: null + } + }); + case _types2.default.system.relay_disconnected: + return _extends({}, state, { + relay: { + status: 'disconnected', + connected: false, + error: null + }, + rpc: { + status: 'disconnected', + connected: false, + error: null + } + }); + case _types2.default.system.rpc_connected: + return _extends({}, state, { + rpc: { + status: 'connected', + connected: true, + error: null + }, + runner: action.runner + }); + case _types2.default.system.rpc_disconnected: + return _extends({}, state, { + rpc: { + status: 'disconnected', + connected: false, + error: null + }, + runner: action.runner || state.runner + }); + case _types2.default.system.load_site: + document.querySelector('title').innerHTML = action.site.name + '.cortex'; + var tool = state.app.tool; + var path = window.location.pathname.split('/')[1]; + if (path in modules) { + tool = path; + } + return _extends({}, state, { + site: action.site, + app: _extends({}, state.app, { + tool: tool + }) + }); + case _types2.default.system.running_command: + return _extends({}, state, { + cmd: { + loading: true, + loaded: false, + name: action.cmd, + error: null, + stdout: null, + stderr: null + } + }); + case _types2.default.system.command_output: + return _extends({}, state, { + cmd: { + loading: false, + loaded: true, + name: action.data.cmd, + error: action.data.error, + stdout: action.data.stdout, + stderr: action.data.stderr + } + }); + case _types2.default.task.task_begin: + console.log('task begin', action.task, action.task.processor); + return _extends({}, state, { + runner: _extends({}, state.runner, _defineProperty({}, action.task.processor, { status: 'RUNNING', task: action.task })), + cmd: _extends({}, state.cmd, { + loaded: false, + stdout: "", + stderr: "" + }), + stdout: "", + stderr: "" + }); + case _types2.default.task.task_finish: + if (action.task.processor === 'cpu' || state.runner.cpu.task && state.runner.cpu.task.uuid === action.task.uuid) { + processor = 'cpu'; + } else if (action.task.processor === 'gpu' || state.runner.gpu.task && state.runner.gpu.task.uuid === action.task.uuid) { + processor = 'gpu'; + } else { + processor = null; + } + console.log('task finish', action); + return _extends({}, state, { + rpc: { + connected: false, + status: "disconnected", + error: null + }, + runner: processor ? _extends({}, state.runner, _defineProperty({}, processor, { status: 'IDLE', task: {} })) : state.runner + }); + case _types2.default.app.change_tool: + return _extends({}, state, { + app: _extends({}, state.app, { + tool: action.tool + }) + }); + case _types2.default.system.stdout: + if (action.data.processor && state.runner[action.data.processor]) { + return _extends({}, state, { + runner: _extends({}, state.runner, _defineProperty({}, action.data.processor, _extends({}, state.runner[action.data.processor], { + last_message: action.data.data + }))), + stdout: state.stdout + action.data.data + }); + } + return _extends({}, state, { + stdout: state.stdout + action.data.data + }); + case _types2.default.system.stderr: + return _extends({}, state, { + last_message: action.data.data, + stderr: state.stderr + action.data.data + }); + default: + return state; + } +}; + +exports.default = systemReducer; + +/***/ }), + +/***/ "./app/client/types.js": +/*!*****************************!*\ + !*** ./app/client/types.js ***! + \*****************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _crud = __webpack_require__(/*! ./api/crud.types */ "./app/client/api/crud.types.js"); + +exports.default = { + system: { + load_site: 'SYSTEM_LOAD_SITE', + running_command: 'SYSTEM_RUNNING_COMMAND', + command_output: 'SYSTEM_COMMAND_OUTPUT', + relay_connected: 'SYSTEM_RELAY_CONNECTED', + relay_disconnected: 'SYSTEM_RELAY_DISCONNECTED', + rpc_connected: 'SYSTEM_RPC_CONNECTED', + rpc_disconnected: 'SYSTEM_RPC_DISCONNECTED', + list_directory: 'SYSTEM_LIST_DIRECTORY', + listing_directory: 'SYSTEM_LISTING_DIRECTORY', + stdout: 'SYSTEM_STDOUT', + stderr: 'SYSTEM_STDERR' + }, + app: { + change_tool: "APP_CHANGE_TOOL", + load_progress: "APP_LOAD_PROGRESS" + }, + folder: (0, _crud.crud_type)('folder', []), + file: (0, _crud.crud_type)('file', []), + task: (0, _crud.crud_type)('task', ['starting_task', 'stopping_task', 'task_begin', 'task_finish', 'start_queue', 'stop_queue', 'starting_queue', 'stopping_queue', 'progress', 'epoch']), + socket: { + connect: 'SOCKET_CONNECT', + connect_error: 'SOCKET_CONNECT_ERROR', + reconnect: 'SOCKET_RECONNECT', + reconnecting: 'SOCKET_RECONNECTING', + reconnect_error: 'SOCKET_RECONNECT_ERROR', + reconnect_failed: 'SOCKET_RECONNECT_FAILED', + disconnect: 'SOCKET_DISCONNECT', + error: 'SOCKET_ERROR', + status: 'SOCKET_STATUS', + + load_params: 'SOCKET_LOAD_PARAMS', + list_checkpoints: 'SOCKET_LIST_CHECKPOINTS', + list_sequences: 'SOCKET_LIST_SEQUENCES', + list_epochs: 'SOCKET_LIST_EPOCHS' + }, + player: { + get_params: 'GET_PARAMS', + set_param: 'SET_PARAM', + + loading_checkpoints: 'LOADING_CHECKPOINTS', + loading_checkpoint: 'LOADING_CHECKPOINT', + list_checkpoints: 'LIST_CHECKPOINTS', + + loading_sequences: 'LOADING_SEQUENCES', + loading_sequence: 'LOADING_SEQUENCE', + load_sequence: 'LOAD_SEQUENCE', + + loading_epochs: 'LOADING_EPOCHS', + load_epoch: 'LOAD_EPOCH', + + set_fps: 'SET_FPS', + seeking: 'SEEKING', + pausing: 'PAUSING', + playing: 'PLAYING', + current_frame: 'CURRENT_FRAME', + start_recording: 'START_RECORDING', + add_record_frame: 'ADD_RECORD_FRAME', + save_frame: 'SAVE_FRAME', + saving_video: 'SAVING_VIDEO', + save_video: 'SAVE_VIDEO', + + set_fullscreen: 'SET_FULLSCREEN' + }, + audioPlayer: { + play: 'AUDIO_PLAY', + pause: 'AUDIO_PAUSE', + resume: 'AUDIO_RESUME', + enqueue: 'AUDIO_ENQUEUE' + }, + dataset: { + load: 'DATASET_LOAD', + set_folder: 'DATASET_SET_FOLDER', + upload_files: 'DATASET_UPLOAD_FILES', + file_progress: 'DATASET_FILE_PROGRESS', + file_uploaded: 'DATASET_FILE_UPLOADED', + fetch_url: 'DATASET_FETCH_URL', + fetch_progress: 'DATASET_FETCH_PROGRESS' + }, + samplernn: { + init: 'SAMPLERNN_INIT', + set_folder: 'SAMPLERNN_SET_FOLDER', + load_loss: 'SAMPLERNN_LOAD_LOSS', + load_graph: 'SAMPLERNN_LOAD_GRAPH' + // queue and train + // update checkpoint settings + // reset checkpoint settings + // queue new checkpoint + }, + pix2pix: (0, _crud.with_type)('pix2pix', ['init', 'set_folder']), + pix2pixhd: (0, _crud.with_type)('pix2pixhd', ['init', 'set_folder', 'load_results']), + pix2wav: (0, _crud.with_type)('pix2wav', ['init', 'set_folder']), + wav2pix: (0, _crud.with_type)('wav2pix', ['load', 'progress', 'finish', 'zip', 'uploading']), + dashboard: (0, _crud.with_type)('dashboard', ['load']), + morph: (0, _crud.with_type)('morph', ['load']) +}; + +/***/ }), + +/***/ "./app/client/util/format.js": +/*!***********************************!*\ + !*** ./app/client/util/format.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.timeInSeconds = timeInSeconds; +exports.gerund = gerund; +exports.commatize = commatize; +exports.carbon_date = carbon_date; +exports.hush_views = hush_views; +exports.hush_threads = hush_threads; +exports.hush_size = hush_size; +exports.hush_null = hush_null; +exports.get_age = get_age; +exports.courtesy_s = courtesy_s; +function timeInSeconds(n) { + return (n / 10).toFixed(1) + ' s.'; +} +function gerund(s) { + return s.replace(/e?$/, 'ing'); +} +function commatize(n, radix) { + radix = radix || 1024; + var nums = [], + i, + counter = 0, + r = Math.floor; + if (n > radix) { + n /= radix; + nums.unshift(r(n * 10 % 10)); + nums.unshift("."); + } + do { + i = n % 10; + n = r(n / 10); + if (n && !(++counter % 3)) { + i = ' ' + r(i); + } + nums.unshift(r(i)); + } while (n); + return nums.join(""); +} +function carbon_date(date, no_bold) { + var span = (+new Date() - new Date(date)) / 1000, + color; + if (!no_bold && span < 86400) // modified today + { + color = "new"; + } else if (span < 604800) // modifed this week + { + color = "recent"; + } else if (span < 1209600) // modifed 2 weeks ago + { + color = "med"; + } else if (span < 3024000) // modifed 5 weeks ago + { + color = "old"; + } else if (span < 12315200) // modifed 6 months ago + { + color = "older"; + } else { + color = "quiet"; + } + return color; +} +function hush_views(n, bias, no_bold) { + var txt = commatize(n, 1000); + bias = bias || 1; + n = n || 0; + if (n < 30) { + return ["quiet", n + " v."]; + } + if (n < 200) { + return ["quiet", txt + " v."]; + } else if (n < 500) { + return ["quiet", txt + " v."]; + } else if (n < 1000) { + return ["old", txt + " v."]; + } else if (n < 5000) { + return ["med", txt + " kv."]; + } else if (no_bold || n < 10000) { + return ["recent", txt + " kv."]; + } else { + return ["new", txt + " kv."]; + } +} +function hush_threads(n, bias, no_bold) { + var txt = commatize(n, 1000); + bias = bias || 1; + n = n || 0; + if (n < 10) { + return ["quiet", n + " t."]; + } else if (n < 25) { + return ["old", txt + " t."]; + } else if (n < 50) { + return ["med", txt + " t."]; + } else if (no_bold || n < 100) { + return ["recent", txt + " t."]; + } else { + return ["new", txt + " t."]; + } +} +function hush_size(n, bias, no_bold) { + var txt = commatize(Math.round(n / 1024)); + bias = 1 || bias; + n = n || 0; + if (!n) { + return ['', '']; + } + if (n < 1000) { + return ["quiet", n + " b."]; + } + if (n < 1000000) { + return ["quiet", txt + " kb."]; + } else if (n < 20000000 / bias) { + return ["quiet", txt + " mb."]; + } else if (n < 50000000 / bias) { + return ["old", txt + " mb."]; + } else if (n < 80000000 / bias) { + return ["med", txt + " mb."]; + } else if (no_bold || n < 170000000 / bias) { + return ["recent", txt + " mb."]; + } else { + return ["new", txt + " mb."]; + } +} +function hush_null(n, unit, no_bold) { + var s = unit ? n + " " + unit + "." : n; + if (n < 3) { + return ["quiet", s]; + } else if (n < 6) { + return ["older", s]; + } else if (n < 10) { + return ["old", s]; + } else if (n < 16) { + return ["med", s]; + } else if (no_bold || n < 21) { + return ["recent", s]; + } else { + return ["new", s]; + } +} +function get_age(t) { + var age = Math.abs(+Date.now() - new Date(t)) / 1000; + var r = Math.floor; + var m; + if (age < 5) { + return "now"; + } + if (age < 60) { + return r(age) + "s"; + } + age /= 60; + if (age < 60) { + return r(age) + "m"; + } + m = r(age % 60); + age /= 60; + if (m > 0 && age < 2) { + return r(age) + "h" + m + "m"; + } + if (age < 24) { + return r(age) + "h"; + } + age /= 24; + if (age < 7) { + return r(age) + "d"; + } + age /= 7; + if (age < 12) { + return r(age) + "w"; + } + age /= 4; + if (age < 12) { + return r(age) + "m"; + } + age /= 12; + return r(age) + "y"; +} +function courtesy_s(n, s) { + return n == 1 ? "" : s || "s"; +} + +/***/ }), + +/***/ "./app/client/util/hidpi-canvas.js": +/*!*****************************************!*\ + !*** ./app/client/util/hidpi-canvas.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/** + * HiDPI Canvas Polyfill (1.0.10) + * + * Author: Jonathan D. Johnson (http://jondavidjohn.com) + * Homepage: https://github.com/jondavidjohn/hidpi-canvas-polyfill + * Issue Tracker: https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues + * License: Apache-2.0 +*/ +(function (prototype) { + + var pixelRatio = function () { + var canvas = window.document.createElement('canvas'), + context = canvas.getContext('2d'), + backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; + + return (window.devicePixelRatio || 1) / backingStore; + }(), + forEach = function forEach(obj, func) { + for (var p in obj) { + if (obj.hasOwnProperty(p)) { + func(obj[p], p); + } + } + }, + ratioArgs = { + 'fillRect': 'all', + 'clearRect': 'all', + 'strokeRect': 'all', + 'moveTo': 'all', + 'lineTo': 'all', + 'arc': [0, 1, 2], + 'arcTo': 'all', + 'bezierCurveTo': 'all', + 'isPointinPath': 'all', + 'isPointinStroke': 'all', + 'quadraticCurveTo': 'all', + 'rect': 'all', + 'translate': 'all', + 'createRadialGradient': 'all', + 'createLinearGradient': 'all' + }; + + if (pixelRatio === 1) return; + + forEach(ratioArgs, function (value, key) { + prototype[key] = function (_super) { + return function () { + var i, + len, + args = Array.prototype.slice.call(arguments); + + if (value === 'all') { + args = args.map(function (a) { + return a * pixelRatio; + }); + } else if (Array.isArray(value)) { + for (i = 0, len = value.length; i < len; i++) { + args[value[i]] *= pixelRatio; + } + } + + return _super.apply(this, args); + }; + }(prototype[key]); + }); + + // Stroke lineWidth adjustment + prototype.stroke = function (_super) { + return function () { + this.lineWidth *= pixelRatio; + _super.apply(this, arguments); + this.lineWidth /= pixelRatio; + }; + }(prototype.stroke); + + // Text + // + prototype.fillText = function (_super) { + return function () { + var args = Array.prototype.slice.call(arguments); + + args[1] *= pixelRatio; // x + args[2] *= pixelRatio; // y + + this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { + return m * pixelRatio + u; + }); + + _super.apply(this, args); + + this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { + return m / pixelRatio + u; + }); + }; + }(prototype.fillText); + + prototype.strokeText = function (_super) { + return function () { + var args = Array.prototype.slice.call(arguments); + + args[1] *= pixelRatio; // x + args[2] *= pixelRatio; // y + + this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { + return m * pixelRatio + u; + }); + + _super.apply(this, args); + + this.font = this.font.replace(/(\d+)(px|em|rem|pt)/g, function (w, m, u) { + return m / pixelRatio + u; + }); + }; + }(prototype.strokeText); +})(window.CanvasRenderingContext2D.prototype); +;(function (prototype) { + prototype.getContext = function (_super) { + return function (type) { + var backingStore, ratio, context; + + if (type == '2d-lodpi') { + context = _super.call(this, '2d'); + } else if (type === '2d') { + context = _super.call(this, '2d'); + + backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; + + ratio = (window.devicePixelRatio || 1) / backingStore; + + if (ratio > 1) { + this.style.height = this.height + 'px'; + this.style.width = this.width + 'px'; + this.width *= ratio; + this.height *= ratio; + } + } else { + context = _super.call(this, type); + } + + return context; + }; + }(prototype.getContext); +})(window.HTMLCanvasElement.prototype); + +/***/ }), + +/***/ "./app/client/util/index.js": +/*!**********************************!*\ + !*** ./app/client/util/index.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +var _sort = __webpack_require__(/*! ./sort */ "./app/client/util/sort.js"); + +var sort = _interopRequireWildcard(_sort); + +var _format = __webpack_require__(/*! ./format */ "./app/client/util/format.js"); + +var format = _interopRequireWildcard(_format); + +var _math = __webpack_require__(/*! ./math */ "./app/client/util/math.js"); + +var maths = _interopRequireWildcard(_math); + +__webpack_require__(/*! ./hidpi-canvas */ "./app/client/util/hidpi-canvas.js"); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var is_iphone = !!(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i)); +var is_ipad = !!navigator.userAgent.match(/iPad/i); +var is_android = !!navigator.userAgent.match(/Android/i); +var is_mobile = is_iphone || is_ipad || is_android; +var is_desktop = !is_mobile; + +var htmlClassList = document.body.parentNode.classList; +htmlClassList.add(is_desktop ? 'desktop' : 'mobile'); +htmlClassList.remove('loading'); + +// window.debug = false + +var allProgress = function allProgress(promises, progress_cb) { + var d = 0; + progress_cb(0, 0, promises.length); + promises.forEach(function (p) { + p.then(function (s) { + d += 1; + progress_cb(Math.floor(d * 100 / promises.length), d, promises.length); + return s; + }); + }); + return Promise.all(promises); +}; + +document.body.style.backgroundImage = 'linear-gradient(' + (maths.randint(40) + 40) + 'deg, #fde, #ffe)'; + +var fieldSet = function fieldSet(defaultFields) { + return function (fields) { + if (fields) { + if (fields instanceof Set) { + return fields; + } + return new Set(fields.split(' ')); + } + return defaultFields; + }; +}; + +exports.default = _extends({}, maths, format, { + sort: sort, + allProgress: allProgress, fieldSet: fieldSet, + is_iphone: is_iphone, is_ipad: is_ipad, is_android: is_android, is_mobile: is_mobile, is_desktop: is_desktop +}); + +/***/ }), + +/***/ "./app/client/util/math.js": +/*!*********************************!*\ + !*** ./app/client/util/math.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.randrange = randrange; +exports.randsign = randsign; +exports.choice = choice; +exports.angle = angle; +exports.dist = dist; +exports.xor = xor; +exports.quantize = quantize; +exports.shuffle = shuffle; +exports.gaussian = gaussian; +var mod = exports.mod = function mod(n, m) { + return n - m * Math.floor(n / m); +}; +var clamp = exports.clamp = function clamp(n, a, b) { + return n < a ? a : n < b ? n : b; +}; +var norm = exports.norm = function norm(n, a, b) { + return (n - a) / (b - a); +}; +var lerp = exports.lerp = function lerp(n, a, b) { + return (b - a) * n + a; +}; +var mix = exports.mix = function mix(n, a, b) { + return a * (1 - n) + b * n; +}; +var randint = exports.randint = function randint(n) { + return Math.floor(Math.random() * n); +}; +function randrange(a, b) { + return Math.random() * (b - a) + a; +} +function randsign() { + return Math.random() >= 0.5 ? -1 : 1; +} +function choice(a) { + return a[Math.floor(Math.random() * a.length)]; +} +function angle(x0, y0, x1, y1) { + return Math.atan2(y1 - y0, x1 - x0); +} +function dist(x0, y0, x1, y1) { + return Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)); +} +function xor(a, b) { + a = !!a;b = !!b;return (a || b) && !(a && b); +} +function quantize(a, b) { + return Math.floor(a / b) * b; +} +function shuffle(a) { + for (var i = a.length; i > 0; i--) { + var r = randint(i); + var swap = a[i - 1]; + a[i - 1] = a[r]; + a[r] = swap; + } + return a; +} +// returns a gaussian random function with the given mean and stdev. +function gaussian(mean, stdev) { + var y2 = void 0; + var use_last = false; + return function () { + var y1 = void 0; + if (use_last) { + y1 = y2; + use_last = false; + } else { + var x1 = void 0, + x2 = void 0, + w = void 0; + do { + x1 = 2.0 * Math.random() - 1.0; + x2 = 2.0 * Math.random() - 1.0; + w = x1 * x1 + x2 * x2; + } while (w >= 1.0); + w = Math.sqrt(-2.0 * Math.log(w) / w); + y1 = x1 * w; + y2 = x2 * w; + use_last = true; + } + + var retval = mean + stdev * y1; + if (retval > 0) return retval; + return -retval; + }; +} + +/***/ }), + +/***/ "./app/client/util/sort.js": +/*!*********************************!*\ + !*** ./app/client/util/sort.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +var numericSort = exports.numericSort = { + asc: function asc(a, b) { + return a[0] - b[0]; + }, + desc: function desc(a, b) { + return b[0] - a[0]; + } +}; +var stringSort = exports.stringSort = { + asc: function asc(a, b) { + return a[0].localeCompare(b[0]); + }, + desc: function desc(a, b) { + return b[0].localeCompare(a[0]); + } +}; +var orderByFn = exports.orderByFn = function orderByFn() { + var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'name asc'; + + var _s$split = s.split(' '), + _s$split2 = _slicedToArray(_s$split, 2), + _s$split2$ = _s$split2[0], + field = _s$split2$ === undefined ? 'name' : _s$split2$, + _s$split2$2 = _s$split2[1], + direction = _s$split2$2 === undefined ? 'asc' : _s$split2$2; + + var mapFn = void 0, + sortFn = void 0; + switch (field) { + case 'epoch': + mapFn = function mapFn(a) { + return [parseInt(a.epoch || a.epochs) || 0, a]; + }; + sortFn = numericSort[direction]; + break; + case 'size': + mapFn = function mapFn(a) { + return [parseInt(a.size) || 0, a]; + }; + sortFn = numericSort[direction]; + break; + case 'date': + mapFn = function mapFn(a) { + return [+new Date(a.date || a.created_at), a]; + }; + sortFn = numericSort[direction]; + break; + case 'updated_at': + mapFn = function mapFn(a) { + return [+new Date(a.updated_at), a]; + }; + sortFn = numericSort[direction]; + break; + case 'priority': + mapFn = function mapFn(a) { + return [parseInt(a.priority) || parseInt(a.id) || 1000, a]; + }; + sortFn = numericSort[direction]; + case 'name': + default: + mapFn = function mapFn(a) { + return [a.name || "", a]; + }; + sortFn = stringSort[direction]; + break; + } + return { mapFn: mapFn, sortFn: sortFn }; +}; + +/***/ }), + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (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 + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + + +var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js") +var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js") +var isArray = __webpack_require__(/*! isarray */ "./node_modules/buffer/node_modules/isarray/index.js") + +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__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) + +/***/ }), + +/***/ "./node_modules/buffer/node_modules/isarray/index.js": +/*!***********************************************************!*\ + !*** ./node_modules/buffer/node_modules/isarray/index.js ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), + +/***/ "./node_modules/core-util-is/lib/util.js": +/*!***********************************************!*\ + !*** ./node_modules/core-util-is/lib/util.js ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer)) + +/***/ }), + +/***/ "./node_modules/events/events.js": +/*!***************************************!*\ + !*** ./node_modules/events/events.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + + +/***/ }), + +/***/ "./node_modules/fbjs/lib/emptyFunction.js": +/*!************************************************!*\ + !*** ./node_modules/fbjs/lib/emptyFunction.js ***! + \************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/** + * 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. + * + * + */ + +function makeEmptyFunction(arg) { + return function () { + return arg; + }; +} + +/** + * This function accepts and discards inputs; it has no side effects. This is + * primarily useful idiomatically for overridable function endpoints which + * always need to be callable, since JS lacks a null-call idiom ala Cocoa. + */ +var emptyFunction = function emptyFunction() {}; + +emptyFunction.thatReturns = makeEmptyFunction; +emptyFunction.thatReturnsFalse = makeEmptyFunction(false); +emptyFunction.thatReturnsTrue = makeEmptyFunction(true); +emptyFunction.thatReturnsNull = makeEmptyFunction(null); +emptyFunction.thatReturnsThis = function () { + return this; +}; +emptyFunction.thatReturnsArgument = function (arg) { + return arg; +}; + +module.exports = emptyFunction; + +/***/ }), + +/***/ "./node_modules/fbjs/lib/invariant.js": +/*!********************************************!*\ + !*** ./node_modules/fbjs/lib/invariant.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/** + * 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. + * + */ + + + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var validateFormat = function validateFormat(format) {}; + +if (true) { + validateFormat = function validateFormat(format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} + +function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); + + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error(format.replace(/%s/g, function () { + return args[argIndex++]; + })); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} + +module.exports = invariant; + +/***/ }), + +/***/ "./node_modules/fbjs/lib/warning.js": +/*!******************************************!*\ + !*** ./node_modules/fbjs/lib/warning.js ***! + \******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/** + * Copyright (c) 2014-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. + * + */ + + + +var emptyFunction = __webpack_require__(/*! ./emptyFunction */ "./node_modules/fbjs/lib/emptyFunction.js"); + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = emptyFunction; + +if (true) { + var printWarning = function printWarning(format) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var argIndex = 0; + var message = 'Warning: ' + format.replace(/%s/g, function () { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; + + warning = function warning(condition, format) { + if (format === undefined) { + throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); + } + + if (format.indexOf('Failed Composite propType: ') === 0) { + return; // Ignore CompositeComponent proptype check. + } + + if (!condition) { + for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + + printWarning.apply(undefined, [format].concat(args)); + } + }; +} + +module.exports = warning; + +/***/ }), + +/***/ "./node_modules/fetch-jsonp/build/fetch-jsonp.js": +/*!*******************************************************!*\ + !*** ./node_modules/fetch-jsonp/build/fetch-jsonp.js ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, module], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), + __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? + (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { var mod; } +})(this, function (exports, module) { + 'use strict'; + + var defaultOptions = { + timeout: 5000, + jsonpCallback: 'callback', + jsonpCallbackFunction: null + }; + + function generateCallbackFunction() { + return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000); + } + + function clearFunction(functionName) { + // IE8 throws an exception when you try to delete a property on window + // http://stackoverflow.com/a/1824228/751089 + try { + delete window[functionName]; + } catch (e) { + window[functionName] = undefined; + } + } + + function removeScript(scriptId) { + var script = document.getElementById(scriptId); + if (script) { + document.getElementsByTagName('head')[0].removeChild(script); + } + } + + function fetchJsonp(_url) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + // to avoid param reassign + var url = _url; + var timeout = options.timeout || defaultOptions.timeout; + var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback; + + var timeoutId = undefined; + + return new Promise(function (resolve, reject) { + var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction(); + var scriptId = jsonpCallback + '_' + callbackFunction; + + window[callbackFunction] = function (response) { + resolve({ + ok: true, + // keep consistent with fetch API + json: function json() { + return Promise.resolve(response); + } + }); + + if (timeoutId) clearTimeout(timeoutId); + + removeScript(scriptId); + + clearFunction(callbackFunction); + }; + + // Check if the user set their own params, and if not add a ? to start a list of params + url += url.indexOf('?') === -1 ? '?' : '&'; + + var jsonpScript = document.createElement('script'); + jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction); + if (options.charset) { + jsonpScript.setAttribute('charset', options.charset); + } + jsonpScript.id = scriptId; + document.getElementsByTagName('head')[0].appendChild(jsonpScript); + + timeoutId = setTimeout(function () { + reject(new Error('JSONP request to ' + _url + ' timed out')); + + clearFunction(callbackFunction); + removeScript(scriptId); + window[callbackFunction] = function () { + clearFunction(callbackFunction); + }; + }, timeout); + + // Caught if got 404/500 + jsonpScript.onerror = function () { + reject(new Error('JSONP request to ' + _url + ' failed')); + + clearFunction(callbackFunction); + removeScript(scriptId); + if (timeoutId) clearTimeout(timeoutId); + }; + }); + } + + // export as global function + /* + let local; + if (typeof global !== 'undefined') { + local = global; + } else if (typeof self !== 'undefined') { + local = self; + } else { + try { + local = Function('return this')(); + } catch (e) { + throw new Error('polyfill failed because global object is unavailable in this environment'); + } + } + local.fetchJsonp = fetchJsonp; + */ + + module.exports = fetchJsonp; +}); + +/***/ }), + +/***/ "./node_modules/fft.js/lib/fft.js": +/*!****************************************!*\ + !*** ./node_modules/fft.js/lib/fft.js ***! + \****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function FFT(size) { + this.size = size | 0; + if (this.size <= 1 || (this.size & (this.size - 1)) !== 0) + throw new Error('FFT size must be a power of two and bigger than 1'); + + this._csize = size << 1; + + // NOTE: Use of `var` is intentional for old V8 versions + var table = new Array(this.size * 2); + for (var i = 0; i < table.length; i += 2) { + const angle = Math.PI * i / this.size; + table[i] = Math.cos(angle); + table[i + 1] = -Math.sin(angle); + } + this.table = table; + + // Find size's power of two + var power = 0; + for (var t = 1; this.size > t; t <<= 1) + power++; + + // Calculate initial step's width: + // * If we are full radix-4 - it is 2x smaller to give inital len=8 + // * Otherwise it is the same as `power` to give len=4 + this._width = power % 2 === 0 ? power - 1 : power; + + // Pre-compute bit-reversal patterns + this._bitrev = new Array(1 << this._width); + for (var j = 0; j < this._bitrev.length; j++) { + this._bitrev[j] = 0; + for (var shift = 0; shift < this._width; shift += 2) { + var revShift = this._width - shift - 2; + this._bitrev[j] |= ((j >>> shift) & 3) << revShift; + } + } + + this._out = null; + this._data = null; + this._inv = 0; +} +module.exports = FFT; + +FFT.prototype.fromComplexArray = function fromComplexArray(complex, storage) { + var res = storage || new Array(complex.length >>> 1); + for (var i = 0; i < complex.length; i += 2) + res[i >>> 1] = complex[i]; + return res; +}; + +FFT.prototype.createComplexArray = function createComplexArray() { + const res = new Array(this._csize); + for (var i = 0; i < res.length; i++) + res[i] = 0; + return res; +}; + +FFT.prototype.toComplexArray = function toComplexArray(input, storage) { + var res = storage || this.createComplexArray(); + for (var i = 0; i < res.length; i += 2) { + res[i] = input[i >>> 1]; + res[i + 1] = 0; + } + return res; +}; + +FFT.prototype.completeSpectrum = function completeSpectrum(spectrum) { + var size = this._csize; + var half = size >>> 1; + for (var i = 2; i < half; i += 2) { + spectrum[size - i] = spectrum[i]; + spectrum[size - i + 1] = -spectrum[i + 1]; + } +}; + +FFT.prototype.transform = function transform(out, data) { + if (out === data) + throw new Error('Input and output buffers must be different'); + + this._out = out; + this._data = data; + this._inv = 0; + this._transform4(); + this._out = null; + this._data = null; +}; + +FFT.prototype.realTransform = function realTransform(out, data) { + if (out === data) + throw new Error('Input and output buffers must be different'); + + this._out = out; + this._data = data; + this._inv = 0; + this._realTransform4(); + this._out = null; + this._data = null; +}; + +FFT.prototype.inverseTransform = function inverseTransform(out, data) { + if (out === data) + throw new Error('Input and output buffers must be different'); + + this._out = out; + this._data = data; + this._inv = 1; + this._transform4(); + for (var i = 0; i < out.length; i++) + out[i] /= this.size; + this._out = null; + this._data = null; +}; + +// radix-4 implementation +// +// NOTE: Uses of `var` are intentional for older V8 version that do not +// support both `let compound assignments` and `const phi` +FFT.prototype._transform4 = function _transform4() { + var out = this._out; + var size = this._csize; + + // Initial step (permute and transform) + var width = this._width; + var step = 1 << width; + var len = (size / step) << 1; + + var outOff; + var t; + var bitrev = this._bitrev; + if (len === 4) { + for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { + const off = bitrev[t]; + this._singleTransform2(outOff, off, step); + } + } else { + // len === 8 + for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { + const off = bitrev[t]; + this._singleTransform4(outOff, off, step); + } + } + + // Loop through steps in decreasing order + var inv = this._inv ? -1 : 1; + var table = this.table; + for (step >>= 2; step >= 2; step >>= 2) { + len = (size / step) << 1; + var quarterLen = len >>> 2; + + // Loop through offsets in the data + for (outOff = 0; outOff < size; outOff += len) { + // Full case + var limit = outOff + quarterLen; + for (var i = outOff, k = 0; i < limit; i += 2, k += step) { + const A = i; + const B = A + quarterLen; + const C = B + quarterLen; + const D = C + quarterLen; + + // Original values + const Ar = out[A]; + const Ai = out[A + 1]; + const Br = out[B]; + const Bi = out[B + 1]; + const Cr = out[C]; + const Ci = out[C + 1]; + const Dr = out[D]; + const Di = out[D + 1]; + + // Middle values + const MAr = Ar; + const MAi = Ai; + + const tableBr = table[k]; + const tableBi = inv * table[k + 1]; + const MBr = Br * tableBr - Bi * tableBi; + const MBi = Br * tableBi + Bi * tableBr; + + const tableCr = table[2 * k]; + const tableCi = inv * table[2 * k + 1]; + const MCr = Cr * tableCr - Ci * tableCi; + const MCi = Cr * tableCi + Ci * tableCr; + + const tableDr = table[3 * k]; + const tableDi = inv * table[3 * k + 1]; + const MDr = Dr * tableDr - Di * tableDi; + const MDi = Dr * tableDi + Di * tableDr; + + // Pre-Final values + const T0r = MAr + MCr; + const T0i = MAi + MCi; + const T1r = MAr - MCr; + const T1i = MAi - MCi; + const T2r = MBr + MDr; + const T2i = MBi + MDi; + const T3r = inv * (MBr - MDr); + const T3i = inv * (MBi - MDi); + + // Final values + const FAr = T0r + T2r; + const FAi = T0i + T2i; + + const FCr = T0r - T2r; + const FCi = T0i - T2i; + + const FBr = T1r + T3i; + const FBi = T1i - T3r; + + const FDr = T1r - T3i; + const FDi = T1i + T3r; + + out[A] = FAr; + out[A + 1] = FAi; + out[B] = FBr; + out[B + 1] = FBi; + out[C] = FCr; + out[C + 1] = FCi; + out[D] = FDr; + out[D + 1] = FDi; + } + } + } +}; + +// radix-2 implementation +// +// NOTE: Only called for len=4 +FFT.prototype._singleTransform2 = function _singleTransform2(outOff, off, + step) { + const out = this._out; + const data = this._data; + + const evenR = data[off]; + const evenI = data[off + 1]; + const oddR = data[off + step]; + const oddI = data[off + step + 1]; + + const leftR = evenR + oddR; + const leftI = evenI + oddI; + const rightR = evenR - oddR; + const rightI = evenI - oddI; + + out[outOff] = leftR; + out[outOff + 1] = leftI; + out[outOff + 2] = rightR; + out[outOff + 3] = rightI; +}; + +// radix-4 +// +// NOTE: Only called for len=8 +FFT.prototype._singleTransform4 = function _singleTransform4(outOff, off, + step) { + const out = this._out; + const data = this._data; + const inv = this._inv ? -1 : 1; + const step2 = step * 2; + const step3 = step * 3; + + // Original values + const Ar = data[off]; + const Ai = data[off + 1]; + const Br = data[off + step]; + const Bi = data[off + step + 1]; + const Cr = data[off + step2]; + const Ci = data[off + step2 + 1]; + const Dr = data[off + step3]; + const Di = data[off + step3 + 1]; + + // Pre-Final values + const T0r = Ar + Cr; + const T0i = Ai + Ci; + const T1r = Ar - Cr; + const T1i = Ai - Ci; + const T2r = Br + Dr; + const T2i = Bi + Di; + const T3r = inv * (Br - Dr); + const T3i = inv * (Bi - Di); + + // Final values + const FAr = T0r + T2r; + const FAi = T0i + T2i; + + const FBr = T1r + T3i; + const FBi = T1i - T3r; + + const FCr = T0r - T2r; + const FCi = T0i - T2i; + + const FDr = T1r - T3i; + const FDi = T1i + T3r; + + out[outOff] = FAr; + out[outOff + 1] = FAi; + out[outOff + 2] = FBr; + out[outOff + 3] = FBi; + out[outOff + 4] = FCr; + out[outOff + 5] = FCi; + out[outOff + 6] = FDr; + out[outOff + 7] = FDi; +}; + +// Real input radix-4 implementation +FFT.prototype._realTransform4 = function _realTransform4() { + var out = this._out; + var size = this._csize; + + // Initial step (permute and transform) + var width = this._width; + var step = 1 << width; + var len = (size / step) << 1; + + var outOff; + var t; + var bitrev = this._bitrev; + if (len === 4) { + for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { + const off = bitrev[t]; + this._singleRealTransform2(outOff, off >>> 1, step >>> 1); + } + } else { + // len === 8 + for (outOff = 0, t = 0; outOff < size; outOff += len, t++) { + const off = bitrev[t]; + this._singleRealTransform4(outOff, off >>> 1, step >>> 1); + } + } + + // Loop through steps in decreasing order + var inv = this._inv ? -1 : 1; + var table = this.table; + for (step >>= 2; step >= 2; step >>= 2) { + len = (size / step) << 1; + var halfLen = len >>> 1; + var quarterLen = halfLen >>> 1; + var hquarterLen = quarterLen >>> 1; + + // Loop through offsets in the data + for (outOff = 0; outOff < size; outOff += len) { + for (var i = 0, k = 0; i <= hquarterLen; i += 2, k += step) { + var A = outOff + i; + var B = A + quarterLen; + var C = B + quarterLen; + var D = C + quarterLen; + + // Original values + var Ar = out[A]; + var Ai = out[A + 1]; + var Br = out[B]; + var Bi = out[B + 1]; + var Cr = out[C]; + var Ci = out[C + 1]; + var Dr = out[D]; + var Di = out[D + 1]; + + // Middle values + var MAr = Ar; + var MAi = Ai; + + var tableBr = table[k]; + var tableBi = inv * table[k + 1]; + var MBr = Br * tableBr - Bi * tableBi; + var MBi = Br * tableBi + Bi * tableBr; + + var tableCr = table[2 * k]; + var tableCi = inv * table[2 * k + 1]; + var MCr = Cr * tableCr - Ci * tableCi; + var MCi = Cr * tableCi + Ci * tableCr; + + var tableDr = table[3 * k]; + var tableDi = inv * table[3 * k + 1]; + var MDr = Dr * tableDr - Di * tableDi; + var MDi = Dr * tableDi + Di * tableDr; + + // Pre-Final values + var T0r = MAr + MCr; + var T0i = MAi + MCi; + var T1r = MAr - MCr; + var T1i = MAi - MCi; + var T2r = MBr + MDr; + var T2i = MBi + MDi; + var T3r = inv * (MBr - MDr); + var T3i = inv * (MBi - MDi); + + // Final values + var FAr = T0r + T2r; + var FAi = T0i + T2i; + + var FBr = T1r + T3i; + var FBi = T1i - T3r; + + out[A] = FAr; + out[A + 1] = FAi; + out[B] = FBr; + out[B + 1] = FBi; + + // Output final middle point + if (i === 0) { + var FCr = T0r - T2r; + var FCi = T0i - T2i; + out[C] = FCr; + out[C + 1] = FCi; + continue; + } + + // Do not overwrite ourselves + if (i === hquarterLen) + continue; + + // In the flipped case: + // MAi = -MAi + // MBr=-MBi, MBi=-MBr + // MCr=-MCr + // MDr=MDi, MDi=MDr + var ST0r = T1r; + var ST0i = -T1i; + var ST1r = T0r; + var ST1i = -T0i; + var ST2r = -inv * T3i; + var ST2i = -inv * T3r; + var ST3r = -inv * T2i; + var ST3i = -inv * T2r; + + var SFAr = ST0r + ST2r; + var SFAi = ST0i + ST2i; + + var SFBr = ST1r + ST3i; + var SFBi = ST1i - ST3r; + + var SA = outOff + quarterLen - i; + var SB = outOff + halfLen - i; + + out[SA] = SFAr; + out[SA + 1] = SFAi; + out[SB] = SFBr; + out[SB + 1] = SFBi; + } + } + } +}; + +// radix-2 implementation +// +// NOTE: Only called for len=4 +FFT.prototype._singleRealTransform2 = function _singleRealTransform2(outOff, + off, + step) { + const out = this._out; + const data = this._data; + + const evenR = data[off]; + const oddR = data[off + step]; + + const leftR = evenR + oddR; + const rightR = evenR - oddR; + + out[outOff] = leftR; + out[outOff + 1] = 0; + out[outOff + 2] = rightR; + out[outOff + 3] = 0; +}; + +// radix-4 +// +// NOTE: Only called for len=8 +FFT.prototype._singleRealTransform4 = function _singleRealTransform4(outOff, + off, + step) { + const out = this._out; + const data = this._data; + const inv = this._inv ? -1 : 1; + const step2 = step * 2; + const step3 = step * 3; + + // Original values + const Ar = data[off]; + const Br = data[off + step]; + const Cr = data[off + step2]; + const Dr = data[off + step3]; + + // Pre-Final values + const T0r = Ar + Cr; + const T1r = Ar - Cr; + const T2r = Br + Dr; + const T3r = inv * (Br - Dr); + + // Final values + const FAr = T0r + T2r; + + const FBr = T1r; + const FBi = -T3r; + + const FCr = T0r - T2r; + + const FDr = T1r; + const FDi = T3r; + + out[outOff] = FAr; + out[outOff + 1] = 0; + out[outOff + 2] = FBr; + out[outOff + 3] = FBi; + out[outOff + 4] = FCr; + out[outOff + 5] = 0; + out[outOff + 6] = FDr; + out[outOff + 7] = FDi; +}; + + +/***/ }), + +/***/ "./node_modules/file-saver/FileSaver.js": +/*!**********************************************!*\ + !*** ./node_modules/file-saver/FileSaver.js ***! + \**********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var __WEBPACK_AMD_DEFINE_RESULT__;/* FileSaver.js + * A saveAs() FileSaver implementation. + * 1.3.2 + * 2016-06-16 18:25:19 + * + * By Eli Grey, http://eligrey.com + * License: MIT + * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md + */ + +/*global self */ +/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */ + +/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */ + +var saveAs = saveAs || (function(view) { + "use strict"; + // IE <10 is explicitly unsupported + if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { + return; + } + var + doc = view.document + // only get URL when necessary in case Blob.js hasn't overridden it yet + , get_URL = function() { + return view.URL || view.webkitURL || view; + } + , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a") + , can_use_save_link = "download" in save_link + , click = function(node) { + var event = new MouseEvent("click"); + node.dispatchEvent(event); + } + , is_safari = /constructor/i.test(view.HTMLElement) || view.safari + , is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent) + , throw_outside = function(ex) { + (view.setImmediate || view.setTimeout)(function() { + throw ex; + }, 0); + } + , force_saveable_type = "application/octet-stream" + // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to + , arbitrary_revoke_timeout = 1000 * 40 // in ms + , revoke = function(file) { + var revoker = function() { + if (typeof file === "string") { // file is an object URL + get_URL().revokeObjectURL(file); + } else { // file is a File + file.remove(); + } + }; + setTimeout(revoker, arbitrary_revoke_timeout); + } + , dispatch = function(filesaver, event_types, event) { + event_types = [].concat(event_types); + var i = event_types.length; + while (i--) { + var listener = filesaver["on" + event_types[i]]; + if (typeof listener === "function") { + try { + listener.call(filesaver, event || filesaver); + } catch (ex) { + throw_outside(ex); + } + } + } + } + , auto_bom = function(blob) { + // prepend BOM for UTF-8 XML and text/* types (including HTML) + // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF + if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { + return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type}); + } + return blob; + } + , FileSaver = function(blob, name, no_auto_bom) { + if (!no_auto_bom) { + blob = auto_bom(blob); + } + // First try a.download, then web filesystem, then object URLs + var + filesaver = this + , type = blob.type + , force = type === force_saveable_type + , object_url + , dispatch_all = function() { + dispatch(filesaver, "writestart progress write writeend".split(" ")); + } + // on any filesys errors revert to saving with object URLs + , fs_error = function() { + if ((is_chrome_ios || (force && is_safari)) && view.FileReader) { + // Safari doesn't allow downloading of blob urls + var reader = new FileReader(); + reader.onloadend = function() { + var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;'); + var popup = view.open(url, '_blank'); + if(!popup) view.location.href = url; + url=undefined; // release reference before dispatching + filesaver.readyState = filesaver.DONE; + dispatch_all(); + }; + reader.readAsDataURL(blob); + filesaver.readyState = filesaver.INIT; + return; + } + // don't create more object URLs than needed + if (!object_url) { + object_url = get_URL().createObjectURL(blob); + } + if (force) { + view.location.href = object_url; + } else { + var opened = view.open(object_url, "_blank"); + if (!opened) { + // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html + view.location.href = object_url; + } + } + filesaver.readyState = filesaver.DONE; + dispatch_all(); + revoke(object_url); + } + ; + filesaver.readyState = filesaver.INIT; + + if (can_use_save_link) { + object_url = get_URL().createObjectURL(blob); + setTimeout(function() { + save_link.href = object_url; + save_link.download = name; + click(save_link); + dispatch_all(); + revoke(object_url); + filesaver.readyState = filesaver.DONE; + }); + return; + } + + fs_error(); + } + , FS_proto = FileSaver.prototype + , saveAs = function(blob, name, no_auto_bom) { + return new FileSaver(blob, name || blob.name || "download", no_auto_bom); + } + ; + // IE 10+ (native saveAs) + if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { + return function(blob, name, no_auto_bom) { + name = name || blob.name || "download"; + + if (!no_auto_bom) { + blob = auto_bom(blob); + } + return navigator.msSaveOrOpenBlob(blob, name); + }; + } + + FS_proto.abort = function(){}; + FS_proto.readyState = FS_proto.INIT = 0; + FS_proto.WRITING = 1; + FS_proto.DONE = 2; + + FS_proto.error = + FS_proto.onwritestart = + FS_proto.onprogress = + FS_proto.onwrite = + FS_proto.onabort = + FS_proto.onerror = + FS_proto.onwriteend = + null; + + return saveAs; +}( + typeof self !== "undefined" && self + || typeof window !== "undefined" && window + || this.content +)); +// `self` is undefined in Firefox for Android content script context +// while `this` is nsIContentFrameMessageManager +// with an attribute `content` that corresponds to the window + +if (typeof module !== "undefined" && module.exports) { + module.exports.saveAs = saveAs; +} else if (("function" !== "undefined" && __webpack_require__(/*! !webpack amd define */ "./node_modules/webpack/buildin/amd-define.js") !== null) && (__webpack_require__(/*! !webpack amd options */ "./node_modules/webpack/buildin/amd-options.js") !== null)) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { + return saveAs; + }).call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); +} + + +/***/ }), + +/***/ "./node_modules/history/DOMUtils.js": +/*!******************************************!*\ + !*** ./node_modules/history/DOMUtils.js ***! + \******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; +var canUseDOM = exports.canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + +var addEventListener = exports.addEventListener = function addEventListener(node, event, listener) { + return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener); +}; + +var removeEventListener = exports.removeEventListener = function removeEventListener(node, event, listener) { + return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener); +}; + +var getConfirmation = exports.getConfirmation = function getConfirmation(message, callback) { + return callback(window.confirm(message)); +}; // eslint-disable-line no-alert + +/** + * Returns true if the HTML5 history API is supported. Taken from Modernizr. + * + * https://github.com/Modernizr/Modernizr/blob/master/LICENSE + * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 + */ +var supportsHistory = exports.supportsHistory = function supportsHistory() { + var ua = window.navigator.userAgent; + + if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false; + + return window.history && 'pushState' in window.history; +}; + +/** + * Returns true if browser fires popstate on hash change. + * IE10 and IE11 do not. + */ +var supportsPopStateOnHashChange = exports.supportsPopStateOnHashChange = function supportsPopStateOnHashChange() { + return window.navigator.userAgent.indexOf('Trident') === -1; +}; + +/** + * Returns false if using go(n) with hash history causes a full page reload. + */ +var supportsGoWithoutReloadUsingHash = exports.supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() { + return window.navigator.userAgent.indexOf('Firefox') === -1; +}; + +/** + * Returns true if a given popstate event is an extraneous WebKit event. + * Accounts for the fact that Chrome on iOS fires real popstate events + * containing undefined state when pressing the back button. + */ +var isExtraneousPopstateEvent = exports.isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) { + return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1; +}; + +/***/ }), + +/***/ "./node_modules/history/LocationUtils.js": +/*!***********************************************!*\ + !*** ./node_modules/history/LocationUtils.js ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; +exports.locationsAreEqual = exports.createLocation = undefined; + +var _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; }; + +var _resolvePathname = __webpack_require__(/*! resolve-pathname */ "./node_modules/resolve-pathname/index.js"); + +var _resolvePathname2 = _interopRequireDefault(_resolvePathname); + +var _valueEqual = __webpack_require__(/*! value-equal */ "./node_modules/value-equal/index.js"); + +var _valueEqual2 = _interopRequireDefault(_valueEqual); + +var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var createLocation = exports.createLocation = function createLocation(path, state, key, currentLocation) { + var location = void 0; + if (typeof path === 'string') { + // Two-arg form: push(path, state) + location = (0, _PathUtils.parsePath)(path); + location.state = state; + } else { + // One-arg form: push(location) + location = _extends({}, path); + + if (location.pathname === undefined) location.pathname = ''; + + if (location.search) { + if (location.search.charAt(0) !== '?') location.search = '?' + location.search; + } else { + location.search = ''; + } + + if (location.hash) { + if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash; + } else { + location.hash = ''; + } + + if (state !== undefined && location.state === undefined) location.state = state; + } + + try { + location.pathname = decodeURI(location.pathname); + } catch (e) { + if (e instanceof URIError) { + throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.'); + } else { + throw e; + } + } + + if (key) location.key = key; + + if (currentLocation) { + // Resolve incomplete/relative pathname relative to current location. + if (!location.pathname) { + location.pathname = currentLocation.pathname; + } else if (location.pathname.charAt(0) !== '/') { + location.pathname = (0, _resolvePathname2.default)(location.pathname, currentLocation.pathname); + } + } else { + // When there is no prior location and pathname is empty, set it to / + if (!location.pathname) { + location.pathname = '/'; + } + } + + return location; +}; + +var locationsAreEqual = exports.locationsAreEqual = function locationsAreEqual(a, b) { + return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && (0, _valueEqual2.default)(a.state, b.state); +}; + +/***/ }), + +/***/ "./node_modules/history/PathUtils.js": +/*!*******************************************!*\ + !*** ./node_modules/history/PathUtils.js ***! + \*******************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; +var addLeadingSlash = exports.addLeadingSlash = function addLeadingSlash(path) { + return path.charAt(0) === '/' ? path : '/' + path; +}; + +var stripLeadingSlash = exports.stripLeadingSlash = function stripLeadingSlash(path) { + return path.charAt(0) === '/' ? path.substr(1) : path; +}; + +var hasBasename = exports.hasBasename = function hasBasename(path, prefix) { + return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path); +}; + +var stripBasename = exports.stripBasename = function stripBasename(path, prefix) { + return hasBasename(path, prefix) ? path.substr(prefix.length) : path; +}; + +var stripTrailingSlash = exports.stripTrailingSlash = function stripTrailingSlash(path) { + return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path; +}; + +var parsePath = exports.parsePath = function parsePath(path) { + var pathname = path || '/'; + var search = ''; + var hash = ''; + + var hashIndex = pathname.indexOf('#'); + if (hashIndex !== -1) { + hash = pathname.substr(hashIndex); + pathname = pathname.substr(0, hashIndex); + } + + var searchIndex = pathname.indexOf('?'); + if (searchIndex !== -1) { + search = pathname.substr(searchIndex); + pathname = pathname.substr(0, searchIndex); + } + + return { + pathname: pathname, + search: search === '?' ? '' : search, + hash: hash === '#' ? '' : hash + }; +}; + +var createPath = exports.createPath = function createPath(location) { + var pathname = location.pathname, + search = location.search, + hash = location.hash; + + + var path = pathname || '/'; + + if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search; + + if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash; + + return path; +}; + +/***/ }), + +/***/ "./node_modules/history/createBrowserHistory.js": +/*!******************************************************!*\ + !*** ./node_modules/history/createBrowserHistory.js ***! + \******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _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; }; + +var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); + +var _warning2 = _interopRequireDefault(_warning); + +var _invariant = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _LocationUtils = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/LocationUtils.js"); + +var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); + +var _createTransitionManager = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/createTransitionManager.js"); + +var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + +var _DOMUtils = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/DOMUtils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var PopStateEvent = 'popstate'; +var HashChangeEvent = 'hashchange'; + +var getHistoryState = function getHistoryState() { + try { + return window.history.state || {}; + } catch (e) { + // IE 11 sometimes throws when accessing window.history.state + // See https://github.com/ReactTraining/history/pull/289 + return {}; + } +}; + +/** + * Creates a history object that uses the HTML5 history API including + * pushState, replaceState, and the popstate event. + */ +var createBrowserHistory = function createBrowserHistory() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + (0, _invariant2.default)(_DOMUtils.canUseDOM, 'Browser history needs a DOM'); + + var globalHistory = window.history; + var canUseHistory = (0, _DOMUtils.supportsHistory)(); + var needsHashChangeListener = !(0, _DOMUtils.supportsPopStateOnHashChange)(); + + var _props$forceRefresh = props.forceRefresh, + forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh, + _props$getUserConfirm = props.getUserConfirmation, + getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm, + _props$keyLength = props.keyLength, + keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; + + var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : ''; + + var getDOMLocation = function getDOMLocation(historyState) { + var _ref = historyState || {}, + key = _ref.key, + state = _ref.state; + + var _window$location = window.location, + pathname = _window$location.pathname, + search = _window$location.search, + hash = _window$location.hash; + + + var path = pathname + search + hash; + + (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); + + if (basename) path = (0, _PathUtils.stripBasename)(path, basename); + + return (0, _LocationUtils.createLocation)(path, state, key); + }; + + var createKey = function createKey() { + return Math.random().toString(36).substr(2, keyLength); + }; + + var transitionManager = (0, _createTransitionManager2.default)(); + + var setState = function setState(nextState) { + _extends(history, nextState); + + history.length = globalHistory.length; + + transitionManager.notifyListeners(history.location, history.action); + }; + + var handlePopState = function handlePopState(event) { + // Ignore extraneous popstate events in WebKit. + if ((0, _DOMUtils.isExtraneousPopstateEvent)(event)) return; + + handlePop(getDOMLocation(event.state)); + }; + + var handleHashChange = function handleHashChange() { + handlePop(getDOMLocation(getHistoryState())); + }; + + var forceNextPop = false; + + var handlePop = function handlePop(location) { + if (forceNextPop) { + forceNextPop = false; + setState(); + } else { + var action = 'POP'; + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ action: action, location: location }); + } else { + revertPop(location); + } + }); + } + }; + + var revertPop = function revertPop(fromLocation) { + var toLocation = history.location; + + // TODO: We could probably make this more reliable by + // keeping a list of keys we've seen in sessionStorage. + // Instead, we just default to 0 for keys we don't know. + + var toIndex = allKeys.indexOf(toLocation.key); + + if (toIndex === -1) toIndex = 0; + + var fromIndex = allKeys.indexOf(fromLocation.key); + + if (fromIndex === -1) fromIndex = 0; + + var delta = toIndex - fromIndex; + + if (delta) { + forceNextPop = true; + go(delta); + } + }; + + var initialLocation = getDOMLocation(getHistoryState()); + var allKeys = [initialLocation.key]; + + // Public interface + + var createHref = function createHref(location) { + return basename + (0, _PathUtils.createPath)(location); + }; + + var push = function push(path, state) { + (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'PUSH'; + var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var href = createHref(location); + var key = location.key, + state = location.state; + + + if (canUseHistory) { + globalHistory.pushState({ key: key, state: state }, null, href); + + if (forceRefresh) { + window.location.href = href; + } else { + var prevIndex = allKeys.indexOf(history.location.key); + var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); + + nextKeys.push(location.key); + allKeys = nextKeys; + + setState({ action: action, location: location }); + } + } else { + (0, _warning2.default)(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history'); + + window.location.href = href; + } + }); + }; + + var replace = function replace(path, state) { + (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'REPLACE'; + var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var href = createHref(location); + var key = location.key, + state = location.state; + + + if (canUseHistory) { + globalHistory.replaceState({ key: key, state: state }, null, href); + + if (forceRefresh) { + window.location.replace(href); + } else { + var prevIndex = allKeys.indexOf(history.location.key); + + if (prevIndex !== -1) allKeys[prevIndex] = location.key; + + setState({ action: action, location: location }); + } + } else { + (0, _warning2.default)(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history'); + + window.location.replace(href); + } + }); + }; + + var go = function go(n) { + globalHistory.go(n); + }; + + var goBack = function goBack() { + return go(-1); + }; + + var goForward = function goForward() { + return go(1); + }; + + var listenerCount = 0; + + var checkDOMListeners = function checkDOMListeners(delta) { + listenerCount += delta; + + if (listenerCount === 1) { + (0, _DOMUtils.addEventListener)(window, PopStateEvent, handlePopState); + + if (needsHashChangeListener) (0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange); + } else if (listenerCount === 0) { + (0, _DOMUtils.removeEventListener)(window, PopStateEvent, handlePopState); + + if (needsHashChangeListener) (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange); + } + }; + + var isBlocked = false; + + var block = function block() { + var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + var unblock = transitionManager.setPrompt(prompt); + + if (!isBlocked) { + checkDOMListeners(1); + isBlocked = true; + } + + return function () { + if (isBlocked) { + isBlocked = false; + checkDOMListeners(-1); + } + + return unblock(); + }; + }; + + var listen = function listen(listener) { + var unlisten = transitionManager.appendListener(listener); + checkDOMListeners(1); + + return function () { + checkDOMListeners(-1); + unlisten(); + }; + }; + + var history = { + length: globalHistory.length, + action: 'POP', + location: initialLocation, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + block: block, + listen: listen + }; + + return history; +}; + +exports.default = createBrowserHistory; + +/***/ }), + +/***/ "./node_modules/history/createHashHistory.js": +/*!***************************************************!*\ + !*** ./node_modules/history/createHashHistory.js ***! + \***************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _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; }; + +var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); + +var _warning2 = _interopRequireDefault(_warning); + +var _invariant = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); + +var _invariant2 = _interopRequireDefault(_invariant); + +var _LocationUtils = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/LocationUtils.js"); + +var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); + +var _createTransitionManager = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/createTransitionManager.js"); + +var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + +var _DOMUtils = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/DOMUtils.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var HashChangeEvent = 'hashchange'; + +var HashPathCoders = { + hashbang: { + encodePath: function encodePath(path) { + return path.charAt(0) === '!' ? path : '!/' + (0, _PathUtils.stripLeadingSlash)(path); + }, + decodePath: function decodePath(path) { + return path.charAt(0) === '!' ? path.substr(1) : path; + } + }, + noslash: { + encodePath: _PathUtils.stripLeadingSlash, + decodePath: _PathUtils.addLeadingSlash + }, + slash: { + encodePath: _PathUtils.addLeadingSlash, + decodePath: _PathUtils.addLeadingSlash + } +}; + +var getHashPath = function getHashPath() { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + var href = window.location.href; + var hashIndex = href.indexOf('#'); + return hashIndex === -1 ? '' : href.substring(hashIndex + 1); +}; + +var pushHashPath = function pushHashPath(path) { + return window.location.hash = path; +}; + +var replaceHashPath = function replaceHashPath(path) { + var hashIndex = window.location.href.indexOf('#'); + + window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path); +}; + +var createHashHistory = function createHashHistory() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + (0, _invariant2.default)(_DOMUtils.canUseDOM, 'Hash history needs a DOM'); + + var globalHistory = window.history; + var canGoWithoutReload = (0, _DOMUtils.supportsGoWithoutReloadUsingHash)(); + + var _props$getUserConfirm = props.getUserConfirmation, + getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils.getConfirmation : _props$getUserConfirm, + _props$hashType = props.hashType, + hashType = _props$hashType === undefined ? 'slash' : _props$hashType; + + var basename = props.basename ? (0, _PathUtils.stripTrailingSlash)((0, _PathUtils.addLeadingSlash)(props.basename)) : ''; + + var _HashPathCoders$hashT = HashPathCoders[hashType], + encodePath = _HashPathCoders$hashT.encodePath, + decodePath = _HashPathCoders$hashT.decodePath; + + + var getDOMLocation = function getDOMLocation() { + var path = decodePath(getHashPath()); + + (0, _warning2.default)(!basename || (0, _PathUtils.hasBasename)(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); + + if (basename) path = (0, _PathUtils.stripBasename)(path, basename); + + return (0, _LocationUtils.createLocation)(path); + }; + + var transitionManager = (0, _createTransitionManager2.default)(); + + var setState = function setState(nextState) { + _extends(history, nextState); + + history.length = globalHistory.length; + + transitionManager.notifyListeners(history.location, history.action); + }; + + var forceNextPop = false; + var ignorePath = null; + + var handleHashChange = function handleHashChange() { + var path = getHashPath(); + var encodedPath = encodePath(path); + + if (path !== encodedPath) { + // Ensure we always have a properly-encoded hash. + replaceHashPath(encodedPath); + } else { + var location = getDOMLocation(); + var prevLocation = history.location; + + if (!forceNextPop && (0, _LocationUtils.locationsAreEqual)(prevLocation, location)) return; // A hashchange doesn't always == location change. + + if (ignorePath === (0, _PathUtils.createPath)(location)) return; // Ignore this change; we already setState in push/replace. + + ignorePath = null; + + handlePop(location); + } + }; + + var handlePop = function handlePop(location) { + if (forceNextPop) { + forceNextPop = false; + setState(); + } else { + var action = 'POP'; + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ action: action, location: location }); + } else { + revertPop(location); + } + }); + } + }; + + var revertPop = function revertPop(fromLocation) { + var toLocation = history.location; + + // TODO: We could probably make this more reliable by + // keeping a list of paths we've seen in sessionStorage. + // Instead, we just default to 0 for paths we don't know. + + var toIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(toLocation)); + + if (toIndex === -1) toIndex = 0; + + var fromIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(fromLocation)); + + if (fromIndex === -1) fromIndex = 0; + + var delta = toIndex - fromIndex; + + if (delta) { + forceNextPop = true; + go(delta); + } + }; + + // Ensure the hash is encoded properly before doing anything else. + var path = getHashPath(); + var encodedPath = encodePath(path); + + if (path !== encodedPath) replaceHashPath(encodedPath); + + var initialLocation = getDOMLocation(); + var allPaths = [(0, _PathUtils.createPath)(initialLocation)]; + + // Public interface + + var createHref = function createHref(location) { + return '#' + encodePath(basename + (0, _PathUtils.createPath)(location)); + }; + + var push = function push(path, state) { + (0, _warning2.default)(state === undefined, 'Hash history cannot push state; it is ignored'); + + var action = 'PUSH'; + var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var path = (0, _PathUtils.createPath)(location); + var encodedPath = encodePath(basename + path); + var hashChanged = getHashPath() !== encodedPath; + + if (hashChanged) { + // We cannot tell if a hashchange was caused by a PUSH, so we'd + // rather setState here and ignore the hashchange. The caveat here + // is that other hash histories in the page will consider it a POP. + ignorePath = path; + pushHashPath(encodedPath); + + var prevIndex = allPaths.lastIndexOf((0, _PathUtils.createPath)(history.location)); + var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); + + nextPaths.push(path); + allPaths = nextPaths; + + setState({ action: action, location: location }); + } else { + (0, _warning2.default)(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack'); + + setState(); + } + }); + }; + + var replace = function replace(path, state) { + (0, _warning2.default)(state === undefined, 'Hash history cannot replace state; it is ignored'); + + var action = 'REPLACE'; + var location = (0, _LocationUtils.createLocation)(path, undefined, undefined, history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var path = (0, _PathUtils.createPath)(location); + var encodedPath = encodePath(basename + path); + var hashChanged = getHashPath() !== encodedPath; + + if (hashChanged) { + // We cannot tell if a hashchange was caused by a REPLACE, so we'd + // rather setState here and ignore the hashchange. The caveat here + // is that other hash histories in the page will consider it a POP. + ignorePath = path; + replaceHashPath(encodedPath); + } + + var prevIndex = allPaths.indexOf((0, _PathUtils.createPath)(history.location)); + + if (prevIndex !== -1) allPaths[prevIndex] = path; + + setState({ action: action, location: location }); + }); + }; + + var go = function go(n) { + (0, _warning2.default)(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser'); + + globalHistory.go(n); + }; + + var goBack = function goBack() { + return go(-1); + }; + + var goForward = function goForward() { + return go(1); + }; + + var listenerCount = 0; + + var checkDOMListeners = function checkDOMListeners(delta) { + listenerCount += delta; + + if (listenerCount === 1) { + (0, _DOMUtils.addEventListener)(window, HashChangeEvent, handleHashChange); + } else if (listenerCount === 0) { + (0, _DOMUtils.removeEventListener)(window, HashChangeEvent, handleHashChange); + } + }; + + var isBlocked = false; + + var block = function block() { + var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + var unblock = transitionManager.setPrompt(prompt); + + if (!isBlocked) { + checkDOMListeners(1); + isBlocked = true; + } + + return function () { + if (isBlocked) { + isBlocked = false; + checkDOMListeners(-1); + } + + return unblock(); + }; + }; + + var listen = function listen(listener) { + var unlisten = transitionManager.appendListener(listener); + checkDOMListeners(1); + + return function () { + checkDOMListeners(-1); + unlisten(); + }; + }; + + var history = { + length: globalHistory.length, + action: 'POP', + location: initialLocation, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + block: block, + listen: listen + }; + + return history; +}; + +exports.default = createHashHistory; + +/***/ }), + +/***/ "./node_modules/history/createMemoryHistory.js": +/*!*****************************************************!*\ + !*** ./node_modules/history/createMemoryHistory.js ***! + \*****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _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; }; + +var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); + +var _warning2 = _interopRequireDefault(_warning); + +var _PathUtils = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/PathUtils.js"); + +var _LocationUtils = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/LocationUtils.js"); + +var _createTransitionManager = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/createTransitionManager.js"); + +var _createTransitionManager2 = _interopRequireDefault(_createTransitionManager); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var clamp = function clamp(n, lowerBound, upperBound) { + return Math.min(Math.max(n, lowerBound), upperBound); +}; + +/** + * Creates a history object that stores locations in memory. + */ +var createMemoryHistory = function createMemoryHistory() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var getUserConfirmation = props.getUserConfirmation, + _props$initialEntries = props.initialEntries, + initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries, + _props$initialIndex = props.initialIndex, + initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex, + _props$keyLength = props.keyLength, + keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; + + + var transitionManager = (0, _createTransitionManager2.default)(); + + var setState = function setState(nextState) { + _extends(history, nextState); + + history.length = history.entries.length; + + transitionManager.notifyListeners(history.location, history.action); + }; + + var createKey = function createKey() { + return Math.random().toString(36).substr(2, keyLength); + }; + + var index = clamp(initialIndex, 0, initialEntries.length - 1); + var entries = initialEntries.map(function (entry) { + return typeof entry === 'string' ? (0, _LocationUtils.createLocation)(entry, undefined, createKey()) : (0, _LocationUtils.createLocation)(entry, undefined, entry.key || createKey()); + }); + + // Public interface + + var createHref = _PathUtils.createPath; + + var push = function push(path, state) { + (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'PUSH'; + var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var prevIndex = history.index; + var nextIndex = prevIndex + 1; + + var nextEntries = history.entries.slice(0); + if (nextEntries.length > nextIndex) { + nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); + } else { + nextEntries.push(location); + } + + setState({ + action: action, + location: location, + index: nextIndex, + entries: nextEntries + }); + }); + }; + + var replace = function replace(path, state) { + (0, _warning2.default)(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'REPLACE'; + var location = (0, _LocationUtils.createLocation)(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + history.entries[history.index] = location; + + setState({ action: action, location: location }); + }); + }; + + var go = function go(n) { + var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); + + var action = 'POP'; + var location = history.entries[nextIndex]; + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ + action: action, + location: location, + index: nextIndex + }); + } else { + // Mimic the behavior of DOM histories by + // causing a render after a cancelled POP. + setState(); + } + }); + }; + + var goBack = function goBack() { + return go(-1); + }; + + var goForward = function goForward() { + return go(1); + }; + + var canGo = function canGo(n) { + var nextIndex = history.index + n; + return nextIndex >= 0 && nextIndex < history.entries.length; + }; + + var block = function block() { + var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + return transitionManager.setPrompt(prompt); + }; + + var listen = function listen(listener) { + return transitionManager.appendListener(listener); + }; + + var history = { + length: entries.length, + action: 'POP', + location: entries[index], + index: index, + entries: entries, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + canGo: canGo, + block: block, + listen: listen + }; + + return history; +}; + +exports.default = createMemoryHistory; + +/***/ }), + +/***/ "./node_modules/history/createTransitionManager.js": +/*!*********************************************************!*\ + !*** ./node_modules/history/createTransitionManager.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +var _warning = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); + +var _warning2 = _interopRequireDefault(_warning); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var createTransitionManager = function createTransitionManager() { + var prompt = null; + + var setPrompt = function setPrompt(nextPrompt) { + (0, _warning2.default)(prompt == null, 'A history supports only one prompt at a time'); + + prompt = nextPrompt; + + return function () { + if (prompt === nextPrompt) prompt = null; + }; + }; + + var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) { + // TODO: If another transition starts while we're still confirming + // the previous one, we may end up in a weird state. Figure out the + // best way to handle this. + if (prompt != null) { + var result = typeof prompt === 'function' ? prompt(location, action) : prompt; + + if (typeof result === 'string') { + if (typeof getUserConfirmation === 'function') { + getUserConfirmation(result, callback); + } else { + (0, _warning2.default)(false, 'A history needs a getUserConfirmation function in order to use a prompt message'); + + callback(true); + } + } else { + // Return false from a transition hook to cancel the transition. + callback(result !== false); + } + } else { + callback(true); + } + }; + + var listeners = []; + + var appendListener = function appendListener(fn) { + var isActive = true; + + var listener = function listener() { + if (isActive) fn.apply(undefined, arguments); + }; + + listeners.push(listener); + + return function () { + isActive = false; + listeners = listeners.filter(function (item) { + return item !== listener; + }); + }; + }; + + var notifyListeners = function notifyListeners() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + listeners.forEach(function (listener) { + return listener.apply(undefined, args); + }); + }; + + return { + setPrompt: setPrompt, + confirmTransitionTo: confirmTransitionTo, + appendListener: appendListener, + notifyListeners: notifyListeners + }; +}; + +exports.default = createTransitionManager; + +/***/ }), + +/***/ "./node_modules/history/es/DOMUtils.js": +/*!*********************************************!*\ + !*** ./node_modules/history/es/DOMUtils.js ***! + \*********************************************/ +/*! exports provided: canUseDOM, addEventListener, removeEventListener, getConfirmation, supportsHistory, supportsPopStateOnHashChange, supportsGoWithoutReloadUsingHash, isExtraneousPopstateEvent */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "canUseDOM", function() { return canUseDOM; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addEventListener", function() { return addEventListener; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeEventListener", function() { return removeEventListener; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getConfirmation", function() { return getConfirmation; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsHistory", function() { return supportsHistory; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsPopStateOnHashChange", function() { return supportsPopStateOnHashChange; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "supportsGoWithoutReloadUsingHash", function() { return supportsGoWithoutReloadUsingHash; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isExtraneousPopstateEvent", function() { return isExtraneousPopstateEvent; }); +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + +var addEventListener = function addEventListener(node, event, listener) { + return node.addEventListener ? node.addEventListener(event, listener, false) : node.attachEvent('on' + event, listener); +}; + +var removeEventListener = function removeEventListener(node, event, listener) { + return node.removeEventListener ? node.removeEventListener(event, listener, false) : node.detachEvent('on' + event, listener); +}; + +var getConfirmation = function getConfirmation(message, callback) { + return callback(window.confirm(message)); +}; // eslint-disable-line no-alert + +/** + * Returns true if the HTML5 history API is supported. Taken from Modernizr. + * + * https://github.com/Modernizr/Modernizr/blob/master/LICENSE + * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js + * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586 + */ +var supportsHistory = function supportsHistory() { + var ua = window.navigator.userAgent; + + if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false; + + return window.history && 'pushState' in window.history; +}; + +/** + * Returns true if browser fires popstate on hash change. + * IE10 and IE11 do not. + */ +var supportsPopStateOnHashChange = function supportsPopStateOnHashChange() { + return window.navigator.userAgent.indexOf('Trident') === -1; +}; + +/** + * Returns false if using go(n) with hash history causes a full page reload. + */ +var supportsGoWithoutReloadUsingHash = function supportsGoWithoutReloadUsingHash() { + return window.navigator.userAgent.indexOf('Firefox') === -1; +}; + +/** + * Returns true if a given popstate event is an extraneous WebKit event. + * Accounts for the fact that Chrome on iOS fires real popstate events + * containing undefined state when pressing the back button. + */ +var isExtraneousPopstateEvent = function isExtraneousPopstateEvent(event) { + return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1; +}; + +/***/ }), + +/***/ "./node_modules/history/es/LocationUtils.js": +/*!**************************************************!*\ + !*** ./node_modules/history/es/LocationUtils.js ***! + \**************************************************/ +/*! exports provided: createLocation, locationsAreEqual */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLocation", function() { return createLocation; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "locationsAreEqual", function() { return locationsAreEqual; }); +/* harmony import */ var resolve_pathname__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! resolve-pathname */ "./node_modules/resolve-pathname/index.js"); +/* harmony import */ var value_equal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! value-equal */ "./node_modules/value-equal/index.js"); +/* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); +var _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; }; + + + + + +var createLocation = function createLocation(path, state, key, currentLocation) { + var location = void 0; + if (typeof path === 'string') { + // Two-arg form: push(path, state) + location = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_2__["parsePath"])(path); + location.state = state; + } else { + // One-arg form: push(location) + location = _extends({}, path); + + if (location.pathname === undefined) location.pathname = ''; + + if (location.search) { + if (location.search.charAt(0) !== '?') location.search = '?' + location.search; + } else { + location.search = ''; + } + + if (location.hash) { + if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash; + } else { + location.hash = ''; + } + + if (state !== undefined && location.state === undefined) location.state = state; + } + + try { + location.pathname = decodeURI(location.pathname); + } catch (e) { + if (e instanceof URIError) { + throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.'); + } else { + throw e; + } + } + + if (key) location.key = key; + + if (currentLocation) { + // Resolve incomplete/relative pathname relative to current location. + if (!location.pathname) { + location.pathname = currentLocation.pathname; + } else if (location.pathname.charAt(0) !== '/') { + location.pathname = Object(resolve_pathname__WEBPACK_IMPORTED_MODULE_0__["default"])(location.pathname, currentLocation.pathname); + } + } else { + // When there is no prior location and pathname is empty, set it to / + if (!location.pathname) { + location.pathname = '/'; + } + } + + return location; +}; + +var locationsAreEqual = function locationsAreEqual(a, b) { + return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && Object(value_equal__WEBPACK_IMPORTED_MODULE_1__["default"])(a.state, b.state); +}; + +/***/ }), + +/***/ "./node_modules/history/es/PathUtils.js": +/*!**********************************************!*\ + !*** ./node_modules/history/es/PathUtils.js ***! + \**********************************************/ +/*! exports provided: addLeadingSlash, stripLeadingSlash, hasBasename, stripBasename, stripTrailingSlash, parsePath, createPath */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addLeadingSlash", function() { return addLeadingSlash; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripLeadingSlash", function() { return stripLeadingSlash; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBasename", function() { return hasBasename; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripBasename", function() { return stripBasename; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripTrailingSlash", function() { return stripTrailingSlash; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parsePath", function() { return parsePath; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPath", function() { return createPath; }); +var addLeadingSlash = function addLeadingSlash(path) { + return path.charAt(0) === '/' ? path : '/' + path; +}; + +var stripLeadingSlash = function stripLeadingSlash(path) { + return path.charAt(0) === '/' ? path.substr(1) : path; +}; + +var hasBasename = function hasBasename(path, prefix) { + return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path); +}; + +var stripBasename = function stripBasename(path, prefix) { + return hasBasename(path, prefix) ? path.substr(prefix.length) : path; +}; + +var stripTrailingSlash = function stripTrailingSlash(path) { + return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path; +}; + +var parsePath = function parsePath(path) { + var pathname = path || '/'; + var search = ''; + var hash = ''; + + var hashIndex = pathname.indexOf('#'); + if (hashIndex !== -1) { + hash = pathname.substr(hashIndex); + pathname = pathname.substr(0, hashIndex); + } + + var searchIndex = pathname.indexOf('?'); + if (searchIndex !== -1) { + search = pathname.substr(searchIndex); + pathname = pathname.substr(0, searchIndex); + } + + return { + pathname: pathname, + search: search === '?' ? '' : search, + hash: hash === '#' ? '' : hash + }; +}; + +var createPath = function createPath(location) { + var pathname = location.pathname, + search = location.search, + hash = location.hash; + + + var path = pathname || '/'; + + if (search && search !== '?') path += search.charAt(0) === '?' ? search : '?' + search; + + if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : '#' + hash; + + return path; +}; + +/***/ }), + +/***/ "./node_modules/history/es/createBrowserHistory.js": +/*!*********************************************************!*\ + !*** ./node_modules/history/es/createBrowserHistory.js ***! + \*********************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); +/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); +/* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); +/* harmony import */ var _createTransitionManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/es/createTransitionManager.js"); +/* harmony import */ var _DOMUtils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/es/DOMUtils.js"); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _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; }; + + + + + + + + +var PopStateEvent = 'popstate'; +var HashChangeEvent = 'hashchange'; + +var getHistoryState = function getHistoryState() { + try { + return window.history.state || {}; + } catch (e) { + // IE 11 sometimes throws when accessing window.history.state + // See https://github.com/ReactTraining/history/pull/289 + return {}; + } +}; + +/** + * Creates a history object that uses the HTML5 history API including + * pushState, replaceState, and the popstate event. + */ +var createBrowserHistory = function createBrowserHistory() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + invariant__WEBPACK_IMPORTED_MODULE_1___default()(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["canUseDOM"], 'Browser history needs a DOM'); + + var globalHistory = window.history; + var canUseHistory = Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["supportsHistory"])(); + var needsHashChangeListener = !Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["supportsPopStateOnHashChange"])(); + + var _props$forceRefresh = props.forceRefresh, + forceRefresh = _props$forceRefresh === undefined ? false : _props$forceRefresh, + _props$getUserConfirm = props.getUserConfirmation, + getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils__WEBPACK_IMPORTED_MODULE_5__["getConfirmation"] : _props$getUserConfirm, + _props$keyLength = props.keyLength, + keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; + + var basename = props.basename ? Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripTrailingSlash"])(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"])(props.basename)) : ''; + + var getDOMLocation = function getDOMLocation(historyState) { + var _ref = historyState || {}, + key = _ref.key, + state = _ref.state; + + var _window$location = window.location, + pathname = _window$location.pathname, + search = _window$location.search, + hash = _window$location.hash; + + + var path = pathname + search + hash; + + warning__WEBPACK_IMPORTED_MODULE_0___default()(!basename || Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["hasBasename"])(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); + + if (basename) path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripBasename"])(path, basename); + + return Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, key); + }; + + var createKey = function createKey() { + return Math.random().toString(36).substr(2, keyLength); + }; + + var transitionManager = Object(_createTransitionManager__WEBPACK_IMPORTED_MODULE_4__["default"])(); + + var setState = function setState(nextState) { + _extends(history, nextState); + + history.length = globalHistory.length; + + transitionManager.notifyListeners(history.location, history.action); + }; + + var handlePopState = function handlePopState(event) { + // Ignore extraneous popstate events in WebKit. + if (Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["isExtraneousPopstateEvent"])(event)) return; + + handlePop(getDOMLocation(event.state)); + }; + + var handleHashChange = function handleHashChange() { + handlePop(getDOMLocation(getHistoryState())); + }; + + var forceNextPop = false; + + var handlePop = function handlePop(location) { + if (forceNextPop) { + forceNextPop = false; + setState(); + } else { + var action = 'POP'; + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ action: action, location: location }); + } else { + revertPop(location); + } + }); + } + }; + + var revertPop = function revertPop(fromLocation) { + var toLocation = history.location; + + // TODO: We could probably make this more reliable by + // keeping a list of keys we've seen in sessionStorage. + // Instead, we just default to 0 for keys we don't know. + + var toIndex = allKeys.indexOf(toLocation.key); + + if (toIndex === -1) toIndex = 0; + + var fromIndex = allKeys.indexOf(fromLocation.key); + + if (fromIndex === -1) fromIndex = 0; + + var delta = toIndex - fromIndex; + + if (delta) { + forceNextPop = true; + go(delta); + } + }; + + var initialLocation = getDOMLocation(getHistoryState()); + var allKeys = [initialLocation.key]; + + // Public interface + + var createHref = function createHref(location) { + return basename + Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location); + }; + + var push = function push(path, state) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'PUSH'; + var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var href = createHref(location); + var key = location.key, + state = location.state; + + + if (canUseHistory) { + globalHistory.pushState({ key: key, state: state }, null, href); + + if (forceRefresh) { + window.location.href = href; + } else { + var prevIndex = allKeys.indexOf(history.location.key); + var nextKeys = allKeys.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); + + nextKeys.push(location.key); + allKeys = nextKeys; + + setState({ action: action, location: location }); + } + } else { + warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history'); + + window.location.href = href; + } + }); + }; + + var replace = function replace(path, state) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'REPLACE'; + var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var href = createHref(location); + var key = location.key, + state = location.state; + + + if (canUseHistory) { + globalHistory.replaceState({ key: key, state: state }, null, href); + + if (forceRefresh) { + window.location.replace(href); + } else { + var prevIndex = allKeys.indexOf(history.location.key); + + if (prevIndex !== -1) allKeys[prevIndex] = location.key; + + setState({ action: action, location: location }); + } + } else { + warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history'); + + window.location.replace(href); + } + }); + }; + + var go = function go(n) { + globalHistory.go(n); + }; + + var goBack = function goBack() { + return go(-1); + }; + + var goForward = function goForward() { + return go(1); + }; + + var listenerCount = 0; + + var checkDOMListeners = function checkDOMListeners(delta) { + listenerCount += delta; + + if (listenerCount === 1) { + Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["addEventListener"])(window, PopStateEvent, handlePopState); + + if (needsHashChangeListener) Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["addEventListener"])(window, HashChangeEvent, handleHashChange); + } else if (listenerCount === 0) { + Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["removeEventListener"])(window, PopStateEvent, handlePopState); + + if (needsHashChangeListener) Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["removeEventListener"])(window, HashChangeEvent, handleHashChange); + } + }; + + var isBlocked = false; + + var block = function block() { + var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + var unblock = transitionManager.setPrompt(prompt); + + if (!isBlocked) { + checkDOMListeners(1); + isBlocked = true; + } + + return function () { + if (isBlocked) { + isBlocked = false; + checkDOMListeners(-1); + } + + return unblock(); + }; + }; + + var listen = function listen(listener) { + var unlisten = transitionManager.appendListener(listener); + checkDOMListeners(1); + + return function () { + checkDOMListeners(-1); + unlisten(); + }; + }; + + var history = { + length: globalHistory.length, + action: 'POP', + location: initialLocation, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + block: block, + listen: listen + }; + + return history; +}; + +/* harmony default export */ __webpack_exports__["default"] = (createBrowserHistory); + +/***/ }), + +/***/ "./node_modules/history/es/createHashHistory.js": +/*!******************************************************!*\ + !*** ./node_modules/history/es/createHashHistory.js ***! + \******************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! invariant */ "./node_modules/invariant/browser.js"); +/* harmony import */ var invariant__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(invariant__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); +/* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); +/* harmony import */ var _createTransitionManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/es/createTransitionManager.js"); +/* harmony import */ var _DOMUtils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DOMUtils */ "./node_modules/history/es/DOMUtils.js"); +var _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; }; + + + + + + + + +var HashChangeEvent = 'hashchange'; + +var HashPathCoders = { + hashbang: { + encodePath: function encodePath(path) { + return path.charAt(0) === '!' ? path : '!/' + Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripLeadingSlash"])(path); + }, + decodePath: function decodePath(path) { + return path.charAt(0) === '!' ? path.substr(1) : path; + } + }, + noslash: { + encodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripLeadingSlash"], + decodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"] + }, + slash: { + encodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"], + decodePath: _PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"] + } +}; + +var getHashPath = function getHashPath() { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + var href = window.location.href; + var hashIndex = href.indexOf('#'); + return hashIndex === -1 ? '' : href.substring(hashIndex + 1); +}; + +var pushHashPath = function pushHashPath(path) { + return window.location.hash = path; +}; + +var replaceHashPath = function replaceHashPath(path) { + var hashIndex = window.location.href.indexOf('#'); + + window.location.replace(window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + '#' + path); +}; + +var createHashHistory = function createHashHistory() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + invariant__WEBPACK_IMPORTED_MODULE_1___default()(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["canUseDOM"], 'Hash history needs a DOM'); + + var globalHistory = window.history; + var canGoWithoutReload = Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["supportsGoWithoutReloadUsingHash"])(); + + var _props$getUserConfirm = props.getUserConfirmation, + getUserConfirmation = _props$getUserConfirm === undefined ? _DOMUtils__WEBPACK_IMPORTED_MODULE_5__["getConfirmation"] : _props$getUserConfirm, + _props$hashType = props.hashType, + hashType = _props$hashType === undefined ? 'slash' : _props$hashType; + + var basename = props.basename ? Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripTrailingSlash"])(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["addLeadingSlash"])(props.basename)) : ''; + + var _HashPathCoders$hashT = HashPathCoders[hashType], + encodePath = _HashPathCoders$hashT.encodePath, + decodePath = _HashPathCoders$hashT.decodePath; + + + var getDOMLocation = function getDOMLocation() { + var path = decodePath(getHashPath()); + + warning__WEBPACK_IMPORTED_MODULE_0___default()(!basename || Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["hasBasename"])(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".'); + + if (basename) path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["stripBasename"])(path, basename); + + return Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path); + }; + + var transitionManager = Object(_createTransitionManager__WEBPACK_IMPORTED_MODULE_4__["default"])(); + + var setState = function setState(nextState) { + _extends(history, nextState); + + history.length = globalHistory.length; + + transitionManager.notifyListeners(history.location, history.action); + }; + + var forceNextPop = false; + var ignorePath = null; + + var handleHashChange = function handleHashChange() { + var path = getHashPath(); + var encodedPath = encodePath(path); + + if (path !== encodedPath) { + // Ensure we always have a properly-encoded hash. + replaceHashPath(encodedPath); + } else { + var location = getDOMLocation(); + var prevLocation = history.location; + + if (!forceNextPop && Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["locationsAreEqual"])(prevLocation, location)) return; // A hashchange doesn't always == location change. + + if (ignorePath === Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location)) return; // Ignore this change; we already setState in push/replace. + + ignorePath = null; + + handlePop(location); + } + }; + + var handlePop = function handlePop(location) { + if (forceNextPop) { + forceNextPop = false; + setState(); + } else { + var action = 'POP'; + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ action: action, location: location }); + } else { + revertPop(location); + } + }); + } + }; + + var revertPop = function revertPop(fromLocation) { + var toLocation = history.location; + + // TODO: We could probably make this more reliable by + // keeping a list of paths we've seen in sessionStorage. + // Instead, we just default to 0 for paths we don't know. + + var toIndex = allPaths.lastIndexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(toLocation)); + + if (toIndex === -1) toIndex = 0; + + var fromIndex = allPaths.lastIndexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(fromLocation)); + + if (fromIndex === -1) fromIndex = 0; + + var delta = toIndex - fromIndex; + + if (delta) { + forceNextPop = true; + go(delta); + } + }; + + // Ensure the hash is encoded properly before doing anything else. + var path = getHashPath(); + var encodedPath = encodePath(path); + + if (path !== encodedPath) replaceHashPath(encodedPath); + + var initialLocation = getDOMLocation(); + var allPaths = [Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(initialLocation)]; + + // Public interface + + var createHref = function createHref(location) { + return '#' + encodePath(basename + Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location)); + }; + + var push = function push(path, state) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Hash history cannot push state; it is ignored'); + + var action = 'PUSH'; + var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, undefined, undefined, history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location); + var encodedPath = encodePath(basename + path); + var hashChanged = getHashPath() !== encodedPath; + + if (hashChanged) { + // We cannot tell if a hashchange was caused by a PUSH, so we'd + // rather setState here and ignore the hashchange. The caveat here + // is that other hash histories in the page will consider it a POP. + ignorePath = path; + pushHashPath(encodedPath); + + var prevIndex = allPaths.lastIndexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(history.location)); + var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1); + + nextPaths.push(path); + allPaths = nextPaths; + + setState({ action: action, location: location }); + } else { + warning__WEBPACK_IMPORTED_MODULE_0___default()(false, 'Hash history cannot PUSH the same path; a new entry will not be added to the history stack'); + + setState(); + } + }); + }; + + var replace = function replace(path, state) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(state === undefined, 'Hash history cannot replace state; it is ignored'); + + var action = 'REPLACE'; + var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, undefined, undefined, history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var path = Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(location); + var encodedPath = encodePath(basename + path); + var hashChanged = getHashPath() !== encodedPath; + + if (hashChanged) { + // We cannot tell if a hashchange was caused by a REPLACE, so we'd + // rather setState here and ignore the hashchange. The caveat here + // is that other hash histories in the page will consider it a POP. + ignorePath = path; + replaceHashPath(encodedPath); + } + + var prevIndex = allPaths.indexOf(Object(_PathUtils__WEBPACK_IMPORTED_MODULE_3__["createPath"])(history.location)); + + if (prevIndex !== -1) allPaths[prevIndex] = path; + + setState({ action: action, location: location }); + }); + }; + + var go = function go(n) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(canGoWithoutReload, 'Hash history go(n) causes a full page reload in this browser'); + + globalHistory.go(n); + }; + + var goBack = function goBack() { + return go(-1); + }; + + var goForward = function goForward() { + return go(1); + }; + + var listenerCount = 0; + + var checkDOMListeners = function checkDOMListeners(delta) { + listenerCount += delta; + + if (listenerCount === 1) { + Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["addEventListener"])(window, HashChangeEvent, handleHashChange); + } else if (listenerCount === 0) { + Object(_DOMUtils__WEBPACK_IMPORTED_MODULE_5__["removeEventListener"])(window, HashChangeEvent, handleHashChange); + } + }; + + var isBlocked = false; + + var block = function block() { + var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + var unblock = transitionManager.setPrompt(prompt); + + if (!isBlocked) { + checkDOMListeners(1); + isBlocked = true; + } + + return function () { + if (isBlocked) { + isBlocked = false; + checkDOMListeners(-1); + } + + return unblock(); + }; + }; + + var listen = function listen(listener) { + var unlisten = transitionManager.appendListener(listener); + checkDOMListeners(1); + + return function () { + checkDOMListeners(-1); + unlisten(); + }; + }; + + var history = { + length: globalHistory.length, + action: 'POP', + location: initialLocation, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + block: block, + listen: listen + }; + + return history; +}; + +/* harmony default export */ __webpack_exports__["default"] = (createHashHistory); + +/***/ }), + +/***/ "./node_modules/history/es/createMemoryHistory.js": +/*!********************************************************!*\ + !*** ./node_modules/history/es/createMemoryHistory.js ***! + \********************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); +/* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); +/* harmony import */ var _createTransitionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./createTransitionManager */ "./node_modules/history/es/createTransitionManager.js"); +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _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; }; + + + + + + +var clamp = function clamp(n, lowerBound, upperBound) { + return Math.min(Math.max(n, lowerBound), upperBound); +}; + +/** + * Creates a history object that stores locations in memory. + */ +var createMemoryHistory = function createMemoryHistory() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var getUserConfirmation = props.getUserConfirmation, + _props$initialEntries = props.initialEntries, + initialEntries = _props$initialEntries === undefined ? ['/'] : _props$initialEntries, + _props$initialIndex = props.initialIndex, + initialIndex = _props$initialIndex === undefined ? 0 : _props$initialIndex, + _props$keyLength = props.keyLength, + keyLength = _props$keyLength === undefined ? 6 : _props$keyLength; + + + var transitionManager = Object(_createTransitionManager__WEBPACK_IMPORTED_MODULE_3__["default"])(); + + var setState = function setState(nextState) { + _extends(history, nextState); + + history.length = history.entries.length; + + transitionManager.notifyListeners(history.location, history.action); + }; + + var createKey = function createKey() { + return Math.random().toString(36).substr(2, keyLength); + }; + + var index = clamp(initialIndex, 0, initialEntries.length - 1); + var entries = initialEntries.map(function (entry) { + return typeof entry === 'string' ? Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(entry, undefined, createKey()) : Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(entry, undefined, entry.key || createKey()); + }); + + // Public interface + + var createHref = _PathUtils__WEBPACK_IMPORTED_MODULE_1__["createPath"]; + + var push = function push(path, state) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'PUSH'; + var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + var prevIndex = history.index; + var nextIndex = prevIndex + 1; + + var nextEntries = history.entries.slice(0); + if (nextEntries.length > nextIndex) { + nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location); + } else { + nextEntries.push(location); + } + + setState({ + action: action, + location: location, + index: nextIndex, + entries: nextEntries + }); + }); + }; + + var replace = function replace(path, state) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(!((typeof path === 'undefined' ? 'undefined' : _typeof(path)) === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored'); + + var action = 'REPLACE'; + var location = Object(_LocationUtils__WEBPACK_IMPORTED_MODULE_2__["createLocation"])(path, state, createKey(), history.location); + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (!ok) return; + + history.entries[history.index] = location; + + setState({ action: action, location: location }); + }); + }; + + var go = function go(n) { + var nextIndex = clamp(history.index + n, 0, history.entries.length - 1); + + var action = 'POP'; + var location = history.entries[nextIndex]; + + transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) { + if (ok) { + setState({ + action: action, + location: location, + index: nextIndex + }); + } else { + // Mimic the behavior of DOM histories by + // causing a render after a cancelled POP. + setState(); + } + }); + }; + + var goBack = function goBack() { + return go(-1); + }; + + var goForward = function goForward() { + return go(1); + }; + + var canGo = function canGo(n) { + var nextIndex = history.index + n; + return nextIndex >= 0 && nextIndex < history.entries.length; + }; + + var block = function block() { + var prompt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + return transitionManager.setPrompt(prompt); + }; + + var listen = function listen(listener) { + return transitionManager.appendListener(listener); + }; + + var history = { + length: entries.length, + action: 'POP', + location: entries[index], + index: index, + entries: entries, + createHref: createHref, + push: push, + replace: replace, + go: go, + goBack: goBack, + goForward: goForward, + canGo: canGo, + block: block, + listen: listen + }; + + return history; +}; + +/* harmony default export */ __webpack_exports__["default"] = (createMemoryHistory); + +/***/ }), + +/***/ "./node_modules/history/es/createTransitionManager.js": +/*!************************************************************!*\ + !*** ./node_modules/history/es/createTransitionManager.js ***! + \************************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! warning */ "./node_modules/warning/browser.js"); +/* harmony import */ var warning__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(warning__WEBPACK_IMPORTED_MODULE_0__); + + +var createTransitionManager = function createTransitionManager() { + var prompt = null; + + var setPrompt = function setPrompt(nextPrompt) { + warning__WEBPACK_IMPORTED_MODULE_0___default()(prompt == null, 'A history supports only one prompt at a time'); + + prompt = nextPrompt; + + return function () { + if (prompt === nextPrompt) prompt = null; + }; + }; + + var confirmTransitionTo = function confirmTransitionTo(location, action, getUserConfirmation, callback) { + // TODO: If another transition starts while we're still confirming + // the previous one, we may end up in a weird state. Figure out the + // best way to handle this. + if (prompt != null) { + var result = typeof prompt === 'function' ? prompt(location, action) : prompt; + + if (typeof result === 'string') { + if (typeof getUserConfirmation === 'function') { + getUserConfirmation(result, callback); + } else { + warning__WEBPACK_IMPORTED_MODULE_0___default()(false, 'A history needs a getUserConfirmation function in order to use a prompt message'); + + callback(true); + } + } else { + // Return false from a transition hook to cancel the transition. + callback(result !== false); + } + } else { + callback(true); + } + }; + + var listeners = []; + + var appendListener = function appendListener(fn) { + var isActive = true; + + var listener = function listener() { + if (isActive) fn.apply(undefined, arguments); + }; + + listeners.push(listener); + + return function () { + isActive = false; + listeners = listeners.filter(function (item) { + return item !== listener; + }); + }; + }; + + var notifyListeners = function notifyListeners() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + listeners.forEach(function (listener) { + return listener.apply(undefined, args); + }); + }; + + return { + setPrompt: setPrompt, + confirmTransitionTo: confirmTransitionTo, + appendListener: appendListener, + notifyListeners: notifyListeners + }; +}; + +/* harmony default export */ __webpack_exports__["default"] = (createTransitionManager); + +/***/ }), + +/***/ "./node_modules/history/es/index.js": +/*!******************************************!*\ + !*** ./node_modules/history/es/index.js ***! + \******************************************/ +/*! exports provided: createBrowserHistory, createHashHistory, createMemoryHistory, createLocation, locationsAreEqual, parsePath, createPath */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _createBrowserHistory__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./createBrowserHistory */ "./node_modules/history/es/createBrowserHistory.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createBrowserHistory", function() { return _createBrowserHistory__WEBPACK_IMPORTED_MODULE_0__["default"]; }); + +/* harmony import */ var _createHashHistory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./createHashHistory */ "./node_modules/history/es/createHashHistory.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createHashHistory", function() { return _createHashHistory__WEBPACK_IMPORTED_MODULE_1__["default"]; }); + +/* harmony import */ var _createMemoryHistory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./createMemoryHistory */ "./node_modules/history/es/createMemoryHistory.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createMemoryHistory", function() { return _createMemoryHistory__WEBPACK_IMPORTED_MODULE_2__["default"]; }); + +/* harmony import */ var _LocationUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./LocationUtils */ "./node_modules/history/es/LocationUtils.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createLocation", function() { return _LocationUtils__WEBPACK_IMPORTED_MODULE_3__["createLocation"]; }); + +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "locationsAreEqual", function() { return _LocationUtils__WEBPACK_IMPORTED_MODULE_3__["locationsAreEqual"]; }); + +/* harmony import */ var _PathUtils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./PathUtils */ "./node_modules/history/es/PathUtils.js"); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "parsePath", function() { return _PathUtils__WEBPACK_IMPORTED_MODULE_4__["parsePath"]; }); + +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "createPath", function() { return _PathUtils__WEBPACK_IMPORTED_MODULE_4__["createPath"]; }); + + + + + + + + + + + +/***/ }), + +/***/ "./node_modules/hoist-non-react-statics/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/hoist-non-react-statics/index.js ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * Copyright 2015, Yahoo! Inc. + * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +(function (global, factory) { + true ? module.exports = factory() : + undefined; +}(this, (function () { + 'use strict'; + + var REACT_STATICS = { + childContextTypes: true, + contextTypes: true, + defaultProps: true, + displayName: true, + getDefaultProps: true, + getDerivedStateFromProps: true, + mixins: true, + propTypes: true, + type: true + }; + + var KNOWN_STATICS = { + name: true, + length: true, + prototype: true, + caller: true, + callee: true, + arguments: true, + arity: true + }; + + var defineProperty = Object.defineProperty; + var getOwnPropertyNames = Object.getOwnPropertyNames; + var getOwnPropertySymbols = Object.getOwnPropertySymbols; + var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var getPrototypeOf = Object.getPrototypeOf; + var objectPrototype = getPrototypeOf && getPrototypeOf(Object); + + return function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { + if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components + + if (objectPrototype) { + var inheritedComponent = getPrototypeOf(sourceComponent); + if (inheritedComponent && inheritedComponent !== objectPrototype) { + hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); + } + } + + var keys = getOwnPropertyNames(sourceComponent); + + if (getOwnPropertySymbols) { + keys = keys.concat(getOwnPropertySymbols(sourceComponent)); + } + + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + if (!REACT_STATICS[key] && !KNOWN_STATICS[key] && (!blacklist || !blacklist[key])) { + var descriptor = getOwnPropertyDescriptor(sourceComponent, key); + try { // Avoid failures from read-only properties + defineProperty(targetComponent, key, descriptor); + } catch (e) {} + } + } + + return targetComponent; + } + + return targetComponent; + }; +}))); + + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), + +/***/ "./node_modules/immediate/lib/browser.js": +/*!***********************************************!*\ + !*** ./node_modules/immediate/lib/browser.js ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { +var Mutation = global.MutationObserver || global.WebKitMutationObserver; + +var scheduleDrain; + +{ + if (Mutation) { + var called = 0; + var observer = new Mutation(nextTick); + var element = global.document.createTextNode(''); + observer.observe(element, { + characterData: true + }); + scheduleDrain = function () { + element.data = (called = ++called % 2); + }; + } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') { + var channel = new global.MessageChannel(); + channel.port1.onmessage = nextTick; + scheduleDrain = function () { + channel.port2.postMessage(0); + }; + } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) { + scheduleDrain = function () { + + // Create a