diff --git a/octoprint_slicer/static/js/octoprint_slicer.min.js b/octoprint_slicer/static/js/octoprint_slicer.min.js index b2ce78d..d9805b6 100644 --- a/octoprint_slicer/static/js/octoprint_slicer.min.js +++ b/octoprint_slicer/static/js/octoprint_slicer.min.js @@ -12504,13432 +12504,9497 @@ STLBinaryExporter.prototype = { }; -/** Detect free variable `global` from Node.js. */ -var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global && global.Object === Object && global; +/** + * @author Mugen87 / https://github.com/Mugen87 + * + * Ported from: https://github.com/maurizzzio/quickhull3d/ by Mauricio Poppe (https://github.com/maurizzzio) + * + */ -/** Detect free variable `self`. */ -var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self; +var Visible = 0; +var Deleted = 1; -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); +function QuickHull() { -/** Built-in value references. */ -var _Symbol = root.Symbol; + this.tolerance = -1; -/** Used for built-in method references. */ -var objectProto = Object.prototype; + this.faces = []; // the generated faces of the convex hull + this.newFaces = []; // this array holds the faces that are generated within a single iteration -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; + // the vertex lists work as follows: + // + // let 'a' and 'b' be 'Face' instances + // let 'v' be points wrapped as instance of 'Vertex' + // + // [v, v, ..., v, v, v, ...] + // ^ ^ + // | | + // a.outside b.outside + // + this.assigned = new VertexList(); + this.unassigned = new VertexList(); -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString = objectProto.toString; + this.vertices = []; // vertices of the hull (internal representation of given geometry data) +} -/** Built-in value references. */ -var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; +Object.assign(QuickHull.prototype, { -/** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. - */ -function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag$1), - tag = value[symToStringTag$1]; + setFromPoints: function setFromPoints(points) { - try { - value[symToStringTag$1] = undefined; - var unmasked = true; - } catch (e) {} + if (Array.isArray(points) !== true) { - var result = nativeObjectToString.call(value); - if (unmasked) { - if (isOwn) { - value[symToStringTag$1] = tag; - } else { - delete value[symToStringTag$1]; - } - } - return result; -} + console.error('THREE.QuickHull: Points parameter is not an array.'); + } -/** Used for built-in method references. */ -var objectProto$1 = Object.prototype; + if (points.length < 4) { -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var nativeObjectToString$1 = objectProto$1.toString; + console.error('THREE.QuickHull: The algorithm needs at least four points.'); + } -/** - * Converts `value` to a string using `Object.prototype.toString`. - * - * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - */ -function objectToString(value) { - return nativeObjectToString$1.call(value); -} + this.makeEmpty(); -/** `Object#toString` result references. */ -var nullTag = '[object Null]'; -var undefinedTag = '[object Undefined]'; + for (var i = 0, l = points.length; i < l; i++) { -/** Built-in value references. */ -var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; + this.vertices.push(new VertexNode(points[i])); + } -/** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); -} + this.compute(); -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object'; -} + return this; + }, -/** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; + setFromObject: function setFromObject(object) { -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag; -} + var points = []; -/** Used as references for various `Number` constants. */ -var NAN = 0 / 0; + object.updateMatrixWorld(true); -/** - * The base implementation of `_.toNumber` which doesn't ensure correct - * conversions of binary, hexadecimal, or octal string values. - * - * @private - * @param {*} value The value to process. - * @returns {number} Returns the number. - */ -function baseToNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN; - } - return +value; -} + object.traverse(function (node) { -/** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ -function arrayMap(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length, - result = Array(length); + var i, l, point; - while (++index < length) { - result[index] = iteratee(array[index], index, array); - } - return result; -} + var geometry = node.geometry; -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray$1 = Array.isArray; + if (geometry !== undefined) { -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; + if (geometry.isGeometry) { -/** Used to convert symbols to primitives and strings. */ -var symbolProto = _Symbol ? _Symbol.prototype : undefined; -var symbolToString = symbolProto ? symbolProto.toString : undefined; + var vertices = geometry.vertices; -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isArray$1(value)) { - // Recursively convert values (susceptible to call stack limits). - return arrayMap(value, baseToString) + ''; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = value + ''; - return result == '0' && 1 / value == -INFINITY ? '-0' : result; -} + for (i = 0, l = vertices.length; i < l; i++) { -/** - * Creates a function that performs a mathematical operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @param {number} [defaultValue] The value used for `undefined` arguments. - * @returns {Function} Returns the new mathematical operation function. - */ -function createMathOperation(operator, defaultValue) { - return function (value, other) { - var result; - if (value === undefined && other === undefined) { - return defaultValue; - } - if (value !== undefined) { - result = value; - } - if (other !== undefined) { - if (result === undefined) { - return other; - } - if (typeof value == 'string' || typeof other == 'string') { - value = baseToString(value); - other = baseToString(other); - } else { - value = baseToNumber(value); - other = baseToNumber(other); - } - result = operator(value, other); - } - return result; - }; -} + point = vertices[i].clone(); + point.applyMatrix4(node.matrixWorld); -/** - * Adds two numbers. - * - * @static - * @memberOf _ - * @since 3.4.0 - * @category Math - * @param {number} augend The first number in an addition. - * @param {number} addend The second number in an addition. - * @returns {number} Returns the total. - * @example - * - * _.add(6, 4); - * // => 10 - */ -var add$1 = createMathOperation(function (augend, addend) { - return augend + addend; -}, 0); + points.push(point); + } + } else if (geometry.isBufferGeometry) { -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); - return value != null && (type == 'object' || type == 'function'); -} + var attribute = geometry.attributes.position; -/** Used as references for various `Number` constants. */ -var NAN$1 = 0 / 0; + if (attribute !== undefined) { -/** Used to match leading and trailing whitespace. */ -var reTrim = /^\s+|\s+$/g; + for (i = 0, l = attribute.count; i < l; i++) { -/** Used to detect bad signed hexadecimal string values. */ -var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + point = new Vector3(); -/** Used to detect binary string values. */ -var reIsBinary = /^0b[01]+$/i; + point.fromBufferAttribute(attribute, i).applyMatrix4(node.matrixWorld); -/** Used to detect octal string values. */ -var reIsOctal = /^0o[0-7]+$/i; + points.push(point); + } + } + } + } + }); -/** Built-in method references without a dependency on `root`. */ -var freeParseInt = parseInt; + return this.setFromPoints(points); + }, -/** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3.2); - * // => 3.2 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity - * - * _.toNumber('3.2'); - * // => 3.2 - */ -function toNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol(value)) { - return NAN$1; - } - if (isObject(value)) { - var other = typeof value.valueOf == 'function' ? value.valueOf() : value; - value = isObject(other) ? other + '' : other; - } - if (typeof value != 'string') { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ''); - var isBinary = reIsBinary.test(value); - return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN$1 : +value; -} + makeEmpty: function makeEmpty() { -/** Used as references for various `Number` constants. */ -var INFINITY$1 = 1 / 0; -var MAX_INTEGER = 1.7976931348623157e+308; + this.faces = []; + this.vertices = []; -/** - * Converts `value` to a finite number. - * - * @static - * @memberOf _ - * @since 4.12.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted number. - * @example - * - * _.toFinite(3.2); - * // => 3.2 - * - * _.toFinite(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toFinite(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toFinite('3.2'); - * // => 3.2 - */ -function toFinite(value) { - if (!value) { - return value === 0 ? value : 0; - } - value = toNumber(value); - if (value === INFINITY$1 || value === -INFINITY$1) { - var sign = value < 0 ? -1 : 1; - return sign * MAX_INTEGER; - } - return value === value ? value : 0; -} + return this; + }, -/** - * Converts `value` to an integer. - * - * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. - * @example - * - * _.toInteger(3.2); - * // => 3 - * - * _.toInteger(Number.MIN_VALUE); - * // => 0 - * - * _.toInteger(Infinity); - * // => 1.7976931348623157e+308 - * - * _.toInteger('3.2'); - * // => 3 - */ -function toInteger(value) { - var result = toFinite(value), - remainder = result % 1; + // Adds a vertex to the 'assigned' list of vertices and assigns it to the given face - return result === result ? remainder ? result - remainder : result : 0; -} + addVertexToFace: function addVertexToFace(vertex, face) { -/** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; + vertex.face = face; -/** - * The opposite of `_.before`; this method creates a function that invokes - * `func` once it's called `n` or more times. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {number} n The number of calls before `func` is invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => Logs 'done saving!' after the two async saves have completed. - */ -function after(n, func) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - n = toInteger(n); - return function () { - if (--n < 1) { - return func.apply(this, arguments); - } - }; -} + if (face.outside === null) { -/** - * This method returns the first argument it receives. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'a': 1 }; - * - * console.log(_.identity(object) === object); - * // => true - */ -function identity$1(value) { - return value; -} + this.assigned.append(vertex); + } else { -/** `Object#toString` result references. */ -var asyncTag = '[object AsyncFunction]'; -var funcTag = '[object Function]'; -var genTag = '[object GeneratorFunction]'; -var proxyTag = '[object Proxy]'; + this.assigned.insertBefore(face.outside, vertex); + } -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - if (!isObject(value)) { - return false; - } - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 9 which returns 'object' for typed arrays and other constructors. - var tag = baseGetTag(value); - return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; -} + face.outside = vertex; -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; + return this; + }, -/** Used to detect methods masquerading as native. */ -var maskSrcKey = function () { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? 'Symbol(src)_1.' + uid : ''; -}(); + // Removes a vertex from the 'assigned' list of vertices and from the given face -/** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ -function isMasked(func) { - return !!maskSrcKey && maskSrcKey in func; -} + removeVertexFromFace: function removeVertexFromFace(vertex, face) { -/** Used for built-in method references. */ -var funcProto$1 = Function.prototype; + if (vertex === face.outside) { -/** Used to resolve the decompiled source of functions. */ -var funcToString$1 = funcProto$1.toString; + // fix face.outside link -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to convert. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString$1.call(func); - } catch (e) {} - try { - return func + ''; - } catch (e) {} - } - return ''; -} + if (vertex.next !== null && vertex.next.face === face) { -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + // face has at least 2 outside vertices, move the 'outside' reference -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; + face.outside = vertex.next; + } else { -/** Used for built-in method references. */ -var funcProto = Function.prototype; -var objectProto$2 = Object.prototype; + // vertex was the only outside vertex that face had -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; + face.outside = null; + } + } -/** Used to check objects for own properties. */ -var hasOwnProperty$1 = objectProto$2.hasOwnProperty; + this.assigned.remove(vertex); -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); + return this; + }, -/** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ -function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); -} + // Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list -/** - * Gets the value at `key` of `object`. - * - * @private - * @param {Object} [object] The object to query. - * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. - */ -function getValue$1(object, key) { - return object == null ? undefined : object[key]; -} + removeAllVerticesFromFace: function removeAllVerticesFromFace(face) { -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue$1(object, key); - return baseIsNative(value) ? value : undefined; -} + if (face.outside !== null) { -/* Built-in method references that are verified to be native. */ -var WeakMap$1 = getNative(root, 'WeakMap'); + // reference to the first and last vertex of this face -/** Used to store function metadata. */ -var metaMap = WeakMap$1 && new WeakMap$1(); + var start = face.outside; + var end = face.outside; -/** - * The base implementation of `setData` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ -var baseSetData = !metaMap ? identity$1 : function (func, data) { - metaMap.set(func, data); - return func; -}; + while (end.next !== null && end.next.face === face) { -/** Built-in value references. */ -var objectCreate = Object.create; + end = end.next; + } -/** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} proto The object to inherit from. - * @returns {Object} Returns the new object. - */ -var baseCreate = function () { - function object() {} - return function (proto) { - if (!isObject(proto)) { - return {}; - } - if (objectCreate) { - return objectCreate(proto); - } - object.prototype = proto; - var result = new object(); - object.prototype = undefined; - return result; - }; -}(); + this.assigned.removeSubList(start, end); -/** - * Creates a function that produces an instance of `Ctor` regardless of - * whether it was invoked as part of a `new` expression or by `call` or `apply`. - * - * @private - * @param {Function} Ctor The constructor to wrap. - * @returns {Function} Returns the new wrapped function. - */ -function createCtor(Ctor) { - return function () { - // Use a `switch` statement to work with class constructors. See - // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist - // for more details. - var args = arguments; - switch (args.length) { - case 0: - return new Ctor(); - case 1: - return new Ctor(args[0]); - case 2: - return new Ctor(args[0], args[1]); - case 3: - return new Ctor(args[0], args[1], args[2]); - case 4: - return new Ctor(args[0], args[1], args[2], args[3]); - case 5: - return new Ctor(args[0], args[1], args[2], args[3], args[4]); - case 6: - return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); - case 7: - return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - } - var thisBinding = baseCreate(Ctor.prototype), - result = Ctor.apply(thisBinding, args); + // fix references - // Mimic the constructor's `return` behavior. - // See https://es5.github.io/#x13.2.2 for more details. - return isObject(result) ? result : thisBinding; - }; -} + start.prev = end.next = null; + face.outside = null; -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$1 = 1; + return start; + } + }, -/** - * Creates a function that wraps `func` to invoke it with the optional `this` - * binding of `thisArg`. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @returns {Function} Returns the new wrapped function. - */ -function createBind(func, bitmask, thisArg) { - var isBind = bitmask & WRAP_BIND_FLAG$1, - Ctor = createCtor(func); + // Removes all the visible vertices that 'face' is able to see - function wrapper() { - var fn = this && this !== root && this instanceof wrapper ? Ctor : func; - return fn.apply(isBind ? thisArg : this, arguments); - } - return wrapper; -} + deleteFaceVertices: function deleteFaceVertices(face, absorbingFace) { -/** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ -function apply$1(func, thisArg, args) { - switch (args.length) { - case 0: - return func.call(thisArg); - case 1: - return func.call(thisArg, args[0]); - case 2: - return func.call(thisArg, args[0], args[1]); - case 3: - return func.call(thisArg, args[0], args[1], args[2]); - } - return func.apply(thisArg, args); -} + var faceVertices = this.removeAllVerticesFromFace(face); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$1 = Math.max; + if (faceVertices !== undefined) { -/** - * Creates an array that is the composition of partially applied arguments, - * placeholders, and provided arguments into a single array of arguments. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to prepend to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ -function composeArgs(args, partials, holders, isCurried) { - var argsIndex = -1, - argsLength = args.length, - holdersLength = holders.length, - leftIndex = -1, - leftLength = partials.length, - rangeLength = nativeMax$1(argsLength - holdersLength, 0), - result = Array(leftLength + rangeLength), - isUncurried = !isCurried; + if (absorbingFace === undefined) { - while (++leftIndex < leftLength) { - result[leftIndex] = partials[leftIndex]; - } - while (++argsIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[holders[argsIndex]] = args[argsIndex]; - } - } - while (rangeLength--) { - result[leftIndex++] = args[argsIndex++]; - } - return result; -} + // mark the vertices to be reassigned to some other face -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$2 = Math.max; + this.unassigned.appendChain(faceVertices); + } else { -/** - * This function is like `composeArgs` except that the arguments composition - * is tailored for `_.partialRight`. - * - * @private - * @param {Array} args The provided arguments. - * @param {Array} partials The arguments to append to those provided. - * @param {Array} holders The `partials` placeholder indexes. - * @params {boolean} [isCurried] Specify composing for a curried function. - * @returns {Array} Returns the new array of composed arguments. - */ -function composeArgsRight(args, partials, holders, isCurried) { - var argsIndex = -1, - argsLength = args.length, - holdersIndex = -1, - holdersLength = holders.length, - rightIndex = -1, - rightLength = partials.length, - rangeLength = nativeMax$2(argsLength - holdersLength, 0), - result = Array(rangeLength + rightLength), - isUncurried = !isCurried; + // if there's an absorbing face try to assign as many vertices as possible to it - while (++argsIndex < rangeLength) { - result[argsIndex] = args[argsIndex]; - } - var offset = argsIndex; - while (++rightIndex < rightLength) { - result[offset + rightIndex] = partials[rightIndex]; - } - while (++holdersIndex < holdersLength) { - if (isUncurried || argsIndex < argsLength) { - result[offset + holders[holdersIndex]] = args[argsIndex++]; - } - } - return result; -} + var vertex = faceVertices; -/** - * Gets the number of `placeholder` occurrences in `array`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} placeholder The placeholder to search for. - * @returns {number} Returns the placeholder count. - */ -function countHolders(array, placeholder) { - var length = array.length, - result = 0; + do { - while (length--) { - if (array[length] === placeholder) { - ++result; - } - } - return result; -} + // we need to buffer the subsequent vertex at this point because the 'vertex.next' reference + // will be changed by upcoming method calls -/** - * The function whose prototype chain sequence wrappers inherit from. - * - * @private - */ -function baseLodash() { - // No operation performed. -} + var nextVertex = vertex.next; -/** Used as references for the maximum length and index of an array. */ -var MAX_ARRAY_LENGTH = 4294967295; + var distance = absorbingFace.distanceToPoint(vertex.point); -/** - * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. - * - * @private - * @constructor - * @param {*} value The value to wrap. - */ -function LazyWrapper(value) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__dir__ = 1; - this.__filtered__ = false; - this.__iteratees__ = []; - this.__takeCount__ = MAX_ARRAY_LENGTH; - this.__views__ = []; -} + // check if 'vertex' is able to see 'absorbingFace' -// Ensure `LazyWrapper` is an instance of `baseLodash`. -LazyWrapper.prototype = baseCreate(baseLodash.prototype); -LazyWrapper.prototype.constructor = LazyWrapper; + if (distance > this.tolerance) { -/** - * This method returns `undefined`. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Util - * @example - * - * _.times(2, _.noop); - * // => [undefined, undefined] - */ -function noop() { - // No operation performed. -} + this.addVertexToFace(vertex, absorbingFace); + } else { -/** - * Gets metadata for `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {*} Returns the metadata for `func`. - */ -var getData = !metaMap ? noop : function (func) { - return metaMap.get(func); -}; + this.unassigned.append(vertex); + } -/** Used to lookup unminified function names. */ -var realNames = {}; + // now assign next vertex -/** Used for built-in method references. */ -var objectProto$3 = Object.prototype; + vertex = nextVertex; + } while (vertex !== null); + } + } -/** Used to check objects for own properties. */ -var hasOwnProperty$2 = objectProto$3.hasOwnProperty; + return this; + }, -/** - * Gets the name of `func`. - * - * @private - * @param {Function} func The function to query. - * @returns {string} Returns the function name. - */ -function getFuncName(func) { - var result = func.name + '', - array = realNames[result], - length = hasOwnProperty$2.call(realNames, result) ? array.length : 0; + // Reassigns as many vertices as possible from the unassigned list to the new faces - while (length--) { - var data = array[length], - otherFunc = data.func; - if (otherFunc == null || otherFunc == func) { - return data.name; - } - } - return result; -} + resolveUnassignedPoints: function resolveUnassignedPoints(newFaces) { -/** - * The base constructor for creating `lodash` wrapper objects. - * - * @private - * @param {*} value The value to wrap. - * @param {boolean} [chainAll] Enable explicit method chain sequences. - */ -function LodashWrapper(value, chainAll) { - this.__wrapped__ = value; - this.__actions__ = []; - this.__chain__ = !!chainAll; - this.__index__ = 0; - this.__values__ = undefined; -} + if (this.unassigned.isEmpty() === false) { -LodashWrapper.prototype = baseCreate(baseLodash.prototype); -LodashWrapper.prototype.constructor = LodashWrapper; + var vertex = this.unassigned.first(); -/** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ -function copyArray$1(source, array) { - var index = -1, - length = source.length; + do { - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; - } - return array; -} + // buffer 'next' reference, see .deleteFaceVertices() -/** - * Creates a clone of `wrapper`. - * - * @private - * @param {Object} wrapper The wrapper to clone. - * @returns {Object} Returns the cloned wrapper. - */ -function wrapperClone(wrapper) { - if (wrapper instanceof LazyWrapper) { - return wrapper.clone(); - } - var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); - result.__actions__ = copyArray$1(wrapper.__actions__); - result.__index__ = wrapper.__index__; - result.__values__ = wrapper.__values__; - return result; -} + var nextVertex = vertex.next; -/** Used for built-in method references. */ -var objectProto$4 = Object.prototype; + var maxDistance = this.tolerance; -/** Used to check objects for own properties. */ -var hasOwnProperty$3 = objectProto$4.hasOwnProperty; + var maxFace = null; -/** - * Creates a `lodash` object which wraps `value` to enable implicit method - * chain sequences. Methods that operate on and return arrays, collections, - * and functions can be chained together. Methods that retrieve a single value - * or may return a primitive value will automatically end the chain sequence - * and return the unwrapped value. Otherwise, the value must be unwrapped - * with `_#value`. - * - * Explicit chain sequences, which must be unwrapped with `_#value`, may be - * enabled using `_.chain`. - * - * The execution of chained methods is lazy, that is, it's deferred until - * `_#value` is implicitly or explicitly called. - * - * Lazy evaluation allows several methods to support shortcut fusion. - * Shortcut fusion is an optimization to merge iteratee calls; this avoids - * the creation of intermediate arrays and can greatly reduce the number of - * iteratee executions. Sections of a chain sequence qualify for shortcut - * fusion if the section is applied to an array and iteratees accept only - * one argument. The heuristic for whether a section qualifies for shortcut - * fusion is subject to change. - * - * Chaining is supported in custom builds as long as the `_#value` method is - * directly or indirectly included in the build. - * - * In addition to lodash methods, wrappers have `Array` and `String` methods. - * - * The wrapper `Array` methods are: - * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` - * - * The wrapper `String` methods are: - * `replace` and `split` - * - * The wrapper methods that support shortcut fusion are: - * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, - * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, - * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` - * - * The chainable wrapper methods are: - * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, - * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, - * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, - * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, - * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, - * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, - * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, - * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, - * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, - * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, - * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, - * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, - * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, - * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, - * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, - * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, - * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, - * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, - * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, - * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, - * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, - * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, - * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, - * `zipObject`, `zipObjectDeep`, and `zipWith` - * - * The wrapper methods that are **not** chainable by default are: - * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, - * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, - * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, - * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, - * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, - * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, - * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, - * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, - * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, - * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, - * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, - * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, - * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, - * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, - * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, - * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, - * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, - * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, - * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, - * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, - * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, - * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, - * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, - * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, - * `upperFirst`, `value`, and `words` - * - * @name _ - * @constructor - * @category Seq - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var wrapped = _([1, 2, 3]); - * - * // Returns an unwrapped value. - * wrapped.reduce(_.add); - * // => 6 - * - * // Returns a wrapped value. - * var squares = wrapped.map(square); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ -function lodash(value) { - if (isObjectLike(value) && !isArray$1(value) && !(value instanceof LazyWrapper)) { - if (value instanceof LodashWrapper) { - return value; - } - if (hasOwnProperty$3.call(value, '__wrapped__')) { - return wrapperClone(value); - } - } - return new LodashWrapper(value); -} + for (var i = 0; i < newFaces.length; i++) { -// Ensure wrappers are instances of `baseLodash`. -lodash.prototype = baseLodash.prototype; -lodash.prototype.constructor = lodash; + var face = newFaces[i]; -/** - * Checks if `func` has a lazy counterpart. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` has a lazy counterpart, - * else `false`. - */ -function isLaziable(func) { - var funcName = getFuncName(func), - other = lodash[funcName]; + if (face.mark === Visible) { - if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { - return false; - } - if (func === other) { - return true; - } - var data = getData(other); - return !!data && func === data[0]; -} + var distance = face.distanceToPoint(vertex.point); -/** Used to detect hot functions by number of calls within a span of milliseconds. */ -var HOT_COUNT = 800; -var HOT_SPAN = 16; + if (distance > maxDistance) { -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeNow = Date.now; + maxDistance = distance; + maxFace = face; + } -/** - * Creates a function that'll short out and invoke `identity` instead - * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` - * milliseconds. - * - * @private - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new shortable function. - */ -function shortOut(func) { - var count = 0, - lastCalled = 0; + if (maxDistance > 1000 * this.tolerance) break; + } + } - return function () { - var stamp = nativeNow(), - remaining = HOT_SPAN - (stamp - lastCalled); + // 'maxFace' can be null e.g. if there are identical vertices - lastCalled = stamp; - if (remaining > 0) { - if (++count >= HOT_COUNT) { - return arguments[0]; - } - } else { - count = 0; - } - return func.apply(undefined, arguments); - }; -} + if (maxFace !== null) { -/** - * Sets metadata for `func`. - * - * **Note:** If this function becomes hot, i.e. is invoked a lot in a short - * period of time, it will trip its breaker and transition to an identity - * function to avoid garbage collection pauses in V8. See - * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) - * for more details. - * - * @private - * @param {Function} func The function to associate metadata with. - * @param {*} data The metadata. - * @returns {Function} Returns `func`. - */ -var setData = shortOut(baseSetData); + this.addVertexToFace(vertex, maxFace); + } -/** Used to match wrap detail comments. */ -var reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/; -var reSplitDetails = /,? & /; + vertex = nextVertex; + } while (vertex !== null); + } -/** - * Extracts wrapper details from the `source` body comment. - * - * @private - * @param {string} source The source to inspect. - * @returns {Array} Returns the wrapper details. - */ -function getWrapDetails(source) { - var match = source.match(reWrapDetails); - return match ? match[1].split(reSplitDetails) : []; -} + return this; + }, -/** Used to match wrap detail comments. */ -var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/; + // Computes the extremes of a simplex which will be the initial hull -/** - * Inserts wrapper `details` in a comment at the top of the `source` body. - * - * @private - * @param {string} source The source to modify. - * @returns {Array} details The details to insert. - * @returns {string} Returns the modified source. - */ -function insertWrapDetails(source, details) { - var length = details.length; - if (!length) { - return source; - } - var lastIndex = length - 1; - details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; - details = details.join(length > 2 ? ', ' : ' '); - return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); -} + computeExtremes: function computeExtremes() { -/** - * Creates a function that returns `value`. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new constant function. - * @example - * - * var objects = _.times(2, _.constant({ 'a': 1 })); - * - * console.log(objects); - * // => [{ 'a': 1 }, { 'a': 1 }] - * - * console.log(objects[0] === objects[1]); - * // => true - */ -function constant(value) { - return function () { - return value; - }; -} + var min = new Vector3(); + var max = new Vector3(); -var defineProperty$2 = function () { - try { - var func = getNative(Object, 'defineProperty'); - func({}, '', {}); - return func; - } catch (e) {} -}(); + var minVertices = []; + var maxVertices = []; -/** - * The base implementation of `setToString` without support for hot loop shorting. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ -var baseSetToString = !defineProperty$2 ? identity$1 : function (func, string) { - return defineProperty$2(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': constant(string), - 'writable': true - }); -}; + var i, l, j; -/** - * Sets the `toString` method of `func` to return `string`. - * - * @private - * @param {Function} func The function to modify. - * @param {Function} string The `toString` result. - * @returns {Function} Returns `func`. - */ -var setToString = shortOut(baseSetToString); + // initially assume that the first vertex is the min/max -/** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ -function arrayEach(array, iteratee) { - var index = -1, - length = array == null ? 0 : array.length; + for (i = 0; i < 3; i++) { - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } - } - return array; -} + minVertices[i] = maxVertices[i] = this.vertices[0]; + } -/** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); + min.copy(this.vertices[0].point); + max.copy(this.vertices[0].point); - while (fromRight ? index-- : ++index < length) { - if (predicate(array[index], index, array)) { - return index; - } - } - return -1; -} + // compute the min/max vertex on all six directions -/** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ -function baseIsNaN(value) { - return value !== value; -} + for (i = 0, l = this.vertices.length; i < l; i++) { -/** - * A specialized version of `_.indexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function strictIndexOf(array, value, fromIndex) { - var index = fromIndex - 1, - length = array.length; + var vertex = this.vertices[i]; + var point = vertex.point; - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; -} + // update the min coordinates -/** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function baseIndexOf(array, value, fromIndex) { - return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex); -} + for (j = 0; j < 3; j++) { -/** - * A specialized version of `_.includes` for arrays without support for - * specifying an index to search from. - * - * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @returns {boolean} Returns `true` if `target` is found, else `false`. - */ -function arrayIncludes(array, value) { - var length = array == null ? 0 : array.length; - return !!length && baseIndexOf(array, value, 0) > -1; -} + if (point.getComponent(j) < min.getComponent(j)) { -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$4 = 1; -var WRAP_BIND_KEY_FLAG$3 = 2; -var WRAP_CURRY_FLAG$3 = 8; -var WRAP_CURRY_RIGHT_FLAG$2 = 16; -var WRAP_PARTIAL_FLAG$2 = 32; -var WRAP_PARTIAL_RIGHT_FLAG$2 = 64; -var WRAP_ARY_FLAG$2 = 128; -var WRAP_REARG_FLAG = 256; -var WRAP_FLIP_FLAG$1 = 512; + min.setComponent(j, point.getComponent(j)); + minVertices[j] = vertex; + } + } -/** Used to associate wrap methods with their bit flags. */ -var wrapFlags = [['ary', WRAP_ARY_FLAG$2], ['bind', WRAP_BIND_FLAG$4], ['bindKey', WRAP_BIND_KEY_FLAG$3], ['curry', WRAP_CURRY_FLAG$3], ['curryRight', WRAP_CURRY_RIGHT_FLAG$2], ['flip', WRAP_FLIP_FLAG$1], ['partial', WRAP_PARTIAL_FLAG$2], ['partialRight', WRAP_PARTIAL_RIGHT_FLAG$2], ['rearg', WRAP_REARG_FLAG]]; + // update the max coordinates -/** - * Updates wrapper `details` based on `bitmask` flags. - * - * @private - * @returns {Array} details The details to modify. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @returns {Array} Returns `details`. - */ -function updateWrapDetails(details, bitmask) { - arrayEach(wrapFlags, function (pair) { - var value = '_.' + pair[0]; - if (bitmask & pair[1] && !arrayIncludes(details, value)) { - details.push(value); - } - }); - return details.sort(); -} + for (j = 0; j < 3; j++) { -/** - * Sets the `toString` method of `wrapper` to mimic the source of `reference` - * with wrapper details in a comment at the top of the source body. - * - * @private - * @param {Function} wrapper The function to modify. - * @param {Function} reference The reference function. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @returns {Function} Returns `wrapper`. - */ -function setWrapToString(wrapper, reference, bitmask) { - var source = reference + ''; - return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); -} + if (point.getComponent(j) > max.getComponent(j)) { -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$3 = 1; -var WRAP_BIND_KEY_FLAG$2 = 2; -var WRAP_CURRY_BOUND_FLAG = 4; -var WRAP_CURRY_FLAG$2 = 8; -var WRAP_PARTIAL_FLAG$1 = 32; -var WRAP_PARTIAL_RIGHT_FLAG$1 = 64; + max.setComponent(j, point.getComponent(j)); + maxVertices[j] = vertex; + } + } + } -/** - * Creates a function that wraps `func` to continue currying. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {Function} wrapFunc The function to create the `func` wrapper. - * @param {*} placeholder The placeholder value. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to - * the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ -function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { - var isCurry = bitmask & WRAP_CURRY_FLAG$2, - newHolders = isCurry ? holders : undefined, - newHoldersRight = isCurry ? undefined : holders, - newPartials = isCurry ? partials : undefined, - newPartialsRight = isCurry ? undefined : partials; + // use min/max vectors to compute an optimal epsilon - bitmask |= isCurry ? WRAP_PARTIAL_FLAG$1 : WRAP_PARTIAL_RIGHT_FLAG$1; - bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG$1 : WRAP_PARTIAL_FLAG$1); + this.tolerance = 3 * Number.EPSILON * (Math.max(Math.abs(min.x), Math.abs(max.x)) + Math.max(Math.abs(min.y), Math.abs(max.y)) + Math.max(Math.abs(min.z), Math.abs(max.z))); - if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { - bitmask &= ~(WRAP_BIND_FLAG$3 | WRAP_BIND_KEY_FLAG$2); - } - var newData = [func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, newHoldersRight, argPos, ary, arity]; + return { min: minVertices, max: maxVertices }; + }, - var result = wrapFunc.apply(undefined, newData); - if (isLaziable(func)) { - setData(result, newData); - } - result.placeholder = placeholder; - return setWrapToString(result, func, bitmask); -} + // Computes the initial simplex assigning to its faces all the points + // that are candidates to form part of the hull -/** - * Gets the argument placeholder value for `func`. - * - * @private - * @param {Function} func The function to inspect. - * @returns {*} Returns the placeholder value. - */ -function getHolder(func) { - var object = func; - return object.placeholder; -} + computeInitialHull: function () { -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER = 9007199254740991; + var line3, plane, closestPoint; -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; + return function computeInitialHull() { -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length; -} + if (line3 === undefined) { -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin = Math.min; + line3 = new Line3(); + plane = new Plane(); + closestPoint = new Vector3(); + } -/** - * Reorder `array` according to the specified indexes where the element at - * the first index is assigned as the first element, the element at - * the second index is assigned as the second element, and so on. - * - * @private - * @param {Array} array The array to reorder. - * @param {Array} indexes The arranged array indexes. - * @returns {Array} Returns `array`. - */ -function reorder$1(array, indexes) { - var arrLength = array.length, - length = nativeMin(indexes.length, arrLength), - oldArray = copyArray$1(array); + var vertex, + vertices = this.vertices; + var extremes = this.computeExtremes(); + var min = extremes.min; + var max = extremes.max; - while (length--) { - var index = indexes[length]; - array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; - } - return array; -} + var v0, v1, v2, v3; + var i, l, j; -/** Used as the internal argument placeholder. */ -var PLACEHOLDER = '__lodash_placeholder__'; + // 1. Find the two vertices 'v0' and 'v1' with the greatest 1d separation + // (max.x - min.x) + // (max.y - min.y) + // (max.z - min.z) -/** - * Replaces all `placeholder` elements in `array` with an internal placeholder - * and returns an array of their indexes. - * - * @private - * @param {Array} array The array to modify. - * @param {*} placeholder The placeholder to replace. - * @returns {Array} Returns the new array of placeholder indexes. - */ -function replaceHolders(array, placeholder) { - var index = -1, - length = array.length, - resIndex = 0, - result = []; + var distance, + maxDistance = 0; + var index = 0; - while (++index < length) { - var value = array[index]; - if (value === placeholder || value === PLACEHOLDER) { - array[index] = PLACEHOLDER; - result[resIndex++] = index; - } - } - return result; -} + for (i = 0; i < 3; i++) { -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$2 = 1; -var WRAP_BIND_KEY_FLAG$1 = 2; -var WRAP_CURRY_FLAG$1 = 8; -var WRAP_CURRY_RIGHT_FLAG$1 = 16; -var WRAP_ARY_FLAG$1 = 128; -var WRAP_FLIP_FLAG = 512; + distance = max[i].point.getComponent(i) - min[i].point.getComponent(i); -/** - * Creates a function that wraps `func` to invoke it with optional `this` - * binding of `thisArg`, partial application, and currying. - * - * @private - * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to prepend to those provided to - * the new function. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [partialsRight] The arguments to append to those provided - * to the new function. - * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ -function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { - var isAry = bitmask & WRAP_ARY_FLAG$1, - isBind = bitmask & WRAP_BIND_FLAG$2, - isBindKey = bitmask & WRAP_BIND_KEY_FLAG$1, - isCurried = bitmask & (WRAP_CURRY_FLAG$1 | WRAP_CURRY_RIGHT_FLAG$1), - isFlip = bitmask & WRAP_FLIP_FLAG, - Ctor = isBindKey ? undefined : createCtor(func); + if (distance > maxDistance) { - function wrapper() { - var length = arguments.length, - args = Array(length), - index = length; + maxDistance = distance; + index = i; + } + } - while (index--) { - args[index] = arguments[index]; - } - if (isCurried) { - var placeholder = getHolder(wrapper), - holdersCount = countHolders(args, placeholder); - } - if (partials) { - args = composeArgs(args, partials, holders, isCurried); - } - if (partialsRight) { - args = composeArgsRight(args, partialsRight, holdersRight, isCurried); - } - length -= holdersCount; - if (isCurried && length < arity) { - var newHolders = replaceHolders(args, placeholder); - return createRecurry(func, bitmask, createHybrid, wrapper.placeholder, thisArg, args, newHolders, argPos, ary, arity - length); - } - var thisBinding = isBind ? thisArg : this, - fn = isBindKey ? thisBinding[func] : func; + v0 = min[index]; + v1 = max[index]; - length = args.length; - if (argPos) { - args = reorder$1(args, argPos); - } else if (isFlip && length > 1) { - args.reverse(); - } - if (isAry && ary < length) { - args.length = ary; - } - if (this && this !== root && this instanceof wrapper) { - fn = Ctor || createCtor(fn); - } - return fn.apply(thisBinding, args); - } - return wrapper; -} + // 2. The next vertex 'v2' is the one farthest to the line formed by 'v0' and 'v1' -/** - * Creates a function that wraps `func` to enable currying. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {number} arity The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ -function createCurry(func, bitmask, arity) { - var Ctor = createCtor(func); + maxDistance = 0; + line3.set(v0.point, v1.point); - function wrapper() { - var length = arguments.length, - args = Array(length), - index = length, - placeholder = getHolder(wrapper); + for (i = 0, l = this.vertices.length; i < l; i++) { - while (index--) { - args[index] = arguments[index]; - } - var holders = length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder ? [] : replaceHolders(args, placeholder); + vertex = vertices[i]; - length -= holders.length; - if (length < arity) { - return createRecurry(func, bitmask, createHybrid, wrapper.placeholder, undefined, args, holders, undefined, undefined, arity - length); - } - var fn = this && this !== root && this instanceof wrapper ? Ctor : func; - return apply$1(fn, this, args); - } - return wrapper; -} + if (vertex !== v0 && vertex !== v1) { -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$5 = 1; + line3.closestPointToPoint(vertex.point, true, closestPoint); -/** - * Creates a function that wraps `func` to invoke it with the `this` binding - * of `thisArg` and `partials` prepended to the arguments it receives. - * - * @private - * @param {Function} func The function to wrap. - * @param {number} bitmask The bitmask flags. See `createWrap` for more details. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} partials The arguments to prepend to those provided to - * the new function. - * @returns {Function} Returns the new wrapped function. - */ -function createPartial(func, bitmask, thisArg, partials) { - var isBind = bitmask & WRAP_BIND_FLAG$5, - Ctor = createCtor(func); + distance = closestPoint.distanceToSquared(vertex.point); - function wrapper() { - var argsIndex = -1, - argsLength = arguments.length, - leftIndex = -1, - leftLength = partials.length, - args = Array(leftLength + argsLength), - fn = this && this !== root && this instanceof wrapper ? Ctor : func; + if (distance > maxDistance) { - while (++leftIndex < leftLength) { - args[leftIndex] = partials[leftIndex]; - } - while (argsLength--) { - args[leftIndex++] = arguments[++argsIndex]; - } - return apply$1(fn, isBind ? thisArg : this, args); - } - return wrapper; -} + maxDistance = distance; + v2 = vertex; + } + } + } -/** Used as the internal argument placeholder. */ -var PLACEHOLDER$1 = '__lodash_placeholder__'; + // 3. The next vertex 'v3' is the one farthest to the plane 'v0', 'v1', 'v2' -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$6 = 1; -var WRAP_BIND_KEY_FLAG$4 = 2; -var WRAP_CURRY_BOUND_FLAG$1 = 4; -var WRAP_CURRY_FLAG$4 = 8; -var WRAP_ARY_FLAG$3 = 128; -var WRAP_REARG_FLAG$1 = 256; + maxDistance = 0; + plane.setFromCoplanarPoints(v0.point, v1.point, v2.point); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin$1 = Math.min; + for (i = 0, l = this.vertices.length; i < l; i++) { -/** - * Merges the function metadata of `source` into `data`. - * - * Merging metadata reduces the number of wrappers used to invoke a function. - * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` - * may be applied regardless of execution order. Methods like `_.ary` and - * `_.rearg` modify function arguments, making the order in which they are - * executed important, preventing the merging of metadata. However, we make - * an exception for a safe combined case where curried functions have `_.ary` - * and or `_.rearg` applied. - * - * @private - * @param {Array} data The destination metadata. - * @param {Array} source The source metadata. - * @returns {Array} Returns `data`. - */ -function mergeData(data, source) { - var bitmask = data[1], - srcBitmask = source[1], - newBitmask = bitmask | srcBitmask, - isCommon = newBitmask < (WRAP_BIND_FLAG$6 | WRAP_BIND_KEY_FLAG$4 | WRAP_ARY_FLAG$3); + vertex = vertices[i]; - var isCombo = srcBitmask == WRAP_ARY_FLAG$3 && bitmask == WRAP_CURRY_FLAG$4 || srcBitmask == WRAP_ARY_FLAG$3 && bitmask == WRAP_REARG_FLAG$1 && data[7].length <= source[8] || srcBitmask == (WRAP_ARY_FLAG$3 | WRAP_REARG_FLAG$1) && source[7].length <= source[8] && bitmask == WRAP_CURRY_FLAG$4; + if (vertex !== v0 && vertex !== v1 && vertex !== v2) { - // Exit early if metadata can't be merged. - if (!(isCommon || isCombo)) { - return data; - } - // Use source `thisArg` if available. - if (srcBitmask & WRAP_BIND_FLAG$6) { - data[2] = source[2]; - // Set when currying a bound function. - newBitmask |= bitmask & WRAP_BIND_FLAG$6 ? 0 : WRAP_CURRY_BOUND_FLAG$1; - } - // Compose partial arguments. - var value = source[3]; - if (value) { - var partials = data[3]; - data[3] = partials ? composeArgs(partials, value, source[4]) : value; - data[4] = partials ? replaceHolders(data[3], PLACEHOLDER$1) : source[4]; - } - // Compose partial right arguments. - value = source[5]; - if (value) { - partials = data[5]; - data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; - data[6] = partials ? replaceHolders(data[5], PLACEHOLDER$1) : source[6]; - } - // Use source `argPos` if available. - value = source[7]; - if (value) { - data[7] = value; - } - // Use source `ary` if it's smaller. - if (srcBitmask & WRAP_ARY_FLAG$3) { - data[8] = data[8] == null ? source[8] : nativeMin$1(data[8], source[8]); - } - // Use source `arity` if one is not provided. - if (data[9] == null) { - data[9] = source[9]; - } - // Use source `func` and merge bitmasks. - data[0] = source[0]; - data[1] = newBitmask; + distance = Math.abs(plane.distanceToPoint(vertex.point)); - return data; -} + if (distance > maxDistance) { -/** Error message constants. */ -var FUNC_ERROR_TEXT$1 = 'Expected a function'; + maxDistance = distance; + v3 = vertex; + } + } + } -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG = 1; -var WRAP_BIND_KEY_FLAG = 2; -var WRAP_CURRY_FLAG = 8; -var WRAP_CURRY_RIGHT_FLAG = 16; -var WRAP_PARTIAL_FLAG = 32; -var WRAP_PARTIAL_RIGHT_FLAG = 64; + var faces = []; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax = Math.max; + if (plane.distanceToPoint(v3.point) < 0) { -/** - * Creates a function that either curries or invokes `func` with optional - * `this` binding and partially applied arguments. - * - * @private - * @param {Function|string} func The function or method name to wrap. - * @param {number} bitmask The bitmask flags. - * 1 - `_.bind` - * 2 - `_.bindKey` - * 4 - `_.curry` or `_.curryRight` of a bound function - * 8 - `_.curry` - * 16 - `_.curryRight` - * 32 - `_.partial` - * 64 - `_.partialRight` - * 128 - `_.rearg` - * 256 - `_.ary` - * 512 - `_.flip` - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partials] The arguments to be partially applied. - * @param {Array} [holders] The `partials` placeholder indexes. - * @param {Array} [argPos] The argument positions of the new function. - * @param {number} [ary] The arity cap of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new wrapped function. - */ -function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { - var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; - if (!isBindKey && typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$1); - } - var length = partials ? partials.length : 0; - if (!length) { - bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); - partials = holders = undefined; - } - ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); - arity = arity === undefined ? arity : toInteger(arity); - length -= holders ? holders.length : 0; + // the face is not able to see the point so 'plane.normal' is pointing outside the tetrahedron - if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { - var partialsRight = partials, - holdersRight = holders; + faces.push(Face.create(v0, v1, v2), Face.create(v3, v1, v0), Face.create(v3, v2, v1), Face.create(v3, v0, v2)); - partials = holders = undefined; - } - var data = isBindKey ? undefined : getData(func); + // set the twin edge - var newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; + for (i = 0; i < 3; i++) { - if (data) { - mergeData(newData, data); - } - func = newData[0]; - bitmask = newData[1]; - thisArg = newData[2]; - partials = newData[3]; - holders = newData[4]; - arity = newData[9] = newData[9] === undefined ? isBindKey ? 0 : func.length : nativeMax(newData[9] - length, 0); + j = (i + 1) % 3; - if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { - bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); - } - if (!bitmask || bitmask == WRAP_BIND_FLAG) { - var result = createBind(func, bitmask, thisArg); - } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { - result = createCurry(func, bitmask, arity); - } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { - result = createPartial(func, bitmask, thisArg, partials); - } else { - result = createHybrid.apply(undefined, newData); - } - var setter = data ? baseSetData : setData; - return setWrapToString(setter(result, newData), func, bitmask); -} + // join face[ i ] i > 0, with the first face -/** Used to compose bitmasks for function metadata. */ -var WRAP_ARY_FLAG = 128; + faces[i + 1].getEdge(2).setTwin(faces[0].getEdge(j)); -/** - * Creates a function that invokes `func`, with up to `n` arguments, - * ignoring any additional arguments. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @param {number} [n=func.length] The arity cap. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new capped function. - * @example - * - * _.map(['6', '8', '10'], _.ary(parseInt, 1)); - * // => [6, 8, 10] - */ -function ary(func, n, guard) { - n = guard ? undefined : n; - n = func && n == null ? func.length : n; - return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); -} + // join face[ i ] with face[ i + 1 ], 1 <= i <= 3 -/** - * The base implementation of `assignValue` and `assignMergeValue` without - * value checks. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function baseAssignValue(object, key, value) { - if (key == '__proto__' && defineProperty$2) { - defineProperty$2(object, key, { - 'configurable': true, - 'enumerable': true, - 'value': value, - 'writable': true - }); - } else { - object[key] = value; - } -} + faces[i + 1].getEdge(1).setTwin(faces[j + 1].getEdge(0)); + } + } else { -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || value !== value && other !== other; -} + // the face is able to see the point so 'plane.normal' is pointing inside the tetrahedron -/** Used for built-in method references. */ -var objectProto$6 = Object.prototype; + faces.push(Face.create(v0, v2, v1), Face.create(v3, v0, v1), Face.create(v3, v1, v2), Face.create(v3, v2, v0)); -/** Used to check objects for own properties. */ -var hasOwnProperty$5 = objectProto$6.hasOwnProperty; + // set the twin edge -/** - * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignValue(object, key, value) { - var objValue = object[key]; - if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) { - baseAssignValue(object, key, value); - } -} + for (i = 0; i < 3; i++) { -/** - * Copies properties of `source` to `object`. - * - * @private - * @param {Object} source The object to copy properties from. - * @param {Array} props The property identifiers to copy. - * @param {Object} [object={}] The object to copy properties to. - * @param {Function} [customizer] The function to customize copied values. - * @returns {Object} Returns `object`. - */ -function copyObject(source, props, object, customizer) { - var isNew = !object; - object || (object = {}); + j = (i + 1) % 3; - var index = -1, - length = props.length; + // join face[ i ] i > 0, with the first face - while (++index < length) { - var key = props[index]; + faces[i + 1].getEdge(2).setTwin(faces[0].getEdge((3 - i) % 3)); - var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined; + // join face[ i ] with face[ i + 1 ] - if (newValue === undefined) { - newValue = source[key]; - } - if (isNew) { - baseAssignValue(object, key, newValue); - } else { - assignValue(object, key, newValue); - } - } - return object; -} + faces[i + 1].getEdge(0).setTwin(faces[j + 1].getEdge(1)); + } + } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$3 = Math.max; + // the initial hull is the tetrahedron -/** - * A specialized version of `baseRest` which transforms the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @param {Function} transform The rest array transform. - * @returns {Function} Returns the new function. - */ -function overRest(func, start, transform) { - start = nativeMax$3(start === undefined ? func.length - 1 : start, 0); - return function () { - var args = arguments, - index = -1, - length = nativeMax$3(args.length - start, 0), - array = Array(length); + for (i = 0; i < 4; i++) { - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = transform(array); - return apply$1(func, this, otherArgs); - }; -} + this.faces.push(faces[i]); + } -/** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - */ -function baseRest(func, start) { - return setToString(overRest(func, start, identity$1), func + ''); -} + // initial assignment of vertices to the faces of the tetrahedron -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER$1 = 9007199254740991; + for (i = 0, l = vertices.length; i < l; i++) { -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1; -} + vertex = vertices[i]; -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); -} + if (vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3) { -/** - * Checks if the given arguments are from an iteratee call. - * - * @private - * @param {*} value The potential iteratee value argument. - * @param {*} index The potential iteratee index or key argument. - * @param {*} object The potential iteratee object argument. - * @returns {boolean} Returns `true` if the arguments are from an iteratee call, - * else `false`. - */ -function isIterateeCall(value, index, object) { - if (!isObject(object)) { - return false; - } - var type = typeof index === 'undefined' ? 'undefined' : _typeof(index); - if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) { - return eq(object[index], value); - } - return false; -} + maxDistance = this.tolerance; + var maxFace = null; -/** - * Creates a function like `_.assign`. - * - * @private - * @param {Function} assigner The function to assign values. - * @returns {Function} Returns the new assigner function. - */ -function createAssigner(assigner) { - return baseRest(function (object, sources) { - var index = -1, - length = sources.length, - customizer = length > 1 ? sources[length - 1] : undefined, - guard = length > 2 ? sources[2] : undefined; + for (j = 0; j < 4; j++) { - customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined; + distance = this.faces[j].distanceToPoint(vertex.point); - if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? undefined : customizer; - length = 1; - } - object = Object(object); - while (++index < length) { - var source = sources[index]; - if (source) { - assigner(object, source, index, customizer); - } - } - return object; - }); -} + if (distance > maxDistance) { -/** Used for built-in method references. */ -var objectProto$7 = Object.prototype; + maxDistance = distance; + maxFace = this.faces[j]; + } + } -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$7; + if (maxFace !== null) { - return value === proto; -} + this.addVertexToFace(vertex, maxFace); + } + } + } -/** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); + return this; + }; + }(), - while (++index < n) { - result[index] = iteratee(index); - } - return result; -} + // Removes inactive faces -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]'; + reindexFaces: function reindexFaces() { -/** - * The base implementation of `_.isArguments`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - */ -function baseIsArguments(value) { - return isObjectLike(value) && baseGetTag(value) == argsTag; -} + var activeFaces = []; -/** Used for built-in method references. */ -var objectProto$9 = Object.prototype; + for (var i = 0; i < this.faces.length; i++) { -/** Used to check objects for own properties. */ -var hasOwnProperty$7 = objectProto$9.hasOwnProperty; + var face = this.faces[i]; -/** Built-in value references. */ -var propertyIsEnumerable$1 = objectProto$9.propertyIsEnumerable; + if (face.mark === Visible) { -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -var isArguments = baseIsArguments(function () { - return arguments; -}()) ? baseIsArguments : function (value) { - return isObjectLike(value) && hasOwnProperty$7.call(value, 'callee') && !propertyIsEnumerable$1.call(value, 'callee'); -}; + activeFaces.push(face); + } + } -/** - * This method returns `false`. - * - * @static - * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {boolean} Returns `false`. - * @example - * - * _.times(2, _.stubFalse); - * // => [false, false] - */ -function stubFalse() { - return false; -} + this.faces = activeFaces; -/** Detect free variable `exports`. */ -var freeExports = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; + return this; + }, -/** Detect free variable `module`. */ -var freeModule = freeExports && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; + // Finds the next vertex to create faces with the current hull -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; + nextVertexToAdd: function nextVertexToAdd() { -/** Built-in value references. */ -var Buffer = moduleExports ? root.Buffer : undefined; + // if the 'assigned' list of vertices is empty, no vertices are left. return with 'undefined' -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + if (this.assigned.isEmpty() === false) { -/** - * Checks if `value` is a buffer. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. - * @example - * - * _.isBuffer(new Buffer(2)); - * // => true - * - * _.isBuffer(new Uint8Array(2)); - * // => false - */ -var isBuffer = nativeIsBuffer || stubFalse; + var eyeVertex, + maxDistance = 0; -/** `Object#toString` result references. */ -var argsTag$1 = '[object Arguments]'; -var arrayTag = '[object Array]'; -var boolTag = '[object Boolean]'; -var dateTag = '[object Date]'; -var errorTag = '[object Error]'; -var funcTag$1 = '[object Function]'; -var mapTag = '[object Map]'; -var numberTag = '[object Number]'; -var objectTag = '[object Object]'; -var regexpTag = '[object RegExp]'; -var setTag = '[object Set]'; -var stringTag = '[object String]'; -var weakMapTag = '[object WeakMap]'; + // grap the first available face and start with the first visible vertex of that face -var arrayBufferTag = '[object ArrayBuffer]'; -var dataViewTag = '[object DataView]'; -var float32Tag = '[object Float32Array]'; -var float64Tag = '[object Float64Array]'; -var int8Tag = '[object Int8Array]'; -var int16Tag = '[object Int16Array]'; -var int32Tag = '[object Int32Array]'; -var uint8Tag = '[object Uint8Array]'; -var uint8ClampedTag = '[object Uint8ClampedArray]'; -var uint16Tag = '[object Uint16Array]'; -var uint32Tag = '[object Uint32Array]'; + var eyeFace = this.assigned.first().face; + var vertex = eyeFace.outside; -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + // now calculate the farthest vertex that face can see -/** - * The base implementation of `_.isTypedArray` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - */ -function baseIsTypedArray(value) { - return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; -} + do { -/** - * The base implementation of `_.unary` without support for storing metadata. - * - * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - */ -function baseUnary(func) { - return function (value) { - return func(value); - }; -} + var distance = eyeFace.distanceToPoint(vertex.point); -/** Detect free variable `exports`. */ -var freeExports$1 = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; + if (distance > maxDistance) { -/** Detect free variable `module`. */ -var freeModule$1 = freeExports$1 && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; + maxDistance = distance; + eyeVertex = vertex; + } -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + vertex = vertex.next; + } while (vertex !== null && vertex.face === eyeFace); -/** Detect free variable `process` from Node.js. */ -var freeProcess = moduleExports$1 && freeGlobal.process; + return eyeVertex; + } + }, -/** Used to access faster Node.js helpers. */ -var nodeUtil = function () { - try { - return freeProcess && freeProcess.binding && freeProcess.binding('util'); - } catch (e) {} -}(); + // Computes a chain of half edges in CCW order called the 'horizon'. + // For an edge to be part of the horizon it must join a face that can see + // 'eyePoint' and a face that cannot see 'eyePoint'. -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + computeHorizon: function computeHorizon(eyePoint, crossEdge, face, horizon) { -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + // moves face's vertices to the 'unassigned' vertex list -/** Used for built-in method references. */ -var objectProto$8 = Object.prototype; + this.deleteFaceVertices(face); -/** Used to check objects for own properties. */ -var hasOwnProperty$6 = objectProto$8.hasOwnProperty; + face.mark = Deleted; -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -function arrayLikeKeys(value, inherited) { - var isArr = isArray$1(value), - isArg = !isArr && isArguments(value), - isBuff = !isArr && !isArg && isBuffer(value), - isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), - skipIndexes = isArr || isArg || isBuff || isType, - result = skipIndexes ? baseTimes(value.length, String) : [], - length = result.length; + var edge; - for (var key in value) { - if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && ( - // Safari 9 has enumerable `arguments.length` in strict mode. - key == 'length' || - // Node.js 0.10 has enumerable non-index properties on buffers. - isBuff && (key == 'offset' || key == 'parent') || - // PhantomJS 2 has enumerable non-index properties on typed arrays. - isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || - // Skip index properties. - isIndex(key, length)))) { - result.push(key); - } - } - return result; -} + if (crossEdge === null) { -/** - * Creates a unary function that invokes `func` with its argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ -function overArg(func, transform) { - return function (arg) { - return func(transform(arg)); - }; -} + edge = crossEdge = face.getEdge(0); + } else { -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object); + // start from the next edge since 'crossEdge' was already analyzed + // (actually 'crossEdge.twin' was the edge who called this method recursively) -/** Used for built-in method references. */ -var objectProto$10 = Object.prototype; + edge = crossEdge.next; + } -/** Used to check objects for own properties. */ -var hasOwnProperty$8 = objectProto$10.hasOwnProperty; + do { -/** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty$8.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; -} + var twinEdge = edge.twin; + var oppositeFace = twinEdge.face; -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys$1(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); -} + if (oppositeFace.mark === Visible) { -/** Used for built-in method references. */ -var objectProto$5 = Object.prototype; + if (oppositeFace.distanceToPoint(eyePoint) > this.tolerance) { -/** Used to check objects for own properties. */ -var hasOwnProperty$4 = objectProto$5.hasOwnProperty; + // the opposite face can see the vertex, so proceed with next edge -/** - * Assigns own enumerable string keyed properties of source objects to the - * destination object. Source objects are applied from left to right. - * Subsequent sources overwrite property assignments of previous sources. - * - * **Note:** This method mutates `object` and is loosely based on - * [`Object.assign`](https://mdn.io/Object/assign). - * - * @static - * @memberOf _ - * @since 0.10.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.assignIn - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } - * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; - * - * _.assign({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'c': 3 } - */ -var assign$1 = createAssigner(function (object, source) { - if (isPrototype(source) || isArrayLike(source)) { - copyObject(source, keys$1(source), object); - return; - } - for (var key in source) { - if (hasOwnProperty$4.call(source, key)) { - assignValue(object, key, source[key]); - } - } -}); + this.computeHorizon(eyePoint, twinEdge, oppositeFace, horizon); + } else { -/** - * This function is like - * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * except that it includes inherited enumerable properties. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function nativeKeysIn(object) { - var result = []; - if (object != null) { - for (var key in Object(object)) { - result.push(key); - } - } - return result; -} + // the opposite face can't see the vertex, so this edge is part of the horizon -/** Used for built-in method references. */ -var objectProto$11 = Object.prototype; + horizon.push(edge); + } + } -/** Used to check objects for own properties. */ -var hasOwnProperty$9 = objectProto$11.hasOwnProperty; + edge = edge.next; + } while (edge !== crossEdge); -/** - * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeysIn(object) { - if (!isObject(object)) { - return nativeKeysIn(object); - } - var isProto = isPrototype(object), - result = []; + return this; + }, - for (var key in object) { - if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) { - result.push(key); - } - } - return result; -} + // Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order -/** - * Creates an array of the own and inherited enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keysIn(new Foo); - * // => ['a', 'b', 'c'] (iteration order is not guaranteed) - */ -function keysIn$1(object) { - return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); -} + addAdjoiningFace: function addAdjoiningFace(eyeVertex, horizonEdge) { -/** - * This method is like `_.assign` except that it iterates over own and - * inherited source properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extend - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.assign - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * function Bar() { - * this.c = 3; - * } - * - * Foo.prototype.b = 2; - * Bar.prototype.d = 4; - * - * _.assignIn({ 'a': 0 }, new Foo, new Bar); - * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } - */ -var assignIn = createAssigner(function (object, source) { - copyObject(source, keysIn$1(source), object); -}); + // all the half edges are created in ccw order thus the face is always pointing outside the hull -/** - * This method is like `_.assignIn` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias extendWith - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignInWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ -var assignInWith = createAssigner(function (object, source, srcIndex, customizer) { - copyObject(source, keysIn$1(source), object, customizer); -}); + var face = Face.create(eyeVertex, horizonEdge.tail(), horizonEdge.head()); -/** - * This method is like `_.assign` except that it accepts `customizer` - * which is invoked to produce the assigned values. If `customizer` returns - * `undefined`, assignment is handled by the method instead. The `customizer` - * is invoked with five arguments: (objValue, srcValue, key, object, source). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. - * @see _.assignInWith - * @example - * - * function customizer(objValue, srcValue) { - * return _.isUndefined(objValue) ? srcValue : objValue; - * } - * - * var defaults = _.partialRight(_.assignWith, customizer); - * - * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } - */ -var assignWith = createAssigner(function (object, source, srcIndex, customizer) { - copyObject(source, keys$1(source), object, customizer); -}); + this.faces.push(face); -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; -var reIsPlainProp = /^\w*$/; + // join face.getEdge( - 1 ) with the horizon's opposite edge face.getEdge( - 1 ) = face.getEdge( 2 ) -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - if (isArray$1(value)) { - return false; - } - var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); - if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) { - return true; - } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object); -} + face.getEdge(-1).setTwin(horizonEdge.twin); -/* Built-in method references that are verified to be native. */ -var nativeCreate = getNative(Object, 'create'); + return face.getEdge(0); // the half edge whose vertex is the eyeVertex + }, -/** - * Removes all key-value entries from the hash. - * - * @private - * @name clear - * @memberOf Hash - */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; - this.size = 0; -} + // Adds 'horizon.length' faces to the hull, each face will be linked with the + // horizon opposite face and the face on the left/right -/** - * Removes `key` and its value from the hash. - * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(key) { - var result = this.has(key) && delete this.__data__[key]; - this.size -= result ? 1 : 0; - return result; -} + addNewFaces: function addNewFaces(eyeVertex, horizon) { -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; + this.newFaces = []; -/** Used for built-in method references. */ -var objectProto$12 = Object.prototype; + var firstSideEdge = null; + var previousSideEdge = null; -/** Used to check objects for own properties. */ -var hasOwnProperty$10 = objectProto$12.hasOwnProperty; + for (var i = 0; i < horizon.length; i++) { -/** - * Gets the hash value for `key`. - * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty$10.call(data, key) ? data[key] : undefined; -} + var horizonEdge = horizon[i]; -/** Used for built-in method references. */ -var objectProto$13 = Object.prototype; + // returns the right side edge -/** Used to check objects for own properties. */ -var hasOwnProperty$11 = objectProto$13.hasOwnProperty; + var sideEdge = this.addAdjoiningFace(eyeVertex, horizonEdge); -/** - * Checks if a hash value for `key` exists. - * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== undefined : hasOwnProperty$11.call(data, key); -} + if (firstSideEdge === null) { -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; + firstSideEdge = sideEdge; + } else { -/** - * Sets the hash `key` to `value`. - * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. - */ -function hashSet(key, value) { - var data = this.__data__; - this.size += this.has(key) ? 0 : 1; - data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value; - return this; -} + // joins face.getEdge( 1 ) with previousFace.getEdge( 0 ) -/** - * Creates a hash object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Hash(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; + sideEdge.next.setTwin(previousSideEdge); + } - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} + this.newFaces.push(sideEdge.face); + previousSideEdge = sideEdge; + } -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; + // perform final join of new faces -/** - * Removes all key-value entries from the list cache. - * - * @private - * @name clear - * @memberOf ListCache - */ -function listCacheClear() { - this.__data__ = []; - this.size = 0; -} + firstSideEdge.next.setTwin(previousSideEdge); -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } - } - return -1; -} + return this; + }, -/** Used for built-in method references. */ -var arrayProto = Array.prototype; + // Adds a vertex to the hull -/** Built-in value references. */ -var splice = arrayProto.splice; + addVertexToHull: function addVertexToHull(eyeVertex) { -/** - * Removes `key` and its value from the list cache. - * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); + var horizon = []; + var i, face; - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - --this.size; - return true; -} + this.unassigned.clear(); -/** - * Gets the list cache value for `key`. - * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); + // remove 'eyeVertex' from 'eyeVertex.face' so that it can't be added to the 'unassigned' vertex list - return index < 0 ? undefined : data[index][1]; -} + this.removeVertexFromFace(eyeVertex, eyeVertex.face); -/** - * Checks if a list cache value for `key` exists. - * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; -} + this.computeHorizon(eyeVertex.point, null, eyeVertex.face, horizon); -/** - * Sets the list cache `key` to `value`. - * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. - */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); + this.addNewFaces(eyeVertex, horizon); - if (index < 0) { - ++this.size; - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; -} + // reassign 'unassigned' vertices to the new faces -/** - * Creates an list cache object. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function ListCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; + this.resolveUnassignedPoints(this.newFaces); - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} + return this; + }, -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; + cleanup: function cleanup() { -/* Built-in method references that are verified to be native. */ -var Map$1 = getNative(root, 'Map'); + this.assigned.clear(); + this.unassigned.clear(); + this.newFaces = []; -/** - * Removes all key-value entries from the map. - * - * @private - * @name clear - * @memberOf MapCache - */ -function mapCacheClear() { - this.size = 0; - this.__data__ = { - 'hash': new Hash(), - 'map': new (Map$1 || ListCache)(), - 'string': new Hash() - }; -} + return this; + }, -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); - return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null; -} + compute: function compute() { -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; -} + var vertex; -/** - * Removes `key` and its value from the map. - * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function mapCacheDelete(key) { - var result = getMapData(this, key)['delete'](key); - this.size -= result ? 1 : 0; - return result; -} + this.computeInitialHull(); -/** - * Gets the map value for `key`. - * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); -} + // add all available vertices gradually to the hull -/** - * Checks if a map value for `key` exists. - * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. - */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); -} + while ((vertex = this.nextVertexToAdd()) !== undefined) { -/** - * Sets the map `key` to `value`. - * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. - */ -function mapCacheSet(key, value) { - var data = getMapData(this, key), - size = data.size; + this.addVertexToHull(vertex); + } - data.set(key, value); - this.size += data.size == size ? 0 : 1; - return this; -} + this.reindexFaces(); -/** - * Creates a map cache object to store key-value pairs. - * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function MapCache(entries) { - var index = -1, - length = entries == null ? 0 : entries.length; + this.cleanup(); - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } + return this; + } + +}); + +// + +function Face() { + + this.normal = new Vector3(); + this.midpoint = new Vector3(); + this.area = 0; + + this.constant = 0; // signed distance from face to the origin + this.outside = null; // reference to a vertex in a vertex list this face can see + this.mark = Visible; + this.edge = null; } -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; +Object.assign(Face, { -/** Error message constants. */ -var FUNC_ERROR_TEXT$2 = 'Expected a function'; + create: function create(a, b, c) { -/** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) - * method interface of `clear`, `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoized function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] - * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; - */ -function memoize$1(func, resolver) { - if (typeof func != 'function' || resolver != null && typeof resolver != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$2); - } - var memoized = function memoized() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; + var face = new Face(); - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result) || cache; - return result; - }; - memoized.cache = new (memoize$1.Cache || MapCache)(); - return memoized; -} + var e0 = new HalfEdge(a, face); + var e1 = new HalfEdge(b, face); + var e2 = new HalfEdge(c, face); -// Expose `MapCache`. -memoize$1.Cache = MapCache; + // join edges -/** Used as the maximum memoize cache size. */ -var MAX_MEMOIZE_SIZE = 500; + e0.next = e2.prev = e1; + e1.next = e0.prev = e2; + e2.next = e1.prev = e0; -/** - * A specialized version of `_.memoize` which clears the memoized function's - * cache when it exceeds `MAX_MEMOIZE_SIZE`. - * - * @private - * @param {Function} func The function to have its output memoized. - * @returns {Function} Returns the new memoized function. - */ -function memoizeCapped(func) { - var result = memoize$1(func, function (key) { - if (cache.size === MAX_MEMOIZE_SIZE) { - cache.clear(); + // main half edge reference + + face.edge = e0; + + return face.compute(); } - return key; - }); - var cache = result.cache; - return result; -} +}); -/** Used to match property names within property paths. */ -var reLeadingDot = /^\./; -var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; +Object.assign(Face.prototype, { -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; + getEdge: function getEdge(i) { -/** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. - */ -var stringToPath = memoizeCapped(function (string) { - var result = []; - if (reLeadingDot.test(string)) { - result.push(''); - } - string.replace(rePropName, function (match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : number || match); - }); - return result; -}); + var edge = this.edge; -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString$1(value) { - return value == null ? '' : baseToString(value); -} + while (i > 0) { -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @param {Object} [object] The object to query keys on. - * @returns {Array} Returns the cast property path array. - */ -function castPath(value, object) { - if (isArray$1(value)) { - return value; - } - return isKey(value, object) ? [value] : stringToPath(toString$1(value)); -} + edge = edge.next; + i--; + } -/** Used as references for various `Number` constants. */ -var INFINITY$2 = 1 / 0; + while (i < 0) { -/** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ -function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; - } - var result = value + ''; - return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result; -} + edge = edge.prev; + i++; + } -/** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path) { - path = castPath(path, object); + return edge; + }, - var index = 0, - length = path.length; + compute: function () { - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return index && index == length ? object : undefined; -} + var triangle; -/** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 - * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' - */ -function get$2(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; -} + return function compute() { -/** - * The base implementation of `_.at` without support for individual paths. - * - * @private - * @param {Object} object The object to iterate over. - * @param {string[]} paths The property paths to pick. - * @returns {Array} Returns the picked elements. - */ -function baseAt(object, paths) { - var index = -1, - length = paths.length, - result = Array(length), - skip = object == null; + if (triangle === undefined) triangle = new Triangle(); - while (++index < length) { - result[index] = skip ? undefined : get$2(object, paths[index]); - } - return result; -} + var a = this.edge.tail(); + var b = this.edge.head(); + var c = this.edge.next.head(); -/** - * Appends the elements of `values` to `array`. - * - * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to append. - * @returns {Array} Returns `array`. - */ -function arrayPush(array, values) { - var index = -1, - length = values.length, - offset = array.length; + triangle.set(a.point, b.point, c.point); - while (++index < length) { - array[offset + index] = values[index]; - } - return array; -} + triangle.normal(this.normal); + triangle.midpoint(this.midpoint); + this.area = triangle.area(); -/** Built-in value references. */ -var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined; + this.constant = this.normal.dot(this.midpoint); -/** - * Checks if `value` is a flattenable `arguments` object or array. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. - */ -function isFlattenable(value) { - return isArray$1(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]); -} + return this; + }; + }(), -/** - * The base implementation of `_.flatten` with support for restricting flattening. - * - * @private - * @param {Array} array The array to flatten. - * @param {number} depth The maximum recursion depth. - * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. - * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. - * @param {Array} [result=[]] The initial result value. - * @returns {Array} Returns the new flattened array. - */ -function baseFlatten(array, depth, predicate, isStrict, result) { - var index = -1, - length = array.length; + distanceToPoint: function distanceToPoint(point) { - predicate || (predicate = isFlattenable); - result || (result = []); + return this.normal.dot(point) - this.constant; + } - while (++index < length) { - var value = array[index]; - if (depth > 0 && predicate(value)) { - if (depth > 1) { - // Recursively flatten arrays (susceptible to call stack limits). - baseFlatten(value, depth - 1, predicate, isStrict, result); - } else { - arrayPush(result, value); - } - } else if (!isStrict) { - result[result.length] = value; - } - } - return result; -} +}); -/** - * Flattens `array` a single level deep. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example - * - * _.flatten([1, [2, [3, [4]], 5]]); - * // => [1, 2, [3, [4]], 5] - */ -function flatten$1(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, 1) : []; -} +// Entity for a Doubly-Connected Edge List (DCEL). -/** - * A specialized version of `baseRest` which flattens the rest array. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. - */ -function flatRest(func) { - return setToString(overRest(func, undefined, flatten$1), func + ''); +function HalfEdge(vertex, face) { + + this.vertex = vertex; + this.prev = null; + this.next = null; + this.twin = null; + this.face = face; } -/** - * Creates an array of values corresponding to `paths` of `object`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Array} Returns the picked values. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; - * - * _.at(object, ['a[0].b.c', 'a[1]']); - * // => [3, 4] - */ -var at$1 = flatRest(baseAt); +Object.assign(HalfEdge.prototype, { -/** Built-in value references. */ -var getPrototype = overArg(Object.getPrototypeOf, Object); + head: function head() { -/** `Object#toString` result references. */ -var objectTag$1 = '[object Object]'; + return this.vertex; + }, -/** Used for built-in method references. */ -var funcProto$2 = Function.prototype; -var objectProto$14 = Object.prototype; + tail: function tail() { -/** Used to resolve the decompiled source of functions. */ -var funcToString$2 = funcProto$2.toString; + return this.prev ? this.prev.vertex : null; + }, -/** Used to check objects for own properties. */ -var hasOwnProperty$12 = objectProto$14.hasOwnProperty; + length: function length() { -/** Used to infer the `Object` constructor. */ -var objectCtorString = funcToString$2.call(Object); + var head = this.head(); + var tail = this.tail(); -/** - * Checks if `value` is a plain object, that is, an object created by the - * `Object` constructor or one with a `[[Prototype]]` of `null`. - * - * @static - * @memberOf _ - * @since 0.8.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Foo() { - * this.a = 1; - * } - * - * _.isPlainObject(new Foo); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - * - * _.isPlainObject(Object.create(null)); - * // => true - */ -function isPlainObject(value) { - if (!isObjectLike(value) || baseGetTag(value) != objectTag$1) { - return false; - } - var proto = getPrototype(value); - if (proto === null) { - return true; - } - var Ctor = hasOwnProperty$12.call(proto, 'constructor') && proto.constructor; - return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString$2.call(Ctor) == objectCtorString; -} + if (tail !== null) { -/** `Object#toString` result references. */ -var domExcTag = '[object DOMException]'; -var errorTag$1 = '[object Error]'; + return tail.point.distanceTo(head.point); + } -/** - * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, - * `SyntaxError`, `TypeError`, or `URIError` object. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, else `false`. - * @example - * - * _.isError(new Error); - * // => true - * - * _.isError(Error); - * // => false - */ -function isError$1(value) { - if (!isObjectLike(value)) { - return false; - } - var tag = baseGetTag(value); - return tag == errorTag$1 || tag == domExcTag || typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value); -} + return -1; + }, -/** - * Attempts to invoke `func`, returning either the result or the caught error - * object. Any additional arguments are provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {Function} func The function to attempt. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {*} Returns the `func` result or error object. - * @example - * - * // Avoid throwing errors for invalid selectors. - * var elements = _.attempt(function(selector) { - * return document.querySelectorAll(selector); - * }, '>_>'); - * - * if (_.isError(elements)) { - * elements = []; - * } - */ -var attempt = baseRest(function (func, args) { - try { - return apply$1(func, undefined, args); - } catch (e) { - return isError$1(e) ? e : new Error(e); - } -}); + lengthSquared: function lengthSquared() { -/** Error message constants. */ -var FUNC_ERROR_TEXT$3 = 'Expected a function'; + var head = this.head(); + var tail = this.tail(); -/** - * Creates a function that invokes `func`, with the `this` binding and arguments - * of the created function, while it's called less than `n` times. Subsequent - * calls to the created function return the result of the last `func` invocation. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {number} n The number of calls at which `func` is no longer invoked. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * jQuery(element).on('click', _.before(5, addContactToList)); - * // => Allows adding up to 4 contacts to the list. - */ -function before(n, func) { - var result; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$3); - } - n = toInteger(n); - return function () { - if (--n > 0) { - result = func.apply(this, arguments); - } - if (n <= 1) { - func = undefined; - } - return result; - }; -} + if (tail !== null) { -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$7 = 1; -var WRAP_PARTIAL_FLAG$3 = 32; + return tail.point.distanceToSquared(head.point); + } -/** - * Creates a function that invokes `func` with the `this` binding of `thisArg` - * and `partials` prepended to the arguments it receives. - * - * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for partially applied arguments. - * - * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" - * property of bound functions. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to bind. - * @param {*} thisArg The `this` binding of `func`. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * function greet(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * - * var object = { 'user': 'fred' }; - * - * var bound = _.bind(greet, object, 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * // Bound with placeholders. - * var bound = _.bind(greet, object, _, '!'); - * bound('hi'); - * // => 'hi fred!' - */ -var bind$1 = baseRest(function (func, thisArg, partials) { - var bitmask = WRAP_BIND_FLAG$7; - if (partials.length) { - var holders = replaceHolders(partials, getHolder(bind$1)); - bitmask |= WRAP_PARTIAL_FLAG$3; - } - return createWrap(func, bitmask, thisArg, partials, holders); -}); + return -1; + }, -// Assign default placeholders. -bind$1.placeholder = {}; + setTwin: function setTwin(edge) { -/** - * Binds methods of an object to the object itself, overwriting the existing - * method. - * - * **Note:** This method doesn't set the "length" property of bound functions. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...(string|string[])} methodNames The object method names to bind. - * @returns {Object} Returns `object`. - * @example - * - * var view = { - * 'label': 'docs', - * 'click': function() { - * console.log('clicked ' + this.label); - * } - * }; - * - * _.bindAll(view, ['click']); - * jQuery(element).on('click', view.click); - * // => Logs 'clicked docs' when clicked. - */ -var bindAll = flatRest(function (object, methodNames) { - arrayEach(methodNames, function (key) { - key = toKey(key); - baseAssignValue(object, key, bind$1(object[key], object)); - }); - return object; -}); + this.twin = edge; + edge.twin = this; -/** Used to compose bitmasks for function metadata. */ -var WRAP_BIND_FLAG$8 = 1; -var WRAP_BIND_KEY_FLAG$5 = 2; -var WRAP_PARTIAL_FLAG$4 = 32; + return this; + } -/** - * Creates a function that invokes the method at `object[key]` with `partials` - * prepended to the arguments it receives. - * - * This method differs from `_.bind` by allowing bound functions to reference - * methods that may be redefined or don't yet exist. See - * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) - * for more details. - * - * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * @static - * @memberOf _ - * @since 0.10.0 - * @category Function - * @param {Object} object The object to invoke the method on. - * @param {string} key The key of the method. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var object = { - * 'user': 'fred', - * 'greet': function(greeting, punctuation) { - * return greeting + ' ' + this.user + punctuation; - * } - * }; - * - * var bound = _.bindKey(object, 'greet', 'hi'); - * bound('!'); - * // => 'hi fred!' - * - * object.greet = function(greeting, punctuation) { - * return greeting + 'ya ' + this.user + punctuation; - * }; - * - * bound('!'); - * // => 'hiya fred!' - * - * // Bound with placeholders. - * var bound = _.bindKey(object, 'greet', _, '!'); - * bound('hi'); - * // => 'hiya fred!' - */ -var bindKey = baseRest(function (object, key, partials) { - var bitmask = WRAP_BIND_FLAG$8 | WRAP_BIND_KEY_FLAG$5; - if (partials.length) { - var holders = replaceHolders(partials, getHolder(bindKey)); - bitmask |= WRAP_PARTIAL_FLAG$4; - } - return createWrap(key, bitmask, object, partials, holders); }); -// Assign default placeholders. -bindKey.placeholder = {}; - -/** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ -function baseSlice(array, start, end) { - var index = -1, - length = array.length; +// A vertex as a double linked list node. - if (start < 0) { - start = -start > length ? 0 : length + start; - } - end = end > length ? length : end; - if (end < 0) { - end += length; - } - length = start > end ? 0 : end - start >>> 0; - start >>>= 0; +function VertexNode(point) { - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; + this.point = point; + this.prev = null; + this.next = null; + this.face = null; // the face that is able to see this vertex } -/** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ -function castSlice(array, start, end) { - var length = array.length; - end = end === undefined ? length : end; - return !start && end >= length ? array : baseSlice(array, start, end); +// A double linked list that contains vertex nodes. + +function VertexList() { + + this.head = null; + this.tail = null; } -/** Used to compose unicode character classes. */ -var rsAstralRange = '\\ud800-\\udfff'; -var rsComboMarksRange = '\\u0300-\\u036f'; -var reComboHalfMarksRange = '\\ufe20-\\ufe2f'; -var rsComboSymbolsRange = '\\u20d0-\\u20ff'; -var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; -var rsVarRange = '\\ufe0e\\ufe0f'; +Object.assign(VertexList.prototype, { -/** Used to compose unicode capture groups. */ -var rsZWJ = '\\u200d'; + first: function first() { -/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ -var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + return this.head; + }, -/** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ -function hasUnicode(string) { - return reHasUnicode.test(string); -} + last: function last() { -/** - * Converts an ASCII `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function asciiToArray(string) { - return string.split(''); -} + return this.tail; + }, -/** Used to compose unicode character classes. */ -var rsAstralRange$1 = '\\ud800-\\udfff'; -var rsComboMarksRange$1 = '\\u0300-\\u036f'; -var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f'; -var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff'; -var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; -var rsVarRange$1 = '\\ufe0e\\ufe0f'; + clear: function clear() { -/** Used to compose unicode capture groups. */ -var rsAstral = '[' + rsAstralRange$1 + ']'; -var rsCombo = '[' + rsComboRange$1 + ']'; -var rsFitz = '\\ud83c[\\udffb-\\udfff]'; -var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')'; -var rsNonAstral = '[^' + rsAstralRange$1 + ']'; -var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; -var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; -var rsZWJ$1 = '\\u200d'; + this.head = this.tail = null; -/** Used to compose unicode regexes. */ -var reOptMod = rsModifier + '?'; -var rsOptVar = '[' + rsVarRange$1 + ']?'; -var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*'; -var rsSeq = rsOptVar + reOptMod + rsOptJoin; -var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + return this; + }, -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + // Inserts a vertex before the target vertex -/** - * Converts a Unicode `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function unicodeToArray(string) { - return string.match(reUnicode) || []; -} + insertBefore: function insertBefore(target, vertex) { -/** - * Converts `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function stringToArray(string) { - return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string); -} + vertex.prev = target.prev; + vertex.next = target; -/** - * Creates a function like `_.lowerFirst`. - * - * @private - * @param {string} methodName The name of the `String` case method to use. - * @returns {Function} Returns the new case function. - */ -function createCaseFirst(methodName) { - return function (string) { - string = toString$1(string); + if (vertex.prev === null) { - var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined; + this.head = vertex; + } else { - var chr = strSymbols ? strSymbols[0] : string.charAt(0); + vertex.prev.next = vertex; + } - var trailing = strSymbols ? castSlice(strSymbols, 1).join('') : string.slice(1); + target.prev = vertex; - return chr[methodName]() + trailing; - }; -} + return this; + }, -/** - * Converts the first character of `string` to upper case. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.upperFirst('fred'); - * // => 'Fred' - * - * _.upperFirst('FRED'); - * // => 'FRED' - */ -var upperFirst = createCaseFirst('toUpperCase'); + // Inserts a vertex after the target vertex -/** - * Converts the first character of `string` to upper case and the remaining - * to lower case. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to capitalize. - * @returns {string} Returns the capitalized string. - * @example - * - * _.capitalize('FRED'); - * // => 'Fred' - */ -function capitalize(string) { - return upperFirst(toString$1(string).toLowerCase()); -} + insertAfter: function insertAfter(target, vertex) { -/** - * A specialized version of `_.reduce` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ -function arrayReduce(array, iteratee, accumulator, initAccum) { - var index = -1, - length = array == null ? 0 : array.length; + vertex.prev = target; + vertex.next = target.next; - if (initAccum && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; -} + if (vertex.next === null) { -/** - * The base implementation of `_.propertyOf` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @returns {Function} Returns the new accessor function. - */ -function basePropertyOf(object) { - return function (key) { - return object == null ? undefined : object[key]; - }; -} + this.tail = vertex; + } else { -/** Used to map Latin Unicode letters to basic Latin letters. */ -var deburredLetters = { - // Latin-1 Supplement block. - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss', - // Latin Extended-A block. - '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', - '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', - '\u0106': 'C', '\u0108': 'C', '\u010A': 'C', '\u010C': 'C', - '\u0107': 'c', '\u0109': 'c', '\u010B': 'c', '\u010D': 'c', - '\u010E': 'D', '\u0110': 'D', '\u010F': 'd', '\u0111': 'd', - '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011A': 'E', - '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011B': 'e', - '\u011C': 'G', '\u011E': 'G', '\u0120': 'G', '\u0122': 'G', - '\u011D': 'g', '\u011F': 'g', '\u0121': 'g', '\u0123': 'g', - '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', - '\u0128': 'I', '\u012A': 'I', '\u012C': 'I', '\u012E': 'I', '\u0130': 'I', - '\u0129': 'i', '\u012B': 'i', '\u012D': 'i', '\u012F': 'i', '\u0131': 'i', - '\u0134': 'J', '\u0135': 'j', - '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', - '\u0139': 'L', '\u013B': 'L', '\u013D': 'L', '\u013F': 'L', '\u0141': 'L', - '\u013A': 'l', '\u013C': 'l', '\u013E': 'l', '\u0140': 'l', '\u0142': 'l', - '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014A': 'N', - '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014B': 'n', - '\u014C': 'O', '\u014E': 'O', '\u0150': 'O', - '\u014D': 'o', '\u014F': 'o', '\u0151': 'o', - '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', - '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', - '\u015A': 'S', '\u015C': 'S', '\u015E': 'S', '\u0160': 'S', - '\u015B': 's', '\u015D': 's', '\u015F': 's', '\u0161': 's', - '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', - '\u0163': 't', '\u0165': 't', '\u0167': 't', - '\u0168': 'U', '\u016A': 'U', '\u016C': 'U', '\u016E': 'U', '\u0170': 'U', '\u0172': 'U', - '\u0169': 'u', '\u016B': 'u', '\u016D': 'u', '\u016F': 'u', '\u0171': 'u', '\u0173': 'u', - '\u0174': 'W', '\u0175': 'w', - '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', - '\u0179': 'Z', '\u017B': 'Z', '\u017D': 'Z', - '\u017A': 'z', '\u017C': 'z', '\u017E': 'z', - '\u0132': 'IJ', '\u0133': 'ij', - '\u0152': 'Oe', '\u0153': 'oe', - '\u0149': "'n", '\u017F': 's' -}; + vertex.next.prev = vertex; + } -/** - * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A - * letters to basic Latin letters. - * - * @private - * @param {string} letter The matched letter to deburr. - * @returns {string} Returns the deburred letter. - */ -var deburrLetter = basePropertyOf(deburredLetters); + target.next = vertex; -/** Used to match Latin Unicode letters (excluding mathematical operators). */ -var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + return this; + }, -/** Used to compose unicode character classes. */ -var rsComboMarksRange$2 = '\\u0300-\\u036f'; -var reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f'; -var rsComboSymbolsRange$2 = '\\u20d0-\\u20ff'; -var rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2; + // Appends a vertex to the end of the linked list -/** Used to compose unicode capture groups. */ -var rsCombo$1 = '[' + rsComboRange$2 + ']'; + append: function append(vertex) { -/** - * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and - * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). - */ -var reComboMark = RegExp(rsCombo$1, 'g'); + if (this.head === null) { -/** - * Deburrs `string` by converting - * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) - * letters to basic Latin letters and removing - * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to deburr. - * @returns {string} Returns the deburred string. - * @example - * - * _.deburr('déjà vu'); - * // => 'deja vu' - */ -function deburr(string) { - string = toString$1(string); - return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); -} + this.head = vertex; + } else { -/** Used to match words composed of alphanumeric characters. */ -var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + this.tail.next = vertex; + } -/** - * Splits an ASCII `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ -function asciiWords(string) { - return string.match(reAsciiWord) || []; -} + vertex.prev = this.tail; + vertex.next = null; // the tail has no subsequent vertex -/** Used to detect strings that need a more robust regexp to match words. */ -var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + this.tail = vertex; -/** - * Checks if `string` contains a word composed of Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a word is found, else `false`. - */ -function hasUnicodeWord(string) { - return reHasUnicodeWord.test(string); -} + return this; + }, -/** Used to compose unicode character classes. */ -var rsAstralRange$2 = '\\ud800-\\udfff'; -var rsComboMarksRange$3 = '\\u0300-\\u036f'; -var reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f'; -var rsComboSymbolsRange$3 = '\\u20d0-\\u20ff'; -var rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3; -var rsDingbatRange = '\\u2700-\\u27bf'; -var rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff'; -var rsMathOpRange = '\\xac\\xb1\\xd7\\xf7'; -var rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf'; -var rsPunctuationRange = '\\u2000-\\u206f'; -var rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000'; -var rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde'; -var rsVarRange$2 = '\\ufe0e\\ufe0f'; -var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; + // Appends a chain of vertices where 'vertex' is the head. -/** Used to compose unicode capture groups. */ -var rsApos$1 = '[\'\u2019]'; -var rsBreak = '[' + rsBreakRange + ']'; -var rsCombo$2 = '[' + rsComboRange$3 + ']'; -var rsDigits = '\\d+'; -var rsDingbat = '[' + rsDingbatRange + ']'; -var rsLower = '[' + rsLowerRange + ']'; -var rsMisc = '[^' + rsAstralRange$2 + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']'; -var rsFitz$1 = '\\ud83c[\\udffb-\\udfff]'; -var rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')'; -var rsNonAstral$1 = '[^' + rsAstralRange$2 + ']'; -var rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}'; -var rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]'; -var rsUpper = '[' + rsUpperRange + ']'; -var rsZWJ$2 = '\\u200d'; + appendChain: function appendChain(vertex) { -/** Used to compose unicode regexes. */ -var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')'; -var rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')'; -var rsOptContrLower = '(?:' + rsApos$1 + '(?:d|ll|m|re|s|t|ve))?'; -var rsOptContrUpper = '(?:' + rsApos$1 + '(?:D|LL|M|RE|S|T|VE))?'; -var reOptMod$1 = rsModifier$1 + '?'; -var rsOptVar$1 = '[' + rsVarRange$2 + ']?'; -var rsOptJoin$1 = '(?:' + rsZWJ$2 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*'; -var rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)'; -var rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)'; -var rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1; -var rsEmoji = '(?:' + [rsDingbat, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsSeq$1; + if (this.head === null) { -/** Used to match complex or compound words. */ -var reUnicodeWord = RegExp([rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, rsUpper + '+' + rsOptContrUpper, rsOrdUpper, rsOrdLower, rsDigits, rsEmoji].join('|'), 'g'); + this.head = vertex; + } else { -/** - * Splits a Unicode `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ -function unicodeWords(string) { - return string.match(reUnicodeWord) || []; -} + this.tail.next = vertex; + } -/** - * Splits `string` into an array of its words. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {RegExp|string} [pattern] The pattern to match words. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the words of `string`. - * @example - * - * _.words('fred, barney, & pebbles'); - * // => ['fred', 'barney', 'pebbles'] - * - * _.words('fred, barney, & pebbles', /[^, ]+/g); - * // => ['fred', 'barney', '&', 'pebbles'] - */ -function words(string, pattern, guard) { - string = toString$1(string); - pattern = guard ? undefined : pattern; + vertex.prev = this.tail; - if (pattern === undefined) { - return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); + // ensure that the 'tail' reference points to the last vertex of the chain + + while (vertex.next !== null) { + + vertex = vertex.next; + } + + this.tail = vertex; + + return this; + }, + + // Removes a vertex from the linked list + + remove: function remove(vertex) { + + if (vertex.prev === null) { + + this.head = vertex.next; + } else { + + vertex.prev.next = vertex.next; + } + + if (vertex.next === null) { + + this.tail = vertex.prev; + } else { + + vertex.next.prev = vertex.prev; + } + + return this; + }, + + // Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b + + removeSubList: function removeSubList(a, b) { + + if (a.prev === null) { + + this.head = b.next; + } else { + + a.prev.next = b.next; + } + + if (b.next === null) { + + this.tail = a.prev; + } else { + + b.next.prev = a.prev; + } + + return this; + }, + + isEmpty: function isEmpty() { + + return this.head === null; + } + +}); + +/** + * @author Mugen87 / https://github.com/Mugen87 + */ + +// ConvexGeometry + +function ConvexGeometry(points) { + + Geometry.call(this); + + this.type = 'ConvexGeometry'; + + this.fromBufferGeometry(new ConvexBufferGeometry(points)); + this.mergeVertices(); +} + +ConvexGeometry.prototype = Object.create(Geometry.prototype); +ConvexGeometry.prototype.constructor = ConvexGeometry; + +// ConvexBufferGeometry + +function ConvexBufferGeometry(points) { + + BufferGeometry.call(this); + + this.type = 'ConvexBufferGeometry'; + + // buffers + + var vertices = []; + var normals = []; + + // execute QuickHull + + var quickHull = new QuickHull().setFromPoints(points); + + // generate vertices and normals + + var faces = quickHull.faces; + + for (var i = 0; i < faces.length; i++) { + + var face = faces[i]; + var edge = face.edge; + + // we move along a doubly-connected edge list to access all face points (see HalfEdge docs) + + do { + + var point = edge.head().point; + + vertices.push(point.x, point.y, point.z); + normals.push(face.normal.x, face.normal.y, face.normal.z); + + edge = edge.next; + } while (edge !== face.edge); + } + + // build geometry + + this.addAttribute('position', new Float32BufferAttribute(vertices, 3)); + this.addAttribute('normal', new Float32BufferAttribute(normals, 3)); +} + +ConvexBufferGeometry.prototype = Object.create(BufferGeometry.prototype); +ConvexBufferGeometry.prototype.constructor = ConvexBufferGeometry; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** Built-in value references. */ +var _Symbol = root.Symbol; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } } - return string.match(pattern) || []; + return result; } -/** Used to compose unicode capture groups. */ -var rsApos = '[\'\u2019]'; +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; -/** Used to match apostrophes. */ -var reApos = RegExp(rsApos, 'g'); +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$1.toString; /** - * Creates a function like `_.camelCase`. + * Converts `value` to a string using `Object.prototype.toString`. * * @private - * @param {Function} callback The function to combine each word. - * @returns {Function} Returns the new compounder function. + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. */ -function createCompounder(callback) { - return function (string) { - return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); - }; +function objectToString(value) { + return nativeObjectToString$1.call(value); +} + +/** `Object#toString` result references. */ +var nullTag = '[object Null]'; +var undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value); } /** - * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the camel cased string. + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * - * _.camelCase('Foo Bar'); - * // => 'fooBar' + * _.isObjectLike({}); + * // => true * - * _.camelCase('--foo-bar--'); - * // => 'fooBar' + * _.isObjectLike([1, 2, 3]); + * // => true * - * _.camelCase('__FOO_BAR__'); - * // => 'fooBar' + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false */ -var camelCase = createCompounder(function (result, word, index) { - word = word.toLowerCase(); - return result + (index ? capitalize(word) : word); -}); +function isObjectLike(value) { + return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object'; +} + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; /** - * Casts `value` as an array if it's not one. + * Checks if `value` is classified as a `Symbol` primitive or object. * * @static * @memberOf _ - * @since 4.4.0 + * @since 4.0.0 * @category Lang - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast array. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. * @example * - * _.castArray(1); - * // => [1] - * - * _.castArray({ 'a': 1 }); - * // => [{ 'a': 1 }] - * - * _.castArray('abc'); - * // => ['abc'] - * - * _.castArray(null); - * // => [null] - * - * _.castArray(undefined); - * // => [undefined] - * - * _.castArray(); - * // => [] - * - * var array = [1, 2, 3]; - * console.log(_.castArray(array) === array); + * _.isSymbol(Symbol.iterator); * // => true + * + * _.isSymbol('abc'); + * // => false */ -function castArray() { - if (!arguments.length) { - return []; - } - var value = arguments[0]; - return isArray$1(value) ? value : [value]; +function isSymbol(value) { + return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag; } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin$2 = Math.min; +/** Used as references for various `Number` constants. */ +var NAN = 0 / 0; /** - * Creates a function like `_.round`. - * + * The base implementation of `_.toNumber` which doesn't ensure correct + * conversions of binary, hexadecimal, or octal string values. + * * @private - * @param {string} methodName The name of the `Math` method to use when rounding. - * @returns {Function} Returns the new round function. + * @param {*} value The value to process. + * @returns {number} Returns the number. */ -function createRound(methodName) { - var func = Math[methodName]; - return function (number, precision) { - number = toNumber(number); - precision = precision == null ? 0 : nativeMin$2(toInteger(precision), 292); - if (precision) { - // Shift with exponential notation to avoid floating-point issues. - // See [MDN](https://mdn.io/round#Examples) for more details. - var pair = (toString$1(number) + 'e').split('e'), - value = func(pair[0] + 'e' + (+pair[1] + precision)); - - pair = (toString$1(value) + 'e').split('e'); - return +(pair[0] + 'e' + (+pair[1] - precision)); - } - return func(number); - }; +function baseToNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN; + } + return +value; } /** - * Computes `number` rounded up to `precision`. - * - * @static - * @memberOf _ - * @since 3.10.0 - * @category Math - * @param {number} number The number to round up. - * @param {number} [precision=0] The precision to round up to. - * @returns {number} Returns the rounded up number. - * @example - * - * _.ceil(4.006); - * // => 5 - * - * _.ceil(6.004, 2); - * // => 6.01 + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. * - * _.ceil(6040, -2); - * // => 6100 + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. */ -var ceil$1 = createRound('ceil'); +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} /** - * Creates a `lodash` wrapper instance that wraps `value` with explicit method - * chain sequences enabled. The result of such sequences must be unwrapped - * with `_#value`. + * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ - * @since 1.3.0 - * @category Seq - * @param {*} value The value to wrap. - * @returns {Object} Returns the new `lodash` wrapper instance. + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'pebbles', 'age': 1 } - * ]; + * _.isArray([1, 2, 3]); + * // => true * - * var youngest = _ - * .chain(users) - * .sortBy('age') - * .map(function(o) { - * return o.user + ' is ' + o.age; - * }) - * .head() - * .value(); - * // => 'pebbles is 1' + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false */ -function chain(value) { - var result = lodash(value); - result.__chain__ = true; - return result; -} +var isArray$1 = Array.isArray; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil = Math.ceil; -var nativeMax$4 = Math.max; +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = _Symbol ? _Symbol.prototype : undefined; +var symbolToString = symbolProto ? symbolProto.toString : undefined; /** - * Creates an array of elements split into groups the length of `size`. - * If `array` can't be split evenly, the final chunk will be the remaining - * elements. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to process. - * @param {number} [size=1] The length of each chunk - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the new array of chunks. - * @example - * - * _.chunk(['a', 'b', 'c', 'd'], 2); - * // => [['a', 'b'], ['c', 'd']] + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. * - * _.chunk(['a', 'b', 'c', 'd'], 3); - * // => [['a', 'b', 'c'], ['d']] + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. */ -function chunk(array, size, guard) { - if (guard ? isIterateeCall(array, size, guard) : size === undefined) { - size = 1; - } else { - size = nativeMax$4(toInteger(size), 0); +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; } - var length = array == null ? 0 : array.length; - if (!length || size < 1) { - return []; + if (isArray$1(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; } - var index = 0, - resIndex = 0, - result = Array(nativeCeil(length / size)); - - while (index < length) { - result[resIndex++] = baseSlice(array, index, index += size); + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; } - return result; + var result = value + ''; + return result == '0' && 1 / value == -INFINITY ? '-0' : result; } /** - * The base implementation of `_.clamp` which doesn't coerce arguments. + * Creates a function that performs a mathematical operation on two values. * * @private - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. + * @param {Function} operator The function to perform the operation. + * @param {number} [defaultValue] The value used for `undefined` arguments. + * @returns {Function} Returns the new mathematical operation function. */ -function baseClamp(number, lower, upper) { - if (number === number) { - if (upper !== undefined) { - number = number <= upper ? number : upper; +function createMathOperation(operator, defaultValue) { + return function (value, other) { + var result; + if (value === undefined && other === undefined) { + return defaultValue; } - if (lower !== undefined) { - number = number >= lower ? number : lower; + if (value !== undefined) { + result = value; } - } - return number; + if (other !== undefined) { + if (result === undefined) { + return other; + } + if (typeof value == 'string' || typeof other == 'string') { + value = baseToString(value); + other = baseToString(other); + } else { + value = baseToNumber(value); + other = baseToNumber(other); + } + result = operator(value, other); + } + return result; + }; } /** - * Clamps `number` within the inclusive `lower` and `upper` bounds. + * Adds two numbers. * * @static * @memberOf _ - * @since 4.0.0 - * @category Number - * @param {number} number The number to clamp. - * @param {number} [lower] The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the clamped number. + * @since 3.4.0 + * @category Math + * @param {number} augend The first number in an addition. + * @param {number} addend The second number in an addition. + * @returns {number} Returns the total. * @example * - * _.clamp(-10, -5, 5); - * // => -5 - * - * _.clamp(10, -5, 5); - * // => 5 + * _.add(6, 4); + * // => 10 */ -function clamp$1(number, lower, upper) { - if (upper === undefined) { - upper = lower; - lower = undefined; - } - if (upper !== undefined) { - upper = toNumber(upper); - upper = upper === upper ? upper : 0; - } - if (lower !== undefined) { - lower = toNumber(lower); - lower = lower === lower ? lower : 0; - } - return baseClamp(toNumber(number), lower, upper); -} +var add$1 = createMathOperation(function (augend, addend) { + return augend + addend; +}, 0); /** - * Removes all key-value entries from the stack. + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * - * @private - * @name clear - * @memberOf Stack - */ -function stackClear() { - this.__data__ = new ListCache(); - this.size = 0; -} - -/** - * Removes `key` and its value from the stack. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function stackDelete(key) { - var data = this.__data__, - result = data['delete'](key); - - this.size = data.size; - return result; -} - -/** - * Gets the stack value for `key`. + * _.isObject({}); + * // => true * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false */ -function stackGet(key) { - return this.__data__.get(key); +function isObject(value) { + var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); + return value != null && (type == 'object' || type == 'function'); } +/** Used as references for various `Number` constants. */ +var NAN$1 = 0 / 0; + +/** Used to match leading and trailing whitespace. */ +var reTrim = /^\s+|\s+$/g; + +/** Used to detect bad signed hexadecimal string values. */ +var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; + +/** Used to detect binary string values. */ +var reIsBinary = /^0b[01]+$/i; + +/** Used to detect octal string values. */ +var reIsOctal = /^0o[0-7]+$/i; + +/** Built-in method references without a dependency on `root`. */ +var freeParseInt = parseInt; + /** - * Checks if a stack value for `key` exists. + * Converts `value` to a number. * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {number} Returns the number. + * @example + * + * _.toNumber(3.2); + * // => 3.2 + * + * _.toNumber(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toNumber(Infinity); + * // => Infinity + * + * _.toNumber('3.2'); + * // => 3.2 */ -function stackHas(key) { - return this.__data__.has(key); +function toNumber(value) { + if (typeof value == 'number') { + return value; + } + if (isSymbol(value)) { + return NAN$1; + } + if (isObject(value)) { + var other = typeof value.valueOf == 'function' ? value.valueOf() : value; + value = isObject(other) ? other + '' : other; + } + if (typeof value != 'string') { + return value === 0 ? value : +value; + } + value = value.replace(reTrim, ''); + var isBinary = reIsBinary.test(value); + return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN$1 : +value; } -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; +/** Used as references for various `Number` constants. */ +var INFINITY$1 = 1 / 0; +var MAX_INTEGER = 1.7976931348623157e+308; /** - * Sets the stack `key` to `value`. + * Converts `value` to a finite number. * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. + * @static + * @memberOf _ + * @since 4.12.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted number. + * @example + * + * _.toFinite(3.2); + * // => 3.2 + * + * _.toFinite(Number.MIN_VALUE); + * // => 5e-324 + * + * _.toFinite(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toFinite('3.2'); + * // => 3.2 */ -function stackSet(key, value) { - var data = this.__data__; - if (data instanceof ListCache) { - var pairs = data.__data__; - if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) { - pairs.push([key, value]); - this.size = ++data.size; - return this; - } - data = this.__data__ = new MapCache(pairs); +function toFinite(value) { + if (!value) { + return value === 0 ? value : 0; } - data.set(key, value); - this.size = data.size; - return this; + value = toNumber(value); + if (value === INFINITY$1 || value === -INFINITY$1) { + var sign = value < 0 ? -1 : 1; + return sign * MAX_INTEGER; + } + return value === value ? value : 0; } /** - * Creates a stack cache object to store key-value pairs. + * Converts `value` to an integer. * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. + * **Note:** This method is loosely based on + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. + * @example + * + * _.toInteger(3.2); + * // => 3 + * + * _.toInteger(Number.MIN_VALUE); + * // => 0 + * + * _.toInteger(Infinity); + * // => 1.7976931348623157e+308 + * + * _.toInteger('3.2'); + * // => 3 */ -function Stack(entries) { - var data = this.__data__ = new ListCache(entries); - this.size = data.size; +function toInteger(value) { + var result = toFinite(value), + remainder = result % 1; + + return result === result ? remainder ? result - remainder : result : 0; } -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; +/** Error message constants. */ +var FUNC_ERROR_TEXT = 'Expected a function'; /** - * The base implementation of `_.assign` without support for multiple sources - * or `customizer` functions. + * The opposite of `_.before`; this method creates a function that invokes + * `func` once it's called `n` or more times. * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {number} n The number of calls before `func` is invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * var saves = ['profile', 'settings']; + * + * var done = _.after(saves.length, function() { + * console.log('done saving!'); + * }); + * + * _.forEach(saves, function(type) { + * asyncSave({ 'type': type, 'complete': done }); + * }); + * // => Logs 'done saving!' after the two async saves have completed. */ -function baseAssign(object, source) { - return object && copyObject(source, keys$1(source), object); +function after(n, func) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + n = toInteger(n); + return function () { + if (--n < 1) { + return func.apply(this, arguments); + } + }; } /** - * The base implementation of `_.assignIn` without support for multiple sources - * or `customizer` functions. + * This method returns the first argument it receives. * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @returns {Object} Returns `object`. - */ -function baseAssignIn(object, source) { - return object && copyObject(source, keysIn$1(source), object); -} - -/** Detect free variable `exports`. */ -var freeExports$2 = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule$2 = freeExports$2 && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2; - -/** Built-in value references. */ -var Buffer$1 = moduleExports$2 ? root.Buffer : undefined; -var allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined; - -/** - * Creates a clone of `buffer`. + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example * - * @private - * @param {Buffer} buffer The buffer to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Buffer} Returns the cloned buffer. - */ -function cloneBuffer(buffer, isDeep) { - if (isDeep) { - return buffer.slice(); - } - var length = buffer.length, - result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); - - buffer.copy(result); - return result; -} - -/** - * A specialized version of `_.filter` for arrays without support for - * iteratee shorthands. + * var object = { 'a': 1 }; * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. + * console.log(_.identity(object) === object); + * // => true */ -function arrayFilter(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result[resIndex++] = value; - } - } - return result; +function identity$1(value) { + return value; } +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]'; +var funcTag = '[object Function]'; +var genTag = '[object GeneratorFunction]'; +var proxyTag = '[object Proxy]'; + /** - * This method returns a new empty array. + * Checks if `value` is classified as a `Function` object. * * @static * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {Array} Returns the new empty array. + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. * @example * - * var arrays = _.times(2, _.stubArray); - * - * console.log(arrays); - * // => [[], []] + * _.isFunction(_); + * // => true * - * console.log(arrays[0] === arrays[1]); + * _.isFunction(/abc/); * // => false */ -function stubArray() { - return []; +function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } -/** Used for built-in method references. */ -var objectProto$15 = Object.prototype; - -/** Built-in value references. */ -var propertyIsEnumerable$2 = objectProto$15.propertyIsEnumerable; +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetSymbols = Object.getOwnPropertySymbols; +/** Used to detect methods masquerading as native. */ +var maskSrcKey = function () { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? 'Symbol(src)_1.' + uid : ''; +}(); /** - * Creates an array of the own enumerable symbols of `object`. + * Checks if `func` has its source masked. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ -var getSymbols = !nativeGetSymbols ? stubArray : function (object) { - if (object == null) { - return []; - } - object = Object(object); - return arrayFilter(nativeGetSymbols(object), function (symbol) { - return propertyIsEnumerable$2.call(object, symbol); - }); -}; +function isMasked(func) { + return !!maskSrcKey && maskSrcKey in func; +} + +/** Used for built-in method references. */ +var funcProto$1 = Function.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$1 = funcProto$1.toString; /** - * Copies own symbols of `source` to `object`. + * Converts `func` to its source code. * * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. + * @param {Function} func The function to convert. + * @returns {string} Returns the source code. */ -function copySymbols(source, object) { - return copyObject(source, getSymbols(source), object); +function toSource(func) { + if (func != null) { + try { + return funcToString$1.call(func); + } catch (e) {} + try { + return func + ''; + } catch (e) {} + } + return ''; } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeGetSymbols$1 = Object.getOwnPropertySymbols; +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; + +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; + +/** Used for built-in method references. */ +var funcProto = Function.prototype; +var objectProto$2 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$2.hasOwnProperty; + +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'); /** - * Creates an array of the own and inherited enumerable symbols of `object`. + * The base implementation of `_.isNative` without bad shim checks. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of symbols. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. */ -var getSymbolsIn = !nativeGetSymbols$1 ? stubArray : function (object) { - var result = []; - while (object) { - arrayPush(result, getSymbols(object)); - object = getPrototype(object); +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; } - return result; -}; + var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); +} /** - * Copies own and inherited symbols of `source` to `object`. + * Gets the value at `key` of `object`. * * @private - * @param {Object} source The object to copy symbols from. - * @param {Object} [object={}] The object to copy symbols to. - * @returns {Object} Returns `object`. + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. */ -function copySymbolsIn(source, object) { - return copyObject(source, getSymbolsIn(source), object); +function getValue$1(object, key) { + return object == null ? undefined : object[key]; } /** - * The base implementation of `getAllKeys` and `getAllKeysIn` which uses - * `keysFunc` and `symbolsFunc` to get the enumerable property names and - * symbols of `object`. + * Gets the native function at `key` of `object`. * * @private * @param {Object} object The object to query. - * @param {Function} keysFunc The function to get the keys of `object`. - * @param {Function} symbolsFunc The function to get the symbols of `object`. - * @returns {Array} Returns the array of property names and symbols. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. */ -function baseGetAllKeys(object, keysFunc, symbolsFunc) { - var result = keysFunc(object); - return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object)); +function getNative(object, key) { + var value = getValue$1(object, key); + return baseIsNative(value) ? value : undefined; } +/* Built-in method references that are verified to be native. */ +var WeakMap$1 = getNative(root, 'WeakMap'); + +/** Used to store function metadata. */ +var metaMap = WeakMap$1 && new WeakMap$1(); + /** - * Creates an array of own enumerable property names and symbols of `object`. + * The base implementation of `setData` without support for hot loop shorting. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. */ -function getAllKeys(object) { - return baseGetAllKeys(object, keys$1, getSymbols); -} +var baseSetData = !metaMap ? identity$1 : function (func, data) { + metaMap.set(func, data); + return func; +}; + +/** Built-in value references. */ +var objectCreate = Object.create; /** - * Creates an array of own and inherited enumerable property names and - * symbols of `object`. + * The base implementation of `_.create` without support for assigning + * properties to the created object. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names and symbols. + * @param {Object} proto The object to inherit from. + * @returns {Object} Returns the new object. */ -function getAllKeysIn(object) { - return baseGetAllKeys(object, keysIn$1, getSymbolsIn); -} - -/* Built-in method references that are verified to be native. */ -var DataView$1 = getNative(root, 'DataView'); - -/* Built-in method references that are verified to be native. */ -var Promise$1 = getNative(root, 'Promise'); - -/* Built-in method references that are verified to be native. */ -var Set$1 = getNative(root, 'Set'); +var baseCreate = function () { + function object() {} + return function (proto) { + if (!isObject(proto)) { + return {}; + } + if (objectCreate) { + return objectCreate(proto); + } + object.prototype = proto; + var result = new object(); + object.prototype = undefined; + return result; + }; +}(); -/** `Object#toString` result references. */ -var mapTag$2 = '[object Map]'; -var objectTag$3 = '[object Object]'; -var promiseTag = '[object Promise]'; -var setTag$2 = '[object Set]'; -var weakMapTag$2 = '[object WeakMap]'; +/** + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. + * + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. + */ +function createCtor(Ctor) { + return function () { + // Use a `switch` statement to work with class constructors. See + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: + return new Ctor(); + case 1: + return new Ctor(args[0]); + case 2: + return new Ctor(args[0], args[1]); + case 3: + return new Ctor(args[0], args[1], args[2]); + case 4: + return new Ctor(args[0], args[1], args[2], args[3]); + case 5: + return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: + return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); -var dataViewTag$2 = '[object DataView]'; + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; +} -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView$1); -var mapCtorString = toSource(Map$1); -var promiseCtorString = toSource(Promise$1); -var setCtorString = toSource(Set$1); -var weakMapCtorString = toSource(WeakMap$1); +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$1 = 1; /** - * Gets the `toStringTag` of `value`. + * Creates a function that wraps `func` to invoke it with the optional `this` + * binding of `thisArg`. * * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new wrapped function. */ -var getTag = baseGetTag; - -// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. -if (DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag(new Map$1()) != mapTag$2 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$2 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag$2) { - getTag = function getTag(value) { - var result = baseGetTag(value), - Ctor = result == objectTag$3 ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : ''; +function createBind(func, bitmask, thisArg) { + var isBind = bitmask & WRAP_BIND_FLAG$1, + Ctor = createCtor(func); - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: - return dataViewTag$2; - case mapCtorString: - return mapTag$2; - case promiseCtorString: - return promiseTag; - case setCtorString: - return setTag$2; - case weakMapCtorString: - return weakMapTag$2; - } - } - return result; - }; + function wrapper() { + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return fn.apply(isBind ? thisArg : this, arguments); + } + return wrapper; } -var getTag$1 = getTag; - -/** Used for built-in method references. */ -var objectProto$16 = Object.prototype; +/** + * A faster alternative to `Function#apply`, this function invokes `func` + * with the `this` binding of `thisArg` and the arguments of `args`. + * + * @private + * @param {Function} func The function to invoke. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} args The arguments to invoke `func` with. + * @returns {*} Returns the result of `func`. + */ +function apply$1(func, thisArg, args) { + switch (args.length) { + case 0: + return func.call(thisArg); + case 1: + return func.call(thisArg, args[0]); + case 2: + return func.call(thisArg, args[0], args[1]); + case 3: + return func.call(thisArg, args[0], args[1], args[2]); + } + return func.apply(thisArg, args); +} -/** Used to check objects for own properties. */ -var hasOwnProperty$13 = objectProto$16.hasOwnProperty; +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$1 = Math.max; /** - * Initializes an array clone. + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. * * @private - * @param {Array} array The array to clone. - * @returns {Array} Returns the initialized clone. + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. */ -function initCloneArray(array) { - var length = array.length, - result = array.constructor(length); +function composeArgs(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersLength = holders.length, + leftIndex = -1, + leftLength = partials.length, + rangeLength = nativeMax$1(argsLength - holdersLength, 0), + result = Array(leftLength + rangeLength), + isUncurried = !isCurried; - // Add properties assigned by `RegExp#exec`. - if (length && typeof array[0] == 'string' && hasOwnProperty$13.call(array, 'index')) { - result.index = array.index; - result.input = array.input; + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + } + while (rangeLength--) { + result[leftIndex++] = args[argsIndex++]; } return result; } -/** Built-in value references. */ -var Uint8Array$1 = root.Uint8Array; +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$2 = Math.max; /** - * Creates a clone of `arrayBuffer`. + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. * * @private - * @param {ArrayBuffer} arrayBuffer The array buffer to clone. - * @returns {ArrayBuffer} Returns the cloned array buffer. + * @param {Array} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @params {boolean} [isCurried] Specify composing for a curried function. + * @returns {Array} Returns the new array of composed arguments. */ -function cloneArrayBuffer(arrayBuffer) { - var result = new arrayBuffer.constructor(arrayBuffer.byteLength); - new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer)); +function composeArgsRight(args, partials, holders, isCurried) { + var argsIndex = -1, + argsLength = args.length, + holdersIndex = -1, + holdersLength = holders.length, + rightIndex = -1, + rightLength = partials.length, + rangeLength = nativeMax$2(argsLength - holdersLength, 0), + result = Array(rangeLength + rightLength), + isUncurried = !isCurried; + + while (++argsIndex < rangeLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + if (isUncurried || argsIndex < argsLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + } return result; } /** - * Creates a clone of `dataView`. + * Gets the number of `placeholder` occurrences in `array`. * * @private - * @param {Object} dataView The data view to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned data view. + * @param {Array} array The array to inspect. + * @param {*} placeholder The placeholder to search for. + * @returns {number} Returns the placeholder count. */ -function cloneDataView(dataView, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; - return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); +function countHolders(array, placeholder) { + var length = array.length, + result = 0; + + while (length--) { + if (array[length] === placeholder) { + ++result; + } + } + return result; } /** - * Adds the key-value `pair` to `map`. + * The function whose prototype chain sequence wrappers inherit from. * * @private - * @param {Object} map The map to modify. - * @param {Array} pair The key-value pair to add. - * @returns {Object} Returns `map`. */ -function addMapEntry(map, pair) { - // Don't return `map.set` because it's not chainable in IE 11. - map.set(pair[0], pair[1]); - return map; -} - -/** - * Converts `map` to its key-value pairs. - * - * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. - */ -function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function (value, key) { - result[++index] = [key, value]; - }); - return result; +function baseLodash() { + // No operation performed. } -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$1 = 1; +/** Used as references for the maximum length and index of an array. */ +var MAX_ARRAY_LENGTH = 4294967295; /** - * Creates a clone of `map`. + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. * * @private - * @param {Object} map The map to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned map. + * @constructor + * @param {*} value The value to wrap. */ -function cloneMap(map, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG$1) : mapToArray(map); - return arrayReduce(array, addMapEntry, new map.constructor()); +function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = MAX_ARRAY_LENGTH; + this.__views__ = []; } -/** Used to match `RegExp` flags from their coerced string values. */ -var reFlags = /\w*$/; +// Ensure `LazyWrapper` is an instance of `baseLodash`. +LazyWrapper.prototype = baseCreate(baseLodash.prototype); +LazyWrapper.prototype.constructor = LazyWrapper; /** - * Creates a clone of `regexp`. + * This method returns `undefined`. * - * @private - * @param {Object} regexp The regexp to clone. - * @returns {Object} Returns the cloned regexp. - */ -function cloneRegExp(regexp) { - var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); - result.lastIndex = regexp.lastIndex; - return result; -} - -/** - * Adds `value` to `set`. + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example * - * @private - * @param {Object} set The set to modify. - * @param {*} value The value to add. - * @returns {Object} Returns `set`. + * _.times(2, _.noop); + * // => [undefined, undefined] */ -function addSetEntry(set, value) { - // Don't return `set.add` because it's not chainable in IE 11. - set.add(value); - return set; +function noop() { + // No operation performed. } /** - * Converts `set` to an array of its values. + * Gets metadata for `func`. * * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. */ -function setToArray(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function (value) { - result[++index] = value; - }); - return result; -} +var getData = !metaMap ? noop : function (func) { + return metaMap.get(func); +}; -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$2 = 1; +/** Used to lookup unminified function names. */ +var realNames = {}; -/** - * Creates a clone of `set`. - * - * @private - * @param {Object} set The set to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned set. - */ -function cloneSet(set, isDeep, cloneFunc) { - var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG$2) : setToArray(set); - return arrayReduce(array, addSetEntry, new set.constructor()); -} +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; -/** Used to convert symbols to primitives and strings. */ -var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined; -var symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined; +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$3.hasOwnProperty; /** - * Creates a clone of the `symbol` object. + * Gets the name of `func`. * * @private - * @param {Object} symbol The symbol object to clone. - * @returns {Object} Returns the cloned symbol object. + * @param {Function} func The function to query. + * @returns {string} Returns the function name. */ -function cloneSymbol(symbol) { - return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; +function getFuncName(func) { + var result = func.name + '', + array = realNames[result], + length = hasOwnProperty$2.call(realNames, result) ? array.length : 0; + + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; } /** - * Creates a clone of `typedArray`. + * The base constructor for creating `lodash` wrapper objects. * * @private - * @param {Object} typedArray The typed array to clone. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the cloned typed array. + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable explicit method chain sequences. */ -function cloneTypedArray(typedArray, isDeep) { - var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; - return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); +function LodashWrapper(value, chainAll) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__chain__ = !!chainAll; + this.__index__ = 0; + this.__values__ = undefined; } -/** `Object#toString` result references. */ -var boolTag$2 = '[object Boolean]'; -var dateTag$2 = '[object Date]'; -var mapTag$3 = '[object Map]'; -var numberTag$2 = '[object Number]'; -var regexpTag$2 = '[object RegExp]'; -var setTag$3 = '[object Set]'; -var stringTag$2 = '[object String]'; -var symbolTag$2 = '[object Symbol]'; - -var arrayBufferTag$2 = '[object ArrayBuffer]'; -var dataViewTag$3 = '[object DataView]'; -var float32Tag$2 = '[object Float32Array]'; -var float64Tag$2 = '[object Float64Array]'; -var int8Tag$2 = '[object Int8Array]'; -var int16Tag$2 = '[object Int16Array]'; -var int32Tag$2 = '[object Int32Array]'; -var uint8Tag$2 = '[object Uint8Array]'; -var uint8ClampedTag$2 = '[object Uint8ClampedArray]'; -var uint16Tag$2 = '[object Uint16Array]'; -var uint32Tag$2 = '[object Uint32Array]'; +LodashWrapper.prototype = baseCreate(baseLodash.prototype); +LodashWrapper.prototype.constructor = LodashWrapper; /** - * Initializes an object clone based on its `toStringTag`. - * - * **Note:** This function only supports cloning values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * Copies the values of `source` to `array`. * * @private - * @param {Object} object The object to clone. - * @param {string} tag The `toStringTag` of the object to clone. - * @param {Function} cloneFunc The function to clone values. - * @param {boolean} [isDeep] Specify a deep clone. - * @returns {Object} Returns the initialized clone. + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. */ -function initCloneByTag(object, tag, cloneFunc, isDeep) { - var Ctor = object.constructor; - switch (tag) { - case arrayBufferTag$2: - return cloneArrayBuffer(object); - - case boolTag$2: - case dateTag$2: - return new Ctor(+object); - - case dataViewTag$3: - return cloneDataView(object, isDeep); - - case float32Tag$2:case float64Tag$2: - case int8Tag$2:case int16Tag$2:case int32Tag$2: - case uint8Tag$2:case uint8ClampedTag$2:case uint16Tag$2:case uint32Tag$2: - return cloneTypedArray(object, isDeep); - - case mapTag$3: - return cloneMap(object, isDeep, cloneFunc); - - case numberTag$2: - case stringTag$2: - return new Ctor(object); - - case regexpTag$2: - return cloneRegExp(object); - - case setTag$3: - return cloneSet(object, isDeep, cloneFunc); +function copyArray$1(source, array) { + var index = -1, + length = source.length; - case symbolTag$2: - return cloneSymbol(object); + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; } + return array; } /** - * Initializes an object clone. + * Creates a clone of `wrapper`. * * @private - * @param {Object} object The object to clone. - * @returns {Object} Returns the initialized clone. + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. */ -function initCloneObject(object) { - return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {}; +function wrapperClone(wrapper) { + if (wrapper instanceof LazyWrapper) { + return wrapper.clone(); + } + var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); + result.__actions__ = copyArray$1(wrapper.__actions__); + result.__index__ = wrapper.__index__; + result.__values__ = wrapper.__values__; + return result; } -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1; -var CLONE_FLAT_FLAG = 2; -var CLONE_SYMBOLS_FLAG$1 = 4; +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; -/** `Object#toString` result references. */ -var argsTag$2 = '[object Arguments]'; -var arrayTag$1 = '[object Array]'; -var boolTag$1 = '[object Boolean]'; -var dateTag$1 = '[object Date]'; -var errorTag$2 = '[object Error]'; -var funcTag$2 = '[object Function]'; -var genTag$1 = '[object GeneratorFunction]'; -var mapTag$1 = '[object Map]'; -var numberTag$1 = '[object Number]'; -var objectTag$2 = '[object Object]'; -var regexpTag$1 = '[object RegExp]'; -var setTag$1 = '[object Set]'; -var stringTag$1 = '[object String]'; -var symbolTag$1 = '[object Symbol]'; -var weakMapTag$1 = '[object WeakMap]'; +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$4.hasOwnProperty; -var arrayBufferTag$1 = '[object ArrayBuffer]'; -var dataViewTag$1 = '[object DataView]'; -var float32Tag$1 = '[object Float32Array]'; -var float64Tag$1 = '[object Float64Array]'; -var int8Tag$1 = '[object Int8Array]'; -var int16Tag$1 = '[object Int16Array]'; -var int32Tag$1 = '[object Int32Array]'; -var uint8Tag$1 = '[object Uint8Array]'; -var uint8ClampedTag$1 = '[object Uint8ClampedArray]'; -var uint16Tag$1 = '[object Uint16Array]'; -var uint32Tag$1 = '[object Uint32Array]'; +/** + * Creates a `lodash` object which wraps `value` to enable implicit method + * chain sequences. Methods that operate on and return arrays, collections, + * and functions can be chained together. Methods that retrieve a single value + * or may return a primitive value will automatically end the chain sequence + * and return the unwrapped value. Otherwise, the value must be unwrapped + * with `_#value`. + * + * Explicit chain sequences, which must be unwrapped with `_#value`, may be + * enabled using `_.chain`. + * + * The execution of chained methods is lazy, that is, it's deferred until + * `_#value` is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. + * Shortcut fusion is an optimization to merge iteratee calls; this avoids + * the creation of intermediate arrays and can greatly reduce the number of + * iteratee executions. Sections of a chain sequence qualify for shortcut + * fusion if the section is applied to an array and iteratees accept only + * one argument. The heuristic for whether a section qualifies for shortcut + * fusion is subject to change. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, + * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, + * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, + * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, + * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, + * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, + * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, + * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, + * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, + * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, + * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, + * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, + * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, + * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, + * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, + * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, + * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, + * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, + * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, + * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, + * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, + * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, + * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, + * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, + * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, + * `zipObject`, `zipObjectDeep`, and `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, + * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, + * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, + * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, + * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, + * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, + * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, + * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, + * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, + * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, + * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, + * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, + * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, + * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, + * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, + * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, + * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, + * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, + * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, + * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, + * `upperFirst`, `value`, and `words` + * + * @name _ + * @constructor + * @category Seq + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * function square(n) { + * return n * n; + * } + * + * var wrapped = _([1, 2, 3]); + * + * // Returns an unwrapped value. + * wrapped.reduce(_.add); + * // => 6 + * + * // Returns a wrapped value. + * var squares = wrapped.map(square); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ +function lodash(value) { + if (isObjectLike(value) && !isArray$1(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty$3.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); +} -/** Used to identify `toStringTag` values supported by `_.clone`. */ -var cloneableTags = {}; -cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag$1] = cloneableTags[float64Tag$1] = cloneableTags[int8Tag$1] = cloneableTags[int16Tag$1] = cloneableTags[int32Tag$1] = cloneableTags[mapTag$1] = cloneableTags[numberTag$1] = cloneableTags[objectTag$2] = cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag$1] = cloneableTags[uint8ClampedTag$1] = cloneableTags[uint16Tag$1] = cloneableTags[uint32Tag$1] = true; -cloneableTags[errorTag$2] = cloneableTags[funcTag$2] = cloneableTags[weakMapTag$1] = false; +// Ensure wrappers are instances of `baseLodash`. +lodash.prototype = baseLodash.prototype; +lodash.prototype.constructor = lodash; /** - * The base implementation of `_.clone` and `_.cloneDeep` which tracks - * traversed objects. + * Checks if `func` has a lazy counterpart. * * @private - * @param {*} value The value to clone. - * @param {boolean} bitmask The bitmask flags. - * 1 - Deep clone - * 2 - Flatten inherited properties - * 4 - Clone symbols - * @param {Function} [customizer] The function to customize cloning. - * @param {string} [key] The key of `value`. - * @param {Object} [object] The parent object of `value`. - * @param {Object} [stack] Tracks traversed objects and their clone counterparts. - * @returns {*} Returns the cloned value. + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, + * else `false`. */ -function baseClone(value, bitmask, customizer, key, object, stack) { - var result, - isDeep = bitmask & CLONE_DEEP_FLAG, - isFlat = bitmask & CLONE_FLAT_FLAG, - isFull = bitmask & CLONE_SYMBOLS_FLAG$1; - - if (customizer) { - result = object ? customizer(value, key, object, stack) : customizer(value); - } - if (result !== undefined) { - return result; - } - if (!isObject(value)) { - return value; - } - var isArr = isArray$1(value); - if (isArr) { - result = initCloneArray(value); - if (!isDeep) { - return copyArray$1(value, result); - } - } else { - var tag = getTag$1(value), - isFunc = tag == funcTag$2 || tag == genTag$1; +function isLaziable(func) { + var funcName = getFuncName(func), + other = lodash[funcName]; - if (isBuffer(value)) { - return cloneBuffer(value, isDeep); - } - if (tag == objectTag$2 || tag == argsTag$2 || isFunc && !object) { - result = isFlat || isFunc ? {} : initCloneObject(value); - if (!isDeep) { - return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value)); - } - } else { - if (!cloneableTags[tag]) { - return object ? value : {}; - } - result = initCloneByTag(value, tag, baseClone, isDeep); - } + if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { + return false; } - // Check for circular references and return its corresponding clone. - stack || (stack = new Stack()); - var stacked = stack.get(value); - if (stacked) { - return stacked; + if (func === other) { + return true; } - stack.set(value, result); - - var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys$1; - - var props = isArr ? undefined : keysFunc(value); - arrayEach(props || value, function (subValue, key) { - if (props) { - key = subValue; - subValue = value[key]; - } - // Recursively populate clone (susceptible to call stack limits). - assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); - }); - return result; + var data = getData(other); + return !!data && func === data[0]; } -/** Used to compose bitmasks for cloning. */ -var CLONE_SYMBOLS_FLAG = 4; +/** Used to detect hot functions by number of calls within a span of milliseconds. */ +var HOT_COUNT = 800; +var HOT_SPAN = 16; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeNow = Date.now; /** - * Creates a shallow clone of `value`. - * - * **Note:** This method is loosely based on the - * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) - * and supports cloning arrays, array buffers, booleans, date objects, maps, - * numbers, `Object` objects, regexes, sets, strings, symbols, and typed - * arrays. The own enumerable properties of `arguments` objects are cloned - * as plain objects. An empty object is returned for uncloneable values such - * as error objects, functions, DOM nodes, and WeakMaps. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to clone. - * @returns {*} Returns the cloned value. - * @see _.cloneDeep - * @example - * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * Creates a function that'll short out and invoke `identity` instead + * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` + * milliseconds. * - * var shallow = _.clone(objects); - * console.log(shallow[0] === objects[0]); - * // => true + * @private + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new shortable function. */ -function clone$1(value) { - return baseClone(value, CLONE_SYMBOLS_FLAG); -} +function shortOut(func) { + var count = 0, + lastCalled = 0; -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$3 = 1; -var CLONE_SYMBOLS_FLAG$2 = 4; + return function () { + var stamp = nativeNow(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return arguments[0]; + } + } else { + count = 0; + } + return func.apply(undefined, arguments); + }; +} /** - * This method is like `_.clone` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 1.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @returns {*} Returns the deep cloned value. - * @see _.clone - * @example + * Sets metadata for `func`. * - * var objects = [{ 'a': 1 }, { 'b': 2 }]; + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity + * function to avoid garbage collection pauses in V8. See + * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) + * for more details. * - * var deep = _.cloneDeep(objects); - * console.log(deep[0] === objects[0]); - * // => false + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. */ -function cloneDeep(value) { - return baseClone(value, CLONE_DEEP_FLAG$3 | CLONE_SYMBOLS_FLAG$2); -} +var setData = shortOut(baseSetData); -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$4 = 1; -var CLONE_SYMBOLS_FLAG$3 = 4; +/** Used to match wrap detail comments. */ +var reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/; +var reSplitDetails = /,? & /; /** - * This method is like `_.cloneWith` except that it recursively clones `value`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to recursively clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the deep cloned value. - * @see _.cloneWith - * @example - * - * function customizer(value) { - * if (_.isElement(value)) { - * return value.cloneNode(true); - * } - * } - * - * var el = _.cloneDeepWith(document.body, customizer); + * Extracts wrapper details from the `source` body comment. * - * console.log(el === document.body); - * // => false - * console.log(el.nodeName); - * // => 'BODY' - * console.log(el.childNodes.length); - * // => 20 + * @private + * @param {string} source The source to inspect. + * @returns {Array} Returns the wrapper details. */ -function cloneDeepWith(value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseClone(value, CLONE_DEEP_FLAG$4 | CLONE_SYMBOLS_FLAG$3, customizer); +function getWrapDetails(source) { + var match = source.match(reWrapDetails); + return match ? match[1].split(reSplitDetails) : []; } -/** Used to compose bitmasks for cloning. */ -var CLONE_SYMBOLS_FLAG$4 = 4; +/** Used to match wrap detail comments. */ +var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/; /** - * This method is like `_.clone` except that it accepts `customizer` which - * is invoked to produce the cloned value. If `customizer` returns `undefined`, - * cloning is handled by the method instead. The `customizer` is invoked with - * up to four arguments; (value [, index|key, object, stack]). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to clone. - * @param {Function} [customizer] The function to customize cloning. - * @returns {*} Returns the cloned value. - * @see _.cloneDeepWith - * @example - * - * function customizer(value) { - * if (_.isElement(value)) { - * return value.cloneNode(false); - * } - * } - * - * var el = _.cloneWith(document.body, customizer); + * Inserts wrapper `details` in a comment at the top of the `source` body. * - * console.log(el === document.body); - * // => false - * console.log(el.nodeName); - * // => 'BODY' - * console.log(el.childNodes.length); - * // => 0 + * @private + * @param {string} source The source to modify. + * @returns {Array} details The details to insert. + * @returns {string} Returns the modified source. */ -function cloneWith(value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseClone(value, CLONE_SYMBOLS_FLAG$4, customizer); +function insertWrapDetails(source, details) { + var length = details.length; + if (!length) { + return source; + } + var lastIndex = length - 1; + details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; + details = details.join(length > 2 ? ', ' : ' '); + return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); } /** - * Executes the chain sequence and returns the wrapped result. + * Creates a function that returns `value`. * - * @name commit + * @static * @memberOf _ - * @since 3.2.0 - * @category Seq - * @returns {Object} Returns the new `lodash` wrapper instance. + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. * @example * - * var array = [1, 2]; - * var wrapped = _(array).push(3); - * - * console.log(array); - * // => [1, 2] - * - * wrapped = wrapped.commit(); - * console.log(array); - * // => [1, 2, 3] + * var objects = _.times(2, _.constant({ 'a': 1 })); * - * wrapped.last(); - * // => 3 + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] * - * console.log(array); - * // => [1, 2, 3] + * console.log(objects[0] === objects[1]); + * // => true */ -function wrapperCommit() { - return new LodashWrapper(this.value(), this.__chain__); +function constant(value) { + return function () { + return value; + }; } +var defineProperty$2 = function () { + try { + var func = getNative(Object, 'defineProperty'); + func({}, '', {}); + return func; + } catch (e) {} +}(); + /** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are falsey. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to compact. - * @returns {Array} Returns the new array of filtered values. - * @example + * The base implementation of `setToString` without support for hot loop shorting. * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. */ -function compact(array) { - var index = -1, - length = array == null ? 0 : array.length, - resIndex = 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (value) { - result[resIndex++] = value; - } - } - return result; -} +var baseSetToString = !defineProperty$2 ? identity$1 : function (func, string) { + return defineProperty$2(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true + }); +}; /** - * Creates a new array concatenating `array` with any additional arrays - * and/or values. + * Sets the `toString` method of `func` to return `string`. * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to concatenate. - * @param {...*} [values] The values to concatenate. - * @returns {Array} Returns the new concatenated array. - * @example - * - * var array = [1]; - * var other = _.concat(array, 2, [3], [[4]]); - * - * console.log(other); - * // => [1, 2, 3, [4]] + * @private + * @param {Function} func The function to modify. + * @param {Function} string The `toString` result. + * @returns {Function} Returns `func`. + */ +var setToString = shortOut(baseSetToString); + +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. * - * console.log(array); - * // => [1] + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. */ -function concat() { - var length = arguments.length; - if (!length) { - return []; - } - var args = Array(length - 1), - array = arguments[0], - index = length; +function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; - while (index--) { - args[index - 1] = arguments[index]; + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } } - return arrayPush(isArray$1(array) ? copyArray$1(array) : [array], baseFlatten(args, 1)); + return array; } -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED$2 = '__lodash_hash_undefined__'; - /** - * Adds `value` to the array cache. + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. * * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. */ -function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED$2); - return this; +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); + + while (fromRight ? index-- : ++index < length) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; } /** - * Checks if `value` is in the array cache. + * The base implementation of `_.isNaN` without support for number objects. * * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. */ -function setCacheHas(value) { - return this.__data__.has(value); +function baseIsNaN(value) { + return value !== value; } /** - * - * Creates an array cache object to store unique values. + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. * * @private - * @constructor - * @param {Array} [values] The values to cache. + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. */ -function SetCache(values) { - var index = -1, - length = values == null ? 0 : values.length; +function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; - this.__data__ = new MapCache(); while (++index < length) { - this.add(values[index]); + if (array[index] === value) { + return index; + } } + return -1; } -// Add methods to `SetCache`. -SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; -SetCache.prototype.has = setCacheHas; +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex); +} /** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. + * A specialized version of `_.includes` for arrays without support for + * specifying an index to search from. * * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @returns {boolean} Returns `true` if `target` is found, else `false`. */ -function arraySome(array, predicate) { - var index = -1, - length = array == null ? 0 : array.length; +function arrayIncludes(array, value) { + var length = array == null ? 0 : array.length; + return !!length && baseIndexOf(array, value, 0) > -1; +} - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$4 = 1; +var WRAP_BIND_KEY_FLAG$3 = 2; +var WRAP_CURRY_FLAG$3 = 8; +var WRAP_CURRY_RIGHT_FLAG$2 = 16; +var WRAP_PARTIAL_FLAG$2 = 32; +var WRAP_PARTIAL_RIGHT_FLAG$2 = 64; +var WRAP_ARY_FLAG$2 = 128; +var WRAP_REARG_FLAG = 256; +var WRAP_FLIP_FLAG$1 = 512; + +/** Used to associate wrap methods with their bit flags. */ +var wrapFlags = [['ary', WRAP_ARY_FLAG$2], ['bind', WRAP_BIND_FLAG$4], ['bindKey', WRAP_BIND_KEY_FLAG$3], ['curry', WRAP_CURRY_FLAG$3], ['curryRight', WRAP_CURRY_RIGHT_FLAG$2], ['flip', WRAP_FLIP_FLAG$1], ['partial', WRAP_PARTIAL_FLAG$2], ['partialRight', WRAP_PARTIAL_RIGHT_FLAG$2], ['rearg', WRAP_REARG_FLAG]]; + +/** + * Updates wrapper `details` based on `bitmask` flags. + * + * @private + * @returns {Array} details The details to modify. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Array} Returns `details`. + */ +function updateWrapDetails(details, bitmask) { + arrayEach(wrapFlags, function (pair) { + var value = '_.' + pair[0]; + if (bitmask & pair[1] && !arrayIncludes(details, value)) { + details.push(value); } - } - return false; + }); + return details.sort(); } /** - * Checks if a `cache` value for `key` exists. + * Sets the `toString` method of `wrapper` to mimic the source of `reference` + * with wrapper details in a comment at the top of the source body. * * @private - * @param {Object} cache The cache to query. - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @param {Function} wrapper The function to modify. + * @param {Function} reference The reference function. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @returns {Function} Returns `wrapper`. */ -function cacheHas(cache, key) { - return cache.has(key); +function setWrapToString(wrapper, reference, bitmask) { + var source = reference + ''; + return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); } -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG$2 = 1; -var COMPARE_UNORDERED_FLAG$1 = 2; +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$3 = 1; +var WRAP_BIND_KEY_FLAG$2 = 2; +var WRAP_CURRY_BOUND_FLAG = 4; +var WRAP_CURRY_FLAG$2 = 8; +var WRAP_PARTIAL_FLAG$1 = 32; +var WRAP_PARTIAL_RIGHT_FLAG$1 = 64; /** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. + * Creates a function that wraps `func` to continue currying. * * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {Function} wrapFunc The function to create the `func` wrapper. + * @param {*} placeholder The placeholder value. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ -function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2, - arrLength = array.length, - othLength = other.length; +function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { + var isCurry = bitmask & WRAP_CURRY_FLAG$2, + newHolders = isCurry ? holders : undefined, + newHoldersRight = isCurry ? undefined : holders, + newPartials = isCurry ? partials : undefined, + newPartialsRight = isCurry ? undefined : partials; - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; + bitmask |= isCurry ? WRAP_PARTIAL_FLAG$1 : WRAP_PARTIAL_RIGHT_FLAG$1; + bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG$1 : WRAP_PARTIAL_FLAG$1); + + if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { + bitmask &= ~(WRAP_BIND_FLAG$3 | WRAP_BIND_KEY_FLAG$2); } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; + var newData = [func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, newHoldersRight, argPos, ary, arity]; + + var result = wrapFunc.apply(undefined, newData); + if (isLaziable(func)) { + setData(result, newData); } - var index = -1, - result = true, - seen = bitmask & COMPARE_UNORDERED_FLAG$1 ? new SetCache() : undefined; + result.placeholder = placeholder; + return setWrapToString(result, func, bitmask); +} - stack.set(array, other); - stack.set(other, array); - - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; - - if (customizer) { - var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function (othValue, othIndex) { - if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - return seen.push(othIndex); - } - })) { - result = false; - break; - } - } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { - result = false; - break; - } - } - stack['delete'](array); - stack['delete'](other); - return result; +/** + * Gets the argument placeholder value for `func`. + * + * @private + * @param {Function} func The function to inspect. + * @returns {*} Returns the placeholder value. + */ +function getHolder(func) { + var object = func; + return object.placeholder; } -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG$3 = 1; -var COMPARE_UNORDERED_FLAG$2 = 2; - -/** `Object#toString` result references. */ -var boolTag$3 = '[object Boolean]'; -var dateTag$3 = '[object Date]'; -var errorTag$3 = '[object Error]'; -var mapTag$4 = '[object Map]'; -var numberTag$3 = '[object Number]'; -var regexpTag$3 = '[object RegExp]'; -var setTag$4 = '[object Set]'; -var stringTag$3 = '[object String]'; -var symbolTag$3 = '[object Symbol]'; - -var arrayBufferTag$3 = '[object ArrayBuffer]'; -var dataViewTag$4 = '[object DataView]'; +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; -/** Used to convert symbols to primitives and strings. */ -var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined; -var symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : undefined; +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; /** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * Checks if `value` is a valid array-like index. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ -function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { - switch (tag) { - case dataViewTag$4: - if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { - return false; - } - object = object.buffer; - other = other.buffer; - - case arrayBufferTag$3: - if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) { - return false; - } - return true; - - case boolTag$3: - case dateTag$3: - case numberTag$3: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - - case errorTag$3: - return object.name == other.name && object.message == other.message; - - case regexpTag$3: - case stringTag$3: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == other + ''; - - case mapTag$4: - var convert = mapToArray; - - case setTag$4: - var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3; - convert || (convert = setToArray); - - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= COMPARE_UNORDERED_FLAG$2; - - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); - stack['delete'](object); - return result; - - case symbolTag$3: - if (symbolValueOf$1) { - return symbolValueOf$1.call(object) == symbolValueOf$1.call(other); - } - } - return false; +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && (typeof value == 'number' || reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length; } -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG$4 = 1; - -/** Used for built-in method references. */ -var objectProto$18 = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty$15 = objectProto$18.hasOwnProperty; +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; /** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. */ -function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { - var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4, - objProps = getAllKeys(object), - objLength = objProps.length, - othProps = getAllKeys(other), - othLength = othProps.length; +function reorder$1(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = copyArray$1(array); - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty$15.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; } - var result = true; - stack.set(object, other); - stack.set(other, object); + return array; +} - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; +/** Used as the internal argument placeholder. */ +var PLACEHOLDER = '__lodash_placeholder__'; - if (customizer) { - var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; +/** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ +function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = 0, + result = []; - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; + while (++index < length) { + var value = array[index]; + if (value === placeholder || value === PLACEHOLDER) { + array[index] = PLACEHOLDER; + result[resIndex++] = index; } } - stack['delete'](object); - stack['delete'](other); return result; } -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG$1 = 1; - -/** `Object#toString` result references. */ -var argsTag$3 = '[object Arguments]'; -var arrayTag$2 = '[object Array]'; -var objectTag$4 = '[object Object]'; - -/** Used for built-in method references. */ -var objectProto$17 = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty$14 = objectProto$17.hasOwnProperty; +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$2 = 1; +var WRAP_BIND_KEY_FLAG$1 = 2; +var WRAP_CURRY_FLAG$1 = 8; +var WRAP_CURRY_RIGHT_FLAG$1 = 16; +var WRAP_ARY_FLAG$1 = 128; +var WRAP_FLIP_FLAG = 512; /** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. + * Creates a function that wraps `func` to invoke it with optional `this` + * binding of `thisArg`, partial application, and currying. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. - * @param {Function} customizer The function to customize comparisons. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to + * the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided + * to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ -function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { - var objIsArr = isArray$1(object), - othIsArr = isArray$1(other), - objTag = objIsArr ? arrayTag$2 : getTag$1(object), - othTag = othIsArr ? arrayTag$2 : getTag$1(other); - - objTag = objTag == argsTag$3 ? objectTag$4 : objTag; - othTag = othTag == argsTag$3 ? objectTag$4 : othTag; +function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & WRAP_ARY_FLAG$1, + isBind = bitmask & WRAP_BIND_FLAG$2, + isBindKey = bitmask & WRAP_BIND_KEY_FLAG$1, + isCurried = bitmask & (WRAP_CURRY_FLAG$1 | WRAP_CURRY_RIGHT_FLAG$1), + isFlip = bitmask & WRAP_FLIP_FLAG, + Ctor = isBindKey ? undefined : createCtor(func); - var objIsObj = objTag == objectTag$4, - othIsObj = othTag == objectTag$4, - isSameTag = objTag == othTag; + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length; - if (isSameTag && isBuffer(object)) { - if (!isBuffer(other)) { - return false; + while (index--) { + args[index] = arguments[index]; } - objIsArr = true; - objIsObj = false; - } - if (isSameTag && !objIsObj) { - stack || (stack = new Stack()); - return objIsArr || isTypedArray$1(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); - } - if (!(bitmask & COMPARE_PARTIAL_FLAG$1)) { - var objIsWrapped = objIsObj && hasOwnProperty$14.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty$14.call(other, '__wrapped__'); - - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; + if (isCurried) { + var placeholder = getHolder(wrapper), + holdersCount = countHolders(args, placeholder); + } + if (partials) { + args = composeArgs(args, partials, holders, isCurried); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight, isCurried); + } + length -= holdersCount; + if (isCurried && length < arity) { + var newHolders = replaceHolders(args, placeholder); + return createRecurry(func, bitmask, createHybrid, wrapper.placeholder, thisArg, args, newHolders, argPos, ary, arity - length); + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; - stack || (stack = new Stack()); - return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + length = args.length; + if (argPos) { + args = reorder$1(args, argPos); + } else if (isFlip && length > 1) { + args.reverse(); } + if (isAry && ary < length) { + args.length = ary; + } + if (this && this !== root && this instanceof wrapper) { + fn = Ctor || createCtor(fn); + } + return fn.apply(thisBinding, args); } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack()); - return equalObjects(object, other, bitmask, customizer, equalFunc, stack); + return wrapper; } /** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. + * Creates a function that wraps `func` to enable currying. * * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {boolean} bitmask The bitmask flags. - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Function} [customizer] The function to customize comparisons. - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {number} arity The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ -function baseIsEqual(value, other, bitmask, customizer, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); -} - -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG = 1; -var COMPARE_UNORDERED_FLAG = 2; +function createCurry(func, bitmask, arity) { + var Ctor = createCtor(func); -/** - * The base implementation of `_.isMatch` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ -function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; + function wrapper() { + var length = arguments.length, + args = Array(length), + index = length, + placeholder = getHolder(wrapper); - if (object == null) { - return !length; - } - object = Object(object); - while (index--) { - var data = matchData[index]; - if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { - return false; + while (index--) { + args[index] = arguments[index]; } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; + var holders = length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder ? [] : replaceHolders(args, placeholder); - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var stack = new Stack(); - if (customizer) { - var result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) : result)) { - return false; - } + length -= holders.length; + if (length < arity) { + return createRecurry(func, bitmask, createHybrid, wrapper.placeholder, undefined, args, holders, undefined, undefined, arity - length); } + var fn = this && this !== root && this instanceof wrapper ? Ctor : func; + return apply$1(fn, this, args); } - return true; + return wrapper; } -/** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ -function isStrictComparable(value) { - return value === value && !isObject(value); -} +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$5 = 1; /** - * Gets the property names, values, and compare flags of `object`. + * Creates a function that wraps `func` to invoke it with the `this` binding + * of `thisArg` and `partials` prepended to the arguments it receives. * * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. + * @param {Function} func The function to wrap. + * @param {number} bitmask The bitmask flags. See `createWrap` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to + * the new function. + * @returns {Function} Returns the new wrapped function. */ -function getMatchData(object) { - var result = keys$1(object), - length = result.length; +function createPartial(func, bitmask, thisArg, partials) { + var isBind = bitmask & WRAP_BIND_FLAG$5, + Ctor = createCtor(func); - while (length--) { - var key = result[length], - value = object[key]; + function wrapper() { + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength), + fn = this && this !== root && this instanceof wrapper ? Ctor : func; - result[length] = [key, value, isStrictComparable(value)]; + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + return apply$1(fn, isBind ? thisArg : this, args); } - return result; + return wrapper; } -/** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -function matchesStrictComparable(key, srcValue) { - return function (object) { - if (object == null) { - return false; - } - return object[key] === srcValue && (srcValue !== undefined || key in Object(object)); - }; -} +/** Used as the internal argument placeholder. */ +var PLACEHOLDER$1 = '__lodash_placeholder__'; + +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$6 = 1; +var WRAP_BIND_KEY_FLAG$4 = 2; +var WRAP_CURRY_BOUND_FLAG$1 = 4; +var WRAP_CURRY_FLAG$4 = 8; +var WRAP_ARY_FLAG$3 = 128; +var WRAP_REARG_FLAG$1 = 256; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin$1 = Math.min; /** - * The base implementation of `_.matches` which doesn't clone `source`. + * Merges the function metadata of `source` into `data`. + * + * Merging metadata reduces the number of wrappers used to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and + * `_.rearg` modify function arguments, making the order in which they are + * executed important, preventing the merging of metadata. However, we make + * an exception for a safe combined case where curried functions have `_.ary` + * and or `_.rearg` applied. * * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. */ -function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - return matchesStrictComparable(matchData[0][0], matchData[0][1]); +function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < (WRAP_BIND_FLAG$6 | WRAP_BIND_KEY_FLAG$4 | WRAP_ARY_FLAG$3); + + var isCombo = srcBitmask == WRAP_ARY_FLAG$3 && bitmask == WRAP_CURRY_FLAG$4 || srcBitmask == WRAP_ARY_FLAG$3 && bitmask == WRAP_REARG_FLAG$1 && data[7].length <= source[8] || srcBitmask == (WRAP_ARY_FLAG$3 | WRAP_REARG_FLAG$1) && source[7].length <= source[8] && bitmask == WRAP_CURRY_FLAG$4; + + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; } - return function (object) { - return object === source || baseIsMatch(object, source, matchData); - }; -} + // Use source `thisArg` if available. + if (srcBitmask & WRAP_BIND_FLAG$6) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= bitmask & WRAP_BIND_FLAG$6 ? 0 : WRAP_CURRY_BOUND_FLAG$1; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : value; + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER$1) : source[4]; + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER$1) : source[6]; + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = value; + } + // Use source `ary` if it's smaller. + if (srcBitmask & WRAP_ARY_FLAG$3) { + data[8] = data[8] == null ? source[8] : nativeMin$1(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; -/** - * The base implementation of `_.hasIn` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHasIn(object, key) { - return object != null && key in Object(object); + return data; } +/** Error message constants. */ +var FUNC_ERROR_TEXT$1 = 'Expected a function'; + +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG = 1; +var WRAP_BIND_KEY_FLAG = 2; +var WRAP_CURRY_FLAG = 8; +var WRAP_CURRY_RIGHT_FLAG = 16; +var WRAP_PARTIAL_FLAG = 32; +var WRAP_PARTIAL_RIGHT_FLAG = 64; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; + /** - * Checks if `path` exists on `object`. + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. * * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @param {Function} hasFunc The function to check properties. - * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @param {Function|string} func The function or method name to wrap. + * @param {number} bitmask The bitmask flags. + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * 512 - `_.flip` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. */ -function hasPath(object, path, hasFunc) { - path = castPath(path, object); +function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$1); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); + arity = arity === undefined ? arity : toInteger(arity); + length -= holders ? holders.length : 0; - var index = -1, - length = path.length, - result = false; + if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; - while (++index < length) { - var key = toKey(path[index]); - if (!(result = object != null && hasFunc(object, key))) { - break; - } - object = object[key]; + partials = holders = undefined; } - if (result || ++index != length) { - return result; + var data = isBindKey ? undefined : getData(func); + + var newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; + + if (data) { + mergeData(newData, data); } - length = object == null ? 0 : object.length; - return !!length && isLength(length) && isIndex(key, length) && (isArray$1(object) || isArguments(object)); + func = newData[0]; + bitmask = newData[1]; + thisArg = newData[2]; + partials = newData[3]; + holders = newData[4]; + arity = newData[9] = newData[9] === undefined ? isBindKey ? 0 : func.length : nativeMax(newData[9] - length, 0); + + if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { + bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); + } + if (!bitmask || bitmask == WRAP_BIND_FLAG) { + var result = createBind(func, bitmask, thisArg); + } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { + result = createCurry(func, bitmask, arity); + } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { + result = createPartial(func, bitmask, thisArg, partials); + } else { + result = createHybrid.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setWrapToString(setter(result, newData), func, bitmask); } +/** Used to compose bitmasks for function metadata. */ +var WRAP_ARY_FLAG = 128; + /** - * Checks if `path` is a direct or inherited property of `object`. + * Creates a function that invokes `func`, with up to `n` arguments, + * ignoring any additional arguments. * * @static * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @since 3.0.0 + * @category Function + * @param {Function} func The function to cap arguments for. + * @param {number} [n=func.length] The arity cap. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new capped function. * @example * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true - * - * _.hasIn(object, ['a', 'b']); - * // => true - * - * _.hasIn(object, 'b'); - * // => false + * _.map(['6', '8', '10'], _.ary(parseInt, 1)); + * // => [6, 8, 10] */ -function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); +function ary(func, n, guard) { + n = guard ? undefined : n; + n = func && n == null ? func.length : n; + return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); } -/** Used to compose bitmasks for value comparisons. */ -var COMPARE_PARTIAL_FLAG$5 = 1; -var COMPARE_UNORDERED_FLAG$3 = 2; - /** - * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * The base implementation of `assignValue` and `assignMergeValue` without + * value checks. * * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ -function baseMatchesProperty(path, srcValue) { - if (isKey(path) && isStrictComparable(srcValue)) { - return matchesStrictComparable(toKey(path), srcValue); +function baseAssignValue(object, key, value) { + if (key == '__proto__' && defineProperty$2) { + defineProperty$2(object, key, { + 'configurable': true, + 'enumerable': true, + 'value': value, + 'writable': true + }); + } else { + object[key] = value; } - return function (object) { - var objValue = get$2(object, path); - return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3); - }; -} - -/** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. - */ -function baseProperty(key) { - return function (object) { - return object == null ? undefined : object[key]; - }; -} - -/** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - */ -function basePropertyDeep(path) { - return function (object) { - return baseGet(object, path); - }; } /** - * Creates a function that returns the value at `path` of a given object. + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. * * @static * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * - * var objects = [ - * { 'a': { 'b': 2 } }, - * { 'a': { 'b': 1 } } - * ]; + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; * - * _.map(objects, _.property('a.b')); - * // => [2, 1] + * _.eq(object, object); + * // => true * - * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); - * // => [1, 2] + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true */ -function property(path) { - return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); +function eq(value, other) { + return value === other || value !== value && other !== other; } +/** Used for built-in method references. */ +var objectProto$6 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$5 = objectProto$6.hasOwnProperty; + /** - * The base implementation of `_.iteratee`. + * Assigns `value` to `key` of `object` if the existing value is not equivalent + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. * * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. */ -function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity$1; - } - if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') { - return isArray$1(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); +function assignValue(object, key, value) { + var objValue = object[key]; + if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) { + baseAssignValue(object, key, value); } - return property(value); } -/** Error message constants. */ -var FUNC_ERROR_TEXT$4 = 'Expected a function'; - /** - * Creates a function that iterates over `pairs` and invokes the corresponding - * function of the first predicate to return truthy. The predicate-function - * pairs are invoked with the `this` binding and arguments of the created - * function. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {Array} pairs The predicate-function pairs. - * @returns {Function} Returns the new composite function. - * @example - * - * var func = _.cond([ - * [_.matches({ 'a': 1 }), _.constant('matches A')], - * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], - * [_.stubTrue, _.constant('no match')] - * ]); - * - * func({ 'a': 1, 'b': 2 }); - * // => 'matches A' - * - * func({ 'a': 0, 'b': 1 }); - * // => 'matches B' + * Copies properties of `source` to `object`. * - * func({ 'a': '1', 'b': '2' }); - * // => 'no match' + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property identifiers to copy. + * @param {Object} [object={}] The object to copy properties to. + * @param {Function} [customizer] The function to customize copied values. + * @returns {Object} Returns `object`. */ -function cond(pairs) { - var length = pairs == null ? 0 : pairs.length, - toIteratee = baseIteratee; +function copyObject(source, props, object, customizer) { + var isNew = !object; + object || (object = {}); - pairs = !length ? [] : arrayMap(pairs, function (pair) { - if (typeof pair[1] != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$4); - } - return [toIteratee(pair[0]), pair[1]]; - }); + var index = -1, + length = props.length; - return baseRest(function (args) { - var index = -1; - while (++index < length) { - var pair = pairs[index]; - if (apply$1(pair[0], this, args)) { - return apply$1(pair[1], this, args); - } + while (++index < length) { + var key = props[index]; + + var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined; + + if (newValue === undefined) { + newValue = source[key]; } - }); + if (isNew) { + baseAssignValue(object, key, newValue); + } else { + assignValue(object, key, newValue); + } + } + return object; } +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$3 = Math.max; + /** - * The base implementation of `_.conformsTo` which accepts `props` to check. + * A specialized version of `baseRest` which transforms the rest array. * * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @param {Function} transform The rest array transform. + * @returns {Function} Returns the new function. */ -function baseConformsTo(object, source, props) { - var length = props.length; - if (object == null) { - return !length; - } - object = Object(object); - while (length--) { - var key = props[length], - predicate = source[key], - value = object[key]; +function overRest(func, start, transform) { + start = nativeMax$3(start === undefined ? func.length - 1 : start, 0); + return function () { + var args = arguments, + index = -1, + length = nativeMax$3(args.length - start, 0), + array = Array(length); - if (value === undefined && !(key in object) || !predicate(value)) { - return false; + while (++index < length) { + array[index] = args[start + index]; } - } - return true; + index = -1; + var otherArgs = Array(start + 1); + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = transform(array); + return apply$1(func, this, otherArgs); + }; } /** - * The base implementation of `_.conforms` which doesn't clone `source`. + * The base implementation of `_.rest` which doesn't validate or coerce arguments. * * @private - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. */ -function baseConforms(source) { - var props = keys$1(source); - return function (object) { - return baseConformsTo(object, source, props); - }; +function baseRest(func, start) { + return setToString(overRest(func, start, identity$1), func + ''); } -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$5 = 1; +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; /** - * Creates a function that invokes the predicate properties of `source` with - * the corresponding property values of a given object, returning `true` if - * all predicates return truthy, else `false`. + * Checks if `value` is a valid array-like length. * - * **Note:** The created function is equivalent to `_.conformsTo` with - * `source` partially applied. + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 - * @category Util - * @param {Object} source The object of property predicates to conform to. - * @returns {Function} Returns the new spec function. + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * - * var objects = [ - * { 'a': 2, 'b': 1 }, - * { 'a': 1, 'b': 2 } - * ]; + * _.isLength(3); + * // => true * - * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); - * // => [{ 'a': 1, 'b': 2 }] + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false */ -function conforms(source) { - return baseConforms(baseClone(source, CLONE_DEEP_FLAG$5)); +function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1; } /** - * Checks if `object` conforms to `source` by invoking the predicate - * properties of `source` with the corresponding property values of `object`. - * - * **Note:** This method is equivalent to `_.conforms` when `source` is - * partially applied. + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @static * @memberOf _ - * @since 4.14.0 + * @since 4.0.0 * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property predicates to conform to. - * @returns {boolean} Returns `true` if `object` conforms, else `false`. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. * @example * - * var object = { 'a': 1, 'b': 2 }; + * _.isArrayLike([1, 2, 3]); + * // => true * - * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); + * _.isArrayLike(document.body.children); * // => true * - * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); * // => false */ -function conformsTo(object, source) { - return source == null || baseConformsTo(object, source, keys$1(source)); +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); } /** - * A specialized version of `baseAggregator` for arrays. + * Checks if the given arguments are from an iteratee call. * * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform keys. - * @param {Object} accumulator The initial aggregated object. - * @returns {Function} Returns `accumulator`. + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, + * else `false`. */ -function arrayAggregator(array, setter, iteratee, accumulator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - var value = array[index]; - setter(accumulator, value, iteratee(value), array); +function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; } - return accumulator; + var type = typeof index === 'undefined' ? 'undefined' : _typeof(index); + if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) { + return eq(object[index], value); + } + return false; } /** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * Creates a function like `_.assign`. * * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. + * @param {Function} assigner The function to assign values. + * @returns {Function} Returns the new assigner function. */ -function createBaseFor(fromRight) { - return function (object, iteratee, keysFunc) { +function createAssigner(assigner) { + return baseRest(function (object, sources) { var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; + length = sources.length, + customizer = length > 1 ? sources[length - 1] : undefined, + guard = length > 2 ? sources[2] : undefined; - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; + customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined; + + if (guard && isIterateeCall(sources[0], sources[1], guard)) { + customizer = length < 3 ? undefined : customizer; + length = 1; + } + object = Object(object); + while (++index < length) { + var source = sources[index]; + if (source) { + assigner(object, source, index, customizer); } } return object; - }; + }); } -/** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -var baseFor = createBaseFor(); - -/** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys$1); -} +/** Used for built-in method references. */ +var objectProto$7 = Object.prototype; /** - * Creates a `baseEach` or `baseEachRight` function. + * Checks if `value` is likely a prototype object. * * @private - * @param {Function} eachFunc The function to iterate over a collection. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ -function createBaseEach(eachFunc, fromRight) { - return function (collection, iteratee) { - if (collection == null) { - return collection; - } - if (!isArrayLike(collection)) { - return eachFunc(collection, iteratee); - } - var length = collection.length, - index = fromRight ? length : -1, - iterable = Object(collection); +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$7; - while (fromRight ? index-- : ++index < length) { - if (iteratee(iterable[index], index, iterable) === false) { - break; - } - } - return collection; - }; + return value === proto; } /** - * The base implementation of `_.forEach` without support for iteratee shorthands. + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. * * @private - * @param {Array|Object} collection The collection to iterate over. + * @param {number} n The number of times to invoke `iteratee`. * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. + * @returns {Array} Returns the array of results. */ -var baseEach = createBaseEach(baseForOwn); +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); -/** - * Aggregates elements of `collection` on `accumulator` with keys transformed - * by `iteratee` and values set by `setter`. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform keys. - * @param {Object} accumulator The initial aggregated object. - * @returns {Function} Returns `accumulator`. - */ -function baseAggregator(collection, setter, iteratee, accumulator) { - baseEach(collection, function (value, key, collection) { - setter(accumulator, value, iteratee(value), collection); - }); - return accumulator; + while (++index < n) { + result[index] = iteratee(index); + } + return result; } +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]'; + /** - * Creates a function like `_.groupBy`. + * The base implementation of `_.isArguments`. * * @private - * @param {Function} setter The function to set accumulator values. - * @param {Function} [initializer] The accumulator object initializer. - * @returns {Function} Returns the new aggregator function. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ -function createAggregator(setter, initializer) { - return function (collection, iteratee) { - var func = isArray$1(collection) ? arrayAggregator : baseAggregator, - accumulator = initializer ? initializer() : {}; - - return func(collection, setter, baseIteratee(iteratee, 2), accumulator); - }; +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; } /** Used for built-in method references. */ -var objectProto$19 = Object.prototype; +var objectProto$9 = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty$16 = objectProto$19.hasOwnProperty; +var hasOwnProperty$7 = objectProto$9.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable$1 = objectProto$9.propertyIsEnumerable; /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the number of times the key was returned by `iteratee`. The - * iteratee is invoked with one argument: (value). + * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ - * @since 0.5.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. * @example * - * _.countBy([6.1, 4.2, 6.3], Math.floor); - * // => { '4': 1, '6': 2 } + * _.isArguments(function() { return arguments; }()); + * // => true * - * // The `_.property` iteratee shorthand. - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } + * _.isArguments([1, 2, 3]); + * // => false */ -var countBy = createAggregator(function (result, value, key) { - if (hasOwnProperty$16.call(result, key)) { - ++result[key]; - } else { - baseAssignValue(result, key, 1); - } -}); +var isArguments = baseIsArguments(function () { + return arguments; +}()) ? baseIsArguments : function (value) { + return isObjectLike(value) && hasOwnProperty$7.call(value, 'callee') && !propertyIsEnumerable$1.call(value, 'callee'); +}; /** - * Creates an object that inherits from the `prototype` object. If a - * `properties` object is given, its own enumerable string keyed properties - * are assigned to the created object. + * This method returns `false`. * * @static * @memberOf _ - * @since 2.3.0 - * @category Object - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. * @example * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { - * 'constructor': Circle - * }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true + * _.times(2, _.stubFalse); + * // => [false, false] */ -function create$1(prototype, properties) { - var result = baseCreate(prototype); - return properties == null ? result : baseAssign(result, properties); +function stubFalse() { + return false; } -/** Used to compose bitmasks for function metadata. */ -var WRAP_CURRY_FLAG$5 = 8; +/** Detect free variable `exports`. */ +var freeExports = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** - * Creates a function that accepts arguments of `func` and either invokes - * `func` returning its result, if at least `arity` number of arguments have - * been provided, or returns a function that accepts the remaining `func` - * arguments, and so on. The arity of `func` may be specified if `func.length` - * is not sufficient. - * - * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, - * may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. + * Checks if `value` is a buffer. * * @static * @memberOf _ - * @since 2.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new curried function. + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. * @example * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curry(abc); - * - * curried(1)(2)(3); - * // => [1, 2, 3] + * _.isBuffer(new Buffer(2)); + * // => true * - * curried(1, 2)(3); - * // => [1, 2, 3] + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]'; +var arrayTag = '[object Array]'; +var boolTag = '[object Boolean]'; +var dateTag = '[object Date]'; +var errorTag = '[object Error]'; +var funcTag$1 = '[object Function]'; +var mapTag = '[object Map]'; +var numberTag = '[object Number]'; +var objectTag = '[object Object]'; +var regexpTag = '[object RegExp]'; +var setTag = '[object Set]'; +var stringTag = '[object String]'; +var weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]'; +var dataViewTag = '[object DataView]'; +var float32Tag = '[object Float32Array]'; +var float64Tag = '[object Float64Array]'; +var int8Tag = '[object Int8Array]'; +var int16Tag = '[object Int16Array]'; +var int32Tag = '[object Int32Array]'; +var uint8Tag = '[object Uint8Array]'; +var uint8ClampedTag = '[object Uint8ClampedArray]'; +var uint16Tag = '[object Uint16Array]'; +var uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. * - * curried(1, 2, 3); - * // => [1, 2, 3] + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +/** + * The base implementation of `_.unary` without support for storing metadata. * - * // Curried with placeholders. - * curried(1)(_, 3)(2); - * // => [1, 2, 3] + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. */ -function curry(func, arity, guard) { - arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_FLAG$5, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curry.placeholder; - return result; +function baseUnary(func) { + return function (value) { + return func(value); + }; } -// Assign default placeholders. -curry.placeholder = {}; +/** Detect free variable `exports`. */ +var freeExports$1 = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; -/** Used to compose bitmasks for function metadata. */ -var WRAP_CURRY_RIGHT_FLAG$3 = 16; +/** Detect free variable `module`. */ +var freeModule$1 = freeExports$1 && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports$1 && freeGlobal.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = function () { + try { + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}(); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** - * This method is like `_.curry` except that arguments are applied to `func` - * in the manner of `_.partialRight` instead of `_.partial`. - * - * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for provided arguments. - * - * **Note:** This method doesn't set the "length" property of curried functions. + * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 - * @category Function - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the new curried function. + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. * @example * - * var abc = function(a, b, c) { - * return [a, b, c]; - * }; - * - * var curried = _.curryRight(abc); - * - * curried(3)(2)(1); - * // => [1, 2, 3] - * - * curried(2, 3)(1); - * // => [1, 2, 3] - * - * curried(1, 2, 3); - * // => [1, 2, 3] + * _.isTypedArray(new Uint8Array); + * // => true * - * // Curried with placeholders. - * curried(3)(1, _)(2); - * // => [1, 2, 3] + * _.isTypedArray([]); + * // => false */ -function curryRight(func, arity, guard) { - arity = guard ? undefined : arity; - var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG$3, undefined, undefined, undefined, undefined, undefined, arity); - result.placeholder = curryRight.placeholder; - return result; -} +var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; -// Assign default placeholders. -curryRight.placeholder = {}; +/** Used for built-in method references. */ +var objectProto$8 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$6 = objectProto$8.hasOwnProperty; /** - * Gets the timestamp of the number of milliseconds that have elapsed since - * the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Date - * @returns {number} Returns the timestamp. - * @example + * Creates an array of the enumerable property names of the array-like `value`. * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => Logs the number of milliseconds it took for the deferred invocation. + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. */ -var now$1 = function now$1() { - return root.Date.now(); -}; +function arrayLikeKeys(value, inherited) { + var isArr = isArray$1(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; -/** Error message constants. */ -var FUNC_ERROR_TEXT$5 = 'Expected a function'; + for (var key in value) { + if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + isBuff && (key == 'offset' || key == 'parent') || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') || + // Skip index properties. + isIndex(key, length)))) { + result.push(key); + } + } + return result; +} + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function (arg) { + return func(transform(arg)); + }; +} /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$5 = Math.max; -var nativeMin$3 = Math.min; +var nativeKeys = overArg(Object.keys, Object); + +/** Used for built-in method references. */ +var objectProto$10 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$8 = objectProto$10.hasOwnProperty; /** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide `options` to indicate whether `func` should be invoked on the - * leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent - * calls to the debounced function return the result of the last `func` - * invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the debounced function - * is invoked more than once during the `wait` timeout. + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$8.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/** + * Creates an array of the own enumerable property names of `object`. * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.debounce` and `_.throttle`. + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. * * @static - * @memberOf _ * @since 0.1.0 - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=false] - * Specify invoking on the leading edge of the timeout. - * @param {number} [options.maxWait] - * The maximum time `func` is allowed to be delayed before it's invoked. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. * @example * - * // Avoid costly calculations while the window size is in flux. - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); + * function Foo() { + * this.a = 1; + * this.b = 2; + * } * - * // Invoke `sendMail` when clicked, debouncing subsequent calls. - * jQuery(element).on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); + * Foo.prototype.c = 3; * - * // Ensure `batchLog` is invoked once after 1 second of debounced calls. - * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); - * var source = new EventSource('/stream'); - * jQuery(source).on('message', debounced); + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) * - * // Cancel the trailing debounced invocation. - * jQuery(window).on('popstate', debounced.cancel); + * _.keys('hi'); + * // => ['0', '1'] */ -function debounce(func, wait, options) { - var lastArgs, - lastThis, - maxWait, - result, - timerId, - lastCallTime, - lastInvokeTime = 0, - leading = false, - maxing = false, - trailing = true; +function keys$1(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$5); - } - wait = toNumber(wait) || 0; - if (isObject(options)) { - leading = !!options.leading; - maxing = 'maxWait' in options; - maxWait = maxing ? nativeMax$5(toNumber(options.maxWait) || 0, wait) : maxWait; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } +/** Used for built-in method references. */ +var objectProto$5 = Object.prototype; - function invokeFunc(time) { - var args = lastArgs, - thisArg = lastThis; +/** Used to check objects for own properties. */ +var hasOwnProperty$4 = objectProto$5.hasOwnProperty; - lastArgs = lastThis = undefined; - lastInvokeTime = time; - result = func.apply(thisArg, args); - return result; +/** + * Assigns own enumerable string keyed properties of source objects to the + * destination object. Source objects are applied from left to right. + * Subsequent sources overwrite property assignments of previous sources. + * + * **Note:** This method mutates `object` and is loosely based on + * [`Object.assign`](https://mdn.io/Object/assign). + * + * @static + * @memberOf _ + * @since 0.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.assignIn + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assign({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'c': 3 } + */ +var assign$1 = createAssigner(function (object, source) { + if (isPrototype(source) || isArrayLike(source)) { + copyObject(source, keys$1(source), object); + return; } - - function leadingEdge(time) { - // Reset any `maxWait` timer. - lastInvokeTime = time; - // Start the timer for the trailing edge. - timerId = setTimeout(timerExpired, wait); - // Invoke the leading edge. - return leading ? invokeFunc(time) : result; + for (var key in source) { + if (hasOwnProperty$4.call(source, key)) { + assignValue(object, key, source[key]); + } } +}); - function remainingWait(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime, - result = wait - timeSinceLastCall; - - return maxing ? nativeMin$3(result, maxWait - timeSinceLastInvoke) : result; +/** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } } + return result; +} - function shouldInvoke(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime; +/** Used for built-in method references. */ +var objectProto$11 = Object.prototype; - // Either this is the first call, activity has stopped and we're at the - // trailing edge, the system time has gone backwards and we're treating - // it as the trailing edge, or we've hit the `maxWait` limit. - return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; - } +/** Used to check objects for own properties. */ +var hasOwnProperty$9 = objectProto$11.hasOwnProperty; - function timerExpired() { - var time = now$1(); - if (shouldInvoke(time)) { - return trailingEdge(time); - } - // Restart the timer. - timerId = setTimeout(timerExpired, remainingWait(time)); - } - - function trailingEdge(time) { - timerId = undefined; - - // Only invoke if we have `lastArgs` which means `func` has been - // debounced at least once. - if (trailing && lastArgs) { - return invokeFunc(time); - } - lastArgs = lastThis = undefined; - return result; - } - - function cancel() { - if (timerId !== undefined) { - clearTimeout(timerId); - } - lastInvokeTime = 0; - lastArgs = lastCallTime = lastThis = timerId = undefined; - } - - function flush() { - return timerId === undefined ? result : trailingEdge(now$1()); +/** + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeysIn(object) { + if (!isObject(object)) { + return nativeKeysIn(object); } + var isProto = isPrototype(object), + result = []; - function debounced() { - var time = now$1(), - isInvoking = shouldInvoke(time); - - lastArgs = arguments; - lastThis = this; - lastCallTime = time; - - if (isInvoking) { - if (timerId === undefined) { - return leadingEdge(lastCallTime); - } - if (maxing) { - // Handle invocations in a tight loop. - timerId = setTimeout(timerExpired, wait); - return invokeFunc(lastCallTime); - } - } - if (timerId === undefined) { - timerId = setTimeout(timerExpired, wait); + for (var key in object) { + if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) { + result.push(key); } - return result; } - debounced.cancel = cancel; - debounced.flush = flush; - return debounced; + return result; } /** - * Checks `value` to determine whether a default value should be returned in - * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, - * or `undefined`. + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. * * @static * @memberOf _ - * @since 4.14.0 - * @category Util - * @param {*} value The value to check. - * @param {*} defaultValue The default value. - * @returns {*} Returns the resolved value. + * @since 3.0.0 + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. * @example * - * _.defaultTo(1, 10); - * // => 1 + * function Foo() { + * this.a = 1; + * this.b = 2; + * } * - * _.defaultTo(undefined, 10); - * // => 10 - */ -function defaultTo(value, defaultValue) { - return value == null || value !== value ? defaultValue : value; -} - -/** Used for built-in method references. */ -var objectProto$20 = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty$17 = objectProto$20.hasOwnProperty; - -/** - * Used by `_.defaults` to customize its `_.assignIn` use to assign properties - * of source objects to the destination object for all destination properties - * that resolve to `undefined`. + * Foo.prototype.c = 3; * - * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to assign. - * @param {Object} object The parent object of `objValue`. - * @returns {*} Returns the value to assign. + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ -function customDefaultsAssignIn(objValue, srcValue, key, object) { - if (objValue === undefined || eq(objValue, objectProto$20[key]) && !hasOwnProperty$17.call(object, key)) { - return srcValue; - } - return objValue; +function keysIn$1(object) { + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } /** - * Assigns own and inherited enumerable string keyed properties of source - * objects to the destination object for all destination properties that - * resolve to `undefined`. Source objects are applied from left to right. - * Once a property is set, additional values of the same property are ignored. + * This method is like `_.assign` except that it iterates over own and + * inherited source properties. * * **Note:** This method mutates `object`. * * @static - * @since 0.1.0 * @memberOf _ + * @since 4.0.0 + * @alias extend * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. - * @see _.defaultsDeep + * @see _.assign * @example * - * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); - * // => { 'a': 1, 'b': 2 } + * function Foo() { + * this.a = 1; + * } + * + * function Bar() { + * this.c = 3; + * } + * + * Foo.prototype.b = 2; + * Bar.prototype.d = 4; + * + * _.assignIn({ 'a': 0 }, new Foo, new Bar); + * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } */ -var defaults$1 = baseRest(function (args) { - args.push(undefined, customDefaultsAssignIn); - return apply$1(assignInWith, undefined, args); +var assignIn = createAssigner(function (object, source) { + copyObject(source, keysIn$1(source), object); }); /** - * This function is like `assignValue` except that it doesn't assign - * `undefined` values. + * This method is like `_.assignIn` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). * - * @private - * @param {Object} object The object to modify. - * @param {string} key The key of the property to assign. - * @param {*} value The value to assign. - */ -function assignMergeValue(object, key, value) { - if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) { - baseAssignValue(object, key, value); - } -} - -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. + * **Note:** This method mutates `object`. * * @static * @memberOf _ * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. + * @alias extendWith + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignWith * @example * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; + * } * - * _.isArrayLikeObject('abc'); - * // => false + * var defaults = _.partialRight(_.assignInWith, customizer); * - * _.isArrayLikeObject(_.noop); - * // => false + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} +var assignInWith = createAssigner(function (object, source, srcIndex, customizer) { + copyObject(source, keysIn$1(source), object, customizer); +}); /** - * Converts `value` to a plain object flattening inherited enumerable string - * keyed properties of `value` to own properties of the plain object. + * This method is like `_.assign` except that it accepts `customizer` + * which is invoked to produce the assigned values. If `customizer` returns + * `undefined`, assignment is handled by the method instead. The `customizer` + * is invoked with five arguments: (objValue, srcValue, key, object, source). + * + * **Note:** This method mutates `object`. * * @static * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {Object} Returns the converted plain object. + * @since 4.0.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @see _.assignInWith * @example * - * function Foo() { - * this.b = 2; + * function customizer(objValue, srcValue) { + * return _.isUndefined(objValue) ? srcValue : objValue; * } * - * Foo.prototype.c = 3; + * var defaults = _.partialRight(_.assignWith, customizer); * - * _.assign({ 'a': 1 }, new Foo); + * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } - * - * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); - * // => { 'a': 1, 'b': 2, 'c': 3 } */ -function toPlainObject(value) { - return copyObject(value, keysIn$1(value)); -} +var assignWith = createAssigner(function (object, source, srcIndex, customizer) { + copyObject(source, keys$1(source), object, customizer); +}); + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; +var reIsPlainProp = /^\w*$/; /** - * A specialized version of `baseMerge` for arrays and objects which performs - * deep merges and tracks traversed objects enabling objects with circular - * references to be merged. + * Checks if `value` is a property name and not a property path. * * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {string} key The key of the value to merge. - * @param {number} srcIndex The index of `source`. - * @param {Function} mergeFunc The function to merge values. - * @param {Function} [customizer] The function to customize assigned values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ -function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { - var objValue = object[key], - srcValue = source[key], - stacked = stack.get(srcValue); - - if (stacked) { - assignMergeValue(object, key, stacked); - return; - } - var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined; - - var isCommon = newValue === undefined; - - if (isCommon) { - var isArr = isArray$1(srcValue), - isBuff = !isArr && isBuffer(srcValue), - isTyped = !isArr && !isBuff && isTypedArray$1(srcValue); - - newValue = srcValue; - if (isArr || isBuff || isTyped) { - if (isArray$1(objValue)) { - newValue = objValue; - } else if (isArrayLikeObject(objValue)) { - newValue = copyArray$1(objValue); - } else if (isBuff) { - isCommon = false; - newValue = cloneBuffer(srcValue, true); - } else if (isTyped) { - isCommon = false; - newValue = cloneTypedArray(srcValue, true); - } else { - newValue = []; - } - } else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = objValue; - if (isArguments(objValue)) { - newValue = toPlainObject(objValue); - } else if (!isObject(objValue) || srcIndex && isFunction(objValue)) { - newValue = initCloneObject(srcValue); - } - } else { - isCommon = false; - } +function isKey(value, object) { + if (isArray$1(value)) { + return false; } - if (isCommon) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, newValue); - mergeFunc(newValue, srcValue, srcIndex, customizer, stack); - stack['delete'](srcValue); + var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); + if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) { + return true; } - assignMergeValue(object, key, newValue); + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object); } +/* Built-in method references that are verified to be native. */ +var nativeCreate = getNative(Object, 'create'); + /** - * The base implementation of `_.merge` without support for multiple sources. + * Removes all key-value entries from the hash. * * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {number} srcIndex The index of `source`. - * @param {Function} [customizer] The function to customize merged values. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. + * @name clear + * @memberOf Hash */ -function baseMerge(object, source, srcIndex, customizer, stack) { - if (object === source) { - return; - } - baseFor(source, function (srcValue, key) { - if (isObject(srcValue)) { - stack || (stack = new Stack()); - baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); - } else { - var newValue = customizer ? customizer(object[key], srcValue, key + '', object, source, stack) : undefined; - - if (newValue === undefined) { - newValue = srcValue; - } - assignMergeValue(object, key, newValue); - } - }, keysIn$1); +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; + this.size = 0; } /** - * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source - * objects into destination objects that are passed thru. + * Removes `key` and its value from the hash. * * @private - * @param {*} objValue The destination value. - * @param {*} srcValue The source value. - * @param {string} key The key of the property to merge. - * @param {Object} object The parent object of `objValue`. - * @param {Object} source The parent object of `srcValue`. - * @param {Object} [stack] Tracks traversed source values and their merged - * counterparts. - * @returns {*} Returns the value to assign. + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { - if (isObject(objValue) && isObject(srcValue)) { - // Recursively merge objects and arrays (susceptible to call stack limits). - stack.set(srcValue, objValue); - baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); - stack['delete'](srcValue); - } - return objValue; +function hashDelete(key) { + var result = this.has(key) && delete this.__data__[key]; + this.size -= result ? 1 : 0; + return result; } +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; + +/** Used for built-in method references. */ +var objectProto$12 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$10 = objectProto$12.hasOwnProperty; + /** - * This method is like `_.merge` except that it accepts `customizer` which - * is invoked to produce the merged values of the destination and source - * properties. If `customizer` returns `undefined`, merging is handled by the - * method instead. The `customizer` is invoked with six arguments: - * (objValue, srcValue, key, object, source, stack). - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} sources The source objects. - * @param {Function} customizer The function to customize assigned values. - * @returns {Object} Returns `object`. - * @example - * - * function customizer(objValue, srcValue) { - * if (_.isArray(objValue)) { - * return objValue.concat(srcValue); - * } - * } - * - * var object = { 'a': [1], 'b': [2] }; - * var other = { 'a': [3], 'b': [4] }; + * Gets the hash value for `key`. * - * _.mergeWith(object, other, customizer); - * // => { 'a': [1, 3], 'b': [2, 4] } + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -var mergeWith = createAssigner(function (object, source, srcIndex, customizer) { - baseMerge(object, source, srcIndex, customizer); -}); +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; + } + return hasOwnProperty$10.call(data, key) ? data[key] : undefined; +} + +/** Used for built-in method references. */ +var objectProto$13 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$11 = objectProto$13.hasOwnProperty; /** - * This method is like `_.defaults` except that it recursively assigns - * default properties. - * - * **Note:** This method mutates `object`. - * - * @static - * @memberOf _ - * @since 3.10.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. - * @see _.defaults - * @example + * Checks if a hash value for `key` exists. * - * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); - * // => { 'a': { 'b': 2, 'c': 3 } } + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -var defaultsDeep = baseRest(function (args) { - args.push(undefined, customDefaultsMerge); - return apply$1(mergeWith, undefined, args); -}); +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? data[key] !== undefined : hasOwnProperty$11.call(data, key); +} -/** Error message constants. */ -var FUNC_ERROR_TEXT$6 = 'Expected a function'; +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; /** - * The base implementation of `_.delay` and `_.defer` which accepts `args` - * to provide to `func`. + * Sets the hash `key` to `value`. * * @private - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {Array} args The arguments to provide to `func`. - * @returns {number|Object} Returns the timer id or timeout object. + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. */ -function baseDelay(func, wait, args) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$6); - } - return setTimeout(function () { - func.apply(undefined, args); - }, wait); +function hashSet(key, value) { + var data = this.__data__; + this.size += this.has(key) ? 0 : 1; + data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value; + return this; } /** - * Defers invoking the `func` until the current call stack has cleared. Any - * additional arguments are provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to defer. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {number} Returns the timer id. - * @example + * Creates a hash object. * - * _.defer(function(text) { - * console.log(text); - * }, 'deferred'); - * // => Logs 'deferred' after one millisecond. + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -var defer = baseRest(function (func, args) { - return baseDelay(func, 1, args); -}); +function Hash(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); + } +} + +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; /** - * Invokes `func` after `wait` milliseconds. Any additional arguments are - * provided to `func` when it's invoked. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay invocation. - * @param {...*} [args] The arguments to invoke `func` with. - * @returns {number} Returns the timer id. - * @example + * Removes all key-value entries from the list cache. * - * _.delay(function(text) { - * console.log(text); - * }, 1000, 'later'); - * // => Logs 'later' after one second. + * @private + * @name clear + * @memberOf ListCache */ -var delay = baseRest(function (func, wait, args) { - return baseDelay(func, toNumber(wait) || 0, args); -}); +function listCacheClear() { + this.__data__ = []; + this.size = 0; +} /** - * This function is like `arrayIncludes` except that it accepts a comparator. + * Gets the index at which the `key` is found in `array` of key-value pairs. * * @private - * @param {Array} [array] The array to inspect. - * @param {*} target The value to search for. - * @param {Function} comparator The comparator invoked per element. - * @returns {boolean} Returns `true` if `target` is found, else `false`. + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. */ -function arrayIncludesWith(array, value, comparator) { - var index = -1, - length = array == null ? 0 : array.length; - - while (++index < length) { - if (comparator(value, array[index])) { - return true; +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; } } - return false; + return -1; } -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE$1 = 200; +/** Used for built-in method references. */ +var arrayProto = Array.prototype; + +/** Built-in value references. */ +var splice = arrayProto.splice; /** - * The base implementation of methods like `_.difference` without support - * for excluding multiple arrays or iteratee shorthands. + * Removes `key` and its value from the list cache. * * @private - * @param {Array} array The array to inspect. - * @param {Array} values The values to exclude. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function baseDifference(array, values, iteratee, comparator) { - var index = -1, - includes = arrayIncludes, - isCommon = true, - length = array.length, - result = [], - valuesLength = values.length; +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); - if (!length) { - return result; - } - if (iteratee) { - values = arrayMap(values, baseUnary(iteratee)); - } - if (comparator) { - includes = arrayIncludesWith; - isCommon = false; - } else if (values.length >= LARGE_ARRAY_SIZE$1) { - includes = cacheHas; - isCommon = false; - values = new SetCache(values); + if (index < 0) { + return false; } - outer: while (++index < length) { - var value = array[index], - computed = iteratee == null ? value : iteratee(value); - - value = comparator || value !== 0 ? value : 0; - if (isCommon && computed === computed) { - var valuesIndex = valuesLength; - while (valuesIndex--) { - if (values[valuesIndex] === computed) { - continue outer; - } - } - result.push(value); - } else if (!includes(values, computed, comparator)) { - result.push(value); - } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); } - return result; + --this.size; + return true; } /** - * Creates an array of `array` values not included in the other given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. - * - * **Note:** Unlike `_.pullAll`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @returns {Array} Returns the new array of filtered values. - * @see _.without, _.xor - * @example + * Gets the list cache value for `key`. * - * _.difference([2, 1], [2, 3]); - * // => [1] + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -var difference = baseRest(function (array, values) { - return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) : []; -}); +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); + + return index < 0 ? undefined : data[index][1]; +} /** - * Gets the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the last element of `array`. - * @example + * Checks if a list cache value for `key` exists. * - * _.last([1, 2, 3]); - * // => 3 + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function last$1(array) { - var length = array == null ? 0 : array.length; - return length ? array[length - 1] : undefined; +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; } /** - * This method is like `_.difference` except that it accepts `iteratee` which - * is invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * **Note:** Unlike `_.pullAllBy`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example - * - * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [1.2] + * Sets the list cache `key` to `value`. * - * // The `_.property` iteratee shorthand. - * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); - * // => [{ 'x': 2 }] + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. */ -var differenceBy = baseRest(function (array, values) { - var iteratee = last$1(values); - if (isArrayLikeObject(iteratee)) { - iteratee = undefined; +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); + + if (index < 0) { + ++this.size; + data.push([key, value]); + } else { + data[index][1] = value; } - return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2)) : []; -}); + return this; +} /** - * This method is like `_.difference` except that it accepts `comparator` - * which is invoked to compare elements of `array` to `values`. The order and - * references of result values are determined by the first array. The comparator - * is invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `_.pullAllWith`, this method returns a new array. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {...Array} [values] The values to exclude. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of filtered values. - * @example + * Creates an list cache object. * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * - * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); - * // => [{ 'x': 2, 'y': 1 }] + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -var differenceWith = baseRest(function (array, values) { - var comparator = last$1(values); - if (isArrayLikeObject(comparator)) { - comparator = undefined; +function ListCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); } - return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) : []; -}); +} -/** - * Divide two numbers. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Math - * @param {number} dividend The first number in a division. - * @param {number} divisor The second number in a division. - * @returns {number} Returns the quotient. - * @example - * - * _.divide(6, 4); - * // => 1.5 - */ -var divide$1 = createMathOperation(function (dividend, divisor) { - return dividend / divisor; -}, 1); +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +/* Built-in method references that are verified to be native. */ +var Map$1 = getNative(root, 'Map'); /** - * Creates a slice of `array` with `n` elements dropped from the beginning. - * - * @static - * @memberOf _ - * @since 0.5.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.drop([1, 2, 3]); - * // => [2, 3] - * - * _.drop([1, 2, 3], 2); - * // => [3] - * - * _.drop([1, 2, 3], 5); - * // => [] + * Removes all key-value entries from the map. * - * _.drop([1, 2, 3], 0); - * // => [1, 2, 3] + * @private + * @name clear + * @memberOf MapCache */ -function drop(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = guard || n === undefined ? 1 : toInteger(n); - return baseSlice(array, n < 0 ? 0 : n, length); +function mapCacheClear() { + this.size = 0; + this.__data__ = { + 'hash': new Hash(), + 'map': new (Map$1 || ListCache)(), + 'string': new Hash() + }; } /** - * Creates a slice of `array` with `n` elements dropped from the end. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to drop. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. - * @example - * - * _.dropRight([1, 2, 3]); - * // => [1, 2] - * - * _.dropRight([1, 2, 3], 2); - * // => [1] - * - * _.dropRight([1, 2, 3], 5); - * // => [] + * Checks if `value` is suitable for use as unique object key. * - * _.dropRight([1, 2, 3], 0); - * // => [1, 2, 3] + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ -function dropRight(array, n, guard) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - n = guard || n === undefined ? 1 : toInteger(n); - n = length - n; - return baseSlice(array, 0, n < 0 ? 0 : n); +function isKeyable(value) { + var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); + return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null; } /** - * The base implementation of methods like `_.dropWhile` and `_.takeWhile` - * without support for iteratee shorthands. + * Gets the data for `map`. * * @private - * @param {Array} array The array to query. - * @param {Function} predicate The function invoked per iteration. - * @param {boolean} [isDrop] Specify dropping elements instead of taking them. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the slice of `array`. + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. */ -function baseWhile(array, predicate, isDrop, fromRight) { - var length = array.length, - index = fromRight ? length : -1; - - while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} - - return isDrop ? baseSlice(array, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array, fromRight ? index + 1 : 0, fromRight ? length : index); +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; } /** - * Creates a slice of `array` excluding elements dropped from the end. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.dropRightWhile(users, function(o) { return !o.active; }); - * // => objects for ['barney'] - * - * // The `_.matches` iteratee shorthand. - * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); - * // => objects for ['barney', 'fred'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.dropRightWhile(users, ['active', false]); - * // => objects for ['barney'] + * Removes `key` and its value from the map. * - * // The `_.property` iteratee shorthand. - * _.dropRightWhile(users, 'active'); - * // => objects for ['barney', 'fred', 'pebbles'] + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function dropRightWhile(array, predicate) { - return array && array.length ? baseWhile(array, baseIteratee(predicate, 3), true, true) : []; +function mapCacheDelete(key) { + var result = getMapData(this, key)['delete'](key); + this.size -= result ? 1 : 0; + return result; } /** - * Creates a slice of `array` excluding elements dropped from the beginning. - * Elements are dropped until `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index, array). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.dropWhile(users, function(o) { return !o.active; }); - * // => objects for ['pebbles'] - * - * // The `_.matches` iteratee shorthand. - * _.dropWhile(users, { 'user': 'barney', 'active': false }); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.dropWhile(users, ['active', false]); - * // => objects for ['pebbles'] + * Gets the map value for `key`. * - * // The `_.property` iteratee shorthand. - * _.dropWhile(users, 'active'); - * // => objects for ['barney', 'fred', 'pebbles'] + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -function dropWhile(array, predicate) { - return array && array.length ? baseWhile(array, baseIteratee(predicate, 3), true) : []; +function mapCacheGet(key) { + return getMapData(this, key).get(key); } /** - * Casts `value` to `identity` if it's not a function. + * Checks if a map value for `key` exists. * * @private - * @param {*} value The value to inspect. - * @returns {Function} Returns cast function. + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function castFunction(value) { - return typeof value == 'function' ? value : identity$1; +function mapCacheHas(key) { + return getMapData(this, key).has(key); } /** - * Iterates over elements of `collection` and invokes `iteratee` for each element. - * The iteratee is invoked with three arguments: (value, index|key, collection). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * **Note:** As with other "Collections" methods, objects with a "length" - * property are iterated like arrays. To avoid this behavior use `_.forIn` - * or `_.forOwn` for object iteration. + * Sets the map `key` to `value`. * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias each - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEachRight - * @example - * - * _.forEach([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `1` then `2`. - * - * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. */ -function forEach$1(collection, iteratee) { - var func = isArray$1(collection) ? arrayEach : baseEach; - return func(collection, castFunction(iteratee)); +function mapCacheSet(key, value) { + var data = getMapData(this, key), + size = data.size; + + data.set(key, value); + this.size += data.size == size ? 0 : 1; + return this; } /** - * A specialized version of `_.forEachRight` for arrays without support for - * iteratee shorthands. + * Creates a map cache object to store key-value pairs. * * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function arrayEachRight(array, iteratee) { - var length = array == null ? 0 : array.length; +function MapCache(entries) { + var index = -1, + length = entries == null ? 0 : entries.length; - while (length--) { - if (iteratee(array[length], length, array) === false) { - break; - } + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); } - return array; } -/** - * This function is like `baseFor` except that it iterates over properties - * in the opposite order. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -var baseForRight = createBaseFor(true); +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; -/** - * The base implementation of `_.forOwnRight` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -function baseForOwnRight(object, iteratee) { - return object && baseForRight(object, iteratee, keys$1); -} +/** Error message constants. */ +var FUNC_ERROR_TEXT$2 = 'Expected a function'; /** - * The base implementation of `_.forEachRight` without support for iteratee shorthands. + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - */ -var baseEachRight = createBaseEach(baseForOwnRight, true); - -/** - * This method is like `_.forEach` except that it iterates over elements of - * `collection` from right to left. + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `clear`, `delete`, `get`, `has`, and `set`. * * @static * @memberOf _ - * @since 2.0.0 - * @alias eachRight - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object} Returns `collection`. - * @see _.forEach + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. * @example * - * _.forEachRight([1, 2], function(value) { - * console.log(value); - * }); - * // => Logs `2` then `1`. - */ -function forEachRight(collection, iteratee) { - var func = isArray$1(collection) ? arrayEachRight : baseEachRight; - return func(collection, castFunction(iteratee)); -} - -/** - * Checks if `string` ends with the given target string. + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=string.length] The position to search up to. - * @returns {boolean} Returns `true` if `string` ends with `target`, - * else `false`. - * @example + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] * - * _.endsWith('abc', 'c'); - * // => true + * values(other); + * // => [3, 4] * - * _.endsWith('abc', 'b'); - * // => false + * object.a = 2; + * values(object); + * // => [1, 2] * - * _.endsWith('abc', 'b', 2); - * // => true + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; */ -function endsWith$1(string, target, position) { - string = toString$1(string); - target = baseToString(target); - - var length = string.length; - position = position === undefined ? length : baseClamp(toInteger(position), 0, length); +function memoize$1(func, resolver) { + if (typeof func != 'function' || resolver != null && typeof resolver != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$2); + } + var memoized = function memoized() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; - var end = position; - position -= target.length; - return position >= 0 && string.slice(position, end) == target; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result) || cache; + return result; + }; + memoized.cache = new (memoize$1.Cache || MapCache)(); + return memoized; } +// Expose `MapCache`. +memoize$1.Cache = MapCache; + +/** Used as the maximum memoize cache size. */ +var MAX_MEMOIZE_SIZE = 500; + /** - * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array - * of key-value pairs for `object` corresponding to the property names of `props`. + * A specialized version of `_.memoize` which clears the memoized function's + * cache when it exceeds `MAX_MEMOIZE_SIZE`. * * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the key-value pairs. + * @param {Function} func The function to have its output memoized. + * @returns {Function} Returns the new memoized function. */ -function baseToPairs(object, props) { - return arrayMap(props, function (key) { - return [key, object[key]]; +function memoizeCapped(func) { + var result = memoize$1(func, function (key) { + if (cache.size === MAX_MEMOIZE_SIZE) { + cache.clear(); + } + return key; }); + + var cache = result.cache; + return result; } +/** Used to match property names within property paths. */ +var reLeadingDot = /^\./; +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; + +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; + /** - * Converts `set` to its value-value pairs. + * Converts `string` to a property path array. * * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the value-value pairs. + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. */ -function setToPairs(set) { - var index = -1, - result = Array(set.size); - - set.forEach(function (value) { - result[++index] = [value, value]; +var stringToPath = memoizeCapped(function (string) { + var result = []; + if (reLeadingDot.test(string)) { + result.push(''); + } + string.replace(rePropName, function (match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, '$1') : number || match); }); return result; -} - -/** `Object#toString` result references. */ -var mapTag$5 = '[object Map]'; -var setTag$5 = '[object Set]'; +}); /** - * Creates a `_.toPairs` or `_.toPairsIn` function. - * - * @private - * @param {Function} keysFunc The function to get the keys of a given object. - * @returns {Function} Returns the new pairs function. - */ -function createToPairs(keysFunc) { - return function (object) { - var tag = getTag$1(object); - if (tag == mapTag$5) { - return mapToArray(object); - } - if (tag == setTag$5) { - return setToPairs(object); - } - return baseToPairs(object, keysFunc(object)); - }; -} - -/** - * Creates an array of own enumerable string keyed-value pairs for `object` - * which can be consumed by `_.fromPairs`. If `object` is a map or set, its - * entries are returned. + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. * * @static * @memberOf _ * @since 4.0.0 - * @alias entries - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the key-value pairs. + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. * @example * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } + * _.toString(null); + * // => '' * - * Foo.prototype.c = 3; + * _.toString(-0); + * // => '-0' * - * _.toPairs(new Foo); - * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) + * _.toString([1, 2, 3]); + * // => '1,2,3' */ -var toPairs = createToPairs(keys$1); +function toString$1(value) { + return value == null ? '' : baseToString(value); +} /** - * Creates an array of own and inherited enumerable string keyed-value pairs - * for `object` which can be consumed by `_.fromPairs`. If `object` is a map - * or set, its entries are returned. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @alias entriesIn - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the key-value pairs. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Casts `value` to a path array if it's not one. * - * _.toPairsIn(new Foo); - * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) + * @private + * @param {*} value The value to inspect. + * @param {Object} [object] The object to query keys on. + * @returns {Array} Returns the cast property path array. */ -var toPairsIn = createToPairs(keysIn$1); +function castPath(value, object) { + if (isArray$1(value)) { + return value; + } + return isKey(value, object) ? [value] : stringToPath(toString$1(value)); +} -/** Used to map characters to HTML entities. */ -var htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' -}; +/** Used as references for various `Number` constants. */ +var INFINITY$2 = 1 / 0; /** - * Used by `_.escape` to convert characters to HTML entities. + * Converts `value` to a string key if it's not a string or symbol. * * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. */ -var escapeHtmlChar = basePropertyOf(htmlEscapes); - -/** Used to match HTML entities and HTML characters. */ -var reUnescapedHtml = /[&<>"']/g; -var reHasUnescapedHtml = RegExp(reUnescapedHtml.source); +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = value + ''; + return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result; +} /** - * Converts the characters "&", "<", ">", '"', and "'" in `string` to their - * corresponding HTML entities. - * - * **Note:** No other characters are escaped. To escape additional - * characters use a third-party library like [_he_](https://mths.be/he). - * - * Though the ">" character is escaped for symmetry, characters like - * ">" and "/" don't need escaping in HTML and have no special meaning - * unless they're part of a tag or unquoted attribute value. See - * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) - * (under "semi-related fun fact") for more details. - * - * When working with HTML you should always - * [quote attribute values](http://wonko.com/post/html-escaping) to reduce - * XSS vectors. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. - * @example + * The base implementation of `_.get` without support for default values. * - * _.escape('fred, barney, & pebbles'); - * // => 'fred, barney, & pebbles' + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. */ -function escape$1(string) { - string = toString$1(string); - return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; -} +function baseGet(object, path) { + path = castPath(path, object); -/** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). - */ -var reRegExpChar$1 = /[\\^$.*+?()[\]{}|]/g; -var reHasRegExpChar = RegExp(reRegExpChar$1.source); + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return index && index == length ? object : undefined; +} /** - * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", - * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to escape. - * @returns {string} Returns the escaped string. + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. * @example * - * _.escapeRegExp('[lodash](https://lodash.com/)'); - * // => '\[lodash\]\(https://lodash\.com/\)' + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' */ -function escapeRegExp(string) { - string = toString$1(string); - return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar$1, '\\$&') : string; +function get$2(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; } /** - * A specialized version of `_.every` for arrays without support for - * iteratee shorthands. + * The base implementation of `_.at` without support for individual paths. * * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. + * @param {Object} object The object to iterate over. + * @param {string[]} paths The property paths to pick. + * @returns {Array} Returns the picked elements. */ -function arrayEvery(array, predicate) { +function baseAt(object, paths) { var index = -1, - length = array == null ? 0 : array.length; + length = paths.length, + result = Array(length), + skip = object == null; while (++index < length) { - if (!predicate(array[index], index, array)) { - return false; - } + result[index] = skip ? undefined : get$2(object, paths[index]); } - return true; + return result; } /** - * The base implementation of `_.every` without support for iteratee shorthands. + * Appends the elements of `values` to `array`. * * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false` + * @param {Array} array The array to modify. + * @param {Array} values The values to append. + * @returns {Array} Returns `array`. */ -function baseEvery(collection, predicate) { - var result = true; - baseEach(collection, function (value, index, collection) { - result = !!predicate(value, index, collection); - return result; - }); - return result; +function arrayPush(array, values) { + var index = -1, + length = values.length, + offset = array.length; + + while (++index < length) { + array[offset + index] = values[index]; + } + return array; } +/** Built-in value references. */ +var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined; + /** - * Checks if `predicate` returns truthy for **all** elements of `collection`. - * Iteration is stopped once `predicate` returns falsey. The predicate is - * invoked with three arguments: (value, index|key, collection). + * Checks if `value` is a flattenable `arguments` object or array. * - * **Note:** This method returns `true` for - * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because - * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of - * elements of empty collections. + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. + */ +function isFlattenable(value) { + return isArray$1(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]); +} + +/** + * The base implementation of `_.flatten` with support for restricting flattening. * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {boolean} Returns `true` if all elements pass the predicate check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes'], Boolean); - * // => false - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.every(users, { 'user': 'barney', 'active': false }); - * // => false - * - * // The `_.matchesProperty` iteratee shorthand. - * _.every(users, ['active', false]); - * // => true - * - * // The `_.property` iteratee shorthand. - * _.every(users, 'active'); - * // => false + * @private + * @param {Array} array The array to flatten. + * @param {number} depth The maximum recursion depth. + * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. + * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. + * @param {Array} [result=[]] The initial result value. + * @returns {Array} Returns the new flattened array. */ -function every$1(collection, predicate, guard) { - var func = isArray$1(collection) ? arrayEvery : baseEvery; - if (guard && isIterateeCall(collection, predicate, guard)) { - predicate = undefined; +function baseFlatten(array, depth, predicate, isStrict, result) { + var index = -1, + length = array.length; + + predicate || (predicate = isFlattenable); + result || (result = []); + + while (++index < length) { + var value = array[index]; + if (depth > 0 && predicate(value)) { + if (depth > 1) { + // Recursively flatten arrays (susceptible to call stack limits). + baseFlatten(value, depth - 1, predicate, isStrict, result); + } else { + arrayPush(result, value); + } + } else if (!isStrict) { + result[result.length] = value; + } } - return func(collection, baseIteratee(predicate, 3)); + return result; } -/** Used as references for the maximum length and index of an array. */ -var MAX_ARRAY_LENGTH$1 = 4294967295; - /** - * Converts `value` to an integer suitable for use as the length of an - * array-like object. - * - * **Note:** This method is based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * Flattens `array` a single level deep. * * @static * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to convert. - * @returns {number} Returns the converted integer. + * @since 0.1.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. * @example * - * _.toLength(3.2); - * // => 3 - * - * _.toLength(Number.MIN_VALUE); - * // => 0 - * - * _.toLength(Infinity); - * // => 4294967295 - * - * _.toLength('3.2'); - * // => 3 + * _.flatten([1, [2, [3, [4]], 5]]); + * // => [1, 2, [3, [4]], 5] */ -function toLength(value) { - return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH$1) : 0; +function flatten$1(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, 1) : []; } /** - * The base implementation of `_.fill` without an iteratee call guard. + * A specialized version of `baseRest` which flattens the rest array. * * @private - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. + * @param {Function} func The function to apply a rest parameter to. + * @returns {Function} Returns the new function. */ -function baseFill(array, value, start, end) { - var length = array.length; - - start = toInteger(start); - if (start < 0) { - start = -start > length ? 0 : length + start; - } - end = end === undefined || end > length ? length : toInteger(end); - if (end < 0) { - end += length; - } - end = start > end ? 0 : toLength(end); - while (start < end) { - array[start++] = value; - } - return array; +function flatRest(func) { + return setToString(overRest(func, undefined, flatten$1), func + ''); } /** - * Fills elements of `array` with `value` from `start` up to, but not - * including, `end`. - * - * **Note:** This method mutates `array`. + * Creates an array of values corresponding to `paths` of `object`. * * @static * @memberOf _ - * @since 3.2.0 - * @category Array - * @param {Array} array The array to fill. - * @param {*} value The value to fill `array` with. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns `array`. + * @since 1.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {...(string|string[])} [paths] The property paths to pick. + * @returns {Array} Returns the picked values. * @example * - * var array = [1, 2, 3]; - * - * _.fill(array, 'a'); - * console.log(array); - * // => ['a', 'a', 'a'] - * - * _.fill(Array(3), 2); - * // => [2, 2, 2] + * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; * - * _.fill([4, 6, 8, 10], '*', 1, 3); - * // => [4, '*', '*', 10] + * _.at(object, ['a[0].b.c', 'a[1]']); + * // => [3, 4] */ -function fill$1(array, value, start, end) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { - start = 0; - end = length; - } - return baseFill(array, value, start, end); -} +var at$1 = flatRest(baseAt); -/** - * The base implementation of `_.filter` without support for iteratee shorthands. - * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - */ -function baseFilter(collection, predicate) { - var result = []; - baseEach(collection, function (value, index, collection) { - if (predicate(value, index, collection)) { - result.push(value); - } - }); - return result; -} +/** Built-in value references. */ +var getPrototype = overArg(Object.getPrototypeOf, Object); + +/** `Object#toString` result references. */ +var objectTag$1 = '[object Object]'; + +/** Used for built-in method references. */ +var funcProto$2 = Function.prototype; +var objectProto$14 = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString$2 = funcProto$2.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty$12 = objectProto$14.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString$2.call(Object); /** - * Iterates over elements of `collection`, returning an array of all elements - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). - * - * **Note:** Unlike `_.remove`, this method returns a new array. + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. * * @static * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new filtered array. - * @see _.reject + * @since 0.8.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. * @example * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; + * function Foo() { + * this.a = 1; + * } * - * _.filter(users, function(o) { return !o.active; }); - * // => objects for ['fred'] + * _.isPlainObject(new Foo); + * // => false * - * // The `_.matches` iteratee shorthand. - * _.filter(users, { 'age': 36, 'active': true }); - * // => objects for ['barney'] + * _.isPlainObject([1, 2, 3]); + * // => false * - * // The `_.matchesProperty` iteratee shorthand. - * _.filter(users, ['active', false]); - * // => objects for ['fred'] + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true * - * // The `_.property` iteratee shorthand. - * _.filter(users, 'active'); - * // => objects for ['barney'] + * _.isPlainObject(Object.create(null)); + * // => true */ -function filter$1(collection, predicate) { - var func = isArray$1(collection) ? arrayFilter : baseFilter; - return func(collection, baseIteratee(predicate, 3)); +function isPlainObject(value) { + if (!isObjectLike(value) || baseGetTag(value) != objectTag$1) { + return false; + } + var proto = getPrototype(value); + if (proto === null) { + return true; + } + var Ctor = hasOwnProperty$12.call(proto, 'constructor') && proto.constructor; + return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString$2.call(Ctor) == objectCtorString; } +/** `Object#toString` result references. */ +var domExcTag = '[object DOMException]'; +var errorTag$1 = '[object Error]'; + /** - * Creates a `_.find` or `_.findLast` function. - * - * @private - * @param {Function} findIndexFunc The function to find the collection index. - * @returns {Function} Returns the new find function. - */ -function createFind(findIndexFunc) { - return function (collection, predicate, fromIndex) { - var iterable = Object(collection); - if (!isArrayLike(collection)) { - var iteratee = baseIteratee(predicate, 3); - collection = keys$1(collection); - predicate = function predicate(key) { - return iteratee(iterable[key], key, iterable); - }; - } - var index = findIndexFunc(collection, predicate, fromIndex); - return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; - }; -} - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$6 = Math.max; - -/** - * This method is like `_.find` except that it returns the index of the first - * element `predicate` returns truthy for instead of the element itself. + * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, + * `SyntaxError`, `TypeError`, or `URIError` object. * * @static * @memberOf _ - * @since 1.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. * @example * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.findIndex(users, function(o) { return o.user == 'barney'; }); - * // => 0 - * - * // The `_.matches` iteratee shorthand. - * _.findIndex(users, { 'user': 'fred', 'active': false }); - * // => 1 - * - * // The `_.matchesProperty` iteratee shorthand. - * _.findIndex(users, ['active', false]); - * // => 0 + * _.isError(new Error); + * // => true * - * // The `_.property` iteratee shorthand. - * _.findIndex(users, 'active'); - * // => 2 + * _.isError(Error); + * // => false */ -function findIndex$1(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax$6(length + index, 0); +function isError$1(value) { + if (!isObjectLike(value)) { + return false; } - return baseFindIndex(array, baseIteratee(predicate, 3), index); + var tag = baseGetTag(value); + return tag == errorTag$1 || tag == domExcTag || typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value); } /** - * Iterates over elements of `collection`, returning the first element - * `predicate` returns truthy for. The predicate is invoked with three - * arguments: (value, index|key, collection). + * Attempts to invoke `func`, returning either the result or the caught error + * object. Any additional arguments are provided to `func` when it's invoked. * * @static * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=0] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. + * @since 3.0.0 + * @category Util + * @param {Function} func The function to attempt. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {*} Returns the `func` result or error object. * @example * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false }, - * { 'user': 'pebbles', 'age': 1, 'active': true } - * ]; - * - * _.find(users, function(o) { return o.age < 40; }); - * // => object for 'barney' - * - * // The `_.matches` iteratee shorthand. - * _.find(users, { 'age': 1, 'active': true }); - * // => object for 'pebbles' - * - * // The `_.matchesProperty` iteratee shorthand. - * _.find(users, ['active', false]); - * // => object for 'fred' + * // Avoid throwing errors for invalid selectors. + * var elements = _.attempt(function(selector) { + * return document.querySelectorAll(selector); + * }, '>_>'); * - * // The `_.property` iteratee shorthand. - * _.find(users, 'active'); - * // => object for 'barney' + * if (_.isError(elements)) { + * elements = []; + * } */ -var find$1 = createFind(findIndex$1); +var attempt = baseRest(function (func, args) { + try { + return apply$1(func, undefined, args); + } catch (e) { + return isError$1(e) ? e : new Error(e); + } +}); + +/** Error message constants. */ +var FUNC_ERROR_TEXT$3 = 'Expected a function'; /** - * The base implementation of methods like `_.findKey` and `_.findLastKey`, - * without support for iteratee shorthands, which iterates over `collection` - * using `eachFunc`. + * Creates a function that invokes `func`, with the `this` binding and arguments + * of the created function, while it's called less than `n` times. Subsequent + * calls to the created function return the result of the last `func` invocation. * - * @private - * @param {Array|Object} collection The collection to inspect. - * @param {Function} predicate The function invoked per iteration. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the found element or its key, else `undefined`. + * @static + * @memberOf _ + * @since 3.0.0 + * @category Function + * @param {number} n The number of calls at which `func` is no longer invoked. + * @param {Function} func The function to restrict. + * @returns {Function} Returns the new restricted function. + * @example + * + * jQuery(element).on('click', _.before(5, addContactToList)); + * // => Allows adding up to 4 contacts to the list. */ -function baseFindKey(collection, predicate, eachFunc) { +function before(n, func) { var result; - eachFunc(collection, function (value, key, collection) { - if (predicate(value, key, collection)) { - result = key; - return false; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$3); + } + n = toInteger(n); + return function () { + if (--n > 0) { + result = func.apply(this, arguments); } - }); - return result; + if (n <= 1) { + func = undefined; + } + return result; + }; } +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$7 = 1; +var WRAP_PARTIAL_FLAG$3 = 32; + /** - * This method is like `_.find` except that it returns the key of the first - * element `predicate` returns truthy for instead of the element itself. + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and `partials` prepended to the arguments it receives. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" + * property of bound functions. * * @static * @memberOf _ - * @since 1.1.0 - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. + * @since 0.1.0 + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. * @example * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } - * }; - * - * _.findKey(users, function(o) { return o.age < 40; }); - * // => 'barney' (iteration order is not guaranteed) + * function greet(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } * - * // The `_.matches` iteratee shorthand. - * _.findKey(users, { 'age': 1, 'active': true }); - * // => 'pebbles' + * var object = { 'user': 'fred' }; * - * // The `_.matchesProperty` iteratee shorthand. - * _.findKey(users, ['active', false]); - * // => 'fred' + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' * - * // The `_.property` iteratee shorthand. - * _.findKey(users, 'active'); - * // => 'barney' + * // Bound with placeholders. + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' */ -function findKey(object, predicate) { - return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn); -} +var bind$1 = baseRest(function (func, thisArg, partials) { + var bitmask = WRAP_BIND_FLAG$7; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bind$1)); + bitmask |= WRAP_PARTIAL_FLAG$3; + } + return createWrap(func, bitmask, thisArg, partials, holders); +}); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$7 = Math.max; -var nativeMin$4 = Math.min; +// Assign default placeholders. +bind$1.placeholder = {}; /** - * This method is like `_.findIndex` except that it iterates over elements - * of `collection` from right to left. + * Binds methods of an object to the object itself, overwriting the existing + * method. + * + * **Note:** This method doesn't set the "length" property of bound functions. * * @static + * @since 0.1.0 * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); - * // => 2 - * - * // The `_.matches` iteratee shorthand. - * _.findLastIndex(users, { 'user': 'barney', 'active': true }); - * // => 0 + * @category Util + * @param {Object} object The object to bind and assign the bound methods to. + * @param {...(string|string[])} methodNames The object method names to bind. + * @returns {Object} Returns `object`. + * @example * - * // The `_.matchesProperty` iteratee shorthand. - * _.findLastIndex(users, ['active', false]); - * // => 2 + * var view = { + * 'label': 'docs', + * 'click': function() { + * console.log('clicked ' + this.label); + * } + * }; * - * // The `_.property` iteratee shorthand. - * _.findLastIndex(users, 'active'); - * // => 0 + * _.bindAll(view, ['click']); + * jQuery(element).on('click', view.click); + * // => Logs 'clicked docs' when clicked. */ -function findLastIndex(array, predicate, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = length - 1; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = fromIndex < 0 ? nativeMax$7(length + index, 0) : nativeMin$4(index, length - 1); - } - return baseFindIndex(array, baseIteratee(predicate, 3), index, true); -} +var bindAll = flatRest(function (object, methodNames) { + arrayEach(methodNames, function (key) { + key = toKey(key); + baseAssignValue(object, key, bind$1(object[key], object)); + }); + return object; +}); + +/** Used to compose bitmasks for function metadata. */ +var WRAP_BIND_FLAG$8 = 1; +var WRAP_BIND_KEY_FLAG$5 = 2; +var WRAP_PARTIAL_FLAG$4 = 32; /** - * This method is like `_.find` except that it iterates over elements of - * `collection` from right to left. + * Creates a function that invokes the method at `object[key]` with `partials` + * prepended to the arguments it receives. * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Collection - * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param {number} [fromIndex=collection.length-1] The index to search from. - * @returns {*} Returns the matched element, else `undefined`. - * @example + * This method differs from `_.bind` by allowing bound functions to reference + * methods that may be redefined or don't yet exist. See + * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) + * for more details. * - * _.findLast([1, 2, 3, 4], function(n) { - * return n % 2 == 1; - * }); - * // => 3 - */ -var findLast = createFind(findLastIndex); - -/** - * This method is like `_.findKey` except that it iterates over elements of - * a collection in the opposite order. + * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for partially applied arguments. * * @static * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to inspect. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {string|undefined} Returns the key of the matched element, - * else `undefined`. + * @since 0.10.0 + * @category Function + * @param {Object} object The object to invoke the method on. + * @param {string} key The key of the method. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. * @example * - * var users = { - * 'barney': { 'age': 36, 'active': true }, - * 'fred': { 'age': 40, 'active': false }, - * 'pebbles': { 'age': 1, 'active': true } + * var object = { + * 'user': 'fred', + * 'greet': function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * } * }; * - * _.findLastKey(users, function(o) { return o.age < 40; }); - * // => returns 'pebbles' assuming `_.findKey` returns 'barney' + * var bound = _.bindKey(object, 'greet', 'hi'); + * bound('!'); + * // => 'hi fred!' * - * // The `_.matches` iteratee shorthand. - * _.findLastKey(users, { 'age': 36, 'active': true }); - * // => 'barney' + * object.greet = function(greeting, punctuation) { + * return greeting + 'ya ' + this.user + punctuation; + * }; * - * // The `_.matchesProperty` iteratee shorthand. - * _.findLastKey(users, ['active', false]); - * // => 'fred' + * bound('!'); + * // => 'hiya fred!' * - * // The `_.property` iteratee shorthand. - * _.findLastKey(users, 'active'); - * // => 'pebbles' + * // Bound with placeholders. + * var bound = _.bindKey(object, 'greet', _, '!'); + * bound('hi'); + * // => 'hiya fred!' */ -function findLastKey(object, predicate) { - return baseFindKey(object, baseIteratee(predicate, 3), baseForOwnRight); -} +var bindKey = baseRest(function (object, key, partials) { + var bitmask = WRAP_BIND_FLAG$8 | WRAP_BIND_KEY_FLAG$5; + if (partials.length) { + var holders = replaceHolders(partials, getHolder(bindKey)); + bitmask |= WRAP_PARTIAL_FLAG$4; + } + return createWrap(key, bitmask, object, partials, holders); +}); -/** - * Gets the first element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @alias first - * @category Array - * @param {Array} array The array to query. - * @returns {*} Returns the first element of `array`. - * @example - * - * _.head([1, 2, 3]); - * // => 1 - * - * _.head([]); - * // => undefined - */ -function head$1(array) { - return array && array.length ? array[0] : undefined; -} +// Assign default placeholders. +bindKey.placeholder = {}; /** - * The base implementation of `_.map` without support for iteratee shorthands. + * The base implementation of `_.slice` without an iteratee call guard. * * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. */ -function baseMap(collection, iteratee) { +function baseSlice(array, start, end) { var index = -1, - result = isArrayLike(collection) ? Array(collection.length) : []; + length = array.length; - baseEach(collection, function (value, key, collection) { - result[++index] = iteratee(value, key, collection); - }); + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : end - start >>> 0; + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } return result; } /** - * Creates an array of values by running each element in `collection` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. - * - * The guarded methods are: - * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, - * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, - * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, - * `template`, `trim`, `trimEnd`, `trimStart`, and `words` - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - * @example - * - * function square(n) { - * return n * n; - * } - * - * _.map([4, 8], square); - * // => [16, 64] - * - * _.map({ 'a': 4, 'b': 8 }, square); - * // => [16, 64] (iteration order is not guaranteed) - * - * var users = [ - * { 'user': 'barney' }, - * { 'user': 'fred' } - * ]; + * Casts `array` to a slice if it's needed. * - * // The `_.property` iteratee shorthand. - * _.map(users, 'user'); - * // => ['barney', 'fred'] + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. */ -function map$1(collection, iteratee) { - var func = isArray$1(collection) ? arrayMap : baseMap; - return func(collection, baseIteratee(iteratee, 3)); +function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return !start && end >= length ? array : baseSlice(array, start, end); } -/** - * Creates a flattened array of values by running each element in `collection` - * thru `iteratee` and flattening the mapped results. The iteratee is invoked - * with three arguments: (value, index|key, collection). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [n, n]; - * } - * - * _.flatMap([1, 2], duplicate); - * // => [1, 1, 2, 2] - */ -function flatMap(collection, iteratee) { - return baseFlatten(map$1(collection, iteratee), 1); -} +/** Used to compose unicode character classes. */ +var rsAstralRange = '\\ud800-\\udfff'; +var rsComboMarksRange = '\\u0300-\\u036f'; +var reComboHalfMarksRange = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange = '\\u20d0-\\u20ff'; +var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; +var rsVarRange = '\\ufe0e\\ufe0f'; -/** Used as references for various `Number` constants. */ -var INFINITY$3 = 1 / 0; +/** Used to compose unicode capture groups. */ +var rsZWJ = '\\u200d'; + +/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ +var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); /** - * This method is like `_.flatMap` except that it recursively flattens the - * mapped results. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [[[n, n]]]; - * } + * Checks if `string` contains Unicode symbols. * - * _.flatMapDeep([1, 2], duplicate); - * // => [1, 1, 2, 2] + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. */ -function flatMapDeep(collection, iteratee) { - return baseFlatten(map$1(collection, iteratee), INFINITY$3); +function hasUnicode(string) { + return reHasUnicode.test(string); } /** - * This method is like `_.flatMap` except that it recursively flattens the - * mapped results up to `depth` times. - * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @example - * - * function duplicate(n) { - * return [[[n, n]]]; - * } + * Converts an ASCII `string` to an array. * - * _.flatMapDepth([1, 2], duplicate, 2); - * // => [[1, 1], [2, 2]] + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. */ -function flatMapDepth(collection, iteratee, depth) { - depth = depth === undefined ? 1 : toInteger(depth); - return baseFlatten(map$1(collection, iteratee), depth); +function asciiToArray(string) { + return string.split(''); } -/** Used as references for various `Number` constants. */ -var INFINITY$4 = 1 / 0; +/** Used to compose unicode character classes. */ +var rsAstralRange$1 = '\\ud800-\\udfff'; +var rsComboMarksRange$1 = '\\u0300-\\u036f'; +var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff'; +var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; +var rsVarRange$1 = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsAstral = '[' + rsAstralRange$1 + ']'; +var rsCombo = '[' + rsComboRange$1 + ']'; +var rsFitz = '\\ud83c[\\udffb-\\udfff]'; +var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')'; +var rsNonAstral = '[^' + rsAstralRange$1 + ']'; +var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; +var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; +var rsZWJ$1 = '\\u200d'; + +/** Used to compose unicode regexes. */ +var reOptMod = rsModifier + '?'; +var rsOptVar = '[' + rsVarRange$1 + ']?'; +var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*'; +var rsSeq = rsOptVar + reOptMod + rsOptJoin; +var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + +/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ +var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** - * Recursively flattens `array`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to flatten. - * @returns {Array} Returns the new flattened array. - * @example + * Converts a Unicode `string` to an array. * - * _.flattenDeep([1, [2, [3, [4]], 5]]); - * // => [1, 2, 3, 4, 5] + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. */ -function flattenDeep(array) { - var length = array == null ? 0 : array.length; - return length ? baseFlatten(array, INFINITY$4) : []; +function unicodeToArray(string) { + return string.match(reUnicode) || []; } /** - * Recursively flatten `array` up to `depth` times. - * - * @static - * @memberOf _ - * @since 4.4.0 - * @category Array - * @param {Array} array The array to flatten. - * @param {number} [depth=1] The maximum recursion depth. - * @returns {Array} Returns the new flattened array. - * @example - * - * var array = [1, [2, [3, [4]], 5]]; - * - * _.flattenDepth(array, 1); - * // => [1, 2, [3, [4]], 5] + * Converts `string` to an array. * - * _.flattenDepth(array, 2); - * // => [1, 2, 3, [4], 5] + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. */ -function flattenDepth(array, depth) { - var length = array == null ? 0 : array.length; - if (!length) { - return []; - } - depth = depth === undefined ? 1 : toInteger(depth); - return baseFlatten(array, depth); +function stringToArray(string) { + return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string); } -/** Used to compose bitmasks for function metadata. */ -var WRAP_FLIP_FLAG$2 = 512; +/** + * Creates a function like `_.lowerFirst`. + * + * @private + * @param {string} methodName The name of the `String` case method to use. + * @returns {Function} Returns the new case function. + */ +function createCaseFirst(methodName) { + return function (string) { + string = toString$1(string); + + var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined; + + var chr = strSymbols ? strSymbols[0] : string.charAt(0); + + var trailing = strSymbols ? castSlice(strSymbols, 1).join('') : string.slice(1); + + return chr[methodName]() + trailing; + }; +} /** - * Creates a function that invokes `func` with arguments reversed. + * Converts the first character of `string` to upper case. * * @static * @memberOf _ * @since 4.0.0 - * @category Function - * @param {Function} func The function to flip arguments for. - * @returns {Function} Returns the new flipped function. + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. * @example * - * var flipped = _.flip(function() { - * return _.toArray(arguments); - * }); + * _.upperFirst('fred'); + * // => 'Fred' * - * flipped('a', 'b', 'c', 'd'); - * // => ['d', 'c', 'b', 'a'] + * _.upperFirst('FRED'); + * // => 'FRED' */ -function flip(func) { - return createWrap(func, WRAP_FLIP_FLAG$2); -} +var upperFirst = createCaseFirst('toUpperCase'); /** - * Computes `number` rounded down to `precision`. + * Converts the first character of `string` to upper case and the remaining + * to lower case. * * @static * @memberOf _ - * @since 3.10.0 - * @category Math - * @param {number} number The number to round down. - * @param {number} [precision=0] The precision to round down to. - * @returns {number} Returns the rounded down number. + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. * @example * - * _.floor(4.006); - * // => 4 - * - * _.floor(0.046, 2); - * // => 0.04 - * - * _.floor(4060, -2); - * // => 4000 + * _.capitalize('FRED'); + * // => 'Fred' */ -var floor$1 = createRound('floor'); - -/** Error message constants. */ -var FUNC_ERROR_TEXT$7 = 'Expected a function'; - -/** Used to compose bitmasks for function metadata. */ -var WRAP_CURRY_FLAG$6 = 8; -var WRAP_PARTIAL_FLAG$5 = 32; -var WRAP_ARY_FLAG$4 = 128; -var WRAP_REARG_FLAG$2 = 256; +function capitalize(string) { + return upperFirst(toString$1(string).toLowerCase()); +} /** - * Creates a `_.flow` or `_.flowRight` function. + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. * * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new flow function. + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. */ -function createFlow(fromRight) { - return flatRest(function (funcs) { - var length = funcs.length, - index = length, - prereq = LodashWrapper.prototype.thru; +function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array == null ? 0 : array.length; - if (fromRight) { - funcs.reverse(); - } - while (index--) { - var func = funcs[index]; - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$7); - } - if (prereq && !wrapper && getFuncName(func) == 'wrapper') { - var wrapper = new LodashWrapper([], true); - } - } - index = wrapper ? index : length; - while (++index < length) { - func = funcs[index]; - - var funcName = getFuncName(func), - data = funcName == 'wrapper' ? getData(func) : undefined; - - if (data && isLaziable(data[0]) && data[1] == (WRAP_ARY_FLAG$4 | WRAP_CURRY_FLAG$6 | WRAP_PARTIAL_FLAG$5 | WRAP_REARG_FLAG$2) && !data[4].length && data[9] == 1) { - wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); - } else { - wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func); - } - } - return function () { - var args = arguments, - value = args[0]; - - if (wrapper && args.length == 1 && isArray$1(value)) { - return wrapper.plant(value).value(); - } - var index = 0, - result = length ? funcs[index].apply(this, args) : value; - - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; - }); + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; } /** - * Creates a function that returns the result of invoking the given functions - * with the `this` binding of the created function, where each successive - * invocation is supplied the return value of the previous. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {...(Function|Function[])} [funcs] The functions to invoke. - * @returns {Function} Returns the new composite function. - * @see _.flowRight - * @example - * - * function square(n) { - * return n * n; - * } + * The base implementation of `_.propertyOf` without support for deep paths. * - * var addSquare = _.flow([_.add, square]); - * addSquare(1, 2); - * // => 9 + * @private + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. */ -var flow = createFlow(); +function basePropertyOf(object) { + return function (key) { + return object == null ? undefined : object[key]; + }; +} + +/** Used to map Latin Unicode letters to basic Latin letters. */ +var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010A': 'C', '\u010C': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010B': 'c', '\u010D': 'c', + '\u010E': 'D', '\u0110': 'D', '\u010F': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011A': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011B': 'e', + '\u011C': 'G', '\u011E': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011D': 'g', '\u011F': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012A': 'I', '\u012C': 'I', '\u012E': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012B': 'i', '\u012D': 'i', '\u012F': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013B': 'L', '\u013D': 'L', '\u013F': 'L', '\u0141': 'L', + '\u013A': 'l', '\u013C': 'l', '\u013E': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014A': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014B': 'n', + '\u014C': 'O', '\u014E': 'O', '\u0150': 'O', + '\u014D': 'o', '\u014F': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015A': 'S', '\u015C': 'S', '\u015E': 'S', '\u0160': 'S', + '\u015B': 's', '\u015D': 's', '\u015F': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016A': 'U', '\u016C': 'U', '\u016E': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016B': 'u', '\u016D': 'u', '\u016F': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017B': 'Z', '\u017D': 'Z', + '\u017A': 'z', '\u017C': 'z', '\u017E': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017F': 's' +}; /** - * This method is like `_.flow` except that it creates a function that - * invokes the given functions from right to left. - * - * @static - * @since 3.0.0 - * @memberOf _ - * @category Util - * @param {...(Function|Function[])} [funcs] The functions to invoke. - * @returns {Function} Returns the new composite function. - * @see _.flow - * @example - * - * function square(n) { - * return n * n; - * } + * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A + * letters to basic Latin letters. * - * var addSquare = _.flowRight([square, _.add]); - * addSquare(1, 2); - * // => 9 + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. */ -var flowRight = createFlow(true); +var deburrLetter = basePropertyOf(deburredLetters); + +/** Used to match Latin Unicode letters (excluding mathematical operators). */ +var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + +/** Used to compose unicode character classes. */ +var rsComboMarksRange$2 = '\\u0300-\\u036f'; +var reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange$2 = '\\u20d0-\\u20ff'; +var rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2; + +/** Used to compose unicode capture groups. */ +var rsCombo$1 = '[' + rsComboRange$2 + ']'; /** - * Iterates over own and inherited enumerable string keyed properties of an - * object and invokes `iteratee` for each property. The iteratee is invoked - * with three arguments: (value, key, object). Iteratee functions may exit - * iteration early by explicitly returning `false`. + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ +var reComboMark = RegExp(rsCombo$1, 'g'); + +/** + * Deburrs `string` by converting + * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) + * letters to basic Latin letters and removing + * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). * * @static * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forInRight + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to deburr. + * @returns {string} Returns the deburred string. * @example * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forIn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). + * _.deburr('déjà vu'); + * // => 'deja vu' */ -function forIn(object, iteratee) { - return object == null ? object : baseFor(object, castFunction(iteratee), keysIn$1); +function deburr(string) { + string = toString$1(string); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); } +/** Used to match words composed of alphanumeric characters. */ +var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + /** - * This method is like `_.forIn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forIn - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Splits an ASCII `string` into an array of its words. * - * _.forInRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. */ -function forInRight(object, iteratee) { - return object == null ? object : baseForRight(object, castFunction(iteratee), keysIn$1); +function asciiWords(string) { + return string.match(reAsciiWord) || []; } +/** Used to detect strings that need a more robust regexp to match words. */ +var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + /** - * Iterates over own enumerable string keyed properties of an object and - * invokes `iteratee` for each property. The iteratee is invoked with three - * arguments: (value, key, object). Iteratee functions may exit iteration - * early by explicitly returning `false`. + * Checks if `string` contains a word composed of Unicode symbols. * - * @static - * @memberOf _ - * @since 0.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forOwnRight - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.forOwn(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'a' then 'b' (iteration order is not guaranteed). + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a word is found, else `false`. */ -function forOwn(object, iteratee) { - return object && baseForOwn(object, castFunction(iteratee)); +function hasUnicodeWord(string) { + return reHasUnicodeWord.test(string); } +/** Used to compose unicode character classes. */ +var rsAstralRange$2 = '\\ud800-\\udfff'; +var rsComboMarksRange$3 = '\\u0300-\\u036f'; +var reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange$3 = '\\u20d0-\\u20ff'; +var rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3; +var rsDingbatRange = '\\u2700-\\u27bf'; +var rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff'; +var rsMathOpRange = '\\xac\\xb1\\xd7\\xf7'; +var rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf'; +var rsPunctuationRange = '\\u2000-\\u206f'; +var rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000'; +var rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde'; +var rsVarRange$2 = '\\ufe0e\\ufe0f'; +var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; + +/** Used to compose unicode capture groups. */ +var rsApos$1 = '[\'\u2019]'; +var rsBreak = '[' + rsBreakRange + ']'; +var rsCombo$2 = '[' + rsComboRange$3 + ']'; +var rsDigits = '\\d+'; +var rsDingbat = '[' + rsDingbatRange + ']'; +var rsLower = '[' + rsLowerRange + ']'; +var rsMisc = '[^' + rsAstralRange$2 + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']'; +var rsFitz$1 = '\\ud83c[\\udffb-\\udfff]'; +var rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')'; +var rsNonAstral$1 = '[^' + rsAstralRange$2 + ']'; +var rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}'; +var rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]'; +var rsUpper = '[' + rsUpperRange + ']'; +var rsZWJ$2 = '\\u200d'; + +/** Used to compose unicode regexes. */ +var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')'; +var rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')'; +var rsOptContrLower = '(?:' + rsApos$1 + '(?:d|ll|m|re|s|t|ve))?'; +var rsOptContrUpper = '(?:' + rsApos$1 + '(?:D|LL|M|RE|S|T|VE))?'; +var reOptMod$1 = rsModifier$1 + '?'; +var rsOptVar$1 = '[' + rsVarRange$2 + ']?'; +var rsOptJoin$1 = '(?:' + rsZWJ$2 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*'; +var rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)'; +var rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)'; +var rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1; +var rsEmoji = '(?:' + [rsDingbat, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsSeq$1; + +/** Used to match complex or compound words. */ +var reUnicodeWord = RegExp([rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, rsUpper + '+' + rsOptContrUpper, rsOrdUpper, rsOrdLower, rsDigits, rsEmoji].join('|'), 'g'); + /** - * This method is like `_.forOwn` except that it iterates over properties of - * `object` in the opposite order. - * - * @static - * @memberOf _ - * @since 2.0.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns `object`. - * @see _.forOwn - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; + * Splits a Unicode `string` into an array of its words. * - * _.forOwnRight(new Foo, function(value, key) { - * console.log(key); - * }); - * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. */ -function forOwnRight(object, iteratee) { - return object && baseForOwnRight(object, castFunction(iteratee)); +function unicodeWords(string) { + return string.match(reUnicodeWord) || []; } /** - * The inverse of `_.toPairs`; this method returns an object composed - * from key-value `pairs`. + * Splits `string` into an array of its words. * * @static * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} pairs The key-value pairs. - * @returns {Object} Returns the new object. + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {RegExp|string} [pattern] The pattern to match words. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the words of `string`. * @example * - * _.fromPairs([['a', 1], ['b', 2]]); - * // => { 'a': 1, 'b': 2 } + * _.words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + * _.words('fred, barney, & pebbles', /[^, ]+/g); + * // => ['fred', 'barney', '&', 'pebbles'] */ -function fromPairs(pairs) { - var index = -1, - length = pairs == null ? 0 : pairs.length, - result = {}; +function words(string, pattern, guard) { + string = toString$1(string); + pattern = guard ? undefined : pattern; - while (++index < length) { - var pair = pairs[index]; - result[pair[0]] = pair[1]; + if (pattern === undefined) { + return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); } - return result; + return string.match(pattern) || []; } +/** Used to compose unicode capture groups. */ +var rsApos = '[\'\u2019]'; + +/** Used to match apostrophes. */ +var reApos = RegExp(rsApos, 'g'); + /** - * The base implementation of `_.functions` which creates an array of - * `object` function property names filtered from `props`. + * Creates a function like `_.camelCase`. * * @private - * @param {Object} object The object to inspect. - * @param {Array} props The property names to filter. - * @returns {Array} Returns the function names. + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. */ -function baseFunctions(object, props) { - return arrayFilter(props, function (key) { - return isFunction(object[key]); - }); +function createCompounder(callback) { + return function (string) { + return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); + }; } /** - * Creates an array of function property names from own enumerable properties - * of `object`. + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). * * @static - * @since 0.1.0 * @memberOf _ - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the function names. - * @see _.functionsIn + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the camel cased string. * @example * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } + * _.camelCase('Foo Bar'); + * // => 'fooBar' * - * Foo.prototype.c = _.constant('c'); + * _.camelCase('--foo-bar--'); + * // => 'fooBar' * - * _.functions(new Foo); - * // => ['a', 'b'] + * _.camelCase('__FOO_BAR__'); + * // => 'fooBar' */ -function functions(object) { - return object == null ? [] : baseFunctions(object, keys$1(object)); -} +var camelCase = createCompounder(function (result, word, index) { + word = word.toLowerCase(); + return result + (index ? capitalize(word) : word); +}); /** - * Creates an array of function property names from own and inherited - * enumerable properties of `object`. + * Casts `value` as an array if it's not one. * * @static * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to inspect. - * @returns {Array} Returns the function names. - * @see _.functions + * @since 4.4.0 + * @category Lang + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast array. * @example * - * function Foo() { - * this.a = _.constant('a'); - * this.b = _.constant('b'); - * } + * _.castArray(1); + * // => [1] * - * Foo.prototype.c = _.constant('c'); + * _.castArray({ 'a': 1 }); + * // => [{ 'a': 1 }] * - * _.functionsIn(new Foo); - * // => ['a', 'b', 'c'] + * _.castArray('abc'); + * // => ['abc'] + * + * _.castArray(null); + * // => [null] + * + * _.castArray(undefined); + * // => [undefined] + * + * _.castArray(); + * // => [] + * + * var array = [1, 2, 3]; + * console.log(_.castArray(array) === array); + * // => true */ -function functionsIn(object) { - return object == null ? [] : baseFunctions(object, keysIn$1(object)); +function castArray() { + if (!arguments.length) { + return []; + } + var value = arguments[0]; + return isArray$1(value) ? value : [value]; } -/** Used for built-in method references. */ -var objectProto$21 = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty$18 = objectProto$21.hasOwnProperty; +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin$2 = Math.min; /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The order of grouped values - * is determined by the order they occur in `collection`. The corresponding - * value of each key is an array of elements responsible for generating the - * key. The iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([6.1, 4.2, 6.3], Math.floor); - * // => { '4': [4.2], '6': [6.1, 6.3] } - * - * // The `_.property` iteratee shorthand. - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } - */ -var groupBy = createAggregator(function (result, value, key) { - if (hasOwnProperty$18.call(result, key)) { - result[key].push(value); - } else { - baseAssignValue(result, key, [value]); - } -}); - -/** - * The base implementation of `_.gt` which doesn't coerce arguments. + * Creates a function like `_.round`. * * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. + * @param {string} methodName The name of the `Math` method to use when rounding. + * @returns {Function} Returns the new round function. */ -function baseGt(value, other) { - return value > other; -} +function createRound(methodName) { + var func = Math[methodName]; + return function (number, precision) { + number = toNumber(number); + precision = precision == null ? 0 : nativeMin$2(toInteger(precision), 292); + if (precision) { + // Shift with exponential notation to avoid floating-point issues. + // See [MDN](https://mdn.io/round#Examples) for more details. + var pair = (toString$1(number) + 'e').split('e'), + value = func(pair[0] + 'e' + (+pair[1] + precision)); -/** - * Creates a function that performs a relational operation on two values. - * - * @private - * @param {Function} operator The function to perform the operation. - * @returns {Function} Returns the new relational operation function. - */ -function createRelationalOperation(operator) { - return function (value, other) { - if (!(typeof value == 'string' && typeof other == 'string')) { - value = toNumber(value); - other = toNumber(other); + pair = (toString$1(value) + 'e').split('e'); + return +(pair[0] + 'e' + (+pair[1] - precision)); } - return operator(value, other); + return func(number); }; } /** - * Checks if `value` is greater than `other`. + * Computes `number` rounded up to `precision`. * * @static * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than `other`, - * else `false`. - * @see _.lt + * @since 3.10.0 + * @category Math + * @param {number} number The number to round up. + * @param {number} [precision=0] The precision to round up to. + * @returns {number} Returns the rounded up number. * @example * - * _.gt(3, 1); - * // => true + * _.ceil(4.006); + * // => 5 * - * _.gt(3, 3); - * // => false + * _.ceil(6.004, 2); + * // => 6.01 * - * _.gt(1, 3); - * // => false + * _.ceil(6040, -2); + * // => 6100 */ -var gt = createRelationalOperation(baseGt); +var ceil$1 = createRound('ceil'); /** - * Checks if `value` is greater than or equal to `other`. + * Creates a `lodash` wrapper instance that wraps `value` with explicit method + * chain sequences enabled. The result of such sequences must be unwrapped + * with `_#value`. * * @static * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is greater than or equal to - * `other`, else `false`. - * @see _.lte + * @since 1.3.0 + * @category Seq + * @param {*} value The value to wrap. + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * _.gte(3, 1); - * // => true - * - * _.gte(3, 3); - * // => true - * - * _.gte(1, 3); - * // => false - */ -var gte = createRelationalOperation(function (value, other) { - return value >= other; -}); - -/** Used for built-in method references. */ -var objectProto$22 = Object.prototype; - -/** Used to check objects for own properties. */ -var hasOwnProperty$19 = objectProto$22.hasOwnProperty; - -/** - * The base implementation of `_.has` without support for deep paths. + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'pebbles', 'age': 1 } + * ]; * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. + * var youngest = _ + * .chain(users) + * .sortBy('age') + * .map(function(o) { + * return o.user + ' is ' + o.age; + * }) + * .head() + * .value(); + * // => 'pebbles is 1' */ -function baseHas(object, key) { - return object != null && hasOwnProperty$19.call(object, key); +function chain(value) { + var result = lodash(value); + result.__chain__ = true; + return result; } +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil; +var nativeMax$4 = Math.max; + /** - * Checks if `path` is a direct property of `object`. + * Creates an array of elements split into groups the length of `size`. + * If `array` can't be split evenly, the final chunk will be the remaining + * elements. * * @static - * @since 0.1.0 * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to process. + * @param {number} [size=1] The length of each chunk + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the new array of chunks. * @example * - * var object = { 'a': { 'b': 2 } }; - * var other = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.has(object, 'a'); - * // => true - * - * _.has(object, 'a.b'); - * // => true - * - * _.has(object, ['a', 'b']); - * // => true + * _.chunk(['a', 'b', 'c', 'd'], 2); + * // => [['a', 'b'], ['c', 'd']] * - * _.has(other, 'a'); - * // => false + * _.chunk(['a', 'b', 'c', 'd'], 3); + * // => [['a', 'b', 'c'], ['d']] */ -function has$1(object, path) { - return object != null && hasPath(object, path, baseHas); -} +function chunk(array, size, guard) { + if (guard ? isIterateeCall(array, size, guard) : size === undefined) { + size = 1; + } else { + size = nativeMax$4(toInteger(size), 0); + } + var length = array == null ? 0 : array.length; + if (!length || size < 1) { + return []; + } + var index = 0, + resIndex = 0, + result = Array(nativeCeil(length / size)); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$8 = Math.max; -var nativeMin$5 = Math.min; + while (index < length) { + result[resIndex++] = baseSlice(array, index, index += size); + } + return result; +} /** - * The base implementation of `_.inRange` which doesn't coerce arguments. + * The base implementation of `_.clamp` which doesn't coerce arguments. * * @private - * @param {number} number The number to check. - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. */ -function baseInRange(number, start, end) { - return number >= nativeMin$5(start, end) && number < nativeMax$8(start, end); +function baseClamp(number, lower, upper) { + if (number === number) { + if (upper !== undefined) { + number = number <= upper ? number : upper; + } + if (lower !== undefined) { + number = number >= lower ? number : lower; + } + } + return number; } /** - * Checks if `n` is between `start` and up to, but not including, `end`. If - * `end` is not specified, it's set to `start` with `start` then set to `0`. - * If `start` is greater than `end` the params are swapped to support - * negative ranges. + * Clamps `number` within the inclusive `lower` and `upper` bounds. * * @static * @memberOf _ - * @since 3.3.0 + * @since 4.0.0 * @category Number - * @param {number} number The number to check. - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @returns {boolean} Returns `true` if `number` is in the range, else `false`. - * @see _.range, _.rangeRight + * @param {number} number The number to clamp. + * @param {number} [lower] The lower bound. + * @param {number} upper The upper bound. + * @returns {number} Returns the clamped number. * @example * - * _.inRange(3, 2, 4); - * // => true - * - * _.inRange(4, 8); - * // => true - * - * _.inRange(4, 2); - * // => false + * _.clamp(-10, -5, 5); + * // => -5 * - * _.inRange(2, 2); - * // => false - * - * _.inRange(1.2, 2); - * // => true - * - * _.inRange(5.2, 4); - * // => false - * - * _.inRange(-3, -2, -6); - * // => true + * _.clamp(10, -5, 5); + * // => 5 */ -function inRange(number, start, end) { - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); +function clamp$1(number, lower, upper) { + if (upper === undefined) { + upper = lower; + lower = undefined; } - number = toNumber(number); - return baseInRange(number, start, end); + if (upper !== undefined) { + upper = toNumber(upper); + upper = upper === upper ? upper : 0; + } + if (lower !== undefined) { + lower = toNumber(lower); + lower = lower === lower ? lower : 0; + } + return baseClamp(toNumber(number), lower, upper); } -/** `Object#toString` result references. */ -var stringTag$4 = '[object String]'; - /** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * _.isString('abc'); - * // => true + * Removes all key-value entries from the stack. * - * _.isString(1); - * // => false + * @private + * @name clear + * @memberOf Stack */ -function isString(value) { - return typeof value == 'string' || !isArray$1(value) && isObjectLike(value) && baseGetTag(value) == stringTag$4; +function stackClear() { + this.__data__ = new ListCache(); + this.size = 0; } /** - * The base implementation of `_.values` and `_.valuesIn` which creates an - * array of `object` property values corresponding to the property names - * of `props`. + * Removes `key` and its value from the stack. * * @private - * @param {Object} object The object to query. - * @param {Array} props The property names to get values for. - * @returns {Object} Returns the array of property values. + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. */ -function baseValues(object, props) { - return arrayMap(props, function (key) { - return object[key]; - }); +function stackDelete(key) { + var data = this.__data__, + result = data['delete'](key); + + this.size = data.size; + return result; } /** - * Creates an array of the own enumerable string keyed property values of `object`. - * - * **Note:** Non-object values are coerced to objects. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property values. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.values(new Foo); - * // => [1, 2] (iteration order is not guaranteed) + * Gets the stack value for `key`. * - * _.values('hi'); - * // => ['h', 'i'] + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. */ -function values$1(object) { - return object == null ? [] : baseValues(object, keys$1(object)); +function stackGet(key) { + return this.__data__.get(key); } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$9 = Math.max; - /** - * Checks if `value` is in `collection`. If `collection` is a string, it's - * checked for a substring of `value`, otherwise - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * is used for equality comparisons. If `fromIndex` is negative, it's used as - * the offset from the end of `collection`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. - * @returns {boolean} Returns `true` if `value` is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'a': 1, 'b': 2 }, 1); - * // => true + * Checks if a stack value for `key` exists. * - * _.includes('abcd', 'bc'); - * // => true + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function includes$1(collection, value, fromIndex, guard) { - collection = isArrayLike(collection) ? collection : values$1(collection); - fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0; - - var length = collection.length; - if (fromIndex < 0) { - fromIndex = nativeMax$9(length + fromIndex, 0); - } - return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1; +function stackHas(key) { + return this.__data__.has(key); } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$10 = Math.max; +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; /** - * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. If `fromIndex` is negative, it's used as the - * offset from the end of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.indexOf([1, 2, 1, 2], 2); - * // => 1 + * Sets the stack `key` to `value`. * - * // Search from the `fromIndex`. - * _.indexOf([1, 2, 1, 2], 2, 2); - * // => 3 + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. */ -function indexOf$1(array, value, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; - } - var index = fromIndex == null ? 0 : toInteger(fromIndex); - if (index < 0) { - index = nativeMax$10(length + index, 0); +function stackSet(key, value) { + var data = this.__data__; + if (data instanceof ListCache) { + var pairs = data.__data__; + if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) { + pairs.push([key, value]); + this.size = ++data.size; + return this; + } + data = this.__data__ = new MapCache(pairs); } - return baseIndexOf(array, value, index); + data.set(key, value); + this.size = data.size; + return this; } /** - * Gets all but the last element of `array`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example + * Creates a stack cache object to store key-value pairs. * - * _.initial([1, 2, 3]); - * // => [1, 2] + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. */ -function initial(array) { - var length = array == null ? 0 : array.length; - return length ? baseSlice(array, 0, -1) : []; +function Stack(entries) { + var data = this.__data__ = new ListCache(entries); + this.size = data.size; } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin$6 = Math.min; +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; /** - * The base implementation of methods like `_.intersection`, without support - * for iteratee shorthands, that accepts an array of arrays to inspect. + * The base implementation of `_.assign` without support for multiple sources + * or `customizer` functions. * * @private - * @param {Array} arrays The arrays to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of shared values. + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. */ -function baseIntersection(arrays, iteratee, comparator) { - var includes = comparator ? arrayIncludesWith : arrayIncludes, - length = arrays[0].length, - othLength = arrays.length, - othIndex = othLength, - caches = Array(othLength), - maxLength = Infinity, - result = []; +function baseAssign(object, source) { + return object && copyObject(source, keys$1(source), object); +} - while (othIndex--) { - var array = arrays[othIndex]; - if (othIndex && iteratee) { - array = arrayMap(array, baseUnary(iteratee)); - } - maxLength = nativeMin$6(array.length, maxLength); - caches[othIndex] = !comparator && (iteratee || length >= 120 && array.length >= 120) ? new SetCache(othIndex && array) : undefined; - } - array = arrays[0]; +/** + * The base implementation of `_.assignIn` without support for multiple sources + * or `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssignIn(object, source) { + return object && copyObject(source, keysIn$1(source), object); +} - var index = -1, - seen = caches[0]; +/** Detect free variable `exports`. */ +var freeExports$2 = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports; - outer: while (++index < length && result.length < maxLength) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; +/** Detect free variable `module`. */ +var freeModule$2 = freeExports$2 && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module; - value = comparator || value !== 0 ? value : 0; - if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) { - othIndex = othLength; - while (--othIndex) { - var cache = caches[othIndex]; - if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) { - continue outer; - } - } - if (seen) { - seen.push(computed); - } - result.push(value); - } +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2; + +/** Built-in value references. */ +var Buffer$1 = moduleExports$2 ? root.Buffer : undefined; +var allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined; + +/** + * Creates a clone of `buffer`. + * + * @private + * @param {Buffer} buffer The buffer to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Buffer} Returns the cloned buffer. + */ +function cloneBuffer(buffer, isDeep) { + if (isDeep) { + return buffer.slice(); } + var length = buffer.length, + result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); + + buffer.copy(result); return result; } /** - * Casts `value` to an empty array if it's not an array like object. + * A specialized version of `_.filter` for arrays without support for + * iteratee shorthands. * * @private - * @param {*} value The value to inspect. - * @returns {Array|Object} Returns the cast array-like object. + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. */ -function castArrayLikeObject(value) { - return isArrayLikeObject(value) ? value : []; +function arrayFilter(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (predicate(value, index, array)) { + result[resIndex++] = value; + } + } + return result; } /** - * Creates an array of unique values that are included in all given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. The order and references of result values are - * determined by the first array. + * This method returns a new empty array. * * @static * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @returns {Array} Returns the new array of intersecting values. + * @since 4.13.0 + * @category Util + * @returns {Array} Returns the new empty array. * @example * - * _.intersection([2, 1], [2, 3]); - * // => [2] + * var arrays = _.times(2, _.stubArray); + * + * console.log(arrays); + * // => [[], []] + * + * console.log(arrays[0] === arrays[1]); + * // => false */ -var intersection = baseRest(function (arrays) { - var mapped = arrayMap(arrays, castArrayLikeObject); - return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : []; -}); +function stubArray() { + return []; +} + +/** Used for built-in method references. */ +var objectProto$15 = Object.prototype; + +/** Built-in value references. */ +var propertyIsEnumerable$2 = objectProto$15.propertyIsEnumerable; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols = Object.getOwnPropertySymbols; /** - * This method is like `_.intersection` except that it accepts `iteratee` - * which is invoked for each element of each `arrays` to generate the criterion - * by which they're compared. The order and references of result values are - * determined by the first array. The iteratee is invoked with one argument: - * (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); - * // => [2.1] + * Creates an array of the own enumerable symbols of `object`. * - * // The `_.property` iteratee shorthand. - * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }] + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. */ -var intersectionBy = baseRest(function (arrays) { - var iteratee = last$1(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); - - if (iteratee === last$1(mapped)) { - iteratee = undefined; - } else { - mapped.pop(); +var getSymbols = !nativeGetSymbols ? stubArray : function (object) { + if (object == null) { + return []; } - return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, baseIteratee(iteratee, 2)) : []; -}); + object = Object(object); + return arrayFilter(nativeGetSymbols(object), function (symbol) { + return propertyIsEnumerable$2.call(object, symbol); + }); +}; /** - * This method is like `_.intersection` except that it accepts `comparator` - * which is invoked to compare elements of `arrays`. The order and references - * of result values are determined by the first array. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {...Array} [arrays] The arrays to inspect. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns the new array of intersecting values. - * @example - * - * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; - * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * Copies own symbols of `source` to `object`. * - * _.intersectionWith(objects, others, _.isEqual); - * // => [{ 'x': 1, 'y': 2 }] + * @private + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. */ -var intersectionWith = baseRest(function (arrays) { - var comparator = last$1(arrays), - mapped = arrayMap(arrays, castArrayLikeObject); +function copySymbols(source, object) { + return copyObject(source, getSymbols(source), object); +} - comparator = typeof comparator == 'function' ? comparator : undefined; - if (comparator) { - mapped.pop(); - } - return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined, comparator) : []; -}); +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeGetSymbols$1 = Object.getOwnPropertySymbols; /** - * The base implementation of `_.invert` and `_.invertBy` which inverts - * `object` with values transformed by `iteratee` and set by `setter`. + * Creates an array of the own and inherited enumerable symbols of `object`. * * @private - * @param {Object} object The object to iterate over. - * @param {Function} setter The function to set `accumulator` values. - * @param {Function} iteratee The iteratee to transform values. - * @param {Object} accumulator The initial inverted object. - * @returns {Function} Returns `accumulator`. + * @param {Object} object The object to query. + * @returns {Array} Returns the array of symbols. */ -function baseInverter(object, setter, iteratee, accumulator) { - baseForOwn(object, function (value, key, object) { - setter(accumulator, iteratee(value), key, object); - }); - return accumulator; -} +var getSymbolsIn = !nativeGetSymbols$1 ? stubArray : function (object) { + var result = []; + while (object) { + arrayPush(result, getSymbols(object)); + object = getPrototype(object); + } + return result; +}; /** - * Creates a function like `_.invertBy`. + * Copies own and inherited symbols of `source` to `object`. * * @private - * @param {Function} setter The function to set accumulator values. - * @param {Function} toIteratee The function to resolve iteratees. - * @returns {Function} Returns the new inverter function. + * @param {Object} source The object to copy symbols from. + * @param {Object} [object={}] The object to copy symbols to. + * @returns {Object} Returns `object`. */ -function createInverter(setter, toIteratee) { - return function (object, iteratee) { - return baseInverter(object, setter, toIteratee(iteratee), {}); - }; +function copySymbolsIn(source, object) { + return copyObject(source, getSymbolsIn(source), object); } /** - * Creates an object composed of the inverted keys and values of `object`. - * If `object` contains duplicate values, subsequent values overwrite - * property assignments of previous values. + * The base implementation of `getAllKeys` and `getAllKeysIn` which uses + * `keysFunc` and `symbolsFunc` to get the enumerable property names and + * symbols of `object`. * - * @static - * @memberOf _ - * @since 0.7.0 - * @category Object - * @param {Object} object The object to invert. - * @returns {Object} Returns the new inverted object. - * @example + * @private + * @param {Object} object The object to query. + * @param {Function} keysFunc The function to get the keys of `object`. + * @param {Function} symbolsFunc The function to get the symbols of `object`. + * @returns {Array} Returns the array of property names and symbols. + */ +function baseGetAllKeys(object, keysFunc, symbolsFunc) { + var result = keysFunc(object); + return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object)); +} + +/** + * Creates an array of own enumerable property names and symbols of `object`. * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. + */ +function getAllKeys(object) { + return baseGetAllKeys(object, keys$1, getSymbols); +} + +/** + * Creates an array of own and inherited enumerable property names and + * symbols of `object`. * - * _.invert(object); - * // => { '1': 'c', '2': 'b' } + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names and symbols. */ -var invert = createInverter(function (result, value, key) { - result[value] = key; -}, constant(identity$1)); +function getAllKeysIn(object) { + return baseGetAllKeys(object, keysIn$1, getSymbolsIn); +} + +/* Built-in method references that are verified to be native. */ +var DataView$1 = getNative(root, 'DataView'); + +/* Built-in method references that are verified to be native. */ +var Promise$1 = getNative(root, 'Promise'); + +/* Built-in method references that are verified to be native. */ +var Set$1 = getNative(root, 'Set'); + +/** `Object#toString` result references. */ +var mapTag$2 = '[object Map]'; +var objectTag$3 = '[object Object]'; +var promiseTag = '[object Promise]'; +var setTag$2 = '[object Set]'; +var weakMapTag$2 = '[object WeakMap]'; + +var dataViewTag$2 = '[object DataView]'; + +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView$1); +var mapCtorString = toSource(Map$1); +var promiseCtorString = toSource(Promise$1); +var setCtorString = toSource(Set$1); +var weakMapCtorString = toSource(WeakMap$1); + +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag; + +// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. +if (DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag(new Map$1()) != mapTag$2 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$2 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag$2) { + getTag = function getTag(value) { + var result = baseGetTag(value), + Ctor = result == objectTag$3 ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : ''; + + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: + return dataViewTag$2; + case mapCtorString: + return mapTag$2; + case promiseCtorString: + return promiseTag; + case setCtorString: + return setTag$2; + case weakMapCtorString: + return weakMapTag$2; + } + } + return result; + }; +} + +var getTag$1 = getTag; /** Used for built-in method references. */ -var objectProto$23 = Object.prototype; +var objectProto$16 = Object.prototype; /** Used to check objects for own properties. */ -var hasOwnProperty$20 = objectProto$23.hasOwnProperty; +var hasOwnProperty$13 = objectProto$16.hasOwnProperty; /** - * This method is like `_.invert` except that the inverted object is generated - * from the results of running each element of `object` thru `iteratee`. The - * corresponding inverted value of each inverted key is an array of keys - * responsible for generating the inverted value. The iteratee is invoked - * with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.1.0 - * @category Object - * @param {Object} object The object to invert. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Object} Returns the new inverted object. - * @example - * - * var object = { 'a': 1, 'b': 2, 'c': 1 }; - * - * _.invertBy(object); - * // => { '1': ['a', 'c'], '2': ['b'] } + * Initializes an array clone. * - * _.invertBy(object, function(value) { - * return 'group' + value; - * }); - * // => { 'group1': ['a', 'c'], 'group2': ['b'] } + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. */ -var invertBy = createInverter(function (result, value, key) { - if (hasOwnProperty$20.call(result, value)) { - result[value].push(key); - } else { - result[value] = [key]; +function initCloneArray(array) { + var length = array.length, + result = array.constructor(length); + + // Add properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty$13.call(array, 'index')) { + result.index = array.index; + result.input = array.input; } -}, baseIteratee); + return result; +} + +/** Built-in value references. */ +var Uint8Array$1 = root.Uint8Array; /** - * Gets the parent value at `path` of `object`. + * Creates a clone of `arrayBuffer`. * * @private - * @param {Object} object The object to query. - * @param {Array} path The path to get the parent value of. - * @returns {*} Returns the parent value. + * @param {ArrayBuffer} arrayBuffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. */ -function parent(object, path) { - return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); +function cloneArrayBuffer(arrayBuffer) { + var result = new arrayBuffer.constructor(arrayBuffer.byteLength); + new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer)); + return result; } /** - * The base implementation of `_.invoke` without support for individual - * method arguments. + * Creates a clone of `dataView`. * * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {Array} args The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. + * @param {Object} dataView The data view to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned data view. */ -function baseInvoke(object, path, args) { - path = castPath(path, object); - object = parent(object, path); - var func = object == null ? object : object[toKey(last$1(path))]; - return func == null ? undefined : apply$1(func, object, args); +function cloneDataView(dataView, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; + return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } /** - * Invokes the method at `path` of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the method to invoke. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {*} Returns the result of the invoked method. - * @example - * - * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; + * Adds the key-value `pair` to `map`. * - * _.invoke(object, 'a[0].b.c.slice', 1, 3); - * // => [2, 3] + * @private + * @param {Object} map The map to modify. + * @param {Array} pair The key-value pair to add. + * @returns {Object} Returns `map`. */ -var invoke$1 = baseRest(baseInvoke); +function addMapEntry(map, pair) { + // Don't return `map.set` because it's not chainable in IE 11. + map.set(pair[0], pair[1]); + return map; +} /** - * Invokes the method at `path` of each element in `collection`, returning - * an array of the results of each invoked method. Any additional arguments - * are provided to each invoked method. If `path` is a function, it's invoked - * for, and `this` bound to, each element in `collection`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array|Function|string} path The path of the method to invoke or - * the function invoked per iteration. - * @param {...*} [args] The arguments to invoke each method with. - * @returns {Array} Returns the array of results. - * @example - * - * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] + * Converts `map` to its key-value pairs. * - * _.invokeMap([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. */ -var invokeMap = baseRest(function (collection, path, args) { +function mapToArray(map) { var index = -1, - isFunc = typeof path == 'function', - result = isArrayLike(collection) ? Array(collection.length) : []; + result = Array(map.size); - baseEach(collection, function (value) { - result[++index] = isFunc ? apply$1(path, value, args) : baseInvoke(value, path, args); + map.forEach(function (value, key) { + result[++index] = [key, value]; }); return result; -}); +} -var arrayBufferTag$4 = '[object ArrayBuffer]'; +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG$1 = 1; /** - * The base implementation of `_.isArrayBuffer` without Node.js optimizations. + * Creates a clone of `map`. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. + * @param {Object} map The map to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned map. */ -function baseIsArrayBuffer(value) { - return isObjectLike(value) && baseGetTag(value) == arrayBufferTag$4; +function cloneMap(map, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG$1) : mapToArray(map); + return arrayReduce(array, addMapEntry, new map.constructor()); } -/* Node.js helper references. */ -var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; +/** Used to match `RegExp` flags from their coerced string values. */ +var reFlags = /\w*$/; /** - * Checks if `value` is classified as an `ArrayBuffer` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. - * @example - * - * _.isArrayBuffer(new ArrayBuffer(2)); - * // => true + * Creates a clone of `regexp`. * - * _.isArrayBuffer(new Array(2)); - * // => false + * @private + * @param {Object} regexp The regexp to clone. + * @returns {Object} Returns the cloned regexp. */ -var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; - -/** `Object#toString` result references. */ -var boolTag$4 = '[object Boolean]'; +function cloneRegExp(regexp) { + var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); + result.lastIndex = regexp.lastIndex; + return result; +} /** - * Checks if `value` is classified as a boolean primitive or object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. - * @example + * Adds `value` to `set`. * - * _.isBoolean(false); - * // => true + * @private + * @param {Object} set The set to modify. + * @param {*} value The value to add. + * @returns {Object} Returns `set`. + */ +function addSetEntry(set, value) { + // Don't return `set.add` because it's not chainable in IE 11. + set.add(value); + return set; +} + +/** + * Converts `set` to an array of its values. * - * _.isBoolean(null); - * // => false + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. */ -function isBoolean(value) { - return value === true || value === false || isObjectLike(value) && baseGetTag(value) == boolTag$4; +function setToArray(set) { + var index = -1, + result = Array(set.size); + + set.forEach(function (value) { + result[++index] = value; + }); + return result; } -/** `Object#toString` result references. */ -var dateTag$4 = '[object Date]'; +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG$2 = 1; /** - * The base implementation of `_.isDate` without Node.js optimizations. + * Creates a clone of `set`. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. + * @param {Object} set The set to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned set. */ -function baseIsDate(value) { - return isObjectLike(value) && baseGetTag(value) == dateTag$4; +function cloneSet(set, isDeep, cloneFunc) { + var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG$2) : setToArray(set); + return arrayReduce(array, addSetEntry, new set.constructor()); } -/* Node.js helper references. */ -var nodeIsDate = nodeUtil && nodeUtil.isDate; +/** Used to convert symbols to primitives and strings. */ +var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined; +var symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : undefined; /** - * Checks if `value` is classified as a `Date` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a date object, else `false`. - * @example - * - * _.isDate(new Date); - * // => true + * Creates a clone of the `symbol` object. * - * _.isDate('Mon April 23 2012'); - * // => false + * @private + * @param {Object} symbol The symbol object to clone. + * @returns {Object} Returns the cloned symbol object. */ -var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; +function cloneSymbol(symbol) { + return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; +} /** - * Checks if `value` is likely a DOM element. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. - * @example - * - * _.isElement(document.body); - * // => true + * Creates a clone of `typedArray`. * - * _.isElement(''); - * // => false + * @private + * @param {Object} typedArray The typed array to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the cloned typed array. */ -function isElement(value) { - return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); +function cloneTypedArray(typedArray, isDeep) { + var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; + return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } /** `Object#toString` result references. */ -var mapTag$6 = '[object Map]'; -var setTag$6 = '[object Set]'; - -/** Used for built-in method references. */ -var objectProto$24 = Object.prototype; +var boolTag$2 = '[object Boolean]'; +var dateTag$2 = '[object Date]'; +var mapTag$3 = '[object Map]'; +var numberTag$2 = '[object Number]'; +var regexpTag$2 = '[object RegExp]'; +var setTag$3 = '[object Set]'; +var stringTag$2 = '[object String]'; +var symbolTag$2 = '[object Symbol]'; -/** Used to check objects for own properties. */ -var hasOwnProperty$21 = objectProto$24.hasOwnProperty; +var arrayBufferTag$2 = '[object ArrayBuffer]'; +var dataViewTag$3 = '[object DataView]'; +var float32Tag$2 = '[object Float32Array]'; +var float64Tag$2 = '[object Float64Array]'; +var int8Tag$2 = '[object Int8Array]'; +var int16Tag$2 = '[object Int16Array]'; +var int32Tag$2 = '[object Int32Array]'; +var uint8Tag$2 = '[object Uint8Array]'; +var uint8ClampedTag$2 = '[object Uint8ClampedArray]'; +var uint16Tag$2 = '[object Uint16Array]'; +var uint32Tag$2 = '[object Uint32Array]'; /** - * Checks if `value` is an empty object, collection, map, or set. - * - * Objects are considered empty if they have no own enumerable string keyed - * properties. - * - * Array-like values such as `arguments` objects, arrays, buffers, strings, or - * jQuery-like collections are considered empty if they have a `length` of `0`. - * Similarly, maps and sets are considered empty if they have a `size` of `0`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is empty, else `false`. - * @example - * - * _.isEmpty(null); - * // => true - * - * _.isEmpty(true); - * // => true - * - * _.isEmpty(1); - * // => true + * Initializes an object clone based on its `toStringTag`. * - * _.isEmpty([1, 2, 3]); - * // => false + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * - * _.isEmpty({ 'a': 1 }); - * // => false + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {Function} cloneFunc The function to clone values. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. */ -function isEmpty$1(value) { - if (value == null) { - return true; - } - if (isArrayLike(value) && (isArray$1(value) || typeof value == 'string' || typeof value.splice == 'function' || isBuffer(value) || isTypedArray$1(value) || isArguments(value))) { - return !value.length; - } - var tag = getTag$1(value); - if (tag == mapTag$6 || tag == setTag$6) { - return !value.size; - } - if (isPrototype(value)) { - return !baseKeys(value).length; - } - for (var key in value) { - if (hasOwnProperty$21.call(value, key)) { - return false; - } - } - return true; -} +function initCloneByTag(object, tag, cloneFunc, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag$2: + return cloneArrayBuffer(object); -/** - * Performs a deep comparison between two values to determine if they are - * equivalent. - * - * **Note:** This method supports comparing arrays, array buffers, booleans, - * date objects, error objects, maps, numbers, `Object` objects, regexes, - * sets, strings, symbols, and typed arrays. `Object` objects are compared - * by their own, not inherited, enumerable properties. Functions and DOM - * nodes are compared by strict equality, i.e. `===`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; + case boolTag$2: + case dateTag$2: + return new Ctor(+object); + + case dataViewTag$3: + return cloneDataView(object, isDeep); + + case float32Tag$2:case float64Tag$2: + case int8Tag$2:case int16Tag$2:case int32Tag$2: + case uint8Tag$2:case uint8ClampedTag$2:case uint16Tag$2:case uint32Tag$2: + return cloneTypedArray(object, isDeep); + + case mapTag$3: + return cloneMap(object, isDeep, cloneFunc); + + case numberTag$2: + case stringTag$2: + return new Ctor(object); + + case regexpTag$2: + return cloneRegExp(object); + + case setTag$3: + return cloneSet(object, isDeep, cloneFunc); + + case symbolTag$2: + return cloneSymbol(object); + } +} + +/** + * Initializes an object clone. * - * _.isEqual(object, other); - * // => true + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneObject(object) { + return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {}; +} + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG = 1; +var CLONE_FLAT_FLAG = 2; +var CLONE_SYMBOLS_FLAG$1 = 4; + +/** `Object#toString` result references. */ +var argsTag$2 = '[object Arguments]'; +var arrayTag$1 = '[object Array]'; +var boolTag$1 = '[object Boolean]'; +var dateTag$1 = '[object Date]'; +var errorTag$2 = '[object Error]'; +var funcTag$2 = '[object Function]'; +var genTag$1 = '[object GeneratorFunction]'; +var mapTag$1 = '[object Map]'; +var numberTag$1 = '[object Number]'; +var objectTag$2 = '[object Object]'; +var regexpTag$1 = '[object RegExp]'; +var setTag$1 = '[object Set]'; +var stringTag$1 = '[object String]'; +var symbolTag$1 = '[object Symbol]'; +var weakMapTag$1 = '[object WeakMap]'; + +var arrayBufferTag$1 = '[object ArrayBuffer]'; +var dataViewTag$1 = '[object DataView]'; +var float32Tag$1 = '[object Float32Array]'; +var float64Tag$1 = '[object Float64Array]'; +var int8Tag$1 = '[object Int8Array]'; +var int16Tag$1 = '[object Int16Array]'; +var int32Tag$1 = '[object Int32Array]'; +var uint8Tag$1 = '[object Uint8Array]'; +var uint8ClampedTag$1 = '[object Uint8ClampedArray]'; +var uint16Tag$1 = '[object Uint16Array]'; +var uint32Tag$1 = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values supported by `_.clone`. */ +var cloneableTags = {}; +cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag$1] = cloneableTags[float64Tag$1] = cloneableTags[int8Tag$1] = cloneableTags[int16Tag$1] = cloneableTags[int32Tag$1] = cloneableTags[mapTag$1] = cloneableTags[numberTag$1] = cloneableTags[objectTag$2] = cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag$1] = cloneableTags[uint8ClampedTag$1] = cloneableTags[uint16Tag$1] = cloneableTags[uint32Tag$1] = true; +cloneableTags[errorTag$2] = cloneableTags[funcTag$2] = cloneableTags[weakMapTag$1] = false; + +/** + * The base implementation of `_.clone` and `_.cloneDeep` which tracks + * traversed objects. * - * object === other; - * // => false + * @private + * @param {*} value The value to clone. + * @param {boolean} bitmask The bitmask flags. + * 1 - Deep clone + * 2 - Flatten inherited properties + * 4 - Clone symbols + * @param {Function} [customizer] The function to customize cloning. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The parent object of `value`. + * @param {Object} [stack] Tracks traversed objects and their clone counterparts. + * @returns {*} Returns the cloned value. */ -function isEqual(value, other) { - return baseIsEqual(value, other); +function baseClone(value, bitmask, customizer, key, object, stack) { + var result, + isDeep = bitmask & CLONE_DEEP_FLAG, + isFlat = bitmask & CLONE_FLAT_FLAG, + isFull = bitmask & CLONE_SYMBOLS_FLAG$1; + + if (customizer) { + result = object ? customizer(value, key, object, stack) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray$1(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return copyArray$1(value, result); + } + } else { + var tag = getTag$1(value), + isFunc = tag == funcTag$2 || tag == genTag$1; + + if (isBuffer(value)) { + return cloneBuffer(value, isDeep); + } + if (tag == objectTag$2 || tag == argsTag$2 || isFunc && !object) { + result = isFlat || isFunc ? {} : initCloneObject(value); + if (!isDeep) { + return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value)); + } + } else { + if (!cloneableTags[tag]) { + return object ? value : {}; + } + result = initCloneByTag(value, tag, baseClone, isDeep); + } + } + // Check for circular references and return its corresponding clone. + stack || (stack = new Stack()); + var stacked = stack.get(value); + if (stacked) { + return stacked; + } + stack.set(value, result); + + var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys$1; + + var props = isArr ? undefined : keysFunc(value); + arrayEach(props || value, function (subValue, key) { + if (props) { + key = subValue; + subValue = value[key]; + } + // Recursively populate clone (susceptible to call stack limits). + assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); + }); + return result; } +/** Used to compose bitmasks for cloning. */ +var CLONE_SYMBOLS_FLAG = 4; + /** - * This method is like `_.isEqual` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with up to - * six arguments: (objValue, othValue [, index|key, object, other, stack]). + * Creates a shallow clone of `value`. + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) + * and supports cloning arrays, array buffers, booleans, date objects, maps, + * numbers, `Object` objects, regexes, sets, strings, symbols, and typed + * arrays. The own enumerable properties of `arguments` objects are cloned + * as plain objects. An empty object is returned for uncloneable values such + * as error objects, functions, DOM nodes, and WeakMaps. * * @static * @memberOf _ - * @since 4.0.0 + * @since 0.1.0 * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @param {*} value The value to clone. + * @returns {*} Returns the cloned value. + * @see _.cloneDeep * @example * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } - * - * function customizer(objValue, othValue) { - * if (isGreeting(objValue) && isGreeting(othValue)) { - * return true; - * } - * } - * - * var array = ['hello', 'goodbye']; - * var other = ['hi', 'goodbye']; + * var objects = [{ 'a': 1 }, { 'b': 2 }]; * - * _.isEqualWith(array, other, customizer); + * var shallow = _.clone(objects); + * console.log(shallow[0] === objects[0]); * // => true */ -function isEqualWith(value, other, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - var result = customizer ? customizer(value, other) : undefined; - return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; +function clone$1(value) { + return baseClone(value, CLONE_SYMBOLS_FLAG); } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeIsFinite = root.isFinite; +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG$3 = 1; +var CLONE_SYMBOLS_FLAG$2 = 4; /** - * Checks if `value` is a finite primitive number. - * - * **Note:** This method is based on - * [`Number.isFinite`](https://mdn.io/Number/isFinite). + * This method is like `_.clone` except that it recursively clones `value`. * * @static * @memberOf _ - * @since 0.1.0 + * @since 1.0.0 * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. + * @param {*} value The value to recursively clone. + * @returns {*} Returns the deep cloned value. + * @see _.clone * @example * - * _.isFinite(3); - * // => true - * - * _.isFinite(Number.MIN_VALUE); - * // => true - * - * _.isFinite(Infinity); - * // => false + * var objects = [{ 'a': 1 }, { 'b': 2 }]; * - * _.isFinite('3'); + * var deep = _.cloneDeep(objects); + * console.log(deep[0] === objects[0]); * // => false */ -function isFinite$1(value) { - return typeof value == 'number' && nativeIsFinite(value); +function cloneDeep(value) { + return baseClone(value, CLONE_DEEP_FLAG$3 | CLONE_SYMBOLS_FLAG$2); } +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG$4 = 1; +var CLONE_SYMBOLS_FLAG$3 = 4; + /** - * Checks if `value` is an integer. - * - * **Note:** This method is based on - * [`Number.isInteger`](https://mdn.io/Number/isInteger). + * This method is like `_.cloneWith` except that it recursively clones `value`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an integer, else `false`. - * @example - * - * _.isInteger(3); - * // => true + * @param {*} value The value to recursively clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the deep cloned value. + * @see _.cloneWith + * @example * - * _.isInteger(Number.MIN_VALUE); - * // => false + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } + * } * - * _.isInteger(Infinity); - * // => false + * var el = _.cloneDeepWith(document.body, customizer); * - * _.isInteger('3'); + * console.log(el === document.body); * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 20 */ -function isInteger$1(value) { - return typeof value == 'number' && value == toInteger(value); -} - -/** `Object#toString` result references. */ -var mapTag$7 = '[object Map]'; - -/** - * The base implementation of `_.isMap` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - */ -function baseIsMap(value) { - return isObjectLike(value) && getTag$1(value) == mapTag$7; +function cloneDeepWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_DEEP_FLAG$4 | CLONE_SYMBOLS_FLAG$3, customizer); } -/* Node.js helper references. */ -var nodeIsMap = nodeUtil && nodeUtil.isMap; - -/** - * Checks if `value` is classified as a `Map` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a map, else `false`. - * @example - * - * _.isMap(new Map); - * // => true - * - * _.isMap(new WeakMap); - * // => false - */ -var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; +/** Used to compose bitmasks for cloning. */ +var CLONE_SYMBOLS_FLAG$4 = 4; /** - * Performs a partial deep comparison between `object` and `source` to - * determine if `object` contains equivalent property values. - * - * **Note:** This method is equivalent to `_.matches` when `source` is - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `_.isEqual` - * for a list of supported value comparisons. + * This method is like `_.clone` except that it accepts `customizer` which + * is invoked to produce the cloned value. If `customizer` returns `undefined`, + * cloning is handled by the method instead. The `customizer` is invoked with + * up to four arguments; (value [, index|key, object, stack]). * * @static * @memberOf _ - * @since 3.0.0 + * @since 4.0.0 * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @param {*} value The value to clone. + * @param {Function} [customizer] The function to customize cloning. + * @returns {*} Returns the cloned value. + * @see _.cloneDeepWith * @example * - * var object = { 'a': 1, 'b': 2 }; + * function customizer(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } + * } * - * _.isMatch(object, { 'b': 2 }); - * // => true + * var el = _.cloneWith(document.body, customizer); * - * _.isMatch(object, { 'b': 1 }); + * console.log(el === document.body); * // => false + * console.log(el.nodeName); + * // => 'BODY' + * console.log(el.childNodes.length); + * // => 0 */ -function isMatch(object, source) { - return object === source || baseIsMatch(object, source, getMatchData(source)); +function cloneWith(value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return baseClone(value, CLONE_SYMBOLS_FLAG$4, customizer); } /** - * This method is like `_.isMatch` except that it accepts `customizer` which - * is invoked to compare values. If `customizer` returns `undefined`, comparisons - * are handled by the method instead. The `customizer` is invoked with five - * arguments: (objValue, srcValue, index|key, object, source). + * Executes the chain sequence and returns the wrapped result. * - * @static + * @name commit * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. + * @since 3.2.0 + * @category Seq + * @returns {Object} Returns the new `lodash` wrapper instance. * @example * - * function isGreeting(value) { - * return /^h(?:i|ello)$/.test(value); - * } + * var array = [1, 2]; + * var wrapped = _(array).push(3); * - * function customizer(objValue, srcValue) { - * if (isGreeting(objValue) && isGreeting(srcValue)) { - * return true; - * } - * } + * console.log(array); + * // => [1, 2] * - * var object = { 'greeting': 'hello' }; - * var source = { 'greeting': 'hi' }; + * wrapped = wrapped.commit(); + * console.log(array); + * // => [1, 2, 3] * - * _.isMatchWith(object, source, customizer); - * // => true + * wrapped.last(); + * // => 3 + * + * console.log(array); + * // => [1, 2, 3] */ -function isMatchWith(object, source, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return baseIsMatch(object, source, getMatchData(source), customizer); +function wrapperCommit() { + return new LodashWrapper(this.value(), this.__chain__); } -/** `Object#toString` result references. */ -var numberTag$4 = '[object Number]'; - /** - * Checks if `value` is classified as a `Number` primitive or object. - * - * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are - * classified as numbers, use the `_.isFinite` method. + * Creates an array with all falsey values removed. The values `false`, `null`, + * `0`, `""`, `undefined`, and `NaN` are falsey. * * @static * @memberOf _ * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a number, else `false`. + * @category Array + * @param {Array} array The array to compact. + * @returns {Array} Returns the new array of filtered values. * @example * - * _.isNumber(3); - * // => true - * - * _.isNumber(Number.MIN_VALUE); - * // => true - * - * _.isNumber(Infinity); - * // => true - * - * _.isNumber('3'); - * // => false + * _.compact([0, 1, false, 2, '', 3]); + * // => [1, 2, 3] */ -function isNumber(value) { - return typeof value == 'number' || isObjectLike(value) && baseGetTag(value) == numberTag$4; +function compact(array) { + var index = -1, + length = array == null ? 0 : array.length, + resIndex = 0, + result = []; + + while (++index < length) { + var value = array[index]; + if (value) { + result[resIndex++] = value; + } + } + return result; } /** - * Checks if `value` is `NaN`. - * - * **Note:** This method is based on - * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as - * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for - * `undefined` and other non-number values. + * Creates a new array concatenating `array` with any additional arrays + * and/or values. * * @static * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. * @example * - * _.isNaN(NaN); - * // => true - * - * _.isNaN(new Number(NaN)); - * // => true + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); * - * isNaN(undefined); - * // => true + * console.log(other); + * // => [1, 2, 3, [4]] * - * _.isNaN(undefined); - * // => false + * console.log(array); + * // => [1] */ -function isNaN$1(value) { - // An `NaN` primitive is the only value that is not equal to itself. - // Perform the `toStringTag` check first to avoid errors with some - // ActiveX objects in IE. - return isNumber(value) && value != +value; +function concat() { + var length = arguments.length; + if (!length) { + return []; + } + var args = Array(length - 1), + array = arguments[0], + index = length; + + while (index--) { + args[index - 1] = arguments[index]; + } + return arrayPush(isArray$1(array) ? copyArray$1(array) : [array], baseFlatten(args, 1)); } +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED$2 = '__lodash_hash_undefined__'; + /** - * Checks if `func` is capable of being masked. + * Adds `value` to the array cache. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `func` is maskable, else `false`. + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. */ -var isMaskable = coreJsData ? isFunction : stubFalse; - -/** Error message constants. */ -var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.'; - -/** - * Checks if `value` is a pristine native function. - * - * **Note:** This method can't reliably detect native functions in the presence - * of the core-js package because core-js circumvents this kind of detection. - * Despite multiple requests, the core-js maintainer has made it clear: any - * attempt to fix the detection will be obstructed. As a result, we're left - * with little choice but to throw an error. Unfortunately, this also affects - * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), - * which rely on core-js. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - * @example - * - * _.isNative(Array.prototype.push); - * // => true - * - * _.isNative(_); - * // => false - */ -function isNative(value) { - if (isMaskable(value)) { - throw new Error(CORE_ERROR_TEXT); - } - return baseIsNative(value); +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED$2); + return this; } /** - * Checks if `value` is `null` or `undefined`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is nullish, else `false`. - * @example - * - * _.isNil(null); - * // => true - * - * _.isNil(void 0); - * // => true + * Checks if `value` is in the array cache. * - * _.isNil(NaN); - * // => false + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. */ -function isNil(value) { - return value == null; +function setCacheHas(value) { + return this.__data__.has(value); } /** - * Checks if `value` is `null`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `null`, else `false`. - * @example - * - * _.isNull(null); - * // => true * - * _.isNull(void 0); - * // => false - */ -function isNull(value) { - return value === null; -} - -/** `Object#toString` result references. */ -var regexpTag$4 = '[object RegExp]'; - -/** - * The base implementation of `_.isRegExp` without Node.js optimizations. + * Creates an array cache object to store unique values. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. + * @constructor + * @param {Array} [values] The values to cache. */ -function baseIsRegExp(value) { - return isObjectLike(value) && baseGetTag(value) == regexpTag$4; +function SetCache(values) { + var index = -1, + length = values == null ? 0 : values.length; + + this.__data__ = new MapCache(); + while (++index < length) { + this.add(values[index]); + } } -/* Node.js helper references. */ -var nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; /** - * Checks if `value` is classified as a `RegExp` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. - * @example - * - * _.isRegExp(/abc/); - * // => true + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. * - * _.isRegExp('/abc/'); - * // => false + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. */ -var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; - -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER$2 = 9007199254740991; +function arraySome(array, predicate) { + var index = -1, + length = array == null ? 0 : array.length; -/** - * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 - * double precision number which isn't the result of a rounded unsafe integer. - * - * **Note:** This method is based on - * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. - * @example - * - * _.isSafeInteger(3); - * // => true - * - * _.isSafeInteger(Number.MIN_VALUE); - * // => false - * - * _.isSafeInteger(Infinity); - * // => false - * - * _.isSafeInteger('3'); - * // => false - */ -function isSafeInteger$1(value) { - return isInteger$1(value) && value >= -MAX_SAFE_INTEGER$2 && value <= MAX_SAFE_INTEGER$2; + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; } -/** `Object#toString` result references. */ -var setTag$7 = '[object Set]'; - /** - * The base implementation of `_.isSet` without Node.js optimizations. + * Checks if a `cache` value for `key` exists. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. + * @param {Object} cache The cache to query. + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. */ -function baseIsSet(value) { - return isObjectLike(value) && getTag$1(value) == setTag$7; +function cacheHas(cache, key) { + return cache.has(key); } -/* Node.js helper references. */ -var nodeIsSet = nodeUtil && nodeUtil.isSet; +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$2 = 1; +var COMPARE_UNORDERED_FLAG$1 = 2; /** - * Checks if `value` is classified as a `Set` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a set, else `false`. - * @example - * - * _.isSet(new Set); - * // => true + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. * - * _.isSet(new WeakSet); - * // => false + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. */ -var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; +function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2, + arrLength = array.length, + othLength = other.length; -/** - * Checks if `value` is `undefined`. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true - * - * _.isUndefined(null); - * // => false - */ -function isUndefined(value) { - return value === undefined; -} + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; + } + var index = -1, + result = true, + seen = bitmask & COMPARE_UNORDERED_FLAG$1 ? new SetCache() : undefined; -/** `Object#toString` result references. */ -var weakMapTag$3 = '[object WeakMap]'; + stack.set(array, other); + stack.set(other, array); -/** - * Checks if `value` is classified as a `WeakMap` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. - * @example - * - * _.isWeakMap(new WeakMap); - * // => true - * - * _.isWeakMap(new Map); - * // => false - */ -function isWeakMap(value) { - return isObjectLike(value) && getTag$1(value) == weakMapTag$3; + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; + + if (customizer) { + var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function (othValue, othIndex) { + if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + return seen.push(othIndex); + } + })) { + result = false; + break; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { + result = false; + break; + } + } + stack['delete'](array); + stack['delete'](other); + return result; } +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$3 = 1; +var COMPARE_UNORDERED_FLAG$2 = 2; + /** `Object#toString` result references. */ -var weakSetTag = '[object WeakSet]'; +var boolTag$3 = '[object Boolean]'; +var dateTag$3 = '[object Date]'; +var errorTag$3 = '[object Error]'; +var mapTag$4 = '[object Map]'; +var numberTag$3 = '[object Number]'; +var regexpTag$3 = '[object RegExp]'; +var setTag$4 = '[object Set]'; +var stringTag$3 = '[object String]'; +var symbolTag$3 = '[object Symbol]'; -/** - * Checks if `value` is classified as a `WeakSet` object. - * - * @static - * @memberOf _ - * @since 4.3.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. - * @example - * - * _.isWeakSet(new WeakSet); - * // => true - * - * _.isWeakSet(new Set); - * // => false - */ -function isWeakSet(value) { - return isObjectLike(value) && baseGetTag(value) == weakSetTag; -} +var arrayBufferTag$3 = '[object ArrayBuffer]'; +var dataViewTag$4 = '[object DataView]'; -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$6 = 1; +/** Used to convert symbols to primitives and strings. */ +var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined; +var symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : undefined; /** - * Creates a function that invokes `func` with the arguments of the created - * function. If `func` is a property name, the created function returns the - * property value for a given element. If `func` is an array or object, the - * created function returns `true` for elements that contain the equivalent - * source properties, otherwise it returns `false`. - * - * @static - * @since 4.0.0 - * @memberOf _ - * @category Util - * @param {*} [func=_.identity] The value to convert to a callback. - * @returns {Function} Returns the callback. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36, 'active': true }, - * { 'user': 'fred', 'age': 40, 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); - * // => [{ 'user': 'barney', 'age': 36, 'active': true }] - * - * // The `_.matchesProperty` iteratee shorthand. - * _.filter(users, _.iteratee(['user', 'fred'])); - * // => [{ 'user': 'fred', 'age': 40 }] - * - * // The `_.property` iteratee shorthand. - * _.map(users, _.iteratee('user')); - * // => ['barney', 'fred'] + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. * - * // Create custom iteratee shorthands. - * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { - * return !_.isRegExp(func) ? iteratee(func) : function(string) { - * return func.test(string); - * }; - * }); + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * - * _.filter(['abc', 'def'], /ef/); - * // => ['def'] + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ -function iteratee(func) { - return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG$6)); +function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { + switch (tag) { + case dataViewTag$4: + if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) { + return false; + } + object = object.buffer; + other = other.buffer; + + case arrayBufferTag$3: + if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) { + return false; + } + return true; + + case boolTag$3: + case dateTag$3: + case numberTag$3: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); + + case errorTag$3: + return object.name == other.name && object.message == other.message; + + case regexpTag$3: + case stringTag$3: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == other + ''; + + case mapTag$4: + var convert = mapToArray; + + case setTag$4: + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3; + convert || (convert = setToArray); + + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= COMPARE_UNORDERED_FLAG$2; + + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); + stack['delete'](object); + return result; + + case symbolTag$3: + if (symbolValueOf$1) { + return symbolValueOf$1.call(object) == symbolValueOf$1.call(other); + } + } + return false; } +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$4 = 1; + /** Used for built-in method references. */ -var arrayProto$1 = Array.prototype; +var objectProto$18 = Object.prototype; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeJoin = arrayProto$1.join; +/** Used to check objects for own properties. */ +var hasOwnProperty$15 = objectProto$18.hasOwnProperty; /** - * Converts all elements in `array` into a string separated by `separator`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to convert. - * @param {string} [separator=','] The element separator. - * @returns {string} Returns the joined string. - * @example + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. * - * _.join(['a', 'b', 'c'], '~'); - * // => 'a~b~c' + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ -function join$1(array, separator) { - return array == null ? '' : nativeJoin.call(array, separator); -} +function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { + var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4, + objProps = getAllKeys(object), + objLength = objProps.length, + othProps = getAllKeys(other), + othLength = othProps.length; -/** - * Converts `string` to - * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the kebab cased string. - * @example - * - * _.kebabCase('Foo Bar'); - * // => 'foo-bar' - * - * _.kebabCase('fooBar'); - * // => 'foo-bar' - * - * _.kebabCase('__FOO_BAR__'); - * // => 'foo-bar' - */ -var kebabCase = createCompounder(function (result, word, index) { - return result + (index ? '-' : '') + word.toLowerCase(); -}); - -/** - * Creates an object composed of keys generated from the results of running - * each element of `collection` thru `iteratee`. The corresponding value of - * each key is the last element responsible for generating the key. The - * iteratee is invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee to transform keys. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var array = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.keyBy(array, function(o) { - * return String.fromCharCode(o.code); - * }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.keyBy(array, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - */ -var keyBy = createAggregator(function (result, value, key) { - baseAssignValue(result, key, value); -}); - -/** - * A specialized version of `_.lastIndexOf` which performs strict equality - * comparisons of values, i.e. `===`. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function strictLastIndexOf(array, value, fromIndex) { - var index = fromIndex + 1; + if (objLength != othLength && !isPartial) { + return false; + } + var index = objLength; while (index--) { - if (array[index] === value) { - return index; + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty$15.call(other, key))) { + return false; } } - return index; -} + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; + } + var result = true; + stack.set(object, other); + stack.set(other, object); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$11 = Math.max; -var nativeMin$7 = Math.min; + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; -/** - * This method is like `_.indexOf` except that it iterates over elements of - * `array` from right to left. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - * @example - * - * _.lastIndexOf([1, 2, 1, 2], 2); - * // => 3 - * - * // Search from the `fromIndex`. - * _.lastIndexOf([1, 2, 1, 2], 2, 2); - * // => 1 - */ -function lastIndexOf$1(array, value, fromIndex) { - var length = array == null ? 0 : array.length; - if (!length) { - return -1; + if (customizer) { + var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack); + } + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) { + result = false; + break; + } + skipCtor || (skipCtor = key == 'constructor'); } - var index = length; - if (fromIndex !== undefined) { - index = toInteger(fromIndex); - index = index < 0 ? nativeMax$11(length + index, 0) : nativeMin$7(index, length - 1); + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; + } } - return value === value ? strictLastIndexOf(array, value, index) : baseFindIndex(array, baseIsNaN, index, true); + stack['delete'](object); + stack['delete'](other); + return result; } -/** - * Converts `string`, as space separated words, to lower case. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the lower cased string. - * @example - * - * _.lowerCase('--Foo-Bar--'); - * // => 'foo bar' - * - * _.lowerCase('fooBar'); - * // => 'foo bar' - * - * _.lowerCase('__FOO_BAR__'); - * // => 'foo bar' - */ -var lowerCase = createCompounder(function (result, word, index) { - return result + (index ? ' ' : '') + word.toLowerCase(); -}); +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$1 = 1; -/** - * Converts the first character of `string` to lower case. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.lowerFirst('Fred'); - * // => 'fred' - * - * _.lowerFirst('FRED'); - * // => 'fRED' - */ -var lowerFirst = createCaseFirst('toLowerCase'); +/** `Object#toString` result references. */ +var argsTag$3 = '[object Arguments]'; +var arrayTag$2 = '[object Array]'; +var objectTag$4 = '[object Object]'; + +/** Used for built-in method references. */ +var objectProto$17 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$14 = objectProto$17.hasOwnProperty; /** - * The base implementation of `_.lt` which doesn't coerce arguments. + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. * * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. + * @param {Function} customizer The function to customize comparisons. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. */ -function baseLt(value, other) { - return value < other; +function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { + var objIsArr = isArray$1(object), + othIsArr = isArray$1(other), + objTag = objIsArr ? arrayTag$2 : getTag$1(object), + othTag = othIsArr ? arrayTag$2 : getTag$1(other); + + objTag = objTag == argsTag$3 ? objectTag$4 : objTag; + othTag = othTag == argsTag$3 ? objectTag$4 : othTag; + + var objIsObj = objTag == objectTag$4, + othIsObj = othTag == objectTag$4, + isSameTag = objTag == othTag; + + if (isSameTag && isBuffer(object)) { + if (!isBuffer(other)) { + return false; + } + objIsArr = true; + objIsObj = false; + } + if (isSameTag && !objIsObj) { + stack || (stack = new Stack()); + return objIsArr || isTypedArray$1(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); + } + if (!(bitmask & COMPARE_PARTIAL_FLAG$1)) { + var objIsWrapped = objIsObj && hasOwnProperty$14.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty$14.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; + + stack || (stack = new Stack()); + return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack()); + return equalObjects(object, other, bitmask, customizer, equalFunc, stack); } /** - * Checks if `value` is less than `other`. + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang + * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than `other`, - * else `false`. - * @see _.gt - * @example - * - * _.lt(1, 3); - * // => true - * - * _.lt(3, 3); - * // => false - * - * _.lt(3, 1); - * // => false + * @param {boolean} bitmask The bitmask flags. + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Function} [customizer] The function to customize comparisons. + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. */ -var lt = createRelationalOperation(baseLt); +function baseIsEqual(value, other, bitmask, customizer, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); +} + +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG = 1; +var COMPARE_UNORDERED_FLAG = 2; /** - * Checks if `value` is less than or equal to `other`. - * - * @static - * @memberOf _ - * @since 3.9.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if `value` is less than or equal to - * `other`, else `false`. - * @see _.gte - * @example - * - * _.lte(1, 3); - * // => true - * - * _.lte(3, 3); - * // => true + * The base implementation of `_.isMatch` without support for iteratee shorthands. * - * _.lte(3, 1); - * // => false + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ -var lte = createRelationalOperation(function (value, other) { - return value <= other; -}); +function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = Object(object); + while (index--) { + var data = matchData[index]; + if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var stack = new Stack(); + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) : result)) { + return false; + } + } + } + return true; +} /** - * The opposite of `_.mapValues`; this method creates an object with the - * same values as `object` and keys generated by running each own enumerable - * string keyed property of `object` thru `iteratee`. The iteratee is invoked - * with three arguments: (value, key, object). - * - * @static - * @memberOf _ - * @since 3.8.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapValues - * @example + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * - * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { - * return key + value; - * }); - * // => { 'a1': 1, 'b2': 2 } + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. */ -function mapKeys(object, iteratee) { - var result = {}; - iteratee = baseIteratee(iteratee, 3); - - baseForOwn(object, function (value, key, object) { - baseAssignValue(result, iteratee(value, key, object), value); - }); - return result; +function isStrictComparable(value) { + return value === value && !isObject(value); } /** - * Creates an object with the same keys as `object` and values generated - * by running each own enumerable string keyed property of `object` thru - * `iteratee`. The iteratee is invoked with three arguments: - * (value, key, object). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Object} Returns the new mapped object. - * @see _.mapKeys - * @example - * - * var users = { - * 'fred': { 'user': 'fred', 'age': 40 }, - * 'pebbles': { 'user': 'pebbles', 'age': 1 } - * }; - * - * _.mapValues(users, function(o) { return o.age; }); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * Gets the property names, values, and compare flags of `object`. * - * // The `_.property` iteratee shorthand. - * _.mapValues(users, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. */ -function mapValues(object, iteratee) { - var result = {}; - iteratee = baseIteratee(iteratee, 3); +function getMatchData(object) { + var result = keys$1(object), + length = result.length; - baseForOwn(object, function (value, key, object) { - baseAssignValue(result, key, iteratee(value, key, object)); - }); + while (length--) { + var key = result[length], + value = object[key]; + + result[length] = [key, value, isStrictComparable(value)]; + } return result; } -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$7 = 1; - /** - * Creates a function that performs a partial deep comparison between a given - * object and `source`, returning `true` if the given object has equivalent - * property values, else `false`. - * - * **Note:** The created function is equivalent to `_.isMatch` with `source` - * partially applied. - * - * Partial comparisons will match empty array and empty object `source` - * values against any array or object value, respectively. See `_.isEqual` - * for a list of supported value comparisons. + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {Object} source The object of property values to match. + * @private + * @param {string} key The key of the property to get. + * @param {*} srcValue The value to match. * @returns {Function} Returns the new spec function. - * @example - * - * var objects = [ - * { 'a': 1, 'b': 2, 'c': 3 }, - * { 'a': 4, 'b': 5, 'c': 6 } - * ]; - * - * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); - * // => [{ 'a': 4, 'b': 5, 'c': 6 }] */ -function matches(source) { - return baseMatches(baseClone(source, CLONE_DEEP_FLAG$7)); +function matchesStrictComparable(key, srcValue) { + return function (object) { + if (object == null) { + return false; + } + return object[key] === srcValue && (srcValue !== undefined || key in Object(object)); + }; } -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$8 = 1; - /** - * Creates a function that performs a partial deep comparison between the - * value at `path` of a given object to `srcValue`, returning `true` if the - * object value is equivalent, else `false`. - * - * **Note:** Partial comparisons will match empty array and empty object - * `srcValue` values against any array or object value, respectively. See - * `_.isEqual` for a list of supported value comparisons. + * The base implementation of `_.matches` which doesn't clone `source`. * - * @static - * @memberOf _ - * @since 3.2.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @param {*} srcValue The value to match. + * @private + * @param {Object} source The object of property values to match. * @returns {Function} Returns the new spec function. - * @example - * - * var objects = [ - * { 'a': 1, 'b': 2, 'c': 3 }, - * { 'a': 4, 'b': 5, 'c': 6 } - * ]; - * - * _.find(objects, _.matchesProperty('a', 4)); - * // => { 'a': 4, 'b': 5, 'c': 6 } */ -function matchesProperty(path, srcValue) { - return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG$8)); +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); + } + return function (object) { + return object === source || baseIsMatch(object, source, matchData); + }; } /** - * The base implementation of methods like `_.max` and `_.min` which accepts a - * `comparator` to determine the extremum value. + * The base implementation of `_.hasIn` without support for deep paths. * * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The iteratee invoked per iteration. - * @param {Function} comparator The comparator used to compare values. - * @returns {*} Returns the extremum value. + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. */ -function baseExtremum(array, iteratee, comparator) { +function baseHasIn(object, key) { + return object != null && key in Object(object); +} + +/** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ +function hasPath(object, path, hasFunc) { + path = castPath(path, object); + var index = -1, - length = array.length; + length = path.length, + result = false; while (++index < length) { - var value = array[index], - current = iteratee(value); - - if (current != null && (computed === undefined ? current === current && !isSymbol(current) : comparator(current, computed))) { - var computed = current, - result = value; + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; } + object = object[key]; } - return result; + if (result || ++index != length) { + return result; + } + length = object == null ? 0 : object.length; + return !!length && isLength(length) && isIndex(key, length) && (isArray$1(object) || isArguments(object)); } /** - * Computes the maximum value of `array`. If `array` is empty or falsey, - * `undefined` is returned. + * Checks if `path` is a direct or inherited property of `object`. * * @static - * @since 0.1.0 * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the maximum value. + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * - * _.max([4, 2, 8, 6]); - * // => 8 - * - * _.max([]); - * // => undefined - */ -function max$1(array) { - return array && array.length ? baseExtremum(array, identity$1, baseGt) : undefined; -} - -/** - * This method is like `_.max` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the maximum value. - * @example + * _.hasIn(object, 'a'); + * // => true * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * _.hasIn(object, 'a.b'); + * // => true * - * _.maxBy(objects, function(o) { return o.n; }); - * // => { 'n': 2 } + * _.hasIn(object, ['a', 'b']); + * // => true * - * // The `_.property` iteratee shorthand. - * _.maxBy(objects, 'n'); - * // => { 'n': 2 } + * _.hasIn(object, 'b'); + * // => false */ -function maxBy(array, iteratee) { - return array && array.length ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt) : undefined; +function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); } +/** Used to compose bitmasks for value comparisons. */ +var COMPARE_PARTIAL_FLAG$5 = 1; +var COMPARE_UNORDERED_FLAG$3 = 2; + /** - * The base implementation of `_.sum` and `_.sumBy` without support for - * iteratee shorthands. + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. * * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. */ -function baseSum(array, iteratee) { - var result, - index = -1, - length = array.length; - - while (++index < length) { - var current = iteratee(array[index]); - if (current !== undefined) { - result = result === undefined ? current : result + current; - } +function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); } - return result; + return function (object) { + var objValue = get$2(object, path); + return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3); + }; } -/** Used as references for various `Number` constants. */ -var NAN$2 = 0 / 0; - /** - * The base implementation of `_.mean` and `_.meanBy` without support for - * iteratee shorthands. + * The base implementation of `_.property` without support for deep paths. * * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the mean. + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. */ -function baseMean(array, iteratee) { - var length = array == null ? 0 : array.length; - return length ? baseSum(array, iteratee) / length : NAN$2; +function baseProperty(key) { + return function (object) { + return object == null ? undefined : object[key]; + }; } /** - * Computes the mean of the values in `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the mean. - * @example + * A specialized version of `baseProperty` which supports deep paths. * - * _.mean([4, 2, 8, 6]); - * // => 5 + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. */ -function mean(array) { - return baseMean(array, identity$1); +function basePropertyDeep(path) { + return function (object) { + return baseGet(object, path); + }; } /** - * This method is like `_.mean` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be averaged. - * The iteratee is invoked with one argument: (value). + * Creates a function that returns the value at `path` of a given object. * * @static * @memberOf _ - * @since 4.7.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the mean. + * @since 2.4.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. * @example * - * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; + * var objects = [ + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } + * ]; * - * _.meanBy(objects, function(o) { return o.n; }); - * // => 5 + * _.map(objects, _.property('a.b')); + * // => [2, 1] * - * // The `_.property` iteratee shorthand. - * _.meanBy(objects, 'n'); - * // => 5 + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); + * // => [1, 2] */ -function meanBy(array, iteratee) { - return baseMean(array, baseIteratee(iteratee, 2)); +function property(path) { + return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); } /** - * This method is like `_.assign` except that it recursively merges own and - * inherited enumerable string keyed properties of source objects into the - * destination object. Source properties that resolve to `undefined` are - * skipped if a destination value exists. Array and plain object properties - * are merged recursively. Other objects and value types are overridden by - * assignment. Source objects are applied from left to right. Subsequent - * sources overwrite property assignments of previous sources. + * The base implementation of `_.iteratee`. * - * **Note:** This method mutates `object`. + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ +function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; + } + if (value == null) { + return identity$1; + } + if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') { + return isArray$1(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value); + } + return property(value); +} + +/** Error message constants. */ +var FUNC_ERROR_TEXT$4 = 'Expected a function'; + +/** + * Creates a function that iterates over `pairs` and invokes the corresponding + * function of the first predicate to return truthy. The predicate-function + * pairs are invoked with the `this` binding and arguments of the created + * function. * * @static * @memberOf _ - * @since 0.5.0 - * @category Object - * @param {Object} object The destination object. - * @param {...Object} [sources] The source objects. - * @returns {Object} Returns `object`. + * @since 4.0.0 + * @category Util + * @param {Array} pairs The predicate-function pairs. + * @returns {Function} Returns the new composite function. * @example * - * var object = { - * 'a': [{ 'b': 2 }, { 'd': 4 }] - * }; + * var func = _.cond([ + * [_.matches({ 'a': 1 }), _.constant('matches A')], + * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], + * [_.stubTrue, _.constant('no match')] + * ]); * - * var other = { - * 'a': [{ 'c': 3 }, { 'e': 5 }] - * }; + * func({ 'a': 1, 'b': 2 }); + * // => 'matches A' * - * _.merge(object, other); - * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } + * func({ 'a': 0, 'b': 1 }); + * // => 'matches B' + * + * func({ 'a': '1', 'b': '2' }); + * // => 'no match' */ -var merge$1 = createAssigner(function (object, source, srcIndex) { - baseMerge(object, source, srcIndex); -}); +function cond(pairs) { + var length = pairs == null ? 0 : pairs.length, + toIteratee = baseIteratee; + + pairs = !length ? [] : arrayMap(pairs, function (pair) { + if (typeof pair[1] != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$4); + } + return [toIteratee(pair[0]), pair[1]]; + }); + + return baseRest(function (args) { + var index = -1; + while (++index < length) { + var pair = pairs[index]; + if (apply$1(pair[0], this, args)) { + return apply$1(pair[1], this, args); + } + } + }); +} /** - * Creates a function that invokes the method at `path` of a given object. - * Any additional arguments are provided to the invoked method. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Util - * @param {Array|string} path The path of the method to invoke. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {Function} Returns the new invoker function. - * @example - * - * var objects = [ - * { 'a': { 'b': _.constant(2) } }, - * { 'a': { 'b': _.constant(1) } } - * ]; - * - * _.map(objects, _.method('a.b')); - * // => [2, 1] + * The base implementation of `_.conformsTo` which accepts `props` to check. * - * _.map(objects, _.method(['a', 'b'])); - * // => [2, 1] + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. */ -var method = baseRest(function (path, args) { - return function (object) { - return baseInvoke(object, path, args); - }; -}); +function baseConformsTo(object, source, props) { + var length = props.length; + if (object == null) { + return !length; + } + object = Object(object); + while (length--) { + var key = props[length], + predicate = source[key], + value = object[key]; + + if (value === undefined && !(key in object) || !predicate(value)) { + return false; + } + } + return true; +} /** - * The opposite of `_.method`; this method creates a function that invokes - * the method at a given path of `object`. Any additional arguments are - * provided to the invoked method. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Util - * @param {Object} object The object to query. - * @param {...*} [args] The arguments to invoke the method with. - * @returns {Function} Returns the new invoker function. - * @example - * - * var array = _.times(3, _.constant), - * object = { 'a': array, 'b': array, 'c': array }; - * - * _.map(['a[2]', 'c[0]'], _.methodOf(object)); - * // => [2, 0] + * The base implementation of `_.conforms` which doesn't clone `source`. * - * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); - * // => [2, 0] + * @private + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. */ -var methodOf = baseRest(function (object, args) { - return function (path) { - return baseInvoke(object, path, args); +function baseConforms(source) { + var props = keys$1(source); + return function (object) { + return baseConformsTo(object, source, props); }; -}); +} + +/** Used to compose bitmasks for cloning. */ +var CLONE_DEEP_FLAG$5 = 1; /** - * Computes the minimum value of `array`. If `array` is empty or falsey, - * `undefined` is returned. + * Creates a function that invokes the predicate properties of `source` with + * the corresponding property values of a given object, returning `true` if + * all predicates return truthy, else `false`. + * + * **Note:** The created function is equivalent to `_.conformsTo` with + * `source` partially applied. * * @static - * @since 0.1.0 * @memberOf _ - * @category Math - * @param {Array} array The array to iterate over. - * @returns {*} Returns the minimum value. + * @since 4.0.0 + * @category Util + * @param {Object} source The object of property predicates to conform to. + * @returns {Function} Returns the new spec function. * @example * - * _.min([4, 2, 8, 6]); - * // => 2 + * var objects = [ + * { 'a': 2, 'b': 1 }, + * { 'a': 1, 'b': 2 } + * ]; * - * _.min([]); - * // => undefined + * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); + * // => [{ 'a': 1, 'b': 2 }] */ -function min$1(array) { - return array && array.length ? baseExtremum(array, identity$1, baseLt) : undefined; +function conforms(source) { + return baseConforms(baseClone(source, CLONE_DEEP_FLAG$5)); } /** - * This method is like `_.min` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the criterion by which - * the value is ranked. The iteratee is invoked with one argument: (value). + * Checks if `object` conforms to `source` by invoking the predicate + * properties of `source` with the corresponding property values of `object`. + * + * **Note:** This method is equivalent to `_.conforms` when `source` is + * partially applied. * * @static * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {*} Returns the minimum value. + * @since 4.14.0 + * @category Lang + * @param {Object} object The object to inspect. + * @param {Object} source The object of property predicates to conform to. + * @returns {boolean} Returns `true` if `object` conforms, else `false`. * @example * - * var objects = [{ 'n': 1 }, { 'n': 2 }]; + * var object = { 'a': 1, 'b': 2 }; * - * _.minBy(objects, function(o) { return o.n; }); - * // => { 'n': 1 } + * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); + * // => true * - * // The `_.property` iteratee shorthand. - * _.minBy(objects, 'n'); - * // => { 'n': 1 } + * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); + * // => false */ -function minBy(array, iteratee) { - return array && array.length ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt) : undefined; +function conformsTo(object, source) { + return source == null || baseConformsTo(object, source, keys$1(source)); } /** - * Adds all own enumerable string keyed function properties of a source - * object to the destination object. If `object` is a function, then methods - * are added to its prototype as well. - * - * **Note:** Use `_.runInContext` to create a pristine `lodash` function to - * avoid conflicts caused by modifying the original. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {Function|Object} [object=lodash] The destination object. - * @param {Object} source The object of functions to add. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.chain=true] Specify whether mixins are chainable. - * @returns {Function|Object} Returns `object`. - * @example - * - * function vowels(string) { - * return _.filter(string, function(v) { - * return /[aeiou]/i.test(v); - * }); - * } - * - * _.mixin({ 'vowels': vowels }); - * _.vowels('fred'); - * // => ['e'] - * - * _('fred').vowels().value(); - * // => ['e'] + * A specialized version of `baseAggregator` for arrays. * - * _.mixin({ 'vowels': vowels }, { 'chain': false }); - * _('fred').vowels(); - * // => ['e'] + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. */ -function mixin(object, source, options) { - var props = keys$1(source), - methodNames = baseFunctions(source, props); - - var chain = !(isObject(options) && 'chain' in options) || !!options.chain, - isFunc = isFunction(object); - - arrayEach(methodNames, function (methodName) { - var func = source[methodName]; - object[methodName] = func; - if (isFunc) { - object.prototype[methodName] = function () { - var chainAll = this.__chain__; - if (chain || chainAll) { - var result = object(this.__wrapped__), - actions = result.__actions__ = copyArray$1(this.__actions__); - - actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); - result.__chain__ = chainAll; - return result; - } - return func.apply(object, arrayPush([this.value()], arguments)); - }; - } - }); +function arrayAggregator(array, setter, iteratee, accumulator) { + var index = -1, + length = array == null ? 0 : array.length; - return object; + while (++index < length) { + var value = array[index]; + setter(accumulator, value, iteratee(value), array); + } + return accumulator; } /** - * Multiply two numbers. + * Creates a base function for methods like `_.forIn` and `_.forOwn`. * - * @static - * @memberOf _ - * @since 4.7.0 - * @category Math - * @param {number} multiplier The first number in a multiplication. - * @param {number} multiplicand The second number in a multiplication. - * @returns {number} Returns the product. - * @example - * - * _.multiply(6, 4); - * // => 24 + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. */ -var multiply$1 = createMathOperation(function (multiplier, multiplicand) { - return multiplier * multiplicand; -}, 1); +function createBaseFor(fromRight) { + return function (object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; -/** Error message constants. */ -var FUNC_ERROR_TEXT$8 = 'Expected a function'; + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} /** - * Creates a function that negates the result of the predicate `func`. The - * `func` predicate is invoked with the `this` binding and arguments of the - * created function. + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} predicate The predicate to negate. - * @returns {Function} Returns the new negated function. - * @example + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); + +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. * - * function isEven(n) { - * return n % 2 == 0; - * } + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys$1); +} + +/** + * Creates a `baseEach` or `baseEachRight` function. * - * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); - * // => [1, 3, 5] + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. */ -function negate$1(predicate) { - if (typeof predicate != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$8); - } - return function () { - var args = arguments; - switch (args.length) { - case 0: - return !predicate.call(this); - case 1: - return !predicate.call(this, args[0]); - case 2: - return !predicate.call(this, args[0], args[1]); - case 3: - return !predicate.call(this, args[0], args[1], args[2]); +function createBaseEach(eachFunc, fromRight) { + return function (collection, iteratee) { + if (collection == null) { + return collection; } - return !predicate.apply(this, args); + if (!isArrayLike(collection)) { + return eachFunc(collection, iteratee); + } + var length = collection.length, + index = fromRight ? length : -1, + iterable = Object(collection); + + while (fromRight ? index-- : ++index < length) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; }; } /** - * Converts `iterator` to an array. + * The base implementation of `_.forEach` without support for iteratee shorthands. * * @private - * @param {Object} iterator The iterator to convert. - * @returns {Array} Returns the converted array. + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. */ -function iteratorToArray(iterator) { - var data, - result = []; +var baseEach = createBaseEach(baseForOwn); - while (!(data = iterator.next()).done) { - result.push(data.value); - } - return result; +/** + * Aggregates elements of `collection` on `accumulator` with keys transformed + * by `iteratee` and values set by `setter`. + * + * @private + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform keys. + * @param {Object} accumulator The initial aggregated object. + * @returns {Function} Returns `accumulator`. + */ +function baseAggregator(collection, setter, iteratee, accumulator) { + baseEach(collection, function (value, key, collection) { + setter(accumulator, value, iteratee(value), collection); + }); + return accumulator; } -/** `Object#toString` result references. */ -var mapTag$8 = '[object Map]'; -var setTag$8 = '[object Set]'; +/** + * Creates a function like `_.groupBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} [initializer] The accumulator object initializer. + * @returns {Function} Returns the new aggregator function. + */ +function createAggregator(setter, initializer) { + return function (collection, iteratee) { + var func = isArray$1(collection) ? arrayAggregator : baseAggregator, + accumulator = initializer ? initializer() : {}; -/** Built-in value references. */ -var symIterator = _Symbol ? _Symbol.iterator : undefined; + return func(collection, setter, baseIteratee(iteratee, 2), accumulator); + }; +} + +/** Used for built-in method references. */ +var objectProto$19 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$16 = objectProto$19.hasOwnProperty; /** - * Converts `value` to an array. + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The corresponding value of + * each key is the number of times the key was returned by `iteratee`. The + * iteratee is invoked with one argument: (value). * * @static - * @since 0.1.0 * @memberOf _ - * @category Lang - * @param {*} value The value to convert. - * @returns {Array} Returns the converted array. + * @since 0.5.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. * @example * - * _.toArray({ 'a': 1, 'b': 2 }); - * // => [1, 2] - * - * _.toArray('abc'); - * // => ['a', 'b', 'c'] - * - * _.toArray(1); - * // => [] + * _.countBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': 1, '6': 2 } * - * _.toArray(null); - * // => [] + * // The `_.property` iteratee shorthand. + * _.countBy(['one', 'two', 'three'], 'length'); + * // => { '3': 2, '5': 1 } */ -function toArray$2(value) { - if (!value) { - return []; - } - if (isArrayLike(value)) { - return isString(value) ? stringToArray(value) : copyArray$1(value); - } - if (symIterator && value[symIterator]) { - return iteratorToArray(value[symIterator]()); +var countBy = createAggregator(function (result, value, key) { + if (hasOwnProperty$16.call(result, key)) { + ++result[key]; + } else { + baseAssignValue(result, key, 1); } - var tag = getTag$1(value), - func = tag == mapTag$8 ? mapToArray : tag == setTag$8 ? setToArray : values$1; - - return func(value); -} +}); /** - * Gets the next value on a wrapped object following the - * [iterator protocol](https://mdn.io/iteration_protocols#iterator). + * Creates an object that inherits from the `prototype` object. If a + * `properties` object is given, its own enumerable string keyed properties + * are assigned to the created object. * - * @name next + * @static * @memberOf _ - * @since 4.0.0 - * @category Seq - * @returns {Object} Returns the next iterator value. + * @since 2.3.0 + * @category Object + * @param {Object} prototype The object to inherit from. + * @param {Object} [properties] The properties to assign to the object. + * @returns {Object} Returns the new object. * @example * - * var wrapped = _([1, 2]); + * function Shape() { + * this.x = 0; + * this.y = 0; + * } * - * wrapped.next(); - * // => { 'done': false, 'value': 1 } + * function Circle() { + * Shape.call(this); + * } * - * wrapped.next(); - * // => { 'done': false, 'value': 2 } + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); * - * wrapped.next(); - * // => { 'done': true, 'value': undefined } + * var circle = new Circle; + * circle instanceof Circle; + * // => true + * + * circle instanceof Shape; + * // => true */ -function wrapperNext() { - if (this.__values__ === undefined) { - this.__values__ = toArray$2(this.value()); - } - var done = this.__index__ >= this.__values__.length, - value = done ? undefined : this.__values__[this.__index__++]; - - return { 'done': done, 'value': value }; +function create$1(prototype, properties) { + var result = baseCreate(prototype); + return properties == null ? result : baseAssign(result, properties); } -/** - * The base implementation of `_.nth` which doesn't coerce arguments. - * - * @private - * @param {Array} array The array to query. - * @param {number} n The index of the element to return. - * @returns {*} Returns the nth element of `array`. - */ -function baseNth(array, n) { - var length = array.length; - if (!length) { - return; - } - n += n < 0 ? length : 0; - return isIndex(n, length) ? array[n] : undefined; -} +/** Used to compose bitmasks for function metadata. */ +var WRAP_CURRY_FLAG$5 = 8; /** - * Gets the element at index `n` of `array`. If `n` is negative, the nth - * element from the end is returned. + * Creates a function that accepts arguments of `func` and either invokes + * `func` returning its result, if at least `arity` number of arguments have + * been provided, or returns a function that accepts the remaining `func` + * arguments, and so on. The arity of `func` may be specified if `func.length` + * is not sufficient. + * + * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. * * @static * @memberOf _ - * @since 4.11.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=0] The index of the element to return. - * @returns {*} Returns the nth element of `array`. + * @since 2.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. * @example * - * var array = ['a', 'b', 'c', 'd']; + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; * - * _.nth(array, 1); - * // => 'b' + * var curried = _.curry(abc); * - * _.nth(array, -2); - * // => 'c'; + * curried(1)(2)(3); + * // => [1, 2, 3] + * + * curried(1, 2)(3); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(1)(_, 3)(2); + * // => [1, 2, 3] */ -function nth(array, n) { - return array && array.length ? baseNth(array, toInteger(n)) : undefined; +function curry(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_FLAG$5, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curry.placeholder; + return result; } +// Assign default placeholders. +curry.placeholder = {}; + +/** Used to compose bitmasks for function metadata. */ +var WRAP_CURRY_RIGHT_FLAG$3 = 16; + /** - * Creates a function that gets the argument at index `n`. If `n` is negative, - * the nth argument from the end is returned. + * This method is like `_.curry` except that arguments are applied to `func` + * in the manner of `_.partialRight` instead of `_.partial`. + * + * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic + * builds, may be used as a placeholder for provided arguments. + * + * **Note:** This method doesn't set the "length" property of curried functions. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {number} [n=0] The index of the argument to return. - * @returns {Function} Returns the new pass-thru function. + * @since 3.0.0 + * @category Function + * @param {Function} func The function to curry. + * @param {number} [arity=func.length] The arity of `func`. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Function} Returns the new curried function. * @example * - * var func = _.nthArg(1); - * func('a', 'b', 'c', 'd'); - * // => 'b' + * var abc = function(a, b, c) { + * return [a, b, c]; + * }; * - * var func = _.nthArg(-2); - * func('a', 'b', 'c', 'd'); - * // => 'c' - */ -function nthArg(n) { - n = toInteger(n); - return baseRest(function (args) { - return baseNth(args, n); - }); -} - -/** - * The base implementation of `_.unset`. + * var curried = _.curryRight(abc); * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The property path to unset. - * @returns {boolean} Returns `true` if the property is deleted, else `false`. + * curried(3)(2)(1); + * // => [1, 2, 3] + * + * curried(2, 3)(1); + * // => [1, 2, 3] + * + * curried(1, 2, 3); + * // => [1, 2, 3] + * + * // Curried with placeholders. + * curried(3)(1, _)(2); + * // => [1, 2, 3] */ -function baseUnset(object, path) { - path = castPath(path, object); - object = parent(object, path); - return object == null || delete object[toKey(last$1(path))]; +function curryRight(func, arity, guard) { + arity = guard ? undefined : arity; + var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG$3, undefined, undefined, undefined, undefined, undefined, arity); + result.placeholder = curryRight.placeholder; + return result; } +// Assign default placeholders. +curryRight.placeholder = {}; + /** - * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain - * objects. + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). * - * @private - * @param {*} value The value to inspect. - * @param {string} key The key of the property to inspect. - * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. */ -function customOmitClone(value) { - return isPlainObject(value) ? undefined : value; -} +var now$1 = function now$1() { + return root.Date.now(); +}; -/** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG$9 = 1; -var CLONE_FLAT_FLAG$1 = 2; -var CLONE_SYMBOLS_FLAG$5 = 4; +/** Error message constants. */ +var FUNC_ERROR_TEXT$5 = 'Expected a function'; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$5 = Math.max; +var nativeMin$3 = Math.min; /** - * The opposite of `_.pick`; this method creates an object composed of the - * own and inherited enumerable property paths of `object` that are not omitted. + * Creates a debounced function that delays invoking `func` until after `wait` + * milliseconds have elapsed since the last time the debounced function was + * invoked. The debounced function comes with a `cancel` method to cancel + * delayed `func` invocations and a `flush` method to immediately invoke them. + * Provide `options` to indicate whether `func` should be invoked on the + * leading and/or trailing edge of the `wait` timeout. The `func` is invoked + * with the last arguments provided to the debounced function. Subsequent + * calls to the debounced function return the result of the last `func` + * invocation. * - * **Note:** This method is considerably slower than `_.pick`. + * **Note:** If `leading` and `trailing` options are `true`, `func` is + * invoked on the trailing edge of the timeout only if the debounced function + * is invoked more than once during the `wait` timeout. + * + * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred + * until to the next tick, similar to `setTimeout` with a timeout of `0`. + * + * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) + * for details over the differences between `_.debounce` and `_.throttle`. * * @static - * @since 0.1.0 * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to omit. - * @returns {Object} Returns the new object. + * @since 0.1.0 + * @category Function + * @param {Function} func The function to debounce. + * @param {number} [wait=0] The number of milliseconds to delay. + * @param {Object} [options={}] The options object. + * @param {boolean} [options.leading=false] + * Specify invoking on the leading edge of the timeout. + * @param {number} [options.maxWait] + * The maximum time `func` is allowed to be delayed before it's invoked. + * @param {boolean} [options.trailing=true] + * Specify invoking on the trailing edge of the timeout. + * @returns {Function} Returns the new debounced function. * @example * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * // Avoid costly calculations while the window size is in flux. + * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); * - * _.omit(object, ['a', 'c']); - * // => { 'b': '2' } + * // Invoke `sendMail` when clicked, debouncing subsequent calls. + * jQuery(element).on('click', _.debounce(sendMail, 300, { + * 'leading': true, + * 'trailing': false + * })); + * + * // Ensure `batchLog` is invoked once after 1 second of debounced calls. + * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); + * var source = new EventSource('/stream'); + * jQuery(source).on('message', debounced); + * + * // Cancel the trailing debounced invocation. + * jQuery(window).on('popstate', debounced.cancel); */ -var omit = flatRest(function (object, paths) { - var result = {}; - if (object == null) { - return result; - } - var isDeep = false; - paths = arrayMap(paths, function (path) { - path = castPath(path, object); - isDeep || (isDeep = path.length > 1); - return path; - }); - copyObject(object, getAllKeysIn(object), result); - if (isDeep) { - result = baseClone(result, CLONE_DEEP_FLAG$9 | CLONE_FLAT_FLAG$1 | CLONE_SYMBOLS_FLAG$5, customOmitClone); +function debounce(func, wait, options) { + var lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime, + lastInvokeTime = 0, + leading = false, + maxing = false, + trailing = true; + + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$5); } - var length = paths.length; - while (length--) { - baseUnset(result, paths[length]); + wait = toNumber(wait) || 0; + if (isObject(options)) { + leading = !!options.leading; + maxing = 'maxWait' in options; + maxWait = maxing ? nativeMax$5(toNumber(options.maxWait) || 0, wait) : maxWait; + trailing = 'trailing' in options ? !!options.trailing : trailing; } - return result; -}); -/** - * The base implementation of `_.set`. - * - * @private - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize path creation. - * @returns {Object} Returns `object`. - */ -function baseSet(object, path, value, customizer) { - if (!isObject(object)) { - return object; + function invokeFunc(time) { + var args = lastArgs, + thisArg = lastThis; + + lastArgs = lastThis = undefined; + lastInvokeTime = time; + result = func.apply(thisArg, args); + return result; } - path = castPath(path, object); - var index = -1, - length = path.length, - lastIndex = length - 1, - nested = object; + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time; + // Start the timer for the trailing edge. + timerId = setTimeout(timerExpired, wait); + // Invoke the leading edge. + return leading ? invokeFunc(time) : result; + } - while (nested != null && ++index < length) { - var key = toKey(path[index]), - newValue = value; + function remainingWait(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime, + result = wait - timeSinceLastCall; - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {}; - } + return maxing ? nativeMin$3(result, maxWait - timeSinceLastInvoke) : result; + } + + function shouldInvoke(time) { + var timeSinceLastCall = time - lastCallTime, + timeSinceLastInvoke = time - lastInvokeTime; + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; + } + + function timerExpired() { + var time = now$1(); + if (shouldInvoke(time)) { + return trailingEdge(time); } - assignValue(nested, key, newValue); - nested = nested[key]; + // Restart the timer. + timerId = setTimeout(timerExpired, remainingWait(time)); } - return object; -} -/** - * The base implementation of `_.pickBy` without support for iteratee shorthands. - * - * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @param {Function} predicate The function invoked per property. - * @returns {Object} Returns the new object. - */ -function basePickBy(object, paths, predicate) { - var index = -1, - length = paths.length, - result = {}; + function trailingEdge(time) { + timerId = undefined; - while (++index < length) { - var path = paths[index], - value = baseGet(object, path); + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time); + } + lastArgs = lastThis = undefined; + return result; + } - if (predicate(value, path)) { - baseSet(result, castPath(path, object), value); + function cancel() { + if (timerId !== undefined) { + clearTimeout(timerId); + } + lastInvokeTime = 0; + lastArgs = lastCallTime = lastThis = timerId = undefined; + } + + function flush() { + return timerId === undefined ? result : trailingEdge(now$1()); + } + + function debounced() { + var time = now$1(), + isInvoking = shouldInvoke(time); + + lastArgs = arguments; + lastThis = this; + lastCallTime = time; + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime); + } + if (maxing) { + // Handle invocations in a tight loop. + timerId = setTimeout(timerExpired, wait); + return invokeFunc(lastCallTime); + } } + if (timerId === undefined) { + timerId = setTimeout(timerExpired, wait); + } + return result; } - return result; + debounced.cancel = cancel; + debounced.flush = flush; + return debounced; } /** - * Creates an object composed of the `object` properties `predicate` returns - * truthy for. The predicate is invoked with two arguments: (value, key). + * Checks `value` to determine whether a default value should be returned in + * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, + * or `undefined`. * * @static * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The source object. - * @param {Function} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. + * @since 4.14.0 + * @category Util + * @param {*} value The value to check. + * @param {*} defaultValue The default value. + * @returns {*} Returns the resolved value. * @example * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * _.defaultTo(1, 10); + * // => 1 * - * _.pickBy(object, _.isNumber); - * // => { 'a': 1, 'c': 3 } + * _.defaultTo(undefined, 10); + * // => 10 */ -function pickBy(object, predicate) { - if (object == null) { - return {}; +function defaultTo(value, defaultValue) { + return value == null || value !== value ? defaultValue : value; +} + +/** Used for built-in method references. */ +var objectProto$20 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$17 = objectProto$20.hasOwnProperty; + +/** + * Used by `_.defaults` to customize its `_.assignIn` use to assign properties + * of source objects to the destination object for all destination properties + * that resolve to `undefined`. + * + * @private + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to assign. + * @param {Object} object The parent object of `objValue`. + * @returns {*} Returns the value to assign. + */ +function customDefaultsAssignIn(objValue, srcValue, key, object) { + if (objValue === undefined || eq(objValue, objectProto$20[key]) && !hasOwnProperty$17.call(object, key)) { + return srcValue; } - var props = arrayMap(getAllKeysIn(object), function (prop) { - return [prop]; - }); - predicate = baseIteratee(predicate); - return basePickBy(object, props, function (value, path) { - return predicate(value, path[0]); - }); + return objValue; } /** - * The opposite of `_.pickBy`; this method creates an object composed of - * the own and inherited enumerable string keyed properties of `object` that - * `predicate` doesn't return truthy for. The predicate is invoked with two - * arguments: (value, key). + * Assigns own and inherited enumerable string keyed properties of source + * objects to the destination object for all destination properties that + * resolve to `undefined`. Source objects are applied from left to right. + * Once a property is set, additional values of the same property are ignored. + * + * **Note:** This method mutates `object`. * * @static + * @since 0.1.0 * @memberOf _ - * @since 4.0.0 * @category Object - * @param {Object} object The source object. - * @param {Function} [predicate=_.identity] The function invoked per property. - * @returns {Object} Returns the new object. + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaultsDeep * @example * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; - * - * _.omitBy(object, _.isNumber); - * // => { 'b': '2' } + * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); + * // => { 'a': 1, 'b': 2 } */ -function omitBy(object, predicate) { - return pickBy(object, negate$1(baseIteratee(predicate))); -} +var defaults$1 = baseRest(function (args) { + args.push(undefined, customDefaultsAssignIn); + return apply$1(assignInWith, undefined, args); +}); /** - * Creates a function that is restricted to invoking `func` once. Repeat calls - * to the function return the value of the first invocation. The `func` is - * invoked with the `this` binding and arguments of the created function. + * This function is like `assignValue` except that it doesn't assign + * `undefined` values. * - * @static + * @private + * @param {Object} object The object to modify. + * @param {string} key The key of the property to assign. + * @param {*} value The value to assign. + */ +function assignMergeValue(object, key, value) { + if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) { + baseAssignValue(object, key, value); + } +} + +/** + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. + * + * @static * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. * @example * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // => `createApplication` is invoked once + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false */ -function once(func) { - return before(2, func); +function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); } /** - * The base implementation of `_.sortBy` which uses `comparer` to define the - * sort order of `array` and replaces criteria objects with their corresponding - * values. + * Converts `value` to a plain object flattening inherited enumerable string + * keyed properties of `value` to own properties of the plain object. * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {Object} Returns the converted plain object. + * @example + * + * function Foo() { + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.assign({ 'a': 1 }, new Foo); + * // => { 'a': 1, 'b': 2 } + * + * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); + * // => { 'a': 1, 'b': 2, 'c': 3 } */ -function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; +function toPlainObject(value) { + return copyObject(value, keysIn$1(value)); } /** - * Compares values to sort them in ascending order. + * A specialized version of `baseMerge` for arrays and objects which performs + * deep merges and tracks traversed objects enabling objects with circular + * references to be merged. * * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {number} Returns the sort order indicator for `value`. + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. + * @param {Function} mergeFunc The function to merge values. + * @param {Function} [customizer] The function to customize assigned values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ -function compareAscending(value, other) { - if (value !== other) { - var valIsDefined = value !== undefined, - valIsNull = value === null, - valIsReflexive = value === value, - valIsSymbol = isSymbol(value); +function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { + var objValue = object[key], + srcValue = source[key], + stacked = stack.get(srcValue); - var othIsDefined = other !== undefined, - othIsNull = other === null, - othIsReflexive = other === other, - othIsSymbol = isSymbol(other); + if (stacked) { + assignMergeValue(object, key, stacked); + return; + } + var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined; - if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) { - return 1; - } - if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) { - return -1; + var isCommon = newValue === undefined; + + if (isCommon) { + var isArr = isArray$1(srcValue), + isBuff = !isArr && isBuffer(srcValue), + isTyped = !isArr && !isBuff && isTypedArray$1(srcValue); + + newValue = srcValue; + if (isArr || isBuff || isTyped) { + if (isArray$1(objValue)) { + newValue = objValue; + } else if (isArrayLikeObject(objValue)) { + newValue = copyArray$1(objValue); + } else if (isBuff) { + isCommon = false; + newValue = cloneBuffer(srcValue, true); + } else if (isTyped) { + isCommon = false; + newValue = cloneTypedArray(srcValue, true); + } else { + newValue = []; + } + } else if (isPlainObject(srcValue) || isArguments(srcValue)) { + newValue = objValue; + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } else if (!isObject(objValue) || srcIndex && isFunction(objValue)) { + newValue = initCloneObject(srcValue); + } + } else { + isCommon = false; } } - return 0; + if (isCommon) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, newValue); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); + stack['delete'](srcValue); + } + assignMergeValue(object, key, newValue); } /** - * Used by `_.orderBy` to compare multiple properties of a value to another - * and stable sort them. - * - * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, - * specify an order of "desc" for descending or "asc" for ascending sort order - * of corresponding values. + * The base implementation of `_.merge` without support for multiple sources. * * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {boolean[]|string[]} orders The order to sort by for each property. - * @returns {number} Returns the sort order indicator for `object`. + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. + * @param {Function} [customizer] The function to customize merged values. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. */ -function compareMultiple(object, other, orders) { - var index = -1, - objCriteria = object.criteria, - othCriteria = other.criteria, - length = objCriteria.length, - ordersLength = orders.length; +function baseMerge(object, source, srcIndex, customizer, stack) { + if (object === source) { + return; + } + baseFor(source, function (srcValue, key) { + if (isObject(srcValue)) { + stack || (stack = new Stack()); + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); + } else { + var newValue = customizer ? customizer(object[key], srcValue, key + '', object, source, stack) : undefined; - while (++index < length) { - var result = compareAscending(objCriteria[index], othCriteria[index]); - if (result) { - if (index >= ordersLength) { - return result; + if (newValue === undefined) { + newValue = srcValue; } - var order = orders[index]; - return result * (order == 'desc' ? -1 : 1); + assignMergeValue(object, key, newValue); } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; + }, keysIn$1); } /** - * The base implementation of `_.orderBy` without param guards. + * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source + * objects into destination objects that are passed thru. * * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. - * @param {string[]} orders The sort orders of `iteratees`. - * @returns {Array} Returns the new sorted array. + * @param {*} objValue The destination value. + * @param {*} srcValue The source value. + * @param {string} key The key of the property to merge. + * @param {Object} object The parent object of `objValue`. + * @param {Object} source The parent object of `srcValue`. + * @param {Object} [stack] Tracks traversed source values and their merged + * counterparts. + * @returns {*} Returns the value to assign. */ -function baseOrderBy(collection, iteratees, orders) { - var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity$1], baseUnary(baseIteratee)); - - var result = baseMap(collection, function (value, key, collection) { - var criteria = arrayMap(iteratees, function (iteratee) { - return iteratee(value); - }); - return { 'criteria': criteria, 'index': ++index, 'value': value }; - }); - - return baseSortBy(result, function (object, other) { - return compareMultiple(object, other, orders); - }); +function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { + if (isObject(objValue) && isObject(srcValue)) { + // Recursively merge objects and arrays (susceptible to call stack limits). + stack.set(srcValue, objValue); + baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); + stack['delete'](srcValue); + } + return objValue; } /** - * This method is like `_.sortBy` except that it allows specifying the sort - * orders of the iteratees to sort by. If `orders` is unspecified, all values - * are sorted in ascending order. Otherwise, specify an order of "desc" for - * descending or "asc" for ascending sort order of corresponding values. - * - * @static + * This method is like `_.merge` except that it accepts `customizer` which + * is invoked to produce the merged values of the destination and source + * properties. If `customizer` returns `undefined`, merging is handled by the + * method instead. The `customizer` is invoked with six arguments: + * (objValue, srcValue, key, object, source, stack). + * + * **Note:** This method mutates `object`. + * + * @static * @memberOf _ * @since 4.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] - * The iteratees to sort by. - * @param {string[]} [orders] The sort orders of `iteratees`. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. - * @returns {Array} Returns the new sorted array. + * @category Object + * @param {Object} object The destination object. + * @param {...Object} sources The source objects. + * @param {Function} customizer The function to customize assigned values. + * @returns {Object} Returns `object`. * @example * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 34 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 36 } - * ]; + * function customizer(objValue, srcValue) { + * if (_.isArray(objValue)) { + * return objValue.concat(srcValue); + * } + * } * - * // Sort by `user` in ascending order and by `age` in descending order. - * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] - */ -function orderBy(collection, iteratees, orders, guard) { - if (collection == null) { - return []; - } - if (!isArray$1(iteratees)) { - iteratees = iteratees == null ? [] : [iteratees]; - } - orders = guard ? undefined : orders; - if (!isArray$1(orders)) { - orders = orders == null ? [] : [orders]; - } - return baseOrderBy(collection, iteratees, orders); -} - -/** - * Creates a function like `_.over`. + * var object = { 'a': [1], 'b': [2] }; + * var other = { 'a': [3], 'b': [4] }; * - * @private - * @param {Function} arrayFunc The function to iterate over iteratees. - * @returns {Function} Returns the new over function. + * _.mergeWith(object, other, customizer); + * // => { 'a': [1, 3], 'b': [2, 4] } */ -function createOver(arrayFunc) { - return flatRest(function (iteratees) { - iteratees = arrayMap(iteratees, baseUnary(baseIteratee)); - return baseRest(function (args) { - var thisArg = this; - return arrayFunc(iteratees, function (iteratee) { - return apply$1(iteratee, thisArg, args); - }); - }); - }); -} +var mergeWith = createAssigner(function (object, source, srcIndex, customizer) { + baseMerge(object, source, srcIndex, customizer); +}); /** - * Creates a function that invokes `iteratees` with the arguments it receives - * and returns their results. + * This method is like `_.defaults` except that it recursively assigns + * default properties. + * + * **Note:** This method mutates `object`. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {...(Function|Function[])} [iteratees=[_.identity]] - * The iteratees to invoke. - * @returns {Function} Returns the new function. + * @since 3.10.0 + * @category Object + * @param {Object} object The destination object. + * @param {...Object} [sources] The source objects. + * @returns {Object} Returns `object`. + * @see _.defaults * @example * - * var func = _.over([Math.max, Math.min]); - * - * func(1, 2, 3, 4); - * // => [4, 1] + * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); + * // => { 'a': { 'b': 2, 'c': 3 } } */ -var over = createOver(arrayMap); +var defaultsDeep = baseRest(function (args) { + args.push(undefined, customDefaultsMerge); + return apply$1(mergeWith, undefined, args); +}); + +/** Error message constants. */ +var FUNC_ERROR_TEXT$6 = 'Expected a function'; /** - * A `baseRest` alias which can be replaced with `identity` by module - * replacement plugins. + * The base implementation of `_.delay` and `_.defer` which accepts `args` + * to provide to `func`. * * @private - * @type {Function} - * @param {Function} func The function to apply a rest parameter to. - * @returns {Function} Returns the new function. + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {Array} args The arguments to provide to `func`. + * @returns {number|Object} Returns the timer id or timeout object. */ -var castRest = baseRest; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin$8 = Math.min; +function baseDelay(func, wait, args) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$6); + } + return setTimeout(function () { + func.apply(undefined, args); + }, wait); +} /** - * Creates a function that invokes `func` with its arguments transformed. + * Defers invoking the `func` until the current call stack has cleared. Any + * additional arguments are provided to `func` when it's invoked. * * @static - * @since 4.0.0 * @memberOf _ + * @since 0.1.0 * @category Function - * @param {Function} func The function to wrap. - * @param {...(Function|Function[])} [transforms=[_.identity]] - * The argument transforms. - * @returns {Function} Returns the new function. + * @param {Function} func The function to defer. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. * @example * - * function doubled(n) { - * return n * 2; - * } - * - * function square(n) { - * return n * n; - * } - * - * var func = _.overArgs(function(x, y) { - * return [x, y]; - * }, [square, doubled]); - * - * func(9, 3); - * // => [81, 6] - * - * func(10, 5); - * // => [100, 10] + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); + * // => Logs 'deferred' after one millisecond. */ -var overArgs = castRest(function (func, transforms) { - transforms = transforms.length == 1 && isArray$1(transforms[0]) ? arrayMap(transforms[0], baseUnary(baseIteratee)) : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee)); - - var funcsLength = transforms.length; - return baseRest(function (args) { - var index = -1, - length = nativeMin$8(args.length, funcsLength); - - while (++index < length) { - args[index] = transforms[index].call(this, args[index]); - } - return apply$1(func, this, args); - }); +var defer = baseRest(function (func, args) { + return baseDelay(func, 1, args); }); /** - * Creates a function that checks if **all** of the `predicates` return - * truthy when invoked with the arguments it receives. + * Invokes `func` after `wait` milliseconds. Any additional arguments are + * provided to `func` when it's invoked. * * @static * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {...(Function|Function[])} [predicates=[_.identity]] - * The predicates to check. - * @returns {Function} Returns the new function. + * @since 0.1.0 + * @category Function + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @param {...*} [args] The arguments to invoke `func` with. + * @returns {number} Returns the timer id. * @example * - * var func = _.overEvery([Boolean, isFinite]); - * - * func('1'); - * // => true - * - * func(null); - * // => false - * - * func(NaN); - * // => false + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); + * // => Logs 'later' after one second. */ -var overEvery = createOver(arrayEvery); +var delay = baseRest(function (func, wait, args) { + return baseDelay(func, toNumber(wait) || 0, args); +}); /** - * Creates a function that checks if **any** of the `predicates` return - * truthy when invoked with the arguments it receives. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Util - * @param {...(Function|Function[])} [predicates=[_.identity]] - * The predicates to check. - * @returns {Function} Returns the new function. - * @example - * - * var func = _.overSome([Boolean, isFinite]); - * - * func('1'); - * // => true - * - * func(null); - * // => true + * This function is like `arrayIncludes` except that it accepts a comparator. * - * func(NaN); - * // => false + * @private + * @param {Array} [array] The array to inspect. + * @param {*} target The value to search for. + * @param {Function} comparator The comparator invoked per element. + * @returns {boolean} Returns `true` if `target` is found, else `false`. */ -var overSome = createOver(arraySome); +function arrayIncludesWith(array, value, comparator) { + var index = -1, + length = array == null ? 0 : array.length; -/** Used as references for various `Number` constants. */ -var MAX_SAFE_INTEGER$3 = 9007199254740991; + while (++index < length) { + if (comparator(value, array[index])) { + return true; + } + } + return false; +} -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeFloor$1 = Math.floor; +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE$1 = 200; /** - * The base implementation of `_.repeat` which doesn't coerce arguments. + * The base implementation of methods like `_.difference` without support + * for excluding multiple arrays or iteratee shorthands. * * @private - * @param {string} string The string to repeat. - * @param {number} n The number of times to repeat the string. - * @returns {string} Returns the repeated string. + * @param {Array} array The array to inspect. + * @param {Array} values The values to exclude. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. */ -function baseRepeat(string, n) { - var result = ''; - if (!string || n < 1 || n > MAX_SAFE_INTEGER$3) { +function baseDifference(array, values, iteratee, comparator) { + var index = -1, + includes = arrayIncludes, + isCommon = true, + length = array.length, + result = [], + valuesLength = values.length; + + if (!length) { return result; } - // Leverage the exponentiation by squaring algorithm for a faster repeat. - // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. - do { - if (n % 2) { - result += string; - } - n = nativeFloor$1(n / 2); - if (n) { - string += string; - } - } while (n); + if (iteratee) { + values = arrayMap(values, baseUnary(iteratee)); + } + if (comparator) { + includes = arrayIncludesWith; + isCommon = false; + } else if (values.length >= LARGE_ARRAY_SIZE$1) { + includes = cacheHas; + isCommon = false; + values = new SetCache(values); + } + outer: while (++index < length) { + var value = array[index], + computed = iteratee == null ? value : iteratee(value); + value = comparator || value !== 0 ? value : 0; + if (isCommon && computed === computed) { + var valuesIndex = valuesLength; + while (valuesIndex--) { + if (values[valuesIndex] === computed) { + continue outer; + } + } + result.push(value); + } else if (!includes(values, computed, comparator)) { + result.push(value); + } + } return result; } /** - * Gets the size of an ASCII `string`. + * Creates an array of `array` values not included in the other given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ -var asciiSize = baseProperty('length'); - -/** Used to compose unicode character classes. */ -var rsAstralRange$3 = '\\ud800-\\udfff'; -var rsComboMarksRange$4 = '\\u0300-\\u036f'; -var reComboHalfMarksRange$4 = '\\ufe20-\\ufe2f'; -var rsComboSymbolsRange$4 = '\\u20d0-\\u20ff'; -var rsComboRange$4 = rsComboMarksRange$4 + reComboHalfMarksRange$4 + rsComboSymbolsRange$4; -var rsVarRange$3 = '\\ufe0e\\ufe0f'; - -/** Used to compose unicode capture groups. */ -var rsAstral$1 = '[' + rsAstralRange$3 + ']'; -var rsCombo$3 = '[' + rsComboRange$4 + ']'; -var rsFitz$2 = '\\ud83c[\\udffb-\\udfff]'; -var rsModifier$2 = '(?:' + rsCombo$3 + '|' + rsFitz$2 + ')'; -var rsNonAstral$2 = '[^' + rsAstralRange$3 + ']'; -var rsRegional$2 = '(?:\\ud83c[\\udde6-\\uddff]){2}'; -var rsSurrPair$2 = '[\\ud800-\\udbff][\\udc00-\\udfff]'; -var rsZWJ$3 = '\\u200d'; - -/** Used to compose unicode regexes. */ -var reOptMod$2 = rsModifier$2 + '?'; -var rsOptVar$2 = '[' + rsVarRange$3 + ']?'; -var rsOptJoin$2 = '(?:' + rsZWJ$3 + '(?:' + [rsNonAstral$2, rsRegional$2, rsSurrPair$2].join('|') + ')' + rsOptVar$2 + reOptMod$2 + ')*'; -var rsSeq$2 = rsOptVar$2 + reOptMod$2 + rsOptJoin$2; -var rsSymbol$1 = '(?:' + [rsNonAstral$2 + rsCombo$3 + '?', rsCombo$3, rsRegional$2, rsSurrPair$2, rsAstral$1].join('|') + ')'; - -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -var reUnicode$1 = RegExp(rsFitz$2 + '(?=' + rsFitz$2 + ')|' + rsSymbol$1 + rsSeq$2, 'g'); - -/** - * Gets the size of a Unicode `string`. + * **Note:** Unlike `_.pullAll`, this method returns a new array. * - * @private - * @param {string} string The string inspect. - * @returns {number} Returns the string size. - */ -function unicodeSize(string) { - var result = reUnicode$1.lastIndex = 0; - while (reUnicode$1.test(string)) { - ++result; - } - return result; -} - -/** - * Gets the number of symbols in `string`. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @returns {Array} Returns the new array of filtered values. + * @see _.without, _.xor + * @example * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the string size. + * _.difference([2, 1], [2, 3]); + * // => [1] */ -function stringSize(string) { - return hasUnicode(string) ? unicodeSize(string) : asciiSize(string); -} - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil$2 = Math.ceil; +var difference = baseRest(function (array, values) { + return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) : []; +}); /** - * Creates the padding for `string` based on `length`. The `chars` string - * is truncated if the number of characters exceeds `length`. + * Gets the last element of `array`. * - * @private - * @param {number} length The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padding for `string`. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 */ -function createPadding(length, chars) { - chars = chars === undefined ? ' ' : baseToString(chars); - - var charsLength = chars.length; - if (charsLength < 2) { - return charsLength ? baseRepeat(chars, length) : chars; - } - var result = baseRepeat(chars, nativeCeil$2(length / stringSize(chars))); - return hasUnicode(chars) ? castSlice(stringToArray(result), 0, length).join('') : result.slice(0, length); +function last$1(array) { + var length = array == null ? 0 : array.length; + return length ? array[length - 1] : undefined; } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil$1 = Math.ceil; -var nativeFloor = Math.floor; - /** - * Pads `string` on the left and right sides if it's shorter than `length`. - * Padding characters are truncated if they can't be evenly divided by `length`. + * This method is like `_.difference` except that it accepts `iteratee` which + * is invoked for each element of `array` and `values` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). + * + * **Note:** Unlike `_.pullAllBy`, this method returns a new array. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. + * @since 4.0.0 + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of filtered values. * @example * - * _.pad('abc', 8); - * // => ' abc ' - * - * _.pad('abc', 8, '_-'); - * // => '_-abc_-_' + * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [1.2] * - * _.pad('abc', 3); - * // => 'abc' + * // The `_.property` iteratee shorthand. + * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); + * // => [{ 'x': 2 }] */ -function pad(string, length, chars) { - string = toString$1(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - if (!length || strLength >= length) { - return string; +var differenceBy = baseRest(function (array, values) { + var iteratee = last$1(values); + if (isArrayLikeObject(iteratee)) { + iteratee = undefined; } - var mid = (length - strLength) / 2; - return createPadding(nativeFloor(mid), chars) + string + createPadding(nativeCeil$1(mid), chars); -} + return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2)) : []; +}); /** - * Pads `string` on the right side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. + * This method is like `_.difference` except that it accepts `comparator` + * which is invoked to compare elements of `array` to `values`. The order and + * references of result values are determined by the first array. The comparator + * is invoked with two arguments: (arrVal, othVal). + * + * **Note:** Unlike `_.pullAllWith`, this method returns a new array. * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. + * @category Array + * @param {Array} array The array to inspect. + * @param {...Array} [values] The values to exclude. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of filtered values. * @example * - * _.padEnd('abc', 6); - * // => 'abc ' - * - * _.padEnd('abc', 6, '_-'); - * // => 'abc_-_' + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; * - * _.padEnd('abc', 3); - * // => 'abc' + * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); + * // => [{ 'x': 2, 'y': 1 }] */ -function padEnd$1(string, length, chars) { - string = toString$1(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - return length && strLength < length ? string + createPadding(length - strLength, chars) : string; -} +var differenceWith = baseRest(function (array, values) { + var comparator = last$1(values); + if (isArrayLikeObject(comparator)) { + comparator = undefined; + } + return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) : []; +}); /** - * Pads `string` on the left side if it's shorter than `length`. Padding - * characters are truncated if they exceed `length`. + * Divide two numbers. * * @static * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to pad. - * @param {number} [length=0] The padding length. - * @param {string} [chars=' '] The string used as padding. - * @returns {string} Returns the padded string. + * @since 4.7.0 + * @category Math + * @param {number} dividend The first number in a division. + * @param {number} divisor The second number in a division. + * @returns {number} Returns the quotient. * @example * - * _.padStart('abc', 6); - * // => ' abc' - * - * _.padStart('abc', 6, '_-'); - * // => '_-_abc' - * - * _.padStart('abc', 3); - * // => 'abc' + * _.divide(6, 4); + * // => 1.5 */ -function padStart$1(string, length, chars) { - string = toString$1(string); - length = toInteger(length); - - var strLength = length ? stringSize(string) : 0; - return length && strLength < length ? createPadding(length - strLength, chars) + string : string; -} - -/** Used to match leading and trailing whitespace. */ -var reTrimStart = /^\s+/; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeParseInt = root.parseInt; +var divide$1 = createMathOperation(function (dividend, divisor) { + return dividend / divisor; +}, 1); /** - * Converts `string` to an integer of the specified radix. If `radix` is - * `undefined` or `0`, a `radix` of `10` is used unless `value` is a - * hexadecimal, in which case a `radix` of `16` is used. - * - * **Note:** This method aligns with the - * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. + * Creates a slice of `array` with `n` elements dropped from the beginning. * * @static * @memberOf _ - * @since 1.1.0 - * @category String - * @param {string} string The string to convert. - * @param {number} [radix=10] The radix to interpret `value` by. + * @since 0.5.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {number} Returns the converted integer. + * @returns {Array} Returns the slice of `array`. * @example * - * _.parseInt('08'); - * // => 8 + * _.drop([1, 2, 3]); + * // => [2, 3] * - * _.map(['6', '08', '10'], _.parseInt); - * // => [6, 8, 10] + * _.drop([1, 2, 3], 2); + * // => [3] + * + * _.drop([1, 2, 3], 5); + * // => [] + * + * _.drop([1, 2, 3], 0); + * // => [1, 2, 3] */ -function parseInt$1(string, radix, guard) { - if (guard || radix == null) { - radix = 0; - } else if (radix) { - radix = +radix; +function drop(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; } - return nativeParseInt(toString$1(string).replace(reTrimStart, ''), radix || 0); + n = guard || n === undefined ? 1 : toInteger(n); + return baseSlice(array, n < 0 ? 0 : n, length); } -/** Used to compose bitmasks for function metadata. */ -var WRAP_PARTIAL_FLAG$6 = 32; - /** - * Creates a function that invokes `func` with `partials` prepended to the - * arguments it receives. This method is like `_.bind` except it does **not** - * alter the `this` binding. - * - * The `_.partial.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. + * Creates a slice of `array` with `n` elements dropped from the end. * * @static * @memberOf _ - * @since 0.2.0 - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {number} [n=1] The number of elements to drop. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the slice of `array`. * @example * - * function greet(greeting, name) { - * return greeting + ' ' + name; - * } + * _.dropRight([1, 2, 3]); + * // => [1, 2] * - * var sayHelloTo = _.partial(greet, 'hello'); - * sayHelloTo('fred'); - * // => 'hello fred' + * _.dropRight([1, 2, 3], 2); + * // => [1] * - * // Partially applied with placeholders. - * var greetFred = _.partial(greet, _, 'fred'); - * greetFred('hi'); - * // => 'hi fred' + * _.dropRight([1, 2, 3], 5); + * // => [] + * + * _.dropRight([1, 2, 3], 0); + * // => [1, 2, 3] */ -var partial = baseRest(function (func, partials) { - var holders = replaceHolders(partials, getHolder(partial)); - return createWrap(func, WRAP_PARTIAL_FLAG$6, undefined, partials, holders); -}); +function dropRight(array, n, guard) { + var length = array == null ? 0 : array.length; + if (!length) { + return []; + } + n = guard || n === undefined ? 1 : toInteger(n); + n = length - n; + return baseSlice(array, 0, n < 0 ? 0 : n); +} -// Assign default placeholders. -partial.placeholder = {}; +/** + * The base implementation of methods like `_.dropWhile` and `_.takeWhile` + * without support for iteratee shorthands. + * + * @private + * @param {Array} array The array to query. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [isDrop] Specify dropping elements instead of taking them. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the slice of `array`. + */ +function baseWhile(array, predicate, isDrop, fromRight) { + var length = array.length, + index = fromRight ? length : -1; -/** Used to compose bitmasks for function metadata. */ -var WRAP_PARTIAL_RIGHT_FLAG$3 = 64; + while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {} + + return isDrop ? baseSlice(array, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array, fromRight ? index + 1 : 0, fromRight ? length : index); +} /** - * This method is like `_.partial` except that partially applied arguments - * are appended to the arguments it receives. - * - * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic - * builds, may be used as a placeholder for partially applied arguments. - * - * **Note:** This method doesn't set the "length" property of partially - * applied functions. + * Creates a slice of `array` excluding elements dropped from the end. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). * * @static * @memberOf _ - * @since 1.0.0 - * @category Function - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [partials] The arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to query. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {Array} Returns the slice of `array`. * @example * - * function greet(greeting, name) { - * return greeting + ' ' + name; - * } + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; * - * var greetFred = _.partialRight(greet, 'fred'); - * greetFred('hi'); - * // => 'hi fred' + * _.dropRightWhile(users, function(o) { return !o.active; }); + * // => objects for ['barney'] * - * // Partially applied with placeholders. - * var sayHelloTo = _.partialRight(greet, 'hello', _); - * sayHelloTo('fred'); - * // => 'hello fred' + * // The `_.matches` iteratee shorthand. + * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); + * // => objects for ['barney', 'fred'] + * + * // The `_.matchesProperty` iteratee shorthand. + * _.dropRightWhile(users, ['active', false]); + * // => objects for ['barney'] + * + * // The `_.property` iteratee shorthand. + * _.dropRightWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] */ -var partialRight = baseRest(function (func, partials) { - var holders = replaceHolders(partials, getHolder(partialRight)); - return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG$3, undefined, partials, holders); -}); - -// Assign default placeholders. -partialRight.placeholder = {}; +function dropRightWhile(array, predicate) { + return array && array.length ? baseWhile(array, baseIteratee(predicate, 3), true, true) : []; +} /** - * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, the second of which - * contains elements `predicate` returns falsey for. The predicate is - * invoked with one argument: (value). + * Creates a slice of `array` excluding elements dropped from the beginning. + * Elements are dropped until `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index, array). * * @static * @memberOf _ * @since 3.0.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. + * @category Array + * @param {Array} array The array to query. * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the array of grouped elements. + * @returns {Array} Returns the slice of `array`. * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true }, - * { 'user': 'pebbles', 'age': 1, 'active': false } + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } * ]; * - * _.partition(users, function(o) { return o.active; }); - * // => objects for [['fred'], ['barney', 'pebbles']] + * _.dropWhile(users, function(o) { return !o.active; }); + * // => objects for ['pebbles'] * * // The `_.matches` iteratee shorthand. - * _.partition(users, { 'age': 1, 'active': false }); - * // => objects for [['pebbles'], ['barney', 'fred']] + * _.dropWhile(users, { 'user': 'barney', 'active': false }); + * // => objects for ['fred', 'pebbles'] * * // The `_.matchesProperty` iteratee shorthand. - * _.partition(users, ['active', false]); - * // => objects for [['barney', 'pebbles'], ['fred']] + * _.dropWhile(users, ['active', false]); + * // => objects for ['pebbles'] * * // The `_.property` iteratee shorthand. - * _.partition(users, 'active'); - * // => objects for [['fred'], ['barney', 'pebbles']] + * _.dropWhile(users, 'active'); + * // => objects for ['barney', 'fred', 'pebbles'] */ -var partition = createAggregator(function (result, value, key) { - result[key ? 0 : 1].push(value); -}, function () { - return [[], []]; -}); +function dropWhile(array, predicate) { + return array && array.length ? baseWhile(array, baseIteratee(predicate, 3), true) : []; +} /** - * The base implementation of `_.pick` without support for individual - * property identifiers. + * Casts `value` to `identity` if it's not a function. * * @private - * @param {Object} object The source object. - * @param {string[]} paths The property paths to pick. - * @returns {Object} Returns the new object. + * @param {*} value The value to inspect. + * @returns {Function} Returns cast function. */ -function basePick(object, paths) { - return basePickBy(object, paths, function (value, path) { - return hasIn(object, path); - }); +function castFunction(value) { + return typeof value == 'function' ? value : identity$1; } /** - * Creates an object composed of the picked `object` properties. + * Iterates over elements of `collection` and invokes `iteratee` for each element. + * The iteratee is invoked with three arguments: (value, index|key, collection). + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" + * property are iterated like arrays. To avoid this behavior use `_.forIn` + * or `_.forOwn` for object iteration. * * @static - * @since 0.1.0 * @memberOf _ - * @category Object - * @param {Object} object The source object. - * @param {...(string|string[])} [paths] The property paths to pick. - * @returns {Object} Returns the new object. + * @since 0.1.0 + * @alias each + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEachRight * @example * - * var object = { 'a': 1, 'b': '2', 'c': 3 }; + * _.forEach([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `1` then `2`. * - * _.pick(object, ['a', 'c']); - * // => { 'a': 1, 'c': 3 } + * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ -var pick = flatRest(function (object, paths) { - return object == null ? {} : basePick(object, paths); -}); +function forEach$1(collection, iteratee) { + var func = isArray$1(collection) ? arrayEach : baseEach; + return func(collection, castFunction(iteratee)); +} /** - * Creates a clone of the chain sequence planting `value` as the wrapped value. - * - * @name plant - * @memberOf _ - * @since 3.2.0 - * @category Seq - * @param {*} value The value to plant. - * @returns {Object} Returns the new `lodash` wrapper instance. - * @example - * - * function square(n) { - * return n * n; - * } - * - * var wrapped = _([1, 2]).map(square); - * var other = wrapped.plant([3, 4]); - * - * other.value(); - * // => [9, 16] + * A specialized version of `_.forEachRight` for arrays without support for + * iteratee shorthands. * - * wrapped.value(); - * // => [1, 4] + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. */ -function wrapperPlant(value) { - var result, - parent = this; +function arrayEachRight(array, iteratee) { + var length = array == null ? 0 : array.length; - while (parent instanceof baseLodash) { - var clone = wrapperClone(parent); - clone.__index__ = 0; - clone.__values__ = undefined; - if (result) { - previous.__wrapped__ = clone; - } else { - result = clone; + while (length--) { + if (iteratee(array[length], length, array) === false) { + break; } - var previous = clone; - parent = parent.__wrapped__; } - previous.__wrapped__ = value; - return result; + return array; } /** - * The opposite of `_.property`; this method creates a function that returns - * the value at a given path of `object`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Util - * @param {Object} object The object to query. - * @returns {Function} Returns the new accessor function. - * @example - * - * var array = [0, 1, 2], - * object = { 'a': array, 'b': array, 'c': array }; - * - * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); - * // => [2, 0] + * This function is like `baseFor` except that it iterates over properties + * in the opposite order. * - * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); - * // => [2, 0] + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. */ -function propertyOf(object) { - return function (path) { - return object == null ? undefined : baseGet(object, path); - }; -} +var baseForRight = createBaseFor(true); /** - * This function is like `baseIndexOf` except that it accepts a comparator. + * The base implementation of `_.forOwnRight` without support for iteratee shorthands. * * @private - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @param {Function} comparator The comparator invoked per element. - * @returns {number} Returns the index of the matched value, else `-1`. + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. */ -function baseIndexOfWith(array, value, fromIndex, comparator) { - var index = fromIndex - 1, - length = array.length; - - while (++index < length) { - if (comparator(array[index], value)) { - return index; - } - } - return -1; +function baseForOwnRight(object, iteratee) { + return object && baseForRight(object, iteratee, keys$1); } -/** Used for built-in method references. */ -var arrayProto$2 = Array.prototype; - -/** Built-in value references. */ -var splice$1 = arrayProto$2.splice; - /** - * The base implementation of `_.pullAllBy` without support for iteratee - * shorthands. + * The base implementation of `_.forEachRight` without support for iteratee shorthands. * * @private - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee] The iteratee invoked per element. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. */ -function basePullAll(array, values, iteratee, comparator) { - var indexOf = comparator ? baseIndexOfWith : baseIndexOf, - index = -1, - length = values.length, - seen = array; - - if (array === values) { - values = copyArray$1(values); - } - if (iteratee) { - seen = arrayMap(array, baseUnary(iteratee)); - } - while (++index < length) { - var fromIndex = 0, - value = values[index], - computed = iteratee ? iteratee(value) : value; - - while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { - if (seen !== array) { - splice$1.call(seen, fromIndex, 1); - } - splice$1.call(array, fromIndex, 1); - } - } - return array; -} +var baseEachRight = createBaseEach(baseForOwnRight, true); /** - * This method is like `_.pull` except that it accepts an array of values to remove. - * - * **Note:** Unlike `_.difference`, this method mutates `array`. + * This method is like `_.forEach` except that it iterates over elements of + * `collection` from right to left. * * @static * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @returns {Array} Returns `array`. + * @since 2.0.0 + * @alias eachRight + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array|Object} Returns `collection`. + * @see _.forEach * @example * - * var array = ['a', 'b', 'c', 'a', 'b', 'c']; - * - * _.pullAll(array, ['a', 'c']); - * console.log(array); - * // => ['b', 'b'] + * _.forEachRight([1, 2], function(value) { + * console.log(value); + * }); + * // => Logs `2` then `1`. */ -function pullAll(array, values) { - return array && array.length && values && values.length ? basePullAll(array, values) : array; +function forEachRight(collection, iteratee) { + var func = isArray$1(collection) ? arrayEachRight : baseEachRight; + return func(collection, castFunction(iteratee)); } /** - * Removes all given values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * for equality comparisons. - * - * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` - * to remove elements from an array by predicate. + * Checks if `string` ends with the given target string. * * @static * @memberOf _ - * @since 2.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {...*} [values] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = ['a', 'b', 'c', 'a', 'b', 'c']; - * - * _.pull(array, 'a', 'c'); - * console.log(array); - * // => ['b', 'b'] - */ -var pull = baseRest(pullAll); - -/** - * This method is like `_.pullAll` except that it accepts `iteratee` which is - * invoked for each element of `array` and `values` to generate the criterion - * by which they're compared. The iteratee is invoked with one argument: (value). - * - * **Note:** Unlike `_.differenceBy`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {Array} Returns `array`. + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search up to. + * @returns {boolean} Returns `true` if `string` ends with `target`, + * else `false`. * @example * - * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; + * _.endsWith('abc', 'c'); + * // => true * - * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); - * console.log(array); - * // => [{ 'x': 2 }] + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true */ -function pullAllBy(array, values, iteratee) { - return array && array.length && values && values.length ? basePullAll(array, values, baseIteratee(iteratee, 2)) : array; +function endsWith$1(string, target, position) { + string = toString$1(string); + target = baseToString(target); + + var length = string.length; + position = position === undefined ? length : baseClamp(toInteger(position), 0, length); + + var end = position; + position -= target.length; + return position >= 0 && string.slice(position, end) == target; } /** - * This method is like `_.pullAll` except that it accepts `comparator` which - * is invoked to compare elements of `array` to `values`. The comparator is - * invoked with two arguments: (arrVal, othVal). - * - * **Note:** Unlike `_.differenceWith`, this method mutates `array`. - * - * @static - * @memberOf _ - * @since 4.6.0 - * @category Array - * @param {Array} array The array to modify. - * @param {Array} values The values to remove. - * @param {Function} [comparator] The comparator invoked per element. - * @returns {Array} Returns `array`. - * @example - * - * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; + * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array + * of key-value pairs for `object` corresponding to the property names of `props`. * - * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); - * console.log(array); - * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the key-value pairs. */ -function pullAllWith(array, values, comparator) { - return array && array.length && values && values.length ? basePullAll(array, values, undefined, comparator) : array; +function baseToPairs(object, props) { + return arrayMap(props, function (key) { + return [key, object[key]]; + }); } -/** Used for built-in method references. */ -var arrayProto$3 = Array.prototype; +/** + * Converts `set` to its value-value pairs. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the value-value pairs. + */ +function setToPairs(set) { + var index = -1, + result = Array(set.size); -/** Built-in value references. */ -var splice$2 = arrayProto$3.splice; + set.forEach(function (value) { + result[++index] = [value, value]; + }); + return result; +} + +/** `Object#toString` result references. */ +var mapTag$5 = '[object Map]'; +var setTag$5 = '[object Set]'; /** - * The base implementation of `_.pullAt` without support for individual - * indexes or capturing the removed elements. + * Creates a `_.toPairs` or `_.toPairsIn` function. * * @private - * @param {Array} array The array to modify. - * @param {number[]} indexes The indexes of elements to remove. - * @returns {Array} Returns `array`. + * @param {Function} keysFunc The function to get the keys of a given object. + * @returns {Function} Returns the new pairs function. */ -function basePullAt(array, indexes) { - var length = array ? indexes.length : 0, - lastIndex = length - 1; - - while (length--) { - var index = indexes[length]; - if (length == lastIndex || index !== previous) { - var previous = index; - if (isIndex(index)) { - splice$2.call(array, index, 1); - } else { - baseUnset(array, index); - } +function createToPairs(keysFunc) { + return function (object) { + var tag = getTag$1(object); + if (tag == mapTag$5) { + return mapToArray(object); } - } - return array; + if (tag == setTag$5) { + return setToPairs(object); + } + return baseToPairs(object, keysFunc(object)); + }; } /** - * Removes elements from `array` corresponding to `indexes` and returns an - * array of removed elements. - * - * **Note:** Unlike `_.at`, this method mutates `array`. + * Creates an array of own enumerable string keyed-value pairs for `object` + * which can be consumed by `_.fromPairs`. If `object` is a map or set, its + * entries are returned. * * @static * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The array to modify. - * @param {...(number|number[])} [indexes] The indexes of elements to remove. - * @returns {Array} Returns the new array of removed elements. + * @since 4.0.0 + * @alias entries + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. * @example * - * var array = ['a', 'b', 'c', 'd']; - * var pulled = _.pullAt(array, [1, 3]); + * function Foo() { + * this.a = 1; + * this.b = 2; + * } * - * console.log(array); - * // => ['a', 'c'] + * Foo.prototype.c = 3; * - * console.log(pulled); - * // => ['b', 'd'] + * _.toPairs(new Foo); + * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) */ -var pullAt = flatRest(function (array, indexes) { - var length = array == null ? 0 : array.length, - result = baseAt(array, indexes); - - basePullAt(array, arrayMap(indexes, function (index) { - return isIndex(index, length) ? +index : index; - }).sort(compareAscending)); +var toPairs = createToPairs(keys$1); - return result; -}); +/** + * Creates an array of own and inherited enumerable string keyed-value pairs + * for `object` which can be consumed by `_.fromPairs`. If `object` is a map + * or set, its entries are returned. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @alias entriesIn + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the key-value pairs. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.toPairsIn(new Foo); + * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) + */ +var toPairsIn = createToPairs(keysIn$1); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeFloor$2 = Math.floor; -var nativeRandom$1 = Math.random; +/** Used to map characters to HTML entities. */ +var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; /** - * The base implementation of `_.random` without support for returning - * floating-point numbers. + * Used by `_.escape` to convert characters to HTML entities. * * @private - * @param {number} lower The lower bound. - * @param {number} upper The upper bound. - * @returns {number} Returns the random number. + * @param {string} chr The matched character to escape. + * @returns {string} Returns the escaped character. */ -function baseRandom(lower, upper) { - return lower + nativeFloor$2(nativeRandom$1() * (upper - lower + 1)); -} - -/** Built-in method references without a dependency on `root`. */ -var freeParseFloat = parseFloat; +var escapeHtmlChar = basePropertyOf(htmlEscapes); -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMin$9 = Math.min; -var nativeRandom = Math.random; +/** Used to match HTML entities and HTML characters. */ +var reUnescapedHtml = /[&<>"']/g; +var reHasUnescapedHtml = RegExp(reUnescapedHtml.source); /** - * Produces a random number between the inclusive `lower` and `upper` bounds. - * If only one argument is provided a number between `0` and the given number - * is returned. If `floating` is `true`, or either `lower` or `upper` are - * floats, a floating-point number is returned instead of an integer. + * Converts the characters "&", "<", ">", '"', and "'" in `string` to their + * corresponding HTML entities. * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. + * **Note:** No other characters are escaped. To escape additional + * characters use a third-party library like [_he_](https://mths.be/he). + * + * Though the ">" character is escaped for symmetry, characters like + * ">" and "/" don't need escaping in HTML and have no special meaning + * unless they're part of a tag or unquoted attribute value. See + * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) + * (under "semi-related fun fact") for more details. + * + * When working with HTML you should always + * [quote attribute values](http://wonko.com/post/html-escaping) to reduce + * XSS vectors. * * @static + * @since 0.1.0 * @memberOf _ - * @since 0.7.0 - * @category Number - * @param {number} [lower=0] The lower bound. - * @param {number} [upper=1] The upper bound. - * @param {boolean} [floating] Specify returning a floating-point number. - * @returns {number} Returns the random number. + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. * @example * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 + * _.escape('fred, barney, & pebbles'); + * // => 'fred, barney, & pebbles' + */ +function escape$1(string) { + string = toString$1(string); + return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar) : string; +} + +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar$1 = /[\\^$.*+?()[\]{}|]/g; +var reHasRegExpChar = RegExp(reRegExpChar$1.source); + +/** + * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", + * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. * - * _.random(5, true); - * // => a floating-point number between 0 and 5 + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to escape. + * @returns {string} Returns the escaped string. + * @example * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 + * _.escapeRegExp('[lodash](https://lodash.com/)'); + * // => '\[lodash\]\(https://lodash\.com/\)' */ -function random(lower, upper, floating) { - if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { - upper = floating = undefined; - } - if (floating === undefined) { - if (typeof upper == 'boolean') { - floating = upper; - upper = undefined; - } else if (typeof lower == 'boolean') { - floating = lower; - lower = undefined; - } - } - if (lower === undefined && upper === undefined) { - lower = 0; - upper = 1; - } else { - lower = toFinite(lower); - if (upper === undefined) { - upper = lower; - lower = 0; - } else { - upper = toFinite(upper); - } - } - if (lower > upper) { - var temp = lower; - lower = upper; - upper = temp; - } - if (floating || lower % 1 || upper % 1) { - var rand = nativeRandom(); - return nativeMin$9(lower + rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1))), upper); - } - return baseRandom(lower, upper); +function escapeRegExp(string) { + string = toString$1(string); + return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar$1, '\\$&') : string; } -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeCeil$3 = Math.ceil; -var nativeMax$12 = Math.max; - /** - * The base implementation of `_.range` and `_.rangeRight` which doesn't - * coerce arguments. + * A specialized version of `_.every` for arrays without support for + * iteratee shorthands. * * @private - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @param {number} step The value to increment or decrement by. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the range of numbers. + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. */ -function baseRange(start, end, step, fromRight) { +function arrayEvery(array, predicate) { var index = -1, - length = nativeMax$12(nativeCeil$3((end - start) / (step || 1)), 0), - result = Array(length); + length = array == null ? 0 : array.length; - while (length--) { - result[fromRight ? length : ++index] = start; - start += step; + while (++index < length) { + if (!predicate(array[index], index, array)) { + return false; + } } - return result; + return true; } /** - * Creates a `_.range` or `_.rangeRight` function. + * The base implementation of `_.every` without support for iteratee shorthands. * * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new range function. + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false` */ -function createRange(fromRight) { - return function (start, end, step) { - if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { - end = step = undefined; - } - // Ensure the sign of `-0` is preserved. - start = toFinite(start); - if (end === undefined) { - end = start; - start = 0; - } else { - end = toFinite(end); - } - step = step === undefined ? start < end ? 1 : -1 : toFinite(step); - return baseRange(start, end, step, fromRight); - }; +function baseEvery(collection, predicate) { + var result = true; + baseEach(collection, function (value, index, collection) { + result = !!predicate(value, index, collection); + return result; + }); + return result; } /** - * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. A step of `-1` is used if a negative - * `start` is specified without an `end` or `step`. If `end` is not specified, - * it's set to `start` with `start` then set to `0`. + * Checks if `predicate` returns truthy for **all** elements of `collection`. + * Iteration is stopped once `predicate` returns falsey. The predicate is + * invoked with three arguments: (value, index|key, collection). * - * **Note:** JavaScript follows the IEEE-754 standard for resolving - * floating-point values which can produce unexpected results. + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. * * @static - * @since 0.1.0 * @memberOf _ - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see _.inRange, _.rangeRight + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {boolean} Returns `true` if all elements pass the predicate check, + * else `false`. * @example * - * _.range(4); - * // => [0, 1, 2, 3] - * - * _.range(-4); - * // => [0, -1, -2, -3] - * - * _.range(1, 5); - * // => [1, 2, 3, 4] + * _.every([true, 1, null, 'yes'], Boolean); + * // => false * - * _.range(0, 20, 5); - * // => [0, 5, 10, 15] + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': false }, + * { 'user': 'fred', 'age': 40, 'active': false } + * ]; * - * _.range(0, -4, -1); - * // => [0, -1, -2, -3] + * // The `_.matches` iteratee shorthand. + * _.every(users, { 'user': 'barney', 'active': false }); + * // => false * - * _.range(1, 4, 0); - * // => [1, 1, 1] + * // The `_.matchesProperty` iteratee shorthand. + * _.every(users, ['active', false]); + * // => true * - * _.range(0); - * // => [] + * // The `_.property` iteratee shorthand. + * _.every(users, 'active'); + * // => false */ -var range = createRange(); +function every$1(collection, predicate, guard) { + var func = isArray$1(collection) ? arrayEvery : baseEvery; + if (guard && isIterateeCall(collection, predicate, guard)) { + predicate = undefined; + } + return func(collection, baseIteratee(predicate, 3)); +} + +/** Used as references for the maximum length and index of an array. */ +var MAX_ARRAY_LENGTH$1 = 4294967295; /** - * This method is like `_.range` except that it populates values in - * descending order. + * Converts `value` to an integer suitable for use as the length of an + * array-like object. + * + * **Note:** This method is based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 - * @category Util - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns the range of numbers. - * @see _.inRange, _.range + * @category Lang + * @param {*} value The value to convert. + * @returns {number} Returns the converted integer. * @example * - * _.rangeRight(4); - * // => [3, 2, 1, 0] - * - * _.rangeRight(-4); - * // => [-3, -2, -1, 0] - * - * _.rangeRight(1, 5); - * // => [4, 3, 2, 1] - * - * _.rangeRight(0, 20, 5); - * // => [15, 10, 5, 0] + * _.toLength(3.2); + * // => 3 * - * _.rangeRight(0, -4, -1); - * // => [-3, -2, -1, 0] + * _.toLength(Number.MIN_VALUE); + * // => 0 * - * _.rangeRight(1, 4, 0); - * // => [1, 1, 1] + * _.toLength(Infinity); + * // => 4294967295 * - * _.rangeRight(0); - * // => [] + * _.toLength('3.2'); + * // => 3 */ -var rangeRight = createRange(true); - -/** Used to compose bitmasks for function metadata. */ -var WRAP_REARG_FLAG$3 = 256; - -/** - * Creates a function that invokes `func` with arguments arranged according - * to the specified `indexes` where the argument value at the first index is - * provided as the first argument, the argument value at the second index is - * provided as the second argument, and so on. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Function - * @param {Function} func The function to rearrange arguments for. - * @param {...(number|number[])} indexes The arranged argument indexes. - * @returns {Function} Returns the new function. - * @example - * - * var rearged = _.rearg(function(a, b, c) { - * return [a, b, c]; - * }, [2, 0, 1]); - * - * rearged('b', 'c', 'a') - * // => ['a', 'b', 'c'] - */ -var rearg = flatRest(function (func, indexes) { - return createWrap(func, WRAP_REARG_FLAG$3, undefined, undefined, undefined, indexes); -}); +function toLength(value) { + return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH$1) : 0; +} /** - * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using `eachFunc`. + * The base implementation of `_.fill` without an iteratee call guard. * * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} accumulator The initial value. - * @param {boolean} initAccum Specify using the first or last element of - * `collection` as the initial value. - * @param {Function} eachFunc The function to iterate over `collection`. - * @returns {*} Returns the accumulated value. + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. */ -function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, function (value, index, collection) { - accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection); - }); - return accumulator; +function baseFill(array, value, start, end) { + var length = array.length; + + start = toInteger(start); + if (start < 0) { + start = -start > length ? 0 : length + start; + } + end = end === undefined || end > length ? length : toInteger(end); + if (end < 0) { + end += length; + } + end = start > end ? 0 : toLength(end); + while (start < end) { + array[start++] = value; + } + return array; } /** - * Reduces `collection` to a value which is the accumulated result of running - * each element in `collection` thru `iteratee`, where each successive - * invocation is supplied the return value of the previous. If `accumulator` - * is not given, the first element of `collection` is used as the initial - * value. The iteratee is invoked with four arguments: - * (accumulator, value, index|key, collection). - * - * Many lodash methods are guarded to work as iteratees for methods like - * `_.reduce`, `_.reduceRight`, and `_.transform`. + * Fills elements of `array` with `value` from `start` up to, but not + * including, `end`. * - * The guarded methods are: - * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, - * and `sortBy` + * **Note:** This method mutates `array`. * * @static * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduceRight + * @since 3.2.0 + * @category Array + * @param {Array} array The array to fill. + * @param {*} value The value to fill `array` with. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns `array`. * @example * - * _.reduce([1, 2], function(sum, n) { - * return sum + n; - * }, 0); - * // => 3 + * var array = [1, 2, 3]; * - * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * return result; - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) - */ -function reduce$1(collection, iteratee, accumulator) { - var func = isArray$1(collection) ? arrayReduce : baseReduce, - initAccum = arguments.length < 3; - - return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach); -} - -/** - * A specialized version of `_.reduceRight` for arrays without support for - * iteratee shorthands. + * _.fill(array, 'a'); + * console.log(array); + * // => ['a', 'a', 'a'] * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the last element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. + * _.fill(Array(3), 2); + * // => [2, 2, 2] + * + * _.fill([4, 6, 8, 10], '*', 1, 3); + * // => [4, '*', '*', 10] */ -function arrayReduceRight(array, iteratee, accumulator, initAccum) { +function fill$1(array, value, start, end) { var length = array == null ? 0 : array.length; - if (initAccum && length) { - accumulator = array[--length]; + if (!length) { + return []; } - while (length--) { - accumulator = iteratee(accumulator, array[length], length, array); + if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { + start = 0; + end = length; } - return accumulator; + return baseFill(array, value, start, end); } /** - * This method is like `_.reduce` except that it iterates over elements of - * `collection` from right to left. + * The base implementation of `_.filter` without support for iteratee shorthands. * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection + * @private * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @returns {*} Returns the accumulated value. - * @see _.reduce - * @example - * - * var array = [[0, 1], [2, 3], [4, 5]]; - * - * _.reduceRight(array, function(flattened, other) { - * return flattened.concat(other); - * }, []); - * // => [4, 5, 2, 3, 0, 1] + * @param {Function} predicate The function invoked per iteration. + * @returns {Array} Returns the new filtered array. */ -function reduceRight$1(collection, iteratee, accumulator) { - var func = isArray$1(collection) ? arrayReduceRight : baseReduce, - initAccum = arguments.length < 3; - - return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); +function baseFilter(collection, predicate) { + var result = []; + baseEach(collection, function (value, index, collection) { + if (predicate(value, index, collection)) { + result.push(value); + } + }); + return result; } /** - * The opposite of `_.filter`; this method returns the elements of `collection` - * that `predicate` does **not** return truthy for. + * Iterates over elements of `collection`, returning an array of all elements + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). + * + * **Note:** Unlike `_.remove`, this method returns a new array. * * @static * @memberOf _ @@ -25938,6356 +22003,10284 @@ function reduceRight$1(collection, iteratee, accumulator) { * @param {Array|Object} collection The collection to iterate over. * @param {Function} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the new filtered array. - * @see _.filter + * @see _.reject * @example * * var users = [ - * { 'user': 'barney', 'age': 36, 'active': false }, - * { 'user': 'fred', 'age': 40, 'active': true } + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false } * ]; * - * _.reject(users, function(o) { return !o.active; }); + * _.filter(users, function(o) { return !o.active; }); * // => objects for ['fred'] * * // The `_.matches` iteratee shorthand. - * _.reject(users, { 'age': 40, 'active': true }); + * _.filter(users, { 'age': 36, 'active': true }); * // => objects for ['barney'] * * // The `_.matchesProperty` iteratee shorthand. - * _.reject(users, ['active', false]); + * _.filter(users, ['active', false]); * // => objects for ['fred'] * * // The `_.property` iteratee shorthand. - * _.reject(users, 'active'); + * _.filter(users, 'active'); * // => objects for ['barney'] */ -function reject$1(collection, predicate) { +function filter$1(collection, predicate) { var func = isArray$1(collection) ? arrayFilter : baseFilter; - return func(collection, negate$1(baseIteratee(predicate, 3))); + return func(collection, baseIteratee(predicate, 3)); } /** - * Removes all elements from `array` that `predicate` returns truthy for - * and returns an array of the removed elements. The predicate is invoked - * with three arguments: (value, index, array). + * Creates a `_.find` or `_.findLast` function. * - * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` - * to pull elements from an array by value. + * @private + * @param {Function} findIndexFunc The function to find the collection index. + * @returns {Function} Returns the new find function. + */ +function createFind(findIndexFunc) { + return function (collection, predicate, fromIndex) { + var iterable = Object(collection); + if (!isArrayLike(collection)) { + var iteratee = baseIteratee(predicate, 3); + collection = keys$1(collection); + predicate = function predicate(key) { + return iteratee(iterable[key], key, iterable); + }; + } + var index = findIndexFunc(collection, predicate, fromIndex); + return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; + }; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$6 = Math.max; + +/** + * This method is like `_.find` except that it returns the index of the first + * element `predicate` returns truthy for instead of the element itself. * * @static * @memberOf _ - * @since 2.0.0 + * @since 1.1.0 * @category Array - * @param {Array} array The array to modify. + * @param {Array} array The array to inspect. * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the new array of removed elements. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. * @example * - * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { - * return n % 2 == 0; - * }); - * - * console.log(array); - * // => [1, 3] + * var users = [ + * { 'user': 'barney', 'active': false }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': true } + * ]; * - * console.log(evens); - * // => [2, 4] + * _.findIndex(users, function(o) { return o.user == 'barney'; }); + * // => 0 + * + * // The `_.matches` iteratee shorthand. + * _.findIndex(users, { 'user': 'fred', 'active': false }); + * // => 1 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findIndex(users, ['active', false]); + * // => 0 + * + * // The `_.property` iteratee shorthand. + * _.findIndex(users, 'active'); + * // => 2 */ -function remove$1(array, predicate) { - var result = []; - if (!(array && array.length)) { - return result; +function findIndex$1(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; } - var index = -1, - indexes = [], - length = array.length; - - predicate = baseIteratee(predicate, 3); - while (++index < length) { - var value = array[index]; - if (predicate(value, index, array)) { - result.push(value); - indexes.push(index); - } + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax$6(length + index, 0); } - basePullAt(array, indexes); - return result; + return baseFindIndex(array, baseIteratee(predicate, 3), index); } /** - * Repeats the given string `n` times. + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is invoked with three + * arguments: (value, index|key, collection). * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to repeat. - * @param {number} [n=1] The number of times to repeat the string. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the repeated string. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=0] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.repeat('*', 3); - * // => '***' - * - * _.repeat('abc', 2); - * // => 'abcabc' + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; * - * _.repeat('abc', 0); - * // => '' - */ -function repeat$1(string, n, guard) { - if (guard ? isIterateeCall(string, n, guard) : n === undefined) { - n = 1; - } else { - n = toInteger(n); - } - return baseRepeat(toString$1(string), n); -} - -/** - * Replaces matches for `pattern` in `string` with `replacement`. + * _.find(users, function(o) { return o.age < 40; }); + * // => object for 'barney' * - * **Note:** This method is based on - * [`String#replace`](https://mdn.io/String/replace). + * // The `_.matches` iteratee shorthand. + * _.find(users, { 'age': 1, 'active': true }); + * // => object for 'pebbles' * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to modify. - * @param {RegExp|string} pattern The pattern to replace. - * @param {Function|string} replacement The match replacement. - * @returns {string} Returns the modified string. - * @example + * // The `_.matchesProperty` iteratee shorthand. + * _.find(users, ['active', false]); + * // => object for 'fred' * - * _.replace('Hi Fred', 'Fred', 'Barney'); - * // => 'Hi Barney' + * // The `_.property` iteratee shorthand. + * _.find(users, 'active'); + * // => object for 'barney' */ -function replace$1() { - var args = arguments, - string = toString$1(args[0]); - - return args.length < 3 ? string : string.replace(args[1], args[2]); -} - -/** Error message constants. */ -var FUNC_ERROR_TEXT$9 = 'Expected a function'; +var find$1 = createFind(findIndex$1); /** - * Creates a function that invokes `func` with the `this` binding of the - * created function and arguments from `start` and beyond provided as - * an array. - * - * **Note:** This method is based on the - * [rest parameter](https://mdn.io/rest_parameters). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - * @example - * - * var say = _.rest(function(what, names) { - * return what + ' ' + _.initial(names).join(', ') + - * (_.size(names) > 1 ? ', & ' : '') + _.last(names); - * }); + * The base implementation of methods like `_.findKey` and `_.findLastKey`, + * without support for iteratee shorthands, which iterates over `collection` + * using `eachFunc`. * - * say('hello', 'fred', 'barney', 'pebbles'); - * // => 'hello fred, barney, & pebbles' + * @private + * @param {Array|Object} collection The collection to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @returns {*} Returns the found element or its key, else `undefined`. */ -function rest(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$9); - } - start = start === undefined ? start : toInteger(start); - return baseRest(func, start); +function baseFindKey(collection, predicate, eachFunc) { + var result; + eachFunc(collection, function (value, key, collection) { + if (predicate(value, key, collection)) { + result = key; + return false; + } + }); + return result; } /** - * This method is like `_.get` except that if the resolved value is a - * function it's invoked with the `this` binding of its parent object and - * its result is returned. + * This method is like `_.find` except that it returns the key of the first + * element `predicate` returns truthy for instead of the element itself. * * @static - * @since 0.1.0 * @memberOf _ + * @since 1.1.0 * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to resolve. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. * @example * - * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; * - * _.result(object, 'a[0].b.c1'); - * // => 3 + * _.findKey(users, function(o) { return o.age < 40; }); + * // => 'barney' (iteration order is not guaranteed) * - * _.result(object, 'a[0].b.c2'); - * // => 4 + * // The `_.matches` iteratee shorthand. + * _.findKey(users, { 'age': 1, 'active': true }); + * // => 'pebbles' * - * _.result(object, 'a[0].b.c3', 'default'); - * // => 'default' + * // The `_.matchesProperty` iteratee shorthand. + * _.findKey(users, ['active', false]); + * // => 'fred' * - * _.result(object, 'a[0].b.c3', _.constant('default')); - * // => 'default' + * // The `_.property` iteratee shorthand. + * _.findKey(users, 'active'); + * // => 'barney' */ -function result(object, path, defaultValue) { - path = castPath(path, object); - - var index = -1, - length = path.length; - - // Ensure the loop is entered when path is empty. - if (!length) { - length = 1; - object = undefined; - } - while (++index < length) { - var value = object == null ? undefined : object[toKey(path[index])]; - if (value === undefined) { - index = length; - value = defaultValue; - } - object = isFunction(value) ? value.call(object) : value; - } - return object; +function findKey(object, predicate) { + return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn); } -/** Used for built-in method references. */ -var arrayProto$4 = Array.prototype; - /* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeReverse = arrayProto$4.reverse; +var nativeMax$7 = Math.max; +var nativeMin$4 = Math.min; /** - * Reverses `array` so that the first element becomes the last, the second - * element becomes the second to last, and so on. - * - * **Note:** This method mutates `array` and is based on - * [`Array#reverse`](https://mdn.io/Array/reverse). + * This method is like `_.findIndex` except that it iterates over elements + * of `collection` from right to left. * * @static * @memberOf _ - * @since 4.0.0 + * @since 2.0.0 * @category Array - * @param {Array} array The array to modify. - * @returns {Array} Returns `array`. + * @param {Array} array The array to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=array.length-1] The index to search from. + * @returns {number} Returns the index of the found element, else `-1`. * @example * - * var array = [1, 2, 3]; + * var users = [ + * { 'user': 'barney', 'active': true }, + * { 'user': 'fred', 'active': false }, + * { 'user': 'pebbles', 'active': false } + * ]; * - * _.reverse(array); - * // => [3, 2, 1] + * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); + * // => 2 * - * console.log(array); - * // => [3, 2, 1] - */ -function reverse$1(array) { - return array == null ? array : nativeReverse.call(array); + * // The `_.matches` iteratee shorthand. + * _.findLastIndex(users, { 'user': 'barney', 'active': true }); + * // => 0 + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastIndex(users, ['active', false]); + * // => 2 + * + * // The `_.property` iteratee shorthand. + * _.findLastIndex(users, 'active'); + * // => 0 + */ +function findLastIndex(array, predicate, fromIndex) { + var length = array == null ? 0 : array.length; + if (!length) { + return -1; + } + var index = length - 1; + if (fromIndex !== undefined) { + index = toInteger(fromIndex); + index = fromIndex < 0 ? nativeMax$7(length + index, 0) : nativeMin$4(index, length - 1); + } + return baseFindIndex(array, baseIteratee(predicate, 3), index, true); } /** - * Computes `number` rounded to `precision`. + * This method is like `_.find` except that it iterates over elements of + * `collection` from right to left. * * @static * @memberOf _ - * @since 3.10.0 - * @category Math - * @param {number} number The number to round. - * @param {number} [precision=0] The precision to round to. - * @returns {number} Returns the rounded number. + * @since 2.0.0 + * @category Collection + * @param {Array|Object} collection The collection to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @param {number} [fromIndex=collection.length-1] The index to search from. + * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.round(4.006); - * // => 4 - * - * _.round(4.006, 2); - * // => 4.01 - * - * _.round(4060, -2); - * // => 4100 + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); + * // => 3 */ -var round$1 = createRound('round'); +var findLast = createFind(findLastIndex); /** - * A specialized version of `_.sample` for arrays. + * This method is like `_.findKey` except that it iterates over elements of + * a collection in the opposite order. * - * @private - * @param {Array} array The array to sample. - * @returns {*} Returns the random element. - */ -function arraySample(array) { - var length = array.length; - return length ? array[baseRandom(0, length - 1)] : undefined; -} - -/** - * The base implementation of `_.sample`. + * @static + * @memberOf _ + * @since 2.0.0 + * @category Object + * @param {Object} object The object to inspect. + * @param {Function} [predicate=_.identity] The function invoked per iteration. + * @returns {string|undefined} Returns the key of the matched element, + * else `undefined`. + * @example * - * @private - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. + * var users = { + * 'barney': { 'age': 36, 'active': true }, + * 'fred': { 'age': 40, 'active': false }, + * 'pebbles': { 'age': 1, 'active': true } + * }; + * + * _.findLastKey(users, function(o) { return o.age < 40; }); + * // => returns 'pebbles' assuming `_.findKey` returns 'barney' + * + * // The `_.matches` iteratee shorthand. + * _.findLastKey(users, { 'age': 36, 'active': true }); + * // => 'barney' + * + * // The `_.matchesProperty` iteratee shorthand. + * _.findLastKey(users, ['active', false]); + * // => 'fred' + * + * // The `_.property` iteratee shorthand. + * _.findLastKey(users, 'active'); + * // => 'pebbles' */ -function baseSample(collection) { - return arraySample(values$1(collection)); +function findLastKey(object, predicate) { + return baseFindKey(object, baseIteratee(predicate, 3), baseForOwnRight); } /** - * Gets a random element from `collection`. + * Gets the first element of `array`. * * @static * @memberOf _ - * @since 2.0.0 - * @category Collection - * @param {Array|Object} collection The collection to sample. - * @returns {*} Returns the random element. + * @since 0.1.0 + * @alias first + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the first element of `array`. * @example * - * _.sample([1, 2, 3, 4]); - * // => 2 + * _.head([1, 2, 3]); + * // => 1 + * + * _.head([]); + * // => undefined */ -function sample(collection) { - var func = isArray$1(collection) ? arraySample : baseSample; - return func(collection); +function head$1(array) { + return array && array.length ? array[0] : undefined; } /** - * A specialized version of `_.shuffle` which mutates and sets the size of `array`. + * The base implementation of `_.map` without support for iteratee shorthands. * * @private - * @param {Array} array The array to shuffle. - * @param {number} [size=array.length] The size of `array`. - * @returns {Array} Returns `array`. + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. */ -function shuffleSelf(array, size) { - var index = -1, - length = array.length, - lastIndex = length - 1; - - size = size === undefined ? length : size; - while (++index < size) { - var rand = baseRandom(index, lastIndex), - value = array[rand]; +function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; - array[rand] = array[index]; - array[index] = value; - } - array.length = size; - return array; + baseEach(collection, function (value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; } /** - * A specialized version of `_.sampleSize` for arrays. + * Creates an array of values by running each element in `collection` thru + * `iteratee`. The iteratee is invoked with three arguments: + * (value, index|key, collection). * - * @private - * @param {Array} array The array to sample. - * @param {number} n The number of elements to sample. - * @returns {Array} Returns the random elements. - */ -function arraySampleSize(array, n) { - return shuffleSelf(copyArray$1(array), baseClamp(n, 0, array.length)); -} - -/** - * The base implementation of `_.sampleSize` without param guards. + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * - * @private - * @param {Array|Object} collection The collection to sample. - * @param {number} n The number of elements to sample. - * @returns {Array} Returns the random elements. - */ -function baseSampleSize(collection, n) { - var array = values$1(collection); - return shuffleSelf(array, baseClamp(n, 0, array.length)); -} - -/** - * Gets `n` random elements at unique keys from `collection` up to the - * size of `collection`. + * The guarded methods are: + * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, + * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, + * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, + * `template`, `trim`, `trimEnd`, `trimStart`, and `words` * * @static * @memberOf _ - * @since 4.0.0 + * @since 0.1.0 * @category Collection - * @param {Array|Object} collection The collection to sample. - * @param {number} [n=1] The number of elements to sample. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the random elements. + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new mapped array. * @example * - * _.sampleSize([1, 2, 3], 2); - * // => [3, 1] + * function square(n) { + * return n * n; + * } * - * _.sampleSize([1, 2, 3], 4); - * // => [2, 3, 1] + * _.map([4, 8], square); + * // => [16, 64] + * + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // The `_.property` iteratee shorthand. + * _.map(users, 'user'); + * // => ['barney', 'fred'] */ -function sampleSize(collection, n, guard) { - if (guard ? isIterateeCall(collection, n, guard) : n === undefined) { - n = 1; - } else { - n = toInteger(n); - } - var func = isArray$1(collection) ? arraySampleSize : baseSampleSize; - return func(collection, n); +function map$1(collection, iteratee) { + var func = isArray$1(collection) ? arrayMap : baseMap; + return func(collection, baseIteratee(iteratee, 3)); } /** - * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, - * it's created. Arrays are created for missing index properties while objects - * are created for all other missing properties. Use `_.setWith` to customize - * `path` creation. - * - * **Note:** This method mutates `object`. + * Creates a flattened array of values by running each element in `collection` + * thru `iteratee` and flattening the mapped results. The iteratee is invoked + * with three arguments: (value, index|key, collection). * * @static * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @returns {Object} Returns `object`. + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. * @example * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * function duplicate(n) { + * return [n, n]; + * } * - * _.set(object, 'a[0].b.c', 4); - * console.log(object.a[0].b.c); - * // => 4 - * - * _.set(object, ['x', '0', 'y', 'z'], 5); - * console.log(object.x[0].y.z); - * // => 5 + * _.flatMap([1, 2], duplicate); + * // => [1, 1, 2, 2] */ -function set$2(object, path, value) { - return object == null ? object : baseSet(object, path, value); +function flatMap(collection, iteratee) { + return baseFlatten(map$1(collection, iteratee), 1); } +/** Used as references for various `Number` constants. */ +var INFINITY$3 = 1 / 0; + /** - * This method is like `_.set` except that it accepts `customizer` which is - * invoked to produce the objects of `path`. If `customizer` returns `undefined` - * path creation is handled by the method instead. The `customizer` is invoked - * with three arguments: (nsValue, key, nsObject). - * - * **Note:** This method mutates `object`. + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results. * * @static * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to modify. - * @param {Array|string} path The path of the property to set. - * @param {*} value The value to set. - * @param {Function} [customizer] The function to customize assigned values. - * @returns {Object} Returns `object`. + * @since 4.7.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Array} Returns the new flattened array. * @example * - * var object = {}; - * - * _.setWith(object, '[0][1]', 'a', Object); - * // => { '0': { '1': 'a' } } - */ -function setWith(object, path, value, customizer) { - customizer = typeof customizer == 'function' ? customizer : undefined; - return object == null ? object : baseSet(object, path, value, customizer); -} - -/** - * A specialized version of `_.shuffle` for arrays. - * - * @private - * @param {Array} array The array to shuffle. - * @returns {Array} Returns the new shuffled array. - */ -function arrayShuffle(array) { - return shuffleSelf(copyArray$1(array)); -} - -/** - * The base implementation of `_.shuffle`. + * function duplicate(n) { + * return [[[n, n]]]; + * } * - * @private - * @param {Array|Object} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. + * _.flatMapDeep([1, 2], duplicate); + * // => [1, 1, 2, 2] */ -function baseShuffle(collection) { - return shuffleSelf(values$1(collection)); +function flatMapDeep(collection, iteratee) { + return baseFlatten(map$1(collection, iteratee), INFINITY$3); } /** - * Creates an array of shuffled values, using a version of the - * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). + * This method is like `_.flatMap` except that it recursively flattens the + * mapped results up to `depth` times. * * @static * @memberOf _ - * @since 0.1.0 + * @since 4.7.0 * @category Collection - * @param {Array|Object} collection The collection to shuffle. - * @returns {Array} Returns the new shuffled array. + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. * @example * - * _.shuffle([1, 2, 3, 4]); - * // => [4, 1, 3, 2] + * function duplicate(n) { + * return [[[n, n]]]; + * } + * + * _.flatMapDepth([1, 2], duplicate, 2); + * // => [[1, 1], [2, 2]] */ -function shuffle(collection) { - var func = isArray$1(collection) ? arrayShuffle : baseShuffle; - return func(collection); +function flatMapDepth(collection, iteratee, depth) { + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(map$1(collection, iteratee), depth); } -/** `Object#toString` result references. */ -var mapTag$9 = '[object Map]'; -var setTag$9 = '[object Set]'; +/** Used as references for various `Number` constants. */ +var INFINITY$4 = 1 / 0; /** - * Gets the size of `collection` by returning its length for array-like - * values or the number of own enumerable string keyed properties for objects. + * Recursively flattens `array`. * * @static * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns the collection size. + * @since 3.0.0 + * @category Array + * @param {Array} array The array to flatten. + * @returns {Array} Returns the new flattened array. * @example * - * _.size([1, 2, 3]); - * // => 3 - * - * _.size({ 'a': 1, 'b': 2 }); - * // => 2 - * - * _.size('pebbles'); - * // => 7 + * _.flattenDeep([1, [2, [3, [4]], 5]]); + * // => [1, 2, 3, 4, 5] */ -function size$1(collection) { - if (collection == null) { - return 0; - } - if (isArrayLike(collection)) { - return isString(collection) ? stringSize(collection) : collection.length; - } - var tag = getTag$1(collection); - if (tag == mapTag$9 || tag == setTag$9) { - return collection.size; - } - return baseKeys(collection).length; +function flattenDeep(array) { + var length = array == null ? 0 : array.length; + return length ? baseFlatten(array, INFINITY$4) : []; } /** - * Creates a slice of `array` from `start` up to, but not including, `end`. - * - * **Note:** This method is used instead of - * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are - * returned. + * Recursively flatten `array` up to `depth` times. * * @static * @memberOf _ - * @since 3.0.0 + * @since 4.4.0 * @category Array - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. + * @param {Array} array The array to flatten. + * @param {number} [depth=1] The maximum recursion depth. + * @returns {Array} Returns the new flattened array. + * @example + * + * var array = [1, [2, [3, [4]], 5]]; + * + * _.flattenDepth(array, 1); + * // => [1, 2, [3, [4]], 5] + * + * _.flattenDepth(array, 2); + * // => [1, 2, 3, [4], 5] */ -function slice$1(array, start, end) { +function flattenDepth(array, depth) { var length = array == null ? 0 : array.length; if (!length) { return []; } - if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { - start = 0; - end = length; - } else { - start = start == null ? 0 : toInteger(start); - end = end === undefined ? length : toInteger(end); - } - return baseSlice(array, start, end); + depth = depth === undefined ? 1 : toInteger(depth); + return baseFlatten(array, depth); } +/** Used to compose bitmasks for function metadata. */ +var WRAP_FLIP_FLAG$2 = 512; + /** - * Converts `string` to - * [snake case](https://en.wikipedia.org/wiki/Snake_case). + * Creates a function that invokes `func` with arguments reversed. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the snake cased string. + * @since 4.0.0 + * @category Function + * @param {Function} func The function to flip arguments for. + * @returns {Function} Returns the new flipped function. * @example * - * _.snakeCase('Foo Bar'); - * // => 'foo_bar' - * - * _.snakeCase('fooBar'); - * // => 'foo_bar' - * - * _.snakeCase('--FOO-BAR--'); - * // => 'foo_bar' - */ -var snakeCase = createCompounder(function (result, word, index) { - return result + (index ? '_' : '') + word.toLowerCase(); -}); - -/** - * The base implementation of `_.some` without support for iteratee shorthands. + * var flipped = _.flip(function() { + * return _.toArray(arguments); + * }); * - * @private - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. + * flipped('a', 'b', 'c', 'd'); + * // => ['d', 'c', 'b', 'a'] */ -function baseSome(collection, predicate) { - var result; - - baseEach(collection, function (value, index, collection) { - result = predicate(value, index, collection); - return !result; - }); - return !!result; +function flip(func) { + return createWrap(func, WRAP_FLIP_FLAG$2); } /** - * Checks if `predicate` returns truthy for **any** element of `collection`. - * Iteration is stopped once `predicate` returns truthy. The predicate is - * invoked with three arguments: (value, index|key, collection). + * Computes `number` rounded down to `precision`. * * @static * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. + * @since 3.10.0 + * @category Math + * @param {number} number The number to round down. + * @param {number} [precision=0] The precision to round down to. + * @returns {number} Returns the rounded down number. * @example * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false } - * ]; - * - * // The `_.matches` iteratee shorthand. - * _.some(users, { 'user': 'barney', 'active': false }); - * // => false + * _.floor(4.006); + * // => 4 * - * // The `_.matchesProperty` iteratee shorthand. - * _.some(users, ['active', false]); - * // => true + * _.floor(0.046, 2); + * // => 0.04 * - * // The `_.property` iteratee shorthand. - * _.some(users, 'active'); - * // => true - */ -function some$1(collection, predicate, guard) { - var func = isArray$1(collection) ? arraySome : baseSome; - if (guard && isIterateeCall(collection, predicate, guard)) { - predicate = undefined; - } - return func(collection, baseIteratee(predicate, 3)); -} - -/** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection thru each iteratee. This method - * performs a stable sort, that is, it preserves the original sort order of - * equal elements. The iteratees are invoked with one argument: (value). - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Collection - * @param {Array|Object} collection The collection to iterate over. - * @param {...(Function|Function[])} [iteratees=[_.identity]] - * The iteratees to sort by. - * @returns {Array} Returns the new sorted array. - * @example - * - * var users = [ - * { 'user': 'fred', 'age': 48 }, - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, - * { 'user': 'barney', 'age': 34 } - * ]; - * - * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] - * - * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] + * _.floor(4060, -2); + * // => 4000 */ -var sortBy = baseRest(function (collection, iteratees) { - if (collection == null) { - return []; - } - var length = iteratees.length; - if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { - iteratees = []; - } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { - iteratees = [iteratees[0]]; - } - return baseOrderBy(collection, baseFlatten(iteratees, 1), []); -}); +var floor$1 = createRound('floor'); -/** Used as references for the maximum length and index of an array. */ -var MAX_ARRAY_LENGTH$3 = 4294967295; -var MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH$3 - 1; +/** Error message constants. */ +var FUNC_ERROR_TEXT$7 = 'Expected a function'; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeFloor$3 = Math.floor; -var nativeMin$10 = Math.min; +/** Used to compose bitmasks for function metadata. */ +var WRAP_CURRY_FLAG$6 = 8; +var WRAP_PARTIAL_FLAG$5 = 32; +var WRAP_ARY_FLAG$4 = 128; +var WRAP_REARG_FLAG$2 = 256; /** - * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` - * which invokes `iteratee` for `value` and each element of `array` to compute - * their sort ranking. The iteratee is invoked with one argument; (value). + * Creates a `_.flow` or `_.flowRight` function. * * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} iteratee The iteratee invoked per element. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new flow function. */ -function baseSortedIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); - - var low = 0, - high = array == null ? 0 : array.length, - valIsNaN = value !== value, - valIsNull = value === null, - valIsSymbol = isSymbol(value), - valIsUndefined = value === undefined; - - while (low < high) { - var mid = nativeFloor$3((low + high) / 2), - computed = iteratee(array[mid]), - othIsDefined = computed !== undefined, - othIsNull = computed === null, - othIsReflexive = computed === computed, - othIsSymbol = isSymbol(computed); +function createFlow(fromRight) { + return flatRest(function (funcs) { + var length = funcs.length, + index = length, + prereq = LodashWrapper.prototype.thru; - if (valIsNaN) { - var setLow = retHighest || othIsReflexive; - } else if (valIsUndefined) { - setLow = othIsReflexive && (retHighest || othIsDefined); - } else if (valIsNull) { - setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); - } else if (valIsSymbol) { - setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); - } else if (othIsNull || othIsSymbol) { - setLow = false; - } else { - setLow = retHighest ? computed <= value : computed < value; + if (fromRight) { + funcs.reverse(); } - if (setLow) { - low = mid + 1; - } else { - high = mid; + while (index--) { + var func = funcs[index]; + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT$7); + } + if (prereq && !wrapper && getFuncName(func) == 'wrapper') { + var wrapper = new LodashWrapper([], true); + } } - } - return nativeMin$10(high, MAX_ARRAY_INDEX); -} - -/** Used as references for the maximum length and index of an array. */ -var MAX_ARRAY_LENGTH$2 = 4294967295; -var HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH$2 >>> 1; - -/** - * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which - * performs a binary search of `array` to determine the index at which `value` - * should be inserted into `array` in order to maintain its sort order. - * - * @private - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {boolean} [retHighest] Specify returning the highest qualified index. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - */ -function baseSortedIndex(array, value, retHighest) { - var low = 0, - high = array == null ? low : array.length; + index = wrapper ? index : length; + while (++index < length) { + func = funcs[index]; - if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { - while (low < high) { - var mid = low + high >>> 1, - computed = array[mid]; + var funcName = getFuncName(func), + data = funcName == 'wrapper' ? getData(func) : undefined; - if (computed !== null && !isSymbol(computed) && (retHighest ? computed <= value : computed < value)) { - low = mid + 1; + if (data && isLaziable(data[0]) && data[1] == (WRAP_ARY_FLAG$4 | WRAP_CURRY_FLAG$6 | WRAP_PARTIAL_FLAG$5 | WRAP_REARG_FLAG$2) && !data[4].length && data[9] == 1) { + wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); } else { - high = mid; + wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func); } } - return high; - } - return baseSortedIndexBy(array, value, identity$1, retHighest); + return function () { + var args = arguments, + value = args[0]; + + if (wrapper && args.length == 1 && isArray$1(value)) { + return wrapper.plant(value).value(); + } + var index = 0, + result = length ? funcs[index].apply(this, args) : value; + + while (++index < length) { + result = funcs[index].call(this, result); + } + return result; + }; + }); } /** - * Uses a binary search to determine the lowest index at which `value` - * should be inserted into `array` in order to maintain its sort order. + * Creates a function that returns the result of invoking the given functions + * with the `this` binding of the created function, where each successive + * invocation is supplied the return value of the previous. * * @static * @memberOf _ - * @since 0.1.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. + * @since 3.0.0 + * @category Util + * @param {...(Function|Function[])} [funcs] The functions to invoke. + * @returns {Function} Returns the new composite function. + * @see _.flowRight * @example * - * _.sortedIndex([30, 50], 40); - * // => 1 + * function square(n) { + * return n * n; + * } + * + * var addSquare = _.flow([_.add, square]); + * addSquare(1, 2); + * // => 9 */ -function sortedIndex(array, value) { - return baseSortedIndex(array, value); -} +var flow = createFlow(); /** - * This method is like `_.sortedIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). + * This method is like `_.flow` except that it creates a function that + * invokes the given functions from right to left. * * @static + * @since 3.0.0 * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. + * @category Util + * @param {...(Function|Function[])} [funcs] The functions to invoke. + * @returns {Function} Returns the new composite function. + * @see _.flow * @example * - * var objects = [{ 'x': 4 }, { 'x': 5 }]; - * - * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); - * // => 0 + * function square(n) { + * return n * n; + * } * - * // The `_.property` iteratee shorthand. - * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); - * // => 0 + * var addSquare = _.flowRight([square, _.add]); + * addSquare(1, 2); + * // => 9 */ -function sortedIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2)); -} +var flowRight = createFlow(true); /** - * This method is like `_.indexOf` except that it performs a binary - * search on a sorted `array`. + * Iterates over own and inherited enumerable string keyed properties of an + * object and invokes `iteratee` for each property. The iteratee is invoked + * with three arguments: (value, key, object). Iteratee functions may exit + * iteration early by explicitly returning `false`. * * @static * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forInRight * @example * - * _.sortedIndexOf([4, 5, 5, 5, 6], 5); - * // => 1 + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forIn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). */ -function sortedIndexOf(array, value) { - var length = array == null ? 0 : array.length; - if (length) { - var index = baseSortedIndex(array, value); - if (index < length && eq(array[index], value)) { - return index; - } - } - return -1; +function forIn(object, iteratee) { + return object == null ? object : baseFor(object, castFunction(iteratee), keysIn$1); } /** - * This method is like `_.sortedIndex` except that it returns the highest - * index at which `value` should be inserted into `array` in order to - * maintain its sort order. + * This method is like `_.forIn` except that it iterates over properties of + * `object` in the opposite order. * * @static * @memberOf _ - * @since 3.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forIn * @example * - * _.sortedLastIndex([4, 5, 5, 5, 6], 5); - * // => 4 + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forInRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. */ -function sortedLastIndex(array, value) { - return baseSortedIndex(array, value, true); +function forInRight(object, iteratee) { + return object == null ? object : baseForRight(object, castFunction(iteratee), keysIn$1); } /** - * This method is like `_.sortedLastIndex` except that it accepts `iteratee` - * which is invoked for `value` and each element of `array` to compute their - * sort ranking. The iteratee is invoked with one argument: (value). + * Iterates over own enumerable string keyed properties of an object and + * invokes `iteratee` for each property. The iteratee is invoked with three + * arguments: (value, key, object). Iteratee functions may exit iteration + * early by explicitly returning `false`. * * @static * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The sorted array to inspect. - * @param {*} value The value to evaluate. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. + * @since 0.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwnRight * @example * - * var objects = [{ 'x': 4 }, { 'x': 5 }]; + * function Foo() { + * this.a = 1; + * this.b = 2; + * } * - * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); - * // => 1 + * Foo.prototype.c = 3; * - * // The `_.property` iteratee shorthand. - * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); - * // => 1 + * _.forOwn(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'a' then 'b' (iteration order is not guaranteed). */ -function sortedLastIndexBy(array, value, iteratee) { - return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2), true); +function forOwn(object, iteratee) { + return object && baseForOwn(object, castFunction(iteratee)); } /** - * This method is like `_.lastIndexOf` except that it performs a binary - * search on a sorted `array`. + * This method is like `_.forOwn` except that it iterates over properties of + * `object` in the opposite order. * * @static * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns the index of the matched value, else `-1`. + * @since 2.0.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @returns {Object} Returns `object`. + * @see _.forOwn * @example * - * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); - * // => 3 + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { + * console.log(key); + * }); + * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. */ -function sortedLastIndexOf(array, value) { - var length = array == null ? 0 : array.length; - if (length) { - var index = baseSortedIndex(array, value, true) - 1; - if (eq(array[index], value)) { - return index; - } - } - return -1; +function forOwnRight(object, iteratee) { + return object && baseForOwnRight(object, castFunction(iteratee)); } /** - * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without - * support for iteratee shorthands. + * The inverse of `_.toPairs`; this method returns an object composed + * from key-value `pairs`. * - * @private - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} pairs The key-value pairs. + * @returns {Object} Returns the new object. + * @example + * + * _.fromPairs([['a', 1], ['b', 2]]); + * // => { 'a': 1, 'b': 2 } */ -function baseSortedUniq(array, iteratee) { +function fromPairs(pairs) { var index = -1, - length = array.length, - resIndex = 0, - result = []; + length = pairs == null ? 0 : pairs.length, + result = {}; while (++index < length) { - var value = array[index], - computed = iteratee ? iteratee(value) : value; - - if (!index || !eq(computed, seen)) { - var seen = computed; - result[resIndex++] = value === 0 ? 0 : value; - } + var pair = pairs[index]; + result[pair[0]] = pair[1]; } return result; } /** - * This method is like `_.uniq` except that it's designed and optimized - * for sorted arrays. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @returns {Array} Returns the new duplicate free array. - * @example + * The base implementation of `_.functions` which creates an array of + * `object` function property names filtered from `props`. * - * _.sortedUniq([1, 1, 2]); - * // => [1, 2] + * @private + * @param {Object} object The object to inspect. + * @param {Array} props The property names to filter. + * @returns {Array} Returns the function names. */ -function sortedUniq(array) { - return array && array.length ? baseSortedUniq(array) : []; +function baseFunctions(object, props) { + return arrayFilter(props, function (key) { + return isFunction(object[key]); + }); } /** - * This method is like `_.uniqBy` except that it's designed and optimized - * for sorted arrays. + * Creates an array of function property names from own enumerable properties + * of `object`. * * @static + * @since 0.1.0 * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to inspect. - * @param {Function} [iteratee] The iteratee invoked per element. - * @returns {Array} Returns the new duplicate free array. + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functionsIn * @example * - * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); - * // => [1.1, 2.3] + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functions(new Foo); + * // => ['a', 'b'] */ -function sortedUniqBy(array, iteratee) { - return array && array.length ? baseSortedUniq(array, baseIteratee(iteratee, 2)) : []; +function functions(object) { + return object == null ? [] : baseFunctions(object, keys$1(object)); } -/** Used as references for the maximum length and index of an array. */ -var MAX_ARRAY_LENGTH$4 = 4294967295; - /** - * Splits `string` by `separator`. - * - * **Note:** This method is based on - * [`String#split`](https://mdn.io/String/split). + * Creates an array of function property names from own and inherited + * enumerable properties of `object`. * * @static * @memberOf _ * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to split. - * @param {RegExp|string} separator The separator pattern to split by. - * @param {number} [limit] The length to truncate results to. - * @returns {Array} Returns the string segments. + * @category Object + * @param {Object} object The object to inspect. + * @returns {Array} Returns the function names. + * @see _.functions * @example * - * _.split('a-b-c', '-', 2); - * // => ['a', 'b'] - */ -function split$1(string, separator, limit) { - if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { - separator = limit = undefined; - } - limit = limit === undefined ? MAX_ARRAY_LENGTH$4 : limit >>> 0; - if (!limit) { - return []; - } - string = toString$1(string); - if (string && (typeof separator == 'string' || separator != null && !isRegExp(separator))) { - separator = baseToString(separator); - if (!separator && hasUnicode(string)) { - return castSlice(stringToArray(string), 0, limit); - } - } - return string.split(separator, limit); + * function Foo() { + * this.a = _.constant('a'); + * this.b = _.constant('b'); + * } + * + * Foo.prototype.c = _.constant('c'); + * + * _.functionsIn(new Foo); + * // => ['a', 'b', 'c'] + */ +function functionsIn(object) { + return object == null ? [] : baseFunctions(object, keysIn$1(object)); } -/** Error message constants. */ -var FUNC_ERROR_TEXT$10 = 'Expected a function'; +/** Used for built-in method references. */ +var objectProto$21 = Object.prototype; -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeMax$13 = Math.max; +/** Used to check objects for own properties. */ +var hasOwnProperty$18 = objectProto$21.hasOwnProperty; /** - * Creates a function that invokes `func` with the `this` binding of the - * create function and an array of arguments much like - * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). - * - * **Note:** This method is based on the - * [spread operator](https://mdn.io/spread_operator). + * Creates an object composed of keys generated from the results of running + * each element of `collection` thru `iteratee`. The order of grouped values + * is determined by the order they occur in `collection`. The corresponding + * value of each key is an array of elements responsible for generating the + * key. The iteratee is invoked with one argument: (value). * * @static * @memberOf _ - * @since 3.2.0 - * @category Function - * @param {Function} func The function to spread arguments over. - * @param {number} [start=0] The start position of the spread. - * @returns {Function} Returns the new function. + * @since 0.1.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The iteratee to transform keys. + * @returns {Object} Returns the composed aggregate object. * @example * - * var say = _.spread(function(who, what) { - * return who + ' says ' + what; - * }); - * - * say(['fred', 'hello']); - * // => 'fred says hello' - * - * var numbers = Promise.all([ - * Promise.resolve(40), - * Promise.resolve(36) - * ]); + * _.groupBy([6.1, 4.2, 6.3], Math.floor); + * // => { '4': [4.2], '6': [6.1, 6.3] } * - * numbers.then(_.spread(function(x, y) { - * return x + y; - * })); - * // => a Promise of 76 + * // The `_.property` iteratee shorthand. + * _.groupBy(['one', 'two', 'three'], 'length'); + * // => { '3': ['one', 'two'], '5': ['three'] } */ -function spread(func, start) { - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$10); +var groupBy = createAggregator(function (result, value, key) { + if (hasOwnProperty$18.call(result, key)) { + result[key].push(value); + } else { + baseAssignValue(result, key, [value]); } - start = start == null ? 0 : nativeMax$13(toInteger(start), 0); - return baseRest(function (args) { - var array = args[start], - otherArgs = castSlice(args, 0, start); +}); - if (array) { - arrayPush(otherArgs, array); +/** + * The base implementation of `_.gt` which doesn't coerce arguments. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + */ +function baseGt(value, other) { + return value > other; +} + +/** + * Creates a function that performs a relational operation on two values. + * + * @private + * @param {Function} operator The function to perform the operation. + * @returns {Function} Returns the new relational operation function. + */ +function createRelationalOperation(operator) { + return function (value, other) { + if (!(typeof value == 'string' && typeof other == 'string')) { + value = toNumber(value); + other = toNumber(other); } - return apply$1(func, this, otherArgs); - }); + return operator(value, other); + }; } /** - * Converts `string` to - * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). + * Checks if `value` is greater than `other`. * * @static * @memberOf _ - * @since 3.1.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the start cased string. + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than `other`, + * else `false`. + * @see _.lt * @example * - * _.startCase('--foo-bar--'); - * // => 'Foo Bar' + * _.gt(3, 1); + * // => true * - * _.startCase('fooBar'); - * // => 'Foo Bar' + * _.gt(3, 3); + * // => false * - * _.startCase('__FOO_BAR__'); - * // => 'FOO BAR' + * _.gt(1, 3); + * // => false */ -var startCase = createCompounder(function (result, word, index) { - return result + (index ? ' ' : '') + upperFirst(word); -}); +var gt = createRelationalOperation(baseGt); /** - * Checks if `string` starts with the given target string. + * Checks if `value` is greater than or equal to `other`. * * @static * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {string} [target] The string to search for. - * @param {number} [position=0] The position to search from. - * @returns {boolean} Returns `true` if `string` starts with `target`, - * else `false`. + * @since 3.9.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if `value` is greater than or equal to + * `other`, else `false`. + * @see _.lte * @example * - * _.startsWith('abc', 'a'); + * _.gte(3, 1); * // => true * - * _.startsWith('abc', 'b'); - * // => false - * - * _.startsWith('abc', 'b', 1); + * _.gte(3, 3); * // => true + * + * _.gte(1, 3); + * // => false */ -function startsWith$1(string, target, position) { - string = toString$1(string); - position = position == null ? 0 : baseClamp(toInteger(position), 0, string.length); +var gte = createRelationalOperation(function (value, other) { + return value >= other; +}); - target = baseToString(target); - return string.slice(position, position + target.length) == target; +/** Used for built-in method references. */ +var objectProto$22 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$19 = objectProto$22.hasOwnProperty; + +/** + * The base implementation of `_.has` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHas(object, key) { + return object != null && hasOwnProperty$19.call(object, key); } /** - * This method returns a new empty object. + * Checks if `path` is a direct property of `object`. * * @static + * @since 0.1.0 * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {Object} Returns the new empty object. + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. * @example * - * var objects = _.times(2, _.stubObject); + * var object = { 'a': { 'b': 2 } }; + * var other = _.create({ 'a': _.create({ 'b': 2 }) }); * - * console.log(objects); - * // => [{}, {}] + * _.has(object, 'a'); + * // => true * - * console.log(objects[0] === objects[1]); + * _.has(object, 'a.b'); + * // => true + * + * _.has(object, ['a', 'b']); + * // => true + * + * _.has(other, 'a'); * // => false */ -function stubObject() { - return {}; +function has$1(object, path) { + return object != null && hasPath(object, path, baseHas); } +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$8 = Math.max; +var nativeMin$5 = Math.min; + /** - * This method returns an empty string. - * - * @static - * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {string} Returns the empty string. - * @example + * The base implementation of `_.inRange` which doesn't coerce arguments. * - * _.times(2, _.stubString); - * // => ['', ''] + * @private + * @param {number} number The number to check. + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. */ -function stubString() { - return ''; +function baseInRange(number, start, end) { + return number >= nativeMin$5(start, end) && number < nativeMax$8(start, end); } /** - * This method returns `true`. + * Checks if `n` is between `start` and up to, but not including, `end`. If + * `end` is not specified, it's set to `start` with `start` then set to `0`. + * If `start` is greater than `end` the params are swapped to support + * negative ranges. * * @static * @memberOf _ - * @since 4.13.0 - * @category Util - * @returns {boolean} Returns `true`. + * @since 3.3.0 + * @category Number + * @param {number} number The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `number` is in the range, else `false`. + * @see _.range, _.rangeRight * @example * - * _.times(2, _.stubTrue); - * // => [true, true] + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + * + * _.inRange(-3, -2, -6); + * // => true */ -function stubTrue() { - return true; +function inRange(number, start, end) { + start = toFinite(start); + if (end === undefined) { + end = start; + start = 0; + } else { + end = toFinite(end); + } + number = toNumber(number); + return baseInRange(number, start, end); } +/** `Object#toString` result references. */ +var stringTag$4 = '[object String]'; + /** - * Subtract two numbers. + * Checks if `value` is classified as a `String` primitive or object. * * @static + * @since 0.1.0 * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {number} minuend The first number in a subtraction. - * @param {number} subtrahend The second number in a subtraction. - * @returns {number} Returns the difference. + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a string, else `false`. * @example * - * _.subtract(6, 4); - * // => 2 + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false */ -var subtract = createMathOperation(function (minuend, subtrahend) { - return minuend - subtrahend; -}, 0); +function isString(value) { + return typeof value == 'string' || !isArray$1(value) && isObjectLike(value) && baseGetTag(value) == stringTag$4; +} /** - * Computes the sum of the values in `array`. - * - * @static - * @memberOf _ - * @since 3.4.0 - * @category Math - * @param {Array} array The array to iterate over. - * @returns {number} Returns the sum. - * @example + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. * - * _.sum([4, 2, 8, 6]); - * // => 20 + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. */ -function sum(array) { - return array && array.length ? baseSum(array, identity$1) : 0; +function baseValues(object, props) { + return arrayMap(props, function (key) { + return object[key]; + }); } /** - * This method is like `_.sum` except that it accepts `iteratee` which is - * invoked for each element in `array` to generate the value to be summed. - * The iteratee is invoked with one argument: (value). + * Creates an array of the own enumerable string keyed property values of `object`. + * + * **Note:** Non-object values are coerced to objects. * * @static + * @since 0.1.0 * @memberOf _ - * @since 4.0.0 - * @category Math - * @param {Array} array The array to iterate over. - * @param {Function} [iteratee=_.identity] The iteratee invoked per element. - * @returns {number} Returns the sum. + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. * @example * - * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; - * - * _.sumBy(objects, function(o) { return o.n; }); - * // => 20 + * function Foo() { + * this.a = 1; + * this.b = 2; + * } * - * // The `_.property` iteratee shorthand. - * _.sumBy(objects, 'n'); - * // => 20 - */ -function sumBy(array, iteratee) { - return array && array.length ? baseSum(array, baseIteratee(iteratee, 2)) : 0; -} - -/** - * Gets all but the first element of `array`. + * Foo.prototype.c = 3; * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Array - * @param {Array} array The array to query. - * @returns {Array} Returns the slice of `array`. - * @example + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) * - * _.tail([1, 2, 3]); - * // => [2, 3] + * _.values('hi'); + * // => ['h', 'i'] */ -function tail$1(array) { - var length = array == null ? 0 : array.length; - return length ? baseSlice(array, 1, length) : []; +function values$1(object) { + return object == null ? [] : baseValues(object, keys$1(object)); } +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$9 = Math.max; + /** - * Creates a slice of `array` with `n` elements taken from the beginning. + * Checks if `value` is in `collection`. If `collection` is a string, it's + * checked for a substring of `value`, otherwise + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * is used for equality comparisons. If `fromIndex` is negative, it's used as + * the offset from the end of `collection`. * * @static * @memberOf _ * @since 0.1.0 - * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. + * @category Collection + * @param {Array|Object|string} collection The collection to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. + * @returns {boolean} Returns `true` if `value` is found, else `false`. * @example * - * _.take([1, 2, 3]); - * // => [1] + * _.includes([1, 2, 3], 1); + * // => true * - * _.take([1, 2, 3], 2); - * // => [1, 2] + * _.includes([1, 2, 3], 1, 2); + * // => false * - * _.take([1, 2, 3], 5); - * // => [1, 2, 3] + * _.includes({ 'a': 1, 'b': 2 }, 1); + * // => true * - * _.take([1, 2, 3], 0); - * // => [] + * _.includes('abcd', 'bc'); + * // => true */ -function take(array, n, guard) { - if (!(array && array.length)) { - return []; +function includes$1(collection, value, fromIndex, guard) { + collection = isArrayLike(collection) ? collection : values$1(collection); + fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0; + + var length = collection.length; + if (fromIndex < 0) { + fromIndex = nativeMax$9(length + fromIndex, 0); } - n = guard || n === undefined ? 1 : toInteger(n); - return baseSlice(array, 0, n < 0 ? 0 : n); + return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1; } +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMax$10 = Math.max; + /** - * Creates a slice of `array` with `n` elements taken from the end. + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it's used as the + * offset from the end of `array`. * * @static * @memberOf _ - * @since 3.0.0 + * @since 0.1.0 * @category Array - * @param {Array} array The array to query. - * @param {number} [n=1] The number of elements to take. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the slice of `array`. + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.takeRight([1, 2, 3]); - * // => [3] - * - * _.takeRight([1, 2, 3], 2); - * // => [2, 3] - * - * _.takeRight([1, 2, 3], 5); - * // => [1, 2, 3] + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 * - * _.takeRight([1, 2, 3], 0); - * // => [] + * // Search from the `fromIndex`. + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 */ -function takeRight(array, n, guard) { +function indexOf$1(array, value, fromIndex) { var length = array == null ? 0 : array.length; if (!length) { - return []; + return -1; } - n = guard || n === undefined ? 1 : toInteger(n); - n = length - n; - return baseSlice(array, n < 0 ? 0 : n, length); + var index = fromIndex == null ? 0 : toInteger(fromIndex); + if (index < 0) { + index = nativeMax$10(length + index, 0); + } + return baseIndexOf(array, value, index); } /** - * Creates a slice of `array` with elements taken from the end. Elements are - * taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). + * Gets all but the last element of `array`. * * @static * @memberOf _ - * @since 3.0.0 + * @since 0.1.0 * @category Array * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the slice of `array`. * @example * - * var users = [ - * { 'user': 'barney', 'active': true }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': false } - * ]; - * - * _.takeRightWhile(users, function(o) { return !o.active; }); - * // => objects for ['fred', 'pebbles'] - * - * // The `_.matches` iteratee shorthand. - * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); - * // => objects for ['pebbles'] + * _.initial([1, 2, 3]); + * // => [1, 2] + */ +function initial(array) { + var length = array == null ? 0 : array.length; + return length ? baseSlice(array, 0, -1) : []; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeMin$6 = Math.min; + +/** + * The base implementation of methods like `_.intersection`, without support + * for iteratee shorthands, that accepts an array of arrays to inspect. * - * // The `_.matchesProperty` iteratee shorthand. - * _.takeRightWhile(users, ['active', false]); - * // => objects for ['fred', 'pebbles'] + * @private + * @param {Array} arrays The arrays to inspect. + * @param {Function} [iteratee] The iteratee invoked per element. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of shared values. + */ +function baseIntersection(arrays, iteratee, comparator) { + var includes = comparator ? arrayIncludesWith : arrayIncludes, + length = arrays[0].length, + othLength = arrays.length, + othIndex = othLength, + caches = Array(othLength), + maxLength = Infinity, + result = []; + + while (othIndex--) { + var array = arrays[othIndex]; + if (othIndex && iteratee) { + array = arrayMap(array, baseUnary(iteratee)); + } + maxLength = nativeMin$6(array.length, maxLength); + caches[othIndex] = !comparator && (iteratee || length >= 120 && array.length >= 120) ? new SetCache(othIndex && array) : undefined; + } + array = arrays[0]; + + var index = -1, + seen = caches[0]; + + outer: while (++index < length && result.length < maxLength) { + var value = array[index], + computed = iteratee ? iteratee(value) : value; + + value = comparator || value !== 0 ? value : 0; + if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) { + othIndex = othLength; + while (--othIndex) { + var cache = caches[othIndex]; + if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) { + continue outer; + } + } + if (seen) { + seen.push(computed); + } + result.push(value); + } + } + return result; +} + +/** + * Casts `value` to an empty array if it's not an array like object. * - * // The `_.property` iteratee shorthand. - * _.takeRightWhile(users, 'active'); - * // => [] + * @private + * @param {*} value The value to inspect. + * @returns {Array|Object} Returns the cast array-like object. */ -function takeRightWhile(array, predicate) { - return array && array.length ? baseWhile(array, baseIteratee(predicate, 3), false, true) : []; +function castArrayLikeObject(value) { + return isArrayLikeObject(value) ? value : []; } /** - * Creates a slice of `array` with elements taken from the beginning. Elements - * are taken until `predicate` returns falsey. The predicate is invoked with - * three arguments: (value, index, array). + * Creates an array of unique values that are included in all given arrays + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * for equality comparisons. The order and references of result values are + * determined by the first array. * * @static * @memberOf _ - * @since 3.0.0 + * @since 0.1.0 * @category Array - * @param {Array} array The array to query. - * @param {Function} [predicate=_.identity] The function invoked per iteration. - * @returns {Array} Returns the slice of `array`. + * @param {...Array} [arrays] The arrays to inspect. + * @returns {Array} Returns the new array of intersecting values. * @example * - * var users = [ - * { 'user': 'barney', 'active': false }, - * { 'user': 'fred', 'active': false }, - * { 'user': 'pebbles', 'active': true } - * ]; - * - * _.takeWhile(users, function(o) { return !o.active; }); - * // => objects for ['barney', 'fred'] + * _.intersection([2, 1], [2, 3]); + * // => [2] + */ +var intersection = baseRest(function (arrays) { + var mapped = arrayMap(arrays, castArrayLikeObject); + return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : []; +}); + +/** + * This method is like `_.intersection` except that it accepts `iteratee` + * which is invoked for each element of each `arrays` to generate the criterion + * by which they're compared. The order and references of result values are + * determined by the first array. The iteratee is invoked with one argument: + * (value). * - * // The `_.matches` iteratee shorthand. - * _.takeWhile(users, { 'user': 'barney', 'active': false }); - * // => objects for ['barney'] + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Array} Returns the new array of intersecting values. + * @example * - * // The `_.matchesProperty` iteratee shorthand. - * _.takeWhile(users, ['active', false]); - * // => objects for ['barney', 'fred'] + * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); + * // => [2.1] * * // The `_.property` iteratee shorthand. - * _.takeWhile(users, 'active'); - * // => [] + * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); + * // => [{ 'x': 1 }] */ -function takeWhile(array, predicate) { - return array && array.length ? baseWhile(array, baseIteratee(predicate, 3)) : []; -} +var intersectionBy = baseRest(function (arrays) { + var iteratee = last$1(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); + + if (iteratee === last$1(mapped)) { + iteratee = undefined; + } else { + mapped.pop(); + } + return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, baseIteratee(iteratee, 2)) : []; +}); /** - * This method invokes `interceptor` and returns `value`. The interceptor - * is invoked with one argument; (value). The purpose of this method is to - * "tap into" a method chain sequence in order to modify intermediate results. + * This method is like `_.intersection` except that it accepts `comparator` + * which is invoked to compare elements of `arrays`. The order and references + * of result values are determined by the first array. The comparator is + * invoked with two arguments: (arrVal, othVal). * * @static * @memberOf _ - * @since 0.1.0 - * @category Seq - * @param {*} value The value to provide to `interceptor`. - * @param {Function} interceptor The function to invoke. - * @returns {*} Returns `value`. + * @since 4.0.0 + * @category Array + * @param {...Array} [arrays] The arrays to inspect. + * @param {Function} [comparator] The comparator invoked per element. + * @returns {Array} Returns the new array of intersecting values. * @example * - * _([1, 2, 3]) - * .tap(function(array) { - * // Mutate input array. - * array.pop(); - * }) - * .reverse() - * .value(); - * // => [2, 1] + * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; + * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; + * + * _.intersectionWith(objects, others, _.isEqual); + * // => [{ 'x': 1, 'y': 2 }] */ -function tap(value, interceptor) { - interceptor(value); - return value; -} +var intersectionWith = baseRest(function (arrays) { + var comparator = last$1(arrays), + mapped = arrayMap(arrays, castArrayLikeObject); -/** Used to escape characters for inclusion in compiled string literals. */ -var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\u2028': 'u2028', - '\u2029': 'u2029' -}; + comparator = typeof comparator == 'function' ? comparator : undefined; + if (comparator) { + mapped.pop(); + } + return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined, comparator) : []; +}); /** - * Used by `_.template` to escape characters for inclusion in compiled string literals. + * The base implementation of `_.invert` and `_.invertBy` which inverts + * `object` with values transformed by `iteratee` and set by `setter`. * * @private - * @param {string} chr The matched character to escape. - * @returns {string} Returns the escaped character. + * @param {Object} object The object to iterate over. + * @param {Function} setter The function to set `accumulator` values. + * @param {Function} iteratee The iteratee to transform values. + * @param {Object} accumulator The initial inverted object. + * @returns {Function} Returns `accumulator`. */ -function escapeStringChar(chr) { - return '\\' + stringEscapes[chr]; +function baseInverter(object, setter, iteratee, accumulator) { + baseForOwn(object, function (value, key, object) { + setter(accumulator, iteratee(value), key, object); + }); + return accumulator; } -/** Used to match template delimiters. */ -var reInterpolate = /<%=([\s\S]+?)%>/g; - -/** Used to match template delimiters. */ -var reEscape = /<%-([\s\S]+?)%>/g; - -/** Used to match template delimiters. */ -var reEvaluate = /<%([\s\S]+?)%>/g; +/** + * Creates a function like `_.invertBy`. + * + * @private + * @param {Function} setter The function to set accumulator values. + * @param {Function} toIteratee The function to resolve iteratees. + * @returns {Function} Returns the new inverter function. + */ +function createInverter(setter, toIteratee) { + return function (object, iteratee) { + return baseInverter(object, setter, toIteratee(iteratee), {}); + }; +} /** - * By default, the template delimiters used by lodash are like those in - * embedded Ruby (ERB) as well as ES2015 template strings. Change the - * following template settings to use alternative delimiters. + * Creates an object composed of the inverted keys and values of `object`. + * If `object` contains duplicate values, subsequent values overwrite + * property assignments of previous values. * * @static * @memberOf _ - * @type {Object} - */ -var templateSettings = { - - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'escape': reEscape, - - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'evaluate': reEvaluate, - - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - 'interpolate': reInterpolate, + * @since 0.7.0 + * @category Object + * @param {Object} object The object to invert. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invert(object); + * // => { '1': 'c', '2': 'b' } + */ +var invert = createInverter(function (result, value, key) { + result[value] = key; +}, constant(identity$1)); - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type {string} - */ - 'variable': '', +/** Used for built-in method references. */ +var objectProto$23 = Object.prototype; - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type {Object} - */ - 'imports': { +/** Used to check objects for own properties. */ +var hasOwnProperty$20 = objectProto$23.hasOwnProperty; - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type {Function} - */ - '_': { 'escape': escape$1 } +/** + * This method is like `_.invert` except that the inverted object is generated + * from the results of running each element of `object` thru `iteratee`. The + * corresponding inverted value of each inverted key is an array of keys + * responsible for generating the inverted value. The iteratee is invoked + * with one argument: (value). + * + * @static + * @memberOf _ + * @since 4.1.0 + * @category Object + * @param {Object} object The object to invert. + * @param {Function} [iteratee=_.identity] The iteratee invoked per element. + * @returns {Object} Returns the new inverted object. + * @example + * + * var object = { 'a': 1, 'b': 2, 'c': 1 }; + * + * _.invertBy(object); + * // => { '1': ['a', 'c'], '2': ['b'] } + * + * _.invertBy(object, function(value) { + * return 'group' + value; + * }); + * // => { 'group1': ['a', 'c'], 'group2': ['b'] } + */ +var invertBy = createInverter(function (result, value, key) { + if (hasOwnProperty$20.call(result, value)) { + result[value].push(key); + } else { + result[value] = [key]; } -}; - -/** Used to match empty string literals in compiled template source. */ -var reEmptyStringLeading = /\b__p \+= '';/g; -var reEmptyStringMiddle = /\b(__p \+=) '' \+/g; -var reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; +}, baseIteratee); /** - * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). + * Gets the parent value at `path` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path to get the parent value of. + * @returns {*} Returns the parent value. */ -var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - -/** Used to ensure capturing order of template delimiters. */ -var reNoMatch = /($^)/; +function parent(object, path) { + return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); +} -/** Used to match unescaped characters in compiled string literals. */ -var reUnescapedString = /['\n\r\u2028\u2029\\]/g; +/** + * The base implementation of `_.invoke` without support for individual + * method arguments. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ +function baseInvoke(object, path, args) { + path = castPath(path, object); + object = parent(object, path); + var func = object == null ? object : object[toKey(last$1(path))]; + return func == null ? undefined : apply$1(func, object, args); +} /** - * Creates a compiled template function that can interpolate data properties - * in "interpolate" delimiters, HTML-escape interpolated data properties in - * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data - * properties may be accessed as free variables in the template. If a setting - * object is given, it takes precedence over `_.templateSettings` values. + * Invokes the method at `path` of `object`. * - * **Note:** In the development build `_.template` utilizes - * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) - * for easier debugging. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {...*} [args] The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + * @example * - * For more information on precompiling templates see - * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; * - * For more information on Chrome extension sandboxes see - * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * _.invoke(object, 'a[0].b.c.slice', 1, 3); + * // => [2, 3] + */ +var invoke$1 = baseRest(baseInvoke); + +/** + * Invokes the method at `path` of each element in `collection`, returning + * an array of the results of each invoked method. Any additional arguments + * are provided to each invoked method. If `path` is a function, it's invoked + * for, and `this` bound to, each element in `collection`. * * @static - * @since 0.1.0 * @memberOf _ - * @category String - * @param {string} [string=''] The template string. - * @param {Object} [options={}] The options object. - * @param {RegExp} [options.escape=_.templateSettings.escape] - * The HTML "escape" delimiter. - * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] - * The "evaluate" delimiter. - * @param {Object} [options.imports=_.templateSettings.imports] - * An object to import into the template as free variables. - * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] - * The "interpolate" delimiter. - * @param {string} [options.sourceURL='templateSources[n]'] - * The sourceURL of the compiled template. - * @param {string} [options.variable='obj'] - * The data object variable name. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Function} Returns the compiled template function. + * @since 4.0.0 + * @category Collection + * @param {Array|Object} collection The collection to iterate over. + * @param {Array|Function|string} path The path of the method to invoke or + * the function invoked per iteration. + * @param {...*} [args] The arguments to invoke each method with. + * @returns {Array} Returns the array of results. * @example * - * // Use the "interpolate" delimiter to create a compiled template. - * var compiled = _.template('hello <%= user %>!'); - * compiled({ 'user': 'fred' }); - * // => 'hello fred!' - * - * // Use the HTML "escape" delimiter to escape data property values. - * var compiled = _.template('<%- value %>'); - * compiled({ 'value': '