diff --git a/bower.json b/bower.json index 3b10236..1de1b2d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "restful.js", - "version": "0.9.3", + "version": "0.9.4", "homepage": "https://github.com/marmelab/restful.js", "authors": [ "Robin Bressan " diff --git a/dist/es5/http/fetch.js b/dist/es5/http/fetch.js index 2492976..15af2e2 100644 --- a/dist/es5/http/fetch.js +++ b/dist/es5/http/fetch.js @@ -10,6 +10,27 @@ var _qs = require('qs'); var _qs2 = _interopRequireDefault(_qs); +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + +function parseBody(response) { + return response.text().then(function (text) { + if (!text || !text.length) { + (0, _warning2['default'])(response.status === 204, 'You should return a 204 status code with an empty body.'); + return null; + } + + (0, _warning2['default'])(response.status !== 204, 'You should return an empty body with a 204 status code.'); + + try { + return JSON.parse(text); + } catch (error) { + return text; + } + }); +} + exports['default'] = function (fetch) { return function (config) { var url = config.url; @@ -24,16 +45,38 @@ exports['default'] = function (fetch) { delete config.params; return fetch(!queryString.length ? url : url + '?' + queryString, config).then(function (response) { - return (response.status === 204 ? Promise.resolve(null) : response.json()).then(function (json) { + return parseBody(response).then(function (json) { var headers = {}; + var keys = response.headers.keys(); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; - response.headers.forEach(function (value, name) { - headers[name] = value; - }); + try { + for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + headers[key] = response.headers.get(key); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } var responsePayload = { data: json, headers: headers, + method: config.method ? config.method.toLowerCase() : 'get', statusCode: response.status }; diff --git a/dist/es5/model/decorator.js b/dist/es5/model/decorator.js index 00ed01a..91f3dab 100644 --- a/dist/es5/model/decorator.js +++ b/dist/es5/model/decorator.js @@ -45,9 +45,6 @@ function collection(endpoint) { getAll: endpoint.get, get: _bindHttpMethod('get'), head: _bindHttpMethod('head'), - one: function one(name, id) { - return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); - }, // eslint-disable-line no-use-before-define patch: _bindHttpMethod('patch'), put: _bindHttpMethod('put') }); diff --git a/dist/es5/model/response.js b/dist/es5/model/response.js index fc66abf..69bb943 100644 --- a/dist/es5/model/response.js +++ b/dist/es5/model/response.js @@ -16,6 +16,10 @@ var _utilSerialize = require('../util/serialize'); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); +var _warning = require('warning'); + +var _warning2 = _interopRequireDefault(_warning); + /* eslint-disable new-cap */ exports['default'] = function (response, decoratedEndpoint) { @@ -35,9 +39,7 @@ exports['default'] = function (response, decoratedEndpoint) { } if (_immutable.List.isList(data)) { - if (decoratedEndpoint.all) { - throw new Error('Unexpected array as response, you should use all method for that'); - } + (0, _warning2['default'])(response.get('method') !== 'get' || !decoratedEndpoint.all, 'Unexpected array as response, you should use all method for that'); return (0, _utilSerialize2['default'])(data.map(function (datum) { var id = datum.get(identifier); @@ -45,9 +47,7 @@ exports['default'] = function (response, decoratedEndpoint) { })); } - if (!decoratedEndpoint.all) { - throw new Error('Expected array as response, you should use one method for that'); - } + (0, _warning2['default'])(response.get('method') !== 'get' || decoratedEndpoint.all, 'Expected array as response, you should use one method for that'); return (0, _entity2['default'])((0, _utilSerialize2['default'])(data), decoratedEndpoint); }, diff --git a/dist/restful.js b/dist/restful.js index f69377d..31416c4 100644 --- a/dist/restful.js +++ b/dist/restful.js @@ -2,7 +2,7 @@ if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) - define(factory); + define([], factory); else if(typeof exports === 'object') exports["restful"] = factory(); else @@ -81,7 +81,7 @@ return /******/ (function(modules) { // webpackBootstrap function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _modelEndpoint = __webpack_require__(4); + var _modelEndpoint = __webpack_require__(2); var _modelEndpoint2 = _interopRequireDefault(_modelEndpoint); @@ -93,13 +93,13 @@ return /******/ (function(modules) { // webpackBootstrap var _serviceHttp2 = _interopRequireDefault(_serviceHttp); - var _modelDecorator = __webpack_require__(2); + var _modelDecorator = __webpack_require__(15); - var _httpRequest = __webpack_require__(15); + var _httpRequest = __webpack_require__(16); var _httpRequest2 = _interopRequireDefault(_httpRequest); - var _modelScope = __webpack_require__(16); + var _modelScope = __webpack_require__(17); var _modelScope2 = _interopRequireDefault(_modelScope); @@ -138,109 +138,6 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - Object.defineProperty(exports, '__esModule', { - value: true - }); - exports.custom = custom; - exports.collection = collection; - exports.member = member; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _objectAssign = __webpack_require__(3); - - var _objectAssign2 = _interopRequireDefault(_objectAssign); - - function custom(endpoint) { - return function (name) { - var relative = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; - - if (relative) { - return member(endpoint['new'](endpoint.url() + '/' + name)); // eslint-disable-line no-use-before-define - } - - return member(endpoint['new'](name)); // eslint-disable-line no-use-before-define - }; - } - - function collection(endpoint) { - function _bindHttpMethod(method) { - return function () { - var _member; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var id = args.shift(); - return (_member = member(endpoint['new'](endpoint.url() + '/' + id)))[method].apply(_member, args); // eslint-disable-line no-use-before-define - }; - } - - return (0, _objectAssign2['default'])(endpoint, { - custom: custom(endpoint), - 'delete': _bindHttpMethod('delete'), - getAll: endpoint.get, - get: _bindHttpMethod('get'), - head: _bindHttpMethod('head'), - one: function one(name, id) { - return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); - }, // eslint-disable-line no-use-before-define - patch: _bindHttpMethod('patch'), - put: _bindHttpMethod('put') - }); - } - - function member(endpoint) { - return (0, _objectAssign2['default'])(endpoint, { - all: function all(name) { - return collection(endpoint['new'](endpoint.url() + '/' + name)); - }, - custom: custom(endpoint), - one: function one(name, id) { - return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); - } - }); - } - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - 'use strict'; - - function ToObject(val) { - if (val == null) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); - } - - module.exports = Object.assign || function (target, source) { - var from; - var keys; - var to = ToObject(target); - - for (var s = 1; s < arguments.length; s++) { - from = arguments[s]; - keys = Object.keys(Object(from)); - - for (var i = 0; i < keys.length; i++) { - to[keys[i]] = from[keys[i]]; - } - } - - return to; - }; - - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - Object.defineProperty(exports, '__esModule', { value: true }); @@ -251,13 +148,13 @@ return /******/ (function(modules) { // webpackBootstrap var _objectAssign2 = _interopRequireDefault(_objectAssign); - var _response = __webpack_require__(5); + var _response = __webpack_require__(4); var _response2 = _interopRequireDefault(_response); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); - var _utilSerialize = __webpack_require__(8); + var _utilSerialize = __webpack_require__(7); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); @@ -390,7 +287,39 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 5 */ +/* 3 */ +/***/ function(module, exports) { + + 'use strict'; + + function ToObject(val) { + if (val == null) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); + } + + module.exports = Object.assign || function (target, source) { + var from; + var keys; + var to = ToObject(target); + + for (var s = 1; s < arguments.length; s++) { + from = arguments[s]; + keys = Object.keys(Object(from)); + + for (var i = 0; i < keys.length; i++) { + to[keys[i]] = from[keys[i]]; + } + } + + return to; + }; + + +/***/ }, +/* 4 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -401,16 +330,20 @@ return /******/ (function(modules) { // webpackBootstrap function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _entity = __webpack_require__(6); + var _entity = __webpack_require__(5); var _entity2 = _interopRequireDefault(_entity); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); - var _utilSerialize = __webpack_require__(8); + var _utilSerialize = __webpack_require__(7); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); + var _warning = __webpack_require__(8); + + var _warning2 = _interopRequireDefault(_warning); + /* eslint-disable new-cap */ exports['default'] = function (response, decoratedEndpoint) { @@ -430,9 +363,7 @@ return /******/ (function(modules) { // webpackBootstrap } if (_immutable.List.isList(data)) { - if (decoratedEndpoint.all) { - throw new Error('Unexpected array as response, you should use all method for that'); - } + (0, _warning2['default'])(response.get('method') !== 'get' || !decoratedEndpoint.all, 'Unexpected array as response, you should use all method for that'); return (0, _utilSerialize2['default'])(data.map(function (datum) { var id = datum.get(identifier); @@ -440,9 +371,7 @@ return /******/ (function(modules) { // webpackBootstrap })); } - if (!decoratedEndpoint.all) { - throw new Error('Expected array as response, you should use one method for that'); - } + (0, _warning2['default'])(response.get('method') !== 'get' || decoratedEndpoint.all, 'Expected array as response, you should use one method for that'); return (0, _entity2['default'])((0, _utilSerialize2['default'])(data), decoratedEndpoint); }, @@ -455,7 +384,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 6 */ +/* 5 */ /***/ function(module, exports) { "use strict"; @@ -490,7 +419,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports["default"]; /***/ }, -/* 7 */ +/* 6 */ /***/ function(module, exports, __webpack_require__) { /** @@ -501,10 +430,11 @@ return /******/ (function(modules) { // webpackBootstrap * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ + (function (global, factory) { - true ? module.exports = factory() : + true ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - global.Immutable = factory() + global.Immutable = factory(); }(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice; function createClass(ctor, superClass) { @@ -514,6 +444,66 @@ return /******/ (function(modules) { // webpackBootstrap ctor.prototype.constructor = ctor; } + function Iterable(value) { + return isIterable(value) ? value : Seq(value); + } + + + createClass(KeyedIterable, Iterable); + function KeyedIterable(value) { + return isKeyed(value) ? value : KeyedSeq(value); + } + + + createClass(IndexedIterable, Iterable); + function IndexedIterable(value) { + return isIndexed(value) ? value : IndexedSeq(value); + } + + + createClass(SetIterable, Iterable); + function SetIterable(value) { + return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); + } + + + + function isIterable(maybeIterable) { + return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); + } + + function isKeyed(maybeKeyed) { + return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); + } + + function isIndexed(maybeIndexed) { + return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); + } + + function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + } + + function isOrdered(maybeOrdered) { + return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); + } + + Iterable.isIterable = isIterable; + Iterable.isKeyed = isKeyed; + Iterable.isIndexed = isIndexed; + Iterable.isAssociative = isAssociative; + Iterable.isOrdered = isOrdered; + + Iterable.Keyed = KeyedIterable; + Iterable.Indexed = IndexedIterable; + Iterable.Set = SetIterable; + + + var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; + var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; + var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; + var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; + // Used for setting prototype methods that IE8 chokes on. var DELETE = 'delete'; @@ -564,18 +554,18 @@ return /******/ (function(modules) { // webpackBootstrap function wrapIndex(iter, index) { // This implements "is array index" which the ECMAString spec defines as: + // // A String property name P is an array index if and only if // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal // to 2^32−1. - // However note that we're currently calling ToNumber() instead of ToUint32() - // which should be improved in the future, as floating point numbers should - // not be accepted as an array index. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects if (typeof index !== 'number') { - var numIndex = +index; - if ('' + numIndex !== index) { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { return NaN; } - index = numIndex; + index = uint32Index; } return index < 0 ? ensureSize(iter) + index : index; } @@ -607,116 +597,56 @@ return /******/ (function(modules) { // webpackBootstrap Math.min(size, index); } - function Iterable(value) { - return isIterable(value) ? value : Seq(value); - } + /* global Symbol */ + var ITERATE_KEYS = 0; + var ITERATE_VALUES = 1; + var ITERATE_ENTRIES = 2; - createClass(KeyedIterable, Iterable); - function KeyedIterable(value) { - return isKeyed(value) ? value : KeyedSeq(value); - } + var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; + var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - createClass(IndexedIterable, Iterable); - function IndexedIterable(value) { - return isIndexed(value) ? value : IndexedSeq(value); + + function Iterator(next) { + this.next = next; } + Iterator.prototype.toString = function() { + return '[Iterator]'; + }; - createClass(SetIterable, Iterable); - function SetIterable(value) { - return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); - } + Iterator.KEYS = ITERATE_KEYS; + Iterator.VALUES = ITERATE_VALUES; + Iterator.ENTRIES = ITERATE_ENTRIES; + Iterator.prototype.inspect = + Iterator.prototype.toSource = function () { return this.toString(); } + Iterator.prototype[ITERATOR_SYMBOL] = function () { + return this; + }; - function isIterable(maybeIterable) { - return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); - } - function isKeyed(maybeKeyed) { - return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); + function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { + value: value, done: false + }); + return iteratorResult; } - function isIndexed(maybeIndexed) { - return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); + function iteratorDone() { + return { value: undefined, done: true }; } - function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + function hasIterator(maybeIterable) { + return !!getIteratorFn(maybeIterable); } - function isOrdered(maybeOrdered) { - return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); - } - - Iterable.isIterable = isIterable; - Iterable.isKeyed = isKeyed; - Iterable.isIndexed = isIndexed; - Iterable.isAssociative = isAssociative; - Iterable.isOrdered = isOrdered; - - Iterable.Keyed = KeyedIterable; - Iterable.Indexed = IndexedIterable; - Iterable.Set = SetIterable; - - - var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; - var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; - var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; - var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; - - /* global Symbol */ - - var ITERATE_KEYS = 0; - var ITERATE_VALUES = 1; - var ITERATE_ENTRIES = 2; - - var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - - var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - - - function src_Iterator__Iterator(next) { - this.next = next; - } - - src_Iterator__Iterator.prototype.toString = function() { - return '[Iterator]'; - }; - - - src_Iterator__Iterator.KEYS = ITERATE_KEYS; - src_Iterator__Iterator.VALUES = ITERATE_VALUES; - src_Iterator__Iterator.ENTRIES = ITERATE_ENTRIES; - - src_Iterator__Iterator.prototype.inspect = - src_Iterator__Iterator.prototype.toSource = function () { return this.toString(); } - src_Iterator__Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; - }; - - - function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { - value: value, done: false - }); - return iteratorResult; - } - - function iteratorDone() { - return { value: undefined, done: true }; - } - - function hasIterator(maybeIterable) { - return !!getIteratorFn(maybeIterable); - } - - function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; + function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; } function getIterator(iterable) { @@ -852,8 +782,6 @@ return /******/ (function(modules) { // webpackBootstrap - // #pragma Root Sequences - createClass(ArraySeq, IndexedSeq); function ArraySeq(array) { this._array = array; @@ -879,7 +807,7 @@ return /******/ (function(modules) { // webpackBootstrap var array = this._array; var maxIndex = array.length - 1; var ii = 0; - return new src_Iterator__Iterator(function() + return new Iterator(function() {return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])} @@ -925,7 +853,7 @@ return /******/ (function(modules) { // webpackBootstrap var keys = this._keys; var maxIndex = keys.length - 1; var ii = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var key = keys[reverse ? maxIndex - ii : ii]; return ii++ > maxIndex ? iteratorDone() : @@ -967,10 +895,10 @@ return /******/ (function(modules) { // webpackBootstrap var iterable = this._iterable; var iterator = getIterator(iterable); if (!isIterator(iterator)) { - return new src_Iterator__Iterator(iteratorDone); + return new Iterator(iteratorDone); } var iterations = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var step = iterator.next(); return step.done ? step : iteratorValue(type, iterations++, step.value); }); @@ -1014,7 +942,7 @@ return /******/ (function(modules) { // webpackBootstrap var iterator = this._iterator; var cache = this._iteratorCache; var iterations = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { if (iterations >= cache.length) { var step = iterator.next(); if (step.done) { @@ -1107,7 +1035,7 @@ return /******/ (function(modules) { // webpackBootstrap if (cache) { var maxIndex = cache.length - 1; var ii = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var entry = cache[reverse ? maxIndex - ii : ii]; return ii++ > maxIndex ? iteratorDone() : @@ -1117,22 +1045,35 @@ return /******/ (function(modules) { // webpackBootstrap return seq.__iteratorUncached(type, reverse); } - createClass(Collection, Iterable); - function Collection() { - throw TypeError('Abstract'); - } - - - createClass(KeyedCollection, Collection);function KeyedCollection() {} - - createClass(IndexedCollection, Collection);function IndexedCollection() {} + function fromJS(json, converter) { + return converter ? + fromJSWith(converter, json, '', {'': json}) : + fromJSDefault(json); + } - createClass(SetCollection, Collection);function SetCollection() {} + function fromJSWith(converter, json, key, parentJSON) { + if (Array.isArray(json)) { + return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + } + if (isPlainObj(json)) { + return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + } + return json; + } + function fromJSDefault(json) { + if (Array.isArray(json)) { + return IndexedSeq(json).map(fromJSDefault).toList(); + } + if (isPlainObj(json)) { + return KeyedSeq(json).map(fromJSDefault).toMap(); + } + return json; + } - Collection.Keyed = KeyedCollection; - Collection.Indexed = IndexedCollection; - Collection.Set = SetCollection; + function isPlainObj(value) { + return value && (value.constructor === Object || value.constructor === undefined); + } /** * An extension of the "same-value" algorithm as [described for use by ES6 Map @@ -1214,1266 +1155,873 @@ return /******/ (function(modules) { // webpackBootstrap return false; } - function fromJS(json, converter) { - return converter ? - fromJSWith(converter, json, '', {'': json}) : - fromJSDefault(json); - } - - function fromJSWith(converter, json, key, parentJSON) { - if (Array.isArray(json)) { - return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); - } - if (isPlainObj(json)) { - return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + function deepEqual(a, b) { + if (a === b) { + return true; } - return json; - } - function fromJSDefault(json) { - if (Array.isArray(json)) { - return IndexedSeq(json).map(fromJSDefault).toList(); + if ( + !isIterable(b) || + a.size !== undefined && b.size !== undefined && a.size !== b.size || + a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; } - if (isPlainObj(json)) { - return KeyedSeq(json).map(fromJSDefault).toMap(); + + if (a.size === 0 && b.size === 0) { + return true; } - return json; - } - function isPlainObj(value) { - return value && (value.constructor === Object || value.constructor === undefined); - } + var notAssociative = !isAssociative(a); - var src_Math__imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? - Math.imul : - function imul(a, b) { - a = a | 0; // int - b = b | 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int - }; + if (isOrdered(a)) { + var entries = a.entries(); + return b.every(function(v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done; + } - // v8 has an optimization for storing 31-bit signed numbers. - // Values which have either 00 or 11 as the high order bits qualify. - // This function drops the highest order bit in a signed number, maintaining - // the sign bit. - function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF); - } + var flipped = false; - function hash(o) { - if (o === false || o === null || o === undefined) { - return 0; - } - if (typeof o.valueOf === 'function') { - o = o.valueOf(); - if (o === false || o === null || o === undefined) { - return 0; - } - } - if (o === true) { - return 1; - } - var type = typeof o; - if (type === 'number') { - var h = o | 0; - if (h !== o) { - h ^= o * 0xFFFFFFFF; - } - while (o > 0xFFFFFFFF) { - o /= 0xFFFFFFFF; - h ^= o; + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; } - return smi(h); - } - if (type === 'string') { - return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o); } - if (typeof o.hashCode === 'function') { - return o.hashCode(); - } - return hashJSObj(o); - } - function cachedHashString(string) { - var hash = stringHashCache[string]; - if (hash === undefined) { - hash = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; + var allEqual = true; + var bSize = b.__iterate(function(v, k) { + if (notAssociative ? !a.has(v) : + flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) { + allEqual = false; + return false; } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hash; - } - return hash; - } + }); - // http://jsperf.com/hashing-strings - function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hash = 0; - for (var ii = 0; ii < string.length; ii++) { - hash = 31 * hash + string.charCodeAt(ii) | 0; - } - return smi(hash); + return allEqual && a.size === bSize; } - function hashJSObj(obj) { - var hash; - if (usingWeakMap) { - hash = weakMap.get(obj); - if (hash !== undefined) { - return hash; + createClass(Repeat, IndexedSeq); + + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + return EMPTY_REPEAT; + } + EMPTY_REPEAT = this; } } - hash = obj[UID_HASH_KEY]; - if (hash !== undefined) { - return hash; - } - - if (!canDefineProperty) { - hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hash !== undefined) { - return hash; + Repeat.prototype.toString = function() { + if (this.size === 0) { + return 'Repeat []'; } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; - hash = getIENodeHash(obj); - if (hash !== undefined) { - return hash; - } - } + Repeat.prototype.get = function(index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; - hash = ++objHashUID; - if (objHashUID & 0x40000000) { - objHashUID = 0; - } + Repeat.prototype.includes = function(searchValue) { + return is(this._value, searchValue); + }; - if (usingWeakMap) { - weakMap.set(obj, hash); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - 'enumerable': false, - 'configurable': false, - 'writable': false, - 'value': hash - }); - } else if (obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function() { - return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments); - }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hash; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hash; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } + Repeat.prototype.slice = function(begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) ? this : + new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size)); + }; - return hash; - } + Repeat.prototype.reverse = function() { + return this; + }; - // Get references to ES5 object methods. - var isExtensible = Object.isExtensible; + Repeat.prototype.indexOf = function(searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; - // True if Object.defineProperty works as expected. IE8 fails this test. - var canDefineProperty = (function() { - try { - Object.defineProperty({}, '@', {}); - return true; - } catch (e) { - return false; - } - }()); + Repeat.prototype.lastIndexOf = function(searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; - // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it - // and avoid memory leaks from the IE cloneNode bug. - function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; + Repeat.prototype.__iterate = function(fn, reverse) { + for (var ii = 0; ii < this.size; ii++) { + if (fn(this._value, ii, this) === false) { + return ii + 1; + } } - } - } + return ii; + }; - // If possible, use a WeakMap. - var usingWeakMap = typeof WeakMap === 'function'; - var weakMap; - if (usingWeakMap) { - weakMap = new WeakMap(); - } + Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this; + var ii = 0; + return new Iterator(function() + {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()} + ); + }; - var objHashUID = 0; + Repeat.prototype.equals = function(other) { + return other instanceof Repeat ? + is(this._value, other._value) : + deepEqual(other); + }; - var UID_HASH_KEY = '__immutablehash__'; - if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); - } - var STRING_HASH_CACHE_MIN_STRLEN = 16; - var STRING_HASH_CACHE_MAX_SIZE = 255; - var STRING_HASH_CACHE_SIZE = 0; - var stringHashCache = {}; + var EMPTY_REPEAT; function invariant(condition, error) { if (!condition) throw new Error(error); } - function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); - } + createClass(Range, IndexedSeq); - createClass(ToKeyedSequence, KeyedSeq); - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; + function Range(start, end, step) { + if (!(this instanceof Range)) { + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + start = start || 0; + if (end === undefined) { + end = Infinity; + } + step = step === undefined ? 1 : Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + return EMPTY_RANGE; + } + EMPTY_RANGE = this; + } } - ToKeyedSequence.prototype.get = function(key, notSetValue) { - return this._iter.get(key, notSetValue); + Range.prototype.toString = function() { + if (this.size === 0) { + return 'Range []'; + } + return 'Range [ ' + + this._start + '...' + this._end + + (this._step > 1 ? ' by ' + this._step : '') + + ' ]'; }; - ToKeyedSequence.prototype.has = function(key) { - return this._iter.has(key); + Range.prototype.get = function(index, notSetValue) { + return this.has(index) ? + this._start + wrapIndex(this, index) * this._step : + notSetValue; }; - ToKeyedSequence.prototype.valueSeq = function() { - return this._iter.valueSeq(); + Range.prototype.includes = function(searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex); }; - ToKeyedSequence.prototype.reverse = function() {var this$0 = this; - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()}; + Range.prototype.slice = function(begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; } - return reversedSequence; + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range(this.get(begin, this._end), this.get(end, this._end), this._step); }; - ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this; - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)}; + Range.prototype.indexOf = function(searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index + } } - return mappedSequence; + return -1; }; - ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var ii; - return this._iter.__iterate( - this._useKeys ? - function(v, k) {return fn(v, k, this$0)} : - ((ii = reverse ? resolveSize(this) : 0), - function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}), - reverse - ); + Range.prototype.lastIndexOf = function(searchValue) { + return this.indexOf(searchValue); }; - ToKeyedSequence.prototype.__iterator = function(type, reverse) { - if (this._useKeys) { - return this._iter.__iterator(type, reverse); + Range.prototype.__iterate = function(fn, reverse) { + var maxIndex = this.size - 1; + var step = this._step; + var value = reverse ? this._start + maxIndex * step : this._start; + for (var ii = 0; ii <= maxIndex; ii++) { + if (fn(value, ii, this) === false) { + return ii + 1; + } + value += reverse ? -step : step; } - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var ii = reverse ? resolveSize(this) : 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, reverse ? --ii : ii++, step.value, step); - }); + return ii; }; - ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; - - - createClass(ToIndexedSequence, IndexedSeq); - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - ToIndexedSequence.prototype.includes = function(value) { - return this._iter.includes(value); - }; - - ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var iterations = 0; - return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse); + Range.prototype.__iterator = function(type, reverse) { + var maxIndex = this.size - 1; + var step = this._step; + var value = reverse ? this._start + maxIndex * step : this._start; + var ii = 0; + return new Iterator(function() { + var v = value; + value += reverse ? -step : step; + return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v); + }); }; - ToIndexedSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, iterations++, step.value, step) - }); + Range.prototype.equals = function(other) { + return other instanceof Range ? + this._start === other._start && + this._end === other._end && + this._step === other._step : + deepEqual(this, other); }; + var EMPTY_RANGE; - createClass(ToSetSequence, SetSeq); - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; + createClass(Collection, Iterable); + function Collection() { + throw TypeError('Abstract'); } - ToSetSequence.prototype.has = function(key) { - return this._iter.includes(key); - }; - - ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse); - }; - - ToSetSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, step.value, step.value, step); - }); - }; + createClass(KeyedCollection, Collection);function KeyedCollection() {} + createClass(IndexedCollection, Collection);function IndexedCollection() {} - createClass(FromEntriesSequence, KeyedSeq); - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; - } + createClass(SetCollection, Collection);function SetCollection() {} - FromEntriesSequence.prototype.entrySeq = function() { - return this._iter.toSeq(); - }; - FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._iter.__iterate(function(entry ) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedIterable = isIterable(entry); - return fn( - indexedIterable ? entry.get(1) : entry[1], - indexedIterable ? entry.get(0) : entry[0], - this$0 - ); - } - }, reverse); - }; + Collection.Keyed = KeyedCollection; + Collection.Indexed = IndexedCollection; + Collection.Set = SetCollection; - FromEntriesSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new src_Iterator__Iterator(function() { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedIterable = isIterable(entry); - return iteratorValue( - type, - indexedIterable ? entry.get(0) : entry[0], - indexedIterable ? entry.get(1) : entry[1], - step - ); - } - } - }); + var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? + Math.imul : + function imul(a, b) { + a = a | 0; // int + b = b | 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int }; + // v8 has an optimization for storing 31-bit signed numbers. + // Values which have either 00 or 11 as the high order bits qualify. + // This function drops the highest order bit in a signed number, maintaining + // the sign bit. + function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF); + } - ToIndexedSequence.prototype.cacheResult = - ToKeyedSequence.prototype.cacheResult = - ToSetSequence.prototype.cacheResult = - FromEntriesSequence.prototype.cacheResult = - cacheResultThrough; - - - function flipFactory(iterable) { - var flipSequence = makeSequence(iterable); - flipSequence._iter = iterable; - flipSequence.size = iterable.size; - flipSequence.flip = function() {return iterable}; - flipSequence.reverse = function () { - var reversedSequence = iterable.reverse.apply(this); // super.reverse() - reversedSequence.flip = function() {return iterable.reverse()}; - return reversedSequence; - }; - flipSequence.has = function(key ) {return iterable.includes(key)}; - flipSequence.includes = function(key ) {return iterable.has(key)}; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse); + function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; } - flipSequence.__iteratorUncached = function(type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = iterable.__iterator(type, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; - } - return step; - }); + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; } - return iterable.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); } - return flipSequence; + if (o === true) { + return 1; + } + var type = typeof o; + if (type === 'number') { + var h = o | 0; + if (h !== o) { + h ^= o * 0xFFFFFFFF; + } + while (o > 0xFFFFFFFF) { + o /= 0xFFFFFFFF; + h ^= o; + } + return smi(h); + } + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o); + } + if (typeof o.hashCode === 'function') { + return o.hashCode(); + } + if (type === 'object') { + return hashJSObj(o); + } + if (typeof o.toString === 'function') { + return hashString(o.toString()); + } + throw new Error('Value type ' + type + ' cannot be hashed.'); } - - function mapFactory(iterable, mapper, context) { - var mappedSequence = makeSequence(iterable); - mappedSequence.size = iterable.size; - mappedSequence.has = function(key ) {return iterable.has(key)}; - mappedSequence.get = function(key, notSetValue) { - var v = iterable.get(key, NOT_SET); - return v === NOT_SET ? - notSetValue : - mapper.call(context, v, key, iterable); - }; - mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - return iterable.__iterate( - function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false}, - reverse - ); + function cachedHashString(string) { + var hash = stringHashCache[string]; + if (hash === undefined) { + hash = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hash; } - mappedSequence.__iteratorUncached = function (type, reverse) { - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, iterable), - step - ); - }); + return hash; + } + + // http://jsperf.com/hashing-strings + function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hash = 0; + for (var ii = 0; ii < string.length; ii++) { + hash = 31 * hash + string.charCodeAt(ii) | 0; } - return mappedSequence; + return smi(hash); } + function hashJSObj(obj) { + var hash; + if (usingWeakMap) { + hash = weakMap.get(obj); + if (hash !== undefined) { + return hash; + } + } - function reverseFactory(iterable, useKeys) { - var reversedSequence = makeSequence(iterable); - reversedSequence._iter = iterable; - reversedSequence.size = iterable.size; - reversedSequence.reverse = function() {return iterable}; - if (iterable.flip) { - reversedSequence.flip = function () { - var flipSequence = flipFactory(iterable); - flipSequence.reverse = function() {return iterable.flip()}; - return flipSequence; + hash = obj[UID_HASH_KEY]; + if (hash !== undefined) { + return hash; + } + + if (!canDefineProperty) { + hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hash !== undefined) { + return hash; + } + + hash = getIENodeHash(obj); + if (hash !== undefined) { + return hash; + } + } + + hash = ++objHashUID; + if (objHashUID & 0x40000000) { + objHashUID = 0; + } + + if (usingWeakMap) { + weakMap.set(obj, hash); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + 'enumerable': false, + 'configurable': false, + 'writable': false, + 'value': hash + }); + } else if (obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function() { + return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments); }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hash; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hash; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); } - reversedSequence.get = function(key, notSetValue) - {return iterable.get(useKeys ? key : -1 - key, notSetValue)}; - reversedSequence.has = function(key ) - {return iterable.has(useKeys ? key : -1 - key)}; - reversedSequence.includes = function(value ) {return iterable.includes(value)}; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function (fn, reverse) {var this$0 = this; - return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse); - }; - reversedSequence.__iterator = - function(type, reverse) {return iterable.__iterator(type, !reverse)}; - return reversedSequence; + + return hash; } + // Get references to ES5 object methods. + var isExtensible = Object.isExtensible; - function filterFactory(iterable, predicate, context, useKeys) { - var filterSequence = makeSequence(iterable); - if (useKeys) { - filterSequence.has = function(key ) { - var v = iterable.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, iterable); - }; - filterSequence.get = function(key, notSetValue) { - var v = iterable.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, iterable) ? - v : notSetValue; - }; + // True if Object.defineProperty works as expected. IE8 fails this test. + var canDefineProperty = (function() { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; } - filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - var iterations = 0; - iterable.__iterate(function(v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0); - } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function (type, reverse) { - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, iterable)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); - } - } - }); + }()); + + // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it + // and avoid memory leaks from the IE cloneNode bug. + function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } } - return filterSequence; } + // If possible, use a WeakMap. + var usingWeakMap = typeof WeakMap === 'function'; + var weakMap; + if (usingWeakMap) { + weakMap = new WeakMap(); + } - function countByFactory(iterable, grouper, context) { - var groups = src_Map__Map().asMutable(); - iterable.__iterate(function(v, k) { - groups.update( - grouper.call(context, v, k, iterable), - 0, - function(a ) {return a + 1} - ); - }); - return groups.asImmutable(); + var objHashUID = 0; + + var UID_HASH_KEY = '__immutablehash__'; + if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); } + var STRING_HASH_CACHE_MIN_STRLEN = 16; + var STRING_HASH_CACHE_MAX_SIZE = 255; + var STRING_HASH_CACHE_SIZE = 0; + var stringHashCache = {}; - function groupByFactory(iterable, grouper, context) { - var isKeyedIter = isKeyed(iterable); - var groups = (isOrdered(iterable) ? OrderedMap() : src_Map__Map()).asMutable(); - iterable.__iterate(function(v, k) { - groups.update( - grouper.call(context, v, k, iterable), - function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)} - ); - }); - var coerce = iterableClass(iterable); - return groups.map(function(arr ) {return reify(iterable, coerce(arr))}); + function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); } + createClass(Map, KeyedCollection); - function sliceFactory(iterable, begin, end, useKeys) { - var originalSize = iterable.size; + // @pragma Construction - // Sanitize begin & end using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - if (begin !== undefined) { - begin = begin | 0; - } - if (end !== undefined) { - end = end | 0; + function Map(value) { + return value === null || value === undefined ? emptyMap() : + isMap(value) && !isOrdered(value) ? value : + emptyMap().withMutations(function(map ) { + var iter = KeyedIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v, k) {return map.set(k, v)}); + }); } - if (wholeSlice(begin, end, originalSize)) { - return iterable; - } + Map.prototype.toString = function() { + return this.__toString('Map {', '}'); + }; - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); + // @pragma Access - // begin or end will be NaN if they were provided as negative numbers and - // this iterable's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { - return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys); - } + Map.prototype.get = function(k, notSetValue) { + return this._root ? + this._root.get(0, undefined, k, notSetValue) : + notSetValue; + }; - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; - } + // @pragma Modification - var sliceSeq = makeSequence(iterable); + Map.prototype.set = function(k, v) { + return updateMap(this, k, v); + }; - // If iterable.size is undefined, the size of the realized sliceSeq is - // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined; + Map.prototype.setIn = function(keyPath, v) { + return this.updateIn(keyPath, NOT_SET, function() {return v}); + }; - if (!useKeys && isSeq(iterable) && sliceSize >= 0) { - sliceSeq.get = function (index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize ? - iterable.get(index + resolvedBegin, notSetValue) : - notSetValue; - } - } + Map.prototype.remove = function(k) { + return updateMap(this, k, NOT_SET); + }; - sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this; - if (sliceSize === 0) { - return 0; - } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - iterable.__iterate(function(v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0) !== false && - iterations !== sliceSize; - } - }); - return iterations; + Map.prototype.deleteIn = function(keyPath) { + return this.updateIn(keyPath, function() {return NOT_SET}); }; - sliceSeq.__iteratorUncached = function(type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); + Map.prototype.update = function(k, notSetValue, updater) { + return arguments.length === 1 ? + k(this) : + this.updateIn([k], notSetValue, updater); + }; + + Map.prototype.updateIn = function(keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; } - // Don't bother instantiating parent iterator if taking 0. - var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { - return step; - } else if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); - } else { - return iteratorValue(type, iterations - 1, step.value[1], step); - } - }); - } + var updatedValue = updateInDeepMap( + this, + forceIterator(keyPath), + notSetValue, + updater + ); + return updatedValue === NOT_SET ? undefined : updatedValue; + }; - return sliceSeq; - } + Map.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + // @pragma Composition - function takeWhileFactory(iterable, predicate, context) { - var takeSequence = makeSequence(iterable); - takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - iterable.__iterate(function(v, k, c) - {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)} + Map.prototype.merge = function(/*...iters*/) { + return mergeIntoMapWith(this, undefined, arguments); + }; + + Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoMapWith(this, merger, iters); + }; + + Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); + return this.updateIn( + keyPath, + emptyMap(), + function(m ) {return typeof m.merge === 'function' ? + m.merge.apply(m, iters) : + iters[iters.length - 1]} ); - return iterations; }; - takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new src_Iterator__Iterator(function() { - if (!iterating) { - return iteratorDone(); - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$0)) { - iterating = false; - return iteratorDone(); - } - return type === ITERATE_ENTRIES ? step : - iteratorValue(type, k, v, step); - }); + + Map.prototype.mergeDeep = function(/*...iters*/) { + return mergeIntoMapWith(this, deepMerger, arguments); }; - return takeSequence; - } + Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoMapWith(this, deepMergerWith(merger), iters); + }; - function skipWhileFactory(iterable, predicate, context, useKeys) { - var skipSequence = makeSequence(iterable); - skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var isSkipping = true; + Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); + return this.updateIn( + keyPath, + emptyMap(), + function(m ) {return typeof m.mergeDeep === 'function' ? + m.mergeDeep.apply(m, iters) : + iters[iters.length - 1]} + ); + }; + + Map.prototype.sort = function(comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function(mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + // @pragma Mutability + + Map.prototype.withMutations = function(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; + }; + + Map.prototype.asMutable = function() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); + }; + + Map.prototype.asImmutable = function() { + return this.__ensureOwner(); + }; + + Map.prototype.wasAltered = function() { + return this.__altered; + }; + + Map.prototype.__iterator = function(type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function(fn, reverse) {var this$0 = this; var iterations = 0; - iterable.__iterate(function(v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0); - } - }); + this._root && this._root.iterate(function(entry ) { + iterations++; + return fn(entry[1], entry[0], this$0); + }, reverse); return iterations; }; - skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterator(type, reverse); + + Map.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; } - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step, k, v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } else if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } else { - return iteratorValue(type, iterations++, step.value[1], step); - } - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$0)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : - iteratorValue(type, k, v, step); - }); + if (!ownerID) { + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); }; - return skipSequence; + + + function isMap(maybeMap) { + return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); } + Map.isMap = isMap; - function concatFactory(iterable, values) { - var isKeyedIterable = isKeyed(iterable); - var iters = [iterable].concat(values).map(function(v ) { - if (!isIterable(v)) { - v = isKeyedIterable ? - keyedSeqFromValue(v) : - indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedIterable) { - v = KeyedIterable(v); - } - return v; - }).filter(function(v ) {return v.size !== 0}); + var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - if (iters.length === 0) { - return iterable; - } + var MapPrototype = Map.prototype; + MapPrototype[IS_MAP_SENTINEL] = true; + MapPrototype[DELETE] = MapPrototype.remove; + MapPrototype.removeIn = MapPrototype.deleteIn; - if (iters.length === 1) { - var singleton = iters[0]; - if (singleton === iterable || - isKeyedIterable && isKeyed(singleton) || - isIndexed(iterable) && isIndexed(singleton)) { - return singleton; - } - } - var concatSeq = new ArraySeq(iters); - if (isKeyedIterable) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(iterable)) { - concatSeq = concatSeq.toSetSeq(); + // #pragma Trie Nodes + + + + function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce( - function(sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } + + ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; } - }, - 0 - ); - return concatSeq; - } + } + return notSetValue; + }; + ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; - function flattenFactory(iterable, depth, useKeys) { - var flatSequence = makeSequence(iterable); - flatSequence.__iterateUncached = function(fn, reverse) { - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) {var this$0 = this; - iter.__iterate(function(v, k) { - if ((!depth || currentDepth < depth) && isIterable(v)) { - flatDeep(v, currentDepth + 1); - } else if (fn(v, useKeys ? k : iterations++, this$0) === false) { - stopped = true; - } - return !stopped; - }, reverse); - } - flatDeep(iterable, 0); - return iterations; - } - flatSequence.__iteratorUncached = function(type, reverse) { - var iterator = iterable.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isIterable(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } + var entries = this.entries; + var idx = 0; + for (var len = entries.length; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; } - return iteratorDone(); - }); - } - return flatSequence; - } + } + var exists = idx < len; + if (exists ? entries[idx][1] === value : removed) { + return this; + } - function flatMapFactory(iterable, mapper, context) { - var coerce = iterableClass(iterable); - return iterable.toSeq().map( - function(v, k) {return coerce(mapper.call(context, v, k, iterable))} - ).flatten(true); - } + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } - function interposeFactory(iterable, separator) { - var interposedSequence = makeSequence(iterable); - interposedSequence.size = iterable.size && iterable.size * 2 -1; - interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; - var iterations = 0; - iterable.__iterate(function(v, k) - {return (!iterations || fn(separator, iterations++, this$0) !== false) && - fn(v, iterations++, this$0) !== false}, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function(type, reverse) { - var iterator = iterable.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new src_Iterator__Iterator(function() { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; } - return iterations % 2 ? - iteratorValue(type, iterations++, separator) : - iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; - } + } else { + newEntries.push([key, value]); + } + if (isEditable) { + this.entries = newEntries; + return this; + } - function sortFactory(iterable, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedIterable = isKeyed(iterable); - var index = 0; - var entries = iterable.toSeq().map( - function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]} - ).toArray(); - entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach( - isKeyedIterable ? - function(v, i) { entries[i].length = 2; } : - function(v, i) { entries[i] = v[1]; } - ); - return isKeyedIterable ? KeyedSeq(entries) : - isIndexed(iterable) ? IndexedSeq(entries) : - SetSeq(entries); - } + return new ArrayMapNode(ownerID, newEntries); + }; - function maxFactory(iterable, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = iterable.toSeq() - .map(function(v, k) {return [v, mapper(v, k, iterable)]}) - .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a}); - return entry && entry[0]; - } else { - return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a}); - } - } - function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0; - } + function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; + } - function zipWithFactory(keyIter, zipper, iters) { - var zipSequence = makeSequence(keyIter); - zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function(fn, reverse) { - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } + BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); } - return iterations; - }; - zipSequence.__iteratorUncached = function(type, reverse) { - var iterators = iters.map(function(i ) - {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))} - ); - var iterations = 0; - var isDone = false; - return new src_Iterator__Iterator(function() { - var steps; - if (!isDone) { - steps = iterators.map(function(i ) {return i.next()}); - isDone = steps.some(function(s ) {return s.done}); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply(null, steps.map(function(s ) {return s.value})) - ); - }); + var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK)); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 ? notSetValue : + this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue); }; - return zipSequence - } + BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; - // #pragma Helper Functions + if (!exists && value === NOT_SET) { + return this; + } - function reify(iter, seq) { - return isSeq(iter) ? seq : iter.constructor(seq); - } + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } - } + if (newNode === node) { + return this; + } - function resolveSize(iter) { - assertNotInfinite(iter.size); - return ensureSize(iter); - } + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } - function iterableClass(iterable) { - return isKeyed(iterable) ? KeyedIterable : - isIndexed(iterable) ? IndexedIterable : - SetIterable; - } + if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) { + return nodes[idx ^ 1]; + } - function makeSequence(iterable) { - return Object.create( - ( - isKeyed(iterable) ? KeyedSeq : - isIndexed(iterable) ? IndexedSeq : - SetSeq - ).prototype - ); - } - - function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } else { - return Seq.prototype.cacheResult.call(this); - } - } - - function defaultComparator(a, b) { - return a > b ? 1 : a < b ? -1 : 0; - } - - function forceIterator(keyPath) { - var iter = getIterator(keyPath); - if (!iter) { - // Array might not be iterable in this environment, so we need a fallback - // to our wrapped type. - if (!isArrayLike(keyPath)) { - throw new TypeError('Expected iterable or array-like: ' + keyPath); + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; } - iter = getIterator(Iterable(keyPath)); - } - return iter; - } - - createClass(src_Map__Map, KeyedCollection); - - // @pragma Construction - - function src_Map__Map(value) { - return value === null || value === undefined ? emptyMap() : - isMap(value) && !isOrdered(value) ? value : - emptyMap().withMutations(function(map ) { - var iter = KeyedIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v, k) {return map.set(k, v)}); - }); - } - src_Map__Map.prototype.toString = function() { - return this.__toString('Map {', '}'); - }; + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newNodes = exists ? newNode ? + setIn(nodes, idx, newNode, isEditable) : + spliceOut(nodes, idx, isEditable) : + spliceIn(nodes, idx, newNode, isEditable); - // @pragma Access + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } - src_Map__Map.prototype.get = function(k, notSetValue) { - return this._root ? - this._root.get(0, undefined, k, notSetValue) : - notSetValue; + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); }; - // @pragma Modification - - src_Map__Map.prototype.set = function(k, v) { - return updateMap(this, k, v); - }; - src_Map__Map.prototype.setIn = function(keyPath, v) { - return this.updateIn(keyPath, NOT_SET, function() {return v}); - }; - src_Map__Map.prototype.remove = function(k) { - return updateMap(this, k, NOT_SET); - }; - src_Map__Map.prototype.deleteIn = function(keyPath) { - return this.updateIn(keyPath, function() {return NOT_SET}); - }; + function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; + } - src_Map__Map.prototype.update = function(k, notSetValue, updater) { - return arguments.length === 1 ? - k(this) : - this.updateIn([k], notSetValue, updater); + HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue; }; - src_Map__Map.prototype.updateIn = function(keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; + HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); } - var updatedValue = updateInDeepMap( - this, - forceIterator(keyPath), - notSetValue, - updater - ); - return updatedValue === NOT_SET ? undefined : updatedValue; - }; + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; - src_Map__Map.prototype.clear = function() { - if (this.size === 0) { + if (removed && !node) { return this; } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; + + var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); + if (newNode === node) { return this; } - return emptyMap(); - }; - - // @pragma Composition - - src_Map__Map.prototype.merge = function(/*...iters*/) { - return mergeIntoMapWith(this, undefined, arguments); - }; - - src_Map__Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoMapWith(this, merger, iters); - }; - - src_Map__Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); - return this.updateIn( - keyPath, - emptyMap(), - function(m ) {return typeof m.merge === 'function' ? - m.merge.apply(m, iters) : - iters[iters.length - 1]} - ); - }; - - src_Map__Map.prototype.mergeDeep = function(/*...iters*/) { - return mergeIntoMapWith(this, deepMerger(undefined), arguments); - }; - - src_Map__Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoMapWith(this, deepMerger(merger), iters); - }; - - src_Map__Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); - return this.updateIn( - keyPath, - emptyMap(), - function(m ) {return typeof m.mergeDeep === 'function' ? - m.mergeDeep.apply(m, iters) : - iters[iters.length - 1]} - ); - }; - - src_Map__Map.prototype.sort = function(comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); - }; - - src_Map__Map.prototype.sortBy = function(mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); - }; - // @pragma Mutability - - src_Map__Map.prototype.withMutations = function(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; - }; - - src_Map__Map.prototype.asMutable = function() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); - }; - - src_Map__Map.prototype.asImmutable = function() { - return this.__ensureOwner(); - }; - - src_Map__Map.prototype.wasAltered = function() { - return this.__altered; - }; - - src_Map__Map.prototype.__iterator = function(type, reverse) { - return new MapIterator(this, type, reverse); - }; + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } - src_Map__Map.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var iterations = 0; - this._root && this._root.iterate(function(entry ) { - iterations++; - return fn(entry[1], entry[0], this$0); - }, reverse); - return iterations; - }; + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setIn(nodes, idx, newNode, isEditable); - src_Map__Map.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - this.__ownerID = ownerID; - this.__altered = false; + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; return this; } - return makeMap(this.size, this._root, ownerID, this.__hash); - }; - - - function isMap(maybeMap) { - return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); - } - - src_Map__Map.isMap = isMap; - - var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - - var MapPrototype = src_Map__Map.prototype; - MapPrototype[IS_MAP_SENTINEL] = true; - MapPrototype[DELETE] = MapPrototype.remove; - MapPrototype.removeIn = MapPrototype.deleteIn; + return new HashArrayMapNode(ownerID, newCount, newNodes); + }; - // #pragma Trie Nodes - function ArrayMapNode(ownerID, entries) { + function HashCollisionNode(ownerID, keyHash, entries) { this.ownerID = ownerID; + this.keyHash = keyHash; this.entries = entries; } - ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { var entries = this.entries; for (var ii = 0, len = entries.length; ii < len; ii++) { if (is(key, entries[ii][0])) { @@ -2483,9 +2031,22 @@ return /******/ (function(modules) { // webpackBootstrap return notSetValue; }; - ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var removed = value === NOT_SET; + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + var entries = this.entries; var idx = 0; for (var len = entries.length; idx < len; idx++) { @@ -2502,12 +2063,8 @@ return /******/ (function(modules) { // webpackBootstrap SetRef(didAlter); (removed || !exists) && SetRef(didChangeSize); - if (removed && entries.length === 1) { - return; // undefined - } - - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); } var isEditable = ownerID && ownerID === this.ownerID; @@ -2528,216 +2085,13 @@ return /******/ (function(modules) { // webpackBootstrap return this; } - return new ArrayMapNode(ownerID, newEntries); + return new HashCollisionNode(ownerID, this.keyHash, newEntries); }; - function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; - } - - BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK)); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 ? notSetValue : - this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue); - }; - - BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; - - if (!exists && value === NOT_SET) { - return this; - } - - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - - if (newNode === node) { - return this; - } - - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } - - if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) { - return nodes[idx ^ 1]; - } - - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; - var newNodes = exists ? newNode ? - setIn(nodes, idx, newNode, isEditable) : - spliceOut(nodes, idx, isEditable) : - spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; - } - - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); - }; - - - - - function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; - } - - HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue; - }; - - HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - - if (removed && !node) { - return this; - } - - var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - if (newNode === node) { - return this; - } - - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); - } - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; - } - - return new HashArrayMapNode(ownerID, newCount, newNodes); - }; - - - - - function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; - } - - HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; - }; - - HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - - var removed = value === NOT_SET; - - if (keyHash !== this.keyHash) { - if (removed) { - return this; - } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); - } - - var entries = this.entries; - var idx = 0; - for (var len = entries.length; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new HashCollisionNode(ownerID, this.keyHash, newEntries); - }; - - - - - function ValueNode(ownerID, keyHash, entry) { + function ValueNode(ownerID, keyHash, entry) { this.ownerID = ownerID; this.keyHash = keyHash; this.entry = entry; @@ -2802,7 +2156,7 @@ return /******/ (function(modules) { // webpackBootstrap return fn(this.entry); } - createClass(MapIterator, src_Iterator__Iterator); + createClass(MapIterator, Iterator); function MapIterator(map, type, reverse) { this._type = type; @@ -2981,11 +2335,20 @@ return /******/ (function(modules) { // webpackBootstrap return mergeIntoCollectionWith(map, merger, iters); } - function deepMerger(merger) { - return function(existing, value, key) - {return existing && existing.mergeDeepWith && isIterable(value) ? - existing.mergeDeepWith(merger, value) : - merger ? merger(existing, value, key) : value}; + function deepMerger(existing, value, key) { + return existing && existing.mergeDeep && isIterable(value) ? + existing.mergeDeep(value) : + is(existing, value) ? existing : value; + } + + function deepMergerWith(merger) { + return function(existing, value, key) { + if (existing && existing.mergeDeepWith && isIterable(value)) { + return existing.mergeDeepWith(merger, value); + } + var nextValue = merger(existing, value, key); + return is(existing, nextValue) ? existing : nextValue; + }; } function mergeIntoCollectionWith(collection, merger, iters) { @@ -3152,6 +2515,10 @@ return /******/ (function(modules) { // webpackBootstrap this.splice(index, 1); }; + List.prototype.insert = function(index, value) { + return this.splice(index, 0, value); + }; + List.prototype.clear = function() { if (this.size === 0) { return this; @@ -3207,11 +2574,11 @@ return /******/ (function(modules) { // webpackBootstrap }; List.prototype.mergeDeep = function(/*...iters*/) { - return mergeIntoListWith(this, deepMerger(undefined), arguments); + return mergeIntoListWith(this, deepMerger, arguments); }; List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoListWith(this, deepMerger(merger), iters); + return mergeIntoListWith(this, deepMergerWith(merger), iters); }; List.prototype.setSize = function(size) { @@ -3235,7 +2602,7 @@ return /******/ (function(modules) { // webpackBootstrap List.prototype.__iterator = function(type, reverse) { var index = 0; var values = iterateList(this, reverse); - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var value = values(); return value === DONE ? iteratorDone() : @@ -3683,7 +3050,7 @@ return /******/ (function(modules) { // webpackBootstrap return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT); } - createClass(OrderedMap, src_Map__Map); + createClass(OrderedMap, Map); // @pragma Construction @@ -3835,453 +3202,834 @@ return /******/ (function(modules) { // webpackBootstrap return makeOrderedMap(newMap, newList); } - createClass(Stack, IndexedCollection); - - // @pragma Construction - - function Stack(value) { - return value === null || value === undefined ? emptyStack() : - isStack(value) ? value : - emptyStack().unshiftAll(value); + createClass(ToKeyedSequence, KeyedSeq); + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; } - Stack.of = function(/*...values*/) { - return this(arguments); + ToKeyedSequence.prototype.get = function(key, notSetValue) { + return this._iter.get(key, notSetValue); }; - Stack.prototype.toString = function() { - return this.__toString('Stack [', ']'); + ToKeyedSequence.prototype.has = function(key) { + return this._iter.has(key); }; - // @pragma Access + ToKeyedSequence.prototype.valueSeq = function() { + return this._iter.valueSeq(); + }; - Stack.prototype.get = function(index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; + ToKeyedSequence.prototype.reverse = function() {var this$0 = this; + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()}; } - return head ? head.value : notSetValue; + return reversedSequence; }; - Stack.prototype.peek = function() { - return this._head && this._head.value; + ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this; + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)}; + } + return mappedSequence; }; - // @pragma Modification - - Stack.prototype.push = function(/*...values*/) { - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments[ii], - next: head - }; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); + ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + var ii; + return this._iter.__iterate( + this._useKeys ? + function(v, k) {return fn(v, k, this$0)} : + ((ii = reverse ? resolveSize(this) : 0), + function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}), + reverse + ); }; - Stack.prototype.pushAll = function(iter) { - iter = IndexedIterable(iter); - if (iter.size === 0) { - return this; + ToKeyedSequence.prototype.__iterator = function(type, reverse) { + if (this._useKeys) { + return this._iter.__iterator(type, reverse); } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.reverse().forEach(function(value ) { - newSize++; - head = { - value: value, - next: head - }; + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var ii = reverse ? resolveSize(this) : 0; + return new Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, reverse ? --ii : ii++, step.value, step); }); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pop = function() { - return this.slice(1); - }; - - Stack.prototype.unshift = function(/*...values*/) { - return this.push.apply(this, arguments); - }; - - Stack.prototype.unshiftAll = function(iter) { - return this.pushAll(iter); - }; - - Stack.prototype.shift = function() { - return this.pop.apply(this, arguments); }; - Stack.prototype.clear = function() { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyStack(); - }; + ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; - Stack.prototype.slice = function(begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - // @pragma Mutability + createClass(ToIndexedSequence, IndexedSeq); + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } - Stack.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeStack(this.size, this._head, ownerID, this.__hash); + ToIndexedSequence.prototype.includes = function(value) { + return this._iter.includes(value); }; - // @pragma Iteration - - Stack.prototype.__iterate = function(fn, reverse) { - if (reverse) { - return this.reverse().__iterate(fn); - } + ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this) === false) { - break; - } - node = node.next; - } - return iterations; + return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse); }; - Stack.prototype.__iterator = function(type, reverse) { - if (reverse) { - return this.reverse().__iterator(type); - } + ToIndexedSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); var iterations = 0; - var node = this._head; - return new src_Iterator__Iterator(function() { - if (node) { - var value = node.value; - node = node.next; - return iteratorValue(type, iterations++, value); - } - return iteratorDone(); + return new Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, iterations++, step.value, step) }); }; - function isStack(maybeStack) { - return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); - } - - Stack.isStack = isStack; - - var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; - - var StackPrototype = Stack.prototype; - StackPrototype[IS_STACK_SENTINEL] = true; - StackPrototype.withMutations = MapPrototype.withMutations; - StackPrototype.asMutable = MapPrototype.asMutable; - StackPrototype.asImmutable = MapPrototype.asImmutable; - StackPrototype.wasAltered = MapPrototype.wasAltered; - - - function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; - } - - var EMPTY_STACK; - function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); - } - - createClass(src_Set__Set, SetCollection); - - // @pragma Construction - function src_Set__Set(value) { - return value === null || value === undefined ? emptySet() : - isSet(value) && !isOrdered(value) ? value : - emptySet().withMutations(function(set ) { - var iter = SetIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v ) {return set.add(v)}); - }); + createClass(ToSetSequence, SetSeq); + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; } - src_Set__Set.of = function(/*...values*/) { - return this(arguments); + ToSetSequence.prototype.has = function(key) { + return this._iter.includes(key); }; - src_Set__Set.fromKeys = function(value) { - return this(KeyedIterable(value).keySeq()); + ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse); }; - src_Set__Set.prototype.toString = function() { - return this.__toString('Set {', '}'); + ToSetSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, step.value, step.value, step); + }); }; - // @pragma Access - - src_Set__Set.prototype.has = function(value) { - return this._map.has(value); - }; - // @pragma Modification - src_Set__Set.prototype.add = function(value) { - return updateSet(this, this._map.set(value, true)); - }; + createClass(FromEntriesSequence, KeyedSeq); + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } - src_Set__Set.prototype.remove = function(value) { - return updateSet(this, this._map.remove(value)); + FromEntriesSequence.prototype.entrySeq = function() { + return this._iter.toSeq(); }; - src_Set__Set.prototype.clear = function() { - return updateSet(this, this._map.clear()); + FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._iter.__iterate(function(entry ) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedIterable = isIterable(entry); + return fn( + indexedIterable ? entry.get(1) : entry[1], + indexedIterable ? entry.get(0) : entry[0], + this$0 + ); + } + }, reverse); }; - // @pragma Composition - - src_Set__Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0); - iters = iters.filter(function(x ) {return x.size !== 0}); - if (iters.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && iters.length === 1) { - return this.constructor(iters[0]); - } - return this.withMutations(function(set ) { - for (var ii = 0; ii < iters.length; ii++) { - SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)}); + FromEntriesSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function() { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedIterable = isIterable(entry); + return iteratorValue( + type, + indexedIterable ? entry.get(0) : entry[0], + indexedIterable ? entry.get(1) : entry[1], + step + ); + } } }); }; - src_Set__Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0); - if (iters.length === 0) { - return this; - } - iters = iters.map(function(iter ) {return SetIterable(iter)}); - var originalSet = this; - return this.withMutations(function(set ) { - originalSet.forEach(function(value ) { - if (!iters.every(function(iter ) {return iter.includes(value)})) { - set.remove(value); - } - }); - }); - }; - src_Set__Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0); - if (iters.length === 0) { - return this; - } - iters = iters.map(function(iter ) {return SetIterable(iter)}); - var originalSet = this; - return this.withMutations(function(set ) { - originalSet.forEach(function(value ) { - if (iters.some(function(iter ) {return iter.includes(value)})) { - set.remove(value); - } - }); - }); - }; + ToIndexedSequence.prototype.cacheResult = + ToKeyedSequence.prototype.cacheResult = + ToSetSequence.prototype.cacheResult = + FromEntriesSequence.prototype.cacheResult = + cacheResultThrough; - src_Set__Set.prototype.merge = function() { - return this.union.apply(this, arguments); - }; - src_Set__Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return this.union.apply(this, iters); + function flipFactory(iterable) { + var flipSequence = makeSequence(iterable); + flipSequence._iter = iterable; + flipSequence.size = iterable.size; + flipSequence.flip = function() {return iterable}; + flipSequence.reverse = function () { + var reversedSequence = iterable.reverse.apply(this); // super.reverse() + reversedSequence.flip = function() {return iterable.reverse()}; + return reversedSequence; }; + flipSequence.has = function(key ) {return iterable.includes(key)}; + flipSequence.includes = function(key ) {return iterable.has(key)}; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse); + } + flipSequence.__iteratorUncached = function(type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = iterable.__iterator(type, reverse); + return new Iterator(function() { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return iterable.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + } + return flipSequence; + } - src_Set__Set.prototype.sort = function(comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator)); - }; - src_Set__Set.prototype.sortBy = function(mapper, comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator, mapper)); + function mapFactory(iterable, mapper, context) { + var mappedSequence = makeSequence(iterable); + mappedSequence.size = iterable.size; + mappedSequence.has = function(key ) {return iterable.has(key)}; + mappedSequence.get = function(key, notSetValue) { + var v = iterable.get(key, NOT_SET); + return v === NOT_SET ? + notSetValue : + mapper.call(context, v, key, iterable); }; + mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + return iterable.__iterate( + function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false}, + reverse + ); + } + mappedSequence.__iteratorUncached = function (type, reverse) { + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function() { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, iterable), + step + ); + }); + } + return mappedSequence; + } - src_Set__Set.prototype.wasAltered = function() { - return this._map.wasAltered(); - }; - src_Set__Set.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse); + function reverseFactory(iterable, useKeys) { + var reversedSequence = makeSequence(iterable); + reversedSequence._iter = iterable; + reversedSequence.size = iterable.size; + reversedSequence.reverse = function() {return iterable}; + if (iterable.flip) { + reversedSequence.flip = function () { + var flipSequence = flipFactory(iterable); + flipSequence.reverse = function() {return iterable.flip()}; + return flipSequence; + }; + } + reversedSequence.get = function(key, notSetValue) + {return iterable.get(useKeys ? key : -1 - key, notSetValue)}; + reversedSequence.has = function(key ) + {return iterable.has(useKeys ? key : -1 - key)}; + reversedSequence.includes = function(value ) {return iterable.includes(value)}; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function (fn, reverse) {var this$0 = this; + return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse); }; + reversedSequence.__iterator = + function(type, reverse) {return iterable.__iterator(type, !reverse)}; + return reversedSequence; + } - src_Set__Set.prototype.__iterator = function(type, reverse) { - return this._map.map(function(_, k) {return k}).__iterator(type, reverse); - }; - src_Set__Set.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return this.__make(newMap, ownerID); + function filterFactory(iterable, predicate, context, useKeys) { + var filterSequence = makeSequence(iterable); + if (useKeys) { + filterSequence.has = function(key ) { + var v = iterable.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, iterable); + }; + filterSequence.get = function(key, notSetValue) { + var v = iterable.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, iterable) ? + v : notSetValue; + }; + } + filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + var iterations = 0; + iterable.__iterate(function(v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0); + } + }, reverse); + return iterations; }; + filterSequence.__iteratorUncached = function (type, reverse) { + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function() { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, iterable)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + } + return filterSequence; + } - function isSet(maybeSet) { - return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); + function countByFactory(iterable, grouper, context) { + var groups = Map().asMutable(); + iterable.__iterate(function(v, k) { + groups.update( + grouper.call(context, v, k, iterable), + 0, + function(a ) {return a + 1} + ); + }); + return groups.asImmutable(); } - src_Set__Set.isSet = isSet; - var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; + function groupByFactory(iterable, grouper, context) { + var isKeyedIter = isKeyed(iterable); + var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable(); + iterable.__iterate(function(v, k) { + groups.update( + grouper.call(context, v, k, iterable), + function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)} + ); + }); + var coerce = iterableClass(iterable); + return groups.map(function(arr ) {return reify(iterable, coerce(arr))}); + } - var SetPrototype = src_Set__Set.prototype; - SetPrototype[IS_SET_SENTINEL] = true; - SetPrototype[DELETE] = SetPrototype.remove; - SetPrototype.mergeDeep = SetPrototype.merge; - SetPrototype.mergeDeepWith = SetPrototype.mergeWith; - SetPrototype.withMutations = MapPrototype.withMutations; - SetPrototype.asMutable = MapPrototype.asMutable; - SetPrototype.asImmutable = MapPrototype.asImmutable; - SetPrototype.__empty = emptySet; - SetPrototype.__make = makeSet; + function sliceFactory(iterable, begin, end, useKeys) { + var originalSize = iterable.size; - function updateSet(set, newMap) { - if (set.__ownerID) { - set.size = newMap.size; - set._map = newMap; - return set; + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin = begin | 0; } - return newMap === set._map ? set : - newMap.size === 0 ? set.__empty() : - set.__make(newMap); - } - - function makeSet(map, ownerID) { - var set = Object.create(SetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; + if (end !== undefined) { + end = end | 0; + } + + if (wholeSlice(begin, end, originalSize)) { + return iterable; + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // begin or end will be NaN if they were provided as negative numbers and + // this iterable's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys); + } + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(iterable); + + // If iterable.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined; + + if (!useKeys && isSeq(iterable) && sliceSize >= 0) { + sliceSeq.get = function (index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize ? + iterable.get(index + resolvedBegin, notSetValue) : + notSetValue; + } + } + + sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this; + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + iterable.__iterate(function(v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0) !== false && + iterations !== sliceSize; + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function(type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function() { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES) { + return step; + } else if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } else { + return iteratorValue(type, iterations - 1, step.value[1], step); + } + }); + } + + return sliceSeq; + } + + + function takeWhileFactory(iterable, predicate, context) { + var takeSequence = makeSequence(iterable); + takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + iterable.__iterate(function(v, k, c) + {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)} + ); + return iterations; + }; + takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function() { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$0)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : + iteratorValue(type, k, v, step); + }); + }; + return takeSequence; + } + + + function skipWhileFactory(iterable, predicate, context, useKeys) { + var skipSequence = makeSequence(iterable); + skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + iterable.__iterate(function(v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function() { + var step, k, v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } else if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } else { + return iteratorValue(type, iterations++, step.value[1], step); + } + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$0)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : + iteratorValue(type, k, v, step); + }); + }; + return skipSequence; + } + + + function concatFactory(iterable, values) { + var isKeyedIterable = isKeyed(iterable); + var iters = [iterable].concat(values).map(function(v ) { + if (!isIterable(v)) { + v = isKeyedIterable ? + keyedSeqFromValue(v) : + indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedIterable) { + v = KeyedIterable(v); + } + return v; + }).filter(function(v ) {return v.size !== 0}); + + if (iters.length === 0) { + return iterable; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if (singleton === iterable || + isKeyedIterable && isKeyed(singleton) || + isIndexed(iterable) && isIndexed(singleton)) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedIterable) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(iterable)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce( + function(sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, + 0 + ); + return concatSeq; + } + + + function flattenFactory(iterable, depth, useKeys) { + var flatSequence = makeSequence(iterable); + flatSequence.__iterateUncached = function(fn, reverse) { + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) {var this$0 = this; + iter.__iterate(function(v, k) { + if ((!depth || currentDepth < depth) && isIterable(v)) { + flatDeep(v, currentDepth + 1); + } else if (fn(v, useKeys ? k : iterations++, this$0) === false) { + stopped = true; + } + return !stopped; + }, reverse); + } + flatDeep(iterable, 0); + return iterations; + } + flatSequence.__iteratorUncached = function(type, reverse) { + var iterator = iterable.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function() { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isIterable(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + } + return flatSequence; + } + + + function flatMapFactory(iterable, mapper, context) { + var coerce = iterableClass(iterable); + return iterable.toSeq().map( + function(v, k) {return coerce(mapper.call(context, v, k, iterable))} + ).flatten(true); + } + + + function interposeFactory(iterable, separator) { + var interposedSequence = makeSequence(iterable); + interposedSequence.size = iterable.size && iterable.size * 2 -1; + interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; + var iterations = 0; + iterable.__iterate(function(v, k) + {return (!iterations || fn(separator, iterations++, this$0) !== false) && + fn(v, iterations++, this$0) !== false}, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function(type, reverse) { + var iterator = iterable.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function() { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 ? + iteratorValue(type, iterations++, separator) : + iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; + } + + + function sortFactory(iterable, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedIterable = isKeyed(iterable); + var index = 0; + var entries = iterable.toSeq().map( + function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]} + ).toArray(); + entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach( + isKeyedIterable ? + function(v, i) { entries[i].length = 2; } : + function(v, i) { entries[i] = v[1]; } + ); + return isKeyedIterable ? KeyedSeq(entries) : + isIndexed(iterable) ? IndexedSeq(entries) : + SetSeq(entries); + } + + + function maxFactory(iterable, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = iterable.toSeq() + .map(function(v, k) {return [v, mapper(v, k, iterable)]}) + .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a}); + return entry && entry[0]; + } else { + return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a}); + } + } + + function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0; + } + + + function zipWithFactory(keyIter, zipper, iters) { + var zipSequence = makeSequence(keyIter); + zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map(function(i ) + {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))} + ); + var iterations = 0; + var isDone = false; + return new Iterator(function() { + var steps; + if (!isDone) { + steps = iterators.map(function(i ) {return i.next()}); + isDone = steps.some(function(s ) {return s.done}); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function(s ) {return s.value})) + ); + }); + }; + return zipSequence } - var EMPTY_SET; - function emptySet() { - return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); - } - createClass(OrderedSet, src_Set__Set); + // #pragma Helper Functions - // @pragma Construction + function reify(iter, seq) { + return isSeq(iter) ? seq : iter.constructor(seq); + } - function OrderedSet(value) { - return value === null || value === undefined ? emptyOrderedSet() : - isOrderedSet(value) ? value : - emptyOrderedSet().withMutations(function(set ) { - var iter = SetIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v ) {return set.add(v)}); - }); + function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); } + } - OrderedSet.of = function(/*...values*/) { - return this(arguments); - }; - - OrderedSet.fromKeys = function(value) { - return this(KeyedIterable(value).keySeq()); - }; - - OrderedSet.prototype.toString = function() { - return this.__toString('OrderedSet {', '}'); - }; - - - function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + function resolveSize(iter) { + assertNotInfinite(iter.size); + return ensureSize(iter); } - OrderedSet.isOrderedSet = isOrderedSet; + function iterableClass(iterable) { + return isKeyed(iterable) ? KeyedIterable : + isIndexed(iterable) ? IndexedIterable : + SetIterable; + } - var OrderedSetPrototype = OrderedSet.prototype; - OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; + function makeSequence(iterable) { + return Object.create( + ( + isKeyed(iterable) ? KeyedSeq : + isIndexed(iterable) ? IndexedSeq : + SetSeq + ).prototype + ); + } - OrderedSetPrototype.__empty = emptyOrderedSet; - OrderedSetPrototype.__make = makeOrderedSet; + function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } else { + return Seq.prototype.cacheResult.call(this); + } + } - function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; + function defaultComparator(a, b) { + return a > b ? 1 : a < b ? -1 : 0; } - var EMPTY_ORDERED_SET; - function emptyOrderedSet() { - return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); + function forceIterator(keyPath) { + var iter = getIterator(keyPath); + if (!iter) { + // Array might not be iterable in this environment, so we need a fallback + // to our wrapped type. + if (!isArrayLike(keyPath)) { + throw new TypeError('Expected iterable or array-like: ' + keyPath); + } + iter = getIterator(Iterable(keyPath)); + } + return iter; } createClass(Record, KeyedCollection); @@ -4305,7 +4053,7 @@ return /******/ (function(modules) { // webpackBootstrap RecordTypePrototype._keys = keys; RecordTypePrototype._defaultValues = defaultValues; } - this._map = src_Map__Map(values); + this._map = Map(values); }; var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype); @@ -4440,255 +4188,454 @@ return /******/ (function(modules) { // webpackBootstrap }); } - function deepEqual(a, b) { - if (a === b) { - return true; + createClass(Set, SetCollection); + + // @pragma Construction + + function Set(value) { + return value === null || value === undefined ? emptySet() : + isSet(value) && !isOrdered(value) ? value : + emptySet().withMutations(function(set ) { + var iter = SetIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v ) {return set.add(v)}); + }); + } + + Set.of = function(/*...values*/) { + return this(arguments); + }; + + Set.fromKeys = function(value) { + return this(KeyedIterable(value).keySeq()); + }; + + Set.prototype.toString = function() { + return this.__toString('Set {', '}'); + }; + + // @pragma Access + + Set.prototype.has = function(value) { + return this._map.has(value); + }; + + // @pragma Modification + + Set.prototype.add = function(value) { + return updateSet(this, this._map.set(value, true)); + }; + + Set.prototype.remove = function(value) { + return updateSet(this, this._map.remove(value)); + }; + + Set.prototype.clear = function() { + return updateSet(this, this._map.clear()); + }; + + // @pragma Composition + + Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0); + iters = iters.filter(function(x ) {return x.size !== 0}); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function(set ) { + for (var ii = 0; ii < iters.length; ii++) { + SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)}); + } + }); + }; + + Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0); + if (iters.length === 0) { + return this; + } + iters = iters.map(function(iter ) {return SetIterable(iter)}); + var originalSet = this; + return this.withMutations(function(set ) { + originalSet.forEach(function(value ) { + if (!iters.every(function(iter ) {return iter.includes(value)})) { + set.remove(value); + } + }); + }); + }; + + Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0); + if (iters.length === 0) { + return this; + } + iters = iters.map(function(iter ) {return SetIterable(iter)}); + var originalSet = this; + return this.withMutations(function(set ) { + originalSet.forEach(function(value ) { + if (iters.some(function(iter ) {return iter.includes(value)})) { + set.remove(value); + } + }); + }); + }; + + Set.prototype.merge = function() { + return this.union.apply(this, arguments); + }; + + Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return this.union.apply(this, iters); + }; + + Set.prototype.sort = function(comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; + + Set.prototype.sortBy = function(mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; + + Set.prototype.wasAltered = function() { + return this._map.wasAltered(); + }; + + Set.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse); + }; + + Set.prototype.__iterator = function(type, reverse) { + return this._map.map(function(_, k) {return k}).__iterator(type, reverse); + }; + + Set.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + + function isSet(maybeSet) { + return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); + } + + Set.isSet = isSet; + + var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; + + var SetPrototype = Set.prototype; + SetPrototype[IS_SET_SENTINEL] = true; + SetPrototype[DELETE] = SetPrototype.remove; + SetPrototype.mergeDeep = SetPrototype.merge; + SetPrototype.mergeDeepWith = SetPrototype.mergeWith; + SetPrototype.withMutations = MapPrototype.withMutations; + SetPrototype.asMutable = MapPrototype.asMutable; + SetPrototype.asImmutable = MapPrototype.asImmutable; + + SetPrototype.__empty = emptySet; + SetPrototype.__make = makeSet; + + function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; } + return newMap === set._map ? set : + newMap.size === 0 ? set.__empty() : + set.__make(newMap); + } + + function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; + } + + var EMPTY_SET; + function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); + } + + createClass(OrderedSet, Set); + + // @pragma Construction - if ( - !isIterable(b) || - a.size !== undefined && b.size !== undefined && a.size !== b.size || - a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; + function OrderedSet(value) { + return value === null || value === undefined ? emptyOrderedSet() : + isOrderedSet(value) ? value : + emptyOrderedSet().withMutations(function(set ) { + var iter = SetIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v ) {return set.add(v)}); + }); } - if (a.size === 0 && b.size === 0) { - return true; - } + OrderedSet.of = function(/*...values*/) { + return this(arguments); + }; - var notAssociative = !isAssociative(a); + OrderedSet.fromKeys = function(value) { + return this(KeyedIterable(value).keySeq()); + }; - if (isOrdered(a)) { - var entries = a.entries(); - return b.every(function(v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done; - } + OrderedSet.prototype.toString = function() { + return this.__toString('OrderedSet {', '}'); + }; - var flipped = false; - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } - } + function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + } - var allEqual = true; - var bSize = b.__iterate(function(v, k) { - if (notAssociative ? !a.has(v) : - flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) { - allEqual = false; - return false; - } - }); + OrderedSet.isOrderedSet = isOrderedSet; - return allEqual && a.size === bSize; + var OrderedSetPrototype = OrderedSet.prototype; + OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; + + OrderedSetPrototype.__empty = emptyOrderedSet; + OrderedSetPrototype.__make = makeOrderedSet; + + function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; } - createClass(Range, IndexedSeq); + var EMPTY_ORDERED_SET; + function emptyOrderedSet() { + return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); + } - function Range(start, end, step) { - if (!(this instanceof Range)) { - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - start = start || 0; - if (end === undefined) { - end = Infinity; - } - step = step === undefined ? 1 : Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { - return EMPTY_RANGE; - } - EMPTY_RANGE = this; - } + createClass(Stack, IndexedCollection); + + // @pragma Construction + + function Stack(value) { + return value === null || value === undefined ? emptyStack() : + isStack(value) ? value : + emptyStack().unshiftAll(value); } - Range.prototype.toString = function() { - if (this.size === 0) { - return 'Range []'; - } - return 'Range [ ' + - this._start + '...' + this._end + - (this._step > 1 ? ' by ' + this._step : '') + - ' ]'; + Stack.of = function(/*...values*/) { + return this(arguments); }; - Range.prototype.get = function(index, notSetValue) { - return this.has(index) ? - this._start + wrapIndex(this, index) * this._step : - notSetValue; + Stack.prototype.toString = function() { + return this.__toString('Stack [', ']'); }; - Range.prototype.includes = function(searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex); - }; + // @pragma Access - Range.prototype.slice = function(begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); + Stack.prototype.get = function(index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; } - return new Range(this.get(begin, this._end), this.get(end, this._end), this._step); + return head ? head.value : notSetValue; }; - Range.prototype.indexOf = function(searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index - } - } - return -1; + Stack.prototype.peek = function() { + return this._head && this._head.value; }; - Range.prototype.lastIndexOf = function(searchValue) { - return this.indexOf(searchValue); - }; + // @pragma Modification - Range.prototype.__iterate = function(fn, reverse) { - var maxIndex = this.size - 1; - var step = this._step; - var value = reverse ? this._start + maxIndex * step : this._start; - for (var ii = 0; ii <= maxIndex; ii++) { - if (fn(value, ii, this) === false) { - return ii + 1; - } - value += reverse ? -step : step; + Stack.prototype.push = function(/*...values*/) { + if (arguments.length === 0) { + return this; } - return ii; - }; - - Range.prototype.__iterator = function(type, reverse) { - var maxIndex = this.size - 1; - var step = this._step; - var value = reverse ? this._start + maxIndex * step : this._start; - var ii = 0; - return new src_Iterator__Iterator(function() { - var v = value; - value += reverse ? -step : step; - return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v); - }); - }; - - Range.prototype.equals = function(other) { - return other instanceof Range ? - this._start === other._start && - this._end === other._end && - this._step === other._step : - deepEqual(this, other); + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments[ii], + next: head + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); }; - - var EMPTY_RANGE; - - createClass(Repeat, IndexedSeq); - - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - return new Repeat(value, times); + Stack.prototype.pushAll = function(iter) { + iter = IndexedIterable(iter); + if (iter.size === 0) { + return this; } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); - if (this.size === 0) { - if (EMPTY_REPEAT) { - return EMPTY_REPEAT; - } - EMPTY_REPEAT = this; + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.reverse().forEach(function(value ) { + newSize++; + head = { + value: value, + next: head + }; + }); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; } - } + return makeStack(newSize, head); + }; - Repeat.prototype.toString = function() { - if (this.size === 0) { - return 'Repeat []'; - } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + Stack.prototype.pop = function() { + return this.slice(1); }; - Repeat.prototype.get = function(index, notSetValue) { - return this.has(index) ? this._value : notSetValue; + Stack.prototype.unshift = function(/*...values*/) { + return this.push.apply(this, arguments); }; - Repeat.prototype.includes = function(searchValue) { - return is(this._value, searchValue); + Stack.prototype.unshiftAll = function(iter) { + return this.pushAll(iter); }; - Repeat.prototype.slice = function(begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) ? this : - new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size)); + Stack.prototype.shift = function() { + return this.pop.apply(this, arguments); }; - Repeat.prototype.reverse = function() { - return this; + Stack.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); }; - Repeat.prototype.indexOf = function(searchValue) { - if (is(this._value, searchValue)) { - return 0; + Stack.prototype.slice = function(begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; } - return -1; + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); }; - Repeat.prototype.lastIndexOf = function(searchValue) { - if (is(this._value, searchValue)) { - return this.size; + // @pragma Mutability + + Stack.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; } - return -1; + if (!ownerID) { + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); }; - Repeat.prototype.__iterate = function(fn, reverse) { - for (var ii = 0; ii < this.size; ii++) { - if (fn(this._value, ii, this) === false) { - return ii + 1; + // @pragma Iteration + + Stack.prototype.__iterate = function(fn, reverse) { + if (reverse) { + return this.reverse().__iterate(fn); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this) === false) { + break; } + node = node.next; } - return ii; + return iterations; }; - Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this; - var ii = 0; - return new src_Iterator__Iterator(function() - {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()} - ); + Stack.prototype.__iterator = function(type, reverse) { + if (reverse) { + return this.reverse().__iterator(type); + } + var iterations = 0; + var node = this._head; + return new Iterator(function() { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); }; - Repeat.prototype.equals = function(other) { - return other instanceof Repeat ? - is(this._value, other._value) : - deepEqual(other); - }; + function isStack(maybeStack) { + return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); + } + + Stack.isStack = isStack; - var EMPTY_REPEAT; + var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; + + var StackPrototype = Stack.prototype; + StackPrototype[IS_STACK_SENTINEL] = true; + StackPrototype.withMutations = MapPrototype.withMutations; + StackPrototype.asMutable = MapPrototype.asMutable; + StackPrototype.asImmutable = MapPrototype.asImmutable; + StackPrototype.wasAltered = MapPrototype.wasAltered; + + + function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; + } + + var EMPTY_STACK; + function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); + } /** * Contributes additional methods to a constructor @@ -4701,7 +4648,7 @@ return /******/ (function(modules) { // webpackBootstrap return ctor; } - Iterable.Iterator = src_Iterator__Iterator; + Iterable.Iterator = Iterator; mixin(Iterable, { @@ -4736,7 +4683,7 @@ return /******/ (function(modules) { // webpackBootstrap toMap: function() { // Use Late Binding here to solve the circular dependency. - return src_Map__Map(this.toKeyedSeq()); + return Map(this.toKeyedSeq()); }, toObject: function() { @@ -4758,7 +4705,7 @@ return /******/ (function(modules) { // webpackBootstrap toSet: function() { // Use Late Binding here to solve the circular dependency. - return src_Set__Set(isKeyed(this) ? this.valueSeq() : this); + return Set(isKeyed(this) ? this.valueSeq() : this); }, toSetSeq: function() { @@ -5223,7 +5170,11 @@ return /******/ (function(modules) { // webpackBootstrap }, lastIndexOf: function(searchValue) { - return this.toSeq().reverse().indexOf(searchValue); + var key = this.toKeyedSeq().reverse().keyOf(searchValue); + return key === undefined ? -1 : key; + + // var index = + // return this.toSeq().reverse().indexOf(searchValue); }, reverse: function() { @@ -5414,12 +5365,12 @@ return /******/ (function(modules) { // webpackBootstrap } function murmurHashOfSize(size, h) { - h = src_Math__imul(h, 0xCC9E2D51); - h = src_Math__imul(h << 15 | h >>> -15, 0x1B873593); - h = src_Math__imul(h << 13 | h >>> -13, 5); + h = imul(h, 0xCC9E2D51); + h = imul(h << 15 | h >>> -15, 0x1B873593); + h = imul(h << 13 | h >>> -13, 5); h = (h + 0xE6546B64 | 0) ^ size; - h = src_Math__imul(h ^ h >>> 16, 0x85EBCA6B); - h = src_Math__imul(h ^ h >>> 13, 0xC2B2AE35); + h = imul(h ^ h >>> 16, 0x85EBCA6B); + h = imul(h ^ h >>> 13, 0xC2B2AE35); h = smi(h ^ h >>> 16); return h; } @@ -5434,11 +5385,11 @@ return /******/ (function(modules) { // webpackBootstrap Seq: Seq, Collection: Collection, - Map: src_Map__Map, + Map: Map, OrderedMap: OrderedMap, List: List, Stack: Stack, - Set: src_Set__Set, + Set: Set, OrderedSet: OrderedSet, Record: Record, @@ -5455,7 +5406,7 @@ return /******/ (function(modules) { // webpackBootstrap })); /***/ }, -/* 8 */ +/* 7 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -5464,7 +5415,7 @@ return /******/ (function(modules) { // webpackBootstrap value: true }); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); exports['default'] = function (value) { if (_immutable.Iterable.isIterable(value)) { @@ -5476,6 +5427,72 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + 'use strict'; + + /** + * 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 = function() {}; + + if ((undefined) !== 'production') { + warning = function(condition, format, args) { + var len = arguments.length; + args = new Array(len > 2 ? len - 2 : 0); + for (var key = 2; key < len; key++) { + args[key - 2] = arguments[key]; + } + if (format === undefined) { + throw new Error( + '`warning(condition, format, ...args)` requires a warning ' + + 'message argument' + ); + } + + if (format.length < 10 || (/^[s\W]*$/).test(format)) { + throw new Error( + 'The warning format should be able to uniquely identify this ' + + 'warning. Please, use a more descriptive format than: ' + format + ); + } + + if (!condition) { + var argIndex = 0; + var message = 'Warning: ' + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // 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) {} + } + }; + } + + module.exports = warning; + + /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { @@ -5492,6 +5509,27 @@ return /******/ (function(modules) { // webpackBootstrap var _qs2 = _interopRequireDefault(_qs); + var _warning = __webpack_require__(8); + + var _warning2 = _interopRequireDefault(_warning); + + function parseBody(response) { + return response.text().then(function (text) { + if (!text || !text.length) { + (0, _warning2['default'])(response.status === 204, 'You should return a 204 status code with an empty body.'); + return null; + } + + (0, _warning2['default'])(response.status !== 204, 'You should return an empty body with a 204 status code.'); + + try { + return JSON.parse(text); + } catch (error) { + return text; + } + }); + } + exports['default'] = function (fetch) { return function (config) { var url = config.url; @@ -5506,16 +5544,38 @@ return /******/ (function(modules) { // webpackBootstrap delete config.params; return fetch(!queryString.length ? url : url + '?' + queryString, config).then(function (response) { - return (response.status === 204 ? Promise.resolve(null) : response.json()).then(function (json) { + return parseBody(response).then(function (json) { var headers = {}; + var keys = response.headers.keys(); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; - response.headers.forEach(function (value, name) { - headers[name] = value; - }); + try { + for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + headers[key] = response.headers.get(key); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } var responsePayload = { data: json, headers: headers, + method: config.method ? config.method.toLowerCase() : 'get', statusCode: response.status }; @@ -6121,9 +6181,9 @@ return /******/ (function(modules) { // webpackBootstrap var _objectAssign2 = _interopRequireDefault(_objectAssign); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); - var _utilSerialize = __webpack_require__(8); + var _utilSerialize = __webpack_require__(7); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); @@ -6183,6 +6243,74 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, /* 15 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.custom = custom; + exports.collection = collection; + exports.member = member; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _objectAssign = __webpack_require__(3); + + var _objectAssign2 = _interopRequireDefault(_objectAssign); + + function custom(endpoint) { + return function (name) { + var relative = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; + + if (relative) { + return member(endpoint['new'](endpoint.url() + '/' + name)); // eslint-disable-line no-use-before-define + } + + return member(endpoint['new'](name)); // eslint-disable-line no-use-before-define + }; + } + + function collection(endpoint) { + function _bindHttpMethod(method) { + return function () { + var _member; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var id = args.shift(); + return (_member = member(endpoint['new'](endpoint.url() + '/' + id)))[method].apply(_member, args); // eslint-disable-line no-use-before-define + }; + } + + return (0, _objectAssign2['default'])(endpoint, { + custom: custom(endpoint), + 'delete': _bindHttpMethod('delete'), + getAll: endpoint.get, + get: _bindHttpMethod('get'), + head: _bindHttpMethod('head'), + patch: _bindHttpMethod('patch'), + put: _bindHttpMethod('put') + }); + } + + function member(endpoint) { + return (0, _objectAssign2['default'])(endpoint, { + all: function all(name) { + return collection(endpoint['new'](endpoint.url() + '/' + name)); + }, + custom: custom(endpoint), + one: function one(name, id) { + return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); + } + }); + } + +/***/ }, +/* 16 */ /***/ function(module, exports) { 'use strict'; @@ -6239,7 +6367,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 16 */ +/* 17 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -6249,9 +6377,9 @@ return /******/ (function(modules) { // webpackBootstrap }); exports['default'] = scopeFactory; - var _events = __webpack_require__(17); + var _events = __webpack_require__(18); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); /* eslint-disable new-cap */ @@ -6326,7 +6454,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 17 */ +/* 18 */ /***/ function(module, exports) { // Copyright Joyent, Inc. and other Node contributors. diff --git a/dist/restful.min.js b/dist/restful.min.js index 75610ae..6afa334 100644 --- a/dist/restful.min.js +++ b/dist/restful.min.js @@ -1,3 +1,3 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.restful=e():t.restful=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),o=n(i);e["default"]=o["default"],t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=v["default"]();r.assign("config","entityIdentifier","id"),!t&&"undefined"!=typeof window&&window.location?r.set("url",window.location.protocol+"//"+window.location.host):r.set("url",t);var n=h.member(u["default"](c["default"](e))(r));return d.push(n),n}Object.defineProperty(e,"__esModule",{value:!0});var o=r(4),u=n(o),s=r(9),a=n(s),f=r(14),c=n(f),h=r(2),p=r(15),l=n(p),_=r(16),v=n(_),d=[];i._instances=function(){return d},i._flush=function(){return d.length=0},e.fetchBackend=a["default"],e.requestBackend=l["default"],e["default"]=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return function(e){var r=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return u(r?t["new"](t.url()+"/"+e):t["new"](e))}}function o(t){function e(e){return function(){for(var r,n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];var s=i.shift();return(r=u(t["new"](t.url()+"/"+s)))[e].apply(r,i)}}return a["default"](t,{custom:i(t),"delete":e("delete"),getAll:t.get,get:e("get"),head:e("head"),one:function(e,r){return u(t["new"](t.url()+"/"+e+"/"+r))},patch:e("patch"),put:e("put")})}function u(t){return a["default"](t,{all:function(e){return o(t["new"](t.url()+"/"+e))},custom:i(t),one:function(e,r){return u(t["new"](t.url()+"/"+e+"/"+r))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.custom=i,e.collection=o,e.member=u;var s=r(3),a=n(s)},function(t,e){"use strict";function r(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t,e){for(var n,i,o=r(t),u=1;ui;i++)n[i]=arguments[i];return e.put.apply(e,[t].concat(n))},url:e.url}},t.exports=e["default"]},function(t,e,r){!function(e,r){t.exports=r()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=new Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function o(t){return void 0===t.size&&(t.size=t.__iterate(s)),t.size}function u(t,e){if("number"!=typeof e){var r=+e;if(""+r!==e)return NaN;e=r}return 0>e?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function f(t,e){return h(t,e,0)}function c(t,e){return h(t,e,e)}function h(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function p(t){return d(t)?t:E(t)}function l(t){return y(t)?t:q(t)}function _(t){return m(t)?t:D(t)}function v(t){return d(t)&&!g(t)?t:A(t)}function d(t){return!(!t||!t[_r])}function y(t){return!(!t||!t[vr])}function m(t){return!(!t||!t[dr])}function g(t){return y(t)||m(t)}function w(t){return!(!t||!t[yr])}function b(t){this.next=t}function I(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function z(t){return!!M(t)}function O(t){return t&&"function"==typeof t.next}function x(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(br&&t[br]||t[Ir]);return"function"==typeof e?e:void 0}function j(t){return t&&"number"==typeof t.length}function E(t){return null===t||void 0===t?P():d(t)?t.toSeq():C(t)}function q(t){return null===t||void 0===t?P().toKeyedSeq():d(t)?y(t)?t.toSeq():t.fromEntrySeq():K(t)}function D(t){return null===t||void 0===t?P():d(t)?y(t)?t.entrySeq():t.toIndexedSeq():N(t)}function A(t){return(null===t||void 0===t?P():d(t)?y(t)?t.entrySeq():t:N(t)).toSetSeq()}function k(t){this._array=t,this.size=t.length}function L(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function T(t){this._iterable=t,this.size=t.length||t.size}function R(t){this._iterator=t,this._iteratorCache=[]}function U(t){return!(!t||!t[zr])}function P(){return Or||(Or=new k([]))}function K(t){var e=Array.isArray(t)?new k(t).fromEntrySeq():O(t)?new R(t).fromEntrySeq():z(t)?new T(t).fromEntrySeq():"object"==typeof t?new L(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function N(t){var e=B(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function C(t){var e=B(t)||"object"==typeof t&&new L(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function B(t){return j(t)?new k(t):O(t)?new R(t):z(t)?new T(t):void 0}function W(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function H(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new b(function(){var t=i[r?o-u:u];return u++>o?S():I(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function J(){throw TypeError("Abstract")}function V(){}function F(){}function G(){}function Y(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function Q(t,e){return e?X(e,t,"",{"":t}):$(t)}function X(t,e,r,n){return Array.isArray(e)?t.call(n,r,D(e).map(function(r,n){return X(t,r,n,e)})):Z(e)?t.call(n,r,q(e).map(function(r,n){return X(t,r,n,e)})):e}function $(t){return Array.isArray(t)?D(t).map($).toList():Z(t)?q(t).map($).toMap():t}function Z(t){return t&&(t.constructor===Object||void 0===t.constructor)}function tt(t){return t>>>1&1073741824|3221225471&t}function et(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return tt(r)}return"string"===e?t.length>kr?rt(t):nt(t):"function"==typeof t.hashCode?t.hashCode():it(t)}function rt(t){var e=Rr[t];return void 0===e&&(e=nt(t),Tr===Lr&&(Tr=0,Rr={}),Tr++,Rr[t]=e),e}function nt(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ut(t,e){if(!t)throw new Error(e)}function st(t){ut(t!==1/0,"Cannot perform this action with an infinite size.")}function at(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ft(t){this._iter=t,this.size=t.size}function ct(t){this._iter=t,this.size=t.size}function ht(t){this._iter=t,this.size=t.size}function pt(t){var e=kt(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Lt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===wr){var n=t.__iterator(e,r);return new b(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===gr?mr:gr,r)},e}function lt(t,e,r){var n=kt(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,hr);return o===hr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(wr,i);return new b(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return I(n,s,e.call(r,u[1],s,t),i)})},n}function _t(t,e){var r=kt(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=pt(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=Lt,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function vt(t,e,r,n){var i=kt(t);return n&&(i.has=function(n){var i=t.get(n,hr);return i!==hr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,hr);return o!==hr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(wr,o),s=0;return new b(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,f=a[0],c=a[1];if(e.call(r,c,f,t))return I(i,n?f:s++,c,o)}})},i}function dt(t,e,r){var n=Ut().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function yt(t,e,r){var n=y(t),i=(w(t)?Se():Ut()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=At(t);return i.map(function(e){return Et(t,o(e))})}function mt(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),a(e,r,i))return t;var o=f(e,i),s=c(r,i);if(o!==o||s!==s)return mt(t.toSeq().cacheResult(),e,r,n);var h,p=s-o;p===p&&(h=0>p?0:p);var l=kt(t);return l.size=0===h?h:t.size&&h||void 0,!n&&U(t)&&h>=0&&(l.get=function(e,r){return e=u(this,e),e>=0&&h>e?t.get(e+o,r):r}),l.__iterateUncached=function(e,r){var i=this;if(0===h)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,s=!0,a=0;return t.__iterate(function(t,r){return s&&(s=u++h)return S();var t=i.next();return n||e===gr?t:e===mr?I(e,s-1,void 0,t):I(e,s-1,t.value[1],t)})},l}function gt(t,e,r){var n=kt(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(wr,i),s=!0;return new b(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],f=i[1];return e.call(r,f,a,o)?n===wr?t:I(n,a,f,t):(s=!1,S())})},n}function wt(t,e,r,n){var i=kt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,f){return s&&(s=e.call(r,t,o,f))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(wr,o),a=!0,f=0;return new b(function(){var t,o,c;do{if(t=s.next(),t.done)return n||i===gr?t:i===mr?I(i,f++,void 0,t):I(i,f++,t.value[1],t);var h=t.value;o=h[0],c=h[1],a&&(a=e.call(r,c,o,u))}while(a);return i===wr?t:I(i,o,c,t)})},i}function bt(t,e){var r=y(t),n=[t].concat(e).map(function(t){return d(t)?r&&(t=l(t)):t=r?K(t):N(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&y(i)||m(t)&&m(i))return i}var o=new k(n);return r?o=o.toKeyedSeq():m(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function It(t,e,r){var n=kt(t);return n.__iterateUncached=function(n,i){function o(t,a){var f=this;t.__iterate(function(t,i){return(!e||e>a)&&d(t)?o(t,a+1):n(t,r?i:u++,f)===!1&&(s=!0),!s},i)}var u=0,s=!1;return o(t,0),u},n.__iteratorUncached=function(n,i){var o=t.__iterator(n,i),u=[],s=0;return new b(function(){for(;o;){var t=o.next();if(t.done===!1){var a=t.value;if(n===wr&&(a=a[1]),e&&!(u.length0}function jt(t,e,r){var n=kt(t);return n.size=new k(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this.__iterator(gr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=p(t),x(n?t.reverse():t)}),o=0,u=!1;return new b(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?S():I(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function Et(t,e){return U(t)?e:t.constructor(e)}function qt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Dt(t){return st(t.size),o(t)}function At(t){return y(t)?l:m(t)?_:v}function kt(t){return Object.create((y(t)?q:m(t)?D:A).prototype)}function Lt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):E.prototype.cacheResult.call(this)}function Tt(t,e){return t>e?1:e>t?-1:0}function Rt(t){var e=x(t);if(!e){if(!j(t))throw new TypeError("Expected iterable or array-like: "+t);e=x(p(t))}return e}function Ut(t){return null===t||void 0===t?Gt():Pt(t)&&!w(t)?t:Gt().withMutations(function(e){var r=l(t);st(r.size),r.forEach(function(t,r){return e.set(r,t)})})}function Pt(t){return!(!t||!t[Ur])}function Kt(t,e){this.ownerID=t,this.entries=e}function Nt(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function Ct(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function Bt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function Wt(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function Ht(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&Vt(t._root)}function Jt(t,e){return I(t,e[0],e[1])}function Vt(t,e){return{node:t,index:0,__prev:e}}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Kr||(Kr=Ft(0))}function Yt(t,r,n){var i,o;if(t._root){var u=e(pr),s=e(lr);if(i=Qt(t._root,t.__ownerID,0,void 0,r,n,u,s),!s.value)return t;o=t.size+(u.value?n===hr?-1:1:0)}else{if(n===hr)return t;o=1,i=new Kt(t.__ownerID,[[r,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Ft(o,i):Gt()}function Qt(t,e,n,i,o,u,s,a){return t?t.update(e,n,i,o,u,s,a):u===hr?t:(r(a),r(s),new Wt(e,i,[o,u]))}function Xt(t){return t.constructor===Wt||t.constructor===Bt}function $t(t,e,r,n,i){if(t.keyHash===n)return new Bt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&cr,s=(0===r?n:n>>>r)&cr,a=u===s?[$t(t,e,r+ar,n,i)]:(o=new Wt(e,n,i),s>u?[t,o]:[o,t]);return new Nt(e,1<s;s++,a<<=1){var c=e[s];void 0!==c&&s!==n&&(i|=a,u[o++]=c)}return new Nt(t,i,u)}function ee(t,e,r,n,i){for(var o=0,u=new Array(fr),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Ct(t,o+1,u)}function re(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function se(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function ae(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function fe(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function ce(t){var e=ve();if(null===t||void 0===t)return e;if(he(t))return t;var r=_(t),n=r.size;return 0===n?e:(st(n),n>0&&fr>n?_e(0,n,ar,null,new pe(r.toArray())):e.withMutations(function(t){t.setSize(n),r.forEach(function(e,r){return t.set(r,e)})}))}function he(t){return!(!t||!t[Wr])}function pe(t,e){this.array=t,this.ownerID=e}function le(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,f=u-r;return f>fr&&(f=fr),function(){if(i===f)return Vr;var t=e?--f:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,f=i>o?0:o-i>>n,c=(u-i>>n)+1;return c>fr&&(c=fr),function(){for(;;){if(s){var t=s();if(t!==Vr)return t;s=null}if(f===c)return Vr;var o=e?--c:f++;s=r(a&&a[o],n-ar,i+(o<=t.size||0>r)return t.withMutations(function(t){0>r?we(t,r).set(0,n):we(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(lr);return r>=Ie(t._capacity)?i=ye(i,t.__ownerID,0,r,n,s):o=ye(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):_e(t._origin,t._capacity,t._level,o,i):t}function ye(t,e,n,i,o,u){var s=i>>>n&cr,a=t&&s0){var c=t&&t.array[s],h=ye(c,e,n-ar,i,o,u);return h===c?t:(f=me(t,e),f.array[s]=h,f)}return a&&t.array[s]===o?t:(r(u),f=me(t,e),void 0===o&&s===f.array.length-1?f.array.pop():f.array[s]=o,f)}function me(t,e){return e&&t&&e===t.ownerID?t:new pe(t?t.array.slice():[],e)}function ge(t,e){if(e>=Ie(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&cr],n-=ar;return r}}function we(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:0>r?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var f=t._level,c=t._root,h=0;0>s+h;)c=new pe(c&&c.array.length?[void 0,c]:[],i),f+=ar,h+=1<=1<l?ge(t,a-1):l>p?new pe([],i):_;if(_&&l>p&&u>s&&_.array.length){c=me(c,i);for(var d=c,y=f;y>ar;y-=ar){var m=p>>>y&cr;d=d.array[m]=me(d.array[m],i)}d.array[p>>>ar&cr]=_}if(u>a&&(v=v&&v.removeAfter(i,0,a)),s>=l)s-=l,a-=l,f=ar,c=null,v=v&&v.removeBefore(i,0,s);else if(s>o||p>l){for(h=0;c;){var g=s>>>f&cr;if(g!==l>>>f&cr)break;g&&(h+=(1<o&&(c=c.removeBefore(i,f,s-h)),c&&p>l&&(c=c.removeAfter(i,f,l-h)),h&&(s-=h,a-=h)}return t.__ownerID?(t.size=a-s,t._origin=s,t._capacity=a,t._level=f,t._root=c,t._tail=v,t.__hash=void 0,t.__altered=!0,t):_e(s,a,f,c,v)}function be(t,e,r){for(var n=[],i=0,o=0;oi&&(i=s.size),d(u)||(s=s.map(function(t){return Q(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)),ie(t,e,n)}function Ie(t){return fr>t?0:t-1>>>ar<=fr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Oe(n,i)}function je(t){return null===t||void 0===t?De():Ee(t)?t:De().unshiftAll(t)}function Ee(t){return!(!t||!t[Gr])}function qe(t,e,r,n){var i=Object.create(Yr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function De(){return Qr||(Qr=qe(0))}function Ae(t){return null===t||void 0===t?Re():ke(t)&&!w(t)?t:Re().withMutations(function(e){var r=v(t);st(r.size),r.forEach(function(t){return e.add(t)})})}function ke(t){return!(!t||!t[Xr])}function Le(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Te(t,e){var r=Object.create($r);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Re(){return Zr||(Zr=Te(Gt()))}function Ue(t){return null===t||void 0===t?Ne():Pe(t)?t:Ne().withMutations(function(e){var r=v(t);st(r.size),r.forEach(function(t){return e.add(t)})})}function Pe(t){return ke(t)&&w(t)}function Ke(t,e){var r=Object.create(tn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ne(){return en||(en=Ke(xe()))}function Ce(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);He(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=Ut(o)},i=n.prototype=Object.create(rn);return i.constructor=n,n}function Be(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function We(t){return t._name||t.constructor.name||"Record"}function He(t,e){try{e.forEach(Je.bind(void 0,t))}catch(r){}}function Je(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ut(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Ve(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||y(t)!==y(e)||m(t)!==m(e)||w(t)!==w(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!g(t);if(w(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&Y(i[1],t)&&(r||Y(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){return(r?t.has(e):i?Y(e,t.get(n,hr)):Y(t.get(n,hr),e))?void 0:(u=!1,!1)});return u&&t.size===s}function Fe(t,e,r){if(!(this instanceof Fe))return new Fe(t,e,r);if(ut(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(nn)return nn;nn=this}}function Ge(t,e){if(!(this instanceof Ge))return new Ge(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(on)return on;on=this}}function Ye(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Qe(t,e){return e}function Xe(t,e){return[e,t]}function $e(t){return function(){return!t.apply(this,arguments)}}function Ze(t){return function(){return-t.apply(this,arguments)}}function tr(t){return"string"==typeof t?JSON.stringify(t):t}function er(){return i(arguments)}function rr(t,e){return e>t?1:t>e?-1:0}function nr(t){if(t.size===1/0)return 0;var e=w(t),r=y(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+or(et(t),et(e))|0}:function(t,e){n=n+or(et(t),et(e))|0}:e?function(t){n=31*n+et(t)|0}:function(t){n=n+et(t)|0});return ir(i,n)}function ir(t,e){return e=Mr(e,3432918353),e=Mr(e<<15|e>>>-15,461845907),e=Mr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Mr(e^e>>>16,2246822507),e=Mr(e^e>>>13,3266489909),e=tt(e^e>>>16)}function or(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var ur=Array.prototype.slice,sr="delete",ar=5,fr=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},k.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new b(function(){return i>n?S():I(t,i,r[e?n-i++:i++])})},t(L,q),L.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},L.prototype.has=function(t){return this._object.hasOwnProperty(t)},L.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){ -var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},L.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new b(function(){var u=n[e?i-o:o];return o++>i?S():I(t,u,r[u])})},L.prototype[yr]=!0,t(T,D),T.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=this._iterable,n=x(r),i=0;if(O(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},T.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=x(r);if(!O(n))return new b(S);var i=0;return new b(function(){var e=n.next();return e.done?e:I(t,i++,e.value)})},t(R,D),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return I(t,i,n[i++])})};var Or;t(J,p),t(V,J),t(F,J),t(G,J),J.Keyed=V,J.Indexed=F,J.Set=G;var xr,Mr="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},jr=Object.isExtensible,Er=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),qr="function"==typeof WeakMap;qr&&(xr=new WeakMap);var Dr=0,Ar="__immutablehash__";"function"==typeof Symbol&&(Ar=Symbol(Ar));var kr=16,Lr=255,Tr=0,Rr={};t(at,q),at.prototype.get=function(t,e){return this._iter.get(t,e)},at.prototype.has=function(t){return this._iter.has(t)},at.prototype.valueSeq=function(){return this._iter.valueSeq()},at.prototype.reverse=function(){var t=this,e=_t(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},at.prototype.map=function(t,e){var r=this,n=lt(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},at.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?Dt(this):0,function(i){return t(i,e?--r:r++,n)}),e)},at.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(gr,e),n=e?Dt(this):0;return new b(function(){var i=r.next();return i.done?i:I(t,e?--n:n++,i.value,i)})},at.prototype[yr]=!0,t(ft,D),ft.prototype.includes=function(t){return this._iter.includes(t)},ft.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ft.prototype.__iterator=function(t,e){var r=this._iter.__iterator(gr,e),n=0;return new b(function(){var e=r.next();return e.done?e:I(t,n++,e.value,e)})},t(ct,A),ct.prototype.has=function(t){return this._iter.includes(t)},ct.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},ct.prototype.__iterator=function(t,e){var r=this._iter.__iterator(gr,e);return new b(function(){var e=r.next();return e.done?e:I(t,e.value,e.value,e)})},t(ht,q),ht.prototype.entrySeq=function(){return this._iter.toSeq()},ht.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){qt(e);var n=d(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ht.prototype.__iterator=function(t,e){var r=this._iter.__iterator(gr,e);return new b(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){qt(n);var i=d(n);return I(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ft.prototype.cacheResult=at.prototype.cacheResult=ct.prototype.cacheResult=ht.prototype.cacheResult=Lt,t(Ut,V),Ut.prototype.toString=function(){return this.__toString("Map {","}")},Ut.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Ut.prototype.set=function(t,e){return Yt(this,t,e)},Ut.prototype.setIn=function(t,e){return this.updateIn(t,hr,function(){return e})},Ut.prototype.remove=function(t){return Yt(this,t,hr)},Ut.prototype.deleteIn=function(t){return this.updateIn(t,function(){return hr})},Ut.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},Ut.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=oe(this,Rt(t),e,r);return n===hr?void 0:n},Ut.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Gt()},Ut.prototype.merge=function(){return re(this,void 0,arguments)},Ut.prototype.mergeWith=function(t){var e=ur.call(arguments,1);return re(this,t,e)},Ut.prototype.mergeIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},Ut.prototype.mergeDeep=function(){return re(this,ne(void 0),arguments)},Ut.prototype.mergeDeepWith=function(t){var e=ur.call(arguments,1);return re(this,ne(t),e)},Ut.prototype.mergeDeepIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},Ut.prototype.sort=function(t){return Se(Ot(this,t))},Ut.prototype.sortBy=function(t,e){return Se(Ot(this,e,t))},Ut.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Ut.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},Ut.prototype.asImmutable=function(){return this.__ensureOwner()},Ut.prototype.wasAltered=function(){return this.__altered},Ut.prototype.__iterator=function(t,e){return new Ht(this,t,e)},Ut.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},Ut.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ut.isMap=Pt;var Ur="@@__IMMUTABLE_MAP__@@",Pr=Ut.prototype;Pr[Ur]=!0,Pr[sr]=Pr.remove,Pr.removeIn=Pr.deleteIn,Kt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(Y(r,i[o][0]))return i[o][1];return n},Kt.prototype.update=function(t,e,n,o,u,s,a){for(var f=u===hr,c=this.entries,h=0,p=c.length;p>h&&!Y(o,c[h][0]);h++);var l=p>h;if(l?c[h][1]===u:f)return this;if(r(a),(f||!l)&&r(s),!f||1!==c.length){if(!l&&!f&&c.length>=Nr)return Zt(t,c,o,u);var _=t&&t===this.ownerID,v=_?c:i(c);return l?f?h===p-1?v.pop():v[h]=v.pop():v[h]=[o,u]:v.push([o,u]),_?(this.entries=v,this):new Kt(t,v)}},Nt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=1<<((0===t?e:e>>>t)&cr),o=this.bitmap;return 0===(o&i)?n:this.nodes[ue(o&i-1)].get(t+ar,e,r,n)},Nt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var s=(0===e?r:r>>>e)&cr,a=1<=Cr)return ee(t,p,f,s,_);if(c&&!_&&2===p.length&&Xt(p[1^h]))return p[1^h];if(c&&_&&1===p.length&&Xt(_))return _;var v=t&&t===this.ownerID,d=c?_?f:f^a:f|a,y=c?_?se(p,h,_,v):fe(p,h,v):ae(p,h,_,v);return v?(this.bitmap=d,this.nodes=y,this):new Nt(t,d,y)},Ct.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=(0===t?e:e>>>t)&cr,o=this.nodes[i];return o?o.get(t+ar,e,r,n):n},Ct.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var s=(0===e?r:r>>>e)&cr,a=i===hr,f=this.nodes,c=f[s];if(a&&!c)return this;var h=Qt(c,t,e+ar,r,n,i,o,u);if(h===c)return this;var p=this.count;if(c){if(!h&&(p--,Br>p))return te(t,f,p,s)}else p++;var l=t&&t===this.ownerID,_=se(f,s,h,l);return l?(this.count=p,this.nodes=_,this):new Ct(t,p,_)},Bt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(Y(r,i[o][0]))return i[o][1];return n},Bt.prototype.update=function(t,e,n,o,u,s,a){void 0===n&&(n=et(o));var f=u===hr;if(n!==this.keyHash)return f?this:(r(a),r(s),$t(this,t,e,n,[o,u]));for(var c=this.entries,h=0,p=c.length;p>h&&!Y(o,c[h][0]);h++);var l=p>h;if(l?c[h][1]===u:f)return this;if(r(a),(f||!l)&&r(s),f&&2===p)return new Wt(t,this.keyHash,c[1^h]);var _=t&&t===this.ownerID,v=_?c:i(c);return l?f?h===p-1?v.pop():v[h]=v.pop():v[h]=[o,u]:v.push([o,u]),_?(this.entries=v,this):new Bt(t,this.keyHash,v)},Wt.prototype.get=function(t,e,r,n){return Y(r,this.entry[0])?this.entry[1]:n},Wt.prototype.update=function(t,e,n,i,o,u,s){var a=o===hr,f=Y(i,this.entry[0]);return(f?o===this.entry[1]:a)?this:(r(s),a?void r(u):f?t&&t===this.ownerID?(this.entry[1]=o,this):new Wt(t,this.keyHash,[i,o]):(r(u),$t(this,t,e,et(i),[i,o])))},Kt.prototype.iterate=Bt.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},Nt.prototype.iterate=Ct.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},Wt.prototype.iterate=function(t,e){return t(this.entry)},t(Ht,b),Ht.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return Jt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return Jt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return Jt(t,o.entry);e=this._stack=Vt(o,e)}continue}e=this._stack=this._stack.__prev}return S()};var Kr,Nr=fr/4,Cr=fr/2,Br=fr/4;t(ce,F),ce.of=function(){return this(arguments)},ce.prototype.toString=function(){return this.__toString("List [","]")},ce.prototype.get=function(t,e){if(t=u(this,t),t>=0&&t>>e&cr;if(n>=this.array.length)return new pe([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-ar,r),i===u&&o)return this}if(o&&!i)return this;var s=me(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},pe.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&cr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-ar,r),i===o&&n===this.array.length-1)return this}var u=me(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Jr,Vr={};t(Se,Ut),Se.of=function(){return this(arguments)},Se.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Se.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Se.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):xe()},Se.prototype.set=function(t,e){return Me(this,t,e)},Se.prototype.remove=function(t){return Me(this,t,hr)},Se.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Se.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Se.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Se.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Oe(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Se.isOrderedMap=ze,Se.prototype[yr]=!0,Se.prototype[sr]=Se.prototype.remove;var Fr;t(je,F),je.of=function(){return this(arguments)},je.prototype.toString=function(){return this.__toString("Stack [","]")},je.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},je.prototype.peek=function(){return this._head&&this._head.value},je.prototype.push=function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):qe(t,e)},je.prototype.pushAll=function(t){if(t=_(t),0===t.size)return this;st(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):qe(e,r)},je.prototype.pop=function(){return this.slice(1)},je.prototype.unshift=function(){return this.push.apply(this,arguments)},je.prototype.unshiftAll=function(t){return this.pushAll(t)},je.prototype.shift=function(){return this.pop.apply(this,arguments)},je.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):De()},je.prototype.slice=function(t,e){if(a(t,e,this.size))return this;var r=f(t,this.size),n=c(e,this.size);if(n!==this.size)return F.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):qe(i,o)},je.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?qe(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},je.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},je.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new b(function(){if(n){var e=n.value;return n=n.next,I(t,r++,e)}return S()})},je.isStack=Ee;var Gr="@@__IMMUTABLE_STACK__@@",Yr=je.prototype;Yr[Gr]=!0,Yr.withMutations=Pr.withMutations,Yr.asMutable=Pr.asMutable,Yr.asImmutable=Pr.asImmutable,Yr.wasAltered=Pr.wasAltered;var Qr;t(Ae,G),Ae.of=function(){return this(arguments)},Ae.fromKeys=function(t){return this(l(t).keySeq())},Ae.prototype.toString=function(){return this.__toString("Set {","}")},Ae.prototype.has=function(t){return this._map.has(t)},Ae.prototype.add=function(t){return Le(this,this._map.set(t,!0))},Ae.prototype.remove=function(t){return Le(this,this._map.remove(t))},Ae.prototype.clear=function(){return Le(this,this._map.clear())},Ae.prototype.union=function(){var t=ur.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;r1?" by "+this._step:"")+" ]"},Fe.prototype.get=function(t,e){return this.has(t)?this._start+u(this,t)*this._step:e},Fe.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&e=e?new Fe(0,0):new Fe(this.get(t,this._end),this.get(e,this._end),this._step))},Fe.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&r=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},Fe.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new b(function(){var u=i;return i+=e?-n:n,o>r?S():I(t,o++,u)})},Fe.prototype.equals=function(t){return t instanceof Fe?this._start===t._start&&this._end===t._end&&this._step===t._step:Ve(this,t)};var nn;t(Ge,D),Ge.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},Ge.prototype.get=function(t,e){return this.has(t)?this._value:e},Ge.prototype.includes=function(t){return Y(this._value,t)},Ge.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:new Ge(this._value,c(e,r)-f(t,r))},Ge.prototype.reverse=function(){return this},Ge.prototype.indexOf=function(t){return Y(this._value,t)?0:-1},Ge.prototype.lastIndexOf=function(t){return Y(this._value,t)?this.size:-1},Ge.prototype.__iterate=function(t,e){for(var r=0;rt?this.count():this.size);var n=this.slice(0,t);return Et(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return Et(this,It(this,t,!1))},get:function(t,e){return t=u(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=u(this,t),t>=0&&(void 0!==this.size?this.size===1/0||t=200&&t.status<300)return n;var i=new Error(t.statusText);throw i.response=n,i})})}},t.exports=e["default"]},function(t,e,r){var n=r(11),i=r(13);t.exports={stringify:n,parse:i}},function(t,e,r){var n=r(12),i={delimiter:"&",arrayPrefixGenerators:{brackets:function(t,e){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t,e){return t}},strictNullHandling:!1,skipNulls:!1,encode:!0};i.stringify=function(t,e,r,o,u,s,a,f){if("function"==typeof a)t=a(e,t);else if(n.isBuffer(t))t=t.toString();else if(t instanceof Date)t=t.toISOString();else if(null===t){if(o)return s?n.encode(e):e;t=""}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return s?[n.encode(e)+"="+n.encode(t)]:[e+"="+t];var c=[];if("undefined"==typeof t)return c;var h;if(Array.isArray(a))h=a;else{var p=Object.keys(t);h=f?p.sort(f):p}for(var l=0,_=h.length;_>l;++l){var v=h[l];u&&null===t[v]||(c=Array.isArray(t)?c.concat(i.stringify(t[v],r(e,v),r,o,u,s,a)):c.concat(i.stringify(t[v],e+"["+v+"]",r,o,u,s,a)))}return c}, -t.exports=function(t,e){e=e||{};var r,n,o="undefined"==typeof e.delimiter?i.delimiter:e.delimiter,u="boolean"==typeof e.strictNullHandling?e.strictNullHandling:i.strictNullHandling,s="boolean"==typeof e.skipNulls?e.skipNulls:i.skipNulls,a="boolean"==typeof e.encode?e.encode:i.encode,f="function"==typeof e.sort?e.sort:null;"function"==typeof e.filter?(n=e.filter,t=n("",t)):Array.isArray(e.filter)&&(r=n=e.filter);var c=[];if("object"!=typeof t||null===t)return"";var h;h=e.arrayFormat in i.arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":"indices";var p=i.arrayPrefixGenerators[h];r||(r=Object.keys(t)),f&&r.sort(f);for(var l=0,_=r.length;_>l;++l){var v=r[l];s&&null===t[v]||(c=c.concat(i.stringify(t[v],v,p,u,s,a,n,f)))}return c.join(o)}},function(t,e){var r={};r.hexTable=new Array(256);for(var n=0;256>n;++n)r.hexTable[n]="%"+((16>n?"0":"")+n.toString(16)).toUpperCase();e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},n=0,i=t.length;i>n;++n)"undefined"!=typeof t[n]&&(r[n]=t[n]);return r},e.merge=function(t,r,n){if(!r)return t;if("object"!=typeof r)return Array.isArray(t)?t.push(r):"object"==typeof t?t[r]=!0:t=[t,r],t;if("object"!=typeof t)return t=[t].concat(r);Array.isArray(t)&&!Array.isArray(r)&&(t=e.arrayToObject(t,n));for(var i=Object.keys(r),o=0,u=i.length;u>o;++o){var s=i[o],a=r[s];Object.prototype.hasOwnProperty.call(t,s)?t[s]=e.merge(t[s],a,n):t[s]=a}return t},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;"string"!=typeof t&&(t=""+t);for(var e="",n=0,i=t.length;i>n;++n){var o=t.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&57>=o||o>=65&&90>=o||o>=97&&122>=o?e+=t[n]:128>o?e+=r.hexTable[o]:2048>o?e+=r.hexTable[192|o>>6]+r.hexTable[128|63&o]:55296>o||o>=57344?e+=r.hexTable[224|o>>12]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o]:(++n,o=65536+((1023&o)<<10|1023&t.charCodeAt(n)),e+=r.hexTable[240|o>>18]+r.hexTable[128|o>>12&63]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o])}return e},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;r=r||[];var n=r.indexOf(t);if(-1!==n)return r[n];if(r.push(t),Array.isArray(t)){for(var i=[],o=0,u=t.length;u>o;++o)"undefined"!=typeof t[o]&&i.push(t[o]);return i}var s=Object.keys(t);for(o=0,u=s.length;u>o;++o){var a=s[o];t[a]=e.compact(t[a],r)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null===t||"undefined"==typeof t?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e,r){var n=r(12),i={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1};i.parseValues=function(t,e){for(var r={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),o=0,u=i.length;u>o;++o){var s=i[o],a=-1===s.indexOf("]=")?s.indexOf("="):s.indexOf("]=")+1;if(-1===a)r[n.decode(s)]="",e.strictNullHandling&&(r[n.decode(s)]=null);else{var f=n.decode(s.slice(0,a)),c=n.decode(s.slice(a+1));Object.prototype.hasOwnProperty.call(r,f)?r[f]=[].concat(r[f]).concat(c):r[f]=c}}return r},i.parseObject=function(t,e,r){if(!t.length)return e;var n,o=t.shift();if("[]"===o)n=[],n=n.concat(i.parseObject(t,e,r));else{n=r.plainObjects?Object.create(null):{};var u="["===o[0]&&"]"===o[o.length-1]?o.slice(1,o.length-1):o,s=parseInt(u,10),a=""+s;!isNaN(s)&&o!==u&&a===u&&s>=0&&r.parseArrays&&s<=r.arrayLimit?(n=[],n[s]=i.parseObject(t,e,r)):n[u]=i.parseObject(t,e,r)}return n},i.parseKeys=function(t,e,r){if(t){r.allowDots&&(t=t.replace(/\.([^\.\[]+)/g,"[$1]"));var n=/^([^\[\]]*)/,o=/(\[[^\[\]]*\])/g,u=n.exec(t),s=[];if(u[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(u[1])&&!r.allowPrototypes)return;s.push(u[1])}for(var a=0;null!==(u=o.exec(t))&&as;++s){var f=u[s],c=i.parseKeys(f,r[f],e);o=n.merge(o,c,e)}return n.compact(o)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e1?n-1:0),o=1;n>o;o++)i[o-1]=arguments[o];r.apply(void 0,[t+":"+e].concat(i))}}var i=a.List(e.get("errorInterceptors")),u=a.List(e.get("requestInterceptors")),s=a.List(e.get("responseInterceptors")),f=e["delete"]("errorInterceptors")["delete"]("requestInterceptors")["delete"]("responseInterceptors");return o(n("request:interceptor"),u,f).then(function(e){return r("request",c["default"](e)),t(c["default"](e)).then(function(t){return o(n("response:interceptor"),s,a.fromJS(t),[c["default"](e)])})}).then(null,function(t){return o(n("error:interceptor"),i,t,[c["default"](f)]).then(function(t){return Promise.reject(t)})})}},t.exports=e["default"]},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=function(t){return function(e){return e.data&&(e.form=/application\/json/.test(e.headers["Content-Type"])?JSON.stringify(e.data):e.data,delete e.data),e.params&&(e.qs=e.params,delete e.params),new Promise(function(r,n){t(e,function(t,e,i){if(t)throw t;var o=void 0;try{o=JSON.parse(i)}catch(u){o=i}var s={data:o,headers:e.headers,statusCode:e.statusCode};if(e.statusCode>=200&&e.statusCode<300)return r(s);var a=new Error(e.statusMessage);a.response=s,n(a)})})}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){var e=o.Map(),r=new i.EventEmitter,u={assign:function(t,r,n){return u.has(t)||u.set(t,o.Map()),e=e.setIn([t,r],n),u},emit:function(){r.emit.apply(r,arguments),t&&t.emit.apply(t,arguments)},get:function(r){var n=e.get(r);if(u.has(r)&&!o.Iterable.isIterable(n)||!t)return n;if(!u.has(r)&&t)return t.get(r);var i=t.get(r);return i?o.List.isList(i)?i.concat(n):i.mergeDeep(n):n},has:function(t){return e.has(t)},"new":function(){return n(u)},on:r.on.bind(r),once:r.once.bind(r),push:function(t,r){return u.has(t)||u.set(t,o.List()),e=e.update(t,function(t){return t.push(r)}),u},set:function(t,r){return e=e.set(t,r),u}};return u}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(17),o=r(7);t.exports=e["default"]},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function u(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,s,a,f;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],u(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];r.apply(this,s)}else if(o(r)){for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];for(f=r.slice(),i=f.length,a=0;i>a;a++)f[a].apply(this,s)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,u,s;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],u=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=u;s-->0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.restful=e():t.restful=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),o=n(i);e["default"]=o["default"],t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=(0,v["default"])();r.assign("config","entityIdentifier","id"),!t&&"undefined"!=typeof window&&window.location?r.set("url",window.location.protocol+"//"+window.location.host):r.set("url",t);var n=(0,h.member)((0,u["default"])((0,c["default"])(e))(r));return d.push(n),n}Object.defineProperty(e,"__esModule",{value:!0});var o=r(2),u=n(o),s=r(9),a=n(s),f=r(14),c=n(f),h=r(15),p=r(16),l=n(p),_=r(17),v=n(_),d=[];i._instances=function(){return d},i._flush=function(){return d.length=0},e.fetchBackend=a["default"],e.requestBackend=l["default"],e["default"]=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),o=n(i),u=r(4),s=n(u),a=r(6),f=r(7),c=n(f);e["default"]=function(t){return function e(r){function n(t,e,n,i){var o=(0,a.Map)({errorInterceptors:(0,a.List)(r.get("errorInterceptors")),headers:(0,a.Map)(r.get("headers")).mergeDeep((0,a.Map)(i)),method:t,params:n,requestInterceptors:(0,a.List)(r.get("requestInterceptors")),responseInterceptors:(0,a.List)(r.get("responseInterceptors")),url:r.get("url")});return e&&(o.hasIn(["headers","Content-Type"])||(o=o.setIn(["headers","Content-Type"],"application/json;charset=UTF-8")),o=o.set("data",(0,a.fromJS)(e))),o}function i(t,e){var n=(0,s["default"])(e,p);return r.emit("response",n,(0,c["default"])(t)),n}function u(t,e){throw r.emit("error",e,(0,c["default"])(t)),e}function f(e){var o=arguments.length<=1||void 0===arguments[1]?!0:arguments[1],s=function(){r.emit.apply(r,arguments)};return o?function(r){var o=arguments.length<=1||void 0===arguments[1]?null:arguments[1],a=arguments.length<=2||void 0===arguments[2]?null:arguments[2],f=n(e,r,o,a);return t(f,s).then(function(t){return i(f,t)},function(t){return u(f,t)})}:function(){var r=arguments.length<=0||void 0===arguments[0]?null:arguments[0],o=arguments.length<=1||void 0===arguments[1]?null:arguments[1],a=n(e,null,r,o);return t(a,s).then(function(t){return i(a,t)},function(t){return u(a,t)})}}function h(t){return function(e){return r.push(t+"Interceptors",e),p}}r.on("error",function(){return!0});var p={};return(0,o["default"])(p,{addErrorInterceptor:h("error"),addRequestInterceptor:h("request"),addResponseInterceptor:h("response"),"delete":f("delete"),identifier:function(t){return void 0===t?r.get("config").get("entityIdentifier"):(r.assign("config","entityIdentifier",t),p)},get:f("get",!1),head:f("head",!1),header:function(t,e){return r.assign("headers",t,e)},headers:function(){return r.get("headers")},"new":function(t){var n=r["new"]();return n.set("url",t),e(n)},on:r.on,once:r.once,patch:f("patch"),post:f("post"),put:f("put"),url:function(){return r.get("url")}}),p}},t.exports=e["default"]},function(t,e){"use strict";function r(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t,e){for(var n,i,o=r(t),u=1;ui;i++)n[i]=arguments[i];return e.put.apply(e,[t].concat(n))},url:e.url}},t.exports=e["default"]},function(t,e,r){!function(e,r){t.exports=r()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return o(t)?t:q(t)}function r(t){return u(t)?t:E(t)}function n(t){return s(t)?t:D(t)}function i(t){return o(t)&&!a(t)?t:A(t)}function o(t){return!(!t||!t[ar])}function u(t){return!(!t||!t[fr])}function s(t){return!(!t||!t[cr])}function a(t){return u(t)||s(t)}function f(t){return!(!t||!t[hr])}function c(t){return t.value=!1,t}function h(t){t&&(t.value=!0)}function p(){}function l(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=new Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function _(t){return void 0===t.size&&(t.size=t.__iterate(d)),t.size}function v(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return 0>e?_(t)+e:e}function d(){return!0}function y(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function m(t,e){return w(t,e,0)}function g(t,e){return w(t,e,e)}function w(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function b(t){this.next=t}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!M(t)}function O(t){return t&&"function"==typeof t.next}function x(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Sr&&t[Sr]||t[Ir]);return"function"==typeof e?e:void 0}function j(t){return t&&"number"==typeof t.length}function q(t){return null===t||void 0===t?P():o(t)?t.toSeq():C(t)}function E(t){return null===t||void 0===t?P().toKeyedSeq():o(t)?u(t)?t.toSeq():t.fromEntrySeq():K(t)}function D(t){return null===t||void 0===t?P():o(t)?u(t)?t.entrySeq():t.toIndexedSeq():N(t)}function A(t){return(null===t||void 0===t?P():o(t)?u(t)?t.entrySeq():t:N(t)).toSetSeq()}function k(t){this._array=t,this.size=t.length}function L(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function T(t){this._iterable=t,this.size=t.length||t.size}function R(t){this._iterator=t,this._iteratorCache=[]}function U(t){return!(!t||!t[Or])}function P(){return xr||(xr=new k([]))}function K(t){var e=Array.isArray(t)?new k(t).fromEntrySeq():O(t)?new R(t).fromEntrySeq():z(t)?new T(t).fromEntrySeq():"object"==typeof t?new L(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function N(t){var e=B(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function C(t){var e=B(t)||"object"==typeof t&&new L(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function B(t){return j(t)?new k(t):O(t)?new R(t):z(t)?new T(t):void 0}function W(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function J(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new b(function(){var t=i[r?o-u:u];return u++>o?I():S(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function H(t,e){return e?V(e,t,"",{"":t}):F(t)}function V(t,e,r,n){return Array.isArray(e)?t.call(n,r,D(e).map(function(r,n){return V(t,r,n,e)})):Y(e)?t.call(n,r,E(e).map(function(r,n){return V(t,r,n,e)})):e}function F(t){return Array.isArray(t)?D(t).map(F).toList():Y(t)?E(t).map(F).toMap():t}function Y(t){return t&&(t.constructor===Object||void 0===t.constructor)}function G(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function Q(t,e){if(t===e)return!0;if(!o(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||u(t)!==u(e)||s(t)!==s(e)||f(t)!==f(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!a(t);if(f(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&G(i[1],t)&&(r||G(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var c=t;t=e,e=c}var h=!0,p=e.__iterate(function(e,n){return(r?t.has(e):i?G(e,t.get(n,dr)):G(t.get(n,dr),e))?void 0:(h=!1,!1)});return h&&t.size===p}function X(t,e){if(!(this instanceof X))return new X(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(Mr)return Mr;Mr=this}}function $(t,e){if(!t)throw new Error(e)}function Z(t,e,r){if(!(this instanceof Z))return new Z(t,e,r);if($(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(jr)return jr;jr=this}}function tt(){throw TypeError("Abstract")}function et(){}function rt(){}function nt(){}function it(t){return t>>>1&1073741824|3221225471&t}function ot(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return it(r)}if("string"===e)return t.length>Rr?ut(t):st(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return at(t);if("function"==typeof t.toString)return st(t.toString());throw new Error("Value type "+e+" cannot be hashed.")}function ut(t){var e=Kr[t];return void 0===e&&(e=st(t),Pr===Ur&&(Pr=0,Kr={}),Pr++,Kr[t]=e),e}function st(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ct(t){$(t!==1/0,"Cannot perform this action with an infinite size.")}function ht(t){return null===t||void 0===t?St():pt(t)&&!f(t)?t:St().withMutations(function(e){var n=r(t);ct(n.size),n.forEach(function(t,r){return e.set(r,t)})})}function pt(t){return!(!t||!t[Nr])}function lt(t,e){this.ownerID=t,this.entries=e}function _t(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function vt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function dt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function yt(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function mt(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&wt(t._root)}function gt(t,e){return S(t,e[0],e[1])}function wt(t,e){return{node:t,index:0,__prev:e}}function bt(t,e,r,n){var i=Object.create(Cr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function St(){return Br||(Br=bt(0))}function It(t,e,r){var n,i;if(t._root){var o=c(yr),u=c(mr);if(n=zt(t._root,t.__ownerID,0,void 0,e,r,o,u),!u.value)return t;i=t.size+(o.value?r===dr?-1:1:0)}else{if(r===dr)return t;i=1,n=new lt(t.__ownerID,[[e,r]])}return t.__ownerID?(t.size=i,t._root=n,t.__hash=void 0,t.__altered=!0,t):n?bt(i,n):St()}function zt(t,e,r,n,i,o,u,s){return t?t.update(e,r,n,i,o,u,s):o===dr?t:(h(s),h(u),new yt(e,n,[i,o]))}function Ot(t){return t.constructor===yt||t.constructor===dt}function xt(t,e,r,n,i){if(t.keyHash===n)return new dt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&vr,s=(0===r?n:n>>>r)&vr,a=u===s?[xt(t,e,r+lr,n,i)]:(o=new yt(e,n,i),s>u?[t,o]:[o,t]);return new _t(e,1<s;s++,a<<=1){var c=e[s];void 0!==c&&s!==n&&(i|=a,u[o++]=c)}return new _t(t,i,u)}function qt(t,e,r,n,i){for(var o=0,u=new Array(_r),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new vt(t,o+1,u)}function Et(t,e,n){for(var i=[],u=0;u>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function Rt(t,e,r,n){var i=n?t:l(t);return i[e]=r,i}function Ut(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function Pt(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function Kt(t){var e=Jt();if(null===t||void 0===t)return e;if(Nt(t))return t;var r=n(t),i=r.size;return 0===i?e:(ct(i),i>0&&_r>i?Wt(0,i,lr,null,new Ct(r.toArray())):e.withMutations(function(t){t.setSize(i),r.forEach(function(e,r){return t.set(r,e)})}))}function Nt(t){return!(!t||!t[Vr])}function Ct(t,e){this.array=t,this.ownerID=e}function Bt(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,f=u-r;return f>_r&&(f=_r),function(){if(i===f)return Gr;var t=e?--f:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,f=i>o?0:o-i>>n,c=(u-i>>n)+1;return c>_r&&(c=_r),function(){for(;;){if(s){var t=s();if(t!==Gr)return t;s=null}if(f===c)return Gr;var o=e?--c:f++;s=r(a&&a[o],n-lr,i+(o<=t.size||0>e)return t.withMutations(function(t){0>e?Gt(t,e).set(0,r):Gt(t,0,e+1).set(e,r)});e+=t._origin;var n=t._tail,i=t._root,o=c(mr);return e>=Xt(t._capacity)?n=Vt(n,t.__ownerID,0,e,r,o):i=Vt(i,t.__ownerID,t._level,e,r,o),o.value?t.__ownerID?(t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t):Wt(t._origin,t._capacity,t._level,i,n):t}function Vt(t,e,r,n,i,o){var u=n>>>r&vr,s=t&&u0){var f=t&&t.array[u],c=Vt(f,e,r-lr,n,i,o);return c===f?t:(a=Ft(t,e),a.array[u]=c,a)}return s&&t.array[u]===i?t:(h(o),a=Ft(t,e),void 0===i&&u===a.array.length-1?a.array.pop():a.array[u]=i,a)}function Ft(t,e){return e&&t&&e===t.ownerID?t:new Ct(t?t.array.slice():[],e)}function Yt(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&vr],n-=lr;return r}}function Gt(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var n=t.__ownerID||new p,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:0>r?o+r:i+r;if(u===i&&s===o)return t;if(u>=s)return t.clear();for(var a=t._level,f=t._root,c=0;0>u+c;)f=new Ct(f&&f.array.length?[void 0,f]:[],n),a+=lr,c+=1<=1<l?Yt(t,s-1):l>h?new Ct([],n):_;if(_&&l>h&&o>u&&_.array.length){f=Ft(f,n);for(var d=f,y=a;y>lr;y-=lr){var m=h>>>y&vr;d=d.array[m]=Ft(d.array[m],n)}d.array[h>>>lr&vr]=_}if(o>s&&(v=v&&v.removeAfter(n,0,s)),u>=l)u-=l,s-=l,a=lr,f=null,v=v&&v.removeBefore(n,0,u);else if(u>i||h>l){for(c=0;f;){var g=u>>>a&vr;if(g!==l>>>a&vr)break;g&&(c+=(1<i&&(f=f.removeBefore(n,a,u-c)),f&&h>l&&(f=f.removeAfter(n,a,l-c)),c&&(u-=c,s-=c)}return t.__ownerID?(t.size=s-u,t._origin=u,t._capacity=s,t._level=a,t._root=f,t._tail=v,t.__hash=void 0,t.__altered=!0,t):Wt(u,s,a,f,v)}function Qt(t,e,r){for(var i=[],u=0,s=0;su&&(u=f.size),o(a)||(f=f.map(function(t){return H(t)})),i.push(f)}return u>t.size&&(t=t.setSize(u)),kt(t,e,i)}function Xt(t){return _r>t?0:t-1>>>lr<=_r&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):te(n,i)}function ne(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ie(t){this._iter=t,this.size=t.size}function oe(t){this._iter=t,this.size=t.size}function ue(t){this._iter=t,this.size=t.size}function se(t){var e=je(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=qe,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===br){var n=t.__iterator(e,r);return new b(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===wr?gr:wr,r)},e}function ae(t,e,r){var n=je(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,dr);return o===dr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(br,i);return new b(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function fe(t,e){var r=je(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=se(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=qe,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function ce(t,e,r,n){var i=je(t);return n&&(i.has=function(n){var i=t.get(n,dr);return i!==dr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,dr);return o!==dr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(br,o),s=0;return new b(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,f=a[0],c=a[1];if(e.call(r,c,f,t))return S(i,n?f:s++,c,o)}})},i}function he(t,e,r){var n=ht().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function pe(t,e,r){var n=u(t),i=(f(t)?$t():ht()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=Me(t);return i.map(function(e){return ze(t,o(e))})}function le(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),y(e,r,i))return t;var o=m(e,i),u=g(r,i);if(o!==o||u!==u)return le(t.toSeq().cacheResult(),e,r,n);var s,a=u-o;a===a&&(s=0>a?0:a);var f=je(t);return f.size=0===s?s:t.size&&s||void 0,!n&&U(t)&&s>=0&&(f.get=function(e,r){return e=v(this,e),e>=0&&s>e?t.get(e+o,r):r}),f.__iterateUncached=function(e,r){var i=this;if(0===s)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,a=!0,f=0;return t.__iterate(function(t,r){return a&&(a=u++s)return I();var t=i.next();return n||e===wr?t:e===gr?S(e,a-1,void 0,t):S(e,a-1,t.value[1],t)})},f}function _e(t,e,r){var n=je(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(br,i),s=!0;return new b(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],f=i[1];return e.call(r,f,a,o)?n===br?t:S(n,a,f,t):(s=!1,I())})},n}function ve(t,e,r,n){var i=je(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,f){return s&&(s=e.call(r,t,o,f))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(br,o),a=!0,f=0;return new b(function(){var t,o,c;do{if(t=s.next(),t.done)return n||i===wr?t:i===gr?S(i,f++,void 0,t):S(i,f++,t.value[1],t);var h=t.value;o=h[0],c=h[1],a&&(a=e.call(r,c,o,u))}while(a);return i===br?t:S(i,o,c,t)})},i}function de(t,e){var n=u(t),i=[t].concat(e).map(function(t){return o(t)?n&&(t=r(t)):t=n?K(t):N(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===i.length)return t;if(1===i.length){var a=i[0];if(a===t||n&&u(a)||s(t)&&s(a))return a}var f=new k(i);return n?f=f.toKeyedSeq():s(t)||(f=f.toSetSeq()),f=f.flatten(!0),f.size=i.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),f}function ye(t,e,r){var n=je(t);return n.__iterateUncached=function(n,i){function u(t,f){var c=this;t.__iterate(function(t,i){return(!e||e>f)&&o(t)?u(t,f+1):n(t,r?i:s++,c)===!1&&(a=!0),!a},i)}var s=0,a=!1;return u(t,0),s},n.__iteratorUncached=function(n,i){var u=t.__iterator(n,i),s=[],a=0;return new b(function(){for(;u;){var t=u.next();if(t.done===!1){var f=t.value;if(n===br&&(f=f[1]),e&&!(s.length0}function Ie(t,r,n){var i=je(t);return i.size=new k(n).map(function(t){return t.size}).min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(wr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},i.__iteratorUncached=function(t,i){var o=n.map(function(t){return t=e(t),x(i?t.reverse():t)}),u=0,s=!1;return new b(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=e.some(function(t){return t.done})),s?I():S(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function ze(t,e){return U(t)?e:t.constructor(e)}function Oe(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function xe(t){return ct(t.size),_(t)}function Me(t){return u(t)?r:s(t)?n:i}function je(t){return Object.create((u(t)?E:s(t)?D:A).prototype)}function qe(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):q.prototype.cacheResult.call(this)}function Ee(t,e){return t>e?1:e>t?-1:0}function De(t){var r=x(t);if(!r){if(!j(t))throw new TypeError("Expected iterable or array-like: "+t);r=x(e(t))}return r}function Ae(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);Te(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=ht(o)},i=n.prototype=Object.create(Xr);return i.constructor=n,n}function ke(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function Le(t){return t._name||t.constructor.name||"Record"}function Te(t,e){try{e.forEach(Re.bind(void 0,t))}catch(r){}}function Re(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){$(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Ue(t){return null===t||void 0===t?Ce():Pe(t)&&!f(t)?t:Ce().withMutations(function(e){var r=i(t);ct(r.size),r.forEach(function(t){return e.add(t)})})}function Pe(t){return!(!t||!t[$r])}function Ke(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Ne(t,e){var r=Object.create(Zr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ce(){return tn||(tn=Ne(St()))}function Be(t){return null===t||void 0===t?He():We(t)?t:He().withMutations(function(e){var r=i(t);ct(r.size),r.forEach(function(t){return e.add(t)})})}function We(t){return Pe(t)&&f(t)}function Je(t,e){var r=Object.create(en);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function He(){return rn||(rn=Je(ee()))}function Ve(t){return null===t||void 0===t?Ge():Fe(t)?t:Ge().unshiftAll(t)}function Fe(t){return!(!t||!t[nn])}function Ye(t,e,r,n){var i=Object.create(on);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Ge(){return un||(un=Ye(0))}function Qe(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Xe(t,e){return e}function $e(t,e){return[e,t]}function Ze(t){return function(){return!t.apply(this,arguments)}}function tr(t){return function(){return-t.apply(this,arguments)}}function er(t){return"string"==typeof t?JSON.stringify(t):t}function rr(){return l(arguments)}function nr(t,e){return e>t?1:t>e?-1:0}function ir(t){if(t.size===1/0)return 0;var e=f(t),r=u(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+ur(ot(t),ot(e))|0}:function(t,e){n=n+ur(ot(t),ot(e))|0}:e?function(t){n=31*n+ot(t)|0}:function(t){n=n+ot(t)|0});return or(i,n)}function or(t,e){return e=Er(e,3432918353),e=Er(e<<15|e>>>-15,461845907),e=Er(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Er(e^e>>>16,2246822507),e=Er(e^e>>>13,3266489909),e=it(e^e>>>16)}function ur(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var sr=Array.prototype.slice;t(r,e),t(n,e),t(i,e),e.isIterable=o,e.isKeyed=u,e.isIndexed=s,e.isAssociative=a,e.isOrdered=f,e.Keyed=r,e.Indexed=n,e.Set=i;var ar="@@__IMMUTABLE_ITERABLE__@@",fr="@@__IMMUTABLE_KEYED__@@",cr="@@__IMMUTABLE_INDEXED__@@",hr="@@__IMMUTABLE_ORDERED__@@",pr="delete",lr=5,_r=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},k.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new b(function(){return i>n?I():S(t,i,r[e?n-i++:i++])})},t(L,E),L.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},L.prototype.has=function(t){return this._object.hasOwnProperty(t)},L.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},L.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new b(function(){var u=n[e?i-o:o];return o++>i?I():S(t,u,r[u])})},L.prototype[hr]=!0,t(T,D),T.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=this._iterable,n=x(r),i=0;if(O(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},T.prototype.__iteratorUncached=function(t,e){ +if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=x(r);if(!O(n))return new b(I);var i=0;return new b(function(){var e=n.next();return e.done?e:S(t,i++,e.value)})},t(R,D),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})};var xr;t(X,D),X.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},X.prototype.get=function(t,e){return this.has(t)?this._value:e},X.prototype.includes=function(t){return G(this._value,t)},X.prototype.slice=function(t,e){var r=this.size;return y(t,e,r)?this:new X(this._value,g(e,r)-m(t,r))},X.prototype.reverse=function(){return this},X.prototype.indexOf=function(t){return G(this._value,t)?0:-1},X.prototype.lastIndexOf=function(t){return G(this._value,t)?this.size:-1},X.prototype.__iterate=function(t,e){for(var r=0;r1?" by "+this._step:"")+" ]"},Z.prototype.get=function(t,e){return this.has(t)?this._start+v(this,t)*this._step:e},Z.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&e=e?new Z(0,0):new Z(this.get(t,this._end),this.get(e,this._end),this._step))},Z.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&r=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},Z.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new b(function(){var u=i;return i+=e?-n:n,o>r?I():S(t,o++,u)})},Z.prototype.equals=function(t){return t instanceof Z?this._start===t._start&&this._end===t._end&&this._step===t._step:Q(this,t)};var jr;t(tt,e),t(et,tt),t(rt,tt),t(nt,tt),tt.Keyed=et,tt.Indexed=rt,tt.Set=nt;var qr,Er="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},Dr=Object.isExtensible,Ar=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),kr="function"==typeof WeakMap;kr&&(qr=new WeakMap);var Lr=0,Tr="__immutablehash__";"function"==typeof Symbol&&(Tr=Symbol(Tr));var Rr=16,Ur=255,Pr=0,Kr={};t(ht,et),ht.prototype.toString=function(){return this.__toString("Map {","}")},ht.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},ht.prototype.set=function(t,e){return It(this,t,e)},ht.prototype.setIn=function(t,e){return this.updateIn(t,dr,function(){return e})},ht.prototype.remove=function(t){return It(this,t,dr)},ht.prototype.deleteIn=function(t){return this.updateIn(t,function(){return dr})},ht.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},ht.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Lt(this,De(t),e,r);return n===dr?void 0:n},ht.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},ht.prototype.merge=function(){return Et(this,void 0,arguments)},ht.prototype.mergeWith=function(t){var e=sr.call(arguments,1);return Et(this,t,e)},ht.prototype.mergeIn=function(t){var e=sr.call(arguments,1);return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},ht.prototype.mergeDeep=function(){return Et(this,Dt,arguments)},ht.prototype.mergeDeepWith=function(t){var e=sr.call(arguments,1);return Et(this,At(t),e)},ht.prototype.mergeDeepIn=function(t){var e=sr.call(arguments,1);return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},ht.prototype.sort=function(t){return $t(we(this,t))},ht.prototype.sortBy=function(t,e){return $t(we(this,e,t))},ht.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},ht.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new p)},ht.prototype.asImmutable=function(){return this.__ensureOwner()},ht.prototype.wasAltered=function(){return this.__altered},ht.prototype.__iterator=function(t,e){return new mt(this,t,e)},ht.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},ht.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?bt(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},ht.isMap=pt;var Nr="@@__IMMUTABLE_MAP__@@",Cr=ht.prototype;Cr[Nr]=!0,Cr[pr]=Cr.remove,Cr.removeIn=Cr.deleteIn,lt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(G(r,i[o][0]))return i[o][1];return n},lt.prototype.update=function(t,e,r,n,i,o,u){for(var s=i===dr,a=this.entries,f=0,c=a.length;c>f&&!G(n,a[f][0]);f++);var p=c>f;if(p?a[f][1]===i:s)return this;if(h(u),(s||!p)&&h(o),!s||1!==a.length){if(!p&&!s&&a.length>=Wr)return Mt(t,a,n,i);var _=t&&t===this.ownerID,v=_?a:l(a);return p?s?f===c-1?v.pop():v[f]=v.pop():v[f]=[n,i]:v.push([n,i]),_?(this.entries=v,this):new lt(t,v)}},_t.prototype.get=function(t,e,r,n){void 0===e&&(e=ot(r));var i=1<<((0===t?e:e>>>t)&vr),o=this.bitmap;return 0===(o&i)?n:this.nodes[Tt(o&i-1)].get(t+lr,e,r,n)},_t.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=(0===e?r:r>>>e)&vr,a=1<=Jr)return qt(t,p,f,s,_);if(c&&!_&&2===p.length&&Ot(p[1^h]))return p[1^h];if(c&&_&&1===p.length&&Ot(_))return _;var v=t&&t===this.ownerID,d=c?_?f:f^a:f|a,y=c?_?Rt(p,h,_,v):Pt(p,h,v):Ut(p,h,_,v);return v?(this.bitmap=d,this.nodes=y,this):new _t(t,d,y)},vt.prototype.get=function(t,e,r,n){void 0===e&&(e=ot(r));var i=(0===t?e:e>>>t)&vr,o=this.nodes[i];return o?o.get(t+lr,e,r,n):n},vt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=(0===e?r:r>>>e)&vr,a=i===dr,f=this.nodes,c=f[s];if(a&&!c)return this;var h=zt(c,t,e+lr,r,n,i,o,u);if(h===c)return this;var p=this.count;if(c){if(!h&&(p--,Hr>p))return jt(t,f,p,s)}else p++;var l=t&&t===this.ownerID,_=Rt(f,s,h,l);return l?(this.count=p,this.nodes=_,this):new vt(t,p,_)},dt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(G(r,i[o][0]))return i[o][1];return n},dt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=i===dr;if(r!==this.keyHash)return s?this:(h(u),h(o),xt(this,t,e,r,[n,i]));for(var a=this.entries,f=0,c=a.length;c>f&&!G(n,a[f][0]);f++);var p=c>f;if(p?a[f][1]===i:s)return this;if(h(u),(s||!p)&&h(o),s&&2===c)return new yt(t,this.keyHash,a[1^f]);var _=t&&t===this.ownerID,v=_?a:l(a);return p?s?f===c-1?v.pop():v[f]=v.pop():v[f]=[n,i]:v.push([n,i]),_?(this.entries=v,this):new dt(t,this.keyHash,v)},yt.prototype.get=function(t,e,r,n){return G(r,this.entry[0])?this.entry[1]:n},yt.prototype.update=function(t,e,r,n,i,o,u){var s=i===dr,a=G(n,this.entry[0]);return(a?i===this.entry[1]:s)?this:(h(u),s?void h(o):a?t&&t===this.ownerID?(this.entry[1]=i,this):new yt(t,this.keyHash,[n,i]):(h(o),xt(this,t,e,ot(n),[n,i])))},lt.prototype.iterate=dt.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},_t.prototype.iterate=vt.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},yt.prototype.iterate=function(t,e){return t(this.entry)},t(mt,b),mt.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return gt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return gt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return gt(t,o.entry);e=this._stack=wt(o,e)}continue}e=this._stack=this._stack.__prev}return I()};var Br,Wr=_r/4,Jr=_r/2,Hr=_r/4;t(Kt,rt),Kt.of=function(){return this(arguments)},Kt.prototype.toString=function(){return this.__toString("List [","]")},Kt.prototype.get=function(t,e){if(t=v(this,t),t>=0&&t>>e&vr;if(n>=this.array.length)return new Ct([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-lr,r),i===u&&o)return this}if(o&&!i)return this;var s=Ft(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},Ct.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&vr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-lr,r),i===o&&n===this.array.length-1)return this}var u=Ft(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Yr,Gr={};t($t,ht),$t.of=function(){return this(arguments)},$t.prototype.toString=function(){return this.__toString("OrderedMap {","}")},$t.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},$t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ee()},$t.prototype.set=function(t,e){return re(this,t,e)},$t.prototype.remove=function(t){return re(this,t,dr)},$t.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},$t.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},$t.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},$t.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?te(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},$t.isOrderedMap=Zt,$t.prototype[hr]=!0,$t.prototype[pr]=$t.prototype.remove;var Qr;t(ne,E),ne.prototype.get=function(t,e){return this._iter.get(t,e)},ne.prototype.has=function(t){return this._iter.has(t)},ne.prototype.valueSeq=function(){return this._iter.valueSeq()},ne.prototype.reverse=function(){var t=this,e=fe(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},ne.prototype.map=function(t,e){var r=this,n=ae(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},ne.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?xe(this):0,function(i){return t(i,e?--r:r++,n)}),e)},ne.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(wr,e),n=e?xe(this):0;return new b(function(){var i=r.next();return i.done?i:S(t,e?--n:n++,i.value,i)})},ne.prototype[hr]=!0,t(ie,D),ie.prototype.includes=function(t){return this._iter.includes(t)},ie.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ie.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e),n=0;return new b(function(){var e=r.next();return e.done?e:S(t,n++,e.value,e)})},t(oe,A),oe.prototype.has=function(t){return this._iter.includes(t)},oe.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},oe.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e);return new b(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},t(ue,E),ue.prototype.entrySeq=function(){return this._iter.toSeq()},ue.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){Oe(e);var n=o(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ue.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e);return new b(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){Oe(n);var i=o(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ie.prototype.cacheResult=ne.prototype.cacheResult=oe.prototype.cacheResult=ue.prototype.cacheResult=qe,t(Ae,et),Ae.prototype.toString=function(){return this.__toString(Le(this)+" {","}")},Ae.prototype.has=function(t){return this._defaultValues.hasOwnProperty(t)},Ae.prototype.get=function(t,e){if(!this.has(t))return e;var r=this._defaultValues[t];return this._map?this._map.get(t,r):r},Ae.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var t=this.constructor;return t._empty||(t._empty=ke(this,St()))},Ae.prototype.set=function(t,e){if(!this.has(t))throw new Error('Cannot set unknown key "'+t+'" on '+Le(this));var r=this._map&&this._map.set(t,e);return this.__ownerID||r===this._map?this:ke(this,r)},Ae.prototype.remove=function(t){if(!this.has(t))return this;var e=this._map&&this._map.remove(t);return this.__ownerID||e===this._map?this:ke(this,e)},Ae.prototype.wasAltered=function(){return this._map.wasAltered()},Ae.prototype.__iterator=function(t,e){var n=this;return r(this._defaultValues).map(function(t,e){return n.get(e)}).__iterator(t,e)},Ae.prototype.__iterate=function(t,e){var n=this;return r(this._defaultValues).map(function(t,e){return n.get(e)}).__iterate(t,e)},Ae.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map&&this._map.__ensureOwner(t);return t?ke(this,e,t):(this.__ownerID=t,this._map=e,this)};var Xr=Ae.prototype;Xr[pr]=Xr.remove,Xr.deleteIn=Xr.removeIn=Cr.removeIn,Xr.merge=Cr.merge,Xr.mergeWith=Cr.mergeWith,Xr.mergeIn=Cr.mergeIn,Xr.mergeDeep=Cr.mergeDeep,Xr.mergeDeepWith=Cr.mergeDeepWith,Xr.mergeDeepIn=Cr.mergeDeepIn,Xr.setIn=Cr.setIn,Xr.update=Cr.update,Xr.updateIn=Cr.updateIn,Xr.withMutations=Cr.withMutations,Xr.asMutable=Cr.asMutable,Xr.asImmutable=Cr.asImmutable,t(Ue,nt),Ue.of=function(){return this(arguments)},Ue.fromKeys=function(t){return this(r(t).keySeq())},Ue.prototype.toString=function(){return this.__toString("Set {","}")},Ue.prototype.has=function(t){return this._map.has(t)},Ue.prototype.add=function(t){return Ke(this,this._map.set(t,!0))},Ue.prototype.remove=function(t){return Ke(this,this._map.remove(t))},Ue.prototype.clear=function(){return Ke(this,this._map.clear())},Ue.prototype.union=function(){var t=sr.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;r=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):Ye(t,e)},Ve.prototype.pushAll=function(t){if(t=n(t),0===t.size)return this;ct(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ye(e,r)},Ve.prototype.pop=function(){return this.slice(1)},Ve.prototype.unshift=function(){return this.push.apply(this,arguments)},Ve.prototype.unshiftAll=function(t){return this.pushAll(t)},Ve.prototype.shift=function(){return this.pop.apply(this,arguments)},Ve.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Ge()},Ve.prototype.slice=function(t,e){if(y(t,e,this.size))return this;var r=m(t,this.size),n=g(e,this.size);if(n!==this.size)return rt.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ye(i,o)},Ve.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ye(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ve.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Ve.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new b(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return I()})},Ve.isStack=Fe;var nn="@@__IMMUTABLE_STACK__@@",on=Ve.prototype;on[nn]=!0,on.withMutations=Cr.withMutations,on.asMutable=Cr.asMutable,on.asImmutable=Cr.asImmutable,on.wasAltered=Cr.wasAltered;var un;e.Iterator=b,Qe(e,{toArray:function(){ct(this.size);var t=new Array(this.size||0);return this.valueSeq().__iterate(function(e,r){t[r]=e}),t},toIndexedSeq:function(){return new ie(this)},toJS:function(){return this.toSeq().map(function(t){return t&&"function"==typeof t.toJS?t.toJS():t}).__toJS()},toJSON:function(){return this.toSeq().map(function(t){return t&&"function"==typeof t.toJSON?t.toJSON():t}).__toJS()},toKeyedSeq:function(){return new ne(this,!0)},toMap:function(){return ht(this.toKeyedSeq())},toObject:function(){ct(this.size);var t={};return this.__iterate(function(e,r){t[r]=e}),t},toOrderedMap:function(){return $t(this.toKeyedSeq())},toOrderedSet:function(){return Be(u(this)?this.valueSeq():this)},toSet:function(){return Ue(u(this)?this.valueSeq():this)},toSetSeq:function(){return new oe(this)},toSeq:function(){return s(this)?this.toIndexedSeq():u(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Ve(u(this)?this.valueSeq():this)},toList:function(){return Kt(u(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(t,e){return 0===this.size?t+e:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+e},concat:function(){var t=sr.call(arguments,0);return ze(this,de(this,t))},includes:function(t){return this.some(function(e){return G(e,t)})},entries:function(){return this.__iterator(br)},every:function(t,e){ct(this.size);var r=!0;return this.__iterate(function(n,i,o){return t.call(e,n,i,o)?void 0:(r=!1,!1)}),r},filter:function(t,e){return ze(this,ce(this,t,e,!0))},find:function(t,e,r){var n=this.findEntry(t,e);return n?n[1]:r},findEntry:function(t,e){var r;return this.__iterate(function(n,i,o){return t.call(e,n,i,o)?(r=[i,n],!1):void 0}),r},findLastEntry:function(t,e){return this.toSeq().reverse().findEntry(t,e)},forEach:function(t,e){return ct(this.size),this.__iterate(e?t.bind(e):t)},join:function(t){ct(this.size),t=void 0!==t?""+t:",";var e="",r=!0;return this.__iterate(function(n){r?r=!1:e+=t,e+=null!==n&&void 0!==n?n.toString():""}),e},keys:function(){return this.__iterator(gr)},map:function(t,e){return ze(this,ae(this,t,e))},reduce:function(t,e,r){ct(this.size);var n,i;return arguments.length<2?i=!0:n=e,this.__iterate(function(e,o,u){i?(i=!1,n=e):n=t.call(r,n,e,o,u)}),n},reduceRight:function(t,e,r){var n=this.toKeyedSeq().reverse();return n.reduce.apply(n,arguments)},reverse:function(){return ze(this,fe(this,!0))},slice:function(t,e){return ze(this,le(this,t,e,!0))},some:function(t,e){return!this.every(Ze(t),e)},sort:function(t){return ze(this,we(this,t))},values:function(){return this.__iterator(wr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some(function(){return!0})},count:function(t,e){return _(t?this.toSeq().filter(t,e):this)},countBy:function(t,e){return he(this,t,e)},equals:function(t){return Q(this,t)},entrySeq:function(){var t=this;if(t._cache)return new k(t._cache);var e=t.toSeq().map($e).toIndexedSeq();return e.fromEntrySeq=function(){return t.toSeq()},e},filterNot:function(t,e){return this.filter(Ze(t),e)},findLast:function(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)},first:function(){return this.find(d)},flatMap:function(t,e){return ze(this,me(this,t,e))},flatten:function(t){return ze(this,ye(this,t,!0))},fromEntrySeq:function(){return new ue(this)},get:function(t,e){return this.find(function(e,r){return G(r,t)},void 0,e)},getIn:function(t,e){for(var r,n=this,i=De(t);!(r=i.next()).done;){var o=r.value;if(n=n&&n.get?n.get(o,dr):dr,n===dr)return e}return n},groupBy:function(t,e){return pe(this,t,e)},has:function(t){return this.get(t,dr)!==dr},hasIn:function(t){return this.getIn(t,dr)!==dr},isSubset:function(t){return t="function"==typeof t.includes?t:e(t),this.every(function(e){return t.includes(e)})},isSuperset:function(t){return t="function"==typeof t.isSubset?t:e(t),t.isSubset(this)},keySeq:function(){return this.toSeq().map(Xe).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},max:function(t){return be(this,t)},maxBy:function(t,e){return be(this,e,t)},min:function(t){return be(this,t?tr(t):nr)},minBy:function(t,e){return be(this,e?tr(e):nr,t)},rest:function(){return this.slice(1)},skip:function(t){return this.slice(Math.max(0,t))},skipLast:function(t){return ze(this,this.toSeq().reverse().skip(t).reverse())},skipWhile:function(t,e){return ze(this,ve(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(Ze(t),e)},sortBy:function(t,e){return ze(this,we(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return ze(this,this.toSeq().reverse().take(t).reverse())},takeWhile:function(t,e){return ze(this,_e(this,t,e))},takeUntil:function(t,e){return this.takeWhile(Ze(t),e)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=ir(this))}});var sn=e.prototype;sn[ar]=!0,sn[zr]=sn.values,sn.__toJS=sn.toArray,sn.__toStringMapper=er,sn.inspect=sn.toSource=function(){return this.toString()},sn.chain=sn.flatMap,sn.contains=sn.includes,function(){try{Object.defineProperty(sn,"length",{get:function(){if(!e.noLengthWarning){var t;try{throw new Error}catch(r){t=r.stack}if(-1===t.indexOf("_wrapObject"))return console&&console.warn&&console.warn("iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version. "+t),this.size}}})}catch(t){}}(),Qe(r,{flip:function(){return ze(this,se(this))},findKey:function(t,e){var r=this.findEntry(t,e);return r&&r[0]},findLastKey:function(t,e){return this.toSeq().reverse().findKey(t,e)},keyOf:function(t){return this.findKey(function(e){return G(e,t)})},lastKeyOf:function(t){return this.findLastKey(function(e){return G(e,t)})},mapEntries:function(t,e){var r=this,n=0;return ze(this,this.toSeq().map(function(i,o){return t.call(e,[o,i],n++,r)}).fromEntrySeq())},mapKeys:function(t,e){var r=this;return ze(this,this.toSeq().flip().map(function(n,i){return t.call(e,n,i,r)}).flip())}});var an=r.prototype;an[fr]=!0,an[zr]=sn.entries,an.__toJS=sn.toObject,an.__toStringMapper=function(t,e){return JSON.stringify(e)+": "+er(t)},Qe(n,{toKeyedSeq:function(){return new ne(this,!1)},filter:function(t,e){return ze(this,ce(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.toKeyedSeq().keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.toKeyedSeq().reverse().keyOf(t);return void 0===e?-1:e},reverse:function(){return ze(this,fe(this,!1))},slice:function(t,e){return ze(this,le(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(0|e,0),0===r||2===r&&!e)return this;t=m(t,0>t?this.count():this.size);var n=this.slice(0,t);return ze(this,1===r?n:n.concat(l(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return ze(this,ye(this,t,!1))},get:function(t,e){return t=v(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=v(this,t),t>=0&&(void 0!==this.size?this.size===1/0||t=200&&t.status<300)return p;var l=new Error(t.statusText);throw l.response=p,l})})}},t.exports=e["default"]},function(t,e,r){var n=r(11),i=r(13);t.exports={stringify:n,parse:i}},function(t,e,r){var n=r(12),i={delimiter:"&",arrayPrefixGenerators:{brackets:function(t,e){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t,e){return t}},strictNullHandling:!1,skipNulls:!1,encode:!0};i.stringify=function(t,e,r,o,u,s,a,f){if("function"==typeof a)t=a(e,t);else if(n.isBuffer(t))t=t.toString();else if(t instanceof Date)t=t.toISOString();else if(null===t){if(o)return s?n.encode(e):e;t=""}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return s?[n.encode(e)+"="+n.encode(t)]:[e+"="+t];var c=[];if("undefined"==typeof t)return c;var h;if(Array.isArray(a))h=a;else{var p=Object.keys(t);h=f?p.sort(f):p}for(var l=0,_=h.length;_>l;++l){var v=h[l];u&&null===t[v]||(c=Array.isArray(t)?c.concat(i.stringify(t[v],r(e,v),r,o,u,s,a)):c.concat(i.stringify(t[v],e+"["+v+"]",r,o,u,s,a))); +}return c},t.exports=function(t,e){e=e||{};var r,n,o="undefined"==typeof e.delimiter?i.delimiter:e.delimiter,u="boolean"==typeof e.strictNullHandling?e.strictNullHandling:i.strictNullHandling,s="boolean"==typeof e.skipNulls?e.skipNulls:i.skipNulls,a="boolean"==typeof e.encode?e.encode:i.encode,f="function"==typeof e.sort?e.sort:null;"function"==typeof e.filter?(n=e.filter,t=n("",t)):Array.isArray(e.filter)&&(r=n=e.filter);var c=[];if("object"!=typeof t||null===t)return"";var h;h=e.arrayFormat in i.arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":"indices";var p=i.arrayPrefixGenerators[h];r||(r=Object.keys(t)),f&&r.sort(f);for(var l=0,_=r.length;_>l;++l){var v=r[l];s&&null===t[v]||(c=c.concat(i.stringify(t[v],v,p,u,s,a,n,f)))}return c.join(o)}},function(t,e){var r={};r.hexTable=new Array(256);for(var n=0;256>n;++n)r.hexTable[n]="%"+((16>n?"0":"")+n.toString(16)).toUpperCase();e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},n=0,i=t.length;i>n;++n)"undefined"!=typeof t[n]&&(r[n]=t[n]);return r},e.merge=function(t,r,n){if(!r)return t;if("object"!=typeof r)return Array.isArray(t)?t.push(r):"object"==typeof t?t[r]=!0:t=[t,r],t;if("object"!=typeof t)return t=[t].concat(r);Array.isArray(t)&&!Array.isArray(r)&&(t=e.arrayToObject(t,n));for(var i=Object.keys(r),o=0,u=i.length;u>o;++o){var s=i[o],a=r[s];Object.prototype.hasOwnProperty.call(t,s)?t[s]=e.merge(t[s],a,n):t[s]=a}return t},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;"string"!=typeof t&&(t=""+t);for(var e="",n=0,i=t.length;i>n;++n){var o=t.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&57>=o||o>=65&&90>=o||o>=97&&122>=o?e+=t[n]:128>o?e+=r.hexTable[o]:2048>o?e+=r.hexTable[192|o>>6]+r.hexTable[128|63&o]:55296>o||o>=57344?e+=r.hexTable[224|o>>12]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o]:(++n,o=65536+((1023&o)<<10|1023&t.charCodeAt(n)),e+=r.hexTable[240|o>>18]+r.hexTable[128|o>>12&63]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o])}return e},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;r=r||[];var n=r.indexOf(t);if(-1!==n)return r[n];if(r.push(t),Array.isArray(t)){for(var i=[],o=0,u=t.length;u>o;++o)"undefined"!=typeof t[o]&&i.push(t[o]);return i}var s=Object.keys(t);for(o=0,u=s.length;u>o;++o){var a=s[o];t[a]=e.compact(t[a],r)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null===t||"undefined"==typeof t?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e,r){var n=r(12),i={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1};i.parseValues=function(t,e){for(var r={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),o=0,u=i.length;u>o;++o){var s=i[o],a=-1===s.indexOf("]=")?s.indexOf("="):s.indexOf("]=")+1;if(-1===a)r[n.decode(s)]="",e.strictNullHandling&&(r[n.decode(s)]=null);else{var f=n.decode(s.slice(0,a)),c=n.decode(s.slice(a+1));Object.prototype.hasOwnProperty.call(r,f)?r[f]=[].concat(r[f]).concat(c):r[f]=c}}return r},i.parseObject=function(t,e,r){if(!t.length)return e;var n,o=t.shift();if("[]"===o)n=[],n=n.concat(i.parseObject(t,e,r));else{n=r.plainObjects?Object.create(null):{};var u="["===o[0]&&"]"===o[o.length-1]?o.slice(1,o.length-1):o,s=parseInt(u,10),a=""+s;!isNaN(s)&&o!==u&&a===u&&s>=0&&r.parseArrays&&s<=r.arrayLimit?(n=[],n[s]=i.parseObject(t,e,r)):n[u]=i.parseObject(t,e,r)}return n},i.parseKeys=function(t,e,r){if(t){r.allowDots&&(t=t.replace(/\.([^\.\[]+)/g,"[$1]"));var n=/^([^\[\]]*)/,o=/(\[[^\[\]]*\])/g,u=n.exec(t),s=[];if(u[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(u[1])&&!r.allowPrototypes)return;s.push(u[1])}for(var a=0;null!==(u=o.exec(t))&&as;++s){var f=u[s],c=i.parseKeys(f,r[f],e);o=n.merge(o,c,e)}return n.compact(o)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e1?n-1:0),o=1;n>o;o++)i[o-1]=arguments[o];r.apply(void 0,[t+":"+e].concat(i))}}var i=(0,a.List)(e.get("errorInterceptors")),u=(0,a.List)(e.get("requestInterceptors")),s=(0,a.List)(e.get("responseInterceptors")),f=e["delete"]("errorInterceptors")["delete"]("requestInterceptors")["delete"]("responseInterceptors");return o(n("request:interceptor"),u,f).then(function(e){return r("request",(0,c["default"])(e)),t((0,c["default"])(e)).then(function(t){return o(n("response:interceptor"),s,(0,a.fromJS)(t),[(0,c["default"])(e)])})}).then(null,function(t){return o(n("error:interceptor"),i,t,[(0,c["default"])(f)]).then(function(t){return Promise.reject(t)})})}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return function(e){var r=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return u(r?t["new"](t.url()+"/"+e):t["new"](e))}}function o(t){function e(e){return function(){for(var r,n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];var s=i.shift();return(r=u(t["new"](t.url()+"/"+s)))[e].apply(r,i)}}return(0,a["default"])(t,{custom:i(t),"delete":e("delete"),getAll:t.get,get:e("get"),head:e("head"),patch:e("patch"),put:e("put")})}function u(t){return(0,a["default"])(t,{all:function(e){return o(t["new"](t.url()+"/"+e))},custom:i(t),one:function(e,r){return u(t["new"](t.url()+"/"+e+"/"+r))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.custom=i,e.collection=o,e.member=u;var s=r(3),a=n(s)},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=function(t){return function(e){return e.data&&(e.form=/application\/json/.test(e.headers["Content-Type"])?JSON.stringify(e.data):e.data,delete e.data),e.params&&(e.qs=e.params,delete e.params),new Promise(function(r,n){t(e,function(t,e,i){if(t)throw t;var o=void 0;try{o=JSON.parse(i)}catch(u){o=i}var s={data:o,headers:e.headers,statusCode:e.statusCode};if(e.statusCode>=200&&e.statusCode<300)return r(s);var a=new Error(e.statusMessage);a.response=s,n(a)})})}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){var e=(0,o.Map)(),r=new i.EventEmitter,u={assign:function(t,r,n){return u.has(t)||u.set(t,(0,o.Map)()),e=e.setIn([t,r],n),u},emit:function(){r.emit.apply(r,arguments),t&&t.emit.apply(t,arguments)},get:function(r){var n=e.get(r);if(u.has(r)&&!o.Iterable.isIterable(n)||!t)return n;if(!u.has(r)&&t)return t.get(r);var i=t.get(r);return i?o.List.isList(i)?i.concat(n):i.mergeDeep(n):n},has:function(t){return e.has(t)},"new":function(){return n(u)},on:r.on.bind(r),once:r.once.bind(r),push:function(t,r){return u.has(t)||u.set(t,(0,o.List)()),e=e.update(t,function(t){return t.push(r)}),u},set:function(t,r){return e=e.set(t,r),u}};return u}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(18),o=r(6);t.exports=e["default"]},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function u(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,s,a,f;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],u(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];r.apply(this,s)}else if(o(r)){for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];for(f=r.slice(),i=f.length,a=0;i>a;a++)f[a].apply(this,s)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,u,s;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],u=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=u;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}}])}); \ No newline at end of file diff --git a/dist/restful.standalone.js b/dist/restful.standalone.js index 7c02ac5..5b551b1 100644 --- a/dist/restful.standalone.js +++ b/dist/restful.standalone.js @@ -2,7 +2,7 @@ if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) - define(factory); + define([], factory); else if(typeof exports === 'object') exports["restful"] = factory(); else @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap var _srcHttpFetch2 = _interopRequireDefault(_srcHttpFetch); - __webpack_require__(18); + __webpack_require__(19); exports['default'] = function (baseUrl) { var httpBackend = arguments.length <= 1 || arguments[1] === undefined ? (0, _srcHttpFetch2['default'])(fetch) : arguments[1]; @@ -92,7 +92,7 @@ return /******/ (function(modules) { // webpackBootstrap function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _modelEndpoint = __webpack_require__(4); + var _modelEndpoint = __webpack_require__(2); var _modelEndpoint2 = _interopRequireDefault(_modelEndpoint); @@ -104,13 +104,13 @@ return /******/ (function(modules) { // webpackBootstrap var _serviceHttp2 = _interopRequireDefault(_serviceHttp); - var _modelDecorator = __webpack_require__(2); + var _modelDecorator = __webpack_require__(15); - var _httpRequest = __webpack_require__(15); + var _httpRequest = __webpack_require__(16); var _httpRequest2 = _interopRequireDefault(_httpRequest); - var _modelScope = __webpack_require__(16); + var _modelScope = __webpack_require__(17); var _modelScope2 = _interopRequireDefault(_modelScope); @@ -149,109 +149,6 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - Object.defineProperty(exports, '__esModule', { - value: true - }); - exports.custom = custom; - exports.collection = collection; - exports.member = member; - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - - var _objectAssign = __webpack_require__(3); - - var _objectAssign2 = _interopRequireDefault(_objectAssign); - - function custom(endpoint) { - return function (name) { - var relative = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; - - if (relative) { - return member(endpoint['new'](endpoint.url() + '/' + name)); // eslint-disable-line no-use-before-define - } - - return member(endpoint['new'](name)); // eslint-disable-line no-use-before-define - }; - } - - function collection(endpoint) { - function _bindHttpMethod(method) { - return function () { - var _member; - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - var id = args.shift(); - return (_member = member(endpoint['new'](endpoint.url() + '/' + id)))[method].apply(_member, args); // eslint-disable-line no-use-before-define - }; - } - - return (0, _objectAssign2['default'])(endpoint, { - custom: custom(endpoint), - 'delete': _bindHttpMethod('delete'), - getAll: endpoint.get, - get: _bindHttpMethod('get'), - head: _bindHttpMethod('head'), - one: function one(name, id) { - return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); - }, // eslint-disable-line no-use-before-define - patch: _bindHttpMethod('patch'), - put: _bindHttpMethod('put') - }); - } - - function member(endpoint) { - return (0, _objectAssign2['default'])(endpoint, { - all: function all(name) { - return collection(endpoint['new'](endpoint.url() + '/' + name)); - }, - custom: custom(endpoint), - one: function one(name, id) { - return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); - } - }); - } - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - 'use strict'; - - function ToObject(val) { - if (val == null) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); - } - - module.exports = Object.assign || function (target, source) { - var from; - var keys; - var to = ToObject(target); - - for (var s = 1; s < arguments.length; s++) { - from = arguments[s]; - keys = Object.keys(Object(from)); - - for (var i = 0; i < keys.length; i++) { - to[keys[i]] = from[keys[i]]; - } - } - - return to; - }; - - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - Object.defineProperty(exports, '__esModule', { value: true }); @@ -262,13 +159,13 @@ return /******/ (function(modules) { // webpackBootstrap var _objectAssign2 = _interopRequireDefault(_objectAssign); - var _response = __webpack_require__(5); + var _response = __webpack_require__(4); var _response2 = _interopRequireDefault(_response); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); - var _utilSerialize = __webpack_require__(8); + var _utilSerialize = __webpack_require__(7); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); @@ -401,7 +298,39 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 5 */ +/* 3 */ +/***/ function(module, exports) { + + 'use strict'; + + function ToObject(val) { + if (val == null) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); + } + + module.exports = Object.assign || function (target, source) { + var from; + var keys; + var to = ToObject(target); + + for (var s = 1; s < arguments.length; s++) { + from = arguments[s]; + keys = Object.keys(Object(from)); + + for (var i = 0; i < keys.length; i++) { + to[keys[i]] = from[keys[i]]; + } + } + + return to; + }; + + +/***/ }, +/* 4 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -412,16 +341,20 @@ return /******/ (function(modules) { // webpackBootstrap function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _entity = __webpack_require__(6); + var _entity = __webpack_require__(5); var _entity2 = _interopRequireDefault(_entity); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); - var _utilSerialize = __webpack_require__(8); + var _utilSerialize = __webpack_require__(7); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); + var _warning = __webpack_require__(8); + + var _warning2 = _interopRequireDefault(_warning); + /* eslint-disable new-cap */ exports['default'] = function (response, decoratedEndpoint) { @@ -441,9 +374,7 @@ return /******/ (function(modules) { // webpackBootstrap } if (_immutable.List.isList(data)) { - if (decoratedEndpoint.all) { - throw new Error('Unexpected array as response, you should use all method for that'); - } + (0, _warning2['default'])(response.get('method') !== 'get' || !decoratedEndpoint.all, 'Unexpected array as response, you should use all method for that'); return (0, _utilSerialize2['default'])(data.map(function (datum) { var id = datum.get(identifier); @@ -451,9 +382,7 @@ return /******/ (function(modules) { // webpackBootstrap })); } - if (!decoratedEndpoint.all) { - throw new Error('Expected array as response, you should use one method for that'); - } + (0, _warning2['default'])(response.get('method') !== 'get' || decoratedEndpoint.all, 'Expected array as response, you should use one method for that'); return (0, _entity2['default'])((0, _utilSerialize2['default'])(data), decoratedEndpoint); }, @@ -466,7 +395,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 6 */ +/* 5 */ /***/ function(module, exports) { "use strict"; @@ -501,7 +430,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports["default"]; /***/ }, -/* 7 */ +/* 6 */ /***/ function(module, exports, __webpack_require__) { /** @@ -512,10 +441,11 @@ return /******/ (function(modules) { // webpackBootstrap * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ + (function (global, factory) { - true ? module.exports = factory() : + true ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - global.Immutable = factory() + global.Immutable = factory(); }(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice; function createClass(ctor, superClass) { @@ -525,6 +455,66 @@ return /******/ (function(modules) { // webpackBootstrap ctor.prototype.constructor = ctor; } + function Iterable(value) { + return isIterable(value) ? value : Seq(value); + } + + + createClass(KeyedIterable, Iterable); + function KeyedIterable(value) { + return isKeyed(value) ? value : KeyedSeq(value); + } + + + createClass(IndexedIterable, Iterable); + function IndexedIterable(value) { + return isIndexed(value) ? value : IndexedSeq(value); + } + + + createClass(SetIterable, Iterable); + function SetIterable(value) { + return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); + } + + + + function isIterable(maybeIterable) { + return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); + } + + function isKeyed(maybeKeyed) { + return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); + } + + function isIndexed(maybeIndexed) { + return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); + } + + function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + } + + function isOrdered(maybeOrdered) { + return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); + } + + Iterable.isIterable = isIterable; + Iterable.isKeyed = isKeyed; + Iterable.isIndexed = isIndexed; + Iterable.isAssociative = isAssociative; + Iterable.isOrdered = isOrdered; + + Iterable.Keyed = KeyedIterable; + Iterable.Indexed = IndexedIterable; + Iterable.Set = SetIterable; + + + var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; + var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; + var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; + var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; + // Used for setting prototype methods that IE8 chokes on. var DELETE = 'delete'; @@ -575,18 +565,18 @@ return /******/ (function(modules) { // webpackBootstrap function wrapIndex(iter, index) { // This implements "is array index" which the ECMAString spec defines as: + // // A String property name P is an array index if and only if // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal // to 2^32−1. - // However note that we're currently calling ToNumber() instead of ToUint32() - // which should be improved in the future, as floating point numbers should - // not be accepted as an array index. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects if (typeof index !== 'number') { - var numIndex = +index; - if ('' + numIndex !== index) { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { return NaN; } - index = numIndex; + index = uint32Index; } return index < 0 ? ensureSize(iter) + index : index; } @@ -618,116 +608,56 @@ return /******/ (function(modules) { // webpackBootstrap Math.min(size, index); } - function Iterable(value) { - return isIterable(value) ? value : Seq(value); - } + /* global Symbol */ + var ITERATE_KEYS = 0; + var ITERATE_VALUES = 1; + var ITERATE_ENTRIES = 2; - createClass(KeyedIterable, Iterable); - function KeyedIterable(value) { - return isKeyed(value) ? value : KeyedSeq(value); - } + var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; + var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - createClass(IndexedIterable, Iterable); - function IndexedIterable(value) { - return isIndexed(value) ? value : IndexedSeq(value); + + function Iterator(next) { + this.next = next; } + Iterator.prototype.toString = function() { + return '[Iterator]'; + }; - createClass(SetIterable, Iterable); - function SetIterable(value) { - return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); - } + Iterator.KEYS = ITERATE_KEYS; + Iterator.VALUES = ITERATE_VALUES; + Iterator.ENTRIES = ITERATE_ENTRIES; + Iterator.prototype.inspect = + Iterator.prototype.toSource = function () { return this.toString(); } + Iterator.prototype[ITERATOR_SYMBOL] = function () { + return this; + }; - function isIterable(maybeIterable) { - return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); - } - function isKeyed(maybeKeyed) { - return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); + function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { + value: value, done: false + }); + return iteratorResult; } - function isIndexed(maybeIndexed) { - return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); + function iteratorDone() { + return { value: undefined, done: true }; } - function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + function hasIterator(maybeIterable) { + return !!getIteratorFn(maybeIterable); } - function isOrdered(maybeOrdered) { - return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); - } - - Iterable.isIterable = isIterable; - Iterable.isKeyed = isKeyed; - Iterable.isIndexed = isIndexed; - Iterable.isAssociative = isAssociative; - Iterable.isOrdered = isOrdered; - - Iterable.Keyed = KeyedIterable; - Iterable.Indexed = IndexedIterable; - Iterable.Set = SetIterable; - - - var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; - var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; - var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; - var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; - - /* global Symbol */ - - var ITERATE_KEYS = 0; - var ITERATE_VALUES = 1; - var ITERATE_ENTRIES = 2; - - var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - - var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - - - function src_Iterator__Iterator(next) { - this.next = next; - } - - src_Iterator__Iterator.prototype.toString = function() { - return '[Iterator]'; - }; - - - src_Iterator__Iterator.KEYS = ITERATE_KEYS; - src_Iterator__Iterator.VALUES = ITERATE_VALUES; - src_Iterator__Iterator.ENTRIES = ITERATE_ENTRIES; - - src_Iterator__Iterator.prototype.inspect = - src_Iterator__Iterator.prototype.toSource = function () { return this.toString(); } - src_Iterator__Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; - }; - - - function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { - value: value, done: false - }); - return iteratorResult; - } - - function iteratorDone() { - return { value: undefined, done: true }; - } - - function hasIterator(maybeIterable) { - return !!getIteratorFn(maybeIterable); - } - - function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; + function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; } function getIterator(iterable) { @@ -863,8 +793,6 @@ return /******/ (function(modules) { // webpackBootstrap - // #pragma Root Sequences - createClass(ArraySeq, IndexedSeq); function ArraySeq(array) { this._array = array; @@ -890,7 +818,7 @@ return /******/ (function(modules) { // webpackBootstrap var array = this._array; var maxIndex = array.length - 1; var ii = 0; - return new src_Iterator__Iterator(function() + return new Iterator(function() {return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])} @@ -936,7 +864,7 @@ return /******/ (function(modules) { // webpackBootstrap var keys = this._keys; var maxIndex = keys.length - 1; var ii = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var key = keys[reverse ? maxIndex - ii : ii]; return ii++ > maxIndex ? iteratorDone() : @@ -978,10 +906,10 @@ return /******/ (function(modules) { // webpackBootstrap var iterable = this._iterable; var iterator = getIterator(iterable); if (!isIterator(iterator)) { - return new src_Iterator__Iterator(iteratorDone); + return new Iterator(iteratorDone); } var iterations = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var step = iterator.next(); return step.done ? step : iteratorValue(type, iterations++, step.value); }); @@ -1025,7 +953,7 @@ return /******/ (function(modules) { // webpackBootstrap var iterator = this._iterator; var cache = this._iteratorCache; var iterations = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { if (iterations >= cache.length) { var step = iterator.next(); if (step.done) { @@ -1118,7 +1046,7 @@ return /******/ (function(modules) { // webpackBootstrap if (cache) { var maxIndex = cache.length - 1; var ii = 0; - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var entry = cache[reverse ? maxIndex - ii : ii]; return ii++ > maxIndex ? iteratorDone() : @@ -1128,22 +1056,35 @@ return /******/ (function(modules) { // webpackBootstrap return seq.__iteratorUncached(type, reverse); } - createClass(Collection, Iterable); - function Collection() { - throw TypeError('Abstract'); - } - - - createClass(KeyedCollection, Collection);function KeyedCollection() {} - - createClass(IndexedCollection, Collection);function IndexedCollection() {} + function fromJS(json, converter) { + return converter ? + fromJSWith(converter, json, '', {'': json}) : + fromJSDefault(json); + } - createClass(SetCollection, Collection);function SetCollection() {} + function fromJSWith(converter, json, key, parentJSON) { + if (Array.isArray(json)) { + return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + } + if (isPlainObj(json)) { + return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + } + return json; + } + function fromJSDefault(json) { + if (Array.isArray(json)) { + return IndexedSeq(json).map(fromJSDefault).toList(); + } + if (isPlainObj(json)) { + return KeyedSeq(json).map(fromJSDefault).toMap(); + } + return json; + } - Collection.Keyed = KeyedCollection; - Collection.Indexed = IndexedCollection; - Collection.Set = SetCollection; + function isPlainObj(value) { + return value && (value.constructor === Object || value.constructor === undefined); + } /** * An extension of the "same-value" algorithm as [described for use by ES6 Map @@ -1225,1266 +1166,873 @@ return /******/ (function(modules) { // webpackBootstrap return false; } - function fromJS(json, converter) { - return converter ? - fromJSWith(converter, json, '', {'': json}) : - fromJSDefault(json); - } - - function fromJSWith(converter, json, key, parentJSON) { - if (Array.isArray(json)) { - return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); - } - if (isPlainObj(json)) { - return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)})); + function deepEqual(a, b) { + if (a === b) { + return true; } - return json; - } - function fromJSDefault(json) { - if (Array.isArray(json)) { - return IndexedSeq(json).map(fromJSDefault).toList(); + if ( + !isIterable(b) || + a.size !== undefined && b.size !== undefined && a.size !== b.size || + a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; } - if (isPlainObj(json)) { - return KeyedSeq(json).map(fromJSDefault).toMap(); + + if (a.size === 0 && b.size === 0) { + return true; } - return json; - } - function isPlainObj(value) { - return value && (value.constructor === Object || value.constructor === undefined); - } + var notAssociative = !isAssociative(a); - var src_Math__imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? - Math.imul : - function imul(a, b) { - a = a | 0; // int - b = b | 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int - }; + if (isOrdered(a)) { + var entries = a.entries(); + return b.every(function(v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done; + } - // v8 has an optimization for storing 31-bit signed numbers. - // Values which have either 00 or 11 as the high order bits qualify. - // This function drops the highest order bit in a signed number, maintaining - // the sign bit. - function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF); - } + var flipped = false; - function hash(o) { - if (o === false || o === null || o === undefined) { - return 0; - } - if (typeof o.valueOf === 'function') { - o = o.valueOf(); - if (o === false || o === null || o === undefined) { - return 0; - } - } - if (o === true) { - return 1; - } - var type = typeof o; - if (type === 'number') { - var h = o | 0; - if (h !== o) { - h ^= o * 0xFFFFFFFF; - } - while (o > 0xFFFFFFFF) { - o /= 0xFFFFFFFF; - h ^= o; + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; } - return smi(h); - } - if (type === 'string') { - return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o); } - if (typeof o.hashCode === 'function') { - return o.hashCode(); - } - return hashJSObj(o); - } - function cachedHashString(string) { - var hash = stringHashCache[string]; - if (hash === undefined) { - hash = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; + var allEqual = true; + var bSize = b.__iterate(function(v, k) { + if (notAssociative ? !a.has(v) : + flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) { + allEqual = false; + return false; } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hash; - } - return hash; - } + }); - // http://jsperf.com/hashing-strings - function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hash = 0; - for (var ii = 0; ii < string.length; ii++) { - hash = 31 * hash + string.charCodeAt(ii) | 0; - } - return smi(hash); + return allEqual && a.size === bSize; } - function hashJSObj(obj) { - var hash; - if (usingWeakMap) { - hash = weakMap.get(obj); - if (hash !== undefined) { - return hash; + createClass(Repeat, IndexedSeq); + + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + return EMPTY_REPEAT; + } + EMPTY_REPEAT = this; } } - hash = obj[UID_HASH_KEY]; - if (hash !== undefined) { - return hash; - } - - if (!canDefineProperty) { - hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hash !== undefined) { - return hash; + Repeat.prototype.toString = function() { + if (this.size === 0) { + return 'Repeat []'; } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; - hash = getIENodeHash(obj); - if (hash !== undefined) { - return hash; - } - } + Repeat.prototype.get = function(index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; - hash = ++objHashUID; - if (objHashUID & 0x40000000) { - objHashUID = 0; - } + Repeat.prototype.includes = function(searchValue) { + return is(this._value, searchValue); + }; - if (usingWeakMap) { - weakMap.set(obj, hash); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - 'enumerable': false, - 'configurable': false, - 'writable': false, - 'value': hash - }); - } else if (obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function() { - return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments); - }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hash; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hash; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } + Repeat.prototype.slice = function(begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) ? this : + new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size)); + }; - return hash; - } + Repeat.prototype.reverse = function() { + return this; + }; - // Get references to ES5 object methods. - var isExtensible = Object.isExtensible; + Repeat.prototype.indexOf = function(searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; - // True if Object.defineProperty works as expected. IE8 fails this test. - var canDefineProperty = (function() { - try { - Object.defineProperty({}, '@', {}); - return true; - } catch (e) { - return false; - } - }()); + Repeat.prototype.lastIndexOf = function(searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; - // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it - // and avoid memory leaks from the IE cloneNode bug. - function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; + Repeat.prototype.__iterate = function(fn, reverse) { + for (var ii = 0; ii < this.size; ii++) { + if (fn(this._value, ii, this) === false) { + return ii + 1; + } } - } - } + return ii; + }; - // If possible, use a WeakMap. - var usingWeakMap = typeof WeakMap === 'function'; - var weakMap; - if (usingWeakMap) { - weakMap = new WeakMap(); - } + Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this; + var ii = 0; + return new Iterator(function() + {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()} + ); + }; - var objHashUID = 0; + Repeat.prototype.equals = function(other) { + return other instanceof Repeat ? + is(this._value, other._value) : + deepEqual(other); + }; - var UID_HASH_KEY = '__immutablehash__'; - if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); - } - var STRING_HASH_CACHE_MIN_STRLEN = 16; - var STRING_HASH_CACHE_MAX_SIZE = 255; - var STRING_HASH_CACHE_SIZE = 0; - var stringHashCache = {}; + var EMPTY_REPEAT; function invariant(condition, error) { if (!condition) throw new Error(error); } - function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); - } + createClass(Range, IndexedSeq); - createClass(ToKeyedSequence, KeyedSeq); - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; + function Range(start, end, step) { + if (!(this instanceof Range)) { + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + start = start || 0; + if (end === undefined) { + end = Infinity; + } + step = step === undefined ? 1 : Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + return EMPTY_RANGE; + } + EMPTY_RANGE = this; + } } - ToKeyedSequence.prototype.get = function(key, notSetValue) { - return this._iter.get(key, notSetValue); + Range.prototype.toString = function() { + if (this.size === 0) { + return 'Range []'; + } + return 'Range [ ' + + this._start + '...' + this._end + + (this._step > 1 ? ' by ' + this._step : '') + + ' ]'; }; - ToKeyedSequence.prototype.has = function(key) { - return this._iter.has(key); + Range.prototype.get = function(index, notSetValue) { + return this.has(index) ? + this._start + wrapIndex(this, index) * this._step : + notSetValue; }; - ToKeyedSequence.prototype.valueSeq = function() { - return this._iter.valueSeq(); + Range.prototype.includes = function(searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex); }; - ToKeyedSequence.prototype.reverse = function() {var this$0 = this; - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()}; + Range.prototype.slice = function(begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; } - return reversedSequence; + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range(this.get(begin, this._end), this.get(end, this._end), this._step); }; - ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this; - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)}; + Range.prototype.indexOf = function(searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index + } } - return mappedSequence; + return -1; }; - ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var ii; - return this._iter.__iterate( - this._useKeys ? - function(v, k) {return fn(v, k, this$0)} : - ((ii = reverse ? resolveSize(this) : 0), - function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}), - reverse - ); + Range.prototype.lastIndexOf = function(searchValue) { + return this.indexOf(searchValue); }; - ToKeyedSequence.prototype.__iterator = function(type, reverse) { - if (this._useKeys) { - return this._iter.__iterator(type, reverse); + Range.prototype.__iterate = function(fn, reverse) { + var maxIndex = this.size - 1; + var step = this._step; + var value = reverse ? this._start + maxIndex * step : this._start; + for (var ii = 0; ii <= maxIndex; ii++) { + if (fn(value, ii, this) === false) { + return ii + 1; + } + value += reverse ? -step : step; } - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var ii = reverse ? resolveSize(this) : 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, reverse ? --ii : ii++, step.value, step); - }); + return ii; }; - ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; - - - createClass(ToIndexedSequence, IndexedSeq); - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - ToIndexedSequence.prototype.includes = function(value) { - return this._iter.includes(value); - }; - - ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var iterations = 0; - return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse); + Range.prototype.__iterator = function(type, reverse) { + var maxIndex = this.size - 1; + var step = this._step; + var value = reverse ? this._start + maxIndex * step : this._start; + var ii = 0; + return new Iterator(function() { + var v = value; + value += reverse ? -step : step; + return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v); + }); }; - ToIndexedSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, iterations++, step.value, step) - }); + Range.prototype.equals = function(other) { + return other instanceof Range ? + this._start === other._start && + this._end === other._end && + this._step === other._step : + deepEqual(this, other); }; + var EMPTY_RANGE; - createClass(ToSetSequence, SetSeq); - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; + createClass(Collection, Iterable); + function Collection() { + throw TypeError('Abstract'); } - ToSetSequence.prototype.has = function(key) { - return this._iter.includes(key); - }; - - ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse); - }; - - ToSetSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - return step.done ? step : - iteratorValue(type, step.value, step.value, step); - }); - }; + createClass(KeyedCollection, Collection);function KeyedCollection() {} + createClass(IndexedCollection, Collection);function IndexedCollection() {} - createClass(FromEntriesSequence, KeyedSeq); - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; - } + createClass(SetCollection, Collection);function SetCollection() {} - FromEntriesSequence.prototype.entrySeq = function() { - return this._iter.toSeq(); - }; - FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._iter.__iterate(function(entry ) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedIterable = isIterable(entry); - return fn( - indexedIterable ? entry.get(1) : entry[1], - indexedIterable ? entry.get(0) : entry[0], - this$0 - ); - } - }, reverse); - }; + Collection.Keyed = KeyedCollection; + Collection.Indexed = IndexedCollection; + Collection.Set = SetCollection; - FromEntriesSequence.prototype.__iterator = function(type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new src_Iterator__Iterator(function() { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedIterable = isIterable(entry); - return iteratorValue( - type, - indexedIterable ? entry.get(0) : entry[0], - indexedIterable ? entry.get(1) : entry[1], - step - ); - } - } - }); + var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? + Math.imul : + function imul(a, b) { + a = a | 0; // int + b = b | 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int }; + // v8 has an optimization for storing 31-bit signed numbers. + // Values which have either 00 or 11 as the high order bits qualify. + // This function drops the highest order bit in a signed number, maintaining + // the sign bit. + function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF); + } - ToIndexedSequence.prototype.cacheResult = - ToKeyedSequence.prototype.cacheResult = - ToSetSequence.prototype.cacheResult = - FromEntriesSequence.prototype.cacheResult = - cacheResultThrough; - - - function flipFactory(iterable) { - var flipSequence = makeSequence(iterable); - flipSequence._iter = iterable; - flipSequence.size = iterable.size; - flipSequence.flip = function() {return iterable}; - flipSequence.reverse = function () { - var reversedSequence = iterable.reverse.apply(this); // super.reverse() - reversedSequence.flip = function() {return iterable.reverse()}; - return reversedSequence; - }; - flipSequence.has = function(key ) {return iterable.includes(key)}; - flipSequence.includes = function(key ) {return iterable.has(key)}; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse); + function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; } - flipSequence.__iteratorUncached = function(type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = iterable.__iterator(type, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; - } - return step; - }); + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; } - return iterable.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); } - return flipSequence; + if (o === true) { + return 1; + } + var type = typeof o; + if (type === 'number') { + var h = o | 0; + if (h !== o) { + h ^= o * 0xFFFFFFFF; + } + while (o > 0xFFFFFFFF) { + o /= 0xFFFFFFFF; + h ^= o; + } + return smi(h); + } + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o); + } + if (typeof o.hashCode === 'function') { + return o.hashCode(); + } + if (type === 'object') { + return hashJSObj(o); + } + if (typeof o.toString === 'function') { + return hashString(o.toString()); + } + throw new Error('Value type ' + type + ' cannot be hashed.'); } - - function mapFactory(iterable, mapper, context) { - var mappedSequence = makeSequence(iterable); - mappedSequence.size = iterable.size; - mappedSequence.has = function(key ) {return iterable.has(key)}; - mappedSequence.get = function(key, notSetValue) { - var v = iterable.get(key, NOT_SET); - return v === NOT_SET ? - notSetValue : - mapper.call(context, v, key, iterable); - }; - mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - return iterable.__iterate( - function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false}, - reverse - ); + function cachedHashString(string) { + var hash = stringHashCache[string]; + if (hash === undefined) { + hash = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hash; } - mappedSequence.__iteratorUncached = function (type, reverse) { - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - return new src_Iterator__Iterator(function() { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, iterable), - step - ); - }); + return hash; + } + + // http://jsperf.com/hashing-strings + function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hash = 0; + for (var ii = 0; ii < string.length; ii++) { + hash = 31 * hash + string.charCodeAt(ii) | 0; } - return mappedSequence; + return smi(hash); } + function hashJSObj(obj) { + var hash; + if (usingWeakMap) { + hash = weakMap.get(obj); + if (hash !== undefined) { + return hash; + } + } - function reverseFactory(iterable, useKeys) { - var reversedSequence = makeSequence(iterable); - reversedSequence._iter = iterable; - reversedSequence.size = iterable.size; - reversedSequence.reverse = function() {return iterable}; - if (iterable.flip) { - reversedSequence.flip = function () { - var flipSequence = flipFactory(iterable); - flipSequence.reverse = function() {return iterable.flip()}; - return flipSequence; + hash = obj[UID_HASH_KEY]; + if (hash !== undefined) { + return hash; + } + + if (!canDefineProperty) { + hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hash !== undefined) { + return hash; + } + + hash = getIENodeHash(obj); + if (hash !== undefined) { + return hash; + } + } + + hash = ++objHashUID; + if (objHashUID & 0x40000000) { + objHashUID = 0; + } + + if (usingWeakMap) { + weakMap.set(obj, hash); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + 'enumerable': false, + 'configurable': false, + 'writable': false, + 'value': hash + }); + } else if (obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function() { + return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments); }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hash; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hash; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); } - reversedSequence.get = function(key, notSetValue) - {return iterable.get(useKeys ? key : -1 - key, notSetValue)}; - reversedSequence.has = function(key ) - {return iterable.has(useKeys ? key : -1 - key)}; - reversedSequence.includes = function(value ) {return iterable.includes(value)}; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function (fn, reverse) {var this$0 = this; - return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse); - }; - reversedSequence.__iterator = - function(type, reverse) {return iterable.__iterator(type, !reverse)}; - return reversedSequence; + + return hash; } + // Get references to ES5 object methods. + var isExtensible = Object.isExtensible; - function filterFactory(iterable, predicate, context, useKeys) { - var filterSequence = makeSequence(iterable); - if (useKeys) { - filterSequence.has = function(key ) { - var v = iterable.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, iterable); - }; - filterSequence.get = function(key, notSetValue) { - var v = iterable.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, iterable) ? - v : notSetValue; - }; + // True if Object.defineProperty works as expected. IE8 fails this test. + var canDefineProperty = (function() { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; } - filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - var iterations = 0; - iterable.__iterate(function(v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0); - } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function (type, reverse) { - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, iterable)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); - } - } - }); + }()); + + // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it + // and avoid memory leaks from the IE cloneNode bug. + function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } } - return filterSequence; } + // If possible, use a WeakMap. + var usingWeakMap = typeof WeakMap === 'function'; + var weakMap; + if (usingWeakMap) { + weakMap = new WeakMap(); + } - function countByFactory(iterable, grouper, context) { - var groups = src_Map__Map().asMutable(); - iterable.__iterate(function(v, k) { - groups.update( - grouper.call(context, v, k, iterable), - 0, - function(a ) {return a + 1} - ); - }); - return groups.asImmutable(); + var objHashUID = 0; + + var UID_HASH_KEY = '__immutablehash__'; + if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); } + var STRING_HASH_CACHE_MIN_STRLEN = 16; + var STRING_HASH_CACHE_MAX_SIZE = 255; + var STRING_HASH_CACHE_SIZE = 0; + var stringHashCache = {}; - function groupByFactory(iterable, grouper, context) { - var isKeyedIter = isKeyed(iterable); - var groups = (isOrdered(iterable) ? OrderedMap() : src_Map__Map()).asMutable(); - iterable.__iterate(function(v, k) { - groups.update( - grouper.call(context, v, k, iterable), - function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)} - ); - }); - var coerce = iterableClass(iterable); - return groups.map(function(arr ) {return reify(iterable, coerce(arr))}); + function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); } + createClass(Map, KeyedCollection); - function sliceFactory(iterable, begin, end, useKeys) { - var originalSize = iterable.size; + // @pragma Construction - // Sanitize begin & end using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - if (begin !== undefined) { - begin = begin | 0; - } - if (end !== undefined) { - end = end | 0; + function Map(value) { + return value === null || value === undefined ? emptyMap() : + isMap(value) && !isOrdered(value) ? value : + emptyMap().withMutations(function(map ) { + var iter = KeyedIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v, k) {return map.set(k, v)}); + }); } - if (wholeSlice(begin, end, originalSize)) { - return iterable; - } + Map.prototype.toString = function() { + return this.__toString('Map {', '}'); + }; - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); + // @pragma Access - // begin or end will be NaN if they were provided as negative numbers and - // this iterable's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { - return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys); - } + Map.prototype.get = function(k, notSetValue) { + return this._root ? + this._root.get(0, undefined, k, notSetValue) : + notSetValue; + }; - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; - } + // @pragma Modification - var sliceSeq = makeSequence(iterable); + Map.prototype.set = function(k, v) { + return updateMap(this, k, v); + }; - // If iterable.size is undefined, the size of the realized sliceSeq is - // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined; + Map.prototype.setIn = function(keyPath, v) { + return this.updateIn(keyPath, NOT_SET, function() {return v}); + }; - if (!useKeys && isSeq(iterable) && sliceSize >= 0) { - sliceSeq.get = function (index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize ? - iterable.get(index + resolvedBegin, notSetValue) : - notSetValue; - } - } + Map.prototype.remove = function(k) { + return updateMap(this, k, NOT_SET); + }; - sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this; - if (sliceSize === 0) { - return 0; - } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - iterable.__iterate(function(v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0) !== false && - iterations !== sliceSize; - } - }); - return iterations; + Map.prototype.deleteIn = function(keyPath) { + return this.updateIn(keyPath, function() {return NOT_SET}); }; - sliceSeq.__iteratorUncached = function(type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); + Map.prototype.update = function(k, notSetValue, updater) { + return arguments.length === 1 ? + k(this) : + this.updateIn([k], notSetValue, updater); + }; + + Map.prototype.updateIn = function(keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; } - // Don't bother instantiating parent iterator if taking 0. - var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { - return step; - } else if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); - } else { - return iteratorValue(type, iterations - 1, step.value[1], step); - } - }); - } + var updatedValue = updateInDeepMap( + this, + forceIterator(keyPath), + notSetValue, + updater + ); + return updatedValue === NOT_SET ? undefined : updatedValue; + }; - return sliceSeq; - } + Map.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + // @pragma Composition - function takeWhileFactory(iterable, predicate, context) { - var takeSequence = makeSequence(iterable); - takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - iterable.__iterate(function(v, k, c) - {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)} + Map.prototype.merge = function(/*...iters*/) { + return mergeIntoMapWith(this, undefined, arguments); + }; + + Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoMapWith(this, merger, iters); + }; + + Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); + return this.updateIn( + keyPath, + emptyMap(), + function(m ) {return typeof m.merge === 'function' ? + m.merge.apply(m, iters) : + iters[iters.length - 1]} ); - return iterations; }; - takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new src_Iterator__Iterator(function() { - if (!iterating) { - return iteratorDone(); - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$0)) { - iterating = false; - return iteratorDone(); - } - return type === ITERATE_ENTRIES ? step : - iteratorValue(type, k, v, step); - }); + + Map.prototype.mergeDeep = function(/*...iters*/) { + return mergeIntoMapWith(this, deepMerger, arguments); }; - return takeSequence; - } + Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + return mergeIntoMapWith(this, deepMergerWith(merger), iters); + }; - function skipWhileFactory(iterable, predicate, context, useKeys) { - var skipSequence = makeSequence(iterable); - skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var isSkipping = true; + Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); + return this.updateIn( + keyPath, + emptyMap(), + function(m ) {return typeof m.mergeDeep === 'function' ? + m.mergeDeep.apply(m, iters) : + iters[iters.length - 1]} + ); + }; + + Map.prototype.sort = function(comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function(mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + // @pragma Mutability + + Map.prototype.withMutations = function(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; + }; + + Map.prototype.asMutable = function() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); + }; + + Map.prototype.asImmutable = function() { + return this.__ensureOwner(); + }; + + Map.prototype.wasAltered = function() { + return this.__altered; + }; + + Map.prototype.__iterator = function(type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function(fn, reverse) {var this$0 = this; var iterations = 0; - iterable.__iterate(function(v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$0); - } - }); + this._root && this._root.iterate(function(entry ) { + iterations++; + return fn(entry[1], entry[0], this$0); + }, reverse); return iterations; }; - skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; - if (reverse) { - return this.cacheResult().__iterator(type, reverse); + + Map.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; } - var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new src_Iterator__Iterator(function() { - var step, k, v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } else if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } else { - return iteratorValue(type, iterations++, step.value[1], step); - } - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$0)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : - iteratorValue(type, k, v, step); - }); + if (!ownerID) { + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); }; - return skipSequence; + + + function isMap(maybeMap) { + return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); } + Map.isMap = isMap; - function concatFactory(iterable, values) { - var isKeyedIterable = isKeyed(iterable); - var iters = [iterable].concat(values).map(function(v ) { - if (!isIterable(v)) { - v = isKeyedIterable ? - keyedSeqFromValue(v) : - indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedIterable) { - v = KeyedIterable(v); - } - return v; - }).filter(function(v ) {return v.size !== 0}); + var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - if (iters.length === 0) { - return iterable; - } + var MapPrototype = Map.prototype; + MapPrototype[IS_MAP_SENTINEL] = true; + MapPrototype[DELETE] = MapPrototype.remove; + MapPrototype.removeIn = MapPrototype.deleteIn; - if (iters.length === 1) { - var singleton = iters[0]; - if (singleton === iterable || - isKeyedIterable && isKeyed(singleton) || - isIndexed(iterable) && isIndexed(singleton)) { - return singleton; - } - } - var concatSeq = new ArraySeq(iters); - if (isKeyedIterable) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(iterable)) { - concatSeq = concatSeq.toSetSeq(); + // #pragma Trie Nodes + + + + function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce( - function(sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } + + ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; } - }, - 0 - ); - return concatSeq; - } + } + return notSetValue; + }; + ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; - function flattenFactory(iterable, depth, useKeys) { - var flatSequence = makeSequence(iterable); - flatSequence.__iterateUncached = function(fn, reverse) { - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) {var this$0 = this; - iter.__iterate(function(v, k) { - if ((!depth || currentDepth < depth) && isIterable(v)) { - flatDeep(v, currentDepth + 1); - } else if (fn(v, useKeys ? k : iterations++, this$0) === false) { - stopped = true; - } - return !stopped; - }, reverse); - } - flatDeep(iterable, 0); - return iterations; - } - flatSequence.__iteratorUncached = function(type, reverse) { - var iterator = iterable.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new src_Iterator__Iterator(function() { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isIterable(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } + var entries = this.entries; + var idx = 0; + for (var len = entries.length; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; } - return iteratorDone(); - }); - } - return flatSequence; - } + } + var exists = idx < len; + if (exists ? entries[idx][1] === value : removed) { + return this; + } - function flatMapFactory(iterable, mapper, context) { - var coerce = iterableClass(iterable); - return iterable.toSeq().map( - function(v, k) {return coerce(mapper.call(context, v, k, iterable))} - ).flatten(true); - } + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } - function interposeFactory(iterable, separator) { - var interposedSequence = makeSequence(iterable); - interposedSequence.size = iterable.size && iterable.size * 2 -1; - interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; - var iterations = 0; - iterable.__iterate(function(v, k) - {return (!iterations || fn(separator, iterations++, this$0) !== false) && - fn(v, iterations++, this$0) !== false}, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function(type, reverse) { - var iterator = iterable.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new src_Iterator__Iterator(function() { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; } - return iterations % 2 ? - iteratorValue(type, iterations++, separator) : - iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; - } + } else { + newEntries.push([key, value]); + } + if (isEditable) { + this.entries = newEntries; + return this; + } - function sortFactory(iterable, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedIterable = isKeyed(iterable); - var index = 0; - var entries = iterable.toSeq().map( - function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]} - ).toArray(); - entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach( - isKeyedIterable ? - function(v, i) { entries[i].length = 2; } : - function(v, i) { entries[i] = v[1]; } - ); - return isKeyedIterable ? KeyedSeq(entries) : - isIndexed(iterable) ? IndexedSeq(entries) : - SetSeq(entries); - } + return new ArrayMapNode(ownerID, newEntries); + }; - function maxFactory(iterable, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = iterable.toSeq() - .map(function(v, k) {return [v, mapper(v, k, iterable)]}) - .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a}); - return entry && entry[0]; - } else { - return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a}); - } - } - function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0; - } + function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; + } - function zipWithFactory(keyIter, zipper, iters) { - var zipSequence = makeSequence(keyIter); - zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function(fn, reverse) { - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } + BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); } - return iterations; - }; - zipSequence.__iteratorUncached = function(type, reverse) { - var iterators = iters.map(function(i ) - {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))} - ); - var iterations = 0; - var isDone = false; - return new src_Iterator__Iterator(function() { - var steps; - if (!isDone) { - steps = iterators.map(function(i ) {return i.next()}); - isDone = steps.some(function(s ) {return s.done}); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply(null, steps.map(function(s ) {return s.value})) - ); - }); + var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK)); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 ? notSetValue : + this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue); }; - return zipSequence - } + BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; - // #pragma Helper Functions + if (!exists && value === NOT_SET) { + return this; + } - function reify(iter, seq) { - return isSeq(iter) ? seq : iter.constructor(seq); - } + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } - } + if (newNode === node) { + return this; + } - function resolveSize(iter) { - assertNotInfinite(iter.size); - return ensureSize(iter); - } + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } - function iterableClass(iterable) { - return isKeyed(iterable) ? KeyedIterable : - isIndexed(iterable) ? IndexedIterable : - SetIterable; - } + if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) { + return nodes[idx ^ 1]; + } - function makeSequence(iterable) { - return Object.create( - ( - isKeyed(iterable) ? KeyedSeq : - isIndexed(iterable) ? IndexedSeq : - SetSeq - ).prototype - ); - } - - function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } else { - return Seq.prototype.cacheResult.call(this); - } - } - - function defaultComparator(a, b) { - return a > b ? 1 : a < b ? -1 : 0; - } - - function forceIterator(keyPath) { - var iter = getIterator(keyPath); - if (!iter) { - // Array might not be iterable in this environment, so we need a fallback - // to our wrapped type. - if (!isArrayLike(keyPath)) { - throw new TypeError('Expected iterable or array-like: ' + keyPath); + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; } - iter = getIterator(Iterable(keyPath)); - } - return iter; - } - - createClass(src_Map__Map, KeyedCollection); - - // @pragma Construction - - function src_Map__Map(value) { - return value === null || value === undefined ? emptyMap() : - isMap(value) && !isOrdered(value) ? value : - emptyMap().withMutations(function(map ) { - var iter = KeyedIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v, k) {return map.set(k, v)}); - }); - } - src_Map__Map.prototype.toString = function() { - return this.__toString('Map {', '}'); - }; + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newNodes = exists ? newNode ? + setIn(nodes, idx, newNode, isEditable) : + spliceOut(nodes, idx, isEditable) : + spliceIn(nodes, idx, newNode, isEditable); - // @pragma Access + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } - src_Map__Map.prototype.get = function(k, notSetValue) { - return this._root ? - this._root.get(0, undefined, k, notSetValue) : - notSetValue; + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); }; - // @pragma Modification - - src_Map__Map.prototype.set = function(k, v) { - return updateMap(this, k, v); - }; - src_Map__Map.prototype.setIn = function(keyPath, v) { - return this.updateIn(keyPath, NOT_SET, function() {return v}); - }; - src_Map__Map.prototype.remove = function(k) { - return updateMap(this, k, NOT_SET); - }; - src_Map__Map.prototype.deleteIn = function(keyPath) { - return this.updateIn(keyPath, function() {return NOT_SET}); - }; + function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; + } - src_Map__Map.prototype.update = function(k, notSetValue, updater) { - return arguments.length === 1 ? - k(this) : - this.updateIn([k], notSetValue, updater); + HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue; }; - src_Map__Map.prototype.updateIn = function(keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; + HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); } - var updatedValue = updateInDeepMap( - this, - forceIterator(keyPath), - notSetValue, - updater - ); - return updatedValue === NOT_SET ? undefined : updatedValue; - }; + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; - src_Map__Map.prototype.clear = function() { - if (this.size === 0) { + if (removed && !node) { return this; } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; + + var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); + if (newNode === node) { return this; } - return emptyMap(); - }; - - // @pragma Composition - - src_Map__Map.prototype.merge = function(/*...iters*/) { - return mergeIntoMapWith(this, undefined, arguments); - }; - - src_Map__Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoMapWith(this, merger, iters); - }; - - src_Map__Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); - return this.updateIn( - keyPath, - emptyMap(), - function(m ) {return typeof m.merge === 'function' ? - m.merge.apply(m, iters) : - iters[iters.length - 1]} - ); - }; - - src_Map__Map.prototype.mergeDeep = function(/*...iters*/) { - return mergeIntoMapWith(this, deepMerger(undefined), arguments); - }; - - src_Map__Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoMapWith(this, deepMerger(merger), iters); - }; - - src_Map__Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1); - return this.updateIn( - keyPath, - emptyMap(), - function(m ) {return typeof m.mergeDeep === 'function' ? - m.mergeDeep.apply(m, iters) : - iters[iters.length - 1]} - ); - }; - - src_Map__Map.prototype.sort = function(comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); - }; - - src_Map__Map.prototype.sortBy = function(mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); - }; - // @pragma Mutability - - src_Map__Map.prototype.withMutations = function(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; - }; - - src_Map__Map.prototype.asMutable = function() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); - }; - - src_Map__Map.prototype.asImmutable = function() { - return this.__ensureOwner(); - }; - - src_Map__Map.prototype.wasAltered = function() { - return this.__altered; - }; - - src_Map__Map.prototype.__iterator = function(type, reverse) { - return new MapIterator(this, type, reverse); - }; + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } - src_Map__Map.prototype.__iterate = function(fn, reverse) {var this$0 = this; - var iterations = 0; - this._root && this._root.iterate(function(entry ) { - iterations++; - return fn(entry[1], entry[0], this$0); - }, reverse); - return iterations; - }; + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setIn(nodes, idx, newNode, isEditable); - src_Map__Map.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - this.__ownerID = ownerID; - this.__altered = false; + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; return this; } - return makeMap(this.size, this._root, ownerID, this.__hash); - }; - - - function isMap(maybeMap) { - return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); - } - - src_Map__Map.isMap = isMap; - - var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - - var MapPrototype = src_Map__Map.prototype; - MapPrototype[IS_MAP_SENTINEL] = true; - MapPrototype[DELETE] = MapPrototype.remove; - MapPrototype.removeIn = MapPrototype.deleteIn; + return new HashArrayMapNode(ownerID, newCount, newNodes); + }; - // #pragma Trie Nodes - function ArrayMapNode(ownerID, entries) { + function HashCollisionNode(ownerID, keyHash, entries) { this.ownerID = ownerID; + this.keyHash = keyHash; this.entries = entries; } - ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { + HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { var entries = this.entries; for (var ii = 0, len = entries.length; ii < len; ii++) { if (is(key, entries[ii][0])) { @@ -2494,9 +2042,22 @@ return /******/ (function(modules) { // webpackBootstrap return notSetValue; }; - ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var removed = value === NOT_SET; + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + var entries = this.entries; var idx = 0; for (var len = entries.length; idx < len; idx++) { @@ -2513,12 +2074,8 @@ return /******/ (function(modules) { // webpackBootstrap SetRef(didAlter); (removed || !exists) && SetRef(didChangeSize); - if (removed && entries.length === 1) { - return; // undefined - } - - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); } var isEditable = ownerID && ownerID === this.ownerID; @@ -2539,216 +2096,13 @@ return /******/ (function(modules) { // webpackBootstrap return this; } - return new ArrayMapNode(ownerID, newEntries); + return new HashCollisionNode(ownerID, this.keyHash, newEntries); }; - function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; - } - - BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK)); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 ? notSetValue : - this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue); - }; - - BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; - - if (!exists && value === NOT_SET) { - return this; - } - - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - - if (newNode === node) { - return this; - } - - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } - - if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) { - return nodes[idx ^ 1]; - } - - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; - var newNodes = exists ? newNode ? - setIn(nodes, idx, newNode, isEditable) : - spliceOut(nodes, idx, isEditable) : - spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; - } - - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); - }; - - - - - function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; - } - - HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue; - }; - - HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - - if (removed && !node) { - return this; - } - - var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter); - if (newNode === node) { - return this; - } - - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); - } - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; - } - - return new HashArrayMapNode(ownerID, newCount, newNodes); - }; - - - - - function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; - } - - HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; - }; - - HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - - var removed = value === NOT_SET; - - if (keyHash !== this.keyHash) { - if (removed) { - return this; - } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); - } - - var entries = this.entries; - var idx = 0; - for (var len = entries.length; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new HashCollisionNode(ownerID, this.keyHash, newEntries); - }; - - - - - function ValueNode(ownerID, keyHash, entry) { + function ValueNode(ownerID, keyHash, entry) { this.ownerID = ownerID; this.keyHash = keyHash; this.entry = entry; @@ -2813,7 +2167,7 @@ return /******/ (function(modules) { // webpackBootstrap return fn(this.entry); } - createClass(MapIterator, src_Iterator__Iterator); + createClass(MapIterator, Iterator); function MapIterator(map, type, reverse) { this._type = type; @@ -2992,11 +2346,20 @@ return /******/ (function(modules) { // webpackBootstrap return mergeIntoCollectionWith(map, merger, iters); } - function deepMerger(merger) { - return function(existing, value, key) - {return existing && existing.mergeDeepWith && isIterable(value) ? - existing.mergeDeepWith(merger, value) : - merger ? merger(existing, value, key) : value}; + function deepMerger(existing, value, key) { + return existing && existing.mergeDeep && isIterable(value) ? + existing.mergeDeep(value) : + is(existing, value) ? existing : value; + } + + function deepMergerWith(merger) { + return function(existing, value, key) { + if (existing && existing.mergeDeepWith && isIterable(value)) { + return existing.mergeDeepWith(merger, value); + } + var nextValue = merger(existing, value, key); + return is(existing, nextValue) ? existing : nextValue; + }; } function mergeIntoCollectionWith(collection, merger, iters) { @@ -3163,6 +2526,10 @@ return /******/ (function(modules) { // webpackBootstrap this.splice(index, 1); }; + List.prototype.insert = function(index, value) { + return this.splice(index, 0, value); + }; + List.prototype.clear = function() { if (this.size === 0) { return this; @@ -3218,11 +2585,11 @@ return /******/ (function(modules) { // webpackBootstrap }; List.prototype.mergeDeep = function(/*...iters*/) { - return mergeIntoListWith(this, deepMerger(undefined), arguments); + return mergeIntoListWith(this, deepMerger, arguments); }; List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1); - return mergeIntoListWith(this, deepMerger(merger), iters); + return mergeIntoListWith(this, deepMergerWith(merger), iters); }; List.prototype.setSize = function(size) { @@ -3246,7 +2613,7 @@ return /******/ (function(modules) { // webpackBootstrap List.prototype.__iterator = function(type, reverse) { var index = 0; var values = iterateList(this, reverse); - return new src_Iterator__Iterator(function() { + return new Iterator(function() { var value = values(); return value === DONE ? iteratorDone() : @@ -3687,386 +3054,1156 @@ return /******/ (function(modules) { // webpackBootstrap if (maxSize > list.size) { list = list.setSize(maxSize); } - return mergeIntoCollectionWith(list, merger, iters); - } - - function getTailOffset(size) { - return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT); + return mergeIntoCollectionWith(list, merger, iters); + } + + function getTailOffset(size) { + return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT); + } + + createClass(OrderedMap, Map); + + // @pragma Construction + + function OrderedMap(value) { + return value === null || value === undefined ? emptyOrderedMap() : + isOrderedMap(value) ? value : + emptyOrderedMap().withMutations(function(map ) { + var iter = KeyedIterable(value); + assertNotInfinite(iter.size); + iter.forEach(function(v, k) {return map.set(k, v)}); + }); + } + + OrderedMap.of = function(/*...values*/) { + return this(arguments); + }; + + OrderedMap.prototype.toString = function() { + return this.__toString('OrderedMap {', '}'); + }; + + // @pragma Access + + OrderedMap.prototype.get = function(k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; + + // @pragma Modification + + OrderedMap.prototype.clear = function() { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + return this; + } + return emptyOrderedMap(); + }; + + OrderedMap.prototype.set = function(k, v) { + return updateOrderedMap(this, k, v); + }; + + OrderedMap.prototype.remove = function(k) { + return updateOrderedMap(this, k, NOT_SET); + }; + + OrderedMap.prototype.wasAltered = function() { + return this._map.wasAltered() || this._list.wasAltered(); + }; + + OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._list.__iterate( + function(entry ) {return entry && fn(entry[1], entry[0], this$0)}, + reverse + ); + }; + + OrderedMap.prototype.__iterator = function(type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; + + OrderedMap.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; + + + function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); + } + + OrderedMap.isOrderedMap = isOrderedMap; + + OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; + OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + + + + function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + return omap; + } + + var EMPTY_ORDERED_MAP; + function emptyOrderedMap() { + return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); + } + + function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx}); + newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap(); + if (omap.__ownerID) { + newMap.__ownerID = newList.__ownerID = omap.__ownerID; + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); + } + } else { + if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + return omap; + } + return makeOrderedMap(newMap, newList); + } + + createClass(ToKeyedSequence, KeyedSeq); + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + ToKeyedSequence.prototype.get = function(key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function(key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function() { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function() {var this$0 = this; + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()}; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this; + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)}; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + var ii; + return this._iter.__iterate( + this._useKeys ? + function(v, k) {return fn(v, k, this$0)} : + ((ii = reverse ? resolveSize(this) : 0), + function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}), + reverse + ); + }; + + ToKeyedSequence.prototype.__iterator = function(type, reverse) { + if (this._useKeys) { + return this._iter.__iterator(type, reverse); + } + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var ii = reverse ? resolveSize(this) : 0; + return new Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, reverse ? --ii : ii++, step.value, step); + }); + }; + + ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; + + + createClass(ToIndexedSequence, IndexedSeq); + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + ToIndexedSequence.prototype.includes = function(value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + var iterations = 0; + return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse); + }; + + ToIndexedSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + return new Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, iterations++, step.value, step) + }); + }; + + + + createClass(ToSetSequence, SetSeq); + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + ToSetSequence.prototype.has = function(key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse); + }; + + ToSetSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function() { + var step = iterator.next(); + return step.done ? step : + iteratorValue(type, step.value, step.value, step); + }); + }; + + + + createClass(FromEntriesSequence, KeyedSeq); + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + FromEntriesSequence.prototype.entrySeq = function() { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return this._iter.__iterate(function(entry ) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedIterable = isIterable(entry); + return fn( + indexedIterable ? entry.get(1) : entry[1], + indexedIterable ? entry.get(0) : entry[0], + this$0 + ); + } + }, reverse); + }; + + FromEntriesSequence.prototype.__iterator = function(type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function() { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedIterable = isIterable(entry); + return iteratorValue( + type, + indexedIterable ? entry.get(0) : entry[0], + indexedIterable ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + + ToIndexedSequence.prototype.cacheResult = + ToKeyedSequence.prototype.cacheResult = + ToSetSequence.prototype.cacheResult = + FromEntriesSequence.prototype.cacheResult = + cacheResultThrough; + + + function flipFactory(iterable) { + var flipSequence = makeSequence(iterable); + flipSequence._iter = iterable; + flipSequence.size = iterable.size; + flipSequence.flip = function() {return iterable}; + flipSequence.reverse = function () { + var reversedSequence = iterable.reverse.apply(this); // super.reverse() + reversedSequence.flip = function() {return iterable.reverse()}; + return reversedSequence; + }; + flipSequence.has = function(key ) {return iterable.includes(key)}; + flipSequence.includes = function(key ) {return iterable.has(key)}; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse); + } + flipSequence.__iteratorUncached = function(type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = iterable.__iterator(type, reverse); + return new Iterator(function() { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return iterable.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + } + return flipSequence; + } + + + function mapFactory(iterable, mapper, context) { + var mappedSequence = makeSequence(iterable); + mappedSequence.size = iterable.size; + mappedSequence.has = function(key ) {return iterable.has(key)}; + mappedSequence.get = function(key, notSetValue) { + var v = iterable.get(key, NOT_SET); + return v === NOT_SET ? + notSetValue : + mapper.call(context, v, key, iterable); + }; + mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + return iterable.__iterate( + function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false}, + reverse + ); + } + mappedSequence.__iteratorUncached = function (type, reverse) { + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function() { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, iterable), + step + ); + }); + } + return mappedSequence; + } + + + function reverseFactory(iterable, useKeys) { + var reversedSequence = makeSequence(iterable); + reversedSequence._iter = iterable; + reversedSequence.size = iterable.size; + reversedSequence.reverse = function() {return iterable}; + if (iterable.flip) { + reversedSequence.flip = function () { + var flipSequence = flipFactory(iterable); + flipSequence.reverse = function() {return iterable.flip()}; + return flipSequence; + }; + } + reversedSequence.get = function(key, notSetValue) + {return iterable.get(useKeys ? key : -1 - key, notSetValue)}; + reversedSequence.has = function(key ) + {return iterable.has(useKeys ? key : -1 - key)}; + reversedSequence.includes = function(value ) {return iterable.includes(value)}; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function (fn, reverse) {var this$0 = this; + return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse); + }; + reversedSequence.__iterator = + function(type, reverse) {return iterable.__iterator(type, !reverse)}; + return reversedSequence; + } + + + function filterFactory(iterable, predicate, context, useKeys) { + var filterSequence = makeSequence(iterable); + if (useKeys) { + filterSequence.has = function(key ) { + var v = iterable.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, iterable); + }; + filterSequence.get = function(key, notSetValue) { + var v = iterable.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, iterable) ? + v : notSetValue; + }; + } + filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + var iterations = 0; + iterable.__iterate(function(v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0); + } + }, reverse); + return iterations; + }; + filterSequence.__iteratorUncached = function (type, reverse) { + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function() { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, iterable)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + } + return filterSequence; + } + + + function countByFactory(iterable, grouper, context) { + var groups = Map().asMutable(); + iterable.__iterate(function(v, k) { + groups.update( + grouper.call(context, v, k, iterable), + 0, + function(a ) {return a + 1} + ); + }); + return groups.asImmutable(); + } + + + function groupByFactory(iterable, grouper, context) { + var isKeyedIter = isKeyed(iterable); + var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable(); + iterable.__iterate(function(v, k) { + groups.update( + grouper.call(context, v, k, iterable), + function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)} + ); + }); + var coerce = iterableClass(iterable); + return groups.map(function(arr ) {return reify(iterable, coerce(arr))}); + } + + + function sliceFactory(iterable, begin, end, useKeys) { + var originalSize = iterable.size; + + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin = begin | 0; + } + if (end !== undefined) { + end = end | 0; + } + + if (wholeSlice(begin, end, originalSize)) { + return iterable; + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // begin or end will be NaN if they were provided as negative numbers and + // this iterable's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys); + } + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(iterable); + + // If iterable.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined; + + if (!useKeys && isSeq(iterable) && sliceSize >= 0) { + sliceSeq.get = function (index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize ? + iterable.get(index + resolvedBegin, notSetValue) : + notSetValue; + } + } + + sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this; + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + iterable.__iterate(function(v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0) !== false && + iterations !== sliceSize; + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function(type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function() { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES) { + return step; + } else if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } else { + return iteratorValue(type, iterations - 1, step.value[1], step); + } + }); + } + + return sliceSeq; + } + + + function takeWhileFactory(iterable, predicate, context) { + var takeSequence = makeSequence(iterable); + takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + iterable.__iterate(function(v, k, c) + {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)} + ); + return iterations; + }; + takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function() { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$0)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : + iteratorValue(type, k, v, step); + }); + }; + return takeSequence; + } + + + function skipWhileFactory(iterable, predicate, context, useKeys) { + var skipSequence = makeSequence(iterable); + skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + iterable.__iterate(function(v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$0); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this; + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function() { + var step, k, v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } else if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } else { + return iteratorValue(type, iterations++, step.value[1], step); + } + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$0)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : + iteratorValue(type, k, v, step); + }); + }; + return skipSequence; + } + + + function concatFactory(iterable, values) { + var isKeyedIterable = isKeyed(iterable); + var iters = [iterable].concat(values).map(function(v ) { + if (!isIterable(v)) { + v = isKeyedIterable ? + keyedSeqFromValue(v) : + indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedIterable) { + v = KeyedIterable(v); + } + return v; + }).filter(function(v ) {return v.size !== 0}); + + if (iters.length === 0) { + return iterable; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if (singleton === iterable || + isKeyedIterable && isKeyed(singleton) || + isIndexed(iterable) && isIndexed(singleton)) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedIterable) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(iterable)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce( + function(sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, + 0 + ); + return concatSeq; + } + + + function flattenFactory(iterable, depth, useKeys) { + var flatSequence = makeSequence(iterable); + flatSequence.__iterateUncached = function(fn, reverse) { + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) {var this$0 = this; + iter.__iterate(function(v, k) { + if ((!depth || currentDepth < depth) && isIterable(v)) { + flatDeep(v, currentDepth + 1); + } else if (fn(v, useKeys ? k : iterations++, this$0) === false) { + stopped = true; + } + return !stopped; + }, reverse); + } + flatDeep(iterable, 0); + return iterations; + } + flatSequence.__iteratorUncached = function(type, reverse) { + var iterator = iterable.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function() { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isIterable(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + } + return flatSequence; } - createClass(OrderedMap, src_Map__Map); - // @pragma Construction + function flatMapFactory(iterable, mapper, context) { + var coerce = iterableClass(iterable); + return iterable.toSeq().map( + function(v, k) {return coerce(mapper.call(context, v, k, iterable))} + ).flatten(true); + } - function OrderedMap(value) { - return value === null || value === undefined ? emptyOrderedMap() : - isOrderedMap(value) ? value : - emptyOrderedMap().withMutations(function(map ) { - var iter = KeyedIterable(value); - assertNotInfinite(iter.size); - iter.forEach(function(v, k) {return map.set(k, v)}); - }); - } - OrderedMap.of = function(/*...values*/) { - return this(arguments); + function interposeFactory(iterable, separator) { + var interposedSequence = makeSequence(iterable); + interposedSequence.size = iterable.size && iterable.size * 2 -1; + interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this; + var iterations = 0; + iterable.__iterate(function(v, k) + {return (!iterations || fn(separator, iterations++, this$0) !== false) && + fn(v, iterations++, this$0) !== false}, + reverse + ); + return iterations; }; - - OrderedMap.prototype.toString = function() { - return this.__toString('OrderedMap {', '}'); + interposedSequence.__iteratorUncached = function(type, reverse) { + var iterator = iterable.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function() { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 ? + iteratorValue(type, iterations++, separator) : + iteratorValue(type, iterations++, step.value, step); + }); }; + return interposedSequence; + } - // @pragma Access - OrderedMap.prototype.get = function(k, notSetValue) { - var index = this._map.get(k); - return index !== undefined ? this._list.get(index)[1] : notSetValue; - }; + function sortFactory(iterable, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedIterable = isKeyed(iterable); + var index = 0; + var entries = iterable.toSeq().map( + function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]} + ).toArray(); + entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach( + isKeyedIterable ? + function(v, i) { entries[i].length = 2; } : + function(v, i) { entries[i] = v[1]; } + ); + return isKeyedIterable ? KeyedSeq(entries) : + isIndexed(iterable) ? IndexedSeq(entries) : + SetSeq(entries); + } - // @pragma Modification - OrderedMap.prototype.clear = function() { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._map.clear(); - this._list.clear(); - return this; - } - return emptyOrderedMap(); - }; + function maxFactory(iterable, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = iterable.toSeq() + .map(function(v, k) {return [v, mapper(v, k, iterable)]}) + .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a}); + return entry && entry[0]; + } else { + return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a}); + } + } - OrderedMap.prototype.set = function(k, v) { - return updateOrderedMap(this, k, v); - }; + function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0; + } - OrderedMap.prototype.remove = function(k) { - return updateOrderedMap(this, k, NOT_SET); - }; - OrderedMap.prototype.wasAltered = function() { - return this._map.wasAltered() || this._list.wasAltered(); + function zipWithFactory(keyIter, zipper, iters) { + var zipSequence = makeSequence(keyIter); + zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + return iterations; }; - - OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return this._list.__iterate( - function(entry ) {return entry && fn(entry[1], entry[0], this$0)}, - reverse + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map(function(i ) + {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))} ); + var iterations = 0; + var isDone = false; + return new Iterator(function() { + var steps; + if (!isDone) { + steps = iterators.map(function(i ) {return i.next()}); + isDone = steps.some(function(s ) {return s.done}); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function(s ) {return s.value})) + ); + }); }; + return zipSequence + } - OrderedMap.prototype.__iterator = function(type, reverse) { - return this._list.fromEntrySeq().__iterator(type, reverse); - }; - - OrderedMap.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - var newList = this._list.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._map = newMap; - this._list = newList; - return this; - } - return makeOrderedMap(newMap, newList, ownerID, this.__hash); - }; + // #pragma Helper Functions - function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); + function reify(iter, seq) { + return isSeq(iter) ? seq : iter.constructor(seq); } - OrderedMap.isOrderedMap = isOrderedMap; + function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } + } - OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; - OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + function resolveSize(iter) { + assertNotInfinite(iter.size); + return ensureSize(iter); + } + function iterableClass(iterable) { + return isKeyed(iterable) ? KeyedIterable : + isIndexed(iterable) ? IndexedIterable : + SetIterable; + } + function makeSequence(iterable) { + return Object.create( + ( + isKeyed(iterable) ? KeyedSeq : + isIndexed(iterable) ? IndexedSeq : + SetSeq + ).prototype + ); + } - function makeOrderedMap(map, list, ownerID, hash) { - var omap = Object.create(OrderedMap.prototype); - omap.size = map ? map.size : 0; - omap._map = map; - omap._list = list; - omap.__ownerID = ownerID; - omap.__hash = hash; - return omap; + function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } else { + return Seq.prototype.cacheResult.call(this); + } } - var EMPTY_ORDERED_MAP; - function emptyOrderedMap() { - return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); + function defaultComparator(a, b) { + return a > b ? 1 : a < b ? -1 : 0; } - function updateOrderedMap(omap, k, v) { - var map = omap._map; - var list = omap._list; - var i = map.get(k); - var has = i !== undefined; - var newMap; - var newList; - if (v === NOT_SET) { // removed - if (!has) { - return omap; - } - if (list.size >= SIZE && list.size >= map.size * 2) { - newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx}); - newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap(); - if (omap.__ownerID) { - newMap.__ownerID = newList.__ownerID = omap.__ownerID; - } - } else { - newMap = map.remove(k); - newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); - } - } else { - if (has) { - if (v === list.get(i)[1]) { - return omap; - } - newMap = map; - newList = list.set(i, [k, v]); - } else { - newMap = map.set(k, list.size); - newList = list.set(list.size, [k, v]); + function forceIterator(keyPath) { + var iter = getIterator(keyPath); + if (!iter) { + // Array might not be iterable in this environment, so we need a fallback + // to our wrapped type. + if (!isArrayLike(keyPath)) { + throw new TypeError('Expected iterable or array-like: ' + keyPath); } + iter = getIterator(Iterable(keyPath)); } - if (omap.__ownerID) { - omap.size = newMap.size; - omap._map = newMap; - omap._list = newList; - omap.__hash = undefined; - return omap; - } - return makeOrderedMap(newMap, newList); + return iter; } - createClass(Stack, IndexedCollection); + createClass(Record, KeyedCollection); - // @pragma Construction + function Record(defaultValues, name) { + var hasInitialized; - function Stack(value) { - return value === null || value === undefined ? emptyStack() : - isStack(value) ? value : - emptyStack().unshiftAll(value); - } + var RecordType = function Record(values) { + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + setProps(RecordTypePrototype, keys); + RecordTypePrototype.size = keys.length; + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + } + this._map = Map(values); + }; - Stack.of = function(/*...values*/) { - return this(arguments); - }; + var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype); + RecordTypePrototype.constructor = RecordType; - Stack.prototype.toString = function() { - return this.__toString('Stack [', ']'); + return RecordType; + } + + Record.prototype.toString = function() { + return this.__toString(recordName(this) + ' {', '}'); }; // @pragma Access - Stack.prototype.get = function(index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; - } - return head ? head.value : notSetValue; + Record.prototype.has = function(k) { + return this._defaultValues.hasOwnProperty(k); }; - Stack.prototype.peek = function() { - return this._head && this._head.value; + Record.prototype.get = function(k, notSetValue) { + if (!this.has(k)) { + return notSetValue; + } + var defaultVal = this._defaultValues[k]; + return this._map ? this._map.get(k, defaultVal) : defaultVal; }; // @pragma Modification - Stack.prototype.push = function(/*...values*/) { - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments[ii], - next: head - }; - } + Record.prototype.clear = function() { if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; + this._map && this._map.clear(); return this; } - return makeStack(newSize, head); + var RecordType = this.constructor; + return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap())); }; - Stack.prototype.pushAll = function(iter) { - iter = IndexedIterable(iter); - if (iter.size === 0) { - return this; + Record.prototype.set = function(k, v) { + if (!this.has(k)) { + throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this)); } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.reverse().forEach(function(value ) { - newSize++; - head = { - value: value, - next: head - }; - }); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; + var newMap = this._map && this._map.set(k, v); + if (this.__ownerID || newMap === this._map) { return this; } - return makeStack(newSize, head); - }; - - Stack.prototype.pop = function() { - return this.slice(1); - }; - - Stack.prototype.unshift = function(/*...values*/) { - return this.push.apply(this, arguments); - }; - - Stack.prototype.unshiftAll = function(iter) { - return this.pushAll(iter); - }; - - Stack.prototype.shift = function() { - return this.pop.apply(this, arguments); + return makeRecord(this, newMap); }; - Stack.prototype.clear = function() { - if (this.size === 0) { + Record.prototype.remove = function(k) { + if (!this.has(k)) { return this; } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; + var newMap = this._map && this._map.remove(k); + if (this.__ownerID || newMap === this._map) { return this; } - return emptyStack(); + return makeRecord(this, newMap); }; - Stack.prototype.slice = function(begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); + Record.prototype.wasAltered = function() { + return this._map.wasAltered(); }; - // @pragma Mutability + Record.prototype.__iterator = function(type, reverse) {var this$0 = this; + return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse); + }; - Stack.prototype.__ensureOwner = function(ownerID) { + Record.prototype.__iterate = function(fn, reverse) {var this$0 = this; + return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse); + }; + + Record.prototype.__ensureOwner = function(ownerID) { if (ownerID === this.__ownerID) { return this; } + var newMap = this._map && this._map.__ensureOwner(ownerID); if (!ownerID) { this.__ownerID = ownerID; - this.__altered = false; + this._map = newMap; return this; } - return makeStack(this.size, this._head, ownerID, this.__hash); + return makeRecord(this, newMap, ownerID); }; - // @pragma Iteration - - Stack.prototype.__iterate = function(fn, reverse) { - if (reverse) { - return this.reverse().__iterate(fn); - } - var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this) === false) { - break; - } - node = node.next; - } - return iterations; - }; - Stack.prototype.__iterator = function(type, reverse) { - if (reverse) { - return this.reverse().__iterator(type); - } - var iterations = 0; - var node = this._head; - return new src_Iterator__Iterator(function() { - if (node) { - var value = node.value; - node = node.next; - return iteratorValue(type, iterations++, value); - } - return iteratorDone(); - }); - }; + var RecordPrototype = Record.prototype; + RecordPrototype[DELETE] = RecordPrototype.remove; + RecordPrototype.deleteIn = + RecordPrototype.removeIn = MapPrototype.removeIn; + RecordPrototype.merge = MapPrototype.merge; + RecordPrototype.mergeWith = MapPrototype.mergeWith; + RecordPrototype.mergeIn = MapPrototype.mergeIn; + RecordPrototype.mergeDeep = MapPrototype.mergeDeep; + RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; + RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; + RecordPrototype.setIn = MapPrototype.setIn; + RecordPrototype.update = MapPrototype.update; + RecordPrototype.updateIn = MapPrototype.updateIn; + RecordPrototype.withMutations = MapPrototype.withMutations; + RecordPrototype.asMutable = MapPrototype.asMutable; + RecordPrototype.asImmutable = MapPrototype.asImmutable; - function isStack(maybeStack) { - return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); + function makeRecord(likeRecord, map, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._map = map; + record.__ownerID = ownerID; + return record; } - Stack.isStack = isStack; - - var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; - - var StackPrototype = Stack.prototype; - StackPrototype[IS_STACK_SENTINEL] = true; - StackPrototype.withMutations = MapPrototype.withMutations; - StackPrototype.asMutable = MapPrototype.asMutable; - StackPrototype.asImmutable = MapPrototype.asImmutable; - StackPrototype.wasAltered = MapPrototype.wasAltered; - + function recordName(record) { + return record._name || record.constructor.name || 'Record'; + } - function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; + function setProps(prototype, names) { + try { + names.forEach(setProp.bind(undefined, prototype)); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } } - var EMPTY_STACK; - function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); + function setProp(prototype, name) { + Object.defineProperty(prototype, name, { + get: function() { + return this.get(name); + }, + set: function(value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + } + }); } - createClass(src_Set__Set, SetCollection); + createClass(Set, SetCollection); // @pragma Construction - function src_Set__Set(value) { + function Set(value) { return value === null || value === undefined ? emptySet() : isSet(value) && !isOrdered(value) ? value : emptySet().withMutations(function(set ) { @@ -4076,41 +4213,41 @@ return /******/ (function(modules) { // webpackBootstrap }); } - src_Set__Set.of = function(/*...values*/) { + Set.of = function(/*...values*/) { return this(arguments); }; - src_Set__Set.fromKeys = function(value) { + Set.fromKeys = function(value) { return this(KeyedIterable(value).keySeq()); }; - src_Set__Set.prototype.toString = function() { + Set.prototype.toString = function() { return this.__toString('Set {', '}'); }; // @pragma Access - src_Set__Set.prototype.has = function(value) { + Set.prototype.has = function(value) { return this._map.has(value); }; // @pragma Modification - src_Set__Set.prototype.add = function(value) { + Set.prototype.add = function(value) { return updateSet(this, this._map.set(value, true)); }; - src_Set__Set.prototype.remove = function(value) { + Set.prototype.remove = function(value) { return updateSet(this, this._map.remove(value)); }; - src_Set__Set.prototype.clear = function() { + Set.prototype.clear = function() { return updateSet(this, this._map.clear()); }; // @pragma Composition - src_Set__Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0); + Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0); iters = iters.filter(function(x ) {return x.size !== 0}); if (iters.length === 0) { return this; @@ -4125,7 +4262,7 @@ return /******/ (function(modules) { // webpackBootstrap }); }; - src_Set__Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0); + Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0); if (iters.length === 0) { return this; } @@ -4140,7 +4277,7 @@ return /******/ (function(modules) { // webpackBootstrap }); }; - src_Set__Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0); + Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0); if (iters.length === 0) { return this; } @@ -4155,37 +4292,37 @@ return /******/ (function(modules) { // webpackBootstrap }); }; - src_Set__Set.prototype.merge = function() { + Set.prototype.merge = function() { return this.union.apply(this, arguments); }; - src_Set__Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); + Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1); return this.union.apply(this, iters); }; - src_Set__Set.prototype.sort = function(comparator) { + Set.prototype.sort = function(comparator) { // Late binding return OrderedSet(sortFactory(this, comparator)); }; - src_Set__Set.prototype.sortBy = function(mapper, comparator) { + Set.prototype.sortBy = function(mapper, comparator) { // Late binding return OrderedSet(sortFactory(this, comparator, mapper)); }; - src_Set__Set.prototype.wasAltered = function() { + Set.prototype.wasAltered = function() { return this._map.wasAltered(); }; - src_Set__Set.prototype.__iterate = function(fn, reverse) {var this$0 = this; + Set.prototype.__iterate = function(fn, reverse) {var this$0 = this; return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse); }; - src_Set__Set.prototype.__iterator = function(type, reverse) { + Set.prototype.__iterator = function(type, reverse) { return this._map.map(function(_, k) {return k}).__iterator(type, reverse); }; - src_Set__Set.prototype.__ensureOwner = function(ownerID) { + Set.prototype.__ensureOwner = function(ownerID) { if (ownerID === this.__ownerID) { return this; } @@ -4203,11 +4340,11 @@ return /******/ (function(modules) { // webpackBootstrap return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); } - src_Set__Set.isSet = isSet; + Set.isSet = isSet; var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; - var SetPrototype = src_Set__Set.prototype; + var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; SetPrototype.mergeDeep = SetPrototype.merge; @@ -4243,7 +4380,7 @@ return /******/ (function(modules) { // webpackBootstrap return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); } - createClass(OrderedSet, src_Set__Set); + createClass(OrderedSet, Set); // @pragma Construction @@ -4267,439 +4404,249 @@ return /******/ (function(modules) { // webpackBootstrap OrderedSet.prototype.toString = function() { return this.__toString('OrderedSet {', '}'); - }; - - - function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); - } - - OrderedSet.isOrderedSet = isOrderedSet; - - var OrderedSetPrototype = OrderedSet.prototype; - OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; - - OrderedSetPrototype.__empty = emptyOrderedSet; - OrderedSetPrototype.__make = makeOrderedSet; - - function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; - } - - var EMPTY_ORDERED_SET; - function emptyOrderedSet() { - return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); - } - - createClass(Record, KeyedCollection); - - function Record(defaultValues, name) { - var hasInitialized; - - var RecordType = function Record(values) { - if (values instanceof RecordType) { - return values; - } - if (!(this instanceof RecordType)) { - return new RecordType(values); - } - if (!hasInitialized) { - hasInitialized = true; - var keys = Object.keys(defaultValues); - setProps(RecordTypePrototype, keys); - RecordTypePrototype.size = keys.length; - RecordTypePrototype._name = name; - RecordTypePrototype._keys = keys; - RecordTypePrototype._defaultValues = defaultValues; - } - this._map = src_Map__Map(values); - }; - - var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype); - RecordTypePrototype.constructor = RecordType; - - return RecordType; - } - - Record.prototype.toString = function() { - return this.__toString(recordName(this) + ' {', '}'); - }; - - // @pragma Access - - Record.prototype.has = function(k) { - return this._defaultValues.hasOwnProperty(k); - }; - - Record.prototype.get = function(k, notSetValue) { - if (!this.has(k)) { - return notSetValue; - } - var defaultVal = this._defaultValues[k]; - return this._map ? this._map.get(k, defaultVal) : defaultVal; - }; - - // @pragma Modification - - Record.prototype.clear = function() { - if (this.__ownerID) { - this._map && this._map.clear(); - return this; - } - var RecordType = this.constructor; - return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap())); - }; - - Record.prototype.set = function(k, v) { - if (!this.has(k)) { - throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this)); - } - var newMap = this._map && this._map.set(k, v); - if (this.__ownerID || newMap === this._map) { - return this; - } - return makeRecord(this, newMap); - }; - - Record.prototype.remove = function(k) { - if (!this.has(k)) { - return this; - } - var newMap = this._map && this._map.remove(k); - if (this.__ownerID || newMap === this._map) { - return this; - } - return makeRecord(this, newMap); - }; - - Record.prototype.wasAltered = function() { - return this._map.wasAltered(); - }; - - Record.prototype.__iterator = function(type, reverse) {var this$0 = this; - return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse); - }; - - Record.prototype.__iterate = function(fn, reverse) {var this$0 = this; - return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse); - }; - - Record.prototype.__ensureOwner = function(ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map && this._map.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return makeRecord(this, newMap, ownerID); - }; - - - var RecordPrototype = Record.prototype; - RecordPrototype[DELETE] = RecordPrototype.remove; - RecordPrototype.deleteIn = - RecordPrototype.removeIn = MapPrototype.removeIn; - RecordPrototype.merge = MapPrototype.merge; - RecordPrototype.mergeWith = MapPrototype.mergeWith; - RecordPrototype.mergeIn = MapPrototype.mergeIn; - RecordPrototype.mergeDeep = MapPrototype.mergeDeep; - RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; - RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; - RecordPrototype.setIn = MapPrototype.setIn; - RecordPrototype.update = MapPrototype.update; - RecordPrototype.updateIn = MapPrototype.updateIn; - RecordPrototype.withMutations = MapPrototype.withMutations; - RecordPrototype.asMutable = MapPrototype.asMutable; - RecordPrototype.asImmutable = MapPrototype.asImmutable; - - - function makeRecord(likeRecord, map, ownerID) { - var record = Object.create(Object.getPrototypeOf(likeRecord)); - record._map = map; - record.__ownerID = ownerID; - return record; - } - - function recordName(record) { - return record._name || record.constructor.name || 'Record'; - } - - function setProps(prototype, names) { - try { - names.forEach(setProp.bind(undefined, prototype)); - } catch (error) { - // Object.defineProperty failed. Probably IE8. - } - } - - function setProp(prototype, name) { - Object.defineProperty(prototype, name, { - get: function() { - return this.get(name); - }, - set: function(value) { - invariant(this.__ownerID, 'Cannot set on an immutable record.'); - this.set(name, value); - } - }); - } - - function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isIterable(b) || - a.size !== undefined && b.size !== undefined && a.size !== b.size || - a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; - } + }; - if (a.size === 0 && b.size === 0) { - return true; - } - var notAssociative = !isAssociative(a); + function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + } - if (isOrdered(a)) { - var entries = a.entries(); - return b.every(function(v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done; - } + OrderedSet.isOrderedSet = isOrderedSet; - var flipped = false; + var OrderedSetPrototype = OrderedSet.prototype; + OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } - } + OrderedSetPrototype.__empty = emptyOrderedSet; + OrderedSetPrototype.__make = makeOrderedSet; - var allEqual = true; - var bSize = b.__iterate(function(v, k) { - if (notAssociative ? !a.has(v) : - flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) { - allEqual = false; - return false; - } - }); + function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; + } - return allEqual && a.size === bSize; + var EMPTY_ORDERED_SET; + function emptyOrderedSet() { + return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); } - createClass(Range, IndexedSeq); + createClass(Stack, IndexedCollection); - function Range(start, end, step) { - if (!(this instanceof Range)) { - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - start = start || 0; - if (end === undefined) { - end = Infinity; - } - step = step === undefined ? 1 : Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { - return EMPTY_RANGE; - } - EMPTY_RANGE = this; - } + // @pragma Construction + + function Stack(value) { + return value === null || value === undefined ? emptyStack() : + isStack(value) ? value : + emptyStack().unshiftAll(value); } - Range.prototype.toString = function() { - if (this.size === 0) { - return 'Range []'; - } - return 'Range [ ' + - this._start + '...' + this._end + - (this._step > 1 ? ' by ' + this._step : '') + - ' ]'; + Stack.of = function(/*...values*/) { + return this(arguments); }; - Range.prototype.get = function(index, notSetValue) { - return this.has(index) ? - this._start + wrapIndex(this, index) * this._step : - notSetValue; + Stack.prototype.toString = function() { + return this.__toString('Stack [', ']'); }; - Range.prototype.includes = function(searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex); - }; + // @pragma Access - Range.prototype.slice = function(begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); + Stack.prototype.get = function(index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; } - return new Range(this.get(begin, this._end), this.get(end, this._end), this._step); + return head ? head.value : notSetValue; }; - Range.prototype.indexOf = function(searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index - } - } - return -1; + Stack.prototype.peek = function() { + return this._head && this._head.value; }; - Range.prototype.lastIndexOf = function(searchValue) { - return this.indexOf(searchValue); - }; + // @pragma Modification - Range.prototype.__iterate = function(fn, reverse) { - var maxIndex = this.size - 1; - var step = this._step; - var value = reverse ? this._start + maxIndex * step : this._start; - for (var ii = 0; ii <= maxIndex; ii++) { - if (fn(value, ii, this) === false) { - return ii + 1; - } - value += reverse ? -step : step; + Stack.prototype.push = function(/*...values*/) { + if (arguments.length === 0) { + return this; } - return ii; + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments[ii], + next: head + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); }; - Range.prototype.__iterator = function(type, reverse) { - var maxIndex = this.size - 1; - var step = this._step; - var value = reverse ? this._start + maxIndex * step : this._start; - var ii = 0; - return new src_Iterator__Iterator(function() { - var v = value; - value += reverse ? -step : step; - return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v); + Stack.prototype.pushAll = function(iter) { + iter = IndexedIterable(iter); + if (iter.size === 0) { + return this; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.reverse().forEach(function(value ) { + newSize++; + head = { + value: value, + next: head + }; }); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); }; - Range.prototype.equals = function(other) { - return other instanceof Range ? - this._start === other._start && - this._end === other._end && - this._step === other._step : - deepEqual(this, other); + Stack.prototype.pop = function() { + return this.slice(1); }; + Stack.prototype.unshift = function(/*...values*/) { + return this.push.apply(this, arguments); + }; - var EMPTY_RANGE; + Stack.prototype.unshiftAll = function(iter) { + return this.pushAll(iter); + }; - createClass(Repeat, IndexedSeq); + Stack.prototype.shift = function() { + return this.pop.apply(this, arguments); + }; - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - return new Repeat(value, times); - } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); + Stack.prototype.clear = function() { if (this.size === 0) { - if (EMPTY_REPEAT) { - return EMPTY_REPEAT; - } - EMPTY_REPEAT = this; + return this; } - } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; - Repeat.prototype.toString = function() { - if (this.size === 0) { - return 'Repeat []'; + Stack.prototype.slice = function(begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; - }; - - Repeat.prototype.get = function(index, notSetValue) { - return this.has(index) ? this._value : notSetValue; + return makeStack(newSize, head); }; - Repeat.prototype.includes = function(searchValue) { - return is(this._value, searchValue); - }; + // @pragma Mutability - Repeat.prototype.slice = function(begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) ? this : - new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size)); + Stack.prototype.__ensureOwner = function(ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); }; - Repeat.prototype.reverse = function() { - return this; - }; + // @pragma Iteration - Repeat.prototype.indexOf = function(searchValue) { - if (is(this._value, searchValue)) { - return 0; + Stack.prototype.__iterate = function(fn, reverse) { + if (reverse) { + return this.reverse().__iterate(fn); } - return -1; - }; - - Repeat.prototype.lastIndexOf = function(searchValue) { - if (is(this._value, searchValue)) { - return this.size; + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this) === false) { + break; + } + node = node.next; } - return -1; + return iterations; }; - Repeat.prototype.__iterate = function(fn, reverse) { - for (var ii = 0; ii < this.size; ii++) { - if (fn(this._value, ii, this) === false) { - return ii + 1; - } + Stack.prototype.__iterator = function(type, reverse) { + if (reverse) { + return this.reverse().__iterator(type); } - return ii; + var iterations = 0; + var node = this._head; + return new Iterator(function() { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); }; - Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this; - var ii = 0; - return new src_Iterator__Iterator(function() - {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()} - ); - }; - Repeat.prototype.equals = function(other) { - return other instanceof Repeat ? - is(this._value, other._value) : - deepEqual(other); - }; + function isStack(maybeStack) { + return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); + } + Stack.isStack = isStack; - var EMPTY_REPEAT; + var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; + + var StackPrototype = Stack.prototype; + StackPrototype[IS_STACK_SENTINEL] = true; + StackPrototype.withMutations = MapPrototype.withMutations; + StackPrototype.asMutable = MapPrototype.asMutable; + StackPrototype.asImmutable = MapPrototype.asImmutable; + StackPrototype.wasAltered = MapPrototype.wasAltered; + + + function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; + } + + var EMPTY_STACK; + function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); + } /** * Contributes additional methods to a constructor @@ -4712,7 +4659,7 @@ return /******/ (function(modules) { // webpackBootstrap return ctor; } - Iterable.Iterator = src_Iterator__Iterator; + Iterable.Iterator = Iterator; mixin(Iterable, { @@ -4747,7 +4694,7 @@ return /******/ (function(modules) { // webpackBootstrap toMap: function() { // Use Late Binding here to solve the circular dependency. - return src_Map__Map(this.toKeyedSeq()); + return Map(this.toKeyedSeq()); }, toObject: function() { @@ -4769,7 +4716,7 @@ return /******/ (function(modules) { // webpackBootstrap toSet: function() { // Use Late Binding here to solve the circular dependency. - return src_Set__Set(isKeyed(this) ? this.valueSeq() : this); + return Set(isKeyed(this) ? this.valueSeq() : this); }, toSetSeq: function() { @@ -5234,7 +5181,11 @@ return /******/ (function(modules) { // webpackBootstrap }, lastIndexOf: function(searchValue) { - return this.toSeq().reverse().indexOf(searchValue); + var key = this.toKeyedSeq().reverse().keyOf(searchValue); + return key === undefined ? -1 : key; + + // var index = + // return this.toSeq().reverse().indexOf(searchValue); }, reverse: function() { @@ -5425,12 +5376,12 @@ return /******/ (function(modules) { // webpackBootstrap } function murmurHashOfSize(size, h) { - h = src_Math__imul(h, 0xCC9E2D51); - h = src_Math__imul(h << 15 | h >>> -15, 0x1B873593); - h = src_Math__imul(h << 13 | h >>> -13, 5); + h = imul(h, 0xCC9E2D51); + h = imul(h << 15 | h >>> -15, 0x1B873593); + h = imul(h << 13 | h >>> -13, 5); h = (h + 0xE6546B64 | 0) ^ size; - h = src_Math__imul(h ^ h >>> 16, 0x85EBCA6B); - h = src_Math__imul(h ^ h >>> 13, 0xC2B2AE35); + h = imul(h ^ h >>> 16, 0x85EBCA6B); + h = imul(h ^ h >>> 13, 0xC2B2AE35); h = smi(h ^ h >>> 16); return h; } @@ -5445,11 +5396,11 @@ return /******/ (function(modules) { // webpackBootstrap Seq: Seq, Collection: Collection, - Map: src_Map__Map, + Map: Map, OrderedMap: OrderedMap, List: List, Stack: Stack, - Set: src_Set__Set, + Set: Set, OrderedSet: OrderedSet, Record: Record, @@ -5466,7 +5417,7 @@ return /******/ (function(modules) { // webpackBootstrap })); /***/ }, -/* 8 */ +/* 7 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -5475,7 +5426,7 @@ return /******/ (function(modules) { // webpackBootstrap value: true }); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); exports['default'] = function (value) { if (_immutable.Iterable.isIterable(value)) { @@ -5487,6 +5438,72 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + 'use strict'; + + /** + * 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 = function() {}; + + if ((undefined) !== 'production') { + warning = function(condition, format, args) { + var len = arguments.length; + args = new Array(len > 2 ? len - 2 : 0); + for (var key = 2; key < len; key++) { + args[key - 2] = arguments[key]; + } + if (format === undefined) { + throw new Error( + '`warning(condition, format, ...args)` requires a warning ' + + 'message argument' + ); + } + + if (format.length < 10 || (/^[s\W]*$/).test(format)) { + throw new Error( + 'The warning format should be able to uniquely identify this ' + + 'warning. Please, use a more descriptive format than: ' + format + ); + } + + if (!condition) { + var argIndex = 0; + var message = 'Warning: ' + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // 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) {} + } + }; + } + + module.exports = warning; + + /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { @@ -5503,6 +5520,27 @@ return /******/ (function(modules) { // webpackBootstrap var _qs2 = _interopRequireDefault(_qs); + var _warning = __webpack_require__(8); + + var _warning2 = _interopRequireDefault(_warning); + + function parseBody(response) { + return response.text().then(function (text) { + if (!text || !text.length) { + (0, _warning2['default'])(response.status === 204, 'You should return a 204 status code with an empty body.'); + return null; + } + + (0, _warning2['default'])(response.status !== 204, 'You should return an empty body with a 204 status code.'); + + try { + return JSON.parse(text); + } catch (error) { + return text; + } + }); + } + exports['default'] = function (fetch) { return function (config) { var url = config.url; @@ -5517,16 +5555,38 @@ return /******/ (function(modules) { // webpackBootstrap delete config.params; return fetch(!queryString.length ? url : url + '?' + queryString, config).then(function (response) { - return (response.status === 204 ? Promise.resolve(null) : response.json()).then(function (json) { + return parseBody(response).then(function (json) { var headers = {}; + var keys = response.headers.keys(); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; - response.headers.forEach(function (value, name) { - headers[name] = value; - }); + try { + for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var key = _step.value; + + headers[key] = response.headers.get(key); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } var responsePayload = { data: json, headers: headers, + method: config.method ? config.method.toLowerCase() : 'get', statusCode: response.status }; @@ -6132,9 +6192,9 @@ return /******/ (function(modules) { // webpackBootstrap var _objectAssign2 = _interopRequireDefault(_objectAssign); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); - var _utilSerialize = __webpack_require__(8); + var _utilSerialize = __webpack_require__(7); var _utilSerialize2 = _interopRequireDefault(_utilSerialize); @@ -6194,6 +6254,74 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, /* 15 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true + }); + exports.custom = custom; + exports.collection = collection; + exports.member = member; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + + var _objectAssign = __webpack_require__(3); + + var _objectAssign2 = _interopRequireDefault(_objectAssign); + + function custom(endpoint) { + return function (name) { + var relative = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; + + if (relative) { + return member(endpoint['new'](endpoint.url() + '/' + name)); // eslint-disable-line no-use-before-define + } + + return member(endpoint['new'](name)); // eslint-disable-line no-use-before-define + }; + } + + function collection(endpoint) { + function _bindHttpMethod(method) { + return function () { + var _member; + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var id = args.shift(); + return (_member = member(endpoint['new'](endpoint.url() + '/' + id)))[method].apply(_member, args); // eslint-disable-line no-use-before-define + }; + } + + return (0, _objectAssign2['default'])(endpoint, { + custom: custom(endpoint), + 'delete': _bindHttpMethod('delete'), + getAll: endpoint.get, + get: _bindHttpMethod('get'), + head: _bindHttpMethod('head'), + patch: _bindHttpMethod('patch'), + put: _bindHttpMethod('put') + }); + } + + function member(endpoint) { + return (0, _objectAssign2['default'])(endpoint, { + all: function all(name) { + return collection(endpoint['new'](endpoint.url() + '/' + name)); + }, + custom: custom(endpoint), + one: function one(name, id) { + return member(endpoint['new'](endpoint.url() + '/' + name + '/' + id)); + } + }); + } + +/***/ }, +/* 16 */ /***/ function(module, exports) { 'use strict'; @@ -6250,7 +6378,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 16 */ +/* 17 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -6260,9 +6388,9 @@ return /******/ (function(modules) { // webpackBootstrap }); exports['default'] = scopeFactory; - var _events = __webpack_require__(17); + var _events = __webpack_require__(18); - var _immutable = __webpack_require__(7); + var _immutable = __webpack_require__(6); /* eslint-disable new-cap */ @@ -6337,7 +6465,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 17 */ +/* 18 */ /***/ function(module, exports) { // Copyright Joyent, Inc. and other Node contributors. @@ -6644,10 +6772,10 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 18 */ +/* 19 */ /***/ function(module, exports) { - (function() { + (function(self) { 'use strict'; if (self.fetch) { @@ -6656,7 +6784,7 @@ return /******/ (function(modules) { // webpackBootstrap function normalizeName(name) { if (typeof name !== 'string') { - name = name.toString(); + name = String(name) } if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { throw new TypeError('Invalid character in header field name') @@ -6666,7 +6794,7 @@ return /******/ (function(modules) { // webpackBootstrap function normalizeValue(value) { if (typeof value !== 'string') { - value = value.toString(); + value = String(value) } return value } @@ -6765,7 +6893,8 @@ return /******/ (function(modules) { // webpackBootstrap return false } })(), - formData: 'FormData' in self + formData: 'FormData' in self, + arrayBuffer: 'ArrayBuffer' in self } function Body() { @@ -6782,9 +6911,20 @@ return /******/ (function(modules) { // webpackBootstrap this._bodyFormData = body } else if (!body) { this._bodyText = '' + } else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) { + // Only support ArrayBuffers for POST method. + // Receiving ArrayBuffers happens via Blobs, instead. } else { throw new Error('unsupported BodyInit type') } + + if (!this.headers.get('content-type')) { + if (typeof body === 'string') { + this.headers.set('content-type', 'text/plain;charset=UTF-8') + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set('content-type', this._bodyBlob.type) + } + } } if (support.blob) { @@ -6849,20 +6989,44 @@ return /******/ (function(modules) { // webpackBootstrap return (methods.indexOf(upcased) > -1) ? upcased : method } - function Request(url, options) { + function Request(input, options) { options = options || {} - this.url = url + var body = options.body + if (Request.prototype.isPrototypeOf(input)) { + if (input.bodyUsed) { + throw new TypeError('Already read') + } + this.url = input.url + this.credentials = input.credentials + if (!options.headers) { + this.headers = new Headers(input.headers) + } + this.method = input.method + this.mode = input.mode + if (!body) { + body = input._bodyInit + input.bodyUsed = true + } + } else { + this.url = input + } - this.credentials = options.credentials || 'omit' - this.headers = new Headers(options.headers) - this.method = normalizeMethod(options.method || 'GET') - this.mode = options.mode || null + this.credentials = options.credentials || this.credentials || 'omit' + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers) + } + this.method = normalizeMethod(options.method || this.method || 'GET') + this.mode = options.mode || this.mode || null this.referrer = null - if ((this.method === 'GET' || this.method === 'HEAD') && options.body) { + if ((this.method === 'GET' || this.method === 'HEAD') && body) { throw new TypeError('Body not allowed for GET or HEAD requests') } - this._initBody(options.body) + this._initBody(body) + } + + Request.prototype.clone = function() { + return new Request(this) } function decode(body) { @@ -6897,32 +7061,55 @@ return /******/ (function(modules) { // webpackBootstrap options = {} } - this._initBody(bodyInit) this.type = 'default' - this.url = null this.status = options.status this.ok = this.status >= 200 && this.status < 300 this.statusText = options.statusText this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers) this.url = options.url || '' + this._initBody(bodyInit) } Body.call(Response.prototype) + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }) + } + + Response.error = function() { + var response = new Response(null, {status: 0, statusText: ''}) + response.type = 'error' + return response + } + + var redirectStatuses = [301, 302, 303, 307, 308] + + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code') + } + + return new Response(null, {status: status, headers: {location: url}}) + } + self.Headers = Headers; self.Request = Request; self.Response = Response; self.fetch = function(input, init) { - // TODO: Request constructor should accept input, init - var request - if (Request.prototype.isPrototypeOf(input) && !init) { - request = input - } else { - request = new Request(input, init) - } - return new Promise(function(resolve, reject) { + var request + if (Request.prototype.isPrototypeOf(input) && !init) { + request = input + } else { + request = new Request(input, init) + } + var xhr = new XMLHttpRequest() function responseURL() { @@ -6976,7 +7163,7 @@ return /******/ (function(modules) { // webpackBootstrap }) } self.fetch.polyfill = true - })(); + })(typeof self !== 'undefined' ? self : this); /***/ } diff --git a/dist/restful.standalone.min.js b/dist/restful.standalone.min.js index 5f60ec8..36d61cb 100644 --- a/dist/restful.standalone.min.js +++ b/dist/restful.standalone.min.js @@ -1,3 +1,3 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.restful=e():t.restful=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),o=n(i),u=r(9),s=n(u);r(18),e["default"]=function(t){var e=arguments.length<=1||void 0===arguments[1]?s["default"](fetch):arguments[1];return o["default"](t,e)},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=v["default"]();r.assign("config","entityIdentifier","id"),!t&&"undefined"!=typeof window&&window.location?r.set("url",window.location.protocol+"//"+window.location.host):r.set("url",t);var n=h.member(u["default"](c["default"](e))(r));return d.push(n),n}Object.defineProperty(e,"__esModule",{value:!0});var o=r(4),u=n(o),s=r(9),a=n(s),f=r(14),c=n(f),h=r(2),p=r(15),l=n(p),_=r(16),v=n(_),d=[];i._instances=function(){return d},i._flush=function(){return d.length=0},e.fetchBackend=a["default"],e.requestBackend=l["default"],e["default"]=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return function(e){var r=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return u(r?t["new"](t.url()+"/"+e):t["new"](e))}}function o(t){function e(e){return function(){for(var r,n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];var s=i.shift();return(r=u(t["new"](t.url()+"/"+s)))[e].apply(r,i)}}return a["default"](t,{custom:i(t),"delete":e("delete"),getAll:t.get,get:e("get"),head:e("head"),one:function(e,r){return u(t["new"](t.url()+"/"+e+"/"+r))},patch:e("patch"),put:e("put")})}function u(t){return a["default"](t,{all:function(e){return o(t["new"](t.url()+"/"+e))},custom:i(t),one:function(e,r){return u(t["new"](t.url()+"/"+e+"/"+r))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.custom=i,e.collection=o,e.member=u;var s=r(3),a=n(s)},function(t,e){"use strict";function r(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t,e){for(var n,i,o=r(t),u=1;ui;i++)n[i]=arguments[i];return e.put.apply(e,[t].concat(n))},url:e.url}},t.exports=e["default"]},function(t,e,r){!function(e,r){t.exports=r()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=new Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function o(t){return void 0===t.size&&(t.size=t.__iterate(s)),t.size}function u(t,e){if("number"!=typeof e){var r=+e;if(""+r!==e)return NaN;e=r}return 0>e?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function f(t,e){return h(t,e,0)}function c(t,e){return h(t,e,e)}function h(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function p(t){return d(t)?t:j(t)}function l(t){return y(t)?t:q(t)}function _(t){return m(t)?t:D(t)}function v(t){return d(t)&&!g(t)?t:A(t)}function d(t){return!(!t||!t[_r])}function y(t){return!(!t||!t[vr])}function m(t){return!(!t||!t[dr])}function g(t){return y(t)||m(t)}function w(t){return!(!t||!t[yr])}function b(t){this.next=t}function I(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function z(t){return!!E(t)}function O(t){return t&&"function"==typeof t.next}function x(t){var e=E(t);return e&&e.call(t)}function E(t){var e=t&&(br&&t[br]||t[Ir]);return"function"==typeof e?e:void 0}function M(t){return t&&"number"==typeof t.length}function j(t){return null===t||void 0===t?U():d(t)?t.toSeq():B(t)}function q(t){return null===t||void 0===t?U().toKeyedSeq():d(t)?y(t)?t.toSeq():t.fromEntrySeq():K(t)}function D(t){return null===t||void 0===t?U():d(t)?y(t)?t.entrySeq():t.toIndexedSeq():N(t)}function A(t){return(null===t||void 0===t?U():d(t)?y(t)?t.entrySeq():t:N(t)).toSetSeq()}function k(t){this._array=t,this.size=t.length}function L(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function T(t){this._iterable=t,this.size=t.length||t.size}function R(t){this._iterator=t,this._iteratorCache=[]}function P(t){return!(!t||!t[zr])}function U(){return Or||(Or=new k([]))}function K(t){var e=Array.isArray(t)?new k(t).fromEntrySeq():O(t)?new R(t).fromEntrySeq():z(t)?new T(t).fromEntrySeq():"object"==typeof t?new L(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function N(t){var e=C(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function B(t){var e=C(t)||"object"==typeof t&&new L(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function C(t){return M(t)?new k(t):O(t)?new R(t):z(t)?new T(t):void 0}function H(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function W(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new b(function(){var t=i[r?o-u:u];return u++>o?S():I(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function J(){throw TypeError("Abstract")}function F(){}function V(){}function G(){}function X(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function Y(t,e){return e?$(e,t,"",{"":t}):Q(t)}function $(t,e,r,n){return Array.isArray(e)?t.call(n,r,D(e).map(function(r,n){return $(t,r,n,e)})):Z(e)?t.call(n,r,q(e).map(function(r,n){return $(t,r,n,e)})):e}function Q(t){return Array.isArray(t)?D(t).map(Q).toList():Z(t)?q(t).map(Q).toMap():t}function Z(t){return t&&(t.constructor===Object||void 0===t.constructor)}function tt(t){return t>>>1&1073741824|3221225471&t}function et(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return tt(r)}return"string"===e?t.length>kr?rt(t):nt(t):"function"==typeof t.hashCode?t.hashCode():it(t)}function rt(t){var e=Rr[t];return void 0===e&&(e=nt(t),Tr===Lr&&(Tr=0,Rr={}),Tr++,Rr[t]=e),e}function nt(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ut(t,e){if(!t)throw new Error(e)}function st(t){ut(t!==1/0,"Cannot perform this action with an infinite size.")}function at(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ft(t){this._iter=t,this.size=t.size}function ct(t){this._iter=t,this.size=t.size}function ht(t){this._iter=t,this.size=t.size}function pt(t){var e=kt(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Lt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===wr){var n=t.__iterator(e,r);return new b(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===gr?mr:gr,r)},e}function lt(t,e,r){var n=kt(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,hr);return o===hr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(wr,i);return new b(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return I(n,s,e.call(r,u[1],s,t),i)})},n}function _t(t,e){var r=kt(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=pt(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=Lt,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function vt(t,e,r,n){var i=kt(t);return n&&(i.has=function(n){var i=t.get(n,hr);return i!==hr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,hr);return o!==hr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(wr,o),s=0;return new b(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,f=a[0],c=a[1];if(e.call(r,c,f,t))return I(i,n?f:s++,c,o)}})},i}function dt(t,e,r){var n=Pt().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function yt(t,e,r){var n=y(t),i=(w(t)?Se():Pt()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=At(t);return i.map(function(e){return jt(t,o(e))})}function mt(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),a(e,r,i))return t;var o=f(e,i),s=c(r,i);if(o!==o||s!==s)return mt(t.toSeq().cacheResult(),e,r,n);var h,p=s-o;p===p&&(h=0>p?0:p);var l=kt(t);return l.size=0===h?h:t.size&&h||void 0,!n&&P(t)&&h>=0&&(l.get=function(e,r){return e=u(this,e),e>=0&&h>e?t.get(e+o,r):r}),l.__iterateUncached=function(e,r){var i=this;if(0===h)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,s=!0,a=0;return t.__iterate(function(t,r){return s&&(s=u++h)return S();var t=i.next();return n||e===gr?t:e===mr?I(e,s-1,void 0,t):I(e,s-1,t.value[1],t)})},l}function gt(t,e,r){var n=kt(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(wr,i),s=!0;return new b(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],f=i[1];return e.call(r,f,a,o)?n===wr?t:I(n,a,f,t):(s=!1,S())})},n}function wt(t,e,r,n){var i=kt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,f){return s&&(s=e.call(r,t,o,f))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(wr,o),a=!0,f=0;return new b(function(){var t,o,c;do{if(t=s.next(),t.done)return n||i===gr?t:i===mr?I(i,f++,void 0,t):I(i,f++,t.value[1],t);var h=t.value;o=h[0],c=h[1],a&&(a=e.call(r,c,o,u))}while(a);return i===wr?t:I(i,o,c,t)})},i}function bt(t,e){var r=y(t),n=[t].concat(e).map(function(t){return d(t)?r&&(t=l(t)):t=r?K(t):N(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&y(i)||m(t)&&m(i))return i}var o=new k(n);return r?o=o.toKeyedSeq():m(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function It(t,e,r){var n=kt(t);return n.__iterateUncached=function(n,i){function o(t,a){var f=this;t.__iterate(function(t,i){return(!e||e>a)&&d(t)?o(t,a+1):n(t,r?i:u++,f)===!1&&(s=!0),!s},i)}var u=0,s=!1;return o(t,0),u},n.__iteratorUncached=function(n,i){var o=t.__iterator(n,i),u=[],s=0;return new b(function(){for(;o;){var t=o.next();if(t.done===!1){var a=t.value;if(n===wr&&(a=a[1]),e&&!(u.length0}function Mt(t,e,r){var n=kt(t);return n.size=new k(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this.__iterator(gr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=p(t),x(n?t.reverse():t)}),o=0,u=!1;return new b(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?S():I(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function jt(t,e){return P(t)?e:t.constructor(e)}function qt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Dt(t){return st(t.size),o(t)}function At(t){return y(t)?l:m(t)?_:v}function kt(t){return Object.create((y(t)?q:m(t)?D:A).prototype)}function Lt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):j.prototype.cacheResult.call(this)}function Tt(t,e){return t>e?1:e>t?-1:0}function Rt(t){var e=x(t);if(!e){if(!M(t))throw new TypeError("Expected iterable or array-like: "+t);e=x(p(t))}return e}function Pt(t){return null===t||void 0===t?Gt():Ut(t)&&!w(t)?t:Gt().withMutations(function(e){var r=l(t);st(r.size),r.forEach(function(t,r){return e.set(r,t)})})}function Ut(t){return!(!t||!t[Pr])}function Kt(t,e){this.ownerID=t,this.entries=e}function Nt(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function Bt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function Ct(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function Ht(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function Wt(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&Ft(t._root)}function Jt(t,e){return I(t,e[0],e[1])}function Ft(t,e){return{node:t,index:0,__prev:e}}function Vt(t,e,r,n){var i=Object.create(Ur);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Kr||(Kr=Vt(0))}function Xt(t,r,n){var i,o;if(t._root){var u=e(pr),s=e(lr);if(i=Yt(t._root,t.__ownerID,0,void 0,r,n,u,s),!s.value)return t;o=t.size+(u.value?n===hr?-1:1:0)}else{if(n===hr)return t;o=1,i=new Kt(t.__ownerID,[[r,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Vt(o,i):Gt()}function Yt(t,e,n,i,o,u,s,a){return t?t.update(e,n,i,o,u,s,a):u===hr?t:(r(a),r(s),new Ht(e,i,[o,u]))}function $t(t){return t.constructor===Ht||t.constructor===Ct}function Qt(t,e,r,n,i){if(t.keyHash===n)return new Ct(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&cr,s=(0===r?n:n>>>r)&cr,a=u===s?[Qt(t,e,r+ar,n,i)]:(o=new Ht(e,n,i),s>u?[t,o]:[o,t]);return new Nt(e,1<s;s++,a<<=1){var c=e[s];void 0!==c&&s!==n&&(i|=a,u[o++]=c)}return new Nt(t,i,u)}function ee(t,e,r,n,i){for(var o=0,u=new Array(fr),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Bt(t,o+1,u)}function re(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function se(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function ae(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function fe(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function ce(t){var e=ve();if(null===t||void 0===t)return e;if(he(t))return t;var r=_(t),n=r.size;return 0===n?e:(st(n),n>0&&fr>n?_e(0,n,ar,null,new pe(r.toArray())):e.withMutations(function(t){t.setSize(n),r.forEach(function(e,r){return t.set(r,e)})}))}function he(t){return!(!t||!t[Hr])}function pe(t,e){this.array=t,this.ownerID=e}function le(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,f=u-r;return f>fr&&(f=fr),function(){if(i===f)return Fr;var t=e?--f:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,f=i>o?0:o-i>>n,c=(u-i>>n)+1;return c>fr&&(c=fr),function(){for(;;){if(s){var t=s();if(t!==Fr)return t;s=null}if(f===c)return Fr;var o=e?--c:f++;s=r(a&&a[o],n-ar,i+(o<=t.size||0>r)return t.withMutations(function(t){0>r?we(t,r).set(0,n):we(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(lr);return r>=Ie(t._capacity)?i=ye(i,t.__ownerID,0,r,n,s):o=ye(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):_e(t._origin,t._capacity,t._level,o,i):t}function ye(t,e,n,i,o,u){var s=i>>>n&cr,a=t&&s0){var c=t&&t.array[s],h=ye(c,e,n-ar,i,o,u);return h===c?t:(f=me(t,e),f.array[s]=h,f)}return a&&t.array[s]===o?t:(r(u),f=me(t,e),void 0===o&&s===f.array.length-1?f.array.pop():f.array[s]=o,f)}function me(t,e){return e&&t&&e===t.ownerID?t:new pe(t?t.array.slice():[],e)}function ge(t,e){if(e>=Ie(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&cr],n-=ar;return r}}function we(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:0>r?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var f=t._level,c=t._root,h=0;0>s+h;)c=new pe(c&&c.array.length?[void 0,c]:[],i),f+=ar,h+=1<=1<l?ge(t,a-1):l>p?new pe([],i):_;if(_&&l>p&&u>s&&_.array.length){c=me(c,i);for(var d=c,y=f;y>ar;y-=ar){var m=p>>>y&cr;d=d.array[m]=me(d.array[m],i)}d.array[p>>>ar&cr]=_}if(u>a&&(v=v&&v.removeAfter(i,0,a)),s>=l)s-=l,a-=l,f=ar,c=null,v=v&&v.removeBefore(i,0,s);else if(s>o||p>l){for(h=0;c;){var g=s>>>f&cr;if(g!==l>>>f&cr)break;g&&(h+=(1<o&&(c=c.removeBefore(i,f,s-h)),c&&p>l&&(c=c.removeAfter(i,f,l-h)),h&&(s-=h,a-=h)}return t.__ownerID?(t.size=a-s,t._origin=s,t._capacity=a,t._level=f,t._root=c,t._tail=v,t.__hash=void 0,t.__altered=!0,t):_e(s,a,f,c,v)}function be(t,e,r){for(var n=[],i=0,o=0;oi&&(i=s.size),d(u)||(s=s.map(function(t){return Y(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)),ie(t,e,n)}function Ie(t){return fr>t?0:t-1>>>ar<=fr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Oe(n,i)}function Me(t){return null===t||void 0===t?De():je(t)?t:De().unshiftAll(t)}function je(t){return!(!t||!t[Gr])}function qe(t,e,r,n){var i=Object.create(Xr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function De(){return Yr||(Yr=qe(0))}function Ae(t){return null===t||void 0===t?Re():ke(t)&&!w(t)?t:Re().withMutations(function(e){var r=v(t);st(r.size),r.forEach(function(t){return e.add(t)})})}function ke(t){return!(!t||!t[$r])}function Le(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Te(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Re(){return Zr||(Zr=Te(Gt()))}function Pe(t){return null===t||void 0===t?Ne():Ue(t)?t:Ne().withMutations(function(e){var r=v(t);st(r.size),r.forEach(function(t){return e.add(t)})})}function Ue(t){return ke(t)&&w(t)}function Ke(t,e){var r=Object.create(tn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ne(){return en||(en=Ke(xe()))}function Be(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);We(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=Pt(o)},i=n.prototype=Object.create(rn);return i.constructor=n,n}function Ce(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function He(t){return t._name||t.constructor.name||"Record"}function We(t,e){try{e.forEach(Je.bind(void 0,t))}catch(r){}}function Je(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ut(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Fe(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||y(t)!==y(e)||m(t)!==m(e)||w(t)!==w(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!g(t);if(w(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&X(i[1],t)&&(r||X(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){return(r?t.has(e):i?X(e,t.get(n,hr)):X(t.get(n,hr),e))?void 0:(u=!1,!1)});return u&&t.size===s}function Ve(t,e,r){if(!(this instanceof Ve))return new Ve(t,e,r);if(ut(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(nn)return nn;nn=this}}function Ge(t,e){if(!(this instanceof Ge))return new Ge(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(on)return on;on=this}}function Xe(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ye(t,e){return e}function $e(t,e){return[e,t]}function Qe(t){return function(){return!t.apply(this,arguments)}}function Ze(t){return function(){return-t.apply(this,arguments)}}function tr(t){return"string"==typeof t?JSON.stringify(t):t}function er(){return i(arguments)}function rr(t,e){return e>t?1:t>e?-1:0}function nr(t){if(t.size===1/0)return 0;var e=w(t),r=y(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+or(et(t),et(e))|0}:function(t,e){n=n+or(et(t),et(e))|0}:e?function(t){n=31*n+et(t)|0}:function(t){n=n+et(t)|0});return ir(i,n)}function ir(t,e){return e=Er(e,3432918353),e=Er(e<<15|e>>>-15,461845907),e=Er(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Er(e^e>>>16,2246822507),e=Er(e^e>>>13,3266489909),e=tt(e^e>>>16)}function or(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var ur=Array.prototype.slice,sr="delete",ar=5,fr=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},k.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new b(function(){return i>n?S():I(t,i,r[e?n-i++:i++])})},t(L,q),L.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},L.prototype.has=function(t){return this._object.hasOwnProperty(t); -},L.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},L.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new b(function(){var u=n[e?i-o:o];return o++>i?S():I(t,u,r[u])})},L.prototype[yr]=!0,t(T,D),T.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=this._iterable,n=x(r),i=0;if(O(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},T.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=x(r);if(!O(n))return new b(S);var i=0;return new b(function(){var e=n.next();return e.done?e:I(t,i++,e.value)})},t(R,D),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return I(t,i,n[i++])})};var Or;t(J,p),t(F,J),t(V,J),t(G,J),J.Keyed=F,J.Indexed=V,J.Set=G;var xr,Er="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},Mr=Object.isExtensible,jr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),qr="function"==typeof WeakMap;qr&&(xr=new WeakMap);var Dr=0,Ar="__immutablehash__";"function"==typeof Symbol&&(Ar=Symbol(Ar));var kr=16,Lr=255,Tr=0,Rr={};t(at,q),at.prototype.get=function(t,e){return this._iter.get(t,e)},at.prototype.has=function(t){return this._iter.has(t)},at.prototype.valueSeq=function(){return this._iter.valueSeq()},at.prototype.reverse=function(){var t=this,e=_t(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},at.prototype.map=function(t,e){var r=this,n=lt(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},at.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?Dt(this):0,function(i){return t(i,e?--r:r++,n)}),e)},at.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(gr,e),n=e?Dt(this):0;return new b(function(){var i=r.next();return i.done?i:I(t,e?--n:n++,i.value,i)})},at.prototype[yr]=!0,t(ft,D),ft.prototype.includes=function(t){return this._iter.includes(t)},ft.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ft.prototype.__iterator=function(t,e){var r=this._iter.__iterator(gr,e),n=0;return new b(function(){var e=r.next();return e.done?e:I(t,n++,e.value,e)})},t(ct,A),ct.prototype.has=function(t){return this._iter.includes(t)},ct.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},ct.prototype.__iterator=function(t,e){var r=this._iter.__iterator(gr,e);return new b(function(){var e=r.next();return e.done?e:I(t,e.value,e.value,e)})},t(ht,q),ht.prototype.entrySeq=function(){return this._iter.toSeq()},ht.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){qt(e);var n=d(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ht.prototype.__iterator=function(t,e){var r=this._iter.__iterator(gr,e);return new b(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){qt(n);var i=d(n);return I(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ft.prototype.cacheResult=at.prototype.cacheResult=ct.prototype.cacheResult=ht.prototype.cacheResult=Lt,t(Pt,F),Pt.prototype.toString=function(){return this.__toString("Map {","}")},Pt.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Pt.prototype.set=function(t,e){return Xt(this,t,e)},Pt.prototype.setIn=function(t,e){return this.updateIn(t,hr,function(){return e})},Pt.prototype.remove=function(t){return Xt(this,t,hr)},Pt.prototype.deleteIn=function(t){return this.updateIn(t,function(){return hr})},Pt.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},Pt.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=oe(this,Rt(t),e,r);return n===hr?void 0:n},Pt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Gt()},Pt.prototype.merge=function(){return re(this,void 0,arguments)},Pt.prototype.mergeWith=function(t){var e=ur.call(arguments,1);return re(this,t,e)},Pt.prototype.mergeIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},Pt.prototype.mergeDeep=function(){return re(this,ne(void 0),arguments)},Pt.prototype.mergeDeepWith=function(t){var e=ur.call(arguments,1);return re(this,ne(t),e)},Pt.prototype.mergeDeepIn=function(t){var e=ur.call(arguments,1);return this.updateIn(t,Gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},Pt.prototype.sort=function(t){return Se(Ot(this,t))},Pt.prototype.sortBy=function(t,e){return Se(Ot(this,e,t))},Pt.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Pt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},Pt.prototype.asImmutable=function(){return this.__ensureOwner()},Pt.prototype.wasAltered=function(){return this.__altered},Pt.prototype.__iterator=function(t,e){return new Wt(this,t,e)},Pt.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},Pt.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Vt(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Pt.isMap=Ut;var Pr="@@__IMMUTABLE_MAP__@@",Ur=Pt.prototype;Ur[Pr]=!0,Ur[sr]=Ur.remove,Ur.removeIn=Ur.deleteIn,Kt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Kt.prototype.update=function(t,e,n,o,u,s,a){for(var f=u===hr,c=this.entries,h=0,p=c.length;p>h&&!X(o,c[h][0]);h++);var l=p>h;if(l?c[h][1]===u:f)return this;if(r(a),(f||!l)&&r(s),!f||1!==c.length){if(!l&&!f&&c.length>=Nr)return Zt(t,c,o,u);var _=t&&t===this.ownerID,v=_?c:i(c);return l?f?h===p-1?v.pop():v[h]=v.pop():v[h]=[o,u]:v.push([o,u]),_?(this.entries=v,this):new Kt(t,v)}},Nt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=1<<((0===t?e:e>>>t)&cr),o=this.bitmap;return 0===(o&i)?n:this.nodes[ue(o&i-1)].get(t+ar,e,r,n)},Nt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var s=(0===e?r:r>>>e)&cr,a=1<=Br)return ee(t,p,f,s,_);if(c&&!_&&2===p.length&&$t(p[1^h]))return p[1^h];if(c&&_&&1===p.length&&$t(_))return _;var v=t&&t===this.ownerID,d=c?_?f:f^a:f|a,y=c?_?se(p,h,_,v):fe(p,h,v):ae(p,h,_,v);return v?(this.bitmap=d,this.nodes=y,this):new Nt(t,d,y)},Bt.prototype.get=function(t,e,r,n){void 0===e&&(e=et(r));var i=(0===t?e:e>>>t)&cr,o=this.nodes[i];return o?o.get(t+ar,e,r,n):n},Bt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=et(n));var s=(0===e?r:r>>>e)&cr,a=i===hr,f=this.nodes,c=f[s];if(a&&!c)return this;var h=Yt(c,t,e+ar,r,n,i,o,u);if(h===c)return this;var p=this.count;if(c){if(!h&&(p--,Cr>p))return te(t,f,p,s)}else p++;var l=t&&t===this.ownerID,_=se(f,s,h,l);return l?(this.count=p,this.nodes=_,this):new Bt(t,p,_)},Ct.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Ct.prototype.update=function(t,e,n,o,u,s,a){void 0===n&&(n=et(o));var f=u===hr;if(n!==this.keyHash)return f?this:(r(a),r(s),Qt(this,t,e,n,[o,u]));for(var c=this.entries,h=0,p=c.length;p>h&&!X(o,c[h][0]);h++);var l=p>h;if(l?c[h][1]===u:f)return this;if(r(a),(f||!l)&&r(s),f&&2===p)return new Ht(t,this.keyHash,c[1^h]);var _=t&&t===this.ownerID,v=_?c:i(c);return l?f?h===p-1?v.pop():v[h]=v.pop():v[h]=[o,u]:v.push([o,u]),_?(this.entries=v,this):new Ct(t,this.keyHash,v)},Ht.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},Ht.prototype.update=function(t,e,n,i,o,u,s){var a=o===hr,f=X(i,this.entry[0]);return(f?o===this.entry[1]:a)?this:(r(s),a?void r(u):f?t&&t===this.ownerID?(this.entry[1]=o,this):new Ht(t,this.keyHash,[i,o]):(r(u),Qt(this,t,e,et(i),[i,o])))},Kt.prototype.iterate=Ct.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},Nt.prototype.iterate=Bt.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},Ht.prototype.iterate=function(t,e){return t(this.entry)},t(Wt,b),Wt.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return Jt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return Jt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return Jt(t,o.entry);e=this._stack=Ft(o,e)}continue}e=this._stack=this._stack.__prev}return S()};var Kr,Nr=fr/4,Br=fr/2,Cr=fr/4;t(ce,V),ce.of=function(){return this(arguments)},ce.prototype.toString=function(){return this.__toString("List [","]")},ce.prototype.get=function(t,e){if(t=u(this,t),t>=0&&t>>e&cr;if(n>=this.array.length)return new pe([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-ar,r),i===u&&o)return this}if(o&&!i)return this;var s=me(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},pe.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&cr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-ar,r),i===o&&n===this.array.length-1)return this}var u=me(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Jr,Fr={};t(Se,Pt),Se.of=function(){return this(arguments)},Se.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Se.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Se.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):xe()},Se.prototype.set=function(t,e){return Ee(this,t,e)},Se.prototype.remove=function(t){return Ee(this,t,hr)},Se.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Se.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Se.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Se.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Oe(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Se.isOrderedMap=ze,Se.prototype[yr]=!0,Se.prototype[sr]=Se.prototype.remove;var Vr;t(Me,V),Me.of=function(){return this(arguments)},Me.prototype.toString=function(){return this.__toString("Stack [","]")},Me.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},Me.prototype.peek=function(){return this._head&&this._head.value},Me.prototype.push=function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):qe(t,e)},Me.prototype.pushAll=function(t){if(t=_(t),0===t.size)return this;st(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):qe(e,r)},Me.prototype.pop=function(){return this.slice(1)},Me.prototype.unshift=function(){return this.push.apply(this,arguments)},Me.prototype.unshiftAll=function(t){return this.pushAll(t)},Me.prototype.shift=function(){return this.pop.apply(this,arguments)},Me.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):De()},Me.prototype.slice=function(t,e){if(a(t,e,this.size))return this;var r=f(t,this.size),n=c(e,this.size);if(n!==this.size)return V.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):qe(i,o)},Me.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?qe(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Me.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Me.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new b(function(){if(n){var e=n.value;return n=n.next,I(t,r++,e)}return S()})},Me.isStack=je;var Gr="@@__IMMUTABLE_STACK__@@",Xr=Me.prototype;Xr[Gr]=!0,Xr.withMutations=Ur.withMutations,Xr.asMutable=Ur.asMutable,Xr.asImmutable=Ur.asImmutable,Xr.wasAltered=Ur.wasAltered;var Yr;t(Ae,G),Ae.of=function(){return this(arguments)},Ae.fromKeys=function(t){return this(l(t).keySeq())},Ae.prototype.toString=function(){return this.__toString("Set {","}")},Ae.prototype.has=function(t){return this._map.has(t)},Ae.prototype.add=function(t){return Le(this,this._map.set(t,!0))},Ae.prototype.remove=function(t){return Le(this,this._map.remove(t))},Ae.prototype.clear=function(){return Le(this,this._map.clear())},Ae.prototype.union=function(){var t=ur.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;r1?" by "+this._step:"")+" ]"},Ve.prototype.get=function(t,e){return this.has(t)?this._start+u(this,t)*this._step:e},Ve.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&e=e?new Ve(0,0):new Ve(this.get(t,this._end),this.get(e,this._end),this._step))},Ve.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&r=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},Ve.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new b(function(){var u=i;return i+=e?-n:n,o>r?S():I(t,o++,u)})},Ve.prototype.equals=function(t){return t instanceof Ve?this._start===t._start&&this._end===t._end&&this._step===t._step:Fe(this,t)};var nn;t(Ge,D),Ge.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},Ge.prototype.get=function(t,e){return this.has(t)?this._value:e},Ge.prototype.includes=function(t){return X(this._value,t)},Ge.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:new Ge(this._value,c(e,r)-f(t,r))},Ge.prototype.reverse=function(){return this},Ge.prototype.indexOf=function(t){return X(this._value,t)?0:-1},Ge.prototype.lastIndexOf=function(t){return X(this._value,t)?this.size:-1},Ge.prototype.__iterate=function(t,e){for(var r=0;rt?this.count():this.size);var n=this.slice(0,t);return jt(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return jt(this,It(this,t,!1))},get:function(t,e){return t=u(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=u(this,t),t>=0&&(void 0!==this.size?this.size===1/0||t=200&&t.status<300)return n;var i=new Error(t.statusText);throw i.response=n,i})})}},t.exports=e["default"]},function(t,e,r){var n=r(11),i=r(13);t.exports={stringify:n,parse:i}},function(t,e,r){var n=r(12),i={delimiter:"&",arrayPrefixGenerators:{brackets:function(t,e){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t,e){return t}},strictNullHandling:!1,skipNulls:!1,encode:!0};i.stringify=function(t,e,r,o,u,s,a,f){if("function"==typeof a)t=a(e,t);else if(n.isBuffer(t))t=t.toString();else if(t instanceof Date)t=t.toISOString();else if(null===t){if(o)return s?n.encode(e):e;t=""}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return s?[n.encode(e)+"="+n.encode(t)]:[e+"="+t];var c=[];if("undefined"==typeof t)return c;var h;if(Array.isArray(a))h=a;else{var p=Object.keys(t);h=f?p.sort(f):p}for(var l=0,_=h.length;_>l;++l){var v=h[l];u&&null===t[v]||(c=Array.isArray(t)?c.concat(i.stringify(t[v],r(e,v),r,o,u,s,a)):c.concat(i.stringify(t[v],e+"["+v+"]",r,o,u,s,a))); -}return c},t.exports=function(t,e){e=e||{};var r,n,o="undefined"==typeof e.delimiter?i.delimiter:e.delimiter,u="boolean"==typeof e.strictNullHandling?e.strictNullHandling:i.strictNullHandling,s="boolean"==typeof e.skipNulls?e.skipNulls:i.skipNulls,a="boolean"==typeof e.encode?e.encode:i.encode,f="function"==typeof e.sort?e.sort:null;"function"==typeof e.filter?(n=e.filter,t=n("",t)):Array.isArray(e.filter)&&(r=n=e.filter);var c=[];if("object"!=typeof t||null===t)return"";var h;h=e.arrayFormat in i.arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":"indices";var p=i.arrayPrefixGenerators[h];r||(r=Object.keys(t)),f&&r.sort(f);for(var l=0,_=r.length;_>l;++l){var v=r[l];s&&null===t[v]||(c=c.concat(i.stringify(t[v],v,p,u,s,a,n,f)))}return c.join(o)}},function(t,e){var r={};r.hexTable=new Array(256);for(var n=0;256>n;++n)r.hexTable[n]="%"+((16>n?"0":"")+n.toString(16)).toUpperCase();e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},n=0,i=t.length;i>n;++n)"undefined"!=typeof t[n]&&(r[n]=t[n]);return r},e.merge=function(t,r,n){if(!r)return t;if("object"!=typeof r)return Array.isArray(t)?t.push(r):"object"==typeof t?t[r]=!0:t=[t,r],t;if("object"!=typeof t)return t=[t].concat(r);Array.isArray(t)&&!Array.isArray(r)&&(t=e.arrayToObject(t,n));for(var i=Object.keys(r),o=0,u=i.length;u>o;++o){var s=i[o],a=r[s];Object.prototype.hasOwnProperty.call(t,s)?t[s]=e.merge(t[s],a,n):t[s]=a}return t},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;"string"!=typeof t&&(t=""+t);for(var e="",n=0,i=t.length;i>n;++n){var o=t.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&57>=o||o>=65&&90>=o||o>=97&&122>=o?e+=t[n]:128>o?e+=r.hexTable[o]:2048>o?e+=r.hexTable[192|o>>6]+r.hexTable[128|63&o]:55296>o||o>=57344?e+=r.hexTable[224|o>>12]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o]:(++n,o=65536+((1023&o)<<10|1023&t.charCodeAt(n)),e+=r.hexTable[240|o>>18]+r.hexTable[128|o>>12&63]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o])}return e},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;r=r||[];var n=r.indexOf(t);if(-1!==n)return r[n];if(r.push(t),Array.isArray(t)){for(var i=[],o=0,u=t.length;u>o;++o)"undefined"!=typeof t[o]&&i.push(t[o]);return i}var s=Object.keys(t);for(o=0,u=s.length;u>o;++o){var a=s[o];t[a]=e.compact(t[a],r)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null===t||"undefined"==typeof t?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e,r){var n=r(12),i={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1};i.parseValues=function(t,e){for(var r={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),o=0,u=i.length;u>o;++o){var s=i[o],a=-1===s.indexOf("]=")?s.indexOf("="):s.indexOf("]=")+1;if(-1===a)r[n.decode(s)]="",e.strictNullHandling&&(r[n.decode(s)]=null);else{var f=n.decode(s.slice(0,a)),c=n.decode(s.slice(a+1));Object.prototype.hasOwnProperty.call(r,f)?r[f]=[].concat(r[f]).concat(c):r[f]=c}}return r},i.parseObject=function(t,e,r){if(!t.length)return e;var n,o=t.shift();if("[]"===o)n=[],n=n.concat(i.parseObject(t,e,r));else{n=r.plainObjects?Object.create(null):{};var u="["===o[0]&&"]"===o[o.length-1]?o.slice(1,o.length-1):o,s=parseInt(u,10),a=""+s;!isNaN(s)&&o!==u&&a===u&&s>=0&&r.parseArrays&&s<=r.arrayLimit?(n=[],n[s]=i.parseObject(t,e,r)):n[u]=i.parseObject(t,e,r)}return n},i.parseKeys=function(t,e,r){if(t){r.allowDots&&(t=t.replace(/\.([^\.\[]+)/g,"[$1]"));var n=/^([^\[\]]*)/,o=/(\[[^\[\]]*\])/g,u=n.exec(t),s=[];if(u[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(u[1])&&!r.allowPrototypes)return;s.push(u[1])}for(var a=0;null!==(u=o.exec(t))&&as;++s){var f=u[s],c=i.parseKeys(f,r[f],e);o=n.merge(o,c,e)}return n.compact(o)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e1?n-1:0),o=1;n>o;o++)i[o-1]=arguments[o];r.apply(void 0,[t+":"+e].concat(i))}}var i=a.List(e.get("errorInterceptors")),u=a.List(e.get("requestInterceptors")),s=a.List(e.get("responseInterceptors")),f=e["delete"]("errorInterceptors")["delete"]("requestInterceptors")["delete"]("responseInterceptors");return o(n("request:interceptor"),u,f).then(function(e){return r("request",c["default"](e)),t(c["default"](e)).then(function(t){return o(n("response:interceptor"),s,a.fromJS(t),[c["default"](e)])})}).then(null,function(t){return o(n("error:interceptor"),i,t,[c["default"](f)]).then(function(t){return Promise.reject(t)})})}},t.exports=e["default"]},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=function(t){return function(e){return e.data&&(e.form=/application\/json/.test(e.headers["Content-Type"])?JSON.stringify(e.data):e.data,delete e.data),e.params&&(e.qs=e.params,delete e.params),new Promise(function(r,n){t(e,function(t,e,i){if(t)throw t;var o=void 0;try{o=JSON.parse(i)}catch(u){o=i}var s={data:o,headers:e.headers,statusCode:e.statusCode};if(e.statusCode>=200&&e.statusCode<300)return r(s);var a=new Error(e.statusMessage);a.response=s,n(a)})})}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){var e=o.Map(),r=new i.EventEmitter,u={assign:function(t,r,n){return u.has(t)||u.set(t,o.Map()),e=e.setIn([t,r],n),u},emit:function(){r.emit.apply(r,arguments),t&&t.emit.apply(t,arguments)},get:function(r){var n=e.get(r);if(u.has(r)&&!o.Iterable.isIterable(n)||!t)return n;if(!u.has(r)&&t)return t.get(r);var i=t.get(r);return i?o.List.isList(i)?i.concat(n):i.mergeDeep(n):n},has:function(t){return e.has(t)},"new":function(){return n(u)},on:r.on.bind(r),once:r.once.bind(r),push:function(t,r){return u.has(t)||u.set(t,o.List()),e=e.update(t,function(t){return t.push(r)}),u},set:function(t,r){return e=e.set(t,r),u}};return u}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(17),o=r(7);t.exports=e["default"]},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function u(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,s,a,f;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],u(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];r.apply(this,s)}else if(o(r)){for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];for(f=r.slice(),i=f.length,a=0;i>a;a++)f[a].apply(this,s)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,u,s;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],u=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=u;s-->0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},function(t,e){!function(){"use strict";function t(t){if("string"!=typeof t&&(t=t.toString()),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function e(t){return"string"!=typeof t&&(t=t.toString()),t}function r(t){this.map={},t instanceof r?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function n(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function i(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function o(t){var e=new FileReader;return e.readAsArrayBuffer(t),i(e)}function u(t){var e=new FileReader;return e.readAsText(t),i(e)}function s(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(l.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(l.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else{if(t)throw new Error("unsupported BodyInit type");this._bodyText=""}},l.blob?(this.blob=function(){var t=n(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(o)},this.text=function(){var t=n(this);if(t)return t;if(this._bodyBlob)return u(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=n(this);return t?t:Promise.resolve(this._bodyText)},l.formData&&(this.formData=function(){return this.text().then(c)}),this.json=function(){return this.text().then(JSON.parse)},this}function a(t){var e=t.toUpperCase();return _.indexOf(e)>-1?e:t}function f(t,e){if(e=e||{},this.url=t,this.credentials=e.credentials||"omit",this.headers=new r(e.headers),this.method=a(e.method||"GET"),this.mode=e.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&e.body)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(e.body)}function c(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function h(t){var e=new r,n=t.getAllResponseHeaders().trim().split("\n");return n.forEach(function(t){var r=t.trim().split(":"),n=r.shift().trim(),i=r.join(":").trim();e.append(n,i)}),e}function p(t,e){e||(e={}),this._initBody(t),this.type="default",this.url=null,this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof r?e.headers:new r(e.headers),this.url=e.url||""}if(!self.fetch){r.prototype.append=function(r,n){r=t(r),n=e(n);var i=this.map[r];i||(i=[],this.map[r]=i),i.push(n)},r.prototype["delete"]=function(e){delete this.map[t(e)]},r.prototype.get=function(e){var r=this.map[t(e)];return r?r[0]:null},r.prototype.getAll=function(e){return this.map[t(e)]||[]},r.prototype.has=function(e){return this.map.hasOwnProperty(t(e))},r.prototype.set=function(r,n){this.map[t(r)]=[e(n)]},r.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(n){t.call(e,n,r,this)},this)},this)};var l={blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self},_=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];s.call(f.prototype),s.call(p.prototype),self.Headers=r,self.Request=f,self.Response=p,self.fetch=function(t,e){var r;return r=f.prototype.isPrototypeOf(t)&&!e?t:new f(t,e),new Promise(function(t,e){function n(){return"responseURL"in i?i.responseURL:/^X-Request-URL:/m.test(i.getAllResponseHeaders())?i.getResponseHeader("X-Request-URL"):void 0}var i=new XMLHttpRequest;i.onload=function(){var r=1223===i.status?204:i.status;if(100>r||r>599)return void e(new TypeError("Network request failed"));var o={status:r,statusText:i.statusText,headers:h(i),url:n()},u="response"in i?i.response:i.responseText;t(new p(u,o))},i.onerror=function(){e(new TypeError("Network request failed"))},i.open(r.method,r.url,!0),"include"===r.credentials&&(i.withCredentials=!0),"responseType"in i&&l.blob&&(i.responseType="blob"),r.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send("undefined"==typeof r._bodyInit?null:r._bodyInit)})},self.fetch.polyfill=!0}}()}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.restful=e():t.restful=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),o=n(i),u=r(9),s=n(u);r(19),e["default"]=function(t){var e=arguments.length<=1||void 0===arguments[1]?(0,s["default"])(fetch):arguments[1];return(0,o["default"])(t,e)},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=(0,d["default"])();r.assign("config","entityIdentifier","id"),!t&&"undefined"!=typeof window&&window.location?r.set("url",window.location.protocol+"//"+window.location.host):r.set("url",t);var n=(0,h.member)((0,u["default"])((0,c["default"])(e))(r));return v.push(n),n}Object.defineProperty(e,"__esModule",{value:!0});var o=r(2),u=n(o),s=r(9),a=n(s),f=r(14),c=n(f),h=r(15),p=r(16),l=n(p),_=r(17),d=n(_),v=[];i._instances=function(){return v},i._flush=function(){return v.length=0},e.fetchBackend=a["default"],e.requestBackend=l["default"],e["default"]=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var i=r(3),o=n(i),u=r(4),s=n(u),a=r(6),f=r(7),c=n(f);e["default"]=function(t){return function e(r){function n(t,e,n,i){var o=(0,a.Map)({errorInterceptors:(0,a.List)(r.get("errorInterceptors")),headers:(0,a.Map)(r.get("headers")).mergeDeep((0,a.Map)(i)),method:t,params:n,requestInterceptors:(0,a.List)(r.get("requestInterceptors")),responseInterceptors:(0,a.List)(r.get("responseInterceptors")),url:r.get("url")});return e&&(o.hasIn(["headers","Content-Type"])||(o=o.setIn(["headers","Content-Type"],"application/json;charset=UTF-8")),o=o.set("data",(0,a.fromJS)(e))),o}function i(t,e){var n=(0,s["default"])(e,p);return r.emit("response",n,(0,c["default"])(t)),n}function u(t,e){throw r.emit("error",e,(0,c["default"])(t)),e}function f(e){var o=arguments.length<=1||void 0===arguments[1]?!0:arguments[1],s=function(){r.emit.apply(r,arguments)};return o?function(r){var o=arguments.length<=1||void 0===arguments[1]?null:arguments[1],a=arguments.length<=2||void 0===arguments[2]?null:arguments[2],f=n(e,r,o,a);return t(f,s).then(function(t){return i(f,t)},function(t){return u(f,t)})}:function(){var r=arguments.length<=0||void 0===arguments[0]?null:arguments[0],o=arguments.length<=1||void 0===arguments[1]?null:arguments[1],a=n(e,null,r,o);return t(a,s).then(function(t){return i(a,t)},function(t){return u(a,t)})}}function h(t){return function(e){return r.push(t+"Interceptors",e),p}}r.on("error",function(){return!0});var p={};return(0,o["default"])(p,{addErrorInterceptor:h("error"),addRequestInterceptor:h("request"),addResponseInterceptor:h("response"),"delete":f("delete"),identifier:function(t){return void 0===t?r.get("config").get("entityIdentifier"):(r.assign("config","entityIdentifier",t),p)},get:f("get",!1),head:f("head",!1),header:function(t,e){return r.assign("headers",t,e)},headers:function(){return r.get("headers")},"new":function(t){var n=r["new"]();return n.set("url",t),e(n)},on:r.on,once:r.once,patch:f("patch"),post:f("post"),put:f("put"),url:function(){return r.get("url")}}),p}},t.exports=e["default"]},function(t,e){"use strict";function r(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t,e){for(var n,i,o=r(t),u=1;ui;i++)n[i]=arguments[i];return e.put.apply(e,[t].concat(n))},url:e.url}},t.exports=e["default"]},function(t,e,r){!function(e,r){t.exports=r()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return o(t)?t:j(t)}function r(t){return u(t)?t:M(t)}function n(t){return s(t)?t:q(t)}function i(t){return o(t)&&!a(t)?t:A(t)}function o(t){return!(!t||!t[ar])}function u(t){return!(!t||!t[fr])}function s(t){return!(!t||!t[cr])}function a(t){return u(t)||s(t)}function f(t){return!(!t||!t[hr])}function c(t){return t.value=!1,t}function h(t){t&&(t.value=!0)}function p(){}function l(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=new Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function _(t){return void 0===t.size&&(t.size=t.__iterate(v)),t.size}function d(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return 0>e?_(t)+e:e}function v(){return!0}function y(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function m(t,e){return w(t,e,0)}function g(t,e){return w(t,e,e)}function w(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function b(t){this.next=t}function I(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function x(t){return!!E(t)}function z(t){return t&&"function"==typeof t.next}function O(t){var e=E(t);return e&&e.call(t)}function E(t){var e=t&&(Ir&&t[Ir]||t[Sr]);return"function"==typeof e?e:void 0}function D(t){return t&&"number"==typeof t.length}function j(t){return null===t||void 0===t?U():o(t)?t.toSeq():N(t)}function M(t){return null===t||void 0===t?U().toKeyedSeq():o(t)?u(t)?t.toSeq():t.fromEntrySeq():B(t)}function q(t){return null===t||void 0===t?U():o(t)?u(t)?t.entrySeq():t.toIndexedSeq():K(t)}function A(t){return(null===t||void 0===t?U():o(t)?u(t)?t.entrySeq():t:K(t)).toSetSeq()}function k(t){this._array=t,this.size=t.length}function L(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function T(t){this._iterable=t,this.size=t.length||t.size}function R(t){this._iterator=t,this._iteratorCache=[]}function P(t){return!(!t||!t[zr])}function U(){return Or||(Or=new k([]))}function B(t){var e=Array.isArray(t)?new k(t).fromEntrySeq():z(t)?new R(t).fromEntrySeq():x(t)?new T(t).fromEntrySeq():"object"==typeof t?new L(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function K(t){var e=C(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function N(t){var e=C(t)||"object"==typeof t&&new L(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function C(t){return D(t)?new k(t):z(t)?new R(t):x(t)?new T(t):void 0}function H(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function W(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new b(function(){var t=i[r?o-u:u];return u++>o?S():I(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function J(t,e){return e?F(e,t,"",{"":t}):V(t)}function F(t,e,r,n){return Array.isArray(e)?t.call(n,r,q(e).map(function(r,n){return F(t,r,n,e)})):G(e)?t.call(n,r,M(e).map(function(r,n){return F(t,r,n,e)})):e}function V(t){return Array.isArray(t)?q(t).map(V).toList():G(t)?M(t).map(V).toMap():t}function G(t){return t&&(t.constructor===Object||void 0===t.constructor)}function X(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function Y(t,e){if(t===e)return!0;if(!o(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||u(t)!==u(e)||s(t)!==s(e)||f(t)!==f(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!a(t);if(f(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&X(i[1],t)&&(r||X(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var c=t;t=e,e=c}var h=!0,p=e.__iterate(function(e,n){return(r?t.has(e):i?X(e,t.get(n,vr)):X(t.get(n,vr),e))?void 0:(h=!1,!1)});return h&&t.size===p}function $(t,e){if(!(this instanceof $))return new $(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(Er)return Er;Er=this}}function Q(t,e){if(!t)throw new Error(e)}function Z(t,e,r){if(!(this instanceof Z))return new Z(t,e,r);if(Q(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(Dr)return Dr;Dr=this}}function tt(){throw TypeError("Abstract")}function et(){}function rt(){}function nt(){}function it(t){return t>>>1&1073741824|3221225471&t}function ot(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return it(r)}if("string"===e)return t.length>Rr?ut(t):st(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return at(t);if("function"==typeof t.toString)return st(t.toString());throw new Error("Value type "+e+" cannot be hashed.")}function ut(t){var e=Br[t];return void 0===e&&(e=st(t),Ur===Pr&&(Ur=0,Br={}),Ur++,Br[t]=e),e}function st(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ct(t){Q(t!==1/0,"Cannot perform this action with an infinite size.")}function ht(t){return null===t||void 0===t?It():pt(t)&&!f(t)?t:It().withMutations(function(e){var n=r(t);ct(n.size),n.forEach(function(t,r){return e.set(r,t)})})}function pt(t){return!(!t||!t[Kr])}function lt(t,e){this.ownerID=t,this.entries=e}function _t(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function dt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function vt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function yt(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function mt(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&wt(t._root)}function gt(t,e){return I(t,e[0],e[1])}function wt(t,e){return{node:t,index:0,__prev:e}}function bt(t,e,r,n){var i=Object.create(Nr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function It(){return Cr||(Cr=bt(0))}function St(t,e,r){var n,i;if(t._root){var o=c(yr),u=c(mr);if(n=xt(t._root,t.__ownerID,0,void 0,e,r,o,u),!u.value)return t;i=t.size+(o.value?r===vr?-1:1:0)}else{if(r===vr)return t;i=1,n=new lt(t.__ownerID,[[e,r]])}return t.__ownerID?(t.size=i,t._root=n,t.__hash=void 0,t.__altered=!0,t):n?bt(i,n):It()}function xt(t,e,r,n,i,o,u,s){return t?t.update(e,r,n,i,o,u,s):o===vr?t:(h(s),h(u),new yt(e,n,[i,o]))}function zt(t){return t.constructor===yt||t.constructor===vt}function Ot(t,e,r,n,i){if(t.keyHash===n)return new vt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&dr,s=(0===r?n:n>>>r)&dr,a=u===s?[Ot(t,e,r+lr,n,i)]:(o=new yt(e,n,i),s>u?[t,o]:[o,t]);return new _t(e,1<s;s++,a<<=1){var c=e[s];void 0!==c&&s!==n&&(i|=a,u[o++]=c)}return new _t(t,i,u)}function jt(t,e,r,n,i){for(var o=0,u=new Array(_r),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new dt(t,o+1,u)}function Mt(t,e,n){for(var i=[],u=0;u>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function Rt(t,e,r,n){var i=n?t:l(t);return i[e]=r,i}function Pt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=new Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function Ut(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function Bt(t){var e=Wt();if(null===t||void 0===t)return e;if(Kt(t))return t;var r=n(t),i=r.size;return 0===i?e:(ct(i),i>0&&_r>i?Ht(0,i,lr,null,new Nt(r.toArray())):e.withMutations(function(t){t.setSize(i),r.forEach(function(e,r){return t.set(r,e)})}))}function Kt(t){return!(!t||!t[Fr])}function Nt(t,e){this.array=t,this.ownerID=e}function Ct(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,f=u-r;return f>_r&&(f=_r),function(){if(i===f)return Xr;var t=e?--f:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,f=i>o?0:o-i>>n,c=(u-i>>n)+1;return c>_r&&(c=_r),function(){for(;;){if(s){var t=s();if(t!==Xr)return t;s=null}if(f===c)return Xr;var o=e?--c:f++;s=r(a&&a[o],n-lr,i+(o<=t.size||0>e)return t.withMutations(function(t){0>e?Xt(t,e).set(0,r):Xt(t,0,e+1).set(e,r)});e+=t._origin;var n=t._tail,i=t._root,o=c(mr);return e>=$t(t._capacity)?n=Ft(n,t.__ownerID,0,e,r,o):i=Ft(i,t.__ownerID,t._level,e,r,o),o.value?t.__ownerID?(t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t):Ht(t._origin,t._capacity,t._level,i,n):t}function Ft(t,e,r,n,i,o){var u=n>>>r&dr,s=t&&u0){var f=t&&t.array[u],c=Ft(f,e,r-lr,n,i,o);return c===f?t:(a=Vt(t,e),a.array[u]=c,a)}return s&&t.array[u]===i?t:(h(o),a=Vt(t,e),void 0===i&&u===a.array.length-1?a.array.pop():a.array[u]=i,a)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Nt(t?t.array.slice():[],e)}function Gt(t,e){if(e>=$t(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&dr],n-=lr;return r}}function Xt(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var n=t.__ownerID||new p,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:0>r?o+r:i+r;if(u===i&&s===o)return t;if(u>=s)return t.clear();for(var a=t._level,f=t._root,c=0;0>u+c;)f=new Nt(f&&f.array.length?[void 0,f]:[],n),a+=lr,c+=1<=1<l?Gt(t,s-1):l>h?new Nt([],n):_;if(_&&l>h&&o>u&&_.array.length){f=Vt(f,n);for(var v=f,y=a;y>lr;y-=lr){var m=h>>>y&dr;v=v.array[m]=Vt(v.array[m],n)}v.array[h>>>lr&dr]=_}if(o>s&&(d=d&&d.removeAfter(n,0,s)),u>=l)u-=l,s-=l,a=lr,f=null,d=d&&d.removeBefore(n,0,u);else if(u>i||h>l){for(c=0;f;){var g=u>>>a&dr;if(g!==l>>>a&dr)break;g&&(c+=(1<i&&(f=f.removeBefore(n,a,u-c)),f&&h>l&&(f=f.removeAfter(n,a,l-c)),c&&(u-=c,s-=c)}return t.__ownerID?(t.size=s-u,t._origin=u,t._capacity=s,t._level=a,t._root=f,t._tail=d,t.__hash=void 0,t.__altered=!0,t):Ht(u,s,a,f,d)}function Yt(t,e,r){for(var i=[],u=0,s=0;su&&(u=f.size),o(a)||(f=f.map(function(t){return J(t)})),i.push(f)}return u>t.size&&(t=t.setSize(u)),kt(t,e,i)}function $t(t){return _r>t?0:t-1>>>lr<=_r&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):te(n,i)}function ne(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ie(t){this._iter=t,this.size=t.size}function oe(t){this._iter=t,this.size=t.size}function ue(t){this._iter=t,this.size=t.size}function se(t){var e=De(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=je,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===br){var n=t.__iterator(e,r);return new b(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===wr?gr:wr,r)},e}function ae(t,e,r){var n=De(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,vr);return o===vr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(br,i);return new b(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return I(n,s,e.call(r,u[1],s,t),i)})},n}function fe(t,e){var r=De(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=se(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=je,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function ce(t,e,r,n){var i=De(t);return n&&(i.has=function(n){var i=t.get(n,vr);return i!==vr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,vr);return o!==vr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(br,o),s=0;return new b(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,f=a[0],c=a[1];if(e.call(r,c,f,t))return I(i,n?f:s++,c,o)}})},i}function he(t,e,r){var n=ht().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function pe(t,e,r){var n=u(t),i=(f(t)?Qt():ht()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=Ee(t);return i.map(function(e){return xe(t,o(e))})}function le(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),y(e,r,i))return t;var o=m(e,i),u=g(r,i);if(o!==o||u!==u)return le(t.toSeq().cacheResult(),e,r,n);var s,a=u-o;a===a&&(s=0>a?0:a);var f=De(t);return f.size=0===s?s:t.size&&s||void 0,!n&&P(t)&&s>=0&&(f.get=function(e,r){return e=d(this,e),e>=0&&s>e?t.get(e+o,r):r}),f.__iterateUncached=function(e,r){var i=this;if(0===s)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,a=!0,f=0;return t.__iterate(function(t,r){return a&&(a=u++s)return S();var t=i.next();return n||e===wr?t:e===gr?I(e,a-1,void 0,t):I(e,a-1,t.value[1],t)})},f}function _e(t,e,r){var n=De(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(br,i),s=!0;return new b(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],f=i[1];return e.call(r,f,a,o)?n===br?t:I(n,a,f,t):(s=!1,S())})},n}function de(t,e,r,n){var i=De(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,f){return s&&(s=e.call(r,t,o,f))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(br,o),a=!0,f=0;return new b(function(){var t,o,c;do{if(t=s.next(),t.done)return n||i===wr?t:i===gr?I(i,f++,void 0,t):I(i,f++,t.value[1],t);var h=t.value;o=h[0],c=h[1],a&&(a=e.call(r,c,o,u))}while(a);return i===br?t:I(i,o,c,t)})},i}function ve(t,e){var n=u(t),i=[t].concat(e).map(function(t){return o(t)?n&&(t=r(t)):t=n?B(t):K(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===i.length)return t;if(1===i.length){var a=i[0];if(a===t||n&&u(a)||s(t)&&s(a))return a}var f=new k(i);return n?f=f.toKeyedSeq():s(t)||(f=f.toSetSeq()),f=f.flatten(!0),f.size=i.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),f}function ye(t,e,r){var n=De(t);return n.__iterateUncached=function(n,i){function u(t,f){var c=this;t.__iterate(function(t,i){return(!e||e>f)&&o(t)?u(t,f+1):n(t,r?i:s++,c)===!1&&(a=!0),!a},i)}var s=0,a=!1;return u(t,0),s},n.__iteratorUncached=function(n,i){var u=t.__iterator(n,i),s=[],a=0;return new b(function(){for(;u;){var t=u.next();if(t.done===!1){var f=t.value;if(n===br&&(f=f[1]),e&&!(s.length0}function Se(t,r,n){var i=De(t);return i.size=new k(n).map(function(t){return t.size}).min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(wr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},i.__iteratorUncached=function(t,i){var o=n.map(function(t){return t=e(t),O(i?t.reverse():t)}),u=0,s=!1;return new b(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=e.some(function(t){return t.done})),s?S():I(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function xe(t,e){return P(t)?e:t.constructor(e)}function ze(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Oe(t){return ct(t.size),_(t)}function Ee(t){return u(t)?r:s(t)?n:i}function De(t){return Object.create((u(t)?M:s(t)?q:A).prototype)}function je(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):j.prototype.cacheResult.call(this)}function Me(t,e){return t>e?1:e>t?-1:0}function qe(t){var r=O(t);if(!r){if(!D(t))throw new TypeError("Expected iterable or array-like: "+t);r=O(e(t))}return r}function Ae(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);Te(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=ht(o)},i=n.prototype=Object.create($r);return i.constructor=n,n}function ke(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function Le(t){return t._name||t.constructor.name||"Record"}function Te(t,e){try{e.forEach(Re.bind(void 0,t))}catch(r){}}function Re(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){Q(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Pe(t){return null===t||void 0===t?Ne():Ue(t)&&!f(t)?t:Ne().withMutations(function(e){var r=i(t);ct(r.size),r.forEach(function(t){return e.add(t)})})}function Ue(t){return!(!t||!t[Qr])}function Be(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Ke(t,e){var r=Object.create(Zr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ne(){return tn||(tn=Ke(It()))}function Ce(t){return null===t||void 0===t?Je():He(t)?t:Je().withMutations(function(e){var r=i(t);ct(r.size),r.forEach(function(t){return e.add(t)})})}function He(t){return Ue(t)&&f(t)}function We(t,e){var r=Object.create(en);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Je(){return rn||(rn=We(ee()))}function Fe(t){return null===t||void 0===t?Xe():Ve(t)?t:Xe().unshiftAll(t)}function Ve(t){return!(!t||!t[nn])}function Ge(t,e,r,n){var i=Object.create(on);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Xe(){return un||(un=Ge(0))}function Ye(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function $e(t,e){return e}function Qe(t,e){return[e,t]}function Ze(t){return function(){return!t.apply(this,arguments)}}function tr(t){return function(){return-t.apply(this,arguments)}}function er(t){return"string"==typeof t?JSON.stringify(t):t}function rr(){return l(arguments)}function nr(t,e){return e>t?1:t>e?-1:0}function ir(t){if(t.size===1/0)return 0;var e=f(t),r=u(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+ur(ot(t),ot(e))|0}:function(t,e){n=n+ur(ot(t),ot(e))|0}:e?function(t){n=31*n+ot(t)|0}:function(t){n=n+ot(t)|0});return or(i,n)}function or(t,e){return e=Mr(e,3432918353),e=Mr(e<<15|e>>>-15,461845907),e=Mr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=Mr(e^e>>>16,2246822507),e=Mr(e^e>>>13,3266489909),e=it(e^e>>>16)}function ur(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var sr=Array.prototype.slice;t(r,e),t(n,e),t(i,e),e.isIterable=o,e.isKeyed=u,e.isIndexed=s,e.isAssociative=a,e.isOrdered=f,e.Keyed=r,e.Indexed=n,e.Set=i;var ar="@@__IMMUTABLE_ITERABLE__@@",fr="@@__IMMUTABLE_KEYED__@@",cr="@@__IMMUTABLE_INDEXED__@@",hr="@@__IMMUTABLE_ORDERED__@@",pr="delete",lr=5,_r=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},k.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new b(function(){return i>n?S():I(t,i,r[e?n-i++:i++])})},t(L,M),L.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},L.prototype.has=function(t){return this._object.hasOwnProperty(t)},L.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},L.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new b(function(){var u=n[e?i-o:o];return o++>i?S():I(t,u,r[u])})},L.prototype[hr]=!0,t(T,q),T.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e); +var r=this._iterable,n=O(r),i=0;if(z(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},T.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=O(r);if(!z(n))return new b(S);var i=0;return new b(function(){var e=n.next();return e.done?e:I(t,i++,e.value)})},t(R,q),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return I(t,i,n[i++])})};var Or;t($,q),$.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},$.prototype.get=function(t,e){return this.has(t)?this._value:e},$.prototype.includes=function(t){return X(this._value,t)},$.prototype.slice=function(t,e){var r=this.size;return y(t,e,r)?this:new $(this._value,g(e,r)-m(t,r))},$.prototype.reverse=function(){return this},$.prototype.indexOf=function(t){return X(this._value,t)?0:-1},$.prototype.lastIndexOf=function(t){return X(this._value,t)?this.size:-1},$.prototype.__iterate=function(t,e){for(var r=0;r1?" by "+this._step:"")+" ]"},Z.prototype.get=function(t,e){return this.has(t)?this._start+d(this,t)*this._step:e},Z.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&e=e?new Z(0,0):new Z(this.get(t,this._end),this.get(e,this._end),this._step))},Z.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&r=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},Z.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new b(function(){var u=i;return i+=e?-n:n,o>r?S():I(t,o++,u)})},Z.prototype.equals=function(t){return t instanceof Z?this._start===t._start&&this._end===t._end&&this._step===t._step:Y(this,t)};var Dr;t(tt,e),t(et,tt),t(rt,tt),t(nt,tt),tt.Keyed=et,tt.Indexed=rt,tt.Set=nt;var jr,Mr="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},qr=Object.isExtensible,Ar=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),kr="function"==typeof WeakMap;kr&&(jr=new WeakMap);var Lr=0,Tr="__immutablehash__";"function"==typeof Symbol&&(Tr=Symbol(Tr));var Rr=16,Pr=255,Ur=0,Br={};t(ht,et),ht.prototype.toString=function(){return this.__toString("Map {","}")},ht.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},ht.prototype.set=function(t,e){return St(this,t,e)},ht.prototype.setIn=function(t,e){return this.updateIn(t,vr,function(){return e})},ht.prototype.remove=function(t){return St(this,t,vr)},ht.prototype.deleteIn=function(t){return this.updateIn(t,function(){return vr})},ht.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},ht.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Lt(this,qe(t),e,r);return n===vr?void 0:n},ht.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):It()},ht.prototype.merge=function(){return Mt(this,void 0,arguments)},ht.prototype.mergeWith=function(t){var e=sr.call(arguments,1);return Mt(this,t,e)},ht.prototype.mergeIn=function(t){var e=sr.call(arguments,1);return this.updateIn(t,It(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},ht.prototype.mergeDeep=function(){return Mt(this,qt,arguments)},ht.prototype.mergeDeepWith=function(t){var e=sr.call(arguments,1);return Mt(this,At(t),e)},ht.prototype.mergeDeepIn=function(t){var e=sr.call(arguments,1);return this.updateIn(t,It(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},ht.prototype.sort=function(t){return Qt(we(this,t))},ht.prototype.sortBy=function(t,e){return Qt(we(this,e,t))},ht.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},ht.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new p)},ht.prototype.asImmutable=function(){return this.__ensureOwner()},ht.prototype.wasAltered=function(){return this.__altered},ht.prototype.__iterator=function(t,e){return new mt(this,t,e)},ht.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},ht.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?bt(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},ht.isMap=pt;var Kr="@@__IMMUTABLE_MAP__@@",Nr=ht.prototype;Nr[Kr]=!0,Nr[pr]=Nr.remove,Nr.removeIn=Nr.deleteIn,lt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},lt.prototype.update=function(t,e,r,n,i,o,u){for(var s=i===vr,a=this.entries,f=0,c=a.length;c>f&&!X(n,a[f][0]);f++);var p=c>f;if(p?a[f][1]===i:s)return this;if(h(u),(s||!p)&&h(o),!s||1!==a.length){if(!p&&!s&&a.length>=Hr)return Et(t,a,n,i);var _=t&&t===this.ownerID,d=_?a:l(a);return p?s?f===c-1?d.pop():d[f]=d.pop():d[f]=[n,i]:d.push([n,i]),_?(this.entries=d,this):new lt(t,d)}},_t.prototype.get=function(t,e,r,n){void 0===e&&(e=ot(r));var i=1<<((0===t?e:e>>>t)&dr),o=this.bitmap;return 0===(o&i)?n:this.nodes[Tt(o&i-1)].get(t+lr,e,r,n)},_t.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=(0===e?r:r>>>e)&dr,a=1<=Wr)return jt(t,p,f,s,_);if(c&&!_&&2===p.length&&zt(p[1^h]))return p[1^h];if(c&&_&&1===p.length&&zt(_))return _;var d=t&&t===this.ownerID,v=c?_?f:f^a:f|a,y=c?_?Rt(p,h,_,d):Ut(p,h,d):Pt(p,h,_,d);return d?(this.bitmap=v,this.nodes=y,this):new _t(t,v,y)},dt.prototype.get=function(t,e,r,n){void 0===e&&(e=ot(r));var i=(0===t?e:e>>>t)&dr,o=this.nodes[i];return o?o.get(t+lr,e,r,n):n},dt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=(0===e?r:r>>>e)&dr,a=i===vr,f=this.nodes,c=f[s];if(a&&!c)return this;var h=xt(c,t,e+lr,r,n,i,o,u);if(h===c)return this;var p=this.count;if(c){if(!h&&(p--,Jr>p))return Dt(t,f,p,s)}else p++;var l=t&&t===this.ownerID,_=Rt(f,s,h,l);return l?(this.count=p,this.nodes=_,this):new dt(t,p,_)},vt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},vt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=i===vr;if(r!==this.keyHash)return s?this:(h(u),h(o),Ot(this,t,e,r,[n,i]));for(var a=this.entries,f=0,c=a.length;c>f&&!X(n,a[f][0]);f++);var p=c>f;if(p?a[f][1]===i:s)return this;if(h(u),(s||!p)&&h(o),s&&2===c)return new yt(t,this.keyHash,a[1^f]);var _=t&&t===this.ownerID,d=_?a:l(a);return p?s?f===c-1?d.pop():d[f]=d.pop():d[f]=[n,i]:d.push([n,i]),_?(this.entries=d,this):new vt(t,this.keyHash,d)},yt.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},yt.prototype.update=function(t,e,r,n,i,o,u){var s=i===vr,a=X(n,this.entry[0]);return(a?i===this.entry[1]:s)?this:(h(u),s?void h(o):a?t&&t===this.ownerID?(this.entry[1]=i,this):new yt(t,this.keyHash,[n,i]):(h(o),Ot(this,t,e,ot(n),[n,i])))},lt.prototype.iterate=vt.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},_t.prototype.iterate=dt.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},yt.prototype.iterate=function(t,e){return t(this.entry)},t(mt,b),mt.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return gt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return gt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return gt(t,o.entry);e=this._stack=wt(o,e)}continue}e=this._stack=this._stack.__prev}return S()};var Cr,Hr=_r/4,Wr=_r/2,Jr=_r/4;t(Bt,rt),Bt.of=function(){return this(arguments)},Bt.prototype.toString=function(){return this.__toString("List [","]")},Bt.prototype.get=function(t,e){if(t=d(this,t),t>=0&&t>>e&dr;if(n>=this.array.length)return new Nt([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-lr,r),i===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},Nt.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&dr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-lr,r),i===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Gr,Xr={};t(Qt,ht),Qt.of=function(){return this(arguments)},Qt.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Qt.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Qt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ee()},Qt.prototype.set=function(t,e){return re(this,t,e)},Qt.prototype.remove=function(t){return re(this,t,vr)},Qt.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Qt.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Qt.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Qt.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?te(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Qt.isOrderedMap=Zt,Qt.prototype[hr]=!0,Qt.prototype[pr]=Qt.prototype.remove;var Yr;t(ne,M),ne.prototype.get=function(t,e){return this._iter.get(t,e)},ne.prototype.has=function(t){return this._iter.has(t)},ne.prototype.valueSeq=function(){return this._iter.valueSeq()},ne.prototype.reverse=function(){var t=this,e=fe(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},ne.prototype.map=function(t,e){var r=this,n=ae(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},ne.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?Oe(this):0,function(i){return t(i,e?--r:r++,n)}),e)},ne.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(wr,e),n=e?Oe(this):0;return new b(function(){var i=r.next();return i.done?i:I(t,e?--n:n++,i.value,i)})},ne.prototype[hr]=!0,t(ie,q),ie.prototype.includes=function(t){return this._iter.includes(t)},ie.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ie.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e),n=0;return new b(function(){var e=r.next();return e.done?e:I(t,n++,e.value,e)})},t(oe,A),oe.prototype.has=function(t){return this._iter.includes(t)},oe.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},oe.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e);return new b(function(){var e=r.next();return e.done?e:I(t,e.value,e.value,e)})},t(ue,M),ue.prototype.entrySeq=function(){return this._iter.toSeq()},ue.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ze(e);var n=o(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ue.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e);return new b(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ze(n);var i=o(n);return I(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ie.prototype.cacheResult=ne.prototype.cacheResult=oe.prototype.cacheResult=ue.prototype.cacheResult=je,t(Ae,et),Ae.prototype.toString=function(){return this.__toString(Le(this)+" {","}")},Ae.prototype.has=function(t){return this._defaultValues.hasOwnProperty(t)},Ae.prototype.get=function(t,e){if(!this.has(t))return e;var r=this._defaultValues[t];return this._map?this._map.get(t,r):r},Ae.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var t=this.constructor;return t._empty||(t._empty=ke(this,It()))},Ae.prototype.set=function(t,e){if(!this.has(t))throw new Error('Cannot set unknown key "'+t+'" on '+Le(this));var r=this._map&&this._map.set(t,e);return this.__ownerID||r===this._map?this:ke(this,r)},Ae.prototype.remove=function(t){if(!this.has(t))return this;var e=this._map&&this._map.remove(t);return this.__ownerID||e===this._map?this:ke(this,e)},Ae.prototype.wasAltered=function(){return this._map.wasAltered()},Ae.prototype.__iterator=function(t,e){var n=this;return r(this._defaultValues).map(function(t,e){return n.get(e)}).__iterator(t,e)},Ae.prototype.__iterate=function(t,e){var n=this;return r(this._defaultValues).map(function(t,e){return n.get(e)}).__iterate(t,e)},Ae.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map&&this._map.__ensureOwner(t);return t?ke(this,e,t):(this.__ownerID=t,this._map=e,this)};var $r=Ae.prototype;$r[pr]=$r.remove,$r.deleteIn=$r.removeIn=Nr.removeIn,$r.merge=Nr.merge,$r.mergeWith=Nr.mergeWith,$r.mergeIn=Nr.mergeIn,$r.mergeDeep=Nr.mergeDeep,$r.mergeDeepWith=Nr.mergeDeepWith,$r.mergeDeepIn=Nr.mergeDeepIn,$r.setIn=Nr.setIn,$r.update=Nr.update,$r.updateIn=Nr.updateIn,$r.withMutations=Nr.withMutations,$r.asMutable=Nr.asMutable,$r.asImmutable=Nr.asImmutable,t(Pe,nt),Pe.of=function(){return this(arguments)},Pe.fromKeys=function(t){return this(r(t).keySeq())},Pe.prototype.toString=function(){return this.__toString("Set {","}")},Pe.prototype.has=function(t){return this._map.has(t)},Pe.prototype.add=function(t){return Be(this,this._map.set(t,!0))},Pe.prototype.remove=function(t){return Be(this,this._map.remove(t))},Pe.prototype.clear=function(){return Be(this,this._map.clear())},Pe.prototype.union=function(){var t=sr.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;r=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):Ge(t,e)},Fe.prototype.pushAll=function(t){if(t=n(t),0===t.size)return this;ct(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ge(e,r)},Fe.prototype.pop=function(){return this.slice(1)},Fe.prototype.unshift=function(){return this.push.apply(this,arguments)},Fe.prototype.unshiftAll=function(t){return this.pushAll(t)},Fe.prototype.shift=function(){return this.pop.apply(this,arguments)},Fe.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Xe()},Fe.prototype.slice=function(t,e){if(y(t,e,this.size))return this;var r=m(t,this.size),n=g(e,this.size);if(n!==this.size)return rt.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ge(i,o)},Fe.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ge(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Fe.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Fe.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new b(function(){if(n){var e=n.value;return n=n.next,I(t,r++,e)}return S()})},Fe.isStack=Ve;var nn="@@__IMMUTABLE_STACK__@@",on=Fe.prototype;on[nn]=!0,on.withMutations=Nr.withMutations,on.asMutable=Nr.asMutable,on.asImmutable=Nr.asImmutable,on.wasAltered=Nr.wasAltered;var un;e.Iterator=b,Ye(e,{toArray:function(){ct(this.size);var t=new Array(this.size||0);return this.valueSeq().__iterate(function(e,r){t[r]=e}),t},toIndexedSeq:function(){return new ie(this)},toJS:function(){return this.toSeq().map(function(t){return t&&"function"==typeof t.toJS?t.toJS():t}).__toJS()},toJSON:function(){return this.toSeq().map(function(t){return t&&"function"==typeof t.toJSON?t.toJSON():t}).__toJS()},toKeyedSeq:function(){return new ne(this,!0)},toMap:function(){return ht(this.toKeyedSeq())},toObject:function(){ct(this.size);var t={};return this.__iterate(function(e,r){t[r]=e}),t},toOrderedMap:function(){return Qt(this.toKeyedSeq())},toOrderedSet:function(){return Ce(u(this)?this.valueSeq():this)},toSet:function(){return Pe(u(this)?this.valueSeq():this)},toSetSeq:function(){return new oe(this)},toSeq:function(){return s(this)?this.toIndexedSeq():u(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Fe(u(this)?this.valueSeq():this)},toList:function(){return Bt(u(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(t,e){return 0===this.size?t+e:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+e},concat:function(){var t=sr.call(arguments,0);return xe(this,ve(this,t))},includes:function(t){return this.some(function(e){return X(e,t)})},entries:function(){return this.__iterator(br)},every:function(t,e){ct(this.size);var r=!0;return this.__iterate(function(n,i,o){return t.call(e,n,i,o)?void 0:(r=!1,!1)}),r},filter:function(t,e){return xe(this,ce(this,t,e,!0))},find:function(t,e,r){var n=this.findEntry(t,e);return n?n[1]:r},findEntry:function(t,e){var r;return this.__iterate(function(n,i,o){return t.call(e,n,i,o)?(r=[i,n],!1):void 0}),r},findLastEntry:function(t,e){return this.toSeq().reverse().findEntry(t,e)},forEach:function(t,e){return ct(this.size),this.__iterate(e?t.bind(e):t)},join:function(t){ct(this.size),t=void 0!==t?""+t:",";var e="",r=!0;return this.__iterate(function(n){r?r=!1:e+=t,e+=null!==n&&void 0!==n?n.toString():""}),e},keys:function(){return this.__iterator(gr)},map:function(t,e){return xe(this,ae(this,t,e))},reduce:function(t,e,r){ct(this.size);var n,i;return arguments.length<2?i=!0:n=e,this.__iterate(function(e,o,u){i?(i=!1,n=e):n=t.call(r,n,e,o,u)}),n},reduceRight:function(t,e,r){var n=this.toKeyedSeq().reverse();return n.reduce.apply(n,arguments)},reverse:function(){return xe(this,fe(this,!0))},slice:function(t,e){return xe(this,le(this,t,e,!0))},some:function(t,e){return!this.every(Ze(t),e)},sort:function(t){return xe(this,we(this,t))},values:function(){return this.__iterator(wr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some(function(){return!0})},count:function(t,e){return _(t?this.toSeq().filter(t,e):this)},countBy:function(t,e){return he(this,t,e)},equals:function(t){return Y(this,t)},entrySeq:function(){var t=this;if(t._cache)return new k(t._cache);var e=t.toSeq().map(Qe).toIndexedSeq();return e.fromEntrySeq=function(){return t.toSeq()},e},filterNot:function(t,e){return this.filter(Ze(t),e)},findLast:function(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)},first:function(){return this.find(v)},flatMap:function(t,e){return xe(this,me(this,t,e))},flatten:function(t){return xe(this,ye(this,t,!0))},fromEntrySeq:function(){return new ue(this)},get:function(t,e){return this.find(function(e,r){return X(r,t)},void 0,e)},getIn:function(t,e){for(var r,n=this,i=qe(t);!(r=i.next()).done;){var o=r.value;if(n=n&&n.get?n.get(o,vr):vr,n===vr)return e}return n},groupBy:function(t,e){return pe(this,t,e)},has:function(t){return this.get(t,vr)!==vr},hasIn:function(t){return this.getIn(t,vr)!==vr},isSubset:function(t){return t="function"==typeof t.includes?t:e(t),this.every(function(e){return t.includes(e)})},isSuperset:function(t){return t="function"==typeof t.isSubset?t:e(t),t.isSubset(this)},keySeq:function(){return this.toSeq().map($e).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},max:function(t){return be(this,t)},maxBy:function(t,e){return be(this,e,t)},min:function(t){return be(this,t?tr(t):nr)},minBy:function(t,e){return be(this,e?tr(e):nr,t)},rest:function(){return this.slice(1)},skip:function(t){return this.slice(Math.max(0,t))},skipLast:function(t){return xe(this,this.toSeq().reverse().skip(t).reverse())},skipWhile:function(t,e){return xe(this,de(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(Ze(t),e)},sortBy:function(t,e){return xe(this,we(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return xe(this,this.toSeq().reverse().take(t).reverse())},takeWhile:function(t,e){return xe(this,_e(this,t,e))},takeUntil:function(t,e){return this.takeWhile(Ze(t),e)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=ir(this))}});var sn=e.prototype;sn[ar]=!0,sn[xr]=sn.values,sn.__toJS=sn.toArray,sn.__toStringMapper=er,sn.inspect=sn.toSource=function(){return this.toString()},sn.chain=sn.flatMap,sn.contains=sn.includes,function(){try{Object.defineProperty(sn,"length",{get:function(){if(!e.noLengthWarning){var t;try{throw new Error}catch(r){t=r.stack}if(-1===t.indexOf("_wrapObject"))return console&&console.warn&&console.warn("iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version. "+t),this.size}}})}catch(t){}}(),Ye(r,{flip:function(){return xe(this,se(this))},findKey:function(t,e){var r=this.findEntry(t,e);return r&&r[0]},findLastKey:function(t,e){return this.toSeq().reverse().findKey(t,e)},keyOf:function(t){return this.findKey(function(e){return X(e,t)})},lastKeyOf:function(t){return this.findLastKey(function(e){return X(e,t)})},mapEntries:function(t,e){var r=this,n=0;return xe(this,this.toSeq().map(function(i,o){return t.call(e,[o,i],n++,r)}).fromEntrySeq())},mapKeys:function(t,e){var r=this;return xe(this,this.toSeq().flip().map(function(n,i){return t.call(e,n,i,r)}).flip())}});var an=r.prototype;an[fr]=!0,an[xr]=sn.entries,an.__toJS=sn.toObject,an.__toStringMapper=function(t,e){return JSON.stringify(e)+": "+er(t)},Ye(n,{toKeyedSeq:function(){return new ne(this,!1)},filter:function(t,e){return xe(this,ce(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.toKeyedSeq().keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.toKeyedSeq().reverse().keyOf(t);return void 0===e?-1:e},reverse:function(){return xe(this,fe(this,!1))},slice:function(t,e){return xe(this,le(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(0|e,0),0===r||2===r&&!e)return this;t=m(t,0>t?this.count():this.size);var n=this.slice(0,t);return xe(this,1===r?n:n.concat(l(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return xe(this,ye(this,t,!1))},get:function(t,e){return t=d(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=d(this,t),t>=0&&(void 0!==this.size?this.size===1/0||t=200&&t.status<300)return p;var l=new Error(t.statusText);throw l.response=p,l})})}},t.exports=e["default"]},function(t,e,r){var n=r(11),i=r(13);t.exports={stringify:n,parse:i}},function(t,e,r){var n=r(12),i={delimiter:"&",arrayPrefixGenerators:{brackets:function(t,e){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t,e){return t}},strictNullHandling:!1,skipNulls:!1,encode:!0};i.stringify=function(t,e,r,o,u,s,a,f){if("function"==typeof a)t=a(e,t);else if(n.isBuffer(t))t=t.toString();else if(t instanceof Date)t=t.toISOString();else if(null===t){if(o)return s?n.encode(e):e;t=""}if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return s?[n.encode(e)+"="+n.encode(t)]:[e+"="+t];var c=[];if("undefined"==typeof t)return c; +var h;if(Array.isArray(a))h=a;else{var p=Object.keys(t);h=f?p.sort(f):p}for(var l=0,_=h.length;_>l;++l){var d=h[l];u&&null===t[d]||(c=Array.isArray(t)?c.concat(i.stringify(t[d],r(e,d),r,o,u,s,a)):c.concat(i.stringify(t[d],e+"["+d+"]",r,o,u,s,a)))}return c},t.exports=function(t,e){e=e||{};var r,n,o="undefined"==typeof e.delimiter?i.delimiter:e.delimiter,u="boolean"==typeof e.strictNullHandling?e.strictNullHandling:i.strictNullHandling,s="boolean"==typeof e.skipNulls?e.skipNulls:i.skipNulls,a="boolean"==typeof e.encode?e.encode:i.encode,f="function"==typeof e.sort?e.sort:null;"function"==typeof e.filter?(n=e.filter,t=n("",t)):Array.isArray(e.filter)&&(r=n=e.filter);var c=[];if("object"!=typeof t||null===t)return"";var h;h=e.arrayFormat in i.arrayPrefixGenerators?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":"indices";var p=i.arrayPrefixGenerators[h];r||(r=Object.keys(t)),f&&r.sort(f);for(var l=0,_=r.length;_>l;++l){var d=r[l];s&&null===t[d]||(c=c.concat(i.stringify(t[d],d,p,u,s,a,n,f)))}return c.join(o)}},function(t,e){var r={};r.hexTable=new Array(256);for(var n=0;256>n;++n)r.hexTable[n]="%"+((16>n?"0":"")+n.toString(16)).toUpperCase();e.arrayToObject=function(t,e){for(var r=e.plainObjects?Object.create(null):{},n=0,i=t.length;i>n;++n)"undefined"!=typeof t[n]&&(r[n]=t[n]);return r},e.merge=function(t,r,n){if(!r)return t;if("object"!=typeof r)return Array.isArray(t)?t.push(r):"object"==typeof t?t[r]=!0:t=[t,r],t;if("object"!=typeof t)return t=[t].concat(r);Array.isArray(t)&&!Array.isArray(r)&&(t=e.arrayToObject(t,n));for(var i=Object.keys(r),o=0,u=i.length;u>o;++o){var s=i[o],a=r[s];Object.prototype.hasOwnProperty.call(t,s)?t[s]=e.merge(t[s],a,n):t[s]=a}return t},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;"string"!=typeof t&&(t=""+t);for(var e="",n=0,i=t.length;i>n;++n){var o=t.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&57>=o||o>=65&&90>=o||o>=97&&122>=o?e+=t[n]:128>o?e+=r.hexTable[o]:2048>o?e+=r.hexTable[192|o>>6]+r.hexTable[128|63&o]:55296>o||o>=57344?e+=r.hexTable[224|o>>12]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o]:(++n,o=65536+((1023&o)<<10|1023&t.charCodeAt(n)),e+=r.hexTable[240|o>>18]+r.hexTable[128|o>>12&63]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o])}return e},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;r=r||[];var n=r.indexOf(t);if(-1!==n)return r[n];if(r.push(t),Array.isArray(t)){for(var i=[],o=0,u=t.length;u>o;++o)"undefined"!=typeof t[o]&&i.push(t[o]);return i}var s=Object.keys(t);for(o=0,u=s.length;u>o;++o){var a=s[o];t[a]=e.compact(t[a],r)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null===t||"undefined"==typeof t?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e,r){var n=r(12),i={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1};i.parseValues=function(t,e){for(var r={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),o=0,u=i.length;u>o;++o){var s=i[o],a=-1===s.indexOf("]=")?s.indexOf("="):s.indexOf("]=")+1;if(-1===a)r[n.decode(s)]="",e.strictNullHandling&&(r[n.decode(s)]=null);else{var f=n.decode(s.slice(0,a)),c=n.decode(s.slice(a+1));Object.prototype.hasOwnProperty.call(r,f)?r[f]=[].concat(r[f]).concat(c):r[f]=c}}return r},i.parseObject=function(t,e,r){if(!t.length)return e;var n,o=t.shift();if("[]"===o)n=[],n=n.concat(i.parseObject(t,e,r));else{n=r.plainObjects?Object.create(null):{};var u="["===o[0]&&"]"===o[o.length-1]?o.slice(1,o.length-1):o,s=parseInt(u,10),a=""+s;!isNaN(s)&&o!==u&&a===u&&s>=0&&r.parseArrays&&s<=r.arrayLimit?(n=[],n[s]=i.parseObject(t,e,r)):n[u]=i.parseObject(t,e,r)}return n},i.parseKeys=function(t,e,r){if(t){r.allowDots&&(t=t.replace(/\.([^\.\[]+)/g,"[$1]"));var n=/^([^\[\]]*)/,o=/(\[[^\[\]]*\])/g,u=n.exec(t),s=[];if(u[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(u[1])&&!r.allowPrototypes)return;s.push(u[1])}for(var a=0;null!==(u=o.exec(t))&&as;++s){var f=u[s],c=i.parseKeys(f,r[f],e);o=n.merge(o,c,e)}return n.compact(o)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e1?n-1:0),o=1;n>o;o++)i[o-1]=arguments[o];r.apply(void 0,[t+":"+e].concat(i))}}var i=(0,a.List)(e.get("errorInterceptors")),u=(0,a.List)(e.get("requestInterceptors")),s=(0,a.List)(e.get("responseInterceptors")),f=e["delete"]("errorInterceptors")["delete"]("requestInterceptors")["delete"]("responseInterceptors");return o(n("request:interceptor"),u,f).then(function(e){return r("request",(0,c["default"])(e)),t((0,c["default"])(e)).then(function(t){return o(n("response:interceptor"),s,(0,a.fromJS)(t),[(0,c["default"])(e)])})}).then(null,function(t){return o(n("error:interceptor"),i,t,[(0,c["default"])(f)]).then(function(t){return Promise.reject(t)})})}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return function(e){var r=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];return u(r?t["new"](t.url()+"/"+e):t["new"](e))}}function o(t){function e(e){return function(){for(var r,n=arguments.length,i=Array(n),o=0;n>o;o++)i[o]=arguments[o];var s=i.shift();return(r=u(t["new"](t.url()+"/"+s)))[e].apply(r,i)}}return(0,a["default"])(t,{custom:i(t),"delete":e("delete"),getAll:t.get,get:e("get"),head:e("head"),patch:e("patch"),put:e("put")})}function u(t){return(0,a["default"])(t,{all:function(e){return o(t["new"](t.url()+"/"+e))},custom:i(t),one:function(e,r){return u(t["new"](t.url()+"/"+e+"/"+r))}})}Object.defineProperty(e,"__esModule",{value:!0}),e.custom=i,e.collection=o,e.member=u;var s=r(3),a=n(s)},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=function(t){return function(e){return e.data&&(e.form=/application\/json/.test(e.headers["Content-Type"])?JSON.stringify(e.data):e.data,delete e.data),e.params&&(e.qs=e.params,delete e.params),new Promise(function(r,n){t(e,function(t,e,i){if(t)throw t;var o=void 0;try{o=JSON.parse(i)}catch(u){o=i}var s={data:o,headers:e.headers,statusCode:e.statusCode};if(e.statusCode>=200&&e.statusCode<300)return r(s);var a=new Error(e.statusMessage);a.response=s,n(a)})})}},t.exports=e["default"]},function(t,e,r){"use strict";function n(t){var e=(0,o.Map)(),r=new i.EventEmitter,u={assign:function(t,r,n){return u.has(t)||u.set(t,(0,o.Map)()),e=e.setIn([t,r],n),u},emit:function(){r.emit.apply(r,arguments),t&&t.emit.apply(t,arguments)},get:function(r){var n=e.get(r);if(u.has(r)&&!o.Iterable.isIterable(n)||!t)return n;if(!u.has(r)&&t)return t.get(r);var i=t.get(r);return i?o.List.isList(i)?i.concat(n):i.mergeDeep(n):n},has:function(t){return e.has(t)},"new":function(){return n(u)},on:r.on.bind(r),once:r.once.bind(r),push:function(t,r){return u.has(t)||u.set(t,(0,o.List)()),e=e.update(t,function(t){return t.push(r)}),u},set:function(t,r){return e=e.set(t,r),u}};return u}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=n;var i=r(18),o=r(6);t.exports=e["default"]},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function u(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,s,a,f;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],u(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];r.apply(this,s)}else if(o(r)){for(i=arguments.length,s=new Array(i-1),a=1;i>a;a++)s[a-1]=arguments[a];for(f=r.slice(),i=f.length,a=0;i>a;a++)f[a].apply(this,s)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,u,s;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],u=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(s=u;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function n(t){this.map={},t instanceof n?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function i(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function o(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function u(t){var e=new FileReader;return e.readAsArrayBuffer(t),o(e)}function s(t){var e=new FileReader;return e.readAsText(t),o(e)}function a(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(_.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(_.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(t){if(!_.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type&&this.headers.set("content-type",this._bodyBlob.type))},_.blob?(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(u)},this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return s(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=i(this);return t?t:Promise.resolve(this._bodyText)},_.formData&&(this.formData=function(){return this.text().then(h)}),this.json=function(){return this.text().then(JSON.parse)},this}function f(t){var e=t.toUpperCase();return d.indexOf(e)>-1?e:t}function c(t,e){e=e||{};var r=e.body;if(c.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new n(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",(e.headers||!this.headers)&&(this.headers=new n(e.headers)),this.method=f(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function h(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function p(t){var e=new n,r=t.getAllResponseHeaders().trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),n=r.shift().trim(),i=r.join(":").trim();e.append(n,i)}),e}function l(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof n?e.headers:new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){n.prototype.append=function(t,n){t=e(t),n=r(n);var i=this.map[t];i||(i=[],this.map[t]=i),i.push(n)},n.prototype["delete"]=function(t){delete this.map[e(t)]},n.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},n.prototype.getAll=function(t){return this.map[e(t)]||[]},n.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},n.prototype.set=function(t,n){this.map[e(t)]=[r(n)]},n.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(n){t.call(e,n,r,this)},this)},this)};var _={blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t},d=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];c.prototype.clone=function(){return new c(this)},a.call(c.prototype),a.call(l.prototype),l.prototype.clone=function(){return new l(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},l.error=function(){var t=new l(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];l.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new l(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=c,t.Response=l,t.fetch=function(t,e){return new Promise(function(r,n){function i(){return"responseURL"in u?u.responseURL:/^X-Request-URL:/m.test(u.getAllResponseHeaders())?u.getResponseHeader("X-Request-URL"):void 0}var o;o=c.prototype.isPrototypeOf(t)&&!e?t:new c(t,e);var u=new XMLHttpRequest;u.onload=function(){var t=1223===u.status?204:u.status;if(100>t||t>599)return void n(new TypeError("Network request failed"));var e={status:t,statusText:u.statusText,headers:p(u),url:i()},o="response"in u?u.response:u.responseText;r(new l(o,e))},u.onerror=function(){n(new TypeError("Network request failed"))},u.open(o.method,o.url,!0),"include"===o.credentials&&(u.withCredentials=!0),"responseType"in u&&_.blob&&(u.responseType="blob"),o.headers.forEach(function(t,e){u.setRequestHeader(e,t)}),u.send("undefined"==typeof o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)}])}); \ No newline at end of file diff --git a/package.json b/package.json index 1d38303..c318dcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "restful.js", - "version": "0.9.3", + "version": "0.9.4", "repository": { "type": "git", "url": "https://github.com/marmelab/restful.js"