pollination-react-io 0.0.1

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.
@@ -0,0 +1,2241 @@
1
+ import { useState, useCallback, useEffect, useMemo } from 'react';
2
+
3
+ function styleInject(css, ref) {
4
+ if ( ref === void 0 ) ref = {};
5
+ var insertAt = ref.insertAt;
6
+
7
+ if (!css || typeof document === 'undefined') { return; }
8
+
9
+ var head = document.head || document.getElementsByTagName('head')[0];
10
+ var style = document.createElement('style');
11
+ style.type = 'text/css';
12
+
13
+ if (insertAt === 'top') {
14
+ if (head.firstChild) {
15
+ head.insertBefore(style, head.firstChild);
16
+ } else {
17
+ head.appendChild(style);
18
+ }
19
+ } else {
20
+ head.appendChild(style);
21
+ }
22
+
23
+ if (style.styleSheet) {
24
+ style.styleSheet.cssText = css;
25
+ } else {
26
+ style.appendChild(document.createTextNode(css));
27
+ }
28
+ }
29
+
30
+ var css_248z = ":root {\n --background: #fff;\n --font-color: #494949;\n}\n\n@media (prefers-color-scheme: dark) {\n :root {\n --background: #3c3c3c;\n --font-color: #fafafa;\n }\n}\n.test-component {\n background-color: var(--background);\n color: var(--font-color);\n border: 1px solid #131111;\n padding: 16px;\n width: 360px;\n text-align: center;\n}\n.test-component .heading {\n font-family: \"Avenir Next\", Helvetica, Arial, sans-serif;\n font-size: 40px;\n font-weight: bold;\n}";
31
+ styleInject(css_248z);
32
+
33
+ /*! *****************************************************************************
34
+ Copyright (c) Microsoft Corporation.
35
+
36
+ Permission to use, copy, modify, and/or distribute this software for any
37
+ purpose with or without fee is hereby granted.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
40
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
41
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
42
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
43
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
44
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45
+ PERFORMANCE OF THIS SOFTWARE.
46
+ ***************************************************************************** */
47
+
48
+ var __assign = function() {
49
+ __assign = Object.assign || function __assign(t) {
50
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
51
+ s = arguments[i];
52
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
53
+ }
54
+ return t;
55
+ };
56
+ return __assign.apply(this, arguments);
57
+ };
58
+
59
+ function __awaiter(thisArg, _arguments, P, generator) {
60
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
61
+ return new (P || (P = Promise))(function (resolve, reject) {
62
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
63
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
64
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
65
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
66
+ });
67
+ }
68
+
69
+ function __generator(thisArg, body) {
70
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
71
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
72
+ function verb(n) { return function (v) { return step([n, v]); }; }
73
+ function step(op) {
74
+ if (f) throw new TypeError("Generator is already executing.");
75
+ while (_) try {
76
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
77
+ if (y = 0, t) op = [op[0] & 2, t.value];
78
+ switch (op[0]) {
79
+ case 0: case 1: t = op; break;
80
+ case 4: _.label++; return { value: op[1], done: false };
81
+ case 5: _.label++; y = op[1]; op = [0]; continue;
82
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
83
+ default:
84
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
85
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
86
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
87
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
88
+ if (t[2]) _.ops.pop();
89
+ _.trys.pop(); continue;
90
+ }
91
+ op = body.call(thisArg, _);
92
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
93
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
94
+ }
95
+ }
96
+
97
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
98
+
99
+ function createCommonjsModule(fn) {
100
+ var module = { exports: {} };
101
+ return fn(module, module.exports), module.exports;
102
+ }
103
+
104
+ /**
105
+ * Lodash (Custom Build) <https://lodash.com/>
106
+ * Build: `lodash modularize exports="npm" -o ./`
107
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
108
+ * Released under MIT license <https://lodash.com/license>
109
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
110
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
111
+ */
112
+
113
+ var lodash_isequal = createCommonjsModule(function (module, exports) {
114
+ /** Used as the size to enable large array optimizations. */
115
+ var LARGE_ARRAY_SIZE = 200;
116
+
117
+ /** Used to stand-in for `undefined` hash values. */
118
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
119
+
120
+ /** Used to compose bitmasks for value comparisons. */
121
+ var COMPARE_PARTIAL_FLAG = 1,
122
+ COMPARE_UNORDERED_FLAG = 2;
123
+
124
+ /** Used as references for various `Number` constants. */
125
+ var MAX_SAFE_INTEGER = 9007199254740991;
126
+
127
+ /** `Object#toString` result references. */
128
+ var argsTag = '[object Arguments]',
129
+ arrayTag = '[object Array]',
130
+ asyncTag = '[object AsyncFunction]',
131
+ boolTag = '[object Boolean]',
132
+ dateTag = '[object Date]',
133
+ errorTag = '[object Error]',
134
+ funcTag = '[object Function]',
135
+ genTag = '[object GeneratorFunction]',
136
+ mapTag = '[object Map]',
137
+ numberTag = '[object Number]',
138
+ nullTag = '[object Null]',
139
+ objectTag = '[object Object]',
140
+ promiseTag = '[object Promise]',
141
+ proxyTag = '[object Proxy]',
142
+ regexpTag = '[object RegExp]',
143
+ setTag = '[object Set]',
144
+ stringTag = '[object String]',
145
+ symbolTag = '[object Symbol]',
146
+ undefinedTag = '[object Undefined]',
147
+ weakMapTag = '[object WeakMap]';
148
+
149
+ var arrayBufferTag = '[object ArrayBuffer]',
150
+ dataViewTag = '[object DataView]',
151
+ float32Tag = '[object Float32Array]',
152
+ float64Tag = '[object Float64Array]',
153
+ int8Tag = '[object Int8Array]',
154
+ int16Tag = '[object Int16Array]',
155
+ int32Tag = '[object Int32Array]',
156
+ uint8Tag = '[object Uint8Array]',
157
+ uint8ClampedTag = '[object Uint8ClampedArray]',
158
+ uint16Tag = '[object Uint16Array]',
159
+ uint32Tag = '[object Uint32Array]';
160
+
161
+ /**
162
+ * Used to match `RegExp`
163
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
164
+ */
165
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
166
+
167
+ /** Used to detect host constructors (Safari). */
168
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
169
+
170
+ /** Used to detect unsigned integer values. */
171
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
172
+
173
+ /** Used to identify `toStringTag` values of typed arrays. */
174
+ var typedArrayTags = {};
175
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
176
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
177
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
178
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
179
+ typedArrayTags[uint32Tag] = true;
180
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
181
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
182
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
183
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
184
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
185
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
186
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
187
+ typedArrayTags[weakMapTag] = false;
188
+
189
+ /** Detect free variable `global` from Node.js. */
190
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
191
+
192
+ /** Detect free variable `self`. */
193
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
194
+
195
+ /** Used as a reference to the global object. */
196
+ var root = freeGlobal || freeSelf || Function('return this')();
197
+
198
+ /** Detect free variable `exports`. */
199
+ var freeExports = exports && !exports.nodeType && exports;
200
+
201
+ /** Detect free variable `module`. */
202
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
203
+
204
+ /** Detect the popular CommonJS extension `module.exports`. */
205
+ var moduleExports = freeModule && freeModule.exports === freeExports;
206
+
207
+ /** Detect free variable `process` from Node.js. */
208
+ var freeProcess = moduleExports && freeGlobal.process;
209
+
210
+ /** Used to access faster Node.js helpers. */
211
+ var nodeUtil = (function() {
212
+ try {
213
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
214
+ } catch (e) {}
215
+ }());
216
+
217
+ /* Node.js helper references. */
218
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
219
+
220
+ /**
221
+ * A specialized version of `_.filter` for arrays without support for
222
+ * iteratee shorthands.
223
+ *
224
+ * @private
225
+ * @param {Array} [array] The array to iterate over.
226
+ * @param {Function} predicate The function invoked per iteration.
227
+ * @returns {Array} Returns the new filtered array.
228
+ */
229
+ function arrayFilter(array, predicate) {
230
+ var index = -1,
231
+ length = array == null ? 0 : array.length,
232
+ resIndex = 0,
233
+ result = [];
234
+
235
+ while (++index < length) {
236
+ var value = array[index];
237
+ if (predicate(value, index, array)) {
238
+ result[resIndex++] = value;
239
+ }
240
+ }
241
+ return result;
242
+ }
243
+
244
+ /**
245
+ * Appends the elements of `values` to `array`.
246
+ *
247
+ * @private
248
+ * @param {Array} array The array to modify.
249
+ * @param {Array} values The values to append.
250
+ * @returns {Array} Returns `array`.
251
+ */
252
+ function arrayPush(array, values) {
253
+ var index = -1,
254
+ length = values.length,
255
+ offset = array.length;
256
+
257
+ while (++index < length) {
258
+ array[offset + index] = values[index];
259
+ }
260
+ return array;
261
+ }
262
+
263
+ /**
264
+ * A specialized version of `_.some` for arrays without support for iteratee
265
+ * shorthands.
266
+ *
267
+ * @private
268
+ * @param {Array} [array] The array to iterate over.
269
+ * @param {Function} predicate The function invoked per iteration.
270
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
271
+ * else `false`.
272
+ */
273
+ function arraySome(array, predicate) {
274
+ var index = -1,
275
+ length = array == null ? 0 : array.length;
276
+
277
+ while (++index < length) {
278
+ if (predicate(array[index], index, array)) {
279
+ return true;
280
+ }
281
+ }
282
+ return false;
283
+ }
284
+
285
+ /**
286
+ * The base implementation of `_.times` without support for iteratee shorthands
287
+ * or max array length checks.
288
+ *
289
+ * @private
290
+ * @param {number} n The number of times to invoke `iteratee`.
291
+ * @param {Function} iteratee The function invoked per iteration.
292
+ * @returns {Array} Returns the array of results.
293
+ */
294
+ function baseTimes(n, iteratee) {
295
+ var index = -1,
296
+ result = Array(n);
297
+
298
+ while (++index < n) {
299
+ result[index] = iteratee(index);
300
+ }
301
+ return result;
302
+ }
303
+
304
+ /**
305
+ * The base implementation of `_.unary` without support for storing metadata.
306
+ *
307
+ * @private
308
+ * @param {Function} func The function to cap arguments for.
309
+ * @returns {Function} Returns the new capped function.
310
+ */
311
+ function baseUnary(func) {
312
+ return function(value) {
313
+ return func(value);
314
+ };
315
+ }
316
+
317
+ /**
318
+ * Checks if a `cache` value for `key` exists.
319
+ *
320
+ * @private
321
+ * @param {Object} cache The cache to query.
322
+ * @param {string} key The key of the entry to check.
323
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
324
+ */
325
+ function cacheHas(cache, key) {
326
+ return cache.has(key);
327
+ }
328
+
329
+ /**
330
+ * Gets the value at `key` of `object`.
331
+ *
332
+ * @private
333
+ * @param {Object} [object] The object to query.
334
+ * @param {string} key The key of the property to get.
335
+ * @returns {*} Returns the property value.
336
+ */
337
+ function getValue(object, key) {
338
+ return object == null ? undefined : object[key];
339
+ }
340
+
341
+ /**
342
+ * Converts `map` to its key-value pairs.
343
+ *
344
+ * @private
345
+ * @param {Object} map The map to convert.
346
+ * @returns {Array} Returns the key-value pairs.
347
+ */
348
+ function mapToArray(map) {
349
+ var index = -1,
350
+ result = Array(map.size);
351
+
352
+ map.forEach(function(value, key) {
353
+ result[++index] = [key, value];
354
+ });
355
+ return result;
356
+ }
357
+
358
+ /**
359
+ * Creates a unary function that invokes `func` with its argument transformed.
360
+ *
361
+ * @private
362
+ * @param {Function} func The function to wrap.
363
+ * @param {Function} transform The argument transform.
364
+ * @returns {Function} Returns the new function.
365
+ */
366
+ function overArg(func, transform) {
367
+ return function(arg) {
368
+ return func(transform(arg));
369
+ };
370
+ }
371
+
372
+ /**
373
+ * Converts `set` to an array of its values.
374
+ *
375
+ * @private
376
+ * @param {Object} set The set to convert.
377
+ * @returns {Array} Returns the values.
378
+ */
379
+ function setToArray(set) {
380
+ var index = -1,
381
+ result = Array(set.size);
382
+
383
+ set.forEach(function(value) {
384
+ result[++index] = value;
385
+ });
386
+ return result;
387
+ }
388
+
389
+ /** Used for built-in method references. */
390
+ var arrayProto = Array.prototype,
391
+ funcProto = Function.prototype,
392
+ objectProto = Object.prototype;
393
+
394
+ /** Used to detect overreaching core-js shims. */
395
+ var coreJsData = root['__core-js_shared__'];
396
+
397
+ /** Used to resolve the decompiled source of functions. */
398
+ var funcToString = funcProto.toString;
399
+
400
+ /** Used to check objects for own properties. */
401
+ var hasOwnProperty = objectProto.hasOwnProperty;
402
+
403
+ /** Used to detect methods masquerading as native. */
404
+ var maskSrcKey = (function() {
405
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
406
+ return uid ? ('Symbol(src)_1.' + uid) : '';
407
+ }());
408
+
409
+ /**
410
+ * Used to resolve the
411
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
412
+ * of values.
413
+ */
414
+ var nativeObjectToString = objectProto.toString;
415
+
416
+ /** Used to detect if a method is native. */
417
+ var reIsNative = RegExp('^' +
418
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
419
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
420
+ );
421
+
422
+ /** Built-in value references. */
423
+ var Buffer = moduleExports ? root.Buffer : undefined,
424
+ Symbol = root.Symbol,
425
+ Uint8Array = root.Uint8Array,
426
+ propertyIsEnumerable = objectProto.propertyIsEnumerable,
427
+ splice = arrayProto.splice,
428
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
429
+
430
+ /* Built-in method references for those with the same name as other `lodash` methods. */
431
+ var nativeGetSymbols = Object.getOwnPropertySymbols,
432
+ nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
433
+ nativeKeys = overArg(Object.keys, Object);
434
+
435
+ /* Built-in method references that are verified to be native. */
436
+ var DataView = getNative(root, 'DataView'),
437
+ Map = getNative(root, 'Map'),
438
+ Promise = getNative(root, 'Promise'),
439
+ Set = getNative(root, 'Set'),
440
+ WeakMap = getNative(root, 'WeakMap'),
441
+ nativeCreate = getNative(Object, 'create');
442
+
443
+ /** Used to detect maps, sets, and weakmaps. */
444
+ var dataViewCtorString = toSource(DataView),
445
+ mapCtorString = toSource(Map),
446
+ promiseCtorString = toSource(Promise),
447
+ setCtorString = toSource(Set),
448
+ weakMapCtorString = toSource(WeakMap);
449
+
450
+ /** Used to convert symbols to primitives and strings. */
451
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
452
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
453
+
454
+ /**
455
+ * Creates a hash object.
456
+ *
457
+ * @private
458
+ * @constructor
459
+ * @param {Array} [entries] The key-value pairs to cache.
460
+ */
461
+ function Hash(entries) {
462
+ var index = -1,
463
+ length = entries == null ? 0 : entries.length;
464
+
465
+ this.clear();
466
+ while (++index < length) {
467
+ var entry = entries[index];
468
+ this.set(entry[0], entry[1]);
469
+ }
470
+ }
471
+
472
+ /**
473
+ * Removes all key-value entries from the hash.
474
+ *
475
+ * @private
476
+ * @name clear
477
+ * @memberOf Hash
478
+ */
479
+ function hashClear() {
480
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
481
+ this.size = 0;
482
+ }
483
+
484
+ /**
485
+ * Removes `key` and its value from the hash.
486
+ *
487
+ * @private
488
+ * @name delete
489
+ * @memberOf Hash
490
+ * @param {Object} hash The hash to modify.
491
+ * @param {string} key The key of the value to remove.
492
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
493
+ */
494
+ function hashDelete(key) {
495
+ var result = this.has(key) && delete this.__data__[key];
496
+ this.size -= result ? 1 : 0;
497
+ return result;
498
+ }
499
+
500
+ /**
501
+ * Gets the hash value for `key`.
502
+ *
503
+ * @private
504
+ * @name get
505
+ * @memberOf Hash
506
+ * @param {string} key The key of the value to get.
507
+ * @returns {*} Returns the entry value.
508
+ */
509
+ function hashGet(key) {
510
+ var data = this.__data__;
511
+ if (nativeCreate) {
512
+ var result = data[key];
513
+ return result === HASH_UNDEFINED ? undefined : result;
514
+ }
515
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
516
+ }
517
+
518
+ /**
519
+ * Checks if a hash value for `key` exists.
520
+ *
521
+ * @private
522
+ * @name has
523
+ * @memberOf Hash
524
+ * @param {string} key The key of the entry to check.
525
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
526
+ */
527
+ function hashHas(key) {
528
+ var data = this.__data__;
529
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
530
+ }
531
+
532
+ /**
533
+ * Sets the hash `key` to `value`.
534
+ *
535
+ * @private
536
+ * @name set
537
+ * @memberOf Hash
538
+ * @param {string} key The key of the value to set.
539
+ * @param {*} value The value to set.
540
+ * @returns {Object} Returns the hash instance.
541
+ */
542
+ function hashSet(key, value) {
543
+ var data = this.__data__;
544
+ this.size += this.has(key) ? 0 : 1;
545
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
546
+ return this;
547
+ }
548
+
549
+ // Add methods to `Hash`.
550
+ Hash.prototype.clear = hashClear;
551
+ Hash.prototype['delete'] = hashDelete;
552
+ Hash.prototype.get = hashGet;
553
+ Hash.prototype.has = hashHas;
554
+ Hash.prototype.set = hashSet;
555
+
556
+ /**
557
+ * Creates an list cache object.
558
+ *
559
+ * @private
560
+ * @constructor
561
+ * @param {Array} [entries] The key-value pairs to cache.
562
+ */
563
+ function ListCache(entries) {
564
+ var index = -1,
565
+ length = entries == null ? 0 : entries.length;
566
+
567
+ this.clear();
568
+ while (++index < length) {
569
+ var entry = entries[index];
570
+ this.set(entry[0], entry[1]);
571
+ }
572
+ }
573
+
574
+ /**
575
+ * Removes all key-value entries from the list cache.
576
+ *
577
+ * @private
578
+ * @name clear
579
+ * @memberOf ListCache
580
+ */
581
+ function listCacheClear() {
582
+ this.__data__ = [];
583
+ this.size = 0;
584
+ }
585
+
586
+ /**
587
+ * Removes `key` and its value from the list cache.
588
+ *
589
+ * @private
590
+ * @name delete
591
+ * @memberOf ListCache
592
+ * @param {string} key The key of the value to remove.
593
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
594
+ */
595
+ function listCacheDelete(key) {
596
+ var data = this.__data__,
597
+ index = assocIndexOf(data, key);
598
+
599
+ if (index < 0) {
600
+ return false;
601
+ }
602
+ var lastIndex = data.length - 1;
603
+ if (index == lastIndex) {
604
+ data.pop();
605
+ } else {
606
+ splice.call(data, index, 1);
607
+ }
608
+ --this.size;
609
+ return true;
610
+ }
611
+
612
+ /**
613
+ * Gets the list cache value for `key`.
614
+ *
615
+ * @private
616
+ * @name get
617
+ * @memberOf ListCache
618
+ * @param {string} key The key of the value to get.
619
+ * @returns {*} Returns the entry value.
620
+ */
621
+ function listCacheGet(key) {
622
+ var data = this.__data__,
623
+ index = assocIndexOf(data, key);
624
+
625
+ return index < 0 ? undefined : data[index][1];
626
+ }
627
+
628
+ /**
629
+ * Checks if a list cache value for `key` exists.
630
+ *
631
+ * @private
632
+ * @name has
633
+ * @memberOf ListCache
634
+ * @param {string} key The key of the entry to check.
635
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
636
+ */
637
+ function listCacheHas(key) {
638
+ return assocIndexOf(this.__data__, key) > -1;
639
+ }
640
+
641
+ /**
642
+ * Sets the list cache `key` to `value`.
643
+ *
644
+ * @private
645
+ * @name set
646
+ * @memberOf ListCache
647
+ * @param {string} key The key of the value to set.
648
+ * @param {*} value The value to set.
649
+ * @returns {Object} Returns the list cache instance.
650
+ */
651
+ function listCacheSet(key, value) {
652
+ var data = this.__data__,
653
+ index = assocIndexOf(data, key);
654
+
655
+ if (index < 0) {
656
+ ++this.size;
657
+ data.push([key, value]);
658
+ } else {
659
+ data[index][1] = value;
660
+ }
661
+ return this;
662
+ }
663
+
664
+ // Add methods to `ListCache`.
665
+ ListCache.prototype.clear = listCacheClear;
666
+ ListCache.prototype['delete'] = listCacheDelete;
667
+ ListCache.prototype.get = listCacheGet;
668
+ ListCache.prototype.has = listCacheHas;
669
+ ListCache.prototype.set = listCacheSet;
670
+
671
+ /**
672
+ * Creates a map cache object to store key-value pairs.
673
+ *
674
+ * @private
675
+ * @constructor
676
+ * @param {Array} [entries] The key-value pairs to cache.
677
+ */
678
+ function MapCache(entries) {
679
+ var index = -1,
680
+ length = entries == null ? 0 : entries.length;
681
+
682
+ this.clear();
683
+ while (++index < length) {
684
+ var entry = entries[index];
685
+ this.set(entry[0], entry[1]);
686
+ }
687
+ }
688
+
689
+ /**
690
+ * Removes all key-value entries from the map.
691
+ *
692
+ * @private
693
+ * @name clear
694
+ * @memberOf MapCache
695
+ */
696
+ function mapCacheClear() {
697
+ this.size = 0;
698
+ this.__data__ = {
699
+ 'hash': new Hash,
700
+ 'map': new (Map || ListCache),
701
+ 'string': new Hash
702
+ };
703
+ }
704
+
705
+ /**
706
+ * Removes `key` and its value from the map.
707
+ *
708
+ * @private
709
+ * @name delete
710
+ * @memberOf MapCache
711
+ * @param {string} key The key of the value to remove.
712
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
713
+ */
714
+ function mapCacheDelete(key) {
715
+ var result = getMapData(this, key)['delete'](key);
716
+ this.size -= result ? 1 : 0;
717
+ return result;
718
+ }
719
+
720
+ /**
721
+ * Gets the map value for `key`.
722
+ *
723
+ * @private
724
+ * @name get
725
+ * @memberOf MapCache
726
+ * @param {string} key The key of the value to get.
727
+ * @returns {*} Returns the entry value.
728
+ */
729
+ function mapCacheGet(key) {
730
+ return getMapData(this, key).get(key);
731
+ }
732
+
733
+ /**
734
+ * Checks if a map value for `key` exists.
735
+ *
736
+ * @private
737
+ * @name has
738
+ * @memberOf MapCache
739
+ * @param {string} key The key of the entry to check.
740
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
741
+ */
742
+ function mapCacheHas(key) {
743
+ return getMapData(this, key).has(key);
744
+ }
745
+
746
+ /**
747
+ * Sets the map `key` to `value`.
748
+ *
749
+ * @private
750
+ * @name set
751
+ * @memberOf MapCache
752
+ * @param {string} key The key of the value to set.
753
+ * @param {*} value The value to set.
754
+ * @returns {Object} Returns the map cache instance.
755
+ */
756
+ function mapCacheSet(key, value) {
757
+ var data = getMapData(this, key),
758
+ size = data.size;
759
+
760
+ data.set(key, value);
761
+ this.size += data.size == size ? 0 : 1;
762
+ return this;
763
+ }
764
+
765
+ // Add methods to `MapCache`.
766
+ MapCache.prototype.clear = mapCacheClear;
767
+ MapCache.prototype['delete'] = mapCacheDelete;
768
+ MapCache.prototype.get = mapCacheGet;
769
+ MapCache.prototype.has = mapCacheHas;
770
+ MapCache.prototype.set = mapCacheSet;
771
+
772
+ /**
773
+ *
774
+ * Creates an array cache object to store unique values.
775
+ *
776
+ * @private
777
+ * @constructor
778
+ * @param {Array} [values] The values to cache.
779
+ */
780
+ function SetCache(values) {
781
+ var index = -1,
782
+ length = values == null ? 0 : values.length;
783
+
784
+ this.__data__ = new MapCache;
785
+ while (++index < length) {
786
+ this.add(values[index]);
787
+ }
788
+ }
789
+
790
+ /**
791
+ * Adds `value` to the array cache.
792
+ *
793
+ * @private
794
+ * @name add
795
+ * @memberOf SetCache
796
+ * @alias push
797
+ * @param {*} value The value to cache.
798
+ * @returns {Object} Returns the cache instance.
799
+ */
800
+ function setCacheAdd(value) {
801
+ this.__data__.set(value, HASH_UNDEFINED);
802
+ return this;
803
+ }
804
+
805
+ /**
806
+ * Checks if `value` is in the array cache.
807
+ *
808
+ * @private
809
+ * @name has
810
+ * @memberOf SetCache
811
+ * @param {*} value The value to search for.
812
+ * @returns {number} Returns `true` if `value` is found, else `false`.
813
+ */
814
+ function setCacheHas(value) {
815
+ return this.__data__.has(value);
816
+ }
817
+
818
+ // Add methods to `SetCache`.
819
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
820
+ SetCache.prototype.has = setCacheHas;
821
+
822
+ /**
823
+ * Creates a stack cache object to store key-value pairs.
824
+ *
825
+ * @private
826
+ * @constructor
827
+ * @param {Array} [entries] The key-value pairs to cache.
828
+ */
829
+ function Stack(entries) {
830
+ var data = this.__data__ = new ListCache(entries);
831
+ this.size = data.size;
832
+ }
833
+
834
+ /**
835
+ * Removes all key-value entries from the stack.
836
+ *
837
+ * @private
838
+ * @name clear
839
+ * @memberOf Stack
840
+ */
841
+ function stackClear() {
842
+ this.__data__ = new ListCache;
843
+ this.size = 0;
844
+ }
845
+
846
+ /**
847
+ * Removes `key` and its value from the stack.
848
+ *
849
+ * @private
850
+ * @name delete
851
+ * @memberOf Stack
852
+ * @param {string} key The key of the value to remove.
853
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
854
+ */
855
+ function stackDelete(key) {
856
+ var data = this.__data__,
857
+ result = data['delete'](key);
858
+
859
+ this.size = data.size;
860
+ return result;
861
+ }
862
+
863
+ /**
864
+ * Gets the stack value for `key`.
865
+ *
866
+ * @private
867
+ * @name get
868
+ * @memberOf Stack
869
+ * @param {string} key The key of the value to get.
870
+ * @returns {*} Returns the entry value.
871
+ */
872
+ function stackGet(key) {
873
+ return this.__data__.get(key);
874
+ }
875
+
876
+ /**
877
+ * Checks if a stack value for `key` exists.
878
+ *
879
+ * @private
880
+ * @name has
881
+ * @memberOf Stack
882
+ * @param {string} key The key of the entry to check.
883
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
884
+ */
885
+ function stackHas(key) {
886
+ return this.__data__.has(key);
887
+ }
888
+
889
+ /**
890
+ * Sets the stack `key` to `value`.
891
+ *
892
+ * @private
893
+ * @name set
894
+ * @memberOf Stack
895
+ * @param {string} key The key of the value to set.
896
+ * @param {*} value The value to set.
897
+ * @returns {Object} Returns the stack cache instance.
898
+ */
899
+ function stackSet(key, value) {
900
+ var data = this.__data__;
901
+ if (data instanceof ListCache) {
902
+ var pairs = data.__data__;
903
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
904
+ pairs.push([key, value]);
905
+ this.size = ++data.size;
906
+ return this;
907
+ }
908
+ data = this.__data__ = new MapCache(pairs);
909
+ }
910
+ data.set(key, value);
911
+ this.size = data.size;
912
+ return this;
913
+ }
914
+
915
+ // Add methods to `Stack`.
916
+ Stack.prototype.clear = stackClear;
917
+ Stack.prototype['delete'] = stackDelete;
918
+ Stack.prototype.get = stackGet;
919
+ Stack.prototype.has = stackHas;
920
+ Stack.prototype.set = stackSet;
921
+
922
+ /**
923
+ * Creates an array of the enumerable property names of the array-like `value`.
924
+ *
925
+ * @private
926
+ * @param {*} value The value to query.
927
+ * @param {boolean} inherited Specify returning inherited property names.
928
+ * @returns {Array} Returns the array of property names.
929
+ */
930
+ function arrayLikeKeys(value, inherited) {
931
+ var isArr = isArray(value),
932
+ isArg = !isArr && isArguments(value),
933
+ isBuff = !isArr && !isArg && isBuffer(value),
934
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
935
+ skipIndexes = isArr || isArg || isBuff || isType,
936
+ result = skipIndexes ? baseTimes(value.length, String) : [],
937
+ length = result.length;
938
+
939
+ for (var key in value) {
940
+ if ((inherited || hasOwnProperty.call(value, key)) &&
941
+ !(skipIndexes && (
942
+ // Safari 9 has enumerable `arguments.length` in strict mode.
943
+ key == 'length' ||
944
+ // Node.js 0.10 has enumerable non-index properties on buffers.
945
+ (isBuff && (key == 'offset' || key == 'parent')) ||
946
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
947
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
948
+ // Skip index properties.
949
+ isIndex(key, length)
950
+ ))) {
951
+ result.push(key);
952
+ }
953
+ }
954
+ return result;
955
+ }
956
+
957
+ /**
958
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
959
+ *
960
+ * @private
961
+ * @param {Array} array The array to inspect.
962
+ * @param {*} key The key to search for.
963
+ * @returns {number} Returns the index of the matched value, else `-1`.
964
+ */
965
+ function assocIndexOf(array, key) {
966
+ var length = array.length;
967
+ while (length--) {
968
+ if (eq(array[length][0], key)) {
969
+ return length;
970
+ }
971
+ }
972
+ return -1;
973
+ }
974
+
975
+ /**
976
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
977
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
978
+ * symbols of `object`.
979
+ *
980
+ * @private
981
+ * @param {Object} object The object to query.
982
+ * @param {Function} keysFunc The function to get the keys of `object`.
983
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
984
+ * @returns {Array} Returns the array of property names and symbols.
985
+ */
986
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
987
+ var result = keysFunc(object);
988
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
989
+ }
990
+
991
+ /**
992
+ * The base implementation of `getTag` without fallbacks for buggy environments.
993
+ *
994
+ * @private
995
+ * @param {*} value The value to query.
996
+ * @returns {string} Returns the `toStringTag`.
997
+ */
998
+ function baseGetTag(value) {
999
+ if (value == null) {
1000
+ return value === undefined ? undefinedTag : nullTag;
1001
+ }
1002
+ return (symToStringTag && symToStringTag in Object(value))
1003
+ ? getRawTag(value)
1004
+ : objectToString(value);
1005
+ }
1006
+
1007
+ /**
1008
+ * The base implementation of `_.isArguments`.
1009
+ *
1010
+ * @private
1011
+ * @param {*} value The value to check.
1012
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1013
+ */
1014
+ function baseIsArguments(value) {
1015
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
1016
+ }
1017
+
1018
+ /**
1019
+ * The base implementation of `_.isEqual` which supports partial comparisons
1020
+ * and tracks traversed objects.
1021
+ *
1022
+ * @private
1023
+ * @param {*} value The value to compare.
1024
+ * @param {*} other The other value to compare.
1025
+ * @param {boolean} bitmask The bitmask flags.
1026
+ * 1 - Unordered comparison
1027
+ * 2 - Partial comparison
1028
+ * @param {Function} [customizer] The function to customize comparisons.
1029
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
1030
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1031
+ */
1032
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
1033
+ if (value === other) {
1034
+ return true;
1035
+ }
1036
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
1037
+ return value !== value && other !== other;
1038
+ }
1039
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1040
+ }
1041
+
1042
+ /**
1043
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
1044
+ * deep comparisons and tracks traversed objects enabling objects with circular
1045
+ * references to be compared.
1046
+ *
1047
+ * @private
1048
+ * @param {Object} object The object to compare.
1049
+ * @param {Object} other The other object to compare.
1050
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1051
+ * @param {Function} customizer The function to customize comparisons.
1052
+ * @param {Function} equalFunc The function to determine equivalents of values.
1053
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
1054
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1055
+ */
1056
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1057
+ var objIsArr = isArray(object),
1058
+ othIsArr = isArray(other),
1059
+ objTag = objIsArr ? arrayTag : getTag(object),
1060
+ othTag = othIsArr ? arrayTag : getTag(other);
1061
+
1062
+ objTag = objTag == argsTag ? objectTag : objTag;
1063
+ othTag = othTag == argsTag ? objectTag : othTag;
1064
+
1065
+ var objIsObj = objTag == objectTag,
1066
+ othIsObj = othTag == objectTag,
1067
+ isSameTag = objTag == othTag;
1068
+
1069
+ if (isSameTag && isBuffer(object)) {
1070
+ if (!isBuffer(other)) {
1071
+ return false;
1072
+ }
1073
+ objIsArr = true;
1074
+ objIsObj = false;
1075
+ }
1076
+ if (isSameTag && !objIsObj) {
1077
+ stack || (stack = new Stack);
1078
+ return (objIsArr || isTypedArray(object))
1079
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
1080
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1081
+ }
1082
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
1083
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
1084
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
1085
+
1086
+ if (objIsWrapped || othIsWrapped) {
1087
+ var objUnwrapped = objIsWrapped ? object.value() : object,
1088
+ othUnwrapped = othIsWrapped ? other.value() : other;
1089
+
1090
+ stack || (stack = new Stack);
1091
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1092
+ }
1093
+ }
1094
+ if (!isSameTag) {
1095
+ return false;
1096
+ }
1097
+ stack || (stack = new Stack);
1098
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1099
+ }
1100
+
1101
+ /**
1102
+ * The base implementation of `_.isNative` without bad shim checks.
1103
+ *
1104
+ * @private
1105
+ * @param {*} value The value to check.
1106
+ * @returns {boolean} Returns `true` if `value` is a native function,
1107
+ * else `false`.
1108
+ */
1109
+ function baseIsNative(value) {
1110
+ if (!isObject(value) || isMasked(value)) {
1111
+ return false;
1112
+ }
1113
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1114
+ return pattern.test(toSource(value));
1115
+ }
1116
+
1117
+ /**
1118
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
1119
+ *
1120
+ * @private
1121
+ * @param {*} value The value to check.
1122
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1123
+ */
1124
+ function baseIsTypedArray(value) {
1125
+ return isObjectLike(value) &&
1126
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1127
+ }
1128
+
1129
+ /**
1130
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1131
+ *
1132
+ * @private
1133
+ * @param {Object} object The object to query.
1134
+ * @returns {Array} Returns the array of property names.
1135
+ */
1136
+ function baseKeys(object) {
1137
+ if (!isPrototype(object)) {
1138
+ return nativeKeys(object);
1139
+ }
1140
+ var result = [];
1141
+ for (var key in Object(object)) {
1142
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
1143
+ result.push(key);
1144
+ }
1145
+ }
1146
+ return result;
1147
+ }
1148
+
1149
+ /**
1150
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
1151
+ * partial deep comparisons.
1152
+ *
1153
+ * @private
1154
+ * @param {Array} array The array to compare.
1155
+ * @param {Array} other The other array to compare.
1156
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1157
+ * @param {Function} customizer The function to customize comparisons.
1158
+ * @param {Function} equalFunc The function to determine equivalents of values.
1159
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
1160
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1161
+ */
1162
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1163
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1164
+ arrLength = array.length,
1165
+ othLength = other.length;
1166
+
1167
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1168
+ return false;
1169
+ }
1170
+ // Assume cyclic values are equal.
1171
+ var stacked = stack.get(array);
1172
+ if (stacked && stack.get(other)) {
1173
+ return stacked == other;
1174
+ }
1175
+ var index = -1,
1176
+ result = true,
1177
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
1178
+
1179
+ stack.set(array, other);
1180
+ stack.set(other, array);
1181
+
1182
+ // Ignore non-index properties.
1183
+ while (++index < arrLength) {
1184
+ var arrValue = array[index],
1185
+ othValue = other[index];
1186
+
1187
+ if (customizer) {
1188
+ var compared = isPartial
1189
+ ? customizer(othValue, arrValue, index, other, array, stack)
1190
+ : customizer(arrValue, othValue, index, array, other, stack);
1191
+ }
1192
+ if (compared !== undefined) {
1193
+ if (compared) {
1194
+ continue;
1195
+ }
1196
+ result = false;
1197
+ break;
1198
+ }
1199
+ // Recursively compare arrays (susceptible to call stack limits).
1200
+ if (seen) {
1201
+ if (!arraySome(other, function(othValue, othIndex) {
1202
+ if (!cacheHas(seen, othIndex) &&
1203
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1204
+ return seen.push(othIndex);
1205
+ }
1206
+ })) {
1207
+ result = false;
1208
+ break;
1209
+ }
1210
+ } else if (!(
1211
+ arrValue === othValue ||
1212
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
1213
+ )) {
1214
+ result = false;
1215
+ break;
1216
+ }
1217
+ }
1218
+ stack['delete'](array);
1219
+ stack['delete'](other);
1220
+ return result;
1221
+ }
1222
+
1223
+ /**
1224
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
1225
+ * the same `toStringTag`.
1226
+ *
1227
+ * **Note:** This function only supports comparing values with tags of
1228
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1229
+ *
1230
+ * @private
1231
+ * @param {Object} object The object to compare.
1232
+ * @param {Object} other The other object to compare.
1233
+ * @param {string} tag The `toStringTag` of the objects to compare.
1234
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1235
+ * @param {Function} customizer The function to customize comparisons.
1236
+ * @param {Function} equalFunc The function to determine equivalents of values.
1237
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1238
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1239
+ */
1240
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1241
+ switch (tag) {
1242
+ case dataViewTag:
1243
+ if ((object.byteLength != other.byteLength) ||
1244
+ (object.byteOffset != other.byteOffset)) {
1245
+ return false;
1246
+ }
1247
+ object = object.buffer;
1248
+ other = other.buffer;
1249
+
1250
+ case arrayBufferTag:
1251
+ if ((object.byteLength != other.byteLength) ||
1252
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1253
+ return false;
1254
+ }
1255
+ return true;
1256
+
1257
+ case boolTag:
1258
+ case dateTag:
1259
+ case numberTag:
1260
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
1261
+ // Invalid dates are coerced to `NaN`.
1262
+ return eq(+object, +other);
1263
+
1264
+ case errorTag:
1265
+ return object.name == other.name && object.message == other.message;
1266
+
1267
+ case regexpTag:
1268
+ case stringTag:
1269
+ // Coerce regexes to strings and treat strings, primitives and objects,
1270
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1271
+ // for more details.
1272
+ return object == (other + '');
1273
+
1274
+ case mapTag:
1275
+ var convert = mapToArray;
1276
+
1277
+ case setTag:
1278
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
1279
+ convert || (convert = setToArray);
1280
+
1281
+ if (object.size != other.size && !isPartial) {
1282
+ return false;
1283
+ }
1284
+ // Assume cyclic values are equal.
1285
+ var stacked = stack.get(object);
1286
+ if (stacked) {
1287
+ return stacked == other;
1288
+ }
1289
+ bitmask |= COMPARE_UNORDERED_FLAG;
1290
+
1291
+ // Recursively compare objects (susceptible to call stack limits).
1292
+ stack.set(object, other);
1293
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
1294
+ stack['delete'](object);
1295
+ return result;
1296
+
1297
+ case symbolTag:
1298
+ if (symbolValueOf) {
1299
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
1300
+ }
1301
+ }
1302
+ return false;
1303
+ }
1304
+
1305
+ /**
1306
+ * A specialized version of `baseIsEqualDeep` for objects with support for
1307
+ * partial deep comparisons.
1308
+ *
1309
+ * @private
1310
+ * @param {Object} object The object to compare.
1311
+ * @param {Object} other The other object to compare.
1312
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1313
+ * @param {Function} customizer The function to customize comparisons.
1314
+ * @param {Function} equalFunc The function to determine equivalents of values.
1315
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1316
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1317
+ */
1318
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1319
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1320
+ objProps = getAllKeys(object),
1321
+ objLength = objProps.length,
1322
+ othProps = getAllKeys(other),
1323
+ othLength = othProps.length;
1324
+
1325
+ if (objLength != othLength && !isPartial) {
1326
+ return false;
1327
+ }
1328
+ var index = objLength;
1329
+ while (index--) {
1330
+ var key = objProps[index];
1331
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1332
+ return false;
1333
+ }
1334
+ }
1335
+ // Assume cyclic values are equal.
1336
+ var stacked = stack.get(object);
1337
+ if (stacked && stack.get(other)) {
1338
+ return stacked == other;
1339
+ }
1340
+ var result = true;
1341
+ stack.set(object, other);
1342
+ stack.set(other, object);
1343
+
1344
+ var skipCtor = isPartial;
1345
+ while (++index < objLength) {
1346
+ key = objProps[index];
1347
+ var objValue = object[key],
1348
+ othValue = other[key];
1349
+
1350
+ if (customizer) {
1351
+ var compared = isPartial
1352
+ ? customizer(othValue, objValue, key, other, object, stack)
1353
+ : customizer(objValue, othValue, key, object, other, stack);
1354
+ }
1355
+ // Recursively compare objects (susceptible to call stack limits).
1356
+ if (!(compared === undefined
1357
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1358
+ : compared
1359
+ )) {
1360
+ result = false;
1361
+ break;
1362
+ }
1363
+ skipCtor || (skipCtor = key == 'constructor');
1364
+ }
1365
+ if (result && !skipCtor) {
1366
+ var objCtor = object.constructor,
1367
+ othCtor = other.constructor;
1368
+
1369
+ // Non `Object` object instances with different constructors are not equal.
1370
+ if (objCtor != othCtor &&
1371
+ ('constructor' in object && 'constructor' in other) &&
1372
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1373
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1374
+ result = false;
1375
+ }
1376
+ }
1377
+ stack['delete'](object);
1378
+ stack['delete'](other);
1379
+ return result;
1380
+ }
1381
+
1382
+ /**
1383
+ * Creates an array of own enumerable property names and symbols of `object`.
1384
+ *
1385
+ * @private
1386
+ * @param {Object} object The object to query.
1387
+ * @returns {Array} Returns the array of property names and symbols.
1388
+ */
1389
+ function getAllKeys(object) {
1390
+ return baseGetAllKeys(object, keys, getSymbols);
1391
+ }
1392
+
1393
+ /**
1394
+ * Gets the data for `map`.
1395
+ *
1396
+ * @private
1397
+ * @param {Object} map The map to query.
1398
+ * @param {string} key The reference key.
1399
+ * @returns {*} Returns the map data.
1400
+ */
1401
+ function getMapData(map, key) {
1402
+ var data = map.__data__;
1403
+ return isKeyable(key)
1404
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1405
+ : data.map;
1406
+ }
1407
+
1408
+ /**
1409
+ * Gets the native function at `key` of `object`.
1410
+ *
1411
+ * @private
1412
+ * @param {Object} object The object to query.
1413
+ * @param {string} key The key of the method to get.
1414
+ * @returns {*} Returns the function if it's native, else `undefined`.
1415
+ */
1416
+ function getNative(object, key) {
1417
+ var value = getValue(object, key);
1418
+ return baseIsNative(value) ? value : undefined;
1419
+ }
1420
+
1421
+ /**
1422
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1423
+ *
1424
+ * @private
1425
+ * @param {*} value The value to query.
1426
+ * @returns {string} Returns the raw `toStringTag`.
1427
+ */
1428
+ function getRawTag(value) {
1429
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
1430
+ tag = value[symToStringTag];
1431
+
1432
+ try {
1433
+ value[symToStringTag] = undefined;
1434
+ var unmasked = true;
1435
+ } catch (e) {}
1436
+
1437
+ var result = nativeObjectToString.call(value);
1438
+ if (unmasked) {
1439
+ if (isOwn) {
1440
+ value[symToStringTag] = tag;
1441
+ } else {
1442
+ delete value[symToStringTag];
1443
+ }
1444
+ }
1445
+ return result;
1446
+ }
1447
+
1448
+ /**
1449
+ * Creates an array of the own enumerable symbols of `object`.
1450
+ *
1451
+ * @private
1452
+ * @param {Object} object The object to query.
1453
+ * @returns {Array} Returns the array of symbols.
1454
+ */
1455
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1456
+ if (object == null) {
1457
+ return [];
1458
+ }
1459
+ object = Object(object);
1460
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
1461
+ return propertyIsEnumerable.call(object, symbol);
1462
+ });
1463
+ };
1464
+
1465
+ /**
1466
+ * Gets the `toStringTag` of `value`.
1467
+ *
1468
+ * @private
1469
+ * @param {*} value The value to query.
1470
+ * @returns {string} Returns the `toStringTag`.
1471
+ */
1472
+ var getTag = baseGetTag;
1473
+
1474
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1475
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1476
+ (Map && getTag(new Map) != mapTag) ||
1477
+ (Promise && getTag(Promise.resolve()) != promiseTag) ||
1478
+ (Set && getTag(new Set) != setTag) ||
1479
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1480
+ getTag = function(value) {
1481
+ var result = baseGetTag(value),
1482
+ Ctor = result == objectTag ? value.constructor : undefined,
1483
+ ctorString = Ctor ? toSource(Ctor) : '';
1484
+
1485
+ if (ctorString) {
1486
+ switch (ctorString) {
1487
+ case dataViewCtorString: return dataViewTag;
1488
+ case mapCtorString: return mapTag;
1489
+ case promiseCtorString: return promiseTag;
1490
+ case setCtorString: return setTag;
1491
+ case weakMapCtorString: return weakMapTag;
1492
+ }
1493
+ }
1494
+ return result;
1495
+ };
1496
+ }
1497
+
1498
+ /**
1499
+ * Checks if `value` is a valid array-like index.
1500
+ *
1501
+ * @private
1502
+ * @param {*} value The value to check.
1503
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1504
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1505
+ */
1506
+ function isIndex(value, length) {
1507
+ length = length == null ? MAX_SAFE_INTEGER : length;
1508
+ return !!length &&
1509
+ (typeof value == 'number' || reIsUint.test(value)) &&
1510
+ (value > -1 && value % 1 == 0 && value < length);
1511
+ }
1512
+
1513
+ /**
1514
+ * Checks if `value` is suitable for use as unique object key.
1515
+ *
1516
+ * @private
1517
+ * @param {*} value The value to check.
1518
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1519
+ */
1520
+ function isKeyable(value) {
1521
+ var type = typeof value;
1522
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1523
+ ? (value !== '__proto__')
1524
+ : (value === null);
1525
+ }
1526
+
1527
+ /**
1528
+ * Checks if `func` has its source masked.
1529
+ *
1530
+ * @private
1531
+ * @param {Function} func The function to check.
1532
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1533
+ */
1534
+ function isMasked(func) {
1535
+ return !!maskSrcKey && (maskSrcKey in func);
1536
+ }
1537
+
1538
+ /**
1539
+ * Checks if `value` is likely a prototype object.
1540
+ *
1541
+ * @private
1542
+ * @param {*} value The value to check.
1543
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1544
+ */
1545
+ function isPrototype(value) {
1546
+ var Ctor = value && value.constructor,
1547
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1548
+
1549
+ return value === proto;
1550
+ }
1551
+
1552
+ /**
1553
+ * Converts `value` to a string using `Object.prototype.toString`.
1554
+ *
1555
+ * @private
1556
+ * @param {*} value The value to convert.
1557
+ * @returns {string} Returns the converted string.
1558
+ */
1559
+ function objectToString(value) {
1560
+ return nativeObjectToString.call(value);
1561
+ }
1562
+
1563
+ /**
1564
+ * Converts `func` to its source code.
1565
+ *
1566
+ * @private
1567
+ * @param {Function} func The function to convert.
1568
+ * @returns {string} Returns the source code.
1569
+ */
1570
+ function toSource(func) {
1571
+ if (func != null) {
1572
+ try {
1573
+ return funcToString.call(func);
1574
+ } catch (e) {}
1575
+ try {
1576
+ return (func + '');
1577
+ } catch (e) {}
1578
+ }
1579
+ return '';
1580
+ }
1581
+
1582
+ /**
1583
+ * Performs a
1584
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1585
+ * comparison between two values to determine if they are equivalent.
1586
+ *
1587
+ * @static
1588
+ * @memberOf _
1589
+ * @since 4.0.0
1590
+ * @category Lang
1591
+ * @param {*} value The value to compare.
1592
+ * @param {*} other The other value to compare.
1593
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1594
+ * @example
1595
+ *
1596
+ * var object = { 'a': 1 };
1597
+ * var other = { 'a': 1 };
1598
+ *
1599
+ * _.eq(object, object);
1600
+ * // => true
1601
+ *
1602
+ * _.eq(object, other);
1603
+ * // => false
1604
+ *
1605
+ * _.eq('a', 'a');
1606
+ * // => true
1607
+ *
1608
+ * _.eq('a', Object('a'));
1609
+ * // => false
1610
+ *
1611
+ * _.eq(NaN, NaN);
1612
+ * // => true
1613
+ */
1614
+ function eq(value, other) {
1615
+ return value === other || (value !== value && other !== other);
1616
+ }
1617
+
1618
+ /**
1619
+ * Checks if `value` is likely an `arguments` object.
1620
+ *
1621
+ * @static
1622
+ * @memberOf _
1623
+ * @since 0.1.0
1624
+ * @category Lang
1625
+ * @param {*} value The value to check.
1626
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1627
+ * else `false`.
1628
+ * @example
1629
+ *
1630
+ * _.isArguments(function() { return arguments; }());
1631
+ * // => true
1632
+ *
1633
+ * _.isArguments([1, 2, 3]);
1634
+ * // => false
1635
+ */
1636
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1637
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
1638
+ !propertyIsEnumerable.call(value, 'callee');
1639
+ };
1640
+
1641
+ /**
1642
+ * Checks if `value` is classified as an `Array` object.
1643
+ *
1644
+ * @static
1645
+ * @memberOf _
1646
+ * @since 0.1.0
1647
+ * @category Lang
1648
+ * @param {*} value The value to check.
1649
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1650
+ * @example
1651
+ *
1652
+ * _.isArray([1, 2, 3]);
1653
+ * // => true
1654
+ *
1655
+ * _.isArray(document.body.children);
1656
+ * // => false
1657
+ *
1658
+ * _.isArray('abc');
1659
+ * // => false
1660
+ *
1661
+ * _.isArray(_.noop);
1662
+ * // => false
1663
+ */
1664
+ var isArray = Array.isArray;
1665
+
1666
+ /**
1667
+ * Checks if `value` is array-like. A value is considered array-like if it's
1668
+ * not a function and has a `value.length` that's an integer greater than or
1669
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1670
+ *
1671
+ * @static
1672
+ * @memberOf _
1673
+ * @since 4.0.0
1674
+ * @category Lang
1675
+ * @param {*} value The value to check.
1676
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1677
+ * @example
1678
+ *
1679
+ * _.isArrayLike([1, 2, 3]);
1680
+ * // => true
1681
+ *
1682
+ * _.isArrayLike(document.body.children);
1683
+ * // => true
1684
+ *
1685
+ * _.isArrayLike('abc');
1686
+ * // => true
1687
+ *
1688
+ * _.isArrayLike(_.noop);
1689
+ * // => false
1690
+ */
1691
+ function isArrayLike(value) {
1692
+ return value != null && isLength(value.length) && !isFunction(value);
1693
+ }
1694
+
1695
+ /**
1696
+ * Checks if `value` is a buffer.
1697
+ *
1698
+ * @static
1699
+ * @memberOf _
1700
+ * @since 4.3.0
1701
+ * @category Lang
1702
+ * @param {*} value The value to check.
1703
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1704
+ * @example
1705
+ *
1706
+ * _.isBuffer(new Buffer(2));
1707
+ * // => true
1708
+ *
1709
+ * _.isBuffer(new Uint8Array(2));
1710
+ * // => false
1711
+ */
1712
+ var isBuffer = nativeIsBuffer || stubFalse;
1713
+
1714
+ /**
1715
+ * Performs a deep comparison between two values to determine if they are
1716
+ * equivalent.
1717
+ *
1718
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
1719
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
1720
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
1721
+ * by their own, not inherited, enumerable properties. Functions and DOM
1722
+ * nodes are compared by strict equality, i.e. `===`.
1723
+ *
1724
+ * @static
1725
+ * @memberOf _
1726
+ * @since 0.1.0
1727
+ * @category Lang
1728
+ * @param {*} value The value to compare.
1729
+ * @param {*} other The other value to compare.
1730
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1731
+ * @example
1732
+ *
1733
+ * var object = { 'a': 1 };
1734
+ * var other = { 'a': 1 };
1735
+ *
1736
+ * _.isEqual(object, other);
1737
+ * // => true
1738
+ *
1739
+ * object === other;
1740
+ * // => false
1741
+ */
1742
+ function isEqual(value, other) {
1743
+ return baseIsEqual(value, other);
1744
+ }
1745
+
1746
+ /**
1747
+ * Checks if `value` is classified as a `Function` object.
1748
+ *
1749
+ * @static
1750
+ * @memberOf _
1751
+ * @since 0.1.0
1752
+ * @category Lang
1753
+ * @param {*} value The value to check.
1754
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1755
+ * @example
1756
+ *
1757
+ * _.isFunction(_);
1758
+ * // => true
1759
+ *
1760
+ * _.isFunction(/abc/);
1761
+ * // => false
1762
+ */
1763
+ function isFunction(value) {
1764
+ if (!isObject(value)) {
1765
+ return false;
1766
+ }
1767
+ // The use of `Object#toString` avoids issues with the `typeof` operator
1768
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
1769
+ var tag = baseGetTag(value);
1770
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
1771
+ }
1772
+
1773
+ /**
1774
+ * Checks if `value` is a valid array-like length.
1775
+ *
1776
+ * **Note:** This method is loosely based on
1777
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1778
+ *
1779
+ * @static
1780
+ * @memberOf _
1781
+ * @since 4.0.0
1782
+ * @category Lang
1783
+ * @param {*} value The value to check.
1784
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1785
+ * @example
1786
+ *
1787
+ * _.isLength(3);
1788
+ * // => true
1789
+ *
1790
+ * _.isLength(Number.MIN_VALUE);
1791
+ * // => false
1792
+ *
1793
+ * _.isLength(Infinity);
1794
+ * // => false
1795
+ *
1796
+ * _.isLength('3');
1797
+ * // => false
1798
+ */
1799
+ function isLength(value) {
1800
+ return typeof value == 'number' &&
1801
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1802
+ }
1803
+
1804
+ /**
1805
+ * Checks if `value` is the
1806
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1807
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1808
+ *
1809
+ * @static
1810
+ * @memberOf _
1811
+ * @since 0.1.0
1812
+ * @category Lang
1813
+ * @param {*} value The value to check.
1814
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1815
+ * @example
1816
+ *
1817
+ * _.isObject({});
1818
+ * // => true
1819
+ *
1820
+ * _.isObject([1, 2, 3]);
1821
+ * // => true
1822
+ *
1823
+ * _.isObject(_.noop);
1824
+ * // => true
1825
+ *
1826
+ * _.isObject(null);
1827
+ * // => false
1828
+ */
1829
+ function isObject(value) {
1830
+ var type = typeof value;
1831
+ return value != null && (type == 'object' || type == 'function');
1832
+ }
1833
+
1834
+ /**
1835
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
1836
+ * and has a `typeof` result of "object".
1837
+ *
1838
+ * @static
1839
+ * @memberOf _
1840
+ * @since 4.0.0
1841
+ * @category Lang
1842
+ * @param {*} value The value to check.
1843
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1844
+ * @example
1845
+ *
1846
+ * _.isObjectLike({});
1847
+ * // => true
1848
+ *
1849
+ * _.isObjectLike([1, 2, 3]);
1850
+ * // => true
1851
+ *
1852
+ * _.isObjectLike(_.noop);
1853
+ * // => false
1854
+ *
1855
+ * _.isObjectLike(null);
1856
+ * // => false
1857
+ */
1858
+ function isObjectLike(value) {
1859
+ return value != null && typeof value == 'object';
1860
+ }
1861
+
1862
+ /**
1863
+ * Checks if `value` is classified as a typed array.
1864
+ *
1865
+ * @static
1866
+ * @memberOf _
1867
+ * @since 3.0.0
1868
+ * @category Lang
1869
+ * @param {*} value The value to check.
1870
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1871
+ * @example
1872
+ *
1873
+ * _.isTypedArray(new Uint8Array);
1874
+ * // => true
1875
+ *
1876
+ * _.isTypedArray([]);
1877
+ * // => false
1878
+ */
1879
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1880
+
1881
+ /**
1882
+ * Creates an array of the own enumerable property names of `object`.
1883
+ *
1884
+ * **Note:** Non-object values are coerced to objects. See the
1885
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1886
+ * for more details.
1887
+ *
1888
+ * @static
1889
+ * @since 0.1.0
1890
+ * @memberOf _
1891
+ * @category Object
1892
+ * @param {Object} object The object to query.
1893
+ * @returns {Array} Returns the array of property names.
1894
+ * @example
1895
+ *
1896
+ * function Foo() {
1897
+ * this.a = 1;
1898
+ * this.b = 2;
1899
+ * }
1900
+ *
1901
+ * Foo.prototype.c = 3;
1902
+ *
1903
+ * _.keys(new Foo);
1904
+ * // => ['a', 'b'] (iteration order is not guaranteed)
1905
+ *
1906
+ * _.keys('hi');
1907
+ * // => ['0', '1']
1908
+ */
1909
+ function keys(object) {
1910
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1911
+ }
1912
+
1913
+ /**
1914
+ * This method returns a new empty array.
1915
+ *
1916
+ * @static
1917
+ * @memberOf _
1918
+ * @since 4.13.0
1919
+ * @category Util
1920
+ * @returns {Array} Returns the new empty array.
1921
+ * @example
1922
+ *
1923
+ * var arrays = _.times(2, _.stubArray);
1924
+ *
1925
+ * console.log(arrays);
1926
+ * // => [[], []]
1927
+ *
1928
+ * console.log(arrays[0] === arrays[1]);
1929
+ * // => false
1930
+ */
1931
+ function stubArray() {
1932
+ return [];
1933
+ }
1934
+
1935
+ /**
1936
+ * This method returns `false`.
1937
+ *
1938
+ * @static
1939
+ * @memberOf _
1940
+ * @since 4.13.0
1941
+ * @category Util
1942
+ * @returns {boolean} Returns `false`.
1943
+ * @example
1944
+ *
1945
+ * _.times(2, _.stubFalse);
1946
+ * // => [false, false]
1947
+ */
1948
+ function stubFalse() {
1949
+ return false;
1950
+ }
1951
+
1952
+ module.exports = isEqual;
1953
+ });
1954
+
1955
+ function checkDotNet() {
1956
+ if (typeof window.parent.chrome === 'undefined') {
1957
+ console.error('[POLLINATION-DEBUG]: chrome not found.');
1958
+ return false;
1959
+ }
1960
+ if (typeof window.parent.chrome.webview === 'undefined') {
1961
+ console.error('[POLLINATION-DEBUG]: webview not found.');
1962
+ return false;
1963
+ }
1964
+ return true;
1965
+ }
1966
+ function checkRuby() {
1967
+ if (typeof window.sketchup === 'undefined') {
1968
+ console.error('[POLLINATION-DEBUG]: sketchup not found.');
1969
+ return false;
1970
+ }
1971
+ return true;
1972
+ }
1973
+ function sendMessageDotNet(message) {
1974
+ if (!checkDotNet())
1975
+ return undefined;
1976
+ var json = JSON.stringify(message);
1977
+ window.parent.chrome.webview.postMessage(json)
1978
+ .catch(function (e) {
1979
+ throw new Error(e);
1980
+ });
1981
+ return message;
1982
+ }
1983
+ function sendMessageRuby(message) {
1984
+ if (!checkRuby())
1985
+ return undefined;
1986
+ // const json = JSON.stringify(message)
1987
+ console.error('[POLLINATION-DEBUG]: sendMesssageRuby not yet implemented');
1988
+ return message;
1989
+ }
1990
+ function subscribeDotNet(interval) {
1991
+ if (interval === void 0) { interval = 1000; }
1992
+ if (!checkDotNet)
1993
+ return undefined;
1994
+ if (!window.parent.chrome.webview.hostObjects ||
1995
+ !window.parent.chrome.webview.hostObjects.sync ||
1996
+ !window.parent.chrome.webview.hostObjects.PassHBJSON) {
1997
+ console.error('[POLLINATION-DEBUG]: hostObjects.sync.PassHBJSON not configured correctly');
1998
+ return;
1999
+ }
2000
+ var subscribe = function (setState) { return setInterval(function () {
2001
+ var token = window.parent.chrome.webview.hostObjects.sync.hbjson.PassHBJSON();
2002
+ setState(token);
2003
+ }, interval); };
2004
+ return subscribe;
2005
+ }
2006
+ // not sure if this will work from Streamlit?
2007
+ function getHost(key, defaultValue) {
2008
+ if (key === void 0) { key = '__host__'; }
2009
+ if (defaultValue === void 0) { defaultValue = 'web'; }
2010
+ // getting stored value
2011
+ var retrieved = localStorage.getItem(key);
2012
+ if (!retrieved)
2013
+ return defaultValue;
2014
+ return typeof retrieved === 'string' ? retrieved.toLocaleLowerCase() : JSON.parse(retrieved).toLocaleLowerCase();
2015
+ }
2016
+
2017
+ var useGetHBJSON = function () {
2018
+ var host = getHost();
2019
+ var _a = useState(), messageResponse = _a[0], setMessageResponse = _a[1];
2020
+ var _b = useState(undefined), hbjson = _b[0], setHbjson = _b[1];
2021
+ var rubyGetHBJSON = useCallback(function (key, selection, isPollinationModel) {
2022
+ if (key === void 0) { key = ''; }
2023
+ if (selection === void 0) { selection = false; }
2024
+ if (isPollinationModel === void 0) { isPollinationModel = false; }
2025
+ if (!checkRuby())
2026
+ return;
2027
+ // ruby invoke
2028
+ if (isPollinationModel) {
2029
+ window.parent.sketchup.get_model(selection, {
2030
+ onCompleted: function (res) {
2031
+ var message = JSON.parse(res);
2032
+ setMessageResponse(function (state) { return (__assign(__assign({}, state), { geometry: message.Geometry, identifier: message.Identifier })); });
2033
+ }
2034
+ });
2035
+ }
2036
+ else {
2037
+ window.parent.sketchup.get_geometry(key, selection, {
2038
+ onCompleted: function (res) {
2039
+ var message = JSON.parse(res);
2040
+ setMessageResponse(function (state) { return (__assign(__assign({}, state), { geometry: message.Geometry, identifier: message.Identifier })); });
2041
+ }
2042
+ });
2043
+ }
2044
+ }, []);
2045
+ var dotNetGetHBJSON = useCallback(function (key, selection, isPollinationModel) {
2046
+ if (key === void 0) { key = ''; }
2047
+ if (selection === void 0) { selection = false; }
2048
+ if (isPollinationModel === void 0) { isPollinationModel = false; }
2049
+ if (!checkDotNet())
2050
+ return;
2051
+ var res = {
2052
+ Geometry: null,
2053
+ Identifier: null
2054
+ };
2055
+ if (isPollinationModel) {
2056
+ // @ts-ignore
2057
+ res = window.parent.chrome.webview
2058
+ .hostObjects.sync.hbjson.PassPollinationModel(selection);
2059
+ setMessageResponse(function (state) { return (__assign(__assign({}, state), { geometry: res.Geometry, identifier: res.Identifier })); });
2060
+ }
2061
+ else {
2062
+ // @ts-ignore
2063
+ res = window.parent.chrome.webview.hostObjects.sync.geometry.PassJsonGeometry(key, selection);
2064
+ setMessageResponse(function (state) { return (__assign(__assign({}, state), { geometry: res.Geometry, identifier: res.Identifier })); });
2065
+ }
2066
+ }, []);
2067
+ useEffect(function () {
2068
+ if (!messageResponse)
2069
+ return;
2070
+ // @ts-ignore
2071
+ var bytes = new TextEncoder().encode(messageResponse.geometry);
2072
+ if (hbjson) {
2073
+ hbjson.arrayBuffer().then(function (data) {
2074
+ if (!lodash_isequal(bytes, new Uint8Array(data))) {
2075
+ setHbjson(new Blob([bytes], {
2076
+ type: 'application/json;charset=utf-8',
2077
+ }));
2078
+ }
2079
+ });
2080
+ }
2081
+ else {
2082
+ setHbjson(new Blob([bytes], {
2083
+ type: 'application/json;charset=utf-8',
2084
+ }));
2085
+ }
2086
+ }, [messageResponse]);
2087
+ var handler = useMemo(function () {
2088
+ switch (host) {
2089
+ case 'sketchup':
2090
+ return rubyGetHBJSON;
2091
+ case 'rhino':
2092
+ return dotNetGetHBJSON;
2093
+ default:
2094
+ return undefined;
2095
+ }
2096
+ }, [host, dotNetGetHBJSON, rubyGetHBJSON]);
2097
+ return {
2098
+ host: host,
2099
+ hbjson: hbjson,
2100
+ handler: handler,
2101
+ };
2102
+ };
2103
+
2104
+ var useRunCommand = function () {
2105
+ var host = getHost();
2106
+ var rhinoRunCommand = useCallback(function (commandString, commandOptions) {
2107
+ var msgObject = {
2108
+ action: 'RunCommand',
2109
+ commandString: commandString,
2110
+ };
2111
+ sendMessageDotNet(msgObject);
2112
+ }, []);
2113
+ var runCommand = useMemo(function () {
2114
+ switch (host) {
2115
+ case 'rhino':
2116
+ return rhinoRunCommand;
2117
+ default:
2118
+ return undefined;
2119
+ }
2120
+ }, [host, rhinoRunCommand]);
2121
+ return {
2122
+ host: host,
2123
+ runCommand: runCommand
2124
+ };
2125
+ };
2126
+
2127
+ var useSendCheckbox = function (_a) {
2128
+ _a.action; _a.data; _a.uniqueId; _a.options; _a.platform; _a.isFocused;
2129
+ var host = getHost();
2130
+ var _b = useState({}); _b[0]; _b[1];
2131
+ return ({
2132
+ host: host
2133
+ });
2134
+ };
2135
+
2136
+ var useSendGeometry = function () {
2137
+ var host = getHost();
2138
+ var _a = useState({}), state = _a[0], setState = _a[1];
2139
+ var rubySendGeometry = useCallback(function (message) {
2140
+ var response = sendMessageRuby(message);
2141
+ setState(function (state) { return (__assign(__assign({}, state), { response: response })); });
2142
+ return response;
2143
+ }, []);
2144
+ var dotNetSendGeometry = useCallback(function (message) {
2145
+ var response = sendMessageDotNet(message);
2146
+ setState(function (state) { return (__assign(__assign({}, state), { response: response })); });
2147
+ return response;
2148
+ }, []);
2149
+ var sendGeometry = useMemo(function () {
2150
+ switch (host) {
2151
+ case 'sketchup':
2152
+ return rubySendGeometry;
2153
+ case 'rhino':
2154
+ return dotNetSendGeometry;
2155
+ case 'revit':
2156
+ return dotNetSendGeometry;
2157
+ default:
2158
+ return undefined;
2159
+ }
2160
+ }, [dotNetSendGeometry, host, rubySendGeometry]);
2161
+ return ({
2162
+ host: host,
2163
+ state: state,
2164
+ sendGeometry: sendGeometry
2165
+ });
2166
+ };
2167
+
2168
+ var useSendSettings = function () {
2169
+ var host = getHost();
2170
+ var rhinoSendSettings = useCallback(function (settings) {
2171
+ var message = {
2172
+ action: 'SetModelSettings',
2173
+ data: settings
2174
+ };
2175
+ return sendMessageDotNet(message);
2176
+ }, []);
2177
+ var sendSettings = useMemo(function () {
2178
+ switch (host) {
2179
+ case 'rhino':
2180
+ return rhinoSendSettings;
2181
+ default:
2182
+ return undefined;
2183
+ }
2184
+ }, [host, rhinoSendSettings]);
2185
+ return ({
2186
+ host: host,
2187
+ sendSettings: sendSettings,
2188
+ });
2189
+ };
2190
+
2191
+ var UTILSENDPOINT = process.env.REACT_APP_UTILS_ENDPOINT || 'https://utilities.staging.pollination.cloud';
2192
+ var useHBJSONtoVTK = function () {
2193
+ var _a = useState(false), loading = _a[0], setLoading = _a[1];
2194
+ var _b = useState(), vtk = _b[0], setVTK = _b[1];
2195
+ var fetchVTK = function (hbjson) {
2196
+ if (!hbjson || hbjson.size < 1)
2197
+ return undefined;
2198
+ setLoading(true);
2199
+ return hbjson.text().then(function (fileString) {
2200
+ fetch(UTILSENDPOINT + "/hbjson-to-vtk", {
2201
+ method: 'POST',
2202
+ headers: {
2203
+ 'Content-Type': 'application/json',
2204
+ 'Accept': '*/*',
2205
+ },
2206
+ body: "{\n \"output_format\": \"vtkjs\",\n \"hbjson\": " + fileString + "\n }"
2207
+ })
2208
+ .catch(function (e) {
2209
+ throw new Error(e);
2210
+ })
2211
+ .then(function (res) { return __awaiter(void 0, void 0, void 0, function () {
2212
+ var translatedFile;
2213
+ return __generator(this, function (_a) {
2214
+ switch (_a.label) {
2215
+ case 0:
2216
+ if (!res.ok) return [3 /*break*/, 2];
2217
+ return [4 /*yield*/, res.blob()];
2218
+ case 1:
2219
+ translatedFile = _a.sent();
2220
+ setVTK(translatedFile);
2221
+ return [2 /*return*/, translatedFile
2222
+ // viewerRef.current.loadFile(translatedFile, 'vtkjs')
2223
+ ];
2224
+ case 2: throw new Error('Failed to retrieve .vtkjs from .hbjson file.Error translating hbjson to vtkjs');
2225
+ }
2226
+ });
2227
+ }); })
2228
+ .finally(function () {
2229
+ setLoading(false);
2230
+ });
2231
+ });
2232
+ };
2233
+ return {
2234
+ loading: loading,
2235
+ vtk: vtk,
2236
+ fetchVTK: fetchVTK
2237
+ };
2238
+ };
2239
+
2240
+ export { checkDotNet, checkRuby, getHost, sendMessageDotNet, sendMessageRuby, subscribeDotNet, useGetHBJSON, useHBJSONtoVTK, useRunCommand, useSendCheckbox, useSendGeometry, useSendSettings };
2241
+ //# sourceMappingURL=index.esm.js.map