@gitlab/frontend-tests 0.0.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +112 -1
  2. package/dist/index.cjs +38 -0
  3. package/dist/index.d.cts +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +5 -0
  6. package/dist/integration/constants.d.cts +3 -0
  7. package/dist/integration/constants.d.ts +3 -0
  8. package/dist/integration/fixture_utils.d.cts +107 -0
  9. package/dist/integration/fixture_utils.d.ts +107 -0
  10. package/dist/integration/fixture_variant_schema.d.cts +74 -0
  11. package/dist/integration/fixture_variant_schema.d.ts +74 -0
  12. package/dist/integration/handlers.d.cts +10 -0
  13. package/dist/integration/handlers.d.ts +10 -0
  14. package/dist/integration/index.d.cts +7 -0
  15. package/dist/integration/index.d.ts +7 -0
  16. package/dist/integration/jest_config.cjs +31 -0
  17. package/dist/integration/jest_config.d.cts +11 -0
  18. package/dist/integration/jest_config.d.ts +11 -0
  19. package/dist/integration/jest_config.js +27 -0
  20. package/dist/integration/operation_helpers.d.cts +70 -0
  21. package/dist/integration/operation_helpers.d.ts +70 -0
  22. package/dist/integration/polyfills.cjs +21 -0
  23. package/dist/integration/polyfills.d.cts +1 -0
  24. package/dist/integration/polyfills.d.ts +1 -0
  25. package/dist/integration/polyfills.js +19 -0
  26. package/dist/integration/polyfills_text_encoding.cjs +8 -0
  27. package/dist/integration/polyfills_text_encoding.d.cts +1 -0
  28. package/dist/integration/polyfills_text_encoding.d.ts +1 -0
  29. package/dist/integration/polyfills_text_encoding.js +6 -0
  30. package/dist/integration/server.d.cts +3 -0
  31. package/dist/integration/server.d.ts +3 -0
  32. package/dist/integration/types.d.cts +82 -0
  33. package/dist/integration/types.d.ts +82 -0
  34. package/dist/integration.cjs +38 -0
  35. package/dist/integration.js +5 -0
  36. package/dist/server-C2Drh977.js +3970 -0
  37. package/dist/server-hzT7AwDi.cjs +3999 -0
  38. package/integration/jest-config.js +2 -0
  39. package/integration/polyfills/text-encoding.js +2 -0
  40. package/integration/polyfills.js +2 -0
  41. package/integration.js +2 -0
  42. package/package.json +138 -5
@@ -0,0 +1,3999 @@
1
+ 'use strict';
2
+
3
+ var node = require('msw/node');
4
+ var msw = require('msw');
5
+ var node_fs = require('node:fs');
6
+ var node_path = require('node:path');
7
+
8
+ const baseMetadata = { router: null };
9
+
10
+ /** Detect free variable `global` from Node.js. */
11
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
12
+
13
+ /** Detect free variable `self`. */
14
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
15
+
16
+ /** Used as a reference to the global object. */
17
+ var root = freeGlobal || freeSelf || Function('return this')();
18
+
19
+ /** Built-in value references. */
20
+ var Symbol = root.Symbol;
21
+
22
+ /** Used for built-in method references. */
23
+ var objectProto$b = Object.prototype;
24
+
25
+ /** Used to check objects for own properties. */
26
+ var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
27
+
28
+ /**
29
+ * Used to resolve the
30
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
31
+ * of values.
32
+ */
33
+ var nativeObjectToString$1 = objectProto$b.toString;
34
+
35
+ /** Built-in value references. */
36
+ var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
37
+
38
+ /**
39
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
40
+ *
41
+ * @private
42
+ * @param {*} value The value to query.
43
+ * @returns {string} Returns the raw `toStringTag`.
44
+ */
45
+ function getRawTag(value) {
46
+ var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
47
+ tag = value[symToStringTag$1];
48
+
49
+ try {
50
+ value[symToStringTag$1] = undefined;
51
+ var unmasked = true;
52
+ } catch (e) {}
53
+
54
+ var result = nativeObjectToString$1.call(value);
55
+ if (unmasked) {
56
+ if (isOwn) {
57
+ value[symToStringTag$1] = tag;
58
+ } else {
59
+ delete value[symToStringTag$1];
60
+ }
61
+ }
62
+ return result;
63
+ }
64
+
65
+ /** Used for built-in method references. */
66
+ var objectProto$a = Object.prototype;
67
+
68
+ /**
69
+ * Used to resolve the
70
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
71
+ * of values.
72
+ */
73
+ var nativeObjectToString = objectProto$a.toString;
74
+
75
+ /**
76
+ * Converts `value` to a string using `Object.prototype.toString`.
77
+ *
78
+ * @private
79
+ * @param {*} value The value to convert.
80
+ * @returns {string} Returns the converted string.
81
+ */
82
+ function objectToString(value) {
83
+ return nativeObjectToString.call(value);
84
+ }
85
+
86
+ /** `Object#toString` result references. */
87
+ var nullTag = '[object Null]',
88
+ undefinedTag = '[object Undefined]';
89
+
90
+ /** Built-in value references. */
91
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
92
+
93
+ /**
94
+ * The base implementation of `getTag` without fallbacks for buggy environments.
95
+ *
96
+ * @private
97
+ * @param {*} value The value to query.
98
+ * @returns {string} Returns the `toStringTag`.
99
+ */
100
+ function baseGetTag(value) {
101
+ if (value == null) {
102
+ return value === undefined ? undefinedTag : nullTag;
103
+ }
104
+ return (symToStringTag && symToStringTag in Object(value))
105
+ ? getRawTag(value)
106
+ : objectToString(value);
107
+ }
108
+
109
+ /**
110
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
111
+ * and has a `typeof` result of "object".
112
+ *
113
+ * @static
114
+ * @memberOf _
115
+ * @since 4.0.0
116
+ * @category Lang
117
+ * @param {*} value The value to check.
118
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
119
+ * @example
120
+ *
121
+ * _.isObjectLike({});
122
+ * // => true
123
+ *
124
+ * _.isObjectLike([1, 2, 3]);
125
+ * // => true
126
+ *
127
+ * _.isObjectLike(_.noop);
128
+ * // => false
129
+ *
130
+ * _.isObjectLike(null);
131
+ * // => false
132
+ */
133
+ function isObjectLike(value) {
134
+ return value != null && typeof value == 'object';
135
+ }
136
+
137
+ /** `Object#toString` result references. */
138
+ var symbolTag$2 = '[object Symbol]';
139
+
140
+ /**
141
+ * Checks if `value` is classified as a `Symbol` primitive or object.
142
+ *
143
+ * @static
144
+ * @memberOf _
145
+ * @since 4.0.0
146
+ * @category Lang
147
+ * @param {*} value The value to check.
148
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
149
+ * @example
150
+ *
151
+ * _.isSymbol(Symbol.iterator);
152
+ * // => true
153
+ *
154
+ * _.isSymbol('abc');
155
+ * // => false
156
+ */
157
+ function isSymbol(value) {
158
+ return typeof value == 'symbol' ||
159
+ (isObjectLike(value) && baseGetTag(value) == symbolTag$2);
160
+ }
161
+
162
+ /**
163
+ * A specialized version of `_.map` for arrays without support for iteratee
164
+ * shorthands.
165
+ *
166
+ * @private
167
+ * @param {Array} [array] The array to iterate over.
168
+ * @param {Function} iteratee The function invoked per iteration.
169
+ * @returns {Array} Returns the new mapped array.
170
+ */
171
+ function arrayMap(array, iteratee) {
172
+ var index = -1,
173
+ length = array == null ? 0 : array.length,
174
+ result = Array(length);
175
+
176
+ while (++index < length) {
177
+ result[index] = iteratee(array[index], index, array);
178
+ }
179
+ return result;
180
+ }
181
+
182
+ /**
183
+ * Checks if `value` is classified as an `Array` object.
184
+ *
185
+ * @static
186
+ * @memberOf _
187
+ * @since 0.1.0
188
+ * @category Lang
189
+ * @param {*} value The value to check.
190
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
191
+ * @example
192
+ *
193
+ * _.isArray([1, 2, 3]);
194
+ * // => true
195
+ *
196
+ * _.isArray(document.body.children);
197
+ * // => false
198
+ *
199
+ * _.isArray('abc');
200
+ * // => false
201
+ *
202
+ * _.isArray(_.noop);
203
+ * // => false
204
+ */
205
+ var isArray = Array.isArray;
206
+
207
+ /** Used to convert symbols to primitives and strings. */
208
+ var symbolProto$1 = Symbol ? Symbol.prototype : undefined,
209
+ symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
210
+
211
+ /**
212
+ * The base implementation of `_.toString` which doesn't convert nullish
213
+ * values to empty strings.
214
+ *
215
+ * @private
216
+ * @param {*} value The value to process.
217
+ * @returns {string} Returns the string.
218
+ */
219
+ function baseToString(value) {
220
+ // Exit early for strings to avoid a performance hit in some environments.
221
+ if (typeof value == 'string') {
222
+ return value;
223
+ }
224
+ if (isArray(value)) {
225
+ // Recursively convert values (susceptible to call stack limits).
226
+ return arrayMap(value, baseToString) + '';
227
+ }
228
+ if (isSymbol(value)) {
229
+ return symbolToString ? symbolToString.call(value) : '';
230
+ }
231
+ var result = (value + '');
232
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
233
+ }
234
+
235
+ /**
236
+ * Checks if `value` is the
237
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
238
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
239
+ *
240
+ * @static
241
+ * @memberOf _
242
+ * @since 0.1.0
243
+ * @category Lang
244
+ * @param {*} value The value to check.
245
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
246
+ * @example
247
+ *
248
+ * _.isObject({});
249
+ * // => true
250
+ *
251
+ * _.isObject([1, 2, 3]);
252
+ * // => true
253
+ *
254
+ * _.isObject(_.noop);
255
+ * // => true
256
+ *
257
+ * _.isObject(null);
258
+ * // => false
259
+ */
260
+ function isObject(value) {
261
+ var type = typeof value;
262
+ return value != null && (type == 'object' || type == 'function');
263
+ }
264
+
265
+ /**
266
+ * This method returns the first argument it receives.
267
+ *
268
+ * @static
269
+ * @since 0.1.0
270
+ * @memberOf _
271
+ * @category Util
272
+ * @param {*} value Any value.
273
+ * @returns {*} Returns `value`.
274
+ * @example
275
+ *
276
+ * var object = { 'a': 1 };
277
+ *
278
+ * console.log(_.identity(object) === object);
279
+ * // => true
280
+ */
281
+ function identity(value) {
282
+ return value;
283
+ }
284
+
285
+ /** `Object#toString` result references. */
286
+ var asyncTag = '[object AsyncFunction]',
287
+ funcTag$2 = '[object Function]',
288
+ genTag$1 = '[object GeneratorFunction]',
289
+ proxyTag = '[object Proxy]';
290
+
291
+ /**
292
+ * Checks if `value` is classified as a `Function` object.
293
+ *
294
+ * @static
295
+ * @memberOf _
296
+ * @since 0.1.0
297
+ * @category Lang
298
+ * @param {*} value The value to check.
299
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
300
+ * @example
301
+ *
302
+ * _.isFunction(_);
303
+ * // => true
304
+ *
305
+ * _.isFunction(/abc/);
306
+ * // => false
307
+ */
308
+ function isFunction(value) {
309
+ if (!isObject(value)) {
310
+ return false;
311
+ }
312
+ // The use of `Object#toString` avoids issues with the `typeof` operator
313
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
314
+ var tag = baseGetTag(value);
315
+ return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
316
+ }
317
+
318
+ /** Used to detect overreaching core-js shims. */
319
+ var coreJsData = root['__core-js_shared__'];
320
+
321
+ /** Used to detect methods masquerading as native. */
322
+ var maskSrcKey = (function() {
323
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
324
+ return uid ? ('Symbol(src)_1.' + uid) : '';
325
+ }());
326
+
327
+ /**
328
+ * Checks if `func` has its source masked.
329
+ *
330
+ * @private
331
+ * @param {Function} func The function to check.
332
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
333
+ */
334
+ function isMasked(func) {
335
+ return !!maskSrcKey && (maskSrcKey in func);
336
+ }
337
+
338
+ /** Used for built-in method references. */
339
+ var funcProto$1 = Function.prototype;
340
+
341
+ /** Used to resolve the decompiled source of functions. */
342
+ var funcToString$1 = funcProto$1.toString;
343
+
344
+ /**
345
+ * Converts `func` to its source code.
346
+ *
347
+ * @private
348
+ * @param {Function} func The function to convert.
349
+ * @returns {string} Returns the source code.
350
+ */
351
+ function toSource(func) {
352
+ if (func != null) {
353
+ try {
354
+ return funcToString$1.call(func);
355
+ } catch (e) {}
356
+ try {
357
+ return (func + '');
358
+ } catch (e) {}
359
+ }
360
+ return '';
361
+ }
362
+
363
+ /**
364
+ * Used to match `RegExp`
365
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
366
+ */
367
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
368
+
369
+ /** Used to detect host constructors (Safari). */
370
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
371
+
372
+ /** Used for built-in method references. */
373
+ var funcProto = Function.prototype,
374
+ objectProto$9 = Object.prototype;
375
+
376
+ /** Used to resolve the decompiled source of functions. */
377
+ var funcToString = funcProto.toString;
378
+
379
+ /** Used to check objects for own properties. */
380
+ var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
381
+
382
+ /** Used to detect if a method is native. */
383
+ var reIsNative = RegExp('^' +
384
+ funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
385
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
386
+ );
387
+
388
+ /**
389
+ * The base implementation of `_.isNative` without bad shim checks.
390
+ *
391
+ * @private
392
+ * @param {*} value The value to check.
393
+ * @returns {boolean} Returns `true` if `value` is a native function,
394
+ * else `false`.
395
+ */
396
+ function baseIsNative(value) {
397
+ if (!isObject(value) || isMasked(value)) {
398
+ return false;
399
+ }
400
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
401
+ return pattern.test(toSource(value));
402
+ }
403
+
404
+ /**
405
+ * Gets the value at `key` of `object`.
406
+ *
407
+ * @private
408
+ * @param {Object} [object] The object to query.
409
+ * @param {string} key The key of the property to get.
410
+ * @returns {*} Returns the property value.
411
+ */
412
+ function getValue(object, key) {
413
+ return object == null ? undefined : object[key];
414
+ }
415
+
416
+ /**
417
+ * Gets the native function at `key` of `object`.
418
+ *
419
+ * @private
420
+ * @param {Object} object The object to query.
421
+ * @param {string} key The key of the method to get.
422
+ * @returns {*} Returns the function if it's native, else `undefined`.
423
+ */
424
+ function getNative(object, key) {
425
+ var value = getValue(object, key);
426
+ return baseIsNative(value) ? value : undefined;
427
+ }
428
+
429
+ /* Built-in method references that are verified to be native. */
430
+ var WeakMap = getNative(root, 'WeakMap');
431
+
432
+ /** Built-in value references. */
433
+ var objectCreate = Object.create;
434
+
435
+ /**
436
+ * The base implementation of `_.create` without support for assigning
437
+ * properties to the created object.
438
+ *
439
+ * @private
440
+ * @param {Object} proto The object to inherit from.
441
+ * @returns {Object} Returns the new object.
442
+ */
443
+ var baseCreate = (function() {
444
+ function object() {}
445
+ return function(proto) {
446
+ if (!isObject(proto)) {
447
+ return {};
448
+ }
449
+ if (objectCreate) {
450
+ return objectCreate(proto);
451
+ }
452
+ object.prototype = proto;
453
+ var result = new object;
454
+ object.prototype = undefined;
455
+ return result;
456
+ };
457
+ }());
458
+
459
+ /**
460
+ * A faster alternative to `Function#apply`, this function invokes `func`
461
+ * with the `this` binding of `thisArg` and the arguments of `args`.
462
+ *
463
+ * @private
464
+ * @param {Function} func The function to invoke.
465
+ * @param {*} thisArg The `this` binding of `func`.
466
+ * @param {Array} args The arguments to invoke `func` with.
467
+ * @returns {*} Returns the result of `func`.
468
+ */
469
+ function apply(func, thisArg, args) {
470
+ switch (args.length) {
471
+ case 0: return func.call(thisArg);
472
+ case 1: return func.call(thisArg, args[0]);
473
+ case 2: return func.call(thisArg, args[0], args[1]);
474
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
475
+ }
476
+ return func.apply(thisArg, args);
477
+ }
478
+
479
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
480
+ var HOT_COUNT = 800,
481
+ HOT_SPAN = 16;
482
+
483
+ /* Built-in method references for those with the same name as other `lodash` methods. */
484
+ var nativeNow = Date.now;
485
+
486
+ /**
487
+ * Creates a function that'll short out and invoke `identity` instead
488
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
489
+ * milliseconds.
490
+ *
491
+ * @private
492
+ * @param {Function} func The function to restrict.
493
+ * @returns {Function} Returns the new shortable function.
494
+ */
495
+ function shortOut(func) {
496
+ var count = 0,
497
+ lastCalled = 0;
498
+
499
+ return function() {
500
+ var stamp = nativeNow(),
501
+ remaining = HOT_SPAN - (stamp - lastCalled);
502
+
503
+ lastCalled = stamp;
504
+ if (remaining > 0) {
505
+ if (++count >= HOT_COUNT) {
506
+ return arguments[0];
507
+ }
508
+ } else {
509
+ count = 0;
510
+ }
511
+ return func.apply(undefined, arguments);
512
+ };
513
+ }
514
+
515
+ /**
516
+ * Creates a function that returns `value`.
517
+ *
518
+ * @static
519
+ * @memberOf _
520
+ * @since 2.4.0
521
+ * @category Util
522
+ * @param {*} value The value to return from the new function.
523
+ * @returns {Function} Returns the new constant function.
524
+ * @example
525
+ *
526
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
527
+ *
528
+ * console.log(objects);
529
+ * // => [{ 'a': 1 }, { 'a': 1 }]
530
+ *
531
+ * console.log(objects[0] === objects[1]);
532
+ * // => true
533
+ */
534
+ function constant(value) {
535
+ return function() {
536
+ return value;
537
+ };
538
+ }
539
+
540
+ var defineProperty = (function() {
541
+ try {
542
+ var func = getNative(Object, 'defineProperty');
543
+ func({}, '', {});
544
+ return func;
545
+ } catch (e) {}
546
+ }());
547
+
548
+ /**
549
+ * The base implementation of `setToString` without support for hot loop shorting.
550
+ *
551
+ * @private
552
+ * @param {Function} func The function to modify.
553
+ * @param {Function} string The `toString` result.
554
+ * @returns {Function} Returns `func`.
555
+ */
556
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
557
+ return defineProperty(func, 'toString', {
558
+ 'configurable': true,
559
+ 'enumerable': false,
560
+ 'value': constant(string),
561
+ 'writable': true
562
+ });
563
+ };
564
+
565
+ /**
566
+ * Sets the `toString` method of `func` to return `string`.
567
+ *
568
+ * @private
569
+ * @param {Function} func The function to modify.
570
+ * @param {Function} string The `toString` result.
571
+ * @returns {Function} Returns `func`.
572
+ */
573
+ var setToString = shortOut(baseSetToString);
574
+
575
+ /**
576
+ * A specialized version of `_.forEach` for arrays without support for
577
+ * iteratee shorthands.
578
+ *
579
+ * @private
580
+ * @param {Array} [array] The array to iterate over.
581
+ * @param {Function} iteratee The function invoked per iteration.
582
+ * @returns {Array} Returns `array`.
583
+ */
584
+ function arrayEach(array, iteratee) {
585
+ var index = -1,
586
+ length = array == null ? 0 : array.length;
587
+
588
+ while (++index < length) {
589
+ if (iteratee(array[index], index, array) === false) {
590
+ break;
591
+ }
592
+ }
593
+ return array;
594
+ }
595
+
596
+ /** Used as references for various `Number` constants. */
597
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
598
+
599
+ /** Used to detect unsigned integer values. */
600
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
601
+
602
+ /**
603
+ * Checks if `value` is a valid array-like index.
604
+ *
605
+ * @private
606
+ * @param {*} value The value to check.
607
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
608
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
609
+ */
610
+ function isIndex(value, length) {
611
+ var type = typeof value;
612
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
613
+
614
+ return !!length &&
615
+ (type == 'number' ||
616
+ (type != 'symbol' && reIsUint.test(value))) &&
617
+ (value > -1 && value % 1 == 0 && value < length);
618
+ }
619
+
620
+ /**
621
+ * The base implementation of `assignValue` and `assignMergeValue` without
622
+ * value checks.
623
+ *
624
+ * @private
625
+ * @param {Object} object The object to modify.
626
+ * @param {string} key The key of the property to assign.
627
+ * @param {*} value The value to assign.
628
+ */
629
+ function baseAssignValue(object, key, value) {
630
+ if (key == '__proto__' && defineProperty) {
631
+ defineProperty(object, key, {
632
+ 'configurable': true,
633
+ 'enumerable': true,
634
+ 'value': value,
635
+ 'writable': true
636
+ });
637
+ } else {
638
+ object[key] = value;
639
+ }
640
+ }
641
+
642
+ /**
643
+ * Performs a
644
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
645
+ * comparison between two values to determine if they are equivalent.
646
+ *
647
+ * @static
648
+ * @memberOf _
649
+ * @since 4.0.0
650
+ * @category Lang
651
+ * @param {*} value The value to compare.
652
+ * @param {*} other The other value to compare.
653
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
654
+ * @example
655
+ *
656
+ * var object = { 'a': 1 };
657
+ * var other = { 'a': 1 };
658
+ *
659
+ * _.eq(object, object);
660
+ * // => true
661
+ *
662
+ * _.eq(object, other);
663
+ * // => false
664
+ *
665
+ * _.eq('a', 'a');
666
+ * // => true
667
+ *
668
+ * _.eq('a', Object('a'));
669
+ * // => false
670
+ *
671
+ * _.eq(NaN, NaN);
672
+ * // => true
673
+ */
674
+ function eq(value, other) {
675
+ return value === other || (value !== value && other !== other);
676
+ }
677
+
678
+ /** Used for built-in method references. */
679
+ var objectProto$8 = Object.prototype;
680
+
681
+ /** Used to check objects for own properties. */
682
+ var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
683
+
684
+ /**
685
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
686
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
687
+ * for equality comparisons.
688
+ *
689
+ * @private
690
+ * @param {Object} object The object to modify.
691
+ * @param {string} key The key of the property to assign.
692
+ * @param {*} value The value to assign.
693
+ */
694
+ function assignValue(object, key, value) {
695
+ var objValue = object[key];
696
+ if (!(hasOwnProperty$6.call(object, key) && eq(objValue, value)) ||
697
+ (value === undefined && !(key in object))) {
698
+ baseAssignValue(object, key, value);
699
+ }
700
+ }
701
+
702
+ /* Built-in method references for those with the same name as other `lodash` methods. */
703
+ var nativeMax = Math.max;
704
+
705
+ /**
706
+ * A specialized version of `baseRest` which transforms the rest array.
707
+ *
708
+ * @private
709
+ * @param {Function} func The function to apply a rest parameter to.
710
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
711
+ * @param {Function} transform The rest array transform.
712
+ * @returns {Function} Returns the new function.
713
+ */
714
+ function overRest(func, start, transform) {
715
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
716
+ return function() {
717
+ var args = arguments,
718
+ index = -1,
719
+ length = nativeMax(args.length - start, 0),
720
+ array = Array(length);
721
+
722
+ while (++index < length) {
723
+ array[index] = args[start + index];
724
+ }
725
+ index = -1;
726
+ var otherArgs = Array(start + 1);
727
+ while (++index < start) {
728
+ otherArgs[index] = args[index];
729
+ }
730
+ otherArgs[start] = transform(array);
731
+ return apply(func, this, otherArgs);
732
+ };
733
+ }
734
+
735
+ /** Used as references for various `Number` constants. */
736
+ var MAX_SAFE_INTEGER = 9007199254740991;
737
+
738
+ /**
739
+ * Checks if `value` is a valid array-like length.
740
+ *
741
+ * **Note:** This method is loosely based on
742
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
743
+ *
744
+ * @static
745
+ * @memberOf _
746
+ * @since 4.0.0
747
+ * @category Lang
748
+ * @param {*} value The value to check.
749
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
750
+ * @example
751
+ *
752
+ * _.isLength(3);
753
+ * // => true
754
+ *
755
+ * _.isLength(Number.MIN_VALUE);
756
+ * // => false
757
+ *
758
+ * _.isLength(Infinity);
759
+ * // => false
760
+ *
761
+ * _.isLength('3');
762
+ * // => false
763
+ */
764
+ function isLength(value) {
765
+ return typeof value == 'number' &&
766
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
767
+ }
768
+
769
+ /**
770
+ * Checks if `value` is array-like. A value is considered array-like if it's
771
+ * not a function and has a `value.length` that's an integer greater than or
772
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
773
+ *
774
+ * @static
775
+ * @memberOf _
776
+ * @since 4.0.0
777
+ * @category Lang
778
+ * @param {*} value The value to check.
779
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
780
+ * @example
781
+ *
782
+ * _.isArrayLike([1, 2, 3]);
783
+ * // => true
784
+ *
785
+ * _.isArrayLike(document.body.children);
786
+ * // => true
787
+ *
788
+ * _.isArrayLike('abc');
789
+ * // => true
790
+ *
791
+ * _.isArrayLike(_.noop);
792
+ * // => false
793
+ */
794
+ function isArrayLike(value) {
795
+ return value != null && isLength(value.length) && !isFunction(value);
796
+ }
797
+
798
+ /** Used for built-in method references. */
799
+ var objectProto$7 = Object.prototype;
800
+
801
+ /**
802
+ * Checks if `value` is likely a prototype object.
803
+ *
804
+ * @private
805
+ * @param {*} value The value to check.
806
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
807
+ */
808
+ function isPrototype(value) {
809
+ var Ctor = value && value.constructor,
810
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
811
+
812
+ return value === proto;
813
+ }
814
+
815
+ /**
816
+ * The base implementation of `_.times` without support for iteratee shorthands
817
+ * or max array length checks.
818
+ *
819
+ * @private
820
+ * @param {number} n The number of times to invoke `iteratee`.
821
+ * @param {Function} iteratee The function invoked per iteration.
822
+ * @returns {Array} Returns the array of results.
823
+ */
824
+ function baseTimes(n, iteratee) {
825
+ var index = -1,
826
+ result = Array(n);
827
+
828
+ while (++index < n) {
829
+ result[index] = iteratee(index);
830
+ }
831
+ return result;
832
+ }
833
+
834
+ /** `Object#toString` result references. */
835
+ var argsTag$2 = '[object Arguments]';
836
+
837
+ /**
838
+ * The base implementation of `_.isArguments`.
839
+ *
840
+ * @private
841
+ * @param {*} value The value to check.
842
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
843
+ */
844
+ function baseIsArguments(value) {
845
+ return isObjectLike(value) && baseGetTag(value) == argsTag$2;
846
+ }
847
+
848
+ /** Used for built-in method references. */
849
+ var objectProto$6 = Object.prototype;
850
+
851
+ /** Used to check objects for own properties. */
852
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
853
+
854
+ /** Built-in value references. */
855
+ var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
856
+
857
+ /**
858
+ * Checks if `value` is likely an `arguments` object.
859
+ *
860
+ * @static
861
+ * @memberOf _
862
+ * @since 0.1.0
863
+ * @category Lang
864
+ * @param {*} value The value to check.
865
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
866
+ * else `false`.
867
+ * @example
868
+ *
869
+ * _.isArguments(function() { return arguments; }());
870
+ * // => true
871
+ *
872
+ * _.isArguments([1, 2, 3]);
873
+ * // => false
874
+ */
875
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
876
+ return isObjectLike(value) && hasOwnProperty$5.call(value, 'callee') &&
877
+ !propertyIsEnumerable$1.call(value, 'callee');
878
+ };
879
+
880
+ /**
881
+ * This method returns `false`.
882
+ *
883
+ * @static
884
+ * @memberOf _
885
+ * @since 4.13.0
886
+ * @category Util
887
+ * @returns {boolean} Returns `false`.
888
+ * @example
889
+ *
890
+ * _.times(2, _.stubFalse);
891
+ * // => [false, false]
892
+ */
893
+ function stubFalse() {
894
+ return false;
895
+ }
896
+
897
+ /** Detect free variable `exports`. */
898
+ var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
899
+
900
+ /** Detect free variable `module`. */
901
+ var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
902
+
903
+ /** Detect the popular CommonJS extension `module.exports`. */
904
+ var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
905
+
906
+ /** Built-in value references. */
907
+ var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
908
+
909
+ /* Built-in method references for those with the same name as other `lodash` methods. */
910
+ var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
911
+
912
+ /**
913
+ * Checks if `value` is a buffer.
914
+ *
915
+ * @static
916
+ * @memberOf _
917
+ * @since 4.3.0
918
+ * @category Lang
919
+ * @param {*} value The value to check.
920
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
921
+ * @example
922
+ *
923
+ * _.isBuffer(new Buffer(2));
924
+ * // => true
925
+ *
926
+ * _.isBuffer(new Uint8Array(2));
927
+ * // => false
928
+ */
929
+ var isBuffer = nativeIsBuffer || stubFalse;
930
+
931
+ /** `Object#toString` result references. */
932
+ var argsTag$1 = '[object Arguments]',
933
+ arrayTag$1 = '[object Array]',
934
+ boolTag$2 = '[object Boolean]',
935
+ dateTag$2 = '[object Date]',
936
+ errorTag$1 = '[object Error]',
937
+ funcTag$1 = '[object Function]',
938
+ mapTag$4 = '[object Map]',
939
+ numberTag$2 = '[object Number]',
940
+ objectTag$2 = '[object Object]',
941
+ regexpTag$2 = '[object RegExp]',
942
+ setTag$4 = '[object Set]',
943
+ stringTag$2 = '[object String]',
944
+ weakMapTag$2 = '[object WeakMap]';
945
+
946
+ var arrayBufferTag$2 = '[object ArrayBuffer]',
947
+ dataViewTag$3 = '[object DataView]',
948
+ float32Tag$2 = '[object Float32Array]',
949
+ float64Tag$2 = '[object Float64Array]',
950
+ int8Tag$2 = '[object Int8Array]',
951
+ int16Tag$2 = '[object Int16Array]',
952
+ int32Tag$2 = '[object Int32Array]',
953
+ uint8Tag$2 = '[object Uint8Array]',
954
+ uint8ClampedTag$2 = '[object Uint8ClampedArray]',
955
+ uint16Tag$2 = '[object Uint16Array]',
956
+ uint32Tag$2 = '[object Uint32Array]';
957
+
958
+ /** Used to identify `toStringTag` values of typed arrays. */
959
+ var typedArrayTags = {};
960
+ typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] =
961
+ typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] =
962
+ typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] =
963
+ typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] =
964
+ typedArrayTags[uint32Tag$2] = true;
965
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
966
+ typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] =
967
+ typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] =
968
+ typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] =
969
+ typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] =
970
+ typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$2] =
971
+ typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] =
972
+ typedArrayTags[weakMapTag$2] = false;
973
+
974
+ /**
975
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
976
+ *
977
+ * @private
978
+ * @param {*} value The value to check.
979
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
980
+ */
981
+ function baseIsTypedArray(value) {
982
+ return isObjectLike(value) &&
983
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
984
+ }
985
+
986
+ /**
987
+ * The base implementation of `_.unary` without support for storing metadata.
988
+ *
989
+ * @private
990
+ * @param {Function} func The function to cap arguments for.
991
+ * @returns {Function} Returns the new capped function.
992
+ */
993
+ function baseUnary(func) {
994
+ return function(value) {
995
+ return func(value);
996
+ };
997
+ }
998
+
999
+ /** Detect free variable `exports`. */
1000
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1001
+
1002
+ /** Detect free variable `module`. */
1003
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1004
+
1005
+ /** Detect the popular CommonJS extension `module.exports`. */
1006
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1007
+
1008
+ /** Detect free variable `process` from Node.js. */
1009
+ var freeProcess = moduleExports$1 && freeGlobal.process;
1010
+
1011
+ /** Used to access faster Node.js helpers. */
1012
+ var nodeUtil = (function() {
1013
+ try {
1014
+ // Use `util.types` for Node.js 10+.
1015
+ var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
1016
+
1017
+ if (types) {
1018
+ return types;
1019
+ }
1020
+
1021
+ // Legacy `process.binding('util')` for Node.js < 10.
1022
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
1023
+ } catch (e) {}
1024
+ }());
1025
+
1026
+ /* Node.js helper references. */
1027
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1028
+
1029
+ /**
1030
+ * Checks if `value` is classified as a typed array.
1031
+ *
1032
+ * @static
1033
+ * @memberOf _
1034
+ * @since 3.0.0
1035
+ * @category Lang
1036
+ * @param {*} value The value to check.
1037
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1038
+ * @example
1039
+ *
1040
+ * _.isTypedArray(new Uint8Array);
1041
+ * // => true
1042
+ *
1043
+ * _.isTypedArray([]);
1044
+ * // => false
1045
+ */
1046
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1047
+
1048
+ /** Used for built-in method references. */
1049
+ var objectProto$5 = Object.prototype;
1050
+
1051
+ /** Used to check objects for own properties. */
1052
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
1053
+
1054
+ /**
1055
+ * Creates an array of the enumerable property names of the array-like `value`.
1056
+ *
1057
+ * @private
1058
+ * @param {*} value The value to query.
1059
+ * @param {boolean} inherited Specify returning inherited property names.
1060
+ * @returns {Array} Returns the array of property names.
1061
+ */
1062
+ function arrayLikeKeys(value, inherited) {
1063
+ var isArr = isArray(value),
1064
+ isArg = !isArr && isArguments(value),
1065
+ isBuff = !isArr && !isArg && isBuffer(value),
1066
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1067
+ skipIndexes = isArr || isArg || isBuff || isType,
1068
+ result = skipIndexes ? baseTimes(value.length, String) : [],
1069
+ length = result.length;
1070
+
1071
+ for (var key in value) {
1072
+ if ((hasOwnProperty$4.call(value, key)) &&
1073
+ !(skipIndexes && (
1074
+ // Safari 9 has enumerable `arguments.length` in strict mode.
1075
+ key == 'length' ||
1076
+ // Node.js 0.10 has enumerable non-index properties on buffers.
1077
+ (isBuff && (key == 'offset' || key == 'parent')) ||
1078
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
1079
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1080
+ // Skip index properties.
1081
+ isIndex(key, length)
1082
+ ))) {
1083
+ result.push(key);
1084
+ }
1085
+ }
1086
+ return result;
1087
+ }
1088
+
1089
+ /**
1090
+ * Creates a unary function that invokes `func` with its argument transformed.
1091
+ *
1092
+ * @private
1093
+ * @param {Function} func The function to wrap.
1094
+ * @param {Function} transform The argument transform.
1095
+ * @returns {Function} Returns the new function.
1096
+ */
1097
+ function overArg(func, transform) {
1098
+ return function(arg) {
1099
+ return func(transform(arg));
1100
+ };
1101
+ }
1102
+
1103
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1104
+ var nativeKeys = overArg(Object.keys, Object);
1105
+
1106
+ /** Used for built-in method references. */
1107
+ var objectProto$4 = Object.prototype;
1108
+
1109
+ /** Used to check objects for own properties. */
1110
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
1111
+
1112
+ /**
1113
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1114
+ *
1115
+ * @private
1116
+ * @param {Object} object The object to query.
1117
+ * @returns {Array} Returns the array of property names.
1118
+ */
1119
+ function baseKeys(object) {
1120
+ if (!isPrototype(object)) {
1121
+ return nativeKeys(object);
1122
+ }
1123
+ var result = [];
1124
+ for (var key in Object(object)) {
1125
+ if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
1126
+ result.push(key);
1127
+ }
1128
+ }
1129
+ return result;
1130
+ }
1131
+
1132
+ /**
1133
+ * Creates an array of the own enumerable property names of `object`.
1134
+ *
1135
+ * **Note:** Non-object values are coerced to objects. See the
1136
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1137
+ * for more details.
1138
+ *
1139
+ * @static
1140
+ * @since 0.1.0
1141
+ * @memberOf _
1142
+ * @category Object
1143
+ * @param {Object} object The object to query.
1144
+ * @returns {Array} Returns the array of property names.
1145
+ * @example
1146
+ *
1147
+ * function Foo() {
1148
+ * this.a = 1;
1149
+ * this.b = 2;
1150
+ * }
1151
+ *
1152
+ * Foo.prototype.c = 3;
1153
+ *
1154
+ * _.keys(new Foo);
1155
+ * // => ['a', 'b'] (iteration order is not guaranteed)
1156
+ *
1157
+ * _.keys('hi');
1158
+ * // => ['0', '1']
1159
+ */
1160
+ function keys(object) {
1161
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1162
+ }
1163
+
1164
+ /** Used to match property names within property paths. */
1165
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
1166
+ reIsPlainProp = /^\w*$/;
1167
+
1168
+ /**
1169
+ * Checks if `value` is a property name and not a property path.
1170
+ *
1171
+ * @private
1172
+ * @param {*} value The value to check.
1173
+ * @param {Object} [object] The object to query keys on.
1174
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
1175
+ */
1176
+ function isKey(value, object) {
1177
+ if (isArray(value)) {
1178
+ return false;
1179
+ }
1180
+ var type = typeof value;
1181
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
1182
+ value == null || isSymbol(value)) {
1183
+ return true;
1184
+ }
1185
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
1186
+ (object != null && value in Object(object));
1187
+ }
1188
+
1189
+ /* Built-in method references that are verified to be native. */
1190
+ var nativeCreate = getNative(Object, 'create');
1191
+
1192
+ /**
1193
+ * Removes all key-value entries from the hash.
1194
+ *
1195
+ * @private
1196
+ * @name clear
1197
+ * @memberOf Hash
1198
+ */
1199
+ function hashClear() {
1200
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
1201
+ this.size = 0;
1202
+ }
1203
+
1204
+ /**
1205
+ * Removes `key` and its value from the hash.
1206
+ *
1207
+ * @private
1208
+ * @name delete
1209
+ * @memberOf Hash
1210
+ * @param {Object} hash The hash to modify.
1211
+ * @param {string} key The key of the value to remove.
1212
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1213
+ */
1214
+ function hashDelete(key) {
1215
+ var result = this.has(key) && delete this.__data__[key];
1216
+ this.size -= result ? 1 : 0;
1217
+ return result;
1218
+ }
1219
+
1220
+ /** Used to stand-in for `undefined` hash values. */
1221
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1222
+
1223
+ /** Used for built-in method references. */
1224
+ var objectProto$3 = Object.prototype;
1225
+
1226
+ /** Used to check objects for own properties. */
1227
+ var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
1228
+
1229
+ /**
1230
+ * Gets the hash value for `key`.
1231
+ *
1232
+ * @private
1233
+ * @name get
1234
+ * @memberOf Hash
1235
+ * @param {string} key The key of the value to get.
1236
+ * @returns {*} Returns the entry value.
1237
+ */
1238
+ function hashGet(key) {
1239
+ var data = this.__data__;
1240
+ if (nativeCreate) {
1241
+ var result = data[key];
1242
+ return result === HASH_UNDEFINED$1 ? undefined : result;
1243
+ }
1244
+ return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
1245
+ }
1246
+
1247
+ /** Used for built-in method references. */
1248
+ var objectProto$2 = Object.prototype;
1249
+
1250
+ /** Used to check objects for own properties. */
1251
+ var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
1252
+
1253
+ /**
1254
+ * Checks if a hash value for `key` exists.
1255
+ *
1256
+ * @private
1257
+ * @name has
1258
+ * @memberOf Hash
1259
+ * @param {string} key The key of the entry to check.
1260
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1261
+ */
1262
+ function hashHas(key) {
1263
+ var data = this.__data__;
1264
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key);
1265
+ }
1266
+
1267
+ /** Used to stand-in for `undefined` hash values. */
1268
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1269
+
1270
+ /**
1271
+ * Sets the hash `key` to `value`.
1272
+ *
1273
+ * @private
1274
+ * @name set
1275
+ * @memberOf Hash
1276
+ * @param {string} key The key of the value to set.
1277
+ * @param {*} value The value to set.
1278
+ * @returns {Object} Returns the hash instance.
1279
+ */
1280
+ function hashSet(key, value) {
1281
+ var data = this.__data__;
1282
+ this.size += this.has(key) ? 0 : 1;
1283
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1284
+ return this;
1285
+ }
1286
+
1287
+ /**
1288
+ * Creates a hash object.
1289
+ *
1290
+ * @private
1291
+ * @constructor
1292
+ * @param {Array} [entries] The key-value pairs to cache.
1293
+ */
1294
+ function Hash(entries) {
1295
+ var index = -1,
1296
+ length = entries == null ? 0 : entries.length;
1297
+
1298
+ this.clear();
1299
+ while (++index < length) {
1300
+ var entry = entries[index];
1301
+ this.set(entry[0], entry[1]);
1302
+ }
1303
+ }
1304
+
1305
+ // Add methods to `Hash`.
1306
+ Hash.prototype.clear = hashClear;
1307
+ Hash.prototype['delete'] = hashDelete;
1308
+ Hash.prototype.get = hashGet;
1309
+ Hash.prototype.has = hashHas;
1310
+ Hash.prototype.set = hashSet;
1311
+
1312
+ /**
1313
+ * Removes all key-value entries from the list cache.
1314
+ *
1315
+ * @private
1316
+ * @name clear
1317
+ * @memberOf ListCache
1318
+ */
1319
+ function listCacheClear() {
1320
+ this.__data__ = [];
1321
+ this.size = 0;
1322
+ }
1323
+
1324
+ /**
1325
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
1326
+ *
1327
+ * @private
1328
+ * @param {Array} array The array to inspect.
1329
+ * @param {*} key The key to search for.
1330
+ * @returns {number} Returns the index of the matched value, else `-1`.
1331
+ */
1332
+ function assocIndexOf(array, key) {
1333
+ var length = array.length;
1334
+ while (length--) {
1335
+ if (eq(array[length][0], key)) {
1336
+ return length;
1337
+ }
1338
+ }
1339
+ return -1;
1340
+ }
1341
+
1342
+ /** Used for built-in method references. */
1343
+ var arrayProto = Array.prototype;
1344
+
1345
+ /** Built-in value references. */
1346
+ var splice = arrayProto.splice;
1347
+
1348
+ /**
1349
+ * Removes `key` and its value from the list cache.
1350
+ *
1351
+ * @private
1352
+ * @name delete
1353
+ * @memberOf ListCache
1354
+ * @param {string} key The key of the value to remove.
1355
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1356
+ */
1357
+ function listCacheDelete(key) {
1358
+ var data = this.__data__,
1359
+ index = assocIndexOf(data, key);
1360
+
1361
+ if (index < 0) {
1362
+ return false;
1363
+ }
1364
+ var lastIndex = data.length - 1;
1365
+ if (index == lastIndex) {
1366
+ data.pop();
1367
+ } else {
1368
+ splice.call(data, index, 1);
1369
+ }
1370
+ --this.size;
1371
+ return true;
1372
+ }
1373
+
1374
+ /**
1375
+ * Gets the list cache value for `key`.
1376
+ *
1377
+ * @private
1378
+ * @name get
1379
+ * @memberOf ListCache
1380
+ * @param {string} key The key of the value to get.
1381
+ * @returns {*} Returns the entry value.
1382
+ */
1383
+ function listCacheGet(key) {
1384
+ var data = this.__data__,
1385
+ index = assocIndexOf(data, key);
1386
+
1387
+ return index < 0 ? undefined : data[index][1];
1388
+ }
1389
+
1390
+ /**
1391
+ * Checks if a list cache value for `key` exists.
1392
+ *
1393
+ * @private
1394
+ * @name has
1395
+ * @memberOf ListCache
1396
+ * @param {string} key The key of the entry to check.
1397
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1398
+ */
1399
+ function listCacheHas(key) {
1400
+ return assocIndexOf(this.__data__, key) > -1;
1401
+ }
1402
+
1403
+ /**
1404
+ * Sets the list cache `key` to `value`.
1405
+ *
1406
+ * @private
1407
+ * @name set
1408
+ * @memberOf ListCache
1409
+ * @param {string} key The key of the value to set.
1410
+ * @param {*} value The value to set.
1411
+ * @returns {Object} Returns the list cache instance.
1412
+ */
1413
+ function listCacheSet(key, value) {
1414
+ var data = this.__data__,
1415
+ index = assocIndexOf(data, key);
1416
+
1417
+ if (index < 0) {
1418
+ ++this.size;
1419
+ data.push([key, value]);
1420
+ } else {
1421
+ data[index][1] = value;
1422
+ }
1423
+ return this;
1424
+ }
1425
+
1426
+ /**
1427
+ * Creates an list cache object.
1428
+ *
1429
+ * @private
1430
+ * @constructor
1431
+ * @param {Array} [entries] The key-value pairs to cache.
1432
+ */
1433
+ function ListCache(entries) {
1434
+ var index = -1,
1435
+ length = entries == null ? 0 : entries.length;
1436
+
1437
+ this.clear();
1438
+ while (++index < length) {
1439
+ var entry = entries[index];
1440
+ this.set(entry[0], entry[1]);
1441
+ }
1442
+ }
1443
+
1444
+ // Add methods to `ListCache`.
1445
+ ListCache.prototype.clear = listCacheClear;
1446
+ ListCache.prototype['delete'] = listCacheDelete;
1447
+ ListCache.prototype.get = listCacheGet;
1448
+ ListCache.prototype.has = listCacheHas;
1449
+ ListCache.prototype.set = listCacheSet;
1450
+
1451
+ /* Built-in method references that are verified to be native. */
1452
+ var Map$1 = getNative(root, 'Map');
1453
+
1454
+ /**
1455
+ * Removes all key-value entries from the map.
1456
+ *
1457
+ * @private
1458
+ * @name clear
1459
+ * @memberOf MapCache
1460
+ */
1461
+ function mapCacheClear() {
1462
+ this.size = 0;
1463
+ this.__data__ = {
1464
+ 'hash': new Hash,
1465
+ 'map': new (Map$1 || ListCache),
1466
+ 'string': new Hash
1467
+ };
1468
+ }
1469
+
1470
+ /**
1471
+ * Checks if `value` is suitable for use as unique object key.
1472
+ *
1473
+ * @private
1474
+ * @param {*} value The value to check.
1475
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1476
+ */
1477
+ function isKeyable(value) {
1478
+ var type = typeof value;
1479
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1480
+ ? (value !== '__proto__')
1481
+ : (value === null);
1482
+ }
1483
+
1484
+ /**
1485
+ * Gets the data for `map`.
1486
+ *
1487
+ * @private
1488
+ * @param {Object} map The map to query.
1489
+ * @param {string} key The reference key.
1490
+ * @returns {*} Returns the map data.
1491
+ */
1492
+ function getMapData(map, key) {
1493
+ var data = map.__data__;
1494
+ return isKeyable(key)
1495
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1496
+ : data.map;
1497
+ }
1498
+
1499
+ /**
1500
+ * Removes `key` and its value from the map.
1501
+ *
1502
+ * @private
1503
+ * @name delete
1504
+ * @memberOf MapCache
1505
+ * @param {string} key The key of the value to remove.
1506
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1507
+ */
1508
+ function mapCacheDelete(key) {
1509
+ var result = getMapData(this, key)['delete'](key);
1510
+ this.size -= result ? 1 : 0;
1511
+ return result;
1512
+ }
1513
+
1514
+ /**
1515
+ * Gets the map value for `key`.
1516
+ *
1517
+ * @private
1518
+ * @name get
1519
+ * @memberOf MapCache
1520
+ * @param {string} key The key of the value to get.
1521
+ * @returns {*} Returns the entry value.
1522
+ */
1523
+ function mapCacheGet(key) {
1524
+ return getMapData(this, key).get(key);
1525
+ }
1526
+
1527
+ /**
1528
+ * Checks if a map value for `key` exists.
1529
+ *
1530
+ * @private
1531
+ * @name has
1532
+ * @memberOf MapCache
1533
+ * @param {string} key The key of the entry to check.
1534
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1535
+ */
1536
+ function mapCacheHas(key) {
1537
+ return getMapData(this, key).has(key);
1538
+ }
1539
+
1540
+ /**
1541
+ * Sets the map `key` to `value`.
1542
+ *
1543
+ * @private
1544
+ * @name set
1545
+ * @memberOf MapCache
1546
+ * @param {string} key The key of the value to set.
1547
+ * @param {*} value The value to set.
1548
+ * @returns {Object} Returns the map cache instance.
1549
+ */
1550
+ function mapCacheSet(key, value) {
1551
+ var data = getMapData(this, key),
1552
+ size = data.size;
1553
+
1554
+ data.set(key, value);
1555
+ this.size += data.size == size ? 0 : 1;
1556
+ return this;
1557
+ }
1558
+
1559
+ /**
1560
+ * Creates a map cache object to store key-value pairs.
1561
+ *
1562
+ * @private
1563
+ * @constructor
1564
+ * @param {Array} [entries] The key-value pairs to cache.
1565
+ */
1566
+ function MapCache(entries) {
1567
+ var index = -1,
1568
+ length = entries == null ? 0 : entries.length;
1569
+
1570
+ this.clear();
1571
+ while (++index < length) {
1572
+ var entry = entries[index];
1573
+ this.set(entry[0], entry[1]);
1574
+ }
1575
+ }
1576
+
1577
+ // Add methods to `MapCache`.
1578
+ MapCache.prototype.clear = mapCacheClear;
1579
+ MapCache.prototype['delete'] = mapCacheDelete;
1580
+ MapCache.prototype.get = mapCacheGet;
1581
+ MapCache.prototype.has = mapCacheHas;
1582
+ MapCache.prototype.set = mapCacheSet;
1583
+
1584
+ /** Error message constants. */
1585
+ var FUNC_ERROR_TEXT = 'Expected a function';
1586
+
1587
+ /**
1588
+ * Creates a function that memoizes the result of `func`. If `resolver` is
1589
+ * provided, it determines the cache key for storing the result based on the
1590
+ * arguments provided to the memoized function. By default, the first argument
1591
+ * provided to the memoized function is used as the map cache key. The `func`
1592
+ * is invoked with the `this` binding of the memoized function.
1593
+ *
1594
+ * **Note:** The cache is exposed as the `cache` property on the memoized
1595
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
1596
+ * constructor with one whose instances implement the
1597
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
1598
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
1599
+ *
1600
+ * @static
1601
+ * @memberOf _
1602
+ * @since 0.1.0
1603
+ * @category Function
1604
+ * @param {Function} func The function to have its output memoized.
1605
+ * @param {Function} [resolver] The function to resolve the cache key.
1606
+ * @returns {Function} Returns the new memoized function.
1607
+ * @example
1608
+ *
1609
+ * var object = { 'a': 1, 'b': 2 };
1610
+ * var other = { 'c': 3, 'd': 4 };
1611
+ *
1612
+ * var values = _.memoize(_.values);
1613
+ * values(object);
1614
+ * // => [1, 2]
1615
+ *
1616
+ * values(other);
1617
+ * // => [3, 4]
1618
+ *
1619
+ * object.a = 2;
1620
+ * values(object);
1621
+ * // => [1, 2]
1622
+ *
1623
+ * // Modify the result cache.
1624
+ * values.cache.set(object, ['a', 'b']);
1625
+ * values(object);
1626
+ * // => ['a', 'b']
1627
+ *
1628
+ * // Replace `_.memoize.Cache`.
1629
+ * _.memoize.Cache = WeakMap;
1630
+ */
1631
+ function memoize(func, resolver) {
1632
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
1633
+ throw new TypeError(FUNC_ERROR_TEXT);
1634
+ }
1635
+ var memoized = function() {
1636
+ var args = arguments,
1637
+ key = resolver ? resolver.apply(this, args) : args[0],
1638
+ cache = memoized.cache;
1639
+
1640
+ if (cache.has(key)) {
1641
+ return cache.get(key);
1642
+ }
1643
+ var result = func.apply(this, args);
1644
+ memoized.cache = cache.set(key, result) || cache;
1645
+ return result;
1646
+ };
1647
+ memoized.cache = new (memoize.Cache || MapCache);
1648
+ return memoized;
1649
+ }
1650
+
1651
+ // Expose `MapCache`.
1652
+ memoize.Cache = MapCache;
1653
+
1654
+ /** Used as the maximum memoize cache size. */
1655
+ var MAX_MEMOIZE_SIZE = 500;
1656
+
1657
+ /**
1658
+ * A specialized version of `_.memoize` which clears the memoized function's
1659
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
1660
+ *
1661
+ * @private
1662
+ * @param {Function} func The function to have its output memoized.
1663
+ * @returns {Function} Returns the new memoized function.
1664
+ */
1665
+ function memoizeCapped(func) {
1666
+ var result = memoize(func, function(key) {
1667
+ if (cache.size === MAX_MEMOIZE_SIZE) {
1668
+ cache.clear();
1669
+ }
1670
+ return key;
1671
+ });
1672
+
1673
+ var cache = result.cache;
1674
+ return result;
1675
+ }
1676
+
1677
+ /** Used to match property names within property paths. */
1678
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1679
+
1680
+ /** Used to match backslashes in property paths. */
1681
+ var reEscapeChar = /\\(\\)?/g;
1682
+
1683
+ /**
1684
+ * Converts `string` to a property path array.
1685
+ *
1686
+ * @private
1687
+ * @param {string} string The string to convert.
1688
+ * @returns {Array} Returns the property path array.
1689
+ */
1690
+ var stringToPath = memoizeCapped(function(string) {
1691
+ var result = [];
1692
+ if (string.charCodeAt(0) === 46 /* . */) {
1693
+ result.push('');
1694
+ }
1695
+ string.replace(rePropName, function(match, number, quote, subString) {
1696
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
1697
+ });
1698
+ return result;
1699
+ });
1700
+
1701
+ /**
1702
+ * Converts `value` to a string. An empty string is returned for `null`
1703
+ * and `undefined` values. The sign of `-0` is preserved.
1704
+ *
1705
+ * @static
1706
+ * @memberOf _
1707
+ * @since 4.0.0
1708
+ * @category Lang
1709
+ * @param {*} value The value to convert.
1710
+ * @returns {string} Returns the converted string.
1711
+ * @example
1712
+ *
1713
+ * _.toString(null);
1714
+ * // => ''
1715
+ *
1716
+ * _.toString(-0);
1717
+ * // => '-0'
1718
+ *
1719
+ * _.toString([1, 2, 3]);
1720
+ * // => '1,2,3'
1721
+ */
1722
+ function toString(value) {
1723
+ return value == null ? '' : baseToString(value);
1724
+ }
1725
+
1726
+ /**
1727
+ * Casts `value` to a path array if it's not one.
1728
+ *
1729
+ * @private
1730
+ * @param {*} value The value to inspect.
1731
+ * @param {Object} [object] The object to query keys on.
1732
+ * @returns {Array} Returns the cast property path array.
1733
+ */
1734
+ function castPath(value, object) {
1735
+ if (isArray(value)) {
1736
+ return value;
1737
+ }
1738
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
1739
+ }
1740
+
1741
+ /**
1742
+ * Converts `value` to a string key if it's not a string or symbol.
1743
+ *
1744
+ * @private
1745
+ * @param {*} value The value to inspect.
1746
+ * @returns {string|symbol} Returns the key.
1747
+ */
1748
+ function toKey(value) {
1749
+ if (typeof value == 'string' || isSymbol(value)) {
1750
+ return value;
1751
+ }
1752
+ var result = (value + '');
1753
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
1754
+ }
1755
+
1756
+ /**
1757
+ * The base implementation of `_.get` without support for default values.
1758
+ *
1759
+ * @private
1760
+ * @param {Object} object The object to query.
1761
+ * @param {Array|string} path The path of the property to get.
1762
+ * @returns {*} Returns the resolved value.
1763
+ */
1764
+ function baseGet(object, path) {
1765
+ path = castPath(path, object);
1766
+
1767
+ var index = 0,
1768
+ length = path.length;
1769
+
1770
+ while (object != null && index < length) {
1771
+ object = object[toKey(path[index++])];
1772
+ }
1773
+ return (index && index == length) ? object : undefined;
1774
+ }
1775
+
1776
+ /**
1777
+ * Appends the elements of `values` to `array`.
1778
+ *
1779
+ * @private
1780
+ * @param {Array} array The array to modify.
1781
+ * @param {Array} values The values to append.
1782
+ * @returns {Array} Returns `array`.
1783
+ */
1784
+ function arrayPush(array, values) {
1785
+ var index = -1,
1786
+ length = values.length,
1787
+ offset = array.length;
1788
+
1789
+ while (++index < length) {
1790
+ array[offset + index] = values[index];
1791
+ }
1792
+ return array;
1793
+ }
1794
+
1795
+ /** Built-in value references. */
1796
+ var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
1797
+
1798
+ /**
1799
+ * Checks if `value` is a flattenable `arguments` object or array.
1800
+ *
1801
+ * @private
1802
+ * @param {*} value The value to check.
1803
+ * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1804
+ */
1805
+ function isFlattenable(value) {
1806
+ return isArray(value) || isArguments(value) ||
1807
+ !!(spreadableSymbol && value && value[spreadableSymbol]);
1808
+ }
1809
+
1810
+ /**
1811
+ * The base implementation of `_.flatten` with support for restricting flattening.
1812
+ *
1813
+ * @private
1814
+ * @param {Array} array The array to flatten.
1815
+ * @param {number} depth The maximum recursion depth.
1816
+ * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
1817
+ * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
1818
+ * @param {Array} [result=[]] The initial result value.
1819
+ * @returns {Array} Returns the new flattened array.
1820
+ */
1821
+ function baseFlatten(array, depth, predicate, isStrict, result) {
1822
+ var index = -1,
1823
+ length = array.length;
1824
+
1825
+ predicate || (predicate = isFlattenable);
1826
+ result || (result = []);
1827
+
1828
+ while (++index < length) {
1829
+ var value = array[index];
1830
+ if (predicate(value)) {
1831
+ {
1832
+ arrayPush(result, value);
1833
+ }
1834
+ } else {
1835
+ result[result.length] = value;
1836
+ }
1837
+ }
1838
+ return result;
1839
+ }
1840
+
1841
+ /**
1842
+ * Flattens `array` a single level deep.
1843
+ *
1844
+ * @static
1845
+ * @memberOf _
1846
+ * @since 0.1.0
1847
+ * @category Array
1848
+ * @param {Array} array The array to flatten.
1849
+ * @returns {Array} Returns the new flattened array.
1850
+ * @example
1851
+ *
1852
+ * _.flatten([1, [2, [3, [4]], 5]]);
1853
+ * // => [1, 2, [3, [4]], 5]
1854
+ */
1855
+ function flatten(array) {
1856
+ var length = array == null ? 0 : array.length;
1857
+ return length ? baseFlatten(array) : [];
1858
+ }
1859
+
1860
+ /**
1861
+ * A specialized version of `baseRest` which flattens the rest array.
1862
+ *
1863
+ * @private
1864
+ * @param {Function} func The function to apply a rest parameter to.
1865
+ * @returns {Function} Returns the new function.
1866
+ */
1867
+ function flatRest(func) {
1868
+ return setToString(overRest(func, undefined, flatten), func + '');
1869
+ }
1870
+
1871
+ /** Built-in value references. */
1872
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
1873
+
1874
+ /**
1875
+ * The base implementation of `_.slice` without an iteratee call guard.
1876
+ *
1877
+ * @private
1878
+ * @param {Array} array The array to slice.
1879
+ * @param {number} [start=0] The start position.
1880
+ * @param {number} [end=array.length] The end position.
1881
+ * @returns {Array} Returns the slice of `array`.
1882
+ */
1883
+ function baseSlice(array, start, end) {
1884
+ var index = -1,
1885
+ length = array.length;
1886
+
1887
+ if (start < 0) {
1888
+ start = -start > length ? 0 : (length + start);
1889
+ }
1890
+ end = end > length ? length : end;
1891
+ if (end < 0) {
1892
+ end += length;
1893
+ }
1894
+ length = start > end ? 0 : ((end - start) >>> 0);
1895
+ start >>>= 0;
1896
+
1897
+ var result = Array(length);
1898
+ while (++index < length) {
1899
+ result[index] = array[index + start];
1900
+ }
1901
+ return result;
1902
+ }
1903
+
1904
+ /**
1905
+ * Casts `array` to a slice if it's needed.
1906
+ *
1907
+ * @private
1908
+ * @param {Array} array The array to inspect.
1909
+ * @param {number} start The start position.
1910
+ * @param {number} [end=array.length] The end position.
1911
+ * @returns {Array} Returns the cast slice.
1912
+ */
1913
+ function castSlice(array, start, end) {
1914
+ var length = array.length;
1915
+ end = end === undefined ? length : end;
1916
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
1917
+ }
1918
+
1919
+ /** Used to compose unicode character classes. */
1920
+ var rsAstralRange$2 = '\\ud800-\\udfff',
1921
+ rsComboMarksRange$3 = '\\u0300-\\u036f',
1922
+ reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f',
1923
+ rsComboSymbolsRange$3 = '\\u20d0-\\u20ff',
1924
+ rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3,
1925
+ rsVarRange$2 = '\\ufe0e\\ufe0f';
1926
+
1927
+ /** Used to compose unicode capture groups. */
1928
+ var rsZWJ$2 = '\\u200d';
1929
+
1930
+ /** 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/). */
1931
+ var reHasUnicode = RegExp('[' + rsZWJ$2 + rsAstralRange$2 + rsComboRange$3 + rsVarRange$2 + ']');
1932
+
1933
+ /**
1934
+ * Checks if `string` contains Unicode symbols.
1935
+ *
1936
+ * @private
1937
+ * @param {string} string The string to inspect.
1938
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
1939
+ */
1940
+ function hasUnicode(string) {
1941
+ return reHasUnicode.test(string);
1942
+ }
1943
+
1944
+ /**
1945
+ * Converts an ASCII `string` to an array.
1946
+ *
1947
+ * @private
1948
+ * @param {string} string The string to convert.
1949
+ * @returns {Array} Returns the converted array.
1950
+ */
1951
+ function asciiToArray(string) {
1952
+ return string.split('');
1953
+ }
1954
+
1955
+ /** Used to compose unicode character classes. */
1956
+ var rsAstralRange$1 = '\\ud800-\\udfff',
1957
+ rsComboMarksRange$2 = '\\u0300-\\u036f',
1958
+ reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f',
1959
+ rsComboSymbolsRange$2 = '\\u20d0-\\u20ff',
1960
+ rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2,
1961
+ rsVarRange$1 = '\\ufe0e\\ufe0f';
1962
+
1963
+ /** Used to compose unicode capture groups. */
1964
+ var rsAstral = '[' + rsAstralRange$1 + ']',
1965
+ rsCombo$2 = '[' + rsComboRange$2 + ']',
1966
+ rsFitz$1 = '\\ud83c[\\udffb-\\udfff]',
1967
+ rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')',
1968
+ rsNonAstral$1 = '[^' + rsAstralRange$1 + ']',
1969
+ rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}',
1970
+ rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]',
1971
+ rsZWJ$1 = '\\u200d';
1972
+
1973
+ /** Used to compose unicode regexes. */
1974
+ var reOptMod$1 = rsModifier$1 + '?',
1975
+ rsOptVar$1 = '[' + rsVarRange$1 + ']?',
1976
+ rsOptJoin$1 = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*',
1977
+ rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1,
1978
+ rsSymbol = '(?:' + [rsNonAstral$1 + rsCombo$2 + '?', rsCombo$2, rsRegional$1, rsSurrPair$1, rsAstral].join('|') + ')';
1979
+
1980
+ /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
1981
+ var reUnicode = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol + rsSeq$1, 'g');
1982
+
1983
+ /**
1984
+ * Converts a Unicode `string` to an array.
1985
+ *
1986
+ * @private
1987
+ * @param {string} string The string to convert.
1988
+ * @returns {Array} Returns the converted array.
1989
+ */
1990
+ function unicodeToArray(string) {
1991
+ return string.match(reUnicode) || [];
1992
+ }
1993
+
1994
+ /**
1995
+ * Converts `string` to an array.
1996
+ *
1997
+ * @private
1998
+ * @param {string} string The string to convert.
1999
+ * @returns {Array} Returns the converted array.
2000
+ */
2001
+ function stringToArray(string) {
2002
+ return hasUnicode(string)
2003
+ ? unicodeToArray(string)
2004
+ : asciiToArray(string);
2005
+ }
2006
+
2007
+ /**
2008
+ * Creates a function like `_.lowerFirst`.
2009
+ *
2010
+ * @private
2011
+ * @param {string} methodName The name of the `String` case method to use.
2012
+ * @returns {Function} Returns the new case function.
2013
+ */
2014
+ function createCaseFirst(methodName) {
2015
+ return function(string) {
2016
+ string = toString(string);
2017
+
2018
+ var strSymbols = hasUnicode(string)
2019
+ ? stringToArray(string)
2020
+ : undefined;
2021
+
2022
+ var chr = strSymbols
2023
+ ? strSymbols[0]
2024
+ : string.charAt(0);
2025
+
2026
+ var trailing = strSymbols
2027
+ ? castSlice(strSymbols, 1).join('')
2028
+ : string.slice(1);
2029
+
2030
+ return chr[methodName]() + trailing;
2031
+ };
2032
+ }
2033
+
2034
+ /**
2035
+ * Converts the first character of `string` to upper case.
2036
+ *
2037
+ * @static
2038
+ * @memberOf _
2039
+ * @since 4.0.0
2040
+ * @category String
2041
+ * @param {string} [string=''] The string to convert.
2042
+ * @returns {string} Returns the converted string.
2043
+ * @example
2044
+ *
2045
+ * _.upperFirst('fred');
2046
+ * // => 'Fred'
2047
+ *
2048
+ * _.upperFirst('FRED');
2049
+ * // => 'FRED'
2050
+ */
2051
+ var upperFirst = createCaseFirst('toUpperCase');
2052
+
2053
+ /**
2054
+ * Converts the first character of `string` to upper case and the remaining
2055
+ * to lower case.
2056
+ *
2057
+ * @static
2058
+ * @memberOf _
2059
+ * @since 3.0.0
2060
+ * @category String
2061
+ * @param {string} [string=''] The string to capitalize.
2062
+ * @returns {string} Returns the capitalized string.
2063
+ * @example
2064
+ *
2065
+ * _.capitalize('FRED');
2066
+ * // => 'Fred'
2067
+ */
2068
+ function capitalize(string) {
2069
+ return upperFirst(toString(string).toLowerCase());
2070
+ }
2071
+
2072
+ /**
2073
+ * A specialized version of `_.reduce` for arrays without support for
2074
+ * iteratee shorthands.
2075
+ *
2076
+ * @private
2077
+ * @param {Array} [array] The array to iterate over.
2078
+ * @param {Function} iteratee The function invoked per iteration.
2079
+ * @param {*} [accumulator] The initial value.
2080
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
2081
+ * the initial value.
2082
+ * @returns {*} Returns the accumulated value.
2083
+ */
2084
+ function arrayReduce(array, iteratee, accumulator, initAccum) {
2085
+ var index = -1,
2086
+ length = array == null ? 0 : array.length;
2087
+ while (++index < length) {
2088
+ accumulator = iteratee(accumulator, array[index], index, array);
2089
+ }
2090
+ return accumulator;
2091
+ }
2092
+
2093
+ /**
2094
+ * The base implementation of `_.propertyOf` without support for deep paths.
2095
+ *
2096
+ * @private
2097
+ * @param {Object} object The object to query.
2098
+ * @returns {Function} Returns the new accessor function.
2099
+ */
2100
+ function basePropertyOf(object) {
2101
+ return function(key) {
2102
+ return object == null ? undefined : object[key];
2103
+ };
2104
+ }
2105
+
2106
+ /** Used to map Latin Unicode letters to basic Latin letters. */
2107
+ var deburredLetters = {
2108
+ // Latin-1 Supplement block.
2109
+ '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
2110
+ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
2111
+ '\xc7': 'C', '\xe7': 'c',
2112
+ '\xd0': 'D', '\xf0': 'd',
2113
+ '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
2114
+ '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
2115
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
2116
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
2117
+ '\xd1': 'N', '\xf1': 'n',
2118
+ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
2119
+ '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
2120
+ '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
2121
+ '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
2122
+ '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
2123
+ '\xc6': 'Ae', '\xe6': 'ae',
2124
+ '\xde': 'Th', '\xfe': 'th',
2125
+ '\xdf': 'ss',
2126
+ // Latin Extended-A block.
2127
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
2128
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
2129
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
2130
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
2131
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
2132
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
2133
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
2134
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
2135
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
2136
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
2137
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
2138
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
2139
+ '\u0134': 'J', '\u0135': 'j',
2140
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
2141
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
2142
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
2143
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
2144
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
2145
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
2146
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
2147
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
2148
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
2149
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
2150
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
2151
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
2152
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
2153
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
2154
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
2155
+ '\u0174': 'W', '\u0175': 'w',
2156
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
2157
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
2158
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
2159
+ '\u0132': 'IJ', '\u0133': 'ij',
2160
+ '\u0152': 'Oe', '\u0153': 'oe',
2161
+ '\u0149': "'n", '\u017f': 's'
2162
+ };
2163
+
2164
+ /**
2165
+ * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
2166
+ * letters to basic Latin letters.
2167
+ *
2168
+ * @private
2169
+ * @param {string} letter The matched letter to deburr.
2170
+ * @returns {string} Returns the deburred letter.
2171
+ */
2172
+ var deburrLetter = basePropertyOf(deburredLetters);
2173
+
2174
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
2175
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
2176
+
2177
+ /** Used to compose unicode character classes. */
2178
+ var rsComboMarksRange$1 = '\\u0300-\\u036f',
2179
+ reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
2180
+ rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
2181
+ rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
2182
+
2183
+ /** Used to compose unicode capture groups. */
2184
+ var rsCombo$1 = '[' + rsComboRange$1 + ']';
2185
+
2186
+ /**
2187
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
2188
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
2189
+ */
2190
+ var reComboMark = RegExp(rsCombo$1, 'g');
2191
+
2192
+ /**
2193
+ * Deburrs `string` by converting
2194
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
2195
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
2196
+ * letters to basic Latin letters and removing
2197
+ * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
2198
+ *
2199
+ * @static
2200
+ * @memberOf _
2201
+ * @since 3.0.0
2202
+ * @category String
2203
+ * @param {string} [string=''] The string to deburr.
2204
+ * @returns {string} Returns the deburred string.
2205
+ * @example
2206
+ *
2207
+ * _.deburr('déjà vu');
2208
+ * // => 'deja vu'
2209
+ */
2210
+ function deburr(string) {
2211
+ string = toString(string);
2212
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
2213
+ }
2214
+
2215
+ /** Used to match words composed of alphanumeric characters. */
2216
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
2217
+
2218
+ /**
2219
+ * Splits an ASCII `string` into an array of its words.
2220
+ *
2221
+ * @private
2222
+ * @param {string} The string to inspect.
2223
+ * @returns {Array} Returns the words of `string`.
2224
+ */
2225
+ function asciiWords(string) {
2226
+ return string.match(reAsciiWord) || [];
2227
+ }
2228
+
2229
+ /** Used to detect strings that need a more robust regexp to match words. */
2230
+ 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 ]/;
2231
+
2232
+ /**
2233
+ * Checks if `string` contains a word composed of Unicode symbols.
2234
+ *
2235
+ * @private
2236
+ * @param {string} string The string to inspect.
2237
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
2238
+ */
2239
+ function hasUnicodeWord(string) {
2240
+ return reHasUnicodeWord.test(string);
2241
+ }
2242
+
2243
+ /** Used to compose unicode character classes. */
2244
+ var rsAstralRange = '\\ud800-\\udfff',
2245
+ rsComboMarksRange = '\\u0300-\\u036f',
2246
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
2247
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
2248
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
2249
+ rsDingbatRange = '\\u2700-\\u27bf',
2250
+ rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
2251
+ rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
2252
+ rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
2253
+ rsPunctuationRange = '\\u2000-\\u206f',
2254
+ 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',
2255
+ rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
2256
+ rsVarRange = '\\ufe0e\\ufe0f',
2257
+ rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
2258
+
2259
+ /** Used to compose unicode capture groups. */
2260
+ var rsApos$1 = "['\u2019]",
2261
+ rsBreak = '[' + rsBreakRange + ']',
2262
+ rsCombo = '[' + rsComboRange + ']',
2263
+ rsDigits = '\\d+',
2264
+ rsDingbat = '[' + rsDingbatRange + ']',
2265
+ rsLower = '[' + rsLowerRange + ']',
2266
+ rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
2267
+ rsFitz = '\\ud83c[\\udffb-\\udfff]',
2268
+ rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
2269
+ rsNonAstral = '[^' + rsAstralRange + ']',
2270
+ rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
2271
+ rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
2272
+ rsUpper = '[' + rsUpperRange + ']',
2273
+ rsZWJ = '\\u200d';
2274
+
2275
+ /** Used to compose unicode regexes. */
2276
+ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
2277
+ rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
2278
+ rsOptContrLower = '(?:' + rsApos$1 + '(?:d|ll|m|re|s|t|ve))?',
2279
+ rsOptContrUpper = '(?:' + rsApos$1 + '(?:D|LL|M|RE|S|T|VE))?',
2280
+ reOptMod = rsModifier + '?',
2281
+ rsOptVar = '[' + rsVarRange + ']?',
2282
+ rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
2283
+ rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
2284
+ rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
2285
+ rsSeq = rsOptVar + reOptMod + rsOptJoin,
2286
+ rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
2287
+
2288
+ /** Used to match complex or compound words. */
2289
+ var reUnicodeWord = RegExp([
2290
+ rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
2291
+ rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
2292
+ rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
2293
+ rsUpper + '+' + rsOptContrUpper,
2294
+ rsOrdUpper,
2295
+ rsOrdLower,
2296
+ rsDigits,
2297
+ rsEmoji
2298
+ ].join('|'), 'g');
2299
+
2300
+ /**
2301
+ * Splits a Unicode `string` into an array of its words.
2302
+ *
2303
+ * @private
2304
+ * @param {string} The string to inspect.
2305
+ * @returns {Array} Returns the words of `string`.
2306
+ */
2307
+ function unicodeWords(string) {
2308
+ return string.match(reUnicodeWord) || [];
2309
+ }
2310
+
2311
+ /**
2312
+ * Splits `string` into an array of its words.
2313
+ *
2314
+ * @static
2315
+ * @memberOf _
2316
+ * @since 3.0.0
2317
+ * @category String
2318
+ * @param {string} [string=''] The string to inspect.
2319
+ * @param {RegExp|string} [pattern] The pattern to match words.
2320
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2321
+ * @returns {Array} Returns the words of `string`.
2322
+ * @example
2323
+ *
2324
+ * _.words('fred, barney, & pebbles');
2325
+ * // => ['fred', 'barney', 'pebbles']
2326
+ *
2327
+ * _.words('fred, barney, & pebbles', /[^, ]+/g);
2328
+ * // => ['fred', 'barney', '&', 'pebbles']
2329
+ */
2330
+ function words(string, pattern, guard) {
2331
+ string = toString(string);
2332
+ pattern = pattern;
2333
+
2334
+ if (pattern === undefined) {
2335
+ return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
2336
+ }
2337
+ return string.match(pattern) || [];
2338
+ }
2339
+
2340
+ /** Used to compose unicode capture groups. */
2341
+ var rsApos = "['\u2019]";
2342
+
2343
+ /** Used to match apostrophes. */
2344
+ var reApos = RegExp(rsApos, 'g');
2345
+
2346
+ /**
2347
+ * Creates a function like `_.camelCase`.
2348
+ *
2349
+ * @private
2350
+ * @param {Function} callback The function to combine each word.
2351
+ * @returns {Function} Returns the new compounder function.
2352
+ */
2353
+ function createCompounder(callback) {
2354
+ return function(string) {
2355
+ return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
2356
+ };
2357
+ }
2358
+
2359
+ /**
2360
+ * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
2361
+ *
2362
+ * @static
2363
+ * @memberOf _
2364
+ * @since 3.0.0
2365
+ * @category String
2366
+ * @param {string} [string=''] The string to convert.
2367
+ * @returns {string} Returns the camel cased string.
2368
+ * @example
2369
+ *
2370
+ * _.camelCase('Foo Bar');
2371
+ * // => 'fooBar'
2372
+ *
2373
+ * _.camelCase('--foo-bar--');
2374
+ * // => 'fooBar'
2375
+ *
2376
+ * _.camelCase('__FOO_BAR__');
2377
+ * // => 'fooBar'
2378
+ */
2379
+ var camelCase = createCompounder(function(result, word, index) {
2380
+ word = word.toLowerCase();
2381
+ return result + (index ? capitalize(word) : word);
2382
+ });
2383
+
2384
+ /**
2385
+ * Removes all key-value entries from the stack.
2386
+ *
2387
+ * @private
2388
+ * @name clear
2389
+ * @memberOf Stack
2390
+ */
2391
+ function stackClear() {
2392
+ this.__data__ = new ListCache;
2393
+ this.size = 0;
2394
+ }
2395
+
2396
+ /**
2397
+ * Removes `key` and its value from the stack.
2398
+ *
2399
+ * @private
2400
+ * @name delete
2401
+ * @memberOf Stack
2402
+ * @param {string} key The key of the value to remove.
2403
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2404
+ */
2405
+ function stackDelete(key) {
2406
+ var data = this.__data__,
2407
+ result = data['delete'](key);
2408
+
2409
+ this.size = data.size;
2410
+ return result;
2411
+ }
2412
+
2413
+ /**
2414
+ * Gets the stack value for `key`.
2415
+ *
2416
+ * @private
2417
+ * @name get
2418
+ * @memberOf Stack
2419
+ * @param {string} key The key of the value to get.
2420
+ * @returns {*} Returns the entry value.
2421
+ */
2422
+ function stackGet(key) {
2423
+ return this.__data__.get(key);
2424
+ }
2425
+
2426
+ /**
2427
+ * Checks if a stack value for `key` exists.
2428
+ *
2429
+ * @private
2430
+ * @name has
2431
+ * @memberOf Stack
2432
+ * @param {string} key The key of the entry to check.
2433
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2434
+ */
2435
+ function stackHas(key) {
2436
+ return this.__data__.has(key);
2437
+ }
2438
+
2439
+ /** Used as the size to enable large array optimizations. */
2440
+ var LARGE_ARRAY_SIZE = 200;
2441
+
2442
+ /**
2443
+ * Sets the stack `key` to `value`.
2444
+ *
2445
+ * @private
2446
+ * @name set
2447
+ * @memberOf Stack
2448
+ * @param {string} key The key of the value to set.
2449
+ * @param {*} value The value to set.
2450
+ * @returns {Object} Returns the stack cache instance.
2451
+ */
2452
+ function stackSet(key, value) {
2453
+ var data = this.__data__;
2454
+ if (data instanceof ListCache) {
2455
+ var pairs = data.__data__;
2456
+ if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2457
+ pairs.push([key, value]);
2458
+ this.size = ++data.size;
2459
+ return this;
2460
+ }
2461
+ data = this.__data__ = new MapCache(pairs);
2462
+ }
2463
+ data.set(key, value);
2464
+ this.size = data.size;
2465
+ return this;
2466
+ }
2467
+
2468
+ /**
2469
+ * Creates a stack cache object to store key-value pairs.
2470
+ *
2471
+ * @private
2472
+ * @constructor
2473
+ * @param {Array} [entries] The key-value pairs to cache.
2474
+ */
2475
+ function Stack(entries) {
2476
+ var data = this.__data__ = new ListCache(entries);
2477
+ this.size = data.size;
2478
+ }
2479
+
2480
+ // Add methods to `Stack`.
2481
+ Stack.prototype.clear = stackClear;
2482
+ Stack.prototype['delete'] = stackDelete;
2483
+ Stack.prototype.get = stackGet;
2484
+ Stack.prototype.has = stackHas;
2485
+ Stack.prototype.set = stackSet;
2486
+
2487
+ /** Detect free variable `exports`. */
2488
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
2489
+
2490
+ /** Detect free variable `module`. */
2491
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
2492
+
2493
+ /** Detect the popular CommonJS extension `module.exports`. */
2494
+ var moduleExports = freeModule && freeModule.exports === freeExports;
2495
+
2496
+ /** Built-in value references. */
2497
+ var Buffer = moduleExports ? root.Buffer : undefined;
2498
+ Buffer ? Buffer.allocUnsafe : undefined;
2499
+
2500
+ /**
2501
+ * Creates a clone of `buffer`.
2502
+ *
2503
+ * @private
2504
+ * @param {Buffer} buffer The buffer to clone.
2505
+ * @param {boolean} [isDeep] Specify a deep clone.
2506
+ * @returns {Buffer} Returns the cloned buffer.
2507
+ */
2508
+ function cloneBuffer(buffer, isDeep) {
2509
+ {
2510
+ return buffer.slice();
2511
+ }
2512
+ }
2513
+
2514
+ /**
2515
+ * A specialized version of `_.filter` for arrays without support for
2516
+ * iteratee shorthands.
2517
+ *
2518
+ * @private
2519
+ * @param {Array} [array] The array to iterate over.
2520
+ * @param {Function} predicate The function invoked per iteration.
2521
+ * @returns {Array} Returns the new filtered array.
2522
+ */
2523
+ function arrayFilter(array, predicate) {
2524
+ var index = -1,
2525
+ length = array == null ? 0 : array.length,
2526
+ resIndex = 0,
2527
+ result = [];
2528
+
2529
+ while (++index < length) {
2530
+ var value = array[index];
2531
+ if (predicate(value, index, array)) {
2532
+ result[resIndex++] = value;
2533
+ }
2534
+ }
2535
+ return result;
2536
+ }
2537
+
2538
+ /**
2539
+ * This method returns a new empty array.
2540
+ *
2541
+ * @static
2542
+ * @memberOf _
2543
+ * @since 4.13.0
2544
+ * @category Util
2545
+ * @returns {Array} Returns the new empty array.
2546
+ * @example
2547
+ *
2548
+ * var arrays = _.times(2, _.stubArray);
2549
+ *
2550
+ * console.log(arrays);
2551
+ * // => [[], []]
2552
+ *
2553
+ * console.log(arrays[0] === arrays[1]);
2554
+ * // => false
2555
+ */
2556
+ function stubArray() {
2557
+ return [];
2558
+ }
2559
+
2560
+ /** Used for built-in method references. */
2561
+ var objectProto$1 = Object.prototype;
2562
+
2563
+ /** Built-in value references. */
2564
+ var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
2565
+
2566
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2567
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
2568
+
2569
+ /**
2570
+ * Creates an array of the own enumerable symbols of `object`.
2571
+ *
2572
+ * @private
2573
+ * @param {Object} object The object to query.
2574
+ * @returns {Array} Returns the array of symbols.
2575
+ */
2576
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
2577
+ if (object == null) {
2578
+ return [];
2579
+ }
2580
+ object = Object(object);
2581
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
2582
+ return propertyIsEnumerable.call(object, symbol);
2583
+ });
2584
+ };
2585
+
2586
+ /**
2587
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
2588
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
2589
+ * symbols of `object`.
2590
+ *
2591
+ * @private
2592
+ * @param {Object} object The object to query.
2593
+ * @param {Function} keysFunc The function to get the keys of `object`.
2594
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
2595
+ * @returns {Array} Returns the array of property names and symbols.
2596
+ */
2597
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
2598
+ var result = keysFunc(object);
2599
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
2600
+ }
2601
+
2602
+ /**
2603
+ * Creates an array of own enumerable property names and symbols of `object`.
2604
+ *
2605
+ * @private
2606
+ * @param {Object} object The object to query.
2607
+ * @returns {Array} Returns the array of property names and symbols.
2608
+ */
2609
+ function getAllKeys(object) {
2610
+ return baseGetAllKeys(object, keys, getSymbols);
2611
+ }
2612
+
2613
+ /* Built-in method references that are verified to be native. */
2614
+ var DataView = getNative(root, 'DataView');
2615
+
2616
+ /* Built-in method references that are verified to be native. */
2617
+ var Promise$1 = getNative(root, 'Promise');
2618
+
2619
+ /* Built-in method references that are verified to be native. */
2620
+ var Set$1 = getNative(root, 'Set');
2621
+
2622
+ /** `Object#toString` result references. */
2623
+ var mapTag$3 = '[object Map]',
2624
+ objectTag$1 = '[object Object]',
2625
+ promiseTag = '[object Promise]',
2626
+ setTag$3 = '[object Set]',
2627
+ weakMapTag$1 = '[object WeakMap]';
2628
+
2629
+ var dataViewTag$2 = '[object DataView]';
2630
+
2631
+ /** Used to detect maps, sets, and weakmaps. */
2632
+ var dataViewCtorString = toSource(DataView),
2633
+ mapCtorString = toSource(Map$1),
2634
+ promiseCtorString = toSource(Promise$1),
2635
+ setCtorString = toSource(Set$1),
2636
+ weakMapCtorString = toSource(WeakMap);
2637
+
2638
+ /**
2639
+ * Gets the `toStringTag` of `value`.
2640
+ *
2641
+ * @private
2642
+ * @param {*} value The value to query.
2643
+ * @returns {string} Returns the `toStringTag`.
2644
+ */
2645
+ var getTag = baseGetTag;
2646
+
2647
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
2648
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$2) ||
2649
+ (Map$1 && getTag(new Map$1) != mapTag$3) ||
2650
+ (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
2651
+ (Set$1 && getTag(new Set$1) != setTag$3) ||
2652
+ (WeakMap && getTag(new WeakMap) != weakMapTag$1)) {
2653
+ getTag = function(value) {
2654
+ var result = baseGetTag(value),
2655
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
2656
+ ctorString = Ctor ? toSource(Ctor) : '';
2657
+
2658
+ if (ctorString) {
2659
+ switch (ctorString) {
2660
+ case dataViewCtorString: return dataViewTag$2;
2661
+ case mapCtorString: return mapTag$3;
2662
+ case promiseCtorString: return promiseTag;
2663
+ case setCtorString: return setTag$3;
2664
+ case weakMapCtorString: return weakMapTag$1;
2665
+ }
2666
+ }
2667
+ return result;
2668
+ };
2669
+ }
2670
+
2671
+ /** Used for built-in method references. */
2672
+ var objectProto = Object.prototype;
2673
+
2674
+ /** Used to check objects for own properties. */
2675
+ var hasOwnProperty = objectProto.hasOwnProperty;
2676
+
2677
+ /**
2678
+ * Initializes an array clone.
2679
+ *
2680
+ * @private
2681
+ * @param {Array} array The array to clone.
2682
+ * @returns {Array} Returns the initialized clone.
2683
+ */
2684
+ function initCloneArray(array) {
2685
+ var length = array.length,
2686
+ result = new array.constructor(length);
2687
+
2688
+ // Add properties assigned by `RegExp#exec`.
2689
+ if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
2690
+ result.index = array.index;
2691
+ result.input = array.input;
2692
+ }
2693
+ return result;
2694
+ }
2695
+
2696
+ /** Built-in value references. */
2697
+ var Uint8Array = root.Uint8Array;
2698
+
2699
+ /**
2700
+ * Creates a clone of `arrayBuffer`.
2701
+ *
2702
+ * @private
2703
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2704
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
2705
+ */
2706
+ function cloneArrayBuffer(arrayBuffer) {
2707
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2708
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2709
+ return result;
2710
+ }
2711
+
2712
+ /**
2713
+ * Creates a clone of `dataView`.
2714
+ *
2715
+ * @private
2716
+ * @param {Object} dataView The data view to clone.
2717
+ * @param {boolean} [isDeep] Specify a deep clone.
2718
+ * @returns {Object} Returns the cloned data view.
2719
+ */
2720
+ function cloneDataView(dataView, isDeep) {
2721
+ var buffer = cloneArrayBuffer(dataView.buffer) ;
2722
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2723
+ }
2724
+
2725
+ /** Used to match `RegExp` flags from their coerced string values. */
2726
+ var reFlags = /\w*$/;
2727
+
2728
+ /**
2729
+ * Creates a clone of `regexp`.
2730
+ *
2731
+ * @private
2732
+ * @param {Object} regexp The regexp to clone.
2733
+ * @returns {Object} Returns the cloned regexp.
2734
+ */
2735
+ function cloneRegExp(regexp) {
2736
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2737
+ result.lastIndex = regexp.lastIndex;
2738
+ return result;
2739
+ }
2740
+
2741
+ /** Used to convert symbols to primitives and strings. */
2742
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
2743
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
2744
+
2745
+ /**
2746
+ * Creates a clone of the `symbol` object.
2747
+ *
2748
+ * @private
2749
+ * @param {Object} symbol The symbol object to clone.
2750
+ * @returns {Object} Returns the cloned symbol object.
2751
+ */
2752
+ function cloneSymbol(symbol) {
2753
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2754
+ }
2755
+
2756
+ /**
2757
+ * Creates a clone of `typedArray`.
2758
+ *
2759
+ * @private
2760
+ * @param {Object} typedArray The typed array to clone.
2761
+ * @param {boolean} [isDeep] Specify a deep clone.
2762
+ * @returns {Object} Returns the cloned typed array.
2763
+ */
2764
+ function cloneTypedArray(typedArray, isDeep) {
2765
+ var buffer = cloneArrayBuffer(typedArray.buffer) ;
2766
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2767
+ }
2768
+
2769
+ /** `Object#toString` result references. */
2770
+ var boolTag$1 = '[object Boolean]',
2771
+ dateTag$1 = '[object Date]',
2772
+ mapTag$2 = '[object Map]',
2773
+ numberTag$1 = '[object Number]',
2774
+ regexpTag$1 = '[object RegExp]',
2775
+ setTag$2 = '[object Set]',
2776
+ stringTag$1 = '[object String]',
2777
+ symbolTag$1 = '[object Symbol]';
2778
+
2779
+ var arrayBufferTag$1 = '[object ArrayBuffer]',
2780
+ dataViewTag$1 = '[object DataView]',
2781
+ float32Tag$1 = '[object Float32Array]',
2782
+ float64Tag$1 = '[object Float64Array]',
2783
+ int8Tag$1 = '[object Int8Array]',
2784
+ int16Tag$1 = '[object Int16Array]',
2785
+ int32Tag$1 = '[object Int32Array]',
2786
+ uint8Tag$1 = '[object Uint8Array]',
2787
+ uint8ClampedTag$1 = '[object Uint8ClampedArray]',
2788
+ uint16Tag$1 = '[object Uint16Array]',
2789
+ uint32Tag$1 = '[object Uint32Array]';
2790
+
2791
+ /**
2792
+ * Initializes an object clone based on its `toStringTag`.
2793
+ *
2794
+ * **Note:** This function only supports cloning values with tags of
2795
+ * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
2796
+ *
2797
+ * @private
2798
+ * @param {Object} object The object to clone.
2799
+ * @param {string} tag The `toStringTag` of the object to clone.
2800
+ * @param {boolean} [isDeep] Specify a deep clone.
2801
+ * @returns {Object} Returns the initialized clone.
2802
+ */
2803
+ function initCloneByTag(object, tag, isDeep) {
2804
+ var Ctor = object.constructor;
2805
+ switch (tag) {
2806
+ case arrayBufferTag$1:
2807
+ return cloneArrayBuffer(object);
2808
+
2809
+ case boolTag$1:
2810
+ case dateTag$1:
2811
+ return new Ctor(+object);
2812
+
2813
+ case dataViewTag$1:
2814
+ return cloneDataView(object);
2815
+
2816
+ case float32Tag$1: case float64Tag$1:
2817
+ case int8Tag$1: case int16Tag$1: case int32Tag$1:
2818
+ case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
2819
+ return cloneTypedArray(object);
2820
+
2821
+ case mapTag$2:
2822
+ return new Ctor;
2823
+
2824
+ case numberTag$1:
2825
+ case stringTag$1:
2826
+ return new Ctor(object);
2827
+
2828
+ case regexpTag$1:
2829
+ return cloneRegExp(object);
2830
+
2831
+ case setTag$2:
2832
+ return new Ctor;
2833
+
2834
+ case symbolTag$1:
2835
+ return cloneSymbol(object);
2836
+ }
2837
+ }
2838
+
2839
+ /**
2840
+ * Initializes an object clone.
2841
+ *
2842
+ * @private
2843
+ * @param {Object} object The object to clone.
2844
+ * @returns {Object} Returns the initialized clone.
2845
+ */
2846
+ function initCloneObject(object) {
2847
+ return (typeof object.constructor == 'function' && !isPrototype(object))
2848
+ ? baseCreate(getPrototype(object))
2849
+ : {};
2850
+ }
2851
+
2852
+ /** `Object#toString` result references. */
2853
+ var mapTag$1 = '[object Map]';
2854
+
2855
+ /**
2856
+ * The base implementation of `_.isMap` without Node.js optimizations.
2857
+ *
2858
+ * @private
2859
+ * @param {*} value The value to check.
2860
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
2861
+ */
2862
+ function baseIsMap(value) {
2863
+ return isObjectLike(value) && getTag(value) == mapTag$1;
2864
+ }
2865
+
2866
+ /* Node.js helper references. */
2867
+ var nodeIsMap = nodeUtil && nodeUtil.isMap;
2868
+
2869
+ /**
2870
+ * Checks if `value` is classified as a `Map` object.
2871
+ *
2872
+ * @static
2873
+ * @memberOf _
2874
+ * @since 4.3.0
2875
+ * @category Lang
2876
+ * @param {*} value The value to check.
2877
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
2878
+ * @example
2879
+ *
2880
+ * _.isMap(new Map);
2881
+ * // => true
2882
+ *
2883
+ * _.isMap(new WeakMap);
2884
+ * // => false
2885
+ */
2886
+ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
2887
+
2888
+ /** `Object#toString` result references. */
2889
+ var setTag$1 = '[object Set]';
2890
+
2891
+ /**
2892
+ * The base implementation of `_.isSet` without Node.js optimizations.
2893
+ *
2894
+ * @private
2895
+ * @param {*} value The value to check.
2896
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
2897
+ */
2898
+ function baseIsSet(value) {
2899
+ return isObjectLike(value) && getTag(value) == setTag$1;
2900
+ }
2901
+
2902
+ /* Node.js helper references. */
2903
+ var nodeIsSet = nodeUtil && nodeUtil.isSet;
2904
+
2905
+ /**
2906
+ * Checks if `value` is classified as a `Set` object.
2907
+ *
2908
+ * @static
2909
+ * @memberOf _
2910
+ * @since 4.3.0
2911
+ * @category Lang
2912
+ * @param {*} value The value to check.
2913
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
2914
+ * @example
2915
+ *
2916
+ * _.isSet(new Set);
2917
+ * // => true
2918
+ *
2919
+ * _.isSet(new WeakSet);
2920
+ * // => false
2921
+ */
2922
+ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
2923
+
2924
+ /** `Object#toString` result references. */
2925
+ var argsTag = '[object Arguments]',
2926
+ arrayTag = '[object Array]',
2927
+ boolTag = '[object Boolean]',
2928
+ dateTag = '[object Date]',
2929
+ errorTag = '[object Error]',
2930
+ funcTag = '[object Function]',
2931
+ genTag = '[object GeneratorFunction]',
2932
+ mapTag = '[object Map]',
2933
+ numberTag = '[object Number]',
2934
+ objectTag = '[object Object]',
2935
+ regexpTag = '[object RegExp]',
2936
+ setTag = '[object Set]',
2937
+ stringTag = '[object String]',
2938
+ symbolTag = '[object Symbol]',
2939
+ weakMapTag = '[object WeakMap]';
2940
+
2941
+ var arrayBufferTag = '[object ArrayBuffer]',
2942
+ dataViewTag = '[object DataView]',
2943
+ float32Tag = '[object Float32Array]',
2944
+ float64Tag = '[object Float64Array]',
2945
+ int8Tag = '[object Int8Array]',
2946
+ int16Tag = '[object Int16Array]',
2947
+ int32Tag = '[object Int32Array]',
2948
+ uint8Tag = '[object Uint8Array]',
2949
+ uint8ClampedTag = '[object Uint8ClampedArray]',
2950
+ uint16Tag = '[object Uint16Array]',
2951
+ uint32Tag = '[object Uint32Array]';
2952
+
2953
+ /** Used to identify `toStringTag` values supported by `_.clone`. */
2954
+ var cloneableTags = {};
2955
+ cloneableTags[argsTag] = cloneableTags[arrayTag] =
2956
+ cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
2957
+ cloneableTags[boolTag] = cloneableTags[dateTag] =
2958
+ cloneableTags[float32Tag] = cloneableTags[float64Tag] =
2959
+ cloneableTags[int8Tag] = cloneableTags[int16Tag] =
2960
+ cloneableTags[int32Tag] = cloneableTags[mapTag] =
2961
+ cloneableTags[numberTag] = cloneableTags[objectTag] =
2962
+ cloneableTags[regexpTag] = cloneableTags[setTag] =
2963
+ cloneableTags[stringTag] = cloneableTags[symbolTag] =
2964
+ cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
2965
+ cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
2966
+ cloneableTags[errorTag] = cloneableTags[funcTag] =
2967
+ cloneableTags[weakMapTag] = false;
2968
+
2969
+ /**
2970
+ * The base implementation of `_.clone` and `_.cloneDeep` which tracks
2971
+ * traversed objects.
2972
+ *
2973
+ * @private
2974
+ * @param {*} value The value to clone.
2975
+ * @param {boolean} bitmask The bitmask flags.
2976
+ * 1 - Deep clone
2977
+ * 2 - Flatten inherited properties
2978
+ * 4 - Clone symbols
2979
+ * @param {Function} [customizer] The function to customize cloning.
2980
+ * @param {string} [key] The key of `value`.
2981
+ * @param {Object} [object] The parent object of `value`.
2982
+ * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
2983
+ * @returns {*} Returns the cloned value.
2984
+ */
2985
+ function baseClone(value, bitmask, customizer, key, object, stack) {
2986
+ var result;
2987
+ if (result !== undefined) {
2988
+ return result;
2989
+ }
2990
+ if (!isObject(value)) {
2991
+ return value;
2992
+ }
2993
+ var isArr = isArray(value);
2994
+ if (isArr) {
2995
+ result = initCloneArray(value);
2996
+ } else {
2997
+ var tag = getTag(value),
2998
+ isFunc = tag == funcTag || tag == genTag;
2999
+
3000
+ if (isBuffer(value)) {
3001
+ return cloneBuffer(value);
3002
+ }
3003
+ if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
3004
+ result = (isFunc) ? {} : initCloneObject(value);
3005
+ } else {
3006
+ if (!cloneableTags[tag]) {
3007
+ return object ? value : {};
3008
+ }
3009
+ result = initCloneByTag(value, tag);
3010
+ }
3011
+ }
3012
+ // Check for circular references and return its corresponding clone.
3013
+ stack || (stack = new Stack);
3014
+ var stacked = stack.get(value);
3015
+ if (stacked) {
3016
+ return stacked;
3017
+ }
3018
+ stack.set(value, result);
3019
+
3020
+ if (isSet(value)) {
3021
+ value.forEach(function(subValue) {
3022
+ result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
3023
+ });
3024
+ } else if (isMap(value)) {
3025
+ value.forEach(function(subValue, key) {
3026
+ result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
3027
+ });
3028
+ }
3029
+
3030
+ var keysFunc = (getAllKeys)
3031
+ ;
3032
+
3033
+ var props = isArr ? undefined : keysFunc(value);
3034
+ arrayEach(props || value, function(subValue, key) {
3035
+ if (props) {
3036
+ key = subValue;
3037
+ subValue = value[key];
3038
+ }
3039
+ // Recursively populate clone (susceptible to call stack limits).
3040
+ assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
3041
+ });
3042
+ return result;
3043
+ }
3044
+
3045
+ /** Used to compose bitmasks for cloning. */
3046
+ var CLONE_DEEP_FLAG = 1,
3047
+ CLONE_SYMBOLS_FLAG = 4;
3048
+
3049
+ /**
3050
+ * This method is like `_.clone` except that it recursively clones `value`.
3051
+ *
3052
+ * @static
3053
+ * @memberOf _
3054
+ * @since 1.0.0
3055
+ * @category Lang
3056
+ * @param {*} value The value to recursively clone.
3057
+ * @returns {*} Returns the deep cloned value.
3058
+ * @see _.clone
3059
+ * @example
3060
+ *
3061
+ * var objects = [{ 'a': 1 }, { 'b': 2 }];
3062
+ *
3063
+ * var deep = _.cloneDeep(objects);
3064
+ * console.log(deep[0] === objects[0]);
3065
+ * // => false
3066
+ */
3067
+ function cloneDeep(value) {
3068
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
3069
+ }
3070
+
3071
+ /**
3072
+ * The base implementation of `_.hasIn` without support for deep paths.
3073
+ *
3074
+ * @private
3075
+ * @param {Object} [object] The object to query.
3076
+ * @param {Array|string} key The key to check.
3077
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
3078
+ */
3079
+ function baseHasIn(object, key) {
3080
+ return object != null && key in Object(object);
3081
+ }
3082
+
3083
+ /**
3084
+ * Checks if `path` exists on `object`.
3085
+ *
3086
+ * @private
3087
+ * @param {Object} object The object to query.
3088
+ * @param {Array|string} path The path to check.
3089
+ * @param {Function} hasFunc The function to check properties.
3090
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3091
+ */
3092
+ function hasPath(object, path, hasFunc) {
3093
+ path = castPath(path, object);
3094
+
3095
+ var index = -1,
3096
+ length = path.length,
3097
+ result = false;
3098
+
3099
+ while (++index < length) {
3100
+ var key = toKey(path[index]);
3101
+ if (!(result = object != null && hasFunc(object, key))) {
3102
+ break;
3103
+ }
3104
+ object = object[key];
3105
+ }
3106
+ if (result || ++index != length) {
3107
+ return result;
3108
+ }
3109
+ length = object == null ? 0 : object.length;
3110
+ return !!length && isLength(length) && isIndex(key, length) &&
3111
+ (isArray(object) || isArguments(object));
3112
+ }
3113
+
3114
+ /**
3115
+ * Checks if `path` is a direct or inherited property of `object`.
3116
+ *
3117
+ * @static
3118
+ * @memberOf _
3119
+ * @since 4.0.0
3120
+ * @category Object
3121
+ * @param {Object} object The object to query.
3122
+ * @param {Array|string} path The path to check.
3123
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3124
+ * @example
3125
+ *
3126
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
3127
+ *
3128
+ * _.hasIn(object, 'a');
3129
+ * // => true
3130
+ *
3131
+ * _.hasIn(object, 'a.b');
3132
+ * // => true
3133
+ *
3134
+ * _.hasIn(object, ['a', 'b']);
3135
+ * // => true
3136
+ *
3137
+ * _.hasIn(object, 'b');
3138
+ * // => false
3139
+ */
3140
+ function hasIn(object, path) {
3141
+ return object != null && hasPath(object, path, baseHasIn);
3142
+ }
3143
+
3144
+ /**
3145
+ * The base implementation of `_.set`.
3146
+ *
3147
+ * @private
3148
+ * @param {Object} object The object to modify.
3149
+ * @param {Array|string} path The path of the property to set.
3150
+ * @param {*} value The value to set.
3151
+ * @param {Function} [customizer] The function to customize path creation.
3152
+ * @returns {Object} Returns `object`.
3153
+ */
3154
+ function baseSet(object, path, value, customizer) {
3155
+ if (!isObject(object)) {
3156
+ return object;
3157
+ }
3158
+ path = castPath(path, object);
3159
+
3160
+ var index = -1,
3161
+ length = path.length,
3162
+ lastIndex = length - 1,
3163
+ nested = object;
3164
+
3165
+ while (nested != null && ++index < length) {
3166
+ var key = toKey(path[index]),
3167
+ newValue = value;
3168
+
3169
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
3170
+ return object;
3171
+ }
3172
+
3173
+ if (index != lastIndex) {
3174
+ var objValue = nested[key];
3175
+ newValue = undefined;
3176
+ if (newValue === undefined) {
3177
+ newValue = isObject(objValue)
3178
+ ? objValue
3179
+ : (isIndex(path[index + 1]) ? [] : {});
3180
+ }
3181
+ }
3182
+ assignValue(nested, key, newValue);
3183
+ nested = nested[key];
3184
+ }
3185
+ return object;
3186
+ }
3187
+
3188
+ /**
3189
+ * The base implementation of `_.pickBy` without support for iteratee shorthands.
3190
+ *
3191
+ * @private
3192
+ * @param {Object} object The source object.
3193
+ * @param {string[]} paths The property paths to pick.
3194
+ * @param {Function} predicate The function invoked per property.
3195
+ * @returns {Object} Returns the new object.
3196
+ */
3197
+ function basePickBy(object, paths, predicate) {
3198
+ var index = -1,
3199
+ length = paths.length,
3200
+ result = {};
3201
+
3202
+ while (++index < length) {
3203
+ var path = paths[index],
3204
+ value = baseGet(object, path);
3205
+
3206
+ if (predicate(value, path)) {
3207
+ baseSet(result, castPath(path, object), value);
3208
+ }
3209
+ }
3210
+ return result;
3211
+ }
3212
+
3213
+ /**
3214
+ * The base implementation of `_.pick` without support for individual
3215
+ * property identifiers.
3216
+ *
3217
+ * @private
3218
+ * @param {Object} object The source object.
3219
+ * @param {string[]} paths The property paths to pick.
3220
+ * @returns {Object} Returns the new object.
3221
+ */
3222
+ function basePick(object, paths) {
3223
+ return basePickBy(object, paths, function(value, path) {
3224
+ return hasIn(object, path);
3225
+ });
3226
+ }
3227
+
3228
+ /**
3229
+ * Creates an object composed of the picked `object` properties.
3230
+ *
3231
+ * @static
3232
+ * @since 0.1.0
3233
+ * @memberOf _
3234
+ * @category Object
3235
+ * @param {Object} object The source object.
3236
+ * @param {...(string|string[])} [paths] The property paths to pick.
3237
+ * @returns {Object} Returns the new object.
3238
+ * @example
3239
+ *
3240
+ * var object = { 'a': 1, 'b': '2', 'c': 3 };
3241
+ *
3242
+ * _.pick(object, ['a', 'c']);
3243
+ * // => { 'a': 1, 'c': 3 }
3244
+ */
3245
+ var pick = flatRest(function(object, paths) {
3246
+ return object == null ? {} : basePick(object, paths);
3247
+ });
3248
+
3249
+ /**
3250
+ * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
3251
+ * it's created. Arrays are created for missing index properties while objects
3252
+ * are created for all other missing properties. Use `_.setWith` to customize
3253
+ * `path` creation.
3254
+ *
3255
+ * **Note:** This method mutates `object`.
3256
+ *
3257
+ * @static
3258
+ * @memberOf _
3259
+ * @since 3.7.0
3260
+ * @category Object
3261
+ * @param {Object} object The object to modify.
3262
+ * @param {Array|string} path The path of the property to set.
3263
+ * @param {*} value The value to set.
3264
+ * @returns {Object} Returns `object`.
3265
+ * @example
3266
+ *
3267
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
3268
+ *
3269
+ * _.set(object, 'a[0].b.c', 4);
3270
+ * console.log(object.a[0].b.c);
3271
+ * // => 4
3272
+ *
3273
+ * _.set(object, ['x', '0', 'y', 'z'], 5);
3274
+ * console.log(object.x[0].y.z);
3275
+ * // => 5
3276
+ */
3277
+ function set(object, path, value) {
3278
+ return object == null ? object : baseSet(object, path, value);
3279
+ }
3280
+
3281
+ /**
3282
+ * Every GraphQL operation a test triggered that no handler answered, collected across
3283
+ * the run so a new suite shows all the handlers it still needs in one go.
3284
+ */
3285
+ const missingOperations = new Set();
3286
+ /** Records an operation no handler answered, so it shows up in the run's summary of missing handlers. */
3287
+ function captureMissingOperation(name) {
3288
+ missingOperations.add(name);
3289
+ }
3290
+ /** Forgets the recorded missing operations, so one spec's gaps do not bleed into the next. */
3291
+ function clearMissingOperations() {
3292
+ missingOperations.clear();
3293
+ }
3294
+ /**
3295
+ * Request tracking utilities for frontend integration tests.
3296
+ * Allows tests to verify which endpoints were called and with what parameters.
3297
+ */
3298
+ const capturedRequests = {};
3299
+ /** Drops every captured request so the next spec's assertions start from zero. Belongs in the global `afterEach`. */
3300
+ function resetCapturedRequests() {
3301
+ Object.keys(capturedRequests).forEach((key) => delete capturedRequests[key]);
3302
+ }
3303
+ /**
3304
+ * Records that a request reached the mock server, with its URL, params and GraphQL
3305
+ * variables, so a spec can later assert what the app asked for and how often. The
3306
+ * handlers call this. Specs read the results through `snapshotRequests`,
3307
+ * `expectGraphQLCalls` and `lastRequestVariables`.
3308
+ */
3309
+ function captureRequest(name, request, variables) {
3310
+ if (!capturedRequests[name]) {
3311
+ capturedRequests[name] = [];
3312
+ }
3313
+ const url = new URL(request.url);
3314
+ capturedRequests[name].push({
3315
+ url: url.toString(),
3316
+ params: Object.fromEntries(url.searchParams),
3317
+ method: request.method,
3318
+ variables,
3319
+ timestamp: Date.now(),
3320
+ });
3321
+ }
3322
+ /**
3323
+ * Returns what the app sent in its latest call to an operation, for asserting on
3324
+ * the request rather than the response. Two filters can return the same rows, so
3325
+ * checking the rendered result cannot prove which one the app applied. The
3326
+ * variables can.
3327
+ *
3328
+ * @throws {Error} When the operation was never called, or was not a GraphQL
3329
+ * operation and so has no variables.
3330
+ */
3331
+ function lastRequestVariables(operationName) {
3332
+ const calls = capturedRequests[operationName];
3333
+ if (!calls?.length) {
3334
+ const called = Object.keys(capturedRequests).sort().join(', ') || 'none';
3335
+ throw new Error(`No request captured for "${operationName}", so there are no variables to assert on. Operations called: ${called}.`);
3336
+ }
3337
+ const { variables } = calls[calls.length - 1];
3338
+ if (variables === undefined) {
3339
+ throw new Error(`"${operationName}" was captured without variables. Only GraphQL operations record them.`);
3340
+ }
3341
+ return variables;
3342
+ }
3343
+ /** Counts only the calls made between two snapshots, per operation. Operations with no new calls are left out. */
3344
+ function getSnapshotRequestsDiff(baselineRequests, allRequests) {
3345
+ return Object.keys(allRequests).reduce((acc, operationName) => {
3346
+ const baseCount = baselineRequests[operationName] || 0;
3347
+ const currentCount = allRequests[operationName] || 0;
3348
+ const delta = currentCount - baseCount;
3349
+ if (delta > 0) {
3350
+ acc[operationName] = delta;
3351
+ }
3352
+ return acc;
3353
+ }, {});
3354
+ }
3355
+ /** Whether an operation name matches any entry of the forbid list, by exact name or regex. */
3356
+ function isForbiddenOperation(op, forbiddenOperations) {
3357
+ return forbiddenOperations.some((pattern) => {
3358
+ if (pattern instanceof RegExp) {
3359
+ return pattern.test(op);
3360
+ }
3361
+ return op === pattern;
3362
+ });
3363
+ }
3364
+ /**
3365
+ * Captures how many times each operation has been called so far. Take one before
3366
+ * an action and hand it to `expectGraphQLCalls` afterwards to assert on only the
3367
+ * calls that action caused.
3368
+ *
3369
+ * @example
3370
+ * const baselineRequests = snapshotRequests();
3371
+ * // baselineRequests = { getWorkItemsFullEE: 1, projectLabels: 1 }
3372
+ */
3373
+ function snapshotRequests() {
3374
+ return Object.keys(capturedRequests).reduce((acc, operationName) => {
3375
+ acc[operationName] = capturedRequests[operationName].length;
3376
+ return acc;
3377
+ }, {});
3378
+ }
3379
+ /**
3380
+ * Asserts which operations an action triggered since a snapshot: everything in
3381
+ * `expect` must have fired and nothing matching `forbid` may have. Its main use is
3382
+ * proving a mutation updated the Apollo cache in place instead of refetching the
3383
+ * lists around it.
3384
+ *
3385
+ * @throws {Error} Listing everything that fired, when an expected operation is
3386
+ * missing or a forbidden one ran.
3387
+ *
3388
+ * @example
3389
+ * const baselineRequests = snapshotRequests();
3390
+ * clickUpdateButton();
3391
+ * await waitFor(() => {
3392
+ * expectGraphQLCalls(baselineRequests, {
3393
+ * expect: ['workItemUpdate'],
3394
+ * forbid: ['getWorkItemsFullEE', 'projectLabels'],
3395
+ * });
3396
+ * });
3397
+ */
3398
+ function expectGraphQLCalls(baselineRequests, { expect: expectedOperations, forbid: forbiddenOperations }) {
3399
+ const newCalls = getSnapshotRequestsDiff(baselineRequests, snapshotRequests());
3400
+ const actualOperations = Object.keys(newCalls);
3401
+ // First, check that expected operations actually fired
3402
+ const missing = expectedOperations.filter((op) => !actualOperations.includes(op));
3403
+ if (missing.length > 0) {
3404
+ throw new Error(`Expected operations did not fire: [${missing.join(', ')}]\n` +
3405
+ `All operations that fired: [${actualOperations.join(', ')}]`);
3406
+ }
3407
+ // Then, check if any forbidden operations fired (cache misses)
3408
+ const violated = actualOperations.filter((op) => isForbiddenOperation(op, forbiddenOperations));
3409
+ if (violated.length > 0) {
3410
+ // Build a counts map of everything that fired, and the same map with the
3411
+ // forbidden operations removed (what we expected to fire). Comparing them
3412
+ // with a Jest matcher renders a readable red/green diff that highlights the
3413
+ // unexpected calls, instead of dumping the full config and call list.
3414
+ const actualCalls = { ...newCalls };
3415
+ const expectedCalls = Object.fromEntries(Object.entries(newCalls).filter(([op]) => !isForbiddenOperation(op, forbiddenOperations)));
3416
+ const headline = `Unexpected GraphQL call (possible cache miss).\n` +
3417
+ `These operations should have been served from the cache: [${violated.join(', ')}]`;
3418
+ try {
3419
+ expect(actualCalls).toEqual(expectedCalls);
3420
+ }
3421
+ catch (error) {
3422
+ if (error instanceof Error) {
3423
+ error.message = `${headline}\n\n${error.message}`;
3424
+ }
3425
+ throw error;
3426
+ }
3427
+ }
3428
+ }
3429
+
3430
+ const isRecord = (value) => typeof value === 'object' && value !== null;
3431
+ /**
3432
+ * Picks which recorded fixture to serve for a request, based on its variables. An
3433
+ * operation recorded under several filters or pages keeps one row per recording in
3434
+ * a fixture table, and this returns the row that fits the request.
3435
+ *
3436
+ * A request no row fits is a missing fixture: it throws, names the table to add a
3437
+ * row to, and records the miss for the run's summary.
3438
+ *
3439
+ * @param label - How the error message refers to the table, usually the operation name.
3440
+ */
3441
+ function matchFixture(variables, table, label) {
3442
+ const match = table.find((candidate) => candidate.matches(variables));
3443
+ if (!match) {
3444
+ const message = `No ${label} fixture matches ${JSON.stringify(variables)}. Add one to the ${label} fixture table.`;
3445
+ captureMissingOperation(message);
3446
+ throw new Error(message);
3447
+ }
3448
+ return match;
3449
+ }
3450
+ /** `get_commit_list.query.graphql.json` and `rest_work_items_list.json` become `getCommitList` and `restWorkItemsList`. */
3451
+ const operationNameOf = (file) => camelCase(file.replace(/\.(query|mutation)\.graphql\.json$/, '').replace(/\.json$/, ''));
3452
+ /**
3453
+ * Fills in the empty `errors` array a recorded success leaves out, so handlers can
3454
+ * serve the fixture as a complete GraphQL response.
3455
+ */
3456
+ function normaliseGraphqlFixture(input) {
3457
+ return { errors: [], ...input };
3458
+ }
3459
+ /**
3460
+ * Loads a directory of recorded responses so a handler file can refer to each one
3461
+ * by operation name instead of reading JSON by hand. File names become camelCased
3462
+ * keys. GraphQL responses always come back with an `errors` array so handlers can
3463
+ * serve them without checking for it. REST payloads are stored untouched.
3464
+ */
3465
+ function loadFixturesMap(basePath) {
3466
+ const files = node_fs.readdirSync(basePath).filter((f) => f.endsWith('.json'));
3467
+ const map = {};
3468
+ files.forEach((file) => {
3469
+ const content = JSON.parse(node_fs.readFileSync(node_path.join(basePath, file), 'utf-8'));
3470
+ map[operationNameOf(file)] = isValidGraphqlFixture(content)
3471
+ ? normaliseGraphqlFixture(content)
3472
+ : content;
3473
+ });
3474
+ return map;
3475
+ }
3476
+ /** Whether a value has the shape of a recorded GraphQL response: an object `data` and, if present, an array `errors`. */
3477
+ function isValidGraphqlFixture(fixture) {
3478
+ if (!isRecord(fixture)) {
3479
+ return false;
3480
+ }
3481
+ const hasData = 'data' in fixture;
3482
+ const isValidData = hasData && isRecord(fixture.data);
3483
+ const isValidErrors = !('errors' in fixture) || Array.isArray(fixture.errors);
3484
+ return hasData && isValidData && isValidErrors;
3485
+ }
3486
+ const PAGINATOR_CURSOR_PREFIX = 'fixture-cursor:';
3487
+ const DEFAULT_PAGE_SIZE = 20;
3488
+ const DEFAULT_VARIABLE_NAMES = {
3489
+ after: 'after',
3490
+ before: 'before',
3491
+ first: 'first',
3492
+ last: 'last',
3493
+ };
3494
+ function splitGraphqlId(id) {
3495
+ const match = String(id).match(/^(.*\/)(\d+)$/);
3496
+ return match ? { prefix: match[1], number: Number(match[2]) } : null;
3497
+ }
3498
+ // Opaque ids (e.g. a finding `uuid`) have no number to count up from, so they get a suffix.
3499
+ function idSynthesizer(ids) {
3500
+ const parsed = ids.map(splitGraphqlId);
3501
+ if (parsed.some((entry) => entry === null)) {
3502
+ const templateId = ids[ids.length - 1];
3503
+ return (index) => `${templateId}-${index + 1}`;
3504
+ }
3505
+ const numeric = parsed;
3506
+ const { prefix } = numeric[numeric.length - 1];
3507
+ // Recorded lists are often sorted DESC, so count up from the highest id rather than
3508
+ // the last one, or the new ids collide with recorded nodes.
3509
+ const highestId = Math.max(...numeric.map(({ number }) => number));
3510
+ return (index) => `${prefix}${highestId + index + 1}`;
3511
+ }
3512
+ // A connection lists its items as `nodes`, as Relay-style `edges` wrapping each node, or both.
3513
+ const ITEM_LISTS = [
3514
+ { key: 'nodes', nodeOf: (item) => item },
3515
+ { key: 'edges', nodeOf: (edge) => edge.node },
3516
+ ];
3517
+ function itemListsOf(connection) {
3518
+ if (!isRecord(connection)) {
3519
+ return [];
3520
+ }
3521
+ return ITEM_LISTS.filter(({ key }) => Array.isArray(connection[key]));
3522
+ }
3523
+ function resizeItems(items, itemCount, nodeOf) {
3524
+ if (itemCount <= items.length) {
3525
+ return items.slice(0, itemCount);
3526
+ }
3527
+ const template = items[items.length - 1];
3528
+ const nextId = idSynthesizer(items.map((item) => nodeOf(item).id));
3529
+ const filled = Array.from({ length: itemCount - items.length }, (_, index) => {
3530
+ const clone = cloneDeep(template);
3531
+ const node = nodeOf(clone);
3532
+ node.id = nextId(index);
3533
+ return clone;
3534
+ });
3535
+ return [...items, ...filled];
3536
+ }
3537
+ function validateLookupKey(lookupKey) {
3538
+ if (!lookupKey || typeof lookupKey !== 'string') {
3539
+ throw new Error('Property name must be a non-empty string');
3540
+ }
3541
+ if (lookupKey === 'nodes' || lookupKey === 'edges') {
3542
+ throw new Error(`Property name must be the connection key (e.g. "workItems"), not "${lookupKey}"; its "nodes" or "edges" child is resized`);
3543
+ }
3544
+ }
3545
+ // Calls `callback` with every `lookupKey` value, without descending into a match.
3546
+ function forEachConnection(obj, lookupKey, callback) {
3547
+ if (!isRecord(obj)) {
3548
+ return;
3549
+ }
3550
+ if (lookupKey in obj) {
3551
+ callback(obj[lookupKey]);
3552
+ return;
3553
+ }
3554
+ Object.values(obj).forEach((value) => forEachConnection(value, lookupKey, callback));
3555
+ }
3556
+ // Only writes keys the fixture already selects, so the response shape stays unchanged.
3557
+ function setPageInfo(connection, values) {
3558
+ const { pageInfo } = connection;
3559
+ if (!isRecord(pageInfo)) {
3560
+ return;
3561
+ }
3562
+ Object.assign(pageInfo, pick(values, Object.keys(pageInfo)));
3563
+ }
3564
+ function encodeCursor(index) {
3565
+ return `${PAGINATOR_CURSOR_PREFIX}${index}`;
3566
+ }
3567
+ function decodeCursor(cursor) {
3568
+ const index = String(cursor).startsWith(PAGINATOR_CURSOR_PREFIX)
3569
+ ? Number(String(cursor).slice(PAGINATOR_CURSOR_PREFIX.length))
3570
+ : NaN;
3571
+ if (!Number.isInteger(index)) {
3572
+ const message = `"${cursor}" is not a cursor issued by createFixturePaginator. Serve every page of this connection through the paginator.`;
3573
+ captureMissingOperation(message);
3574
+ throw new Error(message);
3575
+ }
3576
+ return index;
3577
+ }
3578
+ // Reads the operation's own variable names into one `{ after, before, first, last }` request.
3579
+ function readPageRequest(variables, variableNames) {
3580
+ return Object.fromEntries(Object.entries(variableNames).map(([name, variableName]) => [name, variables[variableName]]));
3581
+ }
3582
+ function pageRange({ after, before, first, last }, { totalCount, pageSize }) {
3583
+ if (before) {
3584
+ const endIndex = decodeCursor(before);
3585
+ return { startIndex: Math.max(0, endIndex - (last ?? pageSize)), endIndex };
3586
+ }
3587
+ const startIndex = after ? decodeCursor(after) + 1 : 0;
3588
+ return { startIndex, endIndex: Math.min(totalCount, startIndex + (first ?? pageSize)) };
3589
+ }
3590
+ /* eslint-disable no-param-reassign */
3591
+ function sliceConnection(connection, itemLists, { startIndex, endIndex }) {
3592
+ itemLists.forEach(({ key }) => {
3593
+ connection[key] = connection[key].slice(startIndex, endIndex);
3594
+ });
3595
+ // An edge cursor must match pageInfo, or following it would fail to decode.
3596
+ const { edges } = connection;
3597
+ if (Array.isArray(edges)) {
3598
+ edges.forEach((edge, index) => {
3599
+ if (isRecord(edge) && 'cursor' in edge) {
3600
+ edge.cursor = encodeCursor(startIndex + index);
3601
+ }
3602
+ });
3603
+ }
3604
+ }
3605
+ /* eslint-enable no-param-reassign */
3606
+ function pageInfoFor({ startIndex, endIndex }, totalCount) {
3607
+ const isEmpty = endIndex <= startIndex;
3608
+ return {
3609
+ hasNextPage: endIndex < totalCount,
3610
+ hasPreviousPage: startIndex > 0,
3611
+ startCursor: isEmpty ? null : encodeCursor(startIndex),
3612
+ endCursor: isEmpty ? null : encodeCursor(endIndex - 1),
3613
+ };
3614
+ }
3615
+ // Main consumers are below
3616
+ /**
3617
+ * Turns a recorded success into an error response, for specs that cover how the UI
3618
+ * reacts when the backend rejects a request. The result carries the given messages
3619
+ * and no data. The original fixture is left untouched.
3620
+ *
3621
+ * @throws {Error} If `errors` is not an array of strings.
3622
+ */
3623
+ function setFixtureErrors(fixture, errors) {
3624
+ if (!isValidGraphqlFixture(fixture)) {
3625
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3626
+ }
3627
+ if (!errors || !Array.isArray(errors) || errors.some((e) => typeof e !== 'string')) {
3628
+ throw new Error('Errors must be an array of error messages');
3629
+ }
3630
+ const clone = cloneDeep(fixture);
3631
+ Object.assign(clone, {
3632
+ errors: errors.map((message) => ({ message })),
3633
+ data: {},
3634
+ });
3635
+ return clone;
3636
+ }
3637
+ /**
3638
+ * Produces a copy of a fixture with one value changed, so a spec can describe the
3639
+ * state it needs ("this item is confidential") instead of maintaining a second
3640
+ * recording.
3641
+ *
3642
+ * Name the key to change and the first occurrence in the data is updated. When the
3643
+ * same key appears in more than one place (an `awardEmoji` connection and an
3644
+ * `awardEmoji` permission, say), pass `{ path }` with a lodash path from
3645
+ * `fixture.data` to pick one exactly.
3646
+ *
3647
+ * @throws {Error} If `selector` is not a non-empty string or a `{ path }` object.
3648
+ */
3649
+ function setFixtureData(fixture, selector, data) {
3650
+ if (!isValidGraphqlFixture(fixture)) {
3651
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3652
+ }
3653
+ const path = typeof selector === 'object' && selector !== null ? selector.path : null;
3654
+ const lookupKey = typeof selector === 'string' ? selector : null;
3655
+ if (!path && !lookupKey) {
3656
+ throw new Error('Selector must be a non-empty key name or an object with a "path"');
3657
+ }
3658
+ const clone = cloneDeep(fixture);
3659
+ let found = false;
3660
+ if (path) {
3661
+ set(clone.data, path, data);
3662
+ return clone;
3663
+ }
3664
+ function updateData(obj) {
3665
+ if (isRecord(obj)) {
3666
+ if (lookupKey in obj) {
3667
+ // eslint-disable-next-line no-param-reassign
3668
+ obj[lookupKey] = data;
3669
+ found = true;
3670
+ }
3671
+ else {
3672
+ Object.values(obj).forEach(updateData);
3673
+ }
3674
+ }
3675
+ }
3676
+ updateData(clone.data);
3677
+ if (!found) {
3678
+ throw new Error(`Property "${lookupKey}" was not found in the fixture data; check the key for typos`);
3679
+ }
3680
+ return clone;
3681
+ }
3682
+ /**
3683
+ * Produces a copy of a fixture whose connection holds exactly `itemCount` items, for
3684
+ * specs that need an empty list, a single row or more rows than were recorded.
3685
+ * Extra items are cloned from the existing ones, and a scalar count field such as
3686
+ * `count` is kept in step. Count-only connections just get the new count.
3687
+ *
3688
+ * @throws {Error} If the fixture, key or count is invalid, or the connection has no
3689
+ * item to clone from.
3690
+ */
3691
+ function setFixtureItemsCount({ fixture, lookupKey, itemCount, countKey = 'count', }) {
3692
+ if (!isValidGraphqlFixture(fixture)) {
3693
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3694
+ }
3695
+ validateLookupKey(lookupKey);
3696
+ if (typeof itemCount !== 'number' || itemCount < 0) {
3697
+ throw new Error('Item count must be a non-negative number');
3698
+ }
3699
+ const clone = cloneDeep(fixture);
3700
+ forEachConnection(clone, lookupKey, (connection) => {
3701
+ const itemLists = itemListsOf(connection);
3702
+ const hasCount = isRecord(connection) && countKey in connection;
3703
+ if (!itemLists.length && !hasCount) {
3704
+ throw new Error(`Property "${lookupKey}" must be a connection with a "nodes" or "edges" array or a "${countKey}" field and cannot be resized`);
3705
+ }
3706
+ // Either branch above proves `connection` is an object.
3707
+ const target = connection;
3708
+ itemLists.forEach(({ key, nodeOf }) => {
3709
+ const items = target[key];
3710
+ if (items.length === 0 && itemCount > 0) {
3711
+ throw new Error(`Property "${lookupKey}.${key}" is empty; cannot synthesize items without a template`);
3712
+ }
3713
+ target[key] = resizeItems(items, itemCount, nodeOf);
3714
+ });
3715
+ if (hasCount) {
3716
+ target[countKey] = itemCount;
3717
+ }
3718
+ const emptyCursors = itemCount === 0 ? { startCursor: null, endCursor: null } : {};
3719
+ setPageInfo(target, { hasNextPage: false, hasPreviousPage: false, ...emptyCursors });
3720
+ });
3721
+ return clone;
3722
+ }
3723
+ /**
3724
+ * Lets one recording stand in for every page of a paginated list, so a spec can
3725
+ * exercise "load more" and cursor navigation without recording each page. The
3726
+ * returned function takes the fixture and the request variables and serves the
3727
+ * page the request asked for. Use `setFixtureItemsCount` first to decide how many
3728
+ * items the full list holds.
3729
+ *
3730
+ * Cursors are made up here, so a cursor copied from a real recording is rejected
3731
+ * instead of quietly serving the first page.
3732
+ *
3733
+ * @throws {Error} If `lookupKey` is invalid.
3734
+ *
3735
+ * @example
3736
+ * const paginateWorkItems = createFixturePaginator({ lookupKey: 'workItems' });
3737
+ * paginateWorkItems(getActiveVariant('getWorkItemsFullEE') ?? base, variables);
3738
+ */
3739
+ function createFixturePaginator({ lookupKey, variableNames = {}, pageSize = DEFAULT_PAGE_SIZE, countKey = 'count', }) {
3740
+ validateLookupKey(lookupKey);
3741
+ const names = { ...DEFAULT_VARIABLE_NAMES, ...variableNames };
3742
+ return (fixture, variables = {}) => {
3743
+ if (!isValidGraphqlFixture(fixture)) {
3744
+ throw new Error('Invalid GraphQL fixture: must be an object with "data" and "errors" fields');
3745
+ }
3746
+ const response = cloneDeep(fixture);
3747
+ const request = readPageRequest(variables, names);
3748
+ let foundConnection = false;
3749
+ forEachConnection(response.data, lookupKey, (connection) => {
3750
+ const itemLists = itemListsOf(connection);
3751
+ if (!itemLists.length) {
3752
+ throw new Error(`Property "${lookupKey}" must be a connection with a "nodes" or "edges" array`);
3753
+ }
3754
+ foundConnection = true;
3755
+ // A non-empty `itemLists` proves `connection` is an object.
3756
+ const target = connection;
3757
+ const totalCount = target[itemLists[0].key].length;
3758
+ const range = pageRange(request, { totalCount, pageSize });
3759
+ sliceConnection(target, itemLists, range);
3760
+ if (countKey in target) {
3761
+ target[countKey] = totalCount;
3762
+ }
3763
+ setPageInfo(target, pageInfoFor(range, totalCount));
3764
+ });
3765
+ if (!foundConnection) {
3766
+ throw new Error(`Property "${lookupKey}" was not found in the fixture data; check the key for typos`);
3767
+ }
3768
+ return response;
3769
+ };
3770
+ }
3771
+
3772
+ const UPPER_SNAKE_CASE_RE = /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/;
3773
+ const variantRegistry = new Map();
3774
+ /**
3775
+ * Switches an operation to one of its variants by name. Specs should use
3776
+ * `setQueryVariant` instead, which has the names checked by the type system. This
3777
+ * exists for the rare shared helper that receives the variant key as a runtime value.
3778
+ */
3779
+ function activateVariant(query, variantKey) {
3780
+ const entry = variantRegistry.get(query);
3781
+ if (!entry) {
3782
+ throw new Error(`activateVariant: no variants registered for query "${query}". ` +
3783
+ 'Did you forget to import the variant file?');
3784
+ }
3785
+ if (!(variantKey in entry.variants)) {
3786
+ const available = Object.keys(entry.variants).join(', ');
3787
+ throw new Error(`activateVariant: unknown variant "${variantKey}" for query "${query}". Available: ${available}`);
3788
+ }
3789
+ entry.active = variantKey;
3790
+ }
3791
+ function registerVariants({ caller, query, variants, normalise, }) {
3792
+ if (!query || typeof query !== 'string') {
3793
+ throw new Error(`${caller}: "query" must be a non-empty string`);
3794
+ }
3795
+ if (!variants || typeof variants !== 'object' || Array.isArray(variants)) {
3796
+ throw new Error(`${caller}: "variants" must be a plain object`);
3797
+ }
3798
+ if (!('BASE' in variants)) {
3799
+ throw new Error(`${caller}: "variants.BASE" is required for query "${query}". ` +
3800
+ 'BASE is the default fixture served when no variant is active.');
3801
+ }
3802
+ const normalised = {};
3803
+ for (const [key, value] of Object.entries(variants)) {
3804
+ if (!UPPER_SNAKE_CASE_RE.test(key)) {
3805
+ throw new Error(`${caller}: variant key "${key}" must be UPPER_SNAKE_CASE (e.g. BASE, WITH_ERROR, EMPTY_LIST).`);
3806
+ }
3807
+ normalised[key] = normalise(key, value);
3808
+ }
3809
+ if (variantRegistry.has(query)) {
3810
+ throw new Error(`${caller}: variants for query "${query}" are already registered. ` +
3811
+ 'Each query must be registered exactly once; check for a duplicate or copy-pasted variant file.');
3812
+ }
3813
+ // Tag the returned object with its query name (non-enumerable so the object
3814
+ // still iterates as the pure variants map) so setQueryVariant can resolve the
3815
+ // query from the constant a spec passes in.
3816
+ Object.defineProperty(normalised, 'query', { value: query });
3817
+ const frozen = Object.freeze(normalised);
3818
+ variantRegistry.set(query, { variants: frozen, active: 'BASE' });
3819
+ return frozen;
3820
+ }
3821
+ /**
3822
+ * Declares the alternate responses an operation can serve, so a spec can switch
3823
+ * between them with one call instead of wiring a handler per case. Every variant
3824
+ * file calls this and exports the result as its default export. `BASE` is required:
3825
+ * it is what the handler serves until a spec asks for something else, and the
3826
+ * recording the other variants are derived from.
3827
+ *
3828
+ * @returns The validated variants object (frozen).
3829
+ *
3830
+ * @example
3831
+ * export default defineFixtureVariants({
3832
+ * query: 'namespaceWorkItem',
3833
+ * variants: {
3834
+ * BASE: namespaceWorkItemFixture,
3835
+ * WITH_ERROR: setFixtureErrors(cloneDeep(namespaceWorkItemFixture), ['Something went wrong']),
3836
+ * },
3837
+ * });
3838
+ */
3839
+ function defineFixtureVariants({ query, variants, }) {
3840
+ return registerVariants({
3841
+ caller: 'defineFixtureVariants',
3842
+ query,
3843
+ variants,
3844
+ normalise: (key, value) => {
3845
+ const fixture = normaliseGraphqlFixture(value);
3846
+ if (!isValidGraphqlFixture(fixture)) {
3847
+ throw new Error(`defineFixtureVariants: variant "${key}" for query "${query}" is not a valid GraphQL fixture. ` +
3848
+ 'Each variant must be an object with "data" (object) and "errors" (array) fields.');
3849
+ }
3850
+ return fixture;
3851
+ },
3852
+ });
3853
+ }
3854
+ /**
3855
+ * The REST counterpart of `defineFixtureVariants`. Each variant is a raw JSON body
3856
+ * served as is. Attach the result to the endpoint as its `variants` and
3857
+ * `buildHandlers` serves whichever one is active. `query` is only the registry key.
3858
+ * By convention it is the fixture's camelCase name, such as `restWorkItemsList`.
3859
+ *
3860
+ * @returns The validated variants object (frozen).
3861
+ */
3862
+ function defineRestFixtureVariants({ query, variants, }) {
3863
+ return registerVariants({
3864
+ caller: 'defineRestFixtureVariants',
3865
+ query,
3866
+ variants,
3867
+ normalise: (key, value) => {
3868
+ if (!value || typeof value !== 'object') {
3869
+ throw new Error(`defineRestFixtureVariants: variant "${key}" for query "${query}" is not a valid REST fixture. ` +
3870
+ 'Each variant must be a JSON body (an array or an object).');
3871
+ }
3872
+ return value;
3873
+ },
3874
+ });
3875
+ }
3876
+ /**
3877
+ * Puts an operation into one of its states for the rest of the test, written as
3878
+ * `setQueryVariant(namespaceWorkItem).archived()`. Pass the variant file's default
3879
+ * export and you get one method per variant, named after its key, so a typo in a
3880
+ * variant name is a type error and autocomplete lists only this operation's states.
3881
+ */
3882
+ function setQueryVariant(queryConstant) {
3883
+ const query = queryConstant?.query;
3884
+ const entry = query && variantRegistry.get(query);
3885
+ if (!entry) {
3886
+ throw new Error('setQueryVariant: expected a query constant from defineFixtureVariants ' +
3887
+ '(a variant file default export). Did you pass a variant key string by mistake?');
3888
+ }
3889
+ const activators = Object.create(null);
3890
+ for (const key of Object.keys(entry.variants)) {
3891
+ activators[camelCase(key)] = () => activateVariant(query, key);
3892
+ }
3893
+ return activators;
3894
+ }
3895
+ /** Looks up one of an operation's variants by key. Null when nothing is registered under that pair. */
3896
+ function getVariant(query, variantKey) {
3897
+ const entry = variantRegistry.get(query);
3898
+ if (!entry)
3899
+ return null;
3900
+ return entry.variants[variantKey] ?? null;
3901
+ }
3902
+ /**
3903
+ * Tells a handler whether a spec has switched this operation to a variant. Returns
3904
+ * that variant when it has, and null while the operation sits at `BASE`, so the
3905
+ * handler can fall back to its own default, often a fixture table lookup.
3906
+ */
3907
+ function getActiveVariant(query) {
3908
+ const entry = variantRegistry.get(query);
3909
+ if (!entry || entry.active === 'BASE')
3910
+ return null;
3911
+ return entry.variants[entry.active];
3912
+ }
3913
+ /** Returns every operation to `BASE` so one spec's state never leaks into the next. Call it from `afterEach`. */
3914
+ function resetAllVariants() {
3915
+ for (const entry of variantRegistry.values()) {
3916
+ entry.active = 'BASE';
3917
+ }
3918
+ }
3919
+ /**
3920
+ * Lists every registered operation and its variant keys, without the fixtures
3921
+ * themselves. Meant for tooling that generates a manifest of available variants,
3922
+ * not for use inside a test.
3923
+ */
3924
+ function dumpRegistry() {
3925
+ const out = {};
3926
+ for (const [query, entry] of variantRegistry) {
3927
+ out[query] = Object.keys(entry.variants).sort();
3928
+ }
3929
+ return out;
3930
+ }
3931
+
3932
+ /**
3933
+ * Assembles the MSW handlers for a test run from the feature handlers and REST
3934
+ * endpoints a consumer registers. Every answered request is captured for
3935
+ * assertions. A GraphQL operation nobody answers is recorded as missing and fails
3936
+ * with a 400, and an unknown REST URL is logged and fails the same way, so a gap in
3937
+ * the handlers surfaces as a loud test failure instead of a silent empty response.
3938
+ */
3939
+ function buildHandlers(allFeatureHandlers, allRestEndpoints) {
3940
+ const restEndpointsHandlers = allRestEndpoints.map((endpoint) => msw.http[endpoint.method](endpoint.path, ({ request }) => {
3941
+ const operationName = endpoint.name || `REST:${endpoint.method}:${endpoint.path}`;
3942
+ captureRequest(operationName, request);
3943
+ const response = endpoint.variants
3944
+ ? (getActiveVariant(endpoint.variants.query) ?? endpoint.variants.BASE)
3945
+ : endpoint.response;
3946
+ return msw.HttpResponse.json(response, { headers: endpoint.headers });
3947
+ }));
3948
+ return [
3949
+ msw.graphql.operation(({ operationName, variables, request }) => {
3950
+ for (const handler of allFeatureHandlers) {
3951
+ const result = handler({ operationName, variables });
3952
+ if (result) {
3953
+ captureRequest(operationName, request, variables);
3954
+ return result;
3955
+ }
3956
+ }
3957
+ captureMissingOperation(operationName);
3958
+ return new msw.HttpResponse(null, { status: 400 });
3959
+ }),
3960
+ ...restEndpointsHandlers,
3961
+ msw.http.get('*', ({ request }) => {
3962
+ // eslint-disable-next-line no-console
3963
+ console.log(`Unhandled url for REST endpoint: ${request.url}`);
3964
+ return new msw.HttpResponse(null, { status: 400 });
3965
+ }),
3966
+ ];
3967
+ }
3968
+
3969
+ /** Builds the MSW node server for a test run from the consumer's feature handlers and REST endpoints. */
3970
+ const createServer = (featureHandlers, restEndpoints) => node.setupServer(...buildHandlers(featureHandlers, restEndpoints));
3971
+
3972
+ exports.activateVariant = activateVariant;
3973
+ exports.baseMetadata = baseMetadata;
3974
+ exports.buildHandlers = buildHandlers;
3975
+ exports.captureMissingOperation = captureMissingOperation;
3976
+ exports.captureRequest = captureRequest;
3977
+ exports.capturedRequests = capturedRequests;
3978
+ exports.clearMissingOperations = clearMissingOperations;
3979
+ exports.createFixturePaginator = createFixturePaginator;
3980
+ exports.createServer = createServer;
3981
+ exports.defineFixtureVariants = defineFixtureVariants;
3982
+ exports.defineRestFixtureVariants = defineRestFixtureVariants;
3983
+ exports.dumpRegistry = dumpRegistry;
3984
+ exports.expectGraphQLCalls = expectGraphQLCalls;
3985
+ exports.getActiveVariant = getActiveVariant;
3986
+ exports.getVariant = getVariant;
3987
+ exports.isValidGraphqlFixture = isValidGraphqlFixture;
3988
+ exports.lastRequestVariables = lastRequestVariables;
3989
+ exports.loadFixturesMap = loadFixturesMap;
3990
+ exports.matchFixture = matchFixture;
3991
+ exports.missingOperations = missingOperations;
3992
+ exports.normaliseGraphqlFixture = normaliseGraphqlFixture;
3993
+ exports.resetAllVariants = resetAllVariants;
3994
+ exports.resetCapturedRequests = resetCapturedRequests;
3995
+ exports.setFixtureData = setFixtureData;
3996
+ exports.setFixtureErrors = setFixtureErrors;
3997
+ exports.setFixtureItemsCount = setFixtureItemsCount;
3998
+ exports.setQueryVariant = setQueryVariant;
3999
+ exports.snapshotRequests = snapshotRequests;