@luxonis/visualizer-protobuf 2.16.2 → 2.18.0

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 (76) hide show
  1. package/dist/FoxgloveServer-C39Uooyk.js +1172 -0
  2. package/dist/{WorkerImageDecoder.worker-DCoSYoLL.js → WorkerImageDecoder.worker-tkX9-IYo.js} +3 -2
  3. package/dist/_commonjsHelpers-E-ZsRS8r.js +32 -0
  4. package/dist/{comlink-D0blLC4P.js → comlink-DHMAu6X7.js} +1 -1
  5. package/dist/{communicator-CkB-oBVq.js → communicator-D49kmBTQ.js} +1 -1
  6. package/dist/{decodeImage-NYPkamnK.js → decodeImage-C8kB6T3V.js} +1 -1
  7. package/dist/deserialization.worker-DsG76nP8.js +1326 -0
  8. package/dist/{foxglove-protocol-RZlF5fna.js → foxglove-protocol-CYoMweAY.js} +1 -1
  9. package/dist/{i18next-C5Qe4-E1.js → i18next-IYI3-Nuv.js} +1624 -3124
  10. package/dist/{i420ToRgbaToPoitcloud.worker-CQFm7P7B.js → i420ToRgbaToPoitcloud.worker-CzFC0VI1.js} +1 -1
  11. package/dist/{index-_CotNV5x.js → index-4PQpGzhb.js} +10 -8
  12. package/dist/{index-C8kEVNt8.js → index-BFMXTxLw.js} +10 -8
  13. package/dist/{index-D7BaFI3k.js → index-BQecGu9I.js} +10 -8
  14. package/dist/{index-BFmZhB_k.js → index-BT9CBn7l.js} +2663 -2658
  15. package/dist/{index-CGZy-t2h.js → index-BWittpbR.js} +10 -8
  16. package/dist/{index-BRyhvg1u.js → index-BeQ1w8aW.js} +10 -8
  17. package/dist/{index-B-NuHgKz.js → index-BomoqOv5.js} +10 -8
  18. package/dist/{index-qRQvVkdj.js → index-ByIsztCr.js} +10 -8
  19. package/dist/{index-C7bn4vhH.js → index-CJRhjhJ0.js} +10 -8
  20. package/dist/{index-De_-85Dx.js → index-CR6XGTJc.js} +26206 -31958
  21. package/dist/{index-BflsEH7y.js → index-CXIVXFcJ.js} +13 -10
  22. package/dist/{index-DeqZpaJF.js → index-CXThSQcL.js} +10 -8
  23. package/dist/{index-BA7oWwVg.js → index-CcIi7pJR.js} +10 -8
  24. package/dist/{index-BDNOxLbq.js → index-CcP1Qppv.js} +10 -8
  25. package/dist/{index-BsSLQ0Qh.js → index-Ci0X5xT3.js} +10 -8
  26. package/dist/{index-D_n427cy.js → index-CrtBH66u.js} +10 -8
  27. package/dist/{index--q0v8_7h.js → index-DUUnuN10.js} +10 -8
  28. package/dist/{index-C3EAt3Mi.js → index-DchGURxJ.js} +10 -8
  29. package/dist/{index-Cls5O6Ds.js → index-DdKOhCXT.js} +10 -8
  30. package/dist/index.js +10 -8
  31. package/dist/isArrayLikeObject-Bytw9p-q.js +1503 -0
  32. package/dist/lib/src/components/Panel.d.ts +1 -0
  33. package/dist/lib/src/components/Panel.d.ts.map +1 -1
  34. package/dist/lib/src/components/Panel.js +2 -2
  35. package/dist/lib/src/components/Panel.js.map +1 -1
  36. package/dist/lib/src/components/PanelToolbar.d.ts +1 -0
  37. package/dist/lib/src/components/PanelToolbar.d.ts.map +1 -1
  38. package/dist/lib/src/components/PanelToolbar.js +6 -3
  39. package/dist/lib/src/components/PanelToolbar.js.map +1 -1
  40. package/dist/lib/src/components/measure-render-delay.d.ts.map +1 -1
  41. package/dist/lib/src/components/measure-render-delay.js +5 -0
  42. package/dist/lib/src/components/measure-render-delay.js.map +1 -1
  43. package/dist/lib/src/messaging/{deserialization.d.ts → deserialization.worker.d.ts} +6 -2
  44. package/dist/lib/src/messaging/deserialization.worker.d.ts.map +1 -0
  45. package/dist/lib/src/messaging/{deserialization.js → deserialization.worker.js} +28 -3
  46. package/dist/lib/src/messaging/deserialization.worker.js.map +1 -0
  47. package/dist/lib/src/messaging/message-handler.d.ts.map +1 -1
  48. package/dist/lib/src/messaging/message-handler.js +14 -20
  49. package/dist/lib/src/messaging/message-handler.js.map +1 -1
  50. package/dist/lib/src/panels/ImagePanel.d.ts +3 -5
  51. package/dist/lib/src/panels/ImagePanel.d.ts.map +1 -1
  52. package/dist/lib/src/panels/ImagePanel.js +1 -0
  53. package/dist/lib/src/panels/ImagePanel.js.map +1 -1
  54. package/dist/lib/src/panels/PointCloudPanel.d.ts +2 -0
  55. package/dist/lib/src/panels/PointCloudPanel.d.ts.map +1 -1
  56. package/dist/lib/src/panels/PointCloudPanel.js +29 -4
  57. package/dist/lib/src/panels/PointCloudPanel.js.map +1 -1
  58. package/dist/lib/src/utils/poitcloud-sync.d.ts.map +1 -1
  59. package/dist/lib/src/utils/poitcloud-sync.js +5 -2
  60. package/dist/lib/src/utils/poitcloud-sync.js.map +1 -1
  61. package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.d.ts.map +1 -1
  62. package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.js +3 -0
  63. package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.js.map +1 -1
  64. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/CameraStateSettings.js +2 -2
  65. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/CameraStateSettings.js.map +1 -1
  66. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/ImageMode.d.ts.map +1 -1
  67. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/ImageMode.js +0 -1
  68. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/ImageMode.js.map +1 -1
  69. package/dist/{FoxgloveServer-DiLI7KZU.js → protobuf-Cr0sn6Ua.js} +996 -2196
  70. package/dist/tslib.es6-D98N6tjc.js +4116 -0
  71. package/dist/useMessageReducer-Cg30zaG9.js +422 -0
  72. package/dist/{worker-CtuCYYTr.js → worker-B5OJw-Fq.js} +5 -3
  73. package/dist/{worker-Bd7K1fGT.js → worker-aVL4LGa3.js} +5 -3
  74. package/package.json +1 -1
  75. package/dist/lib/src/messaging/deserialization.d.ts.map +0 -1
  76. package/dist/lib/src/messaging/deserialization.js.map +0 -1
@@ -0,0 +1,4116 @@
1
+ import { w as wrap } from './comlink-DHMAu6X7.js';
2
+ import { useContext, useRef, useLayoutEffect, createContext, useReducer, useState, useCallback } from 'react';
3
+ import { isParent, getLeaves, createRemoveUpdate, updateTree, getNodeAtPath } from 'react-mosaic-component';
4
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-E-ZsRS8r.js';
5
+ import { useTheme } from '@mui/material';
6
+ import { k as isObjectLike, l as baseGetTag, S as Symbol$1, i as isArray, m as getNative, r as root, n as overArg, g as isPrototype, c as isArrayLike, p as arrayLikeKeys, M as MapCache, f as isArguments, t as toSource, q as Map$1, u as eq, U as Uint8Array$1, d as isBuffer, v as Stack, e as isTypedArray, h as isObject, w as isLength, j as isIndex, x as identity, y as baseFor, b as baseRest, a as isArrayLikeObject } from './isArrayLikeObject-Bytw9p-q.js';
7
+
8
+ var dist = {};
9
+
10
+ var Time = {};
11
+
12
+ Object.defineProperty(Time, "__esModule", { value: true });
13
+
14
+ var timeUtils = {};
15
+
16
+ // This Source Code Form is subject to the terms of the Mozilla Public
17
+ // License, v2.0. If a copy of the MPL was not distributed with this
18
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
19
+ //
20
+ // This file incorporates work covered by the following copyright and
21
+ // permission notice:
22
+ //
23
+ // Copyright 2018-2021 Cruise LLC
24
+ //
25
+ // This source code is licensed under the Apache License, Version 2.0,
26
+ // found at http://www.apache.org/licenses/LICENSE-2.0
27
+ // You may not use this file except in compliance with the License.
28
+ Object.defineProperty(timeUtils, "__esModule", { value: true });
29
+ timeUtils.areEqual = timeUtils.isGreaterThan = timeUtils.isLessThan = timeUtils.compare = timeUtils.isTimeInRangeInclusive = timeUtils.clampTime = timeUtils.fromMicros = timeUtils.fromMillis = timeUtils.toMillis = timeUtils.fromNanoSec = timeUtils.fromSec = timeUtils.toSec = timeUtils.toMicroSec = timeUtils.toNanoSec = timeUtils.subtract = timeUtils.add = timeUtils.fixTime = timeUtils.interpolate = timeUtils.percentOf = timeUtils.fromDate = timeUtils.toDate = timeUtils.fromRFC3339String = timeUtils.toRFC3339String = timeUtils.fromString = timeUtils.toString = timeUtils.isTime = void 0;
30
+ /**
31
+ * Test if a given object matches the signature of { sec: number; nsec: number }
32
+ * @param obj Object to test
33
+ * @returns True if the object is equivalent to a Time object, otherwise false
34
+ */
35
+ function isTime(obj) {
36
+ return (typeof obj === "object" &&
37
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
38
+ !!obj &&
39
+ "sec" in obj &&
40
+ "nsec" in obj &&
41
+ Object.getOwnPropertyNames(obj).length === 2);
42
+ }
43
+ timeUtils.isTime = isTime;
44
+ /**
45
+ * Converts a Time to a string containing a floating point number of seconds
46
+ * @param stamp Time to convert
47
+ * @param allowNegative Allow negative times to be converted
48
+ * @returns String timestamp containing a floating point number of seconds
49
+ */
50
+ function toString$1(stamp, allowNegative = false) {
51
+ if (!allowNegative && (stamp.sec < 0 || stamp.nsec < 0)) {
52
+ throw new Error(`Invalid negative time { sec: ${stamp.sec}, nsec: ${stamp.nsec} }`);
53
+ }
54
+ const sec = Math.floor(stamp.sec);
55
+ const nsec = Math.floor(stamp.nsec);
56
+ return `${sec}.${nsec.toFixed().padStart(9, "0")}`;
57
+ }
58
+ timeUtils.toString = toString$1;
59
+ /**
60
+ * Parse fractional seconds (digits following a decimal separator ".") and interpret them as an
61
+ * integer number of nanoseconds. Because of the rounding behavior, this function may return 1e9 (a
62
+ * value that would be too large for the `nsec` field).
63
+ */
64
+ function parseNanoseconds(digits) {
65
+ // There can be 9 digits of nanoseconds. If the fractional part is "1", we need to add eight
66
+ // zeros. Also, make sure we round to an integer if we need to _remove_ digits.
67
+ const digitsShort = 9 - digits.length;
68
+ return Math.round(parseInt(digits, 10) * 10 ** digitsShort);
69
+ }
70
+ /**
71
+ * Converts a string containing floating point number of seconds to a Time. We use a string because
72
+ * nanosecond precision cannot be stored in a 64-bit float for large values (e.g. UNIX timestamps).
73
+ * @param stamp UNIX timestamp containing a whole or floating point number of seconds
74
+ * @returns Time object on success, undefined on failure
75
+ */
76
+ function fromString(stamp) {
77
+ if (/^\d+\.?$/.test(stamp)) {
78
+ // Whole number with optional "." at the end.
79
+ const sec = parseInt(stamp, 10);
80
+ return { sec: isNaN(sec) ? 0 : sec, nsec: 0 };
81
+ }
82
+ if (!/^\d+\.\d+$/.test(stamp)) {
83
+ // Not digits.digits -- invalid.
84
+ return undefined;
85
+ }
86
+ const partials = stamp.split(".");
87
+ if (partials.length === 0) {
88
+ return undefined;
89
+ }
90
+ const [first, second] = partials;
91
+ if (first == undefined || second == undefined) {
92
+ return undefined;
93
+ }
94
+ // It's possible we rounded to { sec: 1, nsec: 1e9 }, which is invalid, so fixTime.
95
+ const sec = parseInt(first, 10);
96
+ const nsec = parseNanoseconds(second);
97
+ return fixTime({ sec: isNaN(sec) ? 0 : sec, nsec });
98
+ }
99
+ timeUtils.fromString = fromString;
100
+ /**
101
+ * Converts a Time to a string compatible with RFC3339/ISO8601. Similar to
102
+ * `toDate(stamp).toISOString()`, but with nanosecond precision.
103
+ * @param stamp Time to convert
104
+ */
105
+ function toRFC3339String(stamp) {
106
+ if (stamp.sec < 0 || stamp.nsec < 0) {
107
+ throw new Error(`Invalid negative time { sec: ${stamp.sec}, nsec: ${stamp.nsec} }`);
108
+ }
109
+ if (stamp.nsec >= 1e9) {
110
+ throw new Error(`Invalid nanosecond value ${stamp.nsec}`);
111
+ }
112
+ const date = new Date(stamp.sec * 1000);
113
+ const year = date.getUTCFullYear();
114
+ const month = (date.getUTCMonth() + 1).toFixed().padStart(2, "0");
115
+ const day = date.getUTCDate().toFixed().padStart(2, "0");
116
+ const hour = date.getUTCHours().toFixed().padStart(2, "0");
117
+ const minute = date.getUTCMinutes().toFixed().padStart(2, "0");
118
+ const second = date.getUTCSeconds().toFixed().padStart(2, "0");
119
+ const nanosecond = stamp.nsec.toFixed().padStart(9, "0");
120
+ return `${year}-${month}-${day}T${hour}:${minute}:${second}.${nanosecond}Z`;
121
+ }
122
+ timeUtils.toRFC3339String = toRFC3339String;
123
+ /**
124
+ * Parses a Time from a string compatible with a subset of ISO8601/RFC3339. Similar to
125
+ * `fromDate(new Date(string))`, but with nanosecond precision.
126
+ * @param stamp Time to convert
127
+ */
128
+ function fromRFC3339String(stamp) {
129
+ const match = /^(\d{4,})-(\d\d)-(\d\d)[Tt](\d\d):(\d\d):(\d\d)(?:\.(\d+))?(?:[Zz]|([+-])(\d\d):(\d\d))$/.exec(stamp);
130
+ if (match == null) {
131
+ return undefined;
132
+ }
133
+ const [, year, month, day, hour, minute, second, frac, plusMinus, offHours, offMinutes] = match;
134
+ const offSign = plusMinus === "-" ? -1 : 1;
135
+ const utcMillis = Date.UTC(+year, +month - 1, +day, +hour - offSign * +(offHours ?? 0), +minute - offSign * +(offMinutes ?? 0), +second);
136
+ if (utcMillis % 1000 !== 0) {
137
+ return undefined;
138
+ }
139
+ // It's possible we rounded to { sec: 1, nsec: 1e9 }, which is invalid, so fixTime.
140
+ return fixTime({
141
+ sec: utcMillis / 1000,
142
+ nsec: frac != undefined ? parseNanoseconds(frac) : 0,
143
+ });
144
+ }
145
+ timeUtils.fromRFC3339String = fromRFC3339String;
146
+ /**
147
+ * Convert a Time to a JavaScript Date object. NOTE: sub-millisecond precision is lost.
148
+ * @param stamp Time to convert
149
+ * @returns Date representing the given Time as accurately as it can
150
+ */
151
+ function toDate(stamp) {
152
+ const { sec, nsec } = stamp;
153
+ return new Date(sec * 1000 + nsec / 1e6);
154
+ }
155
+ timeUtils.toDate = toDate;
156
+ /**
157
+ * Conver a JavaScript Date object to a Time.
158
+ * @param date Date to convert
159
+ * @returns Time representing the given Date
160
+ */
161
+ function fromDate(date) {
162
+ const millis = date.getTime();
163
+ const remainder = millis % 1000;
164
+ return { sec: Math.floor(millis / 1000), nsec: remainder * 1e6 };
165
+ }
166
+ timeUtils.fromDate = fromDate;
167
+ /**
168
+ * Returns the fraction representing target's position in the range between start and end.
169
+ * e.g. start = { sec: 0 }, end = { sec: 10 }, target = { sec: 5 } = 0.5
170
+ * This is the reverse of the `interpolate()` method
171
+ * @param start Start timestamp of the interpolation range
172
+ * @param end End timestamp of the interpolation range
173
+ * @param target Timestamp that will be measured relative to the interpolation range
174
+ * @returns If target falls in between start and end (inclusive), it will be in the range [0.0-1.0].
175
+ * Otherwise, it is unbounded
176
+ */
177
+ function percentOf(start, end, target) {
178
+ const totalDuration = subtract(end, start);
179
+ const targetDuration = subtract(target, start);
180
+ return toSec(targetDuration) / toSec(totalDuration);
181
+ }
182
+ timeUtils.percentOf = percentOf;
183
+ /**
184
+ * Linearly interpolate the range between start and end by a given fraction.
185
+ * e.g. start = { sec: 0 }, end = { sec: 10 }, fraction = 0.5 = { sec: 5 }
186
+ * This is the reverse of the `percentOf` method
187
+ * @param start Start timestamp of the interpolation range
188
+ * @param end End timestamp of the interpolation range
189
+ * @param fraction Percent to interpolate along the range
190
+ * @returns If fraction is in the range [0.0-1.0], the target will fall in between start and end\
191
+ * (inclusive). Otherwise, it is unbounded
192
+ */
193
+ function interpolate(start, end, fraction) {
194
+ const duration = subtract(end, start);
195
+ return add(start, fromSec(fraction * toSec(duration)));
196
+ }
197
+ timeUtils.interpolate = interpolate;
198
+ /**
199
+ * Equivalent to fromNanoSec(toNanoSec(t)), but no chance of precision loss. nsec should be
200
+ * non-negative, and less than 1e9.
201
+ * @param t Potentially un-normalized time with the nsec (nanoseconds) value containing a value
202
+ * higher than one second (1e9)
203
+ * @param allowNegative Allow negative times to be normalized
204
+ * @returns A normalized Time
205
+ */
206
+ function fixTime(t, allowNegative = false) {
207
+ const durationNanos = t.nsec;
208
+ const secsFromNanos = Math.floor(durationNanos / 1e9);
209
+ const newSecs = t.sec + secsFromNanos;
210
+ const remainingDurationNanos = durationNanos % 1e9;
211
+ // use Math.abs here to prevent -0 when there is exactly 1 second of negative nanoseconds passed in
212
+ const newNanos = Math.abs(Math.sign(remainingDurationNanos) === -1
213
+ ? 1e9 + remainingDurationNanos
214
+ : remainingDurationNanos);
215
+ const result = { sec: newSecs, nsec: newNanos };
216
+ if ((!allowNegative && result.sec < 0) || result.nsec < 0) {
217
+ throw new Error(`Cannot normalize invalid time ${toString$1(result, true)}`);
218
+ }
219
+ return result;
220
+ }
221
+ timeUtils.fixTime = fixTime;
222
+ /**
223
+ * Add two Times together
224
+ * @param param0 First Time
225
+ * @param param1 Second Time
226
+ * @returns A normalized representation of the two Time objects added together
227
+ */
228
+ function add({ sec: sec1, nsec: nsec1 }, { sec: sec2, nsec: nsec2 }) {
229
+ return fixTime({ sec: sec1 + sec2, nsec: nsec1 + nsec2 });
230
+ }
231
+ timeUtils.add = add;
232
+ /**
233
+ * Subtract one Time from another
234
+ * @param param0 First Time
235
+ * @param param1 Time to subtract from the first Time
236
+ * @returns A normalized representation of the second Time subtracted from the first
237
+ */
238
+ function subtract({ sec: sec1, nsec: nsec1 }, { sec: sec2, nsec: nsec2 }) {
239
+ return fixTime({ sec: sec1 - sec2, nsec: nsec1 - nsec2 }, true);
240
+ }
241
+ timeUtils.subtract = subtract;
242
+ /**
243
+ * Convert Time to an integer number of nanoseconds
244
+ * @param param0 Time to convert
245
+ * @returns A bigint integer number of nanoseconds
246
+ */
247
+ function toNanoSec({ sec, nsec }) {
248
+ return BigInt(sec) * 1000000000n + BigInt(nsec);
249
+ }
250
+ timeUtils.toNanoSec = toNanoSec;
251
+ /**
252
+ * Convert Time to a floating point number of microseconds
253
+ * @param param0 Time to convert
254
+ * @returns A floating point number of microseconds
255
+ */
256
+ function toMicroSec({ sec, nsec }) {
257
+ return (sec * 1e9 + nsec) / 1000;
258
+ }
259
+ timeUtils.toMicroSec = toMicroSec;
260
+ /**
261
+ * Convert Time to a floating point number of seconds
262
+ * @param param0 Time to convert
263
+ * @returns A floating point number of seconds
264
+ */
265
+ function toSec({ sec, nsec }) {
266
+ return sec + nsec * 1e-9;
267
+ }
268
+ timeUtils.toSec = toSec;
269
+ /**
270
+ * Convert a floating point number of seconds to Time
271
+ * @param value Number of seconds
272
+ * @returns Time object
273
+ */
274
+ function fromSec(value) {
275
+ // From https://github.com/ros/roscpp_core/blob/indigo-devel/rostime/include/ros/time.h#L153
276
+ let sec = Math.trunc(value);
277
+ let nsec = Math.round((value - sec) * 1e9);
278
+ sec += Math.trunc(nsec / 1e9);
279
+ nsec %= 1e9;
280
+ return { sec, nsec };
281
+ }
282
+ timeUtils.fromSec = fromSec;
283
+ /**
284
+ * Convert an integer number of nanoseconds to Time
285
+ * @param nsec Nanoseconds integer
286
+ * @returns Time object
287
+ */
288
+ function fromNanoSec(nsec) {
289
+ // From https://github.com/ros/roscpp_core/blob/86720717c0e1200234cc0a3545a255b60fb541ec/rostime/include/ros/impl/time.h#L63
290
+ // and https://github.com/ros/roscpp_core/blob/7583b7d38c6e1c2e8623f6d98559c483f7a64c83/rostime/src/time.cpp#L536
291
+ //
292
+ // Note: BigInt(1e9) is slower than writing out the number
293
+ return { sec: Number(nsec / 1000000000n), nsec: Number(nsec % 1000000000n) };
294
+ }
295
+ timeUtils.fromNanoSec = fromNanoSec;
296
+ /**
297
+ * Convert Time to an integer number of milliseconds
298
+ * @param time Time to convert
299
+ * @param roundUp Round up to nearest millisecond if true, otherwise round down. Defaults to true
300
+ * @returns Integer number of milliseconds
301
+ */
302
+ function toMillis(time, roundUp = true) {
303
+ const secondsMillis = time.sec * 1e3;
304
+ const nsecMillis = time.nsec / 1e6;
305
+ return roundUp ? secondsMillis + Math.ceil(nsecMillis) : secondsMillis + Math.floor(nsecMillis);
306
+ }
307
+ timeUtils.toMillis = toMillis;
308
+ /**
309
+ * Convert milliseconds to Time
310
+ * @param value Milliseconds number
311
+ * @returns Time object
312
+ */
313
+ function fromMillis(value) {
314
+ let sec = Math.trunc(value / 1000);
315
+ let nsec = Math.round((value - sec * 1000) * 1e6);
316
+ sec += Math.trunc(nsec / 1e9);
317
+ nsec %= 1e9;
318
+ return { sec, nsec };
319
+ }
320
+ timeUtils.fromMillis = fromMillis;
321
+ /**
322
+ * Convert microseconds to Time
323
+ * @param value Microseconds number
324
+ * @returns Time object
325
+ */
326
+ function fromMicros(value) {
327
+ let sec = Math.trunc(value / 1e6);
328
+ let nsec = Math.round((value - sec * 1e6) * 1e3);
329
+ sec += Math.trunc(nsec / 1e9);
330
+ nsec %= 1e9;
331
+ return { sec, nsec };
332
+ }
333
+ timeUtils.fromMicros = fromMicros;
334
+ /**
335
+ * Clamp a given time value in the range from start to end (inclusive)
336
+ * @param time Time to clamp
337
+ * @param start Start of the target range
338
+ * @param end End of the target range
339
+ * @returns Clamped Time
340
+ */
341
+ function clampTime(time, start, end) {
342
+ if (compare(start, time) > 0) {
343
+ return { sec: start.sec, nsec: start.nsec };
344
+ }
345
+ if (compare(end, time) < 0) {
346
+ return { sec: end.sec, nsec: end.nsec };
347
+ }
348
+ return { sec: time.sec, nsec: time.nsec };
349
+ }
350
+ timeUtils.clampTime = clampTime;
351
+ /**
352
+ * Test if a given time is inside a test range
353
+ * @param time Time to test
354
+ * @param start Start of the test range
355
+ * @param end End of the test range
356
+ * @returns True if time falls in between start and end (inclusive)
357
+ */
358
+ function isTimeInRangeInclusive(time, start, end) {
359
+ if (compare(start, time) > 0 || compare(end, time) < 0) {
360
+ return false;
361
+ }
362
+ return true;
363
+ }
364
+ timeUtils.isTimeInRangeInclusive = isTimeInRangeInclusive;
365
+ /**
366
+ * Comparison function for Time object that can be used for sorting
367
+ * @param left First Time to compare
368
+ * @param right Second Time to compare
369
+ * @returns A positive value if left is larger than right, a negative value if right is larger than
370
+ * left, or zero if both times are equal
371
+ */
372
+ function compare(left, right) {
373
+ const secDiff = left.sec - right.sec;
374
+ return secDiff !== 0 ? secDiff : left.nsec - right.nsec;
375
+ }
376
+ timeUtils.compare = compare;
377
+ /**
378
+ * Returns true if the left time is less than the right time, otherwise false
379
+ * @param left Left side of comparison
380
+ * @param right Right side of comparison
381
+ * @returns Comparison result
382
+ */
383
+ function isLessThan(left, right) {
384
+ return compare(left, right) < 0;
385
+ }
386
+ timeUtils.isLessThan = isLessThan;
387
+ /**
388
+ * Returns true if the left time is greater than the right time, otherwise false
389
+ * @param left Left side of the comparison
390
+ * @param right Right side of the comparison
391
+ * @returns Comparison result
392
+ */
393
+ function isGreaterThan(left, right) {
394
+ return compare(left, right) > 0;
395
+ }
396
+ timeUtils.isGreaterThan = isGreaterThan;
397
+ /**
398
+ * Returns true if both times have the same number of seconds and nanoseconds
399
+ * @param left Left side of the comparison
400
+ * @param right Right side of the comparison
401
+ * @returns Equality result
402
+ */
403
+ function areEqual(left, right) {
404
+ return left.sec === right.sec && left.nsec === right.nsec;
405
+ }
406
+ timeUtils.areEqual = areEqual;
407
+
408
+ (function (exports) {
409
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
410
+ if (k2 === undefined) k2 = k;
411
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
412
+ }) : (function(o, m, k, k2) {
413
+ if (k2 === undefined) k2 = k;
414
+ o[k2] = m[k];
415
+ }));
416
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
417
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
418
+ };
419
+ Object.defineProperty(exports, "__esModule", { value: true });
420
+ __exportStar(Time, exports);
421
+ __exportStar(timeUtils, exports);
422
+
423
+ } (dist));
424
+
425
+ // This Source Code Form is subject to the terms of the Mozilla Public
426
+ // License, v2.0. If a copy of the MPL was not distributed with this
427
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
428
+
429
+ // logger channel -> logger
430
+ const channels = new Map();
431
+ const noop$1 = () => {};
432
+ class Logger {
433
+ // default logger has an empty name
434
+ static default = new Logger("");
435
+ #name;
436
+
437
+ // all new loggers are created from the default logger
438
+ constructor(name) {
439
+ this.#name = name;
440
+ this.setLevel("debug");
441
+ channels.set(name, this);
442
+ }
443
+
444
+ // fully qualified name for the logger
445
+ name() {
446
+ return this.#name;
447
+ }
448
+
449
+ /**
450
+ * Return true if the level would display when logged by the logger
451
+ */
452
+ isLevelOn(level) {
453
+ switch (level) {
454
+ case "debug":
455
+ return this.debug !== noop$1;
456
+ case "info":
457
+ return this.info !== noop$1;
458
+ case "warn":
459
+ return this.warn !== noop$1;
460
+ case "error":
461
+ return this.error !== noop$1;
462
+ }
463
+ return false;
464
+ }
465
+
466
+ /**
467
+ *
468
+ * @returns the current log level
469
+ */
470
+ getLevel() {
471
+ if (this.debug !== noop$1) {
472
+ return "debug";
473
+ } else if (this.info !== noop$1) {
474
+ return "info";
475
+ } else if (this.warn !== noop$1) {
476
+ return "warn";
477
+ } else {
478
+ return "error";
479
+ }
480
+ }
481
+
482
+ /**
483
+ * Set the allowed log level. Any log calls with severity "below" this one will be ignored.
484
+ *
485
+ * i.e. setting a level of "warn" will ignore any "info" or "debug" logs
486
+ */
487
+ setLevel(level) {
488
+ this.debug = noop$1;
489
+ this.info = noop$1;
490
+ this.warn = noop$1;
491
+ this.error = noop$1;
492
+ switch (level) {
493
+ case "debug":
494
+ this.debug = console.debug.bind(global.console);
495
+ this.info = console.info.bind(global.console);
496
+ this.warn = console.warn.bind(global.console);
497
+ this.error = console.error.bind(global.console);
498
+ break;
499
+ case "info":
500
+ this.info = console.info.bind(global.console);
501
+ this.warn = console.warn.bind(global.console);
502
+ this.error = console.error.bind(global.console);
503
+ break;
504
+ case "warn":
505
+ this.warn = console.warn.bind(global.console);
506
+ this.error = console.error.bind(global.console);
507
+ break;
508
+ case "error":
509
+ this.error = console.error.bind(global.console);
510
+ break;
511
+ }
512
+ }
513
+ debug(..._args) {}
514
+ info(..._args) {}
515
+ warn(..._args) {}
516
+ error(..._args) {}
517
+
518
+ // create a new logger under this logger's namespace
519
+ getLogger(name) {
520
+ const shortName = name.replace(/^.+\.(asar|webpack)[\\/\\]/, "").replace(/^(\.\.\/)+/, "");
521
+ const channelName = this.#name.length > 0 ? `${this.#name}.${shortName}` : shortName;
522
+ const existing = channels.get(channelName);
523
+ if (existing) {
524
+ return existing;
525
+ }
526
+ const logger = new Logger(channelName);
527
+ channels.set(channelName, logger);
528
+ return logger;
529
+ }
530
+
531
+ // get all logging channels
532
+ channels() {
533
+ return Array.from(channels.values());
534
+ }
535
+ }
536
+ var Logger$1 = Logger.default;
537
+
538
+ // This Source Code Form is subject to the terms of the Mozilla Public
539
+ // License, v2.0. If a copy of the MPL was not distributed with this
540
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
541
+
542
+ const log$6 = Logger$1.getLogger("src/index.ts");
543
+ /**
544
+ * Values of the contants below are a (more or less) informed guesses and not guaranteed to be accurate.
545
+ */
546
+ const COMPRESSED_POINTER_SIZE = 4; // Pointers use 4 bytes (also on 64-bit systems) due to pointer compression
547
+ const OBJECT_BASE_SIZE = 3 * COMPRESSED_POINTER_SIZE; // 3 compressed pointers
548
+ // Arrays have an additional length property (1 pointer) and a backing store header (2 pointers)
549
+ // See https://stackoverflow.com/a/70550693.
550
+ const ARRAY_BASE_SIZE = OBJECT_BASE_SIZE + 3 * COMPRESSED_POINTER_SIZE;
551
+ const TYPED_ARRAY_BASE_SIZE = 25 * COMPRESSED_POINTER_SIZE; // byteLength, byteOffset, ..., see https://stackoverflow.com/a/45808835
552
+ const SMALL_INTEGER_SIZE = COMPRESSED_POINTER_SIZE; // Small integers (up to 31 bits), pointer tagging
553
+ const HEAP_NUMBER_SIZE = 8 + 2 * COMPRESSED_POINTER_SIZE; // 4-byte map pointer + 8-byte payload + property pointer
554
+ const MAX_NUM_FAST_PROPERTIES = 1020;
555
+
556
+ /**
557
+ * Estimate the size in bytes of an arbitrary object or primitive.
558
+ * @param obj Object or primitive to estimate the size for
559
+ * @returns Estimated size in bytes
560
+ */
561
+ function estimateObjectSize(obj) {
562
+ // catches null and undefined
563
+ // typeof null == "object"
564
+ if (obj == undefined) {
565
+ return SMALL_INTEGER_SIZE;
566
+ }
567
+ switch (typeof obj) {
568
+ case "undefined":
569
+ case "boolean":
570
+ {
571
+ return SMALL_INTEGER_SIZE;
572
+ }
573
+ case "number":
574
+ {
575
+ return Number.isInteger(obj) ? SMALL_INTEGER_SIZE : HEAP_NUMBER_SIZE;
576
+ }
577
+ case "bigint":
578
+ {
579
+ return HEAP_NUMBER_SIZE;
580
+ }
581
+ case "string":
582
+ {
583
+ // The string length is rounded up to the next multiple of 4.
584
+ return COMPRESSED_POINTER_SIZE + OBJECT_BASE_SIZE + Math.ceil(obj.length / 4) * 4;
585
+ }
586
+ case "object":
587
+ {
588
+ if (Array.isArray(obj)) {
589
+ return COMPRESSED_POINTER_SIZE + ARRAY_BASE_SIZE + Object.values(obj).reduce((acc, val) => acc + estimateObjectSize(val), 0);
590
+ } else if (ArrayBuffer.isView(obj)) {
591
+ return TYPED_ARRAY_BASE_SIZE + obj.byteLength;
592
+ } else if (obj instanceof Set) {
593
+ return COMPRESSED_POINTER_SIZE + OBJECT_BASE_SIZE + Array.from(obj.values()).reduce((acc, val) => acc + estimateObjectSize(val), 0);
594
+ } else if (obj instanceof Map) {
595
+ return COMPRESSED_POINTER_SIZE + OBJECT_BASE_SIZE + Array.from(obj.entries()).reduce((acc, [key, val]) => acc + estimateObjectSize(key) + estimateObjectSize(val), 0);
596
+ }
597
+ let propertiesSize = 0;
598
+ const numProps = Object.keys(obj).length;
599
+ if (numProps > MAX_NUM_FAST_PROPERTIES) {
600
+ // If there are too many properties, V8 stores Objects in dictionary mode (slow properties)
601
+ // with each object having a self-contained dictionary. This dictionary contains the key, value
602
+ // and details of properties. Below we estimate the size of this additional dictionary. Formula
603
+ // adapted from
604
+ // medium.com/@bpmxmqd/v8-engine-jsobject-structure-analysis-and-memory-optimization-ideas-be30cfcdcd16
605
+ const propertiesDictSize = 16 + 5 * 8 + 2 ** Math.ceil(Math.log2((numProps + 2) * 1.5)) * 3 * 4;
606
+ // In return, properties are no longer stored in the properties array, so we subtract that.
607
+ propertiesSize = propertiesDictSize - numProps * COMPRESSED_POINTER_SIZE;
608
+ }
609
+ const valuesSize = Object.values(obj).reduce((acc, val) => acc + estimateObjectSize(val), 0);
610
+ return OBJECT_BASE_SIZE + propertiesSize + valuesSize;
611
+ }
612
+ case "symbol":
613
+ case "function":
614
+ {
615
+ throw new Error(`Can't estimate size of type '${typeof obj}'`);
616
+ }
617
+ }
618
+ log$6.error(`Can't estimate size of type '${typeof obj}'`);
619
+ return SMALL_INTEGER_SIZE;
620
+ }
621
+
622
+ // This Source Code Form is subject to the terms of the Mozilla Public
623
+ // License, v2.0. If a copy of the MPL was not distributed with this
624
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
625
+ /// <reference types="@webgpu/types" />
626
+ function uint8ArrayToUint16Array(uint8Array) {
627
+ if (uint8Array.length % 2 !== 0) {
628
+ throw new Error("Uint8Array length must be a multiple of 2 for conversion to Uint16Array");
629
+ }
630
+ const uint16Array = new Uint16Array(uint8Array.length / 2);
631
+ for (let i = 0; i < uint16Array.length; i++) {
632
+ const lowByte = uint8Array[i * 2];
633
+ const highByte = uint8Array[i * 2 + 1];
634
+
635
+ // eslint-disable-next-line @foxglove/strict-equality
636
+ if (highByte === undefined || lowByte === undefined) {
637
+ throw new Error("Invalid data in uint8Array");
638
+ }
639
+ uint16Array[i] = highByte << 8 | lowByte;
640
+ }
641
+ return uint16Array;
642
+ }
643
+ const worker = new Worker(new URL("i420ToRgbaToPoitcloud.worker-CzFC0VI1.js", import.meta.url), {
644
+ type: "module"
645
+ });
646
+ const workerApi = wrap(worker);
647
+ async function i420ToRgbaToPointcloudWorker(i420Data, i420Width, i420Height, depthWidth, depthHeight, data) {
648
+ return await workerApi.i420ToRgbaToPointcloud(i420Data, i420Width, i420Height, depthWidth, depthHeight, data);
649
+ }
650
+
651
+ // This Source Code Form is subject to the terms of the Mozilla Public
652
+ // License, v2.0. If a copy of the MPL was not distributed with this
653
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
654
+
655
+ const globalWithHandler = global;
656
+
657
+ /**
658
+ * Report an error that has escaped past normal error-handling flows in the app and should be
659
+ * triaged and diagnosed.
660
+ */
661
+ function reportError(error) {
662
+ globalWithHandler.foxgloveStudioReportErrorFn?.(error);
663
+ }
664
+
665
+ // This Source Code Form is subject to the terms of the Mozilla Public
666
+ // License, v2.0. If a copy of the MPL was not distributed with this
667
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
668
+ //
669
+ // This file incorporates work covered by the following copyright and
670
+ // permission notice:
671
+ //
672
+ // Copyright 2019-2021 Cruise LLC
673
+ //
674
+ // This source code is licensed under the Apache License, Version 2.0,
675
+ // found at http://www.apache.org/licenses/LICENSE-2.0
676
+ // You may not use this file except in compliance with the License.
677
+
678
+ class AppError extends Error {
679
+ constructor(details, extraInfo) {
680
+ super();
681
+ this.details = details;
682
+ this.extraInfo = extraInfo;
683
+ this.name = "AppError";
684
+ this.message = "";
685
+ if (details instanceof Error) {
686
+ this.message = details.stack ?? details.message;
687
+ } else if (typeof details === "string") {
688
+ this.message = details;
689
+ }
690
+ if (extraInfo != undefined) {
691
+ // If `extraInfo` was passed via a componentDidCatch:
692
+ // https://reactjs.org/docs/react-component.html#componentdidcatch
693
+ if (extraInfo.componentStack != undefined) {
694
+ this.message += `\n\n${extraInfo.componentStack}`;
695
+ } else {
696
+ try {
697
+ const stringifiedExtraInfo = JSON.stringify(extraInfo);
698
+ this.message += `\n\n${stringifiedExtraInfo}`;
699
+ } catch (e) {
700
+ this.message += `\n\n[ Either cyclic object or object with BigInt(s) ]`;
701
+ }
702
+ }
703
+ }
704
+ if (this.message === "") {
705
+ this.message = "Unknown Error";
706
+ }
707
+ }
708
+ }
709
+
710
+ /** `Object#toString` result references. */
711
+ var symbolTag$1 = '[object Symbol]';
712
+
713
+ /**
714
+ * Checks if `value` is classified as a `Symbol` primitive or object.
715
+ *
716
+ * @static
717
+ * @memberOf _
718
+ * @since 4.0.0
719
+ * @category Lang
720
+ * @param {*} value The value to check.
721
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
722
+ * @example
723
+ *
724
+ * _.isSymbol(Symbol.iterator);
725
+ * // => true
726
+ *
727
+ * _.isSymbol('abc');
728
+ * // => false
729
+ */
730
+ function isSymbol(value) {
731
+ return typeof value == 'symbol' ||
732
+ (isObjectLike(value) && baseGetTag(value) == symbolTag$1);
733
+ }
734
+
735
+ /**
736
+ * A specialized version of `_.map` for arrays without support for iteratee
737
+ * shorthands.
738
+ *
739
+ * @private
740
+ * @param {Array} [array] The array to iterate over.
741
+ * @param {Function} iteratee The function invoked per iteration.
742
+ * @returns {Array} Returns the new mapped array.
743
+ */
744
+ function arrayMap(array, iteratee) {
745
+ var index = -1,
746
+ length = array == null ? 0 : array.length,
747
+ result = Array(length);
748
+
749
+ while (++index < length) {
750
+ result[index] = iteratee(array[index], index, array);
751
+ }
752
+ return result;
753
+ }
754
+
755
+ /** Used as references for various `Number` constants. */
756
+ var INFINITY$2 = 1 / 0;
757
+
758
+ /** Used to convert symbols to primitives and strings. */
759
+ var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined,
760
+ symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
761
+
762
+ /**
763
+ * The base implementation of `_.toString` which doesn't convert nullish
764
+ * values to empty strings.
765
+ *
766
+ * @private
767
+ * @param {*} value The value to process.
768
+ * @returns {string} Returns the string.
769
+ */
770
+ function baseToString(value) {
771
+ // Exit early for strings to avoid a performance hit in some environments.
772
+ if (typeof value == 'string') {
773
+ return value;
774
+ }
775
+ if (isArray(value)) {
776
+ // Recursively convert values (susceptible to call stack limits).
777
+ return arrayMap(value, baseToString) + '';
778
+ }
779
+ if (isSymbol(value)) {
780
+ return symbolToString ? symbolToString.call(value) : '';
781
+ }
782
+ var result = (value + '');
783
+ return (result == '0' && (1 / value) == -INFINITY$2) ? '-0' : result;
784
+ }
785
+
786
+ /* Built-in method references that are verified to be native. */
787
+ var WeakMap = getNative(root, 'WeakMap');
788
+
789
+ /**
790
+ * This method returns `undefined`.
791
+ *
792
+ * @static
793
+ * @memberOf _
794
+ * @since 2.3.0
795
+ * @category Util
796
+ * @example
797
+ *
798
+ * _.times(2, _.noop);
799
+ * // => [undefined, undefined]
800
+ */
801
+ function noop() {
802
+ // No operation performed.
803
+ }
804
+
805
+ /**
806
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
807
+ * support for iteratee shorthands.
808
+ *
809
+ * @private
810
+ * @param {Array} array The array to inspect.
811
+ * @param {Function} predicate The function invoked per iteration.
812
+ * @param {number} fromIndex The index to search from.
813
+ * @param {boolean} [fromRight] Specify iterating from right to left.
814
+ * @returns {number} Returns the index of the matched value, else `-1`.
815
+ */
816
+ function baseFindIndex(array, predicate, fromIndex, fromRight) {
817
+ var length = array.length,
818
+ index = fromIndex + (-1);
819
+
820
+ while ((++index < length)) {
821
+ if (predicate(array[index], index, array)) {
822
+ return index;
823
+ }
824
+ }
825
+ return -1;
826
+ }
827
+
828
+ /**
829
+ * The base implementation of `_.isNaN` without support for number objects.
830
+ *
831
+ * @private
832
+ * @param {*} value The value to check.
833
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
834
+ */
835
+ function baseIsNaN(value) {
836
+ return value !== value;
837
+ }
838
+
839
+ /**
840
+ * A specialized version of `_.indexOf` which performs strict equality
841
+ * comparisons of values, i.e. `===`.
842
+ *
843
+ * @private
844
+ * @param {Array} array The array to inspect.
845
+ * @param {*} value The value to search for.
846
+ * @param {number} fromIndex The index to search from.
847
+ * @returns {number} Returns the index of the matched value, else `-1`.
848
+ */
849
+ function strictIndexOf(array, value, fromIndex) {
850
+ var index = fromIndex - 1,
851
+ length = array.length;
852
+
853
+ while (++index < length) {
854
+ if (array[index] === value) {
855
+ return index;
856
+ }
857
+ }
858
+ return -1;
859
+ }
860
+
861
+ /**
862
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
863
+ *
864
+ * @private
865
+ * @param {Array} array The array to inspect.
866
+ * @param {*} value The value to search for.
867
+ * @param {number} fromIndex The index to search from.
868
+ * @returns {number} Returns the index of the matched value, else `-1`.
869
+ */
870
+ function baseIndexOf(array, value, fromIndex) {
871
+ return value === value
872
+ ? strictIndexOf(array, value, fromIndex)
873
+ : baseFindIndex(array, baseIsNaN, fromIndex);
874
+ }
875
+
876
+ /**
877
+ * A specialized version of `_.includes` for arrays without support for
878
+ * specifying an index to search from.
879
+ *
880
+ * @private
881
+ * @param {Array} [array] The array to inspect.
882
+ * @param {*} target The value to search for.
883
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
884
+ */
885
+ function arrayIncludes(array, value) {
886
+ var length = array == null ? 0 : array.length;
887
+ return !!length && baseIndexOf(array, value, 0) > -1;
888
+ }
889
+
890
+ /* Built-in method references for those with the same name as other `lodash` methods. */
891
+ var nativeKeys = overArg(Object.keys, Object);
892
+
893
+ /** Used for built-in method references. */
894
+ var objectProto$3 = Object.prototype;
895
+
896
+ /** Used to check objects for own properties. */
897
+ var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
898
+
899
+ /**
900
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
901
+ *
902
+ * @private
903
+ * @param {Object} object The object to query.
904
+ * @returns {Array} Returns the array of property names.
905
+ */
906
+ function baseKeys(object) {
907
+ if (!isPrototype(object)) {
908
+ return nativeKeys(object);
909
+ }
910
+ var result = [];
911
+ for (var key in Object(object)) {
912
+ if (hasOwnProperty$2.call(object, key) && key != 'constructor') {
913
+ result.push(key);
914
+ }
915
+ }
916
+ return result;
917
+ }
918
+
919
+ /**
920
+ * Creates an array of the own enumerable property names of `object`.
921
+ *
922
+ * **Note:** Non-object values are coerced to objects. See the
923
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
924
+ * for more details.
925
+ *
926
+ * @static
927
+ * @since 0.1.0
928
+ * @memberOf _
929
+ * @category Object
930
+ * @param {Object} object The object to query.
931
+ * @returns {Array} Returns the array of property names.
932
+ * @example
933
+ *
934
+ * function Foo() {
935
+ * this.a = 1;
936
+ * this.b = 2;
937
+ * }
938
+ *
939
+ * Foo.prototype.c = 3;
940
+ *
941
+ * _.keys(new Foo);
942
+ * // => ['a', 'b'] (iteration order is not guaranteed)
943
+ *
944
+ * _.keys('hi');
945
+ * // => ['0', '1']
946
+ */
947
+ function keys(object) {
948
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
949
+ }
950
+
951
+ /** Used to match property names within property paths. */
952
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
953
+ reIsPlainProp = /^\w*$/;
954
+
955
+ /**
956
+ * Checks if `value` is a property name and not a property path.
957
+ *
958
+ * @private
959
+ * @param {*} value The value to check.
960
+ * @param {Object} [object] The object to query keys on.
961
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
962
+ */
963
+ function isKey(value, object) {
964
+ if (isArray(value)) {
965
+ return false;
966
+ }
967
+ var type = typeof value;
968
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
969
+ value == null || isSymbol(value)) {
970
+ return true;
971
+ }
972
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
973
+ (object != null && value in Object(object));
974
+ }
975
+
976
+ /** Error message constants. */
977
+ var FUNC_ERROR_TEXT = 'Expected a function';
978
+
979
+ /**
980
+ * Creates a function that memoizes the result of `func`. If `resolver` is
981
+ * provided, it determines the cache key for storing the result based on the
982
+ * arguments provided to the memoized function. By default, the first argument
983
+ * provided to the memoized function is used as the map cache key. The `func`
984
+ * is invoked with the `this` binding of the memoized function.
985
+ *
986
+ * **Note:** The cache is exposed as the `cache` property on the memoized
987
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
988
+ * constructor with one whose instances implement the
989
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
990
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
991
+ *
992
+ * @static
993
+ * @memberOf _
994
+ * @since 0.1.0
995
+ * @category Function
996
+ * @param {Function} func The function to have its output memoized.
997
+ * @param {Function} [resolver] The function to resolve the cache key.
998
+ * @returns {Function} Returns the new memoized function.
999
+ * @example
1000
+ *
1001
+ * var object = { 'a': 1, 'b': 2 };
1002
+ * var other = { 'c': 3, 'd': 4 };
1003
+ *
1004
+ * var values = _.memoize(_.values);
1005
+ * values(object);
1006
+ * // => [1, 2]
1007
+ *
1008
+ * values(other);
1009
+ * // => [3, 4]
1010
+ *
1011
+ * object.a = 2;
1012
+ * values(object);
1013
+ * // => [1, 2]
1014
+ *
1015
+ * // Modify the result cache.
1016
+ * values.cache.set(object, ['a', 'b']);
1017
+ * values(object);
1018
+ * // => ['a', 'b']
1019
+ *
1020
+ * // Replace `_.memoize.Cache`.
1021
+ * _.memoize.Cache = WeakMap;
1022
+ */
1023
+ function memoize(func, resolver) {
1024
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
1025
+ throw new TypeError(FUNC_ERROR_TEXT);
1026
+ }
1027
+ var memoized = function() {
1028
+ var args = arguments,
1029
+ key = resolver ? resolver.apply(this, args) : args[0],
1030
+ cache = memoized.cache;
1031
+
1032
+ if (cache.has(key)) {
1033
+ return cache.get(key);
1034
+ }
1035
+ var result = func.apply(this, args);
1036
+ memoized.cache = cache.set(key, result) || cache;
1037
+ return result;
1038
+ };
1039
+ memoized.cache = new (memoize.Cache || MapCache);
1040
+ return memoized;
1041
+ }
1042
+
1043
+ // Expose `MapCache`.
1044
+ memoize.Cache = MapCache;
1045
+
1046
+ /** Used as the maximum memoize cache size. */
1047
+ var MAX_MEMOIZE_SIZE = 500;
1048
+
1049
+ /**
1050
+ * A specialized version of `_.memoize` which clears the memoized function's
1051
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
1052
+ *
1053
+ * @private
1054
+ * @param {Function} func The function to have its output memoized.
1055
+ * @returns {Function} Returns the new memoized function.
1056
+ */
1057
+ function memoizeCapped(func) {
1058
+ var result = memoize(func, function(key) {
1059
+ if (cache.size === MAX_MEMOIZE_SIZE) {
1060
+ cache.clear();
1061
+ }
1062
+ return key;
1063
+ });
1064
+
1065
+ var cache = result.cache;
1066
+ return result;
1067
+ }
1068
+
1069
+ /** Used to match property names within property paths. */
1070
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1071
+
1072
+ /** Used to match backslashes in property paths. */
1073
+ var reEscapeChar = /\\(\\)?/g;
1074
+
1075
+ /**
1076
+ * Converts `string` to a property path array.
1077
+ *
1078
+ * @private
1079
+ * @param {string} string The string to convert.
1080
+ * @returns {Array} Returns the property path array.
1081
+ */
1082
+ var stringToPath = memoizeCapped(function(string) {
1083
+ var result = [];
1084
+ if (string.charCodeAt(0) === 46 /* . */) {
1085
+ result.push('');
1086
+ }
1087
+ string.replace(rePropName, function(match, number, quote, subString) {
1088
+ result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
1089
+ });
1090
+ return result;
1091
+ });
1092
+
1093
+ /**
1094
+ * Converts `value` to a string. An empty string is returned for `null`
1095
+ * and `undefined` values. The sign of `-0` is preserved.
1096
+ *
1097
+ * @static
1098
+ * @memberOf _
1099
+ * @since 4.0.0
1100
+ * @category Lang
1101
+ * @param {*} value The value to convert.
1102
+ * @returns {string} Returns the converted string.
1103
+ * @example
1104
+ *
1105
+ * _.toString(null);
1106
+ * // => ''
1107
+ *
1108
+ * _.toString(-0);
1109
+ * // => '-0'
1110
+ *
1111
+ * _.toString([1, 2, 3]);
1112
+ * // => '1,2,3'
1113
+ */
1114
+ function toString(value) {
1115
+ return value == null ? '' : baseToString(value);
1116
+ }
1117
+
1118
+ /**
1119
+ * Casts `value` to a path array if it's not one.
1120
+ *
1121
+ * @private
1122
+ * @param {*} value The value to inspect.
1123
+ * @param {Object} [object] The object to query keys on.
1124
+ * @returns {Array} Returns the cast property path array.
1125
+ */
1126
+ function castPath(value, object) {
1127
+ if (isArray(value)) {
1128
+ return value;
1129
+ }
1130
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
1131
+ }
1132
+
1133
+ /** Used as references for various `Number` constants. */
1134
+ var INFINITY$1 = 1 / 0;
1135
+
1136
+ /**
1137
+ * Converts `value` to a string key if it's not a string or symbol.
1138
+ *
1139
+ * @private
1140
+ * @param {*} value The value to inspect.
1141
+ * @returns {string|symbol} Returns the key.
1142
+ */
1143
+ function toKey(value) {
1144
+ if (typeof value == 'string' || isSymbol(value)) {
1145
+ return value;
1146
+ }
1147
+ var result = (value + '');
1148
+ return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
1149
+ }
1150
+
1151
+ /**
1152
+ * The base implementation of `_.get` without support for default values.
1153
+ *
1154
+ * @private
1155
+ * @param {Object} object The object to query.
1156
+ * @param {Array|string} path The path of the property to get.
1157
+ * @returns {*} Returns the resolved value.
1158
+ */
1159
+ function baseGet(object, path) {
1160
+ path = castPath(path, object);
1161
+
1162
+ var index = 0,
1163
+ length = path.length;
1164
+
1165
+ while (object != null && index < length) {
1166
+ object = object[toKey(path[index++])];
1167
+ }
1168
+ return (index && index == length) ? object : undefined;
1169
+ }
1170
+
1171
+ /**
1172
+ * Gets the value at `path` of `object`. If the resolved value is
1173
+ * `undefined`, the `defaultValue` is returned in its place.
1174
+ *
1175
+ * @static
1176
+ * @memberOf _
1177
+ * @since 3.7.0
1178
+ * @category Object
1179
+ * @param {Object} object The object to query.
1180
+ * @param {Array|string} path The path of the property to get.
1181
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
1182
+ * @returns {*} Returns the resolved value.
1183
+ * @example
1184
+ *
1185
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
1186
+ *
1187
+ * _.get(object, 'a[0].b.c');
1188
+ * // => 3
1189
+ *
1190
+ * _.get(object, ['a', '0', 'b', 'c']);
1191
+ * // => 3
1192
+ *
1193
+ * _.get(object, 'a.b.c', 'default');
1194
+ * // => 'default'
1195
+ */
1196
+ function get(object, path, defaultValue) {
1197
+ var result = object == null ? undefined : baseGet(object, path);
1198
+ return result === undefined ? defaultValue : result;
1199
+ }
1200
+
1201
+ /**
1202
+ * Appends the elements of `values` to `array`.
1203
+ *
1204
+ * @private
1205
+ * @param {Array} array The array to modify.
1206
+ * @param {Array} values The values to append.
1207
+ * @returns {Array} Returns `array`.
1208
+ */
1209
+ function arrayPush(array, values) {
1210
+ var index = -1,
1211
+ length = values.length,
1212
+ offset = array.length;
1213
+
1214
+ while (++index < length) {
1215
+ array[offset + index] = values[index];
1216
+ }
1217
+ return array;
1218
+ }
1219
+
1220
+ /** Built-in value references. */
1221
+ var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : undefined;
1222
+
1223
+ /**
1224
+ * Checks if `value` is a flattenable `arguments` object or array.
1225
+ *
1226
+ * @private
1227
+ * @param {*} value The value to check.
1228
+ * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
1229
+ */
1230
+ function isFlattenable(value) {
1231
+ return isArray(value) || isArguments(value) ||
1232
+ !!(spreadableSymbol && value && value[spreadableSymbol]);
1233
+ }
1234
+
1235
+ /**
1236
+ * The base implementation of `_.flatten` with support for restricting flattening.
1237
+ *
1238
+ * @private
1239
+ * @param {Array} array The array to flatten.
1240
+ * @param {number} depth The maximum recursion depth.
1241
+ * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
1242
+ * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
1243
+ * @param {Array} [result=[]] The initial result value.
1244
+ * @returns {Array} Returns the new flattened array.
1245
+ */
1246
+ function baseFlatten(array, depth, predicate, isStrict, result) {
1247
+ var index = -1,
1248
+ length = array.length;
1249
+
1250
+ predicate || (predicate = isFlattenable);
1251
+ result || (result = []);
1252
+
1253
+ while (++index < length) {
1254
+ var value = array[index];
1255
+ if (predicate(value)) {
1256
+ {
1257
+ arrayPush(result, value);
1258
+ }
1259
+ } else if (!isStrict) {
1260
+ result[result.length] = value;
1261
+ }
1262
+ }
1263
+ return result;
1264
+ }
1265
+
1266
+ /**
1267
+ * A specialized version of `_.filter` for arrays without support for
1268
+ * iteratee shorthands.
1269
+ *
1270
+ * @private
1271
+ * @param {Array} [array] The array to iterate over.
1272
+ * @param {Function} predicate The function invoked per iteration.
1273
+ * @returns {Array} Returns the new filtered array.
1274
+ */
1275
+ function arrayFilter(array, predicate) {
1276
+ var index = -1,
1277
+ length = array == null ? 0 : array.length,
1278
+ resIndex = 0,
1279
+ result = [];
1280
+
1281
+ while (++index < length) {
1282
+ var value = array[index];
1283
+ if (predicate(value, index, array)) {
1284
+ result[resIndex++] = value;
1285
+ }
1286
+ }
1287
+ return result;
1288
+ }
1289
+
1290
+ /**
1291
+ * This method returns a new empty array.
1292
+ *
1293
+ * @static
1294
+ * @memberOf _
1295
+ * @since 4.13.0
1296
+ * @category Util
1297
+ * @returns {Array} Returns the new empty array.
1298
+ * @example
1299
+ *
1300
+ * var arrays = _.times(2, _.stubArray);
1301
+ *
1302
+ * console.log(arrays);
1303
+ * // => [[], []]
1304
+ *
1305
+ * console.log(arrays[0] === arrays[1]);
1306
+ * // => false
1307
+ */
1308
+ function stubArray() {
1309
+ return [];
1310
+ }
1311
+
1312
+ /** Used for built-in method references. */
1313
+ var objectProto$2 = Object.prototype;
1314
+
1315
+ /** Built-in value references. */
1316
+ var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
1317
+
1318
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1319
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1320
+
1321
+ /**
1322
+ * Creates an array of the own enumerable symbols of `object`.
1323
+ *
1324
+ * @private
1325
+ * @param {Object} object The object to query.
1326
+ * @returns {Array} Returns the array of symbols.
1327
+ */
1328
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1329
+ if (object == null) {
1330
+ return [];
1331
+ }
1332
+ object = Object(object);
1333
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
1334
+ return propertyIsEnumerable.call(object, symbol);
1335
+ });
1336
+ };
1337
+
1338
+ /**
1339
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1340
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1341
+ * symbols of `object`.
1342
+ *
1343
+ * @private
1344
+ * @param {Object} object The object to query.
1345
+ * @param {Function} keysFunc The function to get the keys of `object`.
1346
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
1347
+ * @returns {Array} Returns the array of property names and symbols.
1348
+ */
1349
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1350
+ var result = keysFunc(object);
1351
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1352
+ }
1353
+
1354
+ /**
1355
+ * Creates an array of own enumerable property names and symbols of `object`.
1356
+ *
1357
+ * @private
1358
+ * @param {Object} object The object to query.
1359
+ * @returns {Array} Returns the array of property names and symbols.
1360
+ */
1361
+ function getAllKeys(object) {
1362
+ return baseGetAllKeys(object, keys, getSymbols);
1363
+ }
1364
+
1365
+ /* Built-in method references that are verified to be native. */
1366
+ var DataView$1 = getNative(root, 'DataView');
1367
+
1368
+ /* Built-in method references that are verified to be native. */
1369
+ var Promise$1 = getNative(root, 'Promise');
1370
+
1371
+ /* Built-in method references that are verified to be native. */
1372
+ var Set$1 = getNative(root, 'Set');
1373
+
1374
+ /** `Object#toString` result references. */
1375
+ var mapTag$1 = '[object Map]',
1376
+ objectTag$1 = '[object Object]',
1377
+ promiseTag = '[object Promise]',
1378
+ setTag$1 = '[object Set]',
1379
+ weakMapTag = '[object WeakMap]';
1380
+
1381
+ var dataViewTag$1 = '[object DataView]';
1382
+
1383
+ /** Used to detect maps, sets, and weakmaps. */
1384
+ var dataViewCtorString = toSource(DataView$1),
1385
+ mapCtorString = toSource(Map$1),
1386
+ promiseCtorString = toSource(Promise$1),
1387
+ setCtorString = toSource(Set$1),
1388
+ weakMapCtorString = toSource(WeakMap);
1389
+
1390
+ /**
1391
+ * Gets the `toStringTag` of `value`.
1392
+ *
1393
+ * @private
1394
+ * @param {*} value The value to query.
1395
+ * @returns {string} Returns the `toStringTag`.
1396
+ */
1397
+ var getTag = baseGetTag;
1398
+
1399
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1400
+ if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag$1) ||
1401
+ (Map$1 && getTag(new Map$1) != mapTag$1) ||
1402
+ (Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
1403
+ (Set$1 && getTag(new Set$1) != setTag$1) ||
1404
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1405
+ getTag = function(value) {
1406
+ var result = baseGetTag(value),
1407
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
1408
+ ctorString = Ctor ? toSource(Ctor) : '';
1409
+
1410
+ if (ctorString) {
1411
+ switch (ctorString) {
1412
+ case dataViewCtorString: return dataViewTag$1;
1413
+ case mapCtorString: return mapTag$1;
1414
+ case promiseCtorString: return promiseTag;
1415
+ case setCtorString: return setTag$1;
1416
+ case weakMapCtorString: return weakMapTag;
1417
+ }
1418
+ }
1419
+ return result;
1420
+ };
1421
+ }
1422
+
1423
+ /**
1424
+ * Creates an array with all falsey values removed. The values `false`, `null`,
1425
+ * `0`, `""`, `undefined`, and `NaN` are falsey.
1426
+ *
1427
+ * @static
1428
+ * @memberOf _
1429
+ * @since 0.1.0
1430
+ * @category Array
1431
+ * @param {Array} array The array to compact.
1432
+ * @returns {Array} Returns the new array of filtered values.
1433
+ * @example
1434
+ *
1435
+ * _.compact([0, 1, false, 2, '', 3]);
1436
+ * // => [1, 2, 3]
1437
+ */
1438
+ function compact(array) {
1439
+ var index = -1,
1440
+ length = array == null ? 0 : array.length,
1441
+ resIndex = 0,
1442
+ result = [];
1443
+
1444
+ while (++index < length) {
1445
+ var value = array[index];
1446
+ if (value) {
1447
+ result[resIndex++] = value;
1448
+ }
1449
+ }
1450
+ return result;
1451
+ }
1452
+
1453
+ /** Used to stand-in for `undefined` hash values. */
1454
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1455
+
1456
+ /**
1457
+ * Adds `value` to the array cache.
1458
+ *
1459
+ * @private
1460
+ * @name add
1461
+ * @memberOf SetCache
1462
+ * @alias push
1463
+ * @param {*} value The value to cache.
1464
+ * @returns {Object} Returns the cache instance.
1465
+ */
1466
+ function setCacheAdd(value) {
1467
+ this.__data__.set(value, HASH_UNDEFINED);
1468
+ return this;
1469
+ }
1470
+
1471
+ /**
1472
+ * Checks if `value` is in the array cache.
1473
+ *
1474
+ * @private
1475
+ * @name has
1476
+ * @memberOf SetCache
1477
+ * @param {*} value The value to search for.
1478
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1479
+ */
1480
+ function setCacheHas(value) {
1481
+ return this.__data__.has(value);
1482
+ }
1483
+
1484
+ /**
1485
+ *
1486
+ * Creates an array cache object to store unique values.
1487
+ *
1488
+ * @private
1489
+ * @constructor
1490
+ * @param {Array} [values] The values to cache.
1491
+ */
1492
+ function SetCache(values) {
1493
+ var index = -1,
1494
+ length = values == null ? 0 : values.length;
1495
+
1496
+ this.__data__ = new MapCache;
1497
+ while (++index < length) {
1498
+ this.add(values[index]);
1499
+ }
1500
+ }
1501
+
1502
+ // Add methods to `SetCache`.
1503
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
1504
+ SetCache.prototype.has = setCacheHas;
1505
+
1506
+ /**
1507
+ * A specialized version of `_.some` for arrays without support for iteratee
1508
+ * shorthands.
1509
+ *
1510
+ * @private
1511
+ * @param {Array} [array] The array to iterate over.
1512
+ * @param {Function} predicate The function invoked per iteration.
1513
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
1514
+ * else `false`.
1515
+ */
1516
+ function arraySome(array, predicate) {
1517
+ var index = -1,
1518
+ length = array == null ? 0 : array.length;
1519
+
1520
+ while (++index < length) {
1521
+ if (predicate(array[index], index, array)) {
1522
+ return true;
1523
+ }
1524
+ }
1525
+ return false;
1526
+ }
1527
+
1528
+ /**
1529
+ * Checks if a `cache` value for `key` exists.
1530
+ *
1531
+ * @private
1532
+ * @param {Object} cache The cache to query.
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 cacheHas(cache, key) {
1537
+ return cache.has(key);
1538
+ }
1539
+
1540
+ /** Used to compose bitmasks for value comparisons. */
1541
+ var COMPARE_PARTIAL_FLAG$5 = 1,
1542
+ COMPARE_UNORDERED_FLAG$3 = 2;
1543
+
1544
+ /**
1545
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
1546
+ * partial deep comparisons.
1547
+ *
1548
+ * @private
1549
+ * @param {Array} array The array to compare.
1550
+ * @param {Array} other The other array to compare.
1551
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1552
+ * @param {Function} customizer The function to customize comparisons.
1553
+ * @param {Function} equalFunc The function to determine equivalents of values.
1554
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
1555
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1556
+ */
1557
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1558
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5,
1559
+ arrLength = array.length,
1560
+ othLength = other.length;
1561
+
1562
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1563
+ return false;
1564
+ }
1565
+ // Check that cyclic values are equal.
1566
+ var arrStacked = stack.get(array);
1567
+ var othStacked = stack.get(other);
1568
+ if (arrStacked && othStacked) {
1569
+ return arrStacked == other && othStacked == array;
1570
+ }
1571
+ var index = -1,
1572
+ result = true,
1573
+ seen = (bitmask & COMPARE_UNORDERED_FLAG$3) ? new SetCache : undefined;
1574
+
1575
+ stack.set(array, other);
1576
+ stack.set(other, array);
1577
+
1578
+ // Ignore non-index properties.
1579
+ while (++index < arrLength) {
1580
+ var arrValue = array[index],
1581
+ othValue = other[index];
1582
+
1583
+ if (customizer) {
1584
+ var compared = isPartial
1585
+ ? customizer(othValue, arrValue, index, other, array, stack)
1586
+ : customizer(arrValue, othValue, index, array, other, stack);
1587
+ }
1588
+ if (compared !== undefined) {
1589
+ if (compared) {
1590
+ continue;
1591
+ }
1592
+ result = false;
1593
+ break;
1594
+ }
1595
+ // Recursively compare arrays (susceptible to call stack limits).
1596
+ if (seen) {
1597
+ if (!arraySome(other, function(othValue, othIndex) {
1598
+ if (!cacheHas(seen, othIndex) &&
1599
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1600
+ return seen.push(othIndex);
1601
+ }
1602
+ })) {
1603
+ result = false;
1604
+ break;
1605
+ }
1606
+ } else if (!(
1607
+ arrValue === othValue ||
1608
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
1609
+ )) {
1610
+ result = false;
1611
+ break;
1612
+ }
1613
+ }
1614
+ stack['delete'](array);
1615
+ stack['delete'](other);
1616
+ return result;
1617
+ }
1618
+
1619
+ /**
1620
+ * Converts `map` to its key-value pairs.
1621
+ *
1622
+ * @private
1623
+ * @param {Object} map The map to convert.
1624
+ * @returns {Array} Returns the key-value pairs.
1625
+ */
1626
+ function mapToArray(map) {
1627
+ var index = -1,
1628
+ result = Array(map.size);
1629
+
1630
+ map.forEach(function(value, key) {
1631
+ result[++index] = [key, value];
1632
+ });
1633
+ return result;
1634
+ }
1635
+
1636
+ /**
1637
+ * Converts `set` to an array of its values.
1638
+ *
1639
+ * @private
1640
+ * @param {Object} set The set to convert.
1641
+ * @returns {Array} Returns the values.
1642
+ */
1643
+ function setToArray(set) {
1644
+ var index = -1,
1645
+ result = Array(set.size);
1646
+
1647
+ set.forEach(function(value) {
1648
+ result[++index] = value;
1649
+ });
1650
+ return result;
1651
+ }
1652
+
1653
+ /** Used to compose bitmasks for value comparisons. */
1654
+ var COMPARE_PARTIAL_FLAG$4 = 1,
1655
+ COMPARE_UNORDERED_FLAG$2 = 2;
1656
+
1657
+ /** `Object#toString` result references. */
1658
+ var boolTag = '[object Boolean]',
1659
+ dateTag = '[object Date]',
1660
+ errorTag = '[object Error]',
1661
+ mapTag = '[object Map]',
1662
+ numberTag = '[object Number]',
1663
+ regexpTag = '[object RegExp]',
1664
+ setTag = '[object Set]',
1665
+ stringTag = '[object String]',
1666
+ symbolTag = '[object Symbol]';
1667
+
1668
+ var arrayBufferTag = '[object ArrayBuffer]',
1669
+ dataViewTag = '[object DataView]';
1670
+
1671
+ /** Used to convert symbols to primitives and strings. */
1672
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
1673
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
1674
+
1675
+ /**
1676
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
1677
+ * the same `toStringTag`.
1678
+ *
1679
+ * **Note:** This function only supports comparing values with tags of
1680
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1681
+ *
1682
+ * @private
1683
+ * @param {Object} object The object to compare.
1684
+ * @param {Object} other The other object to compare.
1685
+ * @param {string} tag The `toStringTag` of the objects to compare.
1686
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1687
+ * @param {Function} customizer The function to customize comparisons.
1688
+ * @param {Function} equalFunc The function to determine equivalents of values.
1689
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1690
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1691
+ */
1692
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1693
+ switch (tag) {
1694
+ case dataViewTag:
1695
+ if ((object.byteLength != other.byteLength) ||
1696
+ (object.byteOffset != other.byteOffset)) {
1697
+ return false;
1698
+ }
1699
+ object = object.buffer;
1700
+ other = other.buffer;
1701
+
1702
+ case arrayBufferTag:
1703
+ if ((object.byteLength != other.byteLength) ||
1704
+ !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) {
1705
+ return false;
1706
+ }
1707
+ return true;
1708
+
1709
+ case boolTag:
1710
+ case dateTag:
1711
+ case numberTag:
1712
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
1713
+ // Invalid dates are coerced to `NaN`.
1714
+ return eq(+object, +other);
1715
+
1716
+ case errorTag:
1717
+ return object.name == other.name && object.message == other.message;
1718
+
1719
+ case regexpTag:
1720
+ case stringTag:
1721
+ // Coerce regexes to strings and treat strings, primitives and objects,
1722
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1723
+ // for more details.
1724
+ return object == (other + '');
1725
+
1726
+ case mapTag:
1727
+ var convert = mapToArray;
1728
+
1729
+ case setTag:
1730
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
1731
+ convert || (convert = setToArray);
1732
+
1733
+ if (object.size != other.size && !isPartial) {
1734
+ return false;
1735
+ }
1736
+ // Assume cyclic values are equal.
1737
+ var stacked = stack.get(object);
1738
+ if (stacked) {
1739
+ return stacked == other;
1740
+ }
1741
+ bitmask |= COMPARE_UNORDERED_FLAG$2;
1742
+
1743
+ // Recursively compare objects (susceptible to call stack limits).
1744
+ stack.set(object, other);
1745
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
1746
+ stack['delete'](object);
1747
+ return result;
1748
+
1749
+ case symbolTag:
1750
+ if (symbolValueOf) {
1751
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
1752
+ }
1753
+ }
1754
+ return false;
1755
+ }
1756
+
1757
+ /** Used to compose bitmasks for value comparisons. */
1758
+ var COMPARE_PARTIAL_FLAG$3 = 1;
1759
+
1760
+ /** Used for built-in method references. */
1761
+ var objectProto$1 = Object.prototype;
1762
+
1763
+ /** Used to check objects for own properties. */
1764
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1765
+
1766
+ /**
1767
+ * A specialized version of `baseIsEqualDeep` for objects with support for
1768
+ * partial deep comparisons.
1769
+ *
1770
+ * @private
1771
+ * @param {Object} object The object to compare.
1772
+ * @param {Object} other The other object to compare.
1773
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1774
+ * @param {Function} customizer The function to customize comparisons.
1775
+ * @param {Function} equalFunc The function to determine equivalents of values.
1776
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1777
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1778
+ */
1779
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1780
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
1781
+ objProps = getAllKeys(object),
1782
+ objLength = objProps.length,
1783
+ othProps = getAllKeys(other),
1784
+ othLength = othProps.length;
1785
+
1786
+ if (objLength != othLength && !isPartial) {
1787
+ return false;
1788
+ }
1789
+ var index = objLength;
1790
+ while (index--) {
1791
+ var key = objProps[index];
1792
+ if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
1793
+ return false;
1794
+ }
1795
+ }
1796
+ // Check that cyclic values are equal.
1797
+ var objStacked = stack.get(object);
1798
+ var othStacked = stack.get(other);
1799
+ if (objStacked && othStacked) {
1800
+ return objStacked == other && othStacked == object;
1801
+ }
1802
+ var result = true;
1803
+ stack.set(object, other);
1804
+ stack.set(other, object);
1805
+
1806
+ var skipCtor = isPartial;
1807
+ while (++index < objLength) {
1808
+ key = objProps[index];
1809
+ var objValue = object[key],
1810
+ othValue = other[key];
1811
+
1812
+ if (customizer) {
1813
+ var compared = isPartial
1814
+ ? customizer(othValue, objValue, key, other, object, stack)
1815
+ : customizer(objValue, othValue, key, object, other, stack);
1816
+ }
1817
+ // Recursively compare objects (susceptible to call stack limits).
1818
+ if (!(compared === undefined
1819
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1820
+ : compared
1821
+ )) {
1822
+ result = false;
1823
+ break;
1824
+ }
1825
+ skipCtor || (skipCtor = key == 'constructor');
1826
+ }
1827
+ if (result && !skipCtor) {
1828
+ var objCtor = object.constructor,
1829
+ othCtor = other.constructor;
1830
+
1831
+ // Non `Object` object instances with different constructors are not equal.
1832
+ if (objCtor != othCtor &&
1833
+ ('constructor' in object && 'constructor' in other) &&
1834
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1835
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1836
+ result = false;
1837
+ }
1838
+ }
1839
+ stack['delete'](object);
1840
+ stack['delete'](other);
1841
+ return result;
1842
+ }
1843
+
1844
+ /** Used to compose bitmasks for value comparisons. */
1845
+ var COMPARE_PARTIAL_FLAG$2 = 1;
1846
+
1847
+ /** `Object#toString` result references. */
1848
+ var argsTag = '[object Arguments]',
1849
+ arrayTag = '[object Array]',
1850
+ objectTag = '[object Object]';
1851
+
1852
+ /** Used for built-in method references. */
1853
+ var objectProto = Object.prototype;
1854
+
1855
+ /** Used to check objects for own properties. */
1856
+ var hasOwnProperty = objectProto.hasOwnProperty;
1857
+
1858
+ /**
1859
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
1860
+ * deep comparisons and tracks traversed objects enabling objects with circular
1861
+ * references to be compared.
1862
+ *
1863
+ * @private
1864
+ * @param {Object} object The object to compare.
1865
+ * @param {Object} other The other object to compare.
1866
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1867
+ * @param {Function} customizer The function to customize comparisons.
1868
+ * @param {Function} equalFunc The function to determine equivalents of values.
1869
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
1870
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1871
+ */
1872
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1873
+ var objIsArr = isArray(object),
1874
+ othIsArr = isArray(other),
1875
+ objTag = objIsArr ? arrayTag : getTag(object),
1876
+ othTag = othIsArr ? arrayTag : getTag(other);
1877
+
1878
+ objTag = objTag == argsTag ? objectTag : objTag;
1879
+ othTag = othTag == argsTag ? objectTag : othTag;
1880
+
1881
+ var objIsObj = objTag == objectTag,
1882
+ othIsObj = othTag == objectTag,
1883
+ isSameTag = objTag == othTag;
1884
+
1885
+ if (isSameTag && isBuffer(object)) {
1886
+ if (!isBuffer(other)) {
1887
+ return false;
1888
+ }
1889
+ objIsArr = true;
1890
+ objIsObj = false;
1891
+ }
1892
+ if (isSameTag && !objIsObj) {
1893
+ stack || (stack = new Stack);
1894
+ return (objIsArr || isTypedArray(object))
1895
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
1896
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1897
+ }
1898
+ if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
1899
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
1900
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
1901
+
1902
+ if (objIsWrapped || othIsWrapped) {
1903
+ var objUnwrapped = objIsWrapped ? object.value() : object,
1904
+ othUnwrapped = othIsWrapped ? other.value() : other;
1905
+
1906
+ stack || (stack = new Stack);
1907
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1908
+ }
1909
+ }
1910
+ if (!isSameTag) {
1911
+ return false;
1912
+ }
1913
+ stack || (stack = new Stack);
1914
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1915
+ }
1916
+
1917
+ /**
1918
+ * The base implementation of `_.isEqual` which supports partial comparisons
1919
+ * and tracks traversed objects.
1920
+ *
1921
+ * @private
1922
+ * @param {*} value The value to compare.
1923
+ * @param {*} other The other value to compare.
1924
+ * @param {boolean} bitmask The bitmask flags.
1925
+ * 1 - Unordered comparison
1926
+ * 2 - Partial comparison
1927
+ * @param {Function} [customizer] The function to customize comparisons.
1928
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
1929
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1930
+ */
1931
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
1932
+ if (value === other) {
1933
+ return true;
1934
+ }
1935
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
1936
+ return value !== value && other !== other;
1937
+ }
1938
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1939
+ }
1940
+
1941
+ /** Used to compose bitmasks for value comparisons. */
1942
+ var COMPARE_PARTIAL_FLAG$1 = 1,
1943
+ COMPARE_UNORDERED_FLAG$1 = 2;
1944
+
1945
+ /**
1946
+ * The base implementation of `_.isMatch` without support for iteratee shorthands.
1947
+ *
1948
+ * @private
1949
+ * @param {Object} object The object to inspect.
1950
+ * @param {Object} source The object of property values to match.
1951
+ * @param {Array} matchData The property names, values, and compare flags to match.
1952
+ * @param {Function} [customizer] The function to customize comparisons.
1953
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
1954
+ */
1955
+ function baseIsMatch(object, source, matchData, customizer) {
1956
+ var index = matchData.length,
1957
+ length = index;
1958
+
1959
+ if (object == null) {
1960
+ return !length;
1961
+ }
1962
+ object = Object(object);
1963
+ while (index--) {
1964
+ var data = matchData[index];
1965
+ if ((data[2])
1966
+ ? data[1] !== object[data[0]]
1967
+ : !(data[0] in object)
1968
+ ) {
1969
+ return false;
1970
+ }
1971
+ }
1972
+ while (++index < length) {
1973
+ data = matchData[index];
1974
+ var key = data[0],
1975
+ objValue = object[key],
1976
+ srcValue = data[1];
1977
+
1978
+ if (data[2]) {
1979
+ if (objValue === undefined && !(key in object)) {
1980
+ return false;
1981
+ }
1982
+ } else {
1983
+ var stack = new Stack;
1984
+ var result;
1985
+ if (!(result === undefined
1986
+ ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack)
1987
+ : result
1988
+ )) {
1989
+ return false;
1990
+ }
1991
+ }
1992
+ }
1993
+ return true;
1994
+ }
1995
+
1996
+ /**
1997
+ * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
1998
+ *
1999
+ * @private
2000
+ * @param {*} value The value to check.
2001
+ * @returns {boolean} Returns `true` if `value` if suitable for strict
2002
+ * equality comparisons, else `false`.
2003
+ */
2004
+ function isStrictComparable(value) {
2005
+ return value === value && !isObject(value);
2006
+ }
2007
+
2008
+ /**
2009
+ * Gets the property names, values, and compare flags of `object`.
2010
+ *
2011
+ * @private
2012
+ * @param {Object} object The object to query.
2013
+ * @returns {Array} Returns the match data of `object`.
2014
+ */
2015
+ function getMatchData(object) {
2016
+ var result = keys(object),
2017
+ length = result.length;
2018
+
2019
+ while (length--) {
2020
+ var key = result[length],
2021
+ value = object[key];
2022
+
2023
+ result[length] = [key, value, isStrictComparable(value)];
2024
+ }
2025
+ return result;
2026
+ }
2027
+
2028
+ /**
2029
+ * A specialized version of `matchesProperty` for source values suitable
2030
+ * for strict equality comparisons, i.e. `===`.
2031
+ *
2032
+ * @private
2033
+ * @param {string} key The key of the property to get.
2034
+ * @param {*} srcValue The value to match.
2035
+ * @returns {Function} Returns the new spec function.
2036
+ */
2037
+ function matchesStrictComparable(key, srcValue) {
2038
+ return function(object) {
2039
+ if (object == null) {
2040
+ return false;
2041
+ }
2042
+ return object[key] === srcValue &&
2043
+ (srcValue !== undefined || (key in Object(object)));
2044
+ };
2045
+ }
2046
+
2047
+ /**
2048
+ * The base implementation of `_.matches` which doesn't clone `source`.
2049
+ *
2050
+ * @private
2051
+ * @param {Object} source The object of property values to match.
2052
+ * @returns {Function} Returns the new spec function.
2053
+ */
2054
+ function baseMatches(source) {
2055
+ var matchData = getMatchData(source);
2056
+ if (matchData.length == 1 && matchData[0][2]) {
2057
+ return matchesStrictComparable(matchData[0][0], matchData[0][1]);
2058
+ }
2059
+ return function(object) {
2060
+ return object === source || baseIsMatch(object, source, matchData);
2061
+ };
2062
+ }
2063
+
2064
+ /**
2065
+ * The base implementation of `_.hasIn` without support for deep paths.
2066
+ *
2067
+ * @private
2068
+ * @param {Object} [object] The object to query.
2069
+ * @param {Array|string} key The key to check.
2070
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
2071
+ */
2072
+ function baseHasIn(object, key) {
2073
+ return object != null && key in Object(object);
2074
+ }
2075
+
2076
+ /**
2077
+ * Checks if `path` exists on `object`.
2078
+ *
2079
+ * @private
2080
+ * @param {Object} object The object to query.
2081
+ * @param {Array|string} path The path to check.
2082
+ * @param {Function} hasFunc The function to check properties.
2083
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
2084
+ */
2085
+ function hasPath(object, path, hasFunc) {
2086
+ path = castPath(path, object);
2087
+
2088
+ var index = -1,
2089
+ length = path.length,
2090
+ result = false;
2091
+
2092
+ while (++index < length) {
2093
+ var key = toKey(path[index]);
2094
+ if (!(result = object != null && hasFunc(object, key))) {
2095
+ break;
2096
+ }
2097
+ object = object[key];
2098
+ }
2099
+ if (result || ++index != length) {
2100
+ return result;
2101
+ }
2102
+ length = object == null ? 0 : object.length;
2103
+ return !!length && isLength(length) && isIndex(key, length) &&
2104
+ (isArray(object) || isArguments(object));
2105
+ }
2106
+
2107
+ /**
2108
+ * Checks if `path` is a direct or inherited property of `object`.
2109
+ *
2110
+ * @static
2111
+ * @memberOf _
2112
+ * @since 4.0.0
2113
+ * @category Object
2114
+ * @param {Object} object The object to query.
2115
+ * @param {Array|string} path The path to check.
2116
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
2117
+ * @example
2118
+ *
2119
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
2120
+ *
2121
+ * _.hasIn(object, 'a');
2122
+ * // => true
2123
+ *
2124
+ * _.hasIn(object, 'a.b');
2125
+ * // => true
2126
+ *
2127
+ * _.hasIn(object, ['a', 'b']);
2128
+ * // => true
2129
+ *
2130
+ * _.hasIn(object, 'b');
2131
+ * // => false
2132
+ */
2133
+ function hasIn(object, path) {
2134
+ return object != null && hasPath(object, path, baseHasIn);
2135
+ }
2136
+
2137
+ /** Used to compose bitmasks for value comparisons. */
2138
+ var COMPARE_PARTIAL_FLAG = 1,
2139
+ COMPARE_UNORDERED_FLAG = 2;
2140
+
2141
+ /**
2142
+ * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
2143
+ *
2144
+ * @private
2145
+ * @param {string} path The path of the property to get.
2146
+ * @param {*} srcValue The value to match.
2147
+ * @returns {Function} Returns the new spec function.
2148
+ */
2149
+ function baseMatchesProperty(path, srcValue) {
2150
+ if (isKey(path) && isStrictComparable(srcValue)) {
2151
+ return matchesStrictComparable(toKey(path), srcValue);
2152
+ }
2153
+ return function(object) {
2154
+ var objValue = get(object, path);
2155
+ return (objValue === undefined && objValue === srcValue)
2156
+ ? hasIn(object, path)
2157
+ : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
2158
+ };
2159
+ }
2160
+
2161
+ /**
2162
+ * The base implementation of `_.property` without support for deep paths.
2163
+ *
2164
+ * @private
2165
+ * @param {string} key The key of the property to get.
2166
+ * @returns {Function} Returns the new accessor function.
2167
+ */
2168
+ function baseProperty(key) {
2169
+ return function(object) {
2170
+ return object == null ? undefined : object[key];
2171
+ };
2172
+ }
2173
+
2174
+ /**
2175
+ * A specialized version of `baseProperty` which supports deep paths.
2176
+ *
2177
+ * @private
2178
+ * @param {Array|string} path The path of the property to get.
2179
+ * @returns {Function} Returns the new accessor function.
2180
+ */
2181
+ function basePropertyDeep(path) {
2182
+ return function(object) {
2183
+ return baseGet(object, path);
2184
+ };
2185
+ }
2186
+
2187
+ /**
2188
+ * Creates a function that returns the value at `path` of a given object.
2189
+ *
2190
+ * @static
2191
+ * @memberOf _
2192
+ * @since 2.4.0
2193
+ * @category Util
2194
+ * @param {Array|string} path The path of the property to get.
2195
+ * @returns {Function} Returns the new accessor function.
2196
+ * @example
2197
+ *
2198
+ * var objects = [
2199
+ * { 'a': { 'b': 2 } },
2200
+ * { 'a': { 'b': 1 } }
2201
+ * ];
2202
+ *
2203
+ * _.map(objects, _.property('a.b'));
2204
+ * // => [2, 1]
2205
+ *
2206
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
2207
+ * // => [1, 2]
2208
+ */
2209
+ function property(path) {
2210
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
2211
+ }
2212
+
2213
+ /**
2214
+ * The base implementation of `_.iteratee`.
2215
+ *
2216
+ * @private
2217
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
2218
+ * @returns {Function} Returns the iteratee.
2219
+ */
2220
+ function baseIteratee(value) {
2221
+ // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
2222
+ // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
2223
+ if (typeof value == 'function') {
2224
+ return value;
2225
+ }
2226
+ if (value == null) {
2227
+ return identity;
2228
+ }
2229
+ if (typeof value == 'object') {
2230
+ return isArray(value)
2231
+ ? baseMatchesProperty(value[0], value[1])
2232
+ : baseMatches(value);
2233
+ }
2234
+ return property(value);
2235
+ }
2236
+
2237
+ /**
2238
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
2239
+ *
2240
+ * @private
2241
+ * @param {Object} object The object to iterate over.
2242
+ * @param {Function} iteratee The function invoked per iteration.
2243
+ * @returns {Object} Returns `object`.
2244
+ */
2245
+ function baseForOwn(object, iteratee) {
2246
+ return object && baseFor(object, iteratee, keys);
2247
+ }
2248
+
2249
+ /**
2250
+ * Creates a `baseEach` or `baseEachRight` function.
2251
+ *
2252
+ * @private
2253
+ * @param {Function} eachFunc The function to iterate over a collection.
2254
+ * @param {boolean} [fromRight] Specify iterating from right to left.
2255
+ * @returns {Function} Returns the new base function.
2256
+ */
2257
+ function createBaseEach(eachFunc, fromRight) {
2258
+ return function(collection, iteratee) {
2259
+ if (collection == null) {
2260
+ return collection;
2261
+ }
2262
+ if (!isArrayLike(collection)) {
2263
+ return eachFunc(collection, iteratee);
2264
+ }
2265
+ var length = collection.length,
2266
+ index = -1,
2267
+ iterable = Object(collection);
2268
+
2269
+ while ((++index < length)) {
2270
+ if (iteratee(iterable[index], index, iterable) === false) {
2271
+ break;
2272
+ }
2273
+ }
2274
+ return collection;
2275
+ };
2276
+ }
2277
+
2278
+ /**
2279
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
2280
+ *
2281
+ * @private
2282
+ * @param {Array|Object} collection The collection to iterate over.
2283
+ * @param {Function} iteratee The function invoked per iteration.
2284
+ * @returns {Array|Object} Returns `collection`.
2285
+ */
2286
+ var baseEach = createBaseEach(baseForOwn);
2287
+
2288
+ /** Used as the size to enable large array optimizations. */
2289
+ var LARGE_ARRAY_SIZE$1 = 200;
2290
+
2291
+ /**
2292
+ * The base implementation of methods like `_.difference` without support
2293
+ * for excluding multiple arrays or iteratee shorthands.
2294
+ *
2295
+ * @private
2296
+ * @param {Array} array The array to inspect.
2297
+ * @param {Array} values The values to exclude.
2298
+ * @param {Function} [iteratee] The iteratee invoked per element.
2299
+ * @param {Function} [comparator] The comparator invoked per element.
2300
+ * @returns {Array} Returns the new array of filtered values.
2301
+ */
2302
+ function baseDifference(array, values, iteratee, comparator) {
2303
+ var index = -1,
2304
+ includes = arrayIncludes,
2305
+ isCommon = true,
2306
+ length = array.length,
2307
+ result = [],
2308
+ valuesLength = values.length;
2309
+
2310
+ if (!length) {
2311
+ return result;
2312
+ }
2313
+ if (values.length >= LARGE_ARRAY_SIZE$1) {
2314
+ includes = cacheHas;
2315
+ isCommon = false;
2316
+ values = new SetCache(values);
2317
+ }
2318
+ outer:
2319
+ while (++index < length) {
2320
+ var value = array[index],
2321
+ computed = value ;
2322
+
2323
+ value = (value !== 0) ? value : 0;
2324
+ if (isCommon && computed === computed) {
2325
+ var valuesIndex = valuesLength;
2326
+ while (valuesIndex--) {
2327
+ if (values[valuesIndex] === computed) {
2328
+ continue outer;
2329
+ }
2330
+ }
2331
+ result.push(value);
2332
+ }
2333
+ else if (!includes(values, computed, comparator)) {
2334
+ result.push(value);
2335
+ }
2336
+ }
2337
+ return result;
2338
+ }
2339
+
2340
+ /**
2341
+ * The base implementation of `_.map` without support for iteratee shorthands.
2342
+ *
2343
+ * @private
2344
+ * @param {Array|Object} collection The collection to iterate over.
2345
+ * @param {Function} iteratee The function invoked per iteration.
2346
+ * @returns {Array} Returns the new mapped array.
2347
+ */
2348
+ function baseMap(collection, iteratee) {
2349
+ var index = -1,
2350
+ result = isArrayLike(collection) ? Array(collection.length) : [];
2351
+
2352
+ baseEach(collection, function(value, key, collection) {
2353
+ result[++index] = iteratee(value, key, collection);
2354
+ });
2355
+ return result;
2356
+ }
2357
+
2358
+ /**
2359
+ * Creates an array of values by running each element in `collection` thru
2360
+ * `iteratee`. The iteratee is invoked with three arguments:
2361
+ * (value, index|key, collection).
2362
+ *
2363
+ * Many lodash methods are guarded to work as iteratees for methods like
2364
+ * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
2365
+ *
2366
+ * The guarded methods are:
2367
+ * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
2368
+ * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
2369
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
2370
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
2371
+ *
2372
+ * @static
2373
+ * @memberOf _
2374
+ * @since 0.1.0
2375
+ * @category Collection
2376
+ * @param {Array|Object} collection The collection to iterate over.
2377
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2378
+ * @returns {Array} Returns the new mapped array.
2379
+ * @example
2380
+ *
2381
+ * function square(n) {
2382
+ * return n * n;
2383
+ * }
2384
+ *
2385
+ * _.map([4, 8], square);
2386
+ * // => [16, 64]
2387
+ *
2388
+ * _.map({ 'a': 4, 'b': 8 }, square);
2389
+ * // => [16, 64] (iteration order is not guaranteed)
2390
+ *
2391
+ * var users = [
2392
+ * { 'user': 'barney' },
2393
+ * { 'user': 'fred' }
2394
+ * ];
2395
+ *
2396
+ * // The `_.property` iteratee shorthand.
2397
+ * _.map(users, 'user');
2398
+ * // => ['barney', 'fred']
2399
+ */
2400
+ function map(collection, iteratee) {
2401
+ var func = isArray(collection) ? arrayMap : baseMap;
2402
+ return func(collection, baseIteratee(iteratee));
2403
+ }
2404
+
2405
+ /**
2406
+ * Creates a flattened array of values by running each element in `collection`
2407
+ * thru `iteratee` and flattening the mapped results. The iteratee is invoked
2408
+ * with three arguments: (value, index|key, collection).
2409
+ *
2410
+ * @static
2411
+ * @memberOf _
2412
+ * @since 4.0.0
2413
+ * @category Collection
2414
+ * @param {Array|Object} collection The collection to iterate over.
2415
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
2416
+ * @returns {Array} Returns the new flattened array.
2417
+ * @example
2418
+ *
2419
+ * function duplicate(n) {
2420
+ * return [n, n];
2421
+ * }
2422
+ *
2423
+ * _.flatMap([1, 2], duplicate);
2424
+ * // => [1, 1, 2, 2]
2425
+ */
2426
+ function flatMap(collection, iteratee) {
2427
+ return baseFlatten(map(collection, iteratee));
2428
+ }
2429
+
2430
+ /** Used as references for various `Number` constants. */
2431
+ var INFINITY = 1 / 0;
2432
+
2433
+ /**
2434
+ * Creates a set object of `values`.
2435
+ *
2436
+ * @private
2437
+ * @param {Array} values The values to add to the set.
2438
+ * @returns {Object} Returns the new set.
2439
+ */
2440
+ var createSet = !(Set$1 && (1 / setToArray(new Set$1([,-0]))[1]) == INFINITY) ? noop : function(values) {
2441
+ return new Set$1(values);
2442
+ };
2443
+
2444
+ /** Used as the size to enable large array optimizations. */
2445
+ var LARGE_ARRAY_SIZE = 200;
2446
+
2447
+ /**
2448
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
2449
+ *
2450
+ * @private
2451
+ * @param {Array} array The array to inspect.
2452
+ * @param {Function} [iteratee] The iteratee invoked per element.
2453
+ * @param {Function} [comparator] The comparator invoked per element.
2454
+ * @returns {Array} Returns the new duplicate free array.
2455
+ */
2456
+ function baseUniq(array, iteratee, comparator) {
2457
+ var index = -1,
2458
+ includes = arrayIncludes,
2459
+ length = array.length,
2460
+ isCommon = true,
2461
+ result = [],
2462
+ seen = result;
2463
+
2464
+ if (length >= LARGE_ARRAY_SIZE) {
2465
+ var set = createSet(array);
2466
+ if (set) {
2467
+ return setToArray(set);
2468
+ }
2469
+ isCommon = false;
2470
+ includes = cacheHas;
2471
+ seen = new SetCache;
2472
+ }
2473
+ else {
2474
+ seen = result;
2475
+ }
2476
+ outer:
2477
+ while (++index < length) {
2478
+ var value = array[index],
2479
+ computed = value;
2480
+
2481
+ value = (value !== 0) ? value : 0;
2482
+ if (isCommon && computed === computed) {
2483
+ var seenIndex = seen.length;
2484
+ while (seenIndex--) {
2485
+ if (seen[seenIndex] === computed) {
2486
+ continue outer;
2487
+ }
2488
+ }
2489
+ result.push(value);
2490
+ }
2491
+ else if (!includes(seen, computed, comparator)) {
2492
+ if (seen !== result) {
2493
+ seen.push(computed);
2494
+ }
2495
+ result.push(value);
2496
+ }
2497
+ }
2498
+ return result;
2499
+ }
2500
+
2501
+ /**
2502
+ * Creates a duplicate-free version of an array, using
2503
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2504
+ * for equality comparisons, in which only the first occurrence of each element
2505
+ * is kept. The order of result values is determined by the order they occur
2506
+ * in the array.
2507
+ *
2508
+ * @static
2509
+ * @memberOf _
2510
+ * @since 0.1.0
2511
+ * @category Array
2512
+ * @param {Array} array The array to inspect.
2513
+ * @returns {Array} Returns the new duplicate free array.
2514
+ * @example
2515
+ *
2516
+ * _.uniq([2, 1, 2]);
2517
+ * // => [2, 1]
2518
+ */
2519
+ function uniq(array) {
2520
+ return (array && array.length) ? baseUniq(array) : [];
2521
+ }
2522
+
2523
+ /**
2524
+ * Creates an array excluding all given values using
2525
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
2526
+ * for equality comparisons.
2527
+ *
2528
+ * **Note:** Unlike `_.pull`, this method returns a new array.
2529
+ *
2530
+ * @static
2531
+ * @memberOf _
2532
+ * @since 0.1.0
2533
+ * @category Array
2534
+ * @param {Array} array The array to inspect.
2535
+ * @param {...*} [values] The values to exclude.
2536
+ * @returns {Array} Returns the new array of filtered values.
2537
+ * @see _.difference, _.xor
2538
+ * @example
2539
+ *
2540
+ * _.without([2, 1, 2, 3], 1, 2);
2541
+ * // => [3]
2542
+ */
2543
+ var without = baseRest(function(array, values) {
2544
+ return isArrayLikeObject(array)
2545
+ ? baseDifference(array, values)
2546
+ : [];
2547
+ });
2548
+
2549
+ /**
2550
+ * The base implementation of methods like `_.xor`, without support for
2551
+ * iteratee shorthands, that accepts an array of arrays to inspect.
2552
+ *
2553
+ * @private
2554
+ * @param {Array} arrays The arrays to inspect.
2555
+ * @param {Function} [iteratee] The iteratee invoked per element.
2556
+ * @param {Function} [comparator] The comparator invoked per element.
2557
+ * @returns {Array} Returns the new array of values.
2558
+ */
2559
+ function baseXor(arrays, iteratee, comparator) {
2560
+ var length = arrays.length;
2561
+ if (length < 2) {
2562
+ return length ? baseUniq(arrays[0]) : [];
2563
+ }
2564
+ var index = -1,
2565
+ result = Array(length);
2566
+
2567
+ while (++index < length) {
2568
+ var array = arrays[index],
2569
+ othIndex = -1;
2570
+
2571
+ while (++othIndex < length) {
2572
+ if (othIndex != index) {
2573
+ result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
2574
+ }
2575
+ }
2576
+ }
2577
+ return baseUniq(baseFlatten(result), iteratee, comparator);
2578
+ }
2579
+
2580
+ /**
2581
+ * Creates an array of unique values that is the
2582
+ * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
2583
+ * of the given arrays. The order of result values is determined by the order
2584
+ * they occur in the arrays.
2585
+ *
2586
+ * @static
2587
+ * @memberOf _
2588
+ * @since 2.4.0
2589
+ * @category Array
2590
+ * @param {...Array} [arrays] The arrays to inspect.
2591
+ * @returns {Array} Returns the new array of filtered values.
2592
+ * @see _.difference, _.without
2593
+ * @example
2594
+ *
2595
+ * _.xor([2, 1], [2, 3]);
2596
+ * // => [1, 3]
2597
+ */
2598
+ var xor = baseRest(function(arrays) {
2599
+ return baseXor(arrayFilter(arrays, isArrayLikeObject));
2600
+ });
2601
+
2602
+ //
2603
+
2604
+ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
2605
+ var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
2606
+
2607
+ if (ret !== void 0) {
2608
+ return !!ret;
2609
+ }
2610
+
2611
+ if (objA === objB) {
2612
+ return true;
2613
+ }
2614
+
2615
+ if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
2616
+ return false;
2617
+ }
2618
+
2619
+ var keysA = Object.keys(objA);
2620
+ var keysB = Object.keys(objB);
2621
+
2622
+ if (keysA.length !== keysB.length) {
2623
+ return false;
2624
+ }
2625
+
2626
+ var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
2627
+
2628
+ // Test for A's keys different from B.
2629
+ for (var idx = 0; idx < keysA.length; idx++) {
2630
+ var key = keysA[idx];
2631
+
2632
+ if (!bHasOwnProperty(key)) {
2633
+ return false;
2634
+ }
2635
+
2636
+ var valueA = objA[key];
2637
+ var valueB = objB[key];
2638
+
2639
+ ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
2640
+
2641
+ if (ret === false || (ret === void 0 && valueA !== valueB)) {
2642
+ return false;
2643
+ }
2644
+ }
2645
+
2646
+ return true;
2647
+ };
2648
+
2649
+ var shallowequal$1 = /*@__PURE__*/getDefaultExportFromCjs(shallowequal);
2650
+
2651
+ // This Source Code Form is subject to the terms of the Mozilla Public
2652
+ // License, v2.0. If a copy of the MPL was not distributed with this
2653
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2654
+ //
2655
+ // This file incorporates work covered by the following copyright and
2656
+ // permission notice:
2657
+ //
2658
+ // Copyright 2018-2021 Cruise LLC
2659
+ //
2660
+ // This source code is licensed under the Apache License, Version 2.0,
2661
+ // found at http://www.apache.org/licenses/LICENSE-2.0
2662
+ // You may not use this file except in compliance with the License.
2663
+
2664
+ function useGuaranteedContext(contextType, debugContextName) {
2665
+ const context = useContext(contextType);
2666
+ if (context == undefined) {
2667
+ throw new Error(`useGuaranteedContext got null for contextType${""}`);
2668
+ }
2669
+ return context;
2670
+ }
2671
+
2672
+ // This Source Code Form is subject to the terms of the Mozilla Public
2673
+ // License, v2.0. If a copy of the MPL was not distributed with this
2674
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2675
+
2676
+ const log$5 = Logger$1.getLogger("src/index.ts");
2677
+ const useMustNotChangeImpl = value => {
2678
+ const valueRef = useRef(value);
2679
+ if (valueRef.current !== value) {
2680
+ log$5.error("Value must not change", valueRef.current);
2681
+ }
2682
+ valueRef.current = value;
2683
+ };
2684
+ const noOpImpl$1 = () => {};
2685
+
2686
+ /**
2687
+ * useMustNotChange throws if the value provided as the first argument ever changes.
2688
+ *
2689
+ * Note: In production builds this hook is a no-op.
2690
+ *
2691
+ */
2692
+ const useMustNotChange = process.env.NODE_ENV !== "development" ? noOpImpl$1 : useMustNotChangeImpl;
2693
+
2694
+ // This Source Code Form is subject to the terms of the Mozilla Public
2695
+ // License, v2.0. If a copy of the MPL was not distributed with this
2696
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2697
+
2698
+ /** Continues to return the same instance as long as shallow equality is maintained. */
2699
+ function useShallowMemo(value) {
2700
+ const ref = useRef(value);
2701
+ if (shallowequal$1(value, ref.current)) {
2702
+ return ref.current;
2703
+ }
2704
+ ref.current = value;
2705
+ return value;
2706
+ }
2707
+
2708
+ // This Source Code Form is subject to the terms of the Mozilla Public
2709
+ // License, v2.0. If a copy of the MPL was not distributed with this
2710
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2711
+
2712
+ const log$4 = Logger$1.getLogger("src/index.ts");
2713
+ const noOpImpl = () => {};
2714
+ function useValueChangedDebugLogImpl(value, msg) {
2715
+ const prevValue = useRef(value);
2716
+ if (prevValue.current !== value) {
2717
+ log$4.debug(`value changed: ${msg}`);
2718
+ }
2719
+ useLayoutEffect(() => {
2720
+ prevValue.current = value;
2721
+ });
2722
+ }
2723
+
2724
+ /**
2725
+ * useValueChangedDebugLog logs `msg` if `value` changes
2726
+ *
2727
+ * Note: In production builds this hook is a no-op.
2728
+ */
2729
+ const useValueChangedDebugLog = process.env.NODE_ENV !== "development" && process.env.NODE_ENV !== "test" ? noOpImpl : useValueChangedDebugLogImpl;
2730
+
2731
+ // This Source Code Form is subject to the terms of the Mozilla Public
2732
+ // License, v2.0. If a copy of the MPL was not distributed with this
2733
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2734
+ const log$3 = Logger$1.getLogger("src/index.ts");
2735
+
2736
+ // useWarnImmediateReRender will warn if the component re-renders before the next animation frame
2737
+ // This typically indicates that the component state is changing in rapid succession and more
2738
+ // work is being done than necessary.
2739
+ //
2740
+ // Note: This detects state change triggers in useLayoutEffect. It does not detect state changes from
2741
+ // useEffect which run on the next animation frame.
2742
+ process.env.NODE_ENV !== "development" ? () => {} : () => {
2743
+ const renderedRef = useRef(false);
2744
+ useLayoutEffect(() => {
2745
+ if (renderedRef.current) {
2746
+ log$3.warn("Component re-rendered immediately");
2747
+ }
2748
+ renderedRef.current = true;
2749
+ const raf = requestAnimationFrame(() => {
2750
+ renderedRef.current = false;
2751
+ });
2752
+ return () => {
2753
+ cancelAnimationFrame(raf);
2754
+ };
2755
+ });
2756
+ };
2757
+
2758
+ // This Source Code Form is subject to the terms of the Mozilla Public
2759
+ // License, v2.0. If a copy of the MPL was not distributed with this
2760
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2761
+
2762
+ Logger$1.getLogger("src/index.ts");
2763
+
2764
+ // This Source Code Form is subject to the terms of the Mozilla Public
2765
+ // License, v2.0. If a copy of the MPL was not distributed with this
2766
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2767
+ const log$2 = Logger$1.getLogger("src/index.ts");
2768
+ function selectWithUnstableIdentityWarning(value, selector) {
2769
+ const result = selector(value);
2770
+ if (process.env.NODE_ENV === "development") {
2771
+ const secondResult = selector(value);
2772
+ if (result !== secondResult) {
2773
+ log$2.warn(`Selector ${selector.toString()} produced different values for the same input.
2774
+ This will cause unecesessery re-renders of your component.`);
2775
+ }
2776
+ return secondResult;
2777
+ }
2778
+ return result;
2779
+ }
2780
+
2781
+ // This Source Code Form is subject to the terms of the Mozilla Public
2782
+ // License, v2.0. If a copy of the MPL was not distributed with this
2783
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2784
+ //
2785
+ // This file incorporates work covered by the following copyright and
2786
+ // permission notice:
2787
+ //
2788
+ // Copyright 2018-2021 Cruise LLC
2789
+ //
2790
+ // This source code is licensed under the Apache License, Version 2.0,
2791
+ // found at http://www.apache.org/licenses/LICENSE-2.0
2792
+ // You may not use this file except in compliance with the License.
2793
+
2794
+
2795
+ // Call _warn_ if a given value changes twice within 200 ms
2796
+ function useShouldNotChangeOften(value, warn) {
2797
+ const prev = useRef(value);
2798
+ const prevPrev = useRef(value);
2799
+ const lastTime = useRef(Date.now());
2800
+ if (value !== prev.current && prev.current !== prevPrev.current && Date.now() - lastTime.current < 200) {
2801
+ warn();
2802
+ }
2803
+ prevPrev.current = prev.current;
2804
+ prev.current = value;
2805
+ lastTime.current = Date.now();
2806
+ return value;
2807
+ }
2808
+
2809
+ // This Source Code Form is subject to the terms of the Mozilla Public
2810
+ // License, v2.0. If a copy of the MPL was not distributed with this
2811
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2812
+ //
2813
+ // This file incorporates work covered by the following copyright and
2814
+ // permission notice:
2815
+ //
2816
+ // Copyright 2019-2021 Cruise LLC
2817
+ //
2818
+ // This source code is licensed under the Apache License, Version 2.0,
2819
+ // found at http://www.apache.org/licenses/LICENSE-2.0
2820
+ // You may not use this file except in compliance with the License.
2821
+
2822
+ /**
2823
+ * filterMap creates a new array populated with the results of calling a provided function on every
2824
+ * element in the calling array. Results which resolve to a javascript "false" value are discarded
2825
+ * from the array.
2826
+ *
2827
+ * This is a more efficient version of [...values].map(mapFn).filter(Boolean) that avoids two
2828
+ * iterations of the array.
2829
+ */
2830
+ function filterMap(values, mapFn) {
2831
+ const results = [];
2832
+ let index = 0;
2833
+ for (const item of values) {
2834
+ const mappedItem = mapFn(item, index++);
2835
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
2836
+ if (mappedItem) {
2837
+ results.push(mappedItem);
2838
+ }
2839
+ }
2840
+ return results;
2841
+ }
2842
+
2843
+ // This Source Code Form is subject to the terms of the Mozilla Public
2844
+ // License, v2.0. If a copy of the MPL was not distributed with this
2845
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2846
+ //
2847
+ // This file incorporates work covered by the following copyright and
2848
+ // permission notice:
2849
+ //
2850
+ // Copyright 2018-2021 Cruise LLC
2851
+ //
2852
+ // This source code is licensed under the Apache License, Version 2.0,
2853
+ // found at http://www.apache.org/licenses/LICENSE-2.0
2854
+ // You may not use this file except in compliance with the License.
2855
+ function useJsonTreeTheme() {
2856
+ const {
2857
+ palette: {
2858
+ mode,
2859
+ text
2860
+ }
2861
+ } = useTheme();
2862
+ return {
2863
+ dark: {
2864
+ base00: "transparent",
2865
+ // bg
2866
+ base0B: "#ffa657",
2867
+ // string & date, item string
2868
+ base09: "#7ee787",
2869
+ // # & boolean
2870
+ base07: "#79c0ff",
2871
+ // text
2872
+ base08: "#ff7b72",
2873
+ // null, undefined, function, & symbol
2874
+ base0D: "#79c0ff",
2875
+ // label & arrow
2876
+ base03: text.secondary // item string expanded
2877
+ },
2878
+ light: {
2879
+ base00: "transparent",
2880
+ // bg
2881
+ base0B: "#953800",
2882
+ // string & date, item string
2883
+ base09: "#116329",
2884
+ // # & boolean
2885
+ base07: "#0550ae",
2886
+ // text
2887
+ base08: "#cf222e",
2888
+ // null, undefined, function, & symbol
2889
+ base0D: "#0550ae",
2890
+ // label & arrow
2891
+ base03: text.secondary // item string expanded
2892
+ }
2893
+ }[mode];
2894
+ }
2895
+ const TAB_PANEL_TYPE = "Tab";
2896
+
2897
+ // This Source Code Form is subject to the terms of the Mozilla Public
2898
+ // License, v2.0. If a copy of the MPL was not distributed with this
2899
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
2900
+ //
2901
+ // This file incorporates work covered by the following copyright and
2902
+ // permission notice:
2903
+ //
2904
+ // Copyright 2019-2021 Cruise LLC
2905
+ //
2906
+ // This source code is licensed under the Apache License, Version 2.0,
2907
+ // found at http://www.apache.org/licenses/LICENSE-2.0
2908
+ // You may not use this file except in compliance with the License.
2909
+ const log$1 = Logger$1.getLogger("src/index.ts");
2910
+
2911
+ /** Key injected into panel configs for user-selected title (overrides setDefaultPanelTitle) */
2912
+ const PANEL_TITLE_CONFIG_KEY = "foxglovePanelTitle";
2913
+
2914
+ // given a panel type, create a unique id for a panel
2915
+ // with the type embedded within the id
2916
+ // we need this because react-mosaic
2917
+ function getPanelIdForType(type) {
2918
+ const factor = 1e10;
2919
+ const rnd = Math.round(Math.random() * factor).toString(36);
2920
+ // a panel id consists of its type, an exclamation mark for splitting, and a random val
2921
+ // because each panel id functions is the react 'key' for the react-mosaic-component layout
2922
+ // but also must encode the panel type for panel factory construction
2923
+ return `${type}!${rnd}`;
2924
+ }
2925
+ function getPanelTypeFromId(id) {
2926
+ return id.split("!")[0] ?? "";
2927
+ }
2928
+ function isTabPanel(panelId) {
2929
+ return getPanelTypeFromId(panelId) === TAB_PANEL_TYPE;
2930
+ }
2931
+ function isTabPanelConfig(config) {
2932
+ return config != undefined && "tabs" in config && "activeTabIdx" in config;
2933
+ }
2934
+
2935
+ // Traverses `tree` to find the path to the specified `node`
2936
+ function getPathFromNode(node, tree,
2937
+ // eslint-disable-line no-restricted-syntax
2938
+ path = []) {
2939
+ if (tree === node) {
2940
+ return path;
2941
+ }
2942
+ if (tree != undefined && isParent(tree)) {
2943
+ const first = getPathFromNode(node, tree.first, [...path, "first"]);
2944
+ if (first.length > 0) {
2945
+ return first;
2946
+ }
2947
+ const second = getPathFromNode(node, tree.second, [...path, "second"]);
2948
+ if (second.length > 0) {
2949
+ return second;
2950
+ }
2951
+ }
2952
+ return [];
2953
+ }
2954
+ function mapTemplateIdsToNewIds(templateIds) {
2955
+ const result = {};
2956
+ for (const id of templateIds) {
2957
+ result[id] = getPanelIdForType(getPanelTypeFromId(id));
2958
+ }
2959
+ return result;
2960
+ }
2961
+ function getLayoutWithNewPanelIds(layout, panelIdMap) {
2962
+ if (typeof layout === "string") {
2963
+ // return corresponding ID if it exists in panelIdMap
2964
+ // (e.g. for Tab panel presets with 1 panel in active layout)
2965
+ return panelIdMap[layout] ?? getPanelIdForType(getPanelTypeFromId(layout));
2966
+ }
2967
+ if (layout == undefined) {
2968
+ return undefined;
2969
+ }
2970
+ const newLayout = {};
2971
+ for (const key in layout) {
2972
+ if (typeof layout[key] === "object" && !Array.isArray(layout[key])) {
2973
+ newLayout[key] = getLayoutWithNewPanelIds(layout[key], panelIdMap);
2974
+ } else if (typeof layout[key] === "string" && panelIdMap[layout[key]] != undefined) {
2975
+ newLayout[key] = panelIdMap[layout[key]];
2976
+ } else {
2977
+ newLayout[key] = layout[key];
2978
+ }
2979
+ }
2980
+ return newLayout;
2981
+ }
2982
+
2983
+ // Recursively removes all empty nodes from a layout
2984
+ function compactLayout(layout) {
2985
+ if (typeof layout === "string") {
2986
+ return layout;
2987
+ }
2988
+ const prunedChildren = [layout.first, layout.second].filter(Boolean).map(compactLayout);
2989
+ const [first, second] = prunedChildren;
2990
+ if (first == undefined && second == undefined) {
2991
+ return "";
2992
+ } else if (first != undefined && second != undefined) {
2993
+ return {
2994
+ ...layout,
2995
+ first,
2996
+ second
2997
+ };
2998
+ }
2999
+ return {
3000
+ ...layout,
3001
+ first: first ?? second ?? "",
3002
+ second: ""
3003
+ };
3004
+ }
3005
+
3006
+ // Recursively replaces all leaves of the current layout
3007
+ function replaceLeafLayouts(layout, replacerFn) {
3008
+ if (typeof layout === "string") {
3009
+ return replacerFn(layout);
3010
+ }
3011
+ return {
3012
+ ...layout,
3013
+ first: replaceLeafLayouts(layout.first, replacerFn),
3014
+ second: replaceLeafLayouts(layout.second, replacerFn)
3015
+ };
3016
+ }
3017
+
3018
+ // Replaces Tab panels with their active tab's layout
3019
+ function inlineTabPanelLayouts(layout, savedProps, preserveTabPanelIds) {
3020
+ const tabFreeLayout = replaceLeafLayouts(layout, id => {
3021
+ if (typeof id === "string" && isTabPanel(id) && !preserveTabPanelIds.includes(id)) {
3022
+ const panelProps = getValidTabPanelConfig(id, savedProps);
3023
+ const tabLayout = panelProps.tabs[panelProps.activeTabIdx]?.layout;
3024
+ if (tabLayout != undefined) {
3025
+ return inlineTabPanelLayouts(tabLayout, savedProps, preserveTabPanelIds);
3026
+ }
3027
+ }
3028
+ return id;
3029
+ });
3030
+ return compactLayout(tabFreeLayout);
3031
+ }
3032
+
3033
+ // Maps panels to their parent Tab panel
3034
+ const getParentTabPanelByPanelId = savedProps => Object.entries(savedProps).reduce((memo, [savedPanelId, savedConfig]) => {
3035
+ if (isTabPanel(savedPanelId) && savedConfig != undefined) {
3036
+ const tabPanelConfig = savedConfig;
3037
+ tabPanelConfig.tabs?.forEach(tab => {
3038
+ const panelIdsInTab = getLeaves(tab.layout ?? null);
3039
+ panelIdsInTab.forEach(id => memo[id] = savedPanelId);
3040
+ });
3041
+ }
3042
+ return memo;
3043
+ }, {});
3044
+ const replaceMaybeTabLayoutWithNewPanelIds = panelIdMap => {
3045
+ return ({
3046
+ id,
3047
+ config
3048
+ }) => {
3049
+ return config.tabs ? {
3050
+ id,
3051
+ config: {
3052
+ ...config,
3053
+ tabs: config.tabs.map(tab => ({
3054
+ ...tab,
3055
+ layout: getLayoutWithNewPanelIds(tab.layout, panelIdMap)
3056
+ }))
3057
+ }
3058
+ } : {
3059
+ id,
3060
+ config
3061
+ };
3062
+ };
3063
+ };
3064
+ const getSaveConfigsPayloadForAddedPanel = ({
3065
+ id,
3066
+ config,
3067
+ savedProps
3068
+ }) => {
3069
+ const templateIds = getPanelIdsInsideTabPanels([id],
3070
+ // Merge the new config with existing configs in case the new panel is a Tab that references other existing panels
3071
+ {
3072
+ ...savedProps,
3073
+ [id]: config
3074
+ });
3075
+ const panelIdMap = mapTemplateIdsToNewIds(templateIds);
3076
+ const newConfigs = filterMap(templateIds, templateId => {
3077
+ const panelId = panelIdMap[templateId];
3078
+ const panelProps = savedProps[templateId];
3079
+ if (panelId == undefined || panelProps == undefined) {
3080
+ return;
3081
+ }
3082
+ return {
3083
+ id: panelId,
3084
+ config: panelProps
3085
+ };
3086
+ });
3087
+ const allConfigs = [...newConfigs, {
3088
+ id,
3089
+ config
3090
+ }].map(replaceMaybeTabLayoutWithNewPanelIds(panelIdMap));
3091
+ return {
3092
+ configs: allConfigs
3093
+ };
3094
+ };
3095
+ function getPanelIdsInsideTabPanels(panelIds, savedProps) {
3096
+ const tabPanelIds = panelIds.filter(isTabPanel);
3097
+ const tabLayouts = [];
3098
+ tabPanelIds.forEach(panelId => {
3099
+ const tabProps = savedProps[panelId];
3100
+ if (tabProps?.tabs) {
3101
+ tabProps.tabs.forEach(tab => {
3102
+ tabLayouts.push(tab.layout, ...getPanelIdsInsideTabPanels(getLeaves(tab.layout ?? null), savedProps));
3103
+ });
3104
+ }
3105
+ });
3106
+ return flatMap(tabLayouts, getLeaves);
3107
+ }
3108
+ const DEFAULT_TAB_PANEL_CONFIG = {
3109
+ activeTabIdx: 0,
3110
+ tabs: [{
3111
+ title: "1",
3112
+ layout: undefined
3113
+ }]
3114
+ };
3115
+ // Returns all panelIds for a given layout (including layouts stored in Tab panels)
3116
+ function getAllPanelIds(layout, savedProps) {
3117
+ const layoutPanelIds = getLeaves(layout);
3118
+ const tabPanelIds = getPanelIdsInsideTabPanels(layoutPanelIds, savedProps);
3119
+ return [...layoutPanelIds, ...tabPanelIds];
3120
+ }
3121
+ const validateTabPanelConfig = config => {
3122
+ if (!config) {
3123
+ return false;
3124
+ }
3125
+ if (!Array.isArray(config.tabs) || typeof config.activeTabIdx !== "number") {
3126
+ const error = new Error("A non-Tab panel config is being operated on as if it were a Tab panel.");
3127
+ log$1.info(`Invalid Tab panel config: ${error.message}`, config);
3128
+ reportError(error);
3129
+ return false;
3130
+ }
3131
+ if (config.activeTabIdx >= config.tabs.length) {
3132
+ const error = new Error("A Tab panel has an activeTabIdx for a nonexistent tab.");
3133
+ log$1.info(`Invalid Tab panel config: ${error.message}`, config);
3134
+ reportError(error);
3135
+ return false;
3136
+ }
3137
+ return true;
3138
+ };
3139
+ const updateTabPanelLayout = (layout, tabPanelConfig) => {
3140
+ const updatedTabs = tabPanelConfig.tabs.map((tab, i) => {
3141
+ if (i === tabPanelConfig.activeTabIdx) {
3142
+ return {
3143
+ ...tab,
3144
+ layout
3145
+ };
3146
+ }
3147
+ return tab;
3148
+ });
3149
+ // Create a new tab if there isn't one active
3150
+ if (tabPanelConfig.activeTabIdx === -1) {
3151
+ updatedTabs.push({
3152
+ layout,
3153
+ title: "1"
3154
+ });
3155
+ }
3156
+ return {
3157
+ ...tabPanelConfig,
3158
+ tabs: updatedTabs,
3159
+ activeTabIdx: Math.max(0, tabPanelConfig.activeTabIdx)
3160
+ };
3161
+ };
3162
+ const removePanelFromTabPanel = (path = [], config, tabId) => {
3163
+ if (!validateTabPanelConfig(config)) {
3164
+ return {
3165
+ configs: []
3166
+ };
3167
+ }
3168
+ const currentTabLayout = config.tabs[config.activeTabIdx]?.layout;
3169
+ let newTree;
3170
+ if (path.length === 0) {
3171
+ newTree = undefined;
3172
+ } else {
3173
+ const update = createRemoveUpdate(currentTabLayout ?? null, path);
3174
+ newTree = updateTree(currentTabLayout, [update]);
3175
+ }
3176
+ const saveConfigsPayload = {
3177
+ configs: [{
3178
+ id: tabId,
3179
+ config: updateTabPanelLayout(newTree, config)
3180
+ }]
3181
+ };
3182
+ return saveConfigsPayload;
3183
+ };
3184
+ const createAddUpdates = (tree, panelId, newPath, position) => {
3185
+ if (tree == undefined) {
3186
+ return [];
3187
+ }
3188
+ const node = getNodeAtPath(tree, newPath);
3189
+ const before = position === "left" || position === "top";
3190
+ const [first, second] = before ? [panelId, node] : [node, panelId];
3191
+ const direction = position === "left" || position === "right" ? "row" : "column";
3192
+ const updates = [{
3193
+ path: newPath,
3194
+ spec: {
3195
+ $set: {
3196
+ first,
3197
+ second,
3198
+ direction
3199
+ }
3200
+ }
3201
+ }];
3202
+ return updates;
3203
+ };
3204
+ const addPanelToTab = (insertedPanelId, destinationPath, destinationPosition, tabConfig, tabId) => {
3205
+ const safeTabConfig = validateTabPanelConfig(tabConfig) ? tabConfig : DEFAULT_TAB_PANEL_CONFIG;
3206
+ const currentTabLayout = safeTabConfig.tabs[safeTabConfig.activeTabIdx]?.layout;
3207
+ const newTree = currentTabLayout != undefined && destinationPath && destinationPosition != undefined ? updateTree(currentTabLayout, createAddUpdates(currentTabLayout, insertedPanelId, destinationPath, destinationPosition)) : insertedPanelId;
3208
+ const saveConfigsPayload = {
3209
+ configs: [{
3210
+ id: tabId,
3211
+ config: updateTabPanelLayout(newTree, safeTabConfig)
3212
+ }]
3213
+ };
3214
+ return saveConfigsPayload;
3215
+ };
3216
+ function getValidTabPanelConfig(panelId, savedProps) {
3217
+ const config = savedProps[panelId];
3218
+ if (!config) {
3219
+ return DEFAULT_TAB_PANEL_CONFIG;
3220
+ }
3221
+ return validateTabPanelConfig(config) ? config : DEFAULT_TAB_PANEL_CONFIG;
3222
+ }
3223
+ const reorderTabWithinTabPanel = ({
3224
+ source,
3225
+ target,
3226
+ savedProps
3227
+ }) => {
3228
+ const {
3229
+ tabs,
3230
+ activeTabIdx
3231
+ } = getValidTabPanelConfig(source.panelId, savedProps);
3232
+ const sourceIndex = source.tabIndex ?? tabs.length - 1; // source.tabIndex will always be set
3233
+ const targetIndex = target.tabIndex ?? tabs.length - 1; // target.tabIndex will only be set when dropping on a tab
3234
+
3235
+ const nextSourceTabs = [...tabs.slice(0, sourceIndex), ...tabs.slice(sourceIndex + 1)];
3236
+ nextSourceTabs.splice(targetIndex, 0, tabs[sourceIndex]);
3237
+
3238
+ // Update activeTabIdx so the active tab does not change when we move the tab
3239
+ const movedActiveTab = activeTabIdx === source.tabIndex;
3240
+ const movedToBeforeActiveTab = targetIndex <= activeTabIdx && sourceIndex >= activeTabIdx;
3241
+ const movedFromBeforeActiveTab = sourceIndex <= activeTabIdx && targetIndex >= activeTabIdx;
3242
+ let nextActiveTabIdx = activeTabIdx;
3243
+ if (movedActiveTab) {
3244
+ nextActiveTabIdx = targetIndex;
3245
+ } else if (movedToBeforeActiveTab) {
3246
+ nextActiveTabIdx++;
3247
+ } else if (movedFromBeforeActiveTab) {
3248
+ nextActiveTabIdx--;
3249
+ }
3250
+ return {
3251
+ configs: [{
3252
+ id: source.panelId,
3253
+ config: {
3254
+ tabs: nextSourceTabs,
3255
+ activeTabIdx: nextActiveTabIdx
3256
+ }
3257
+ }]
3258
+ };
3259
+ };
3260
+ const moveTabBetweenTabPanels = ({
3261
+ source,
3262
+ target,
3263
+ savedProps
3264
+ }) => {
3265
+ const sourceConfig = getValidTabPanelConfig(source.panelId, savedProps);
3266
+ const targetConfig = getValidTabPanelConfig(target.panelId, savedProps);
3267
+ const sourceIndex = source.tabIndex ?? sourceConfig.tabs.length;
3268
+ const targetIndex = target.tabIndex ?? targetConfig.tabs.length;
3269
+ const nextTabsSource = [...sourceConfig.tabs.slice(0, sourceIndex), ...sourceConfig.tabs.slice(sourceIndex + 1)];
3270
+ const nextTabsTarget = targetConfig.tabs.slice();
3271
+ nextTabsTarget.splice(targetIndex, 0, sourceConfig.tabs[sourceIndex]);
3272
+
3273
+ // Update activeTabIdx so the active tab does not change as we move the tab
3274
+ const movedToBeforeActiveTabSource = sourceIndex <= sourceConfig.activeTabIdx;
3275
+ const nextActiveTabIdxSource = movedToBeforeActiveTabSource ? Math.max(0, sourceConfig.activeTabIdx - 1) : sourceConfig.activeTabIdx;
3276
+ const movedToBeforeActiveTabTarget = targetIndex <= targetConfig.activeTabIdx;
3277
+ const nextActiveTabIdxTarget = movedToBeforeActiveTabTarget ? targetConfig.activeTabIdx + 1 : targetConfig.activeTabIdx;
3278
+ return {
3279
+ configs: [{
3280
+ id: source.panelId,
3281
+ config: {
3282
+ tabs: nextTabsSource,
3283
+ activeTabIdx: nextActiveTabIdxSource
3284
+ }
3285
+ }, {
3286
+ id: target.panelId,
3287
+ config: {
3288
+ tabs: nextTabsTarget,
3289
+ activeTabIdx: nextActiveTabIdxTarget
3290
+ }
3291
+ }]
3292
+ };
3293
+ };
3294
+ const replaceAndRemovePanels = (panelArgs, layout) => {
3295
+ const {
3296
+ originalId,
3297
+ newId,
3298
+ idsToRemove = []
3299
+ } = panelArgs;
3300
+ const panelIds = getLeaves(layout);
3301
+ if (xor(panelIds, idsToRemove).length === 0) {
3302
+ return newId;
3303
+ }
3304
+ return uniq(compact([...idsToRemove, originalId])).reduce((currentLayout, panelIdToRemove) => {
3305
+ if (!panelIds.includes(panelIdToRemove)) {
3306
+ return currentLayout;
3307
+ } else if (currentLayout === originalId) {
3308
+ return newId;
3309
+ } else if (currentLayout == undefined || currentLayout === panelIdToRemove) {
3310
+ return undefined;
3311
+ }
3312
+ const pathToNode = getPathFromNode(panelIdToRemove, currentLayout);
3313
+ const update = panelIdToRemove === originalId ? {
3314
+ path: pathToNode,
3315
+ spec: {
3316
+ $set: newId
3317
+ }
3318
+ } : createRemoveUpdate(currentLayout, pathToNode);
3319
+ return updateTree(currentLayout, [update]);
3320
+ }, layout);
3321
+ };
3322
+ function getConfigsForNestedPanelsInsideTab(panelIdToReplace, tabPanelId, panelIdsToRemove, savedProps) {
3323
+ const configs = [];
3324
+ const tabPanelIds = Object.keys(savedProps).filter(isTabPanel);
3325
+ tabPanelIds.forEach(panelId => {
3326
+ const {
3327
+ tabs,
3328
+ activeTabIdx
3329
+ } = getValidTabPanelConfig(panelId, savedProps);
3330
+ const tabLayout = tabs[activeTabIdx]?.layout;
3331
+ if (tabLayout != undefined && getLeaves(tabLayout).some(id => panelIdsToRemove.includes(id))) {
3332
+ const newTabLayout = replaceAndRemovePanels({
3333
+ originalId: panelIdToReplace,
3334
+ newId: tabPanelId,
3335
+ idsToRemove: panelIdsToRemove
3336
+ }, tabLayout);
3337
+ const newTabConfig = updateTabPanelLayout(newTabLayout, savedProps[panelId]);
3338
+ configs.push({
3339
+ id: panelId,
3340
+ config: newTabConfig
3341
+ });
3342
+ }
3343
+ });
3344
+ return configs;
3345
+ }
3346
+
3347
+ // This Source Code Form is subject to the terms of the Mozilla Public
3348
+ // License, v2.0. If a copy of the MPL was not distributed with this
3349
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3350
+ //
3351
+ // This file incorporates work covered by the following copyright and
3352
+ // permission notice:
3353
+ //
3354
+ // Copyright 2018-2021 Cruise LLC
3355
+ //
3356
+ // This source code is licensed under the Apache License, Version 2.0,
3357
+ // found at http://www.apache.org/licenses/LICENSE-2.0
3358
+ // You may not use this file except in compliance with the License.
3359
+
3360
+ function toggleSelectedPanel(panelId, containingTabId, configById, selectedPanelIds) {
3361
+ const panelIdsToDeselect = [];
3362
+
3363
+ // If we selected a Tab panel, deselect its children
3364
+ const savedConfig = configById[panelId];
3365
+ if (isTabPanel(panelId) && savedConfig) {
3366
+ const {
3367
+ activeTabIdx,
3368
+ tabs
3369
+ } = savedConfig;
3370
+ const activeTabLayout = tabs[activeTabIdx]?.layout;
3371
+ if (activeTabLayout != undefined) {
3372
+ const childrenPanelIds = getAllPanelIds(activeTabLayout, configById);
3373
+ panelIdsToDeselect.push(...childrenPanelIds);
3374
+ }
3375
+ }
3376
+
3377
+ // If we selected a child, deselect all parent Tab panels
3378
+ const parentTabPanelByPanelId = getParentTabPanelByPanelId(configById);
3379
+ let nextParentId = containingTabId;
3380
+ const parentTabPanelIds = [];
3381
+ while (nextParentId != undefined) {
3382
+ parentTabPanelIds.push(nextParentId);
3383
+ nextParentId = parentTabPanelByPanelId[nextParentId];
3384
+ }
3385
+ panelIdsToDeselect.push(...parentTabPanelIds);
3386
+ const nextSelectedPanelIds = xor(selectedPanelIds, [panelId]);
3387
+ const nextValidSelectedPanelIds = without(nextSelectedPanelIds, ...panelIdsToDeselect);
3388
+ return nextValidSelectedPanelIds;
3389
+ }
3390
+
3391
+ // This Source Code Form is subject to the terms of the Mozilla Public
3392
+ // License, v2.0. If a copy of the MPL was not distributed with this
3393
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3394
+
3395
+
3396
+ /**
3397
+ * Encapsulates the mosaic layout, user nodes, and playback settings (everything considered to be
3398
+ * part of a saved "layout") used by the current workspace.
3399
+ */
3400
+
3401
+ const log = Logger$1.getLogger("src/index.ts");
3402
+ const CurrentLayoutContext = /*#__PURE__*/createContext(undefined);
3403
+ CurrentLayoutContext.displayName = "CurrentLayoutContext";
3404
+ function usePanelMosaicId() {
3405
+ return useGuaranteedContext(CurrentLayoutContext).mosaicId;
3406
+ }
3407
+ function useCurrentLayoutActions() {
3408
+ return useGuaranteedContext(CurrentLayoutContext).actions;
3409
+ }
3410
+ function useCurrentLayoutSelector(selector) {
3411
+ const currentLayout = useGuaranteedContext(CurrentLayoutContext);
3412
+ const [, forceUpdate] = useReducer(x => x + 1, 0);
3413
+
3414
+ // Catch locations using unstable function selectors
3415
+ useShouldNotChangeOften(selector, () => {
3416
+ log.warn("useCurrentLayoutSelector is changing frequently. Rewrite your selector as a stable function.");
3417
+ });
3418
+ const state = useRef(undefined);
3419
+ if (!state.current || selector !== state.current.selector) {
3420
+ state.current = {
3421
+ value: selectWithUnstableIdentityWarning(currentLayout.actions.getCurrentLayoutState(), selector),
3422
+ selector
3423
+ };
3424
+ }
3425
+ useLayoutEffect(() => {
3426
+ let mounted = true;
3427
+ const listener = layoutState => {
3428
+ // Note: Our removeLayoutStateListener is is too late if the layout state listeners are already
3429
+ // being invoked. Our component might become unmounted during the state listener invocation
3430
+ if (!mounted) {
3431
+ return;
3432
+ }
3433
+ const newValue = selectWithUnstableIdentityWarning(layoutState, selector);
3434
+ if (newValue === state.current?.value) {
3435
+ return;
3436
+ }
3437
+ state.current = {
3438
+ value: newValue,
3439
+ selector
3440
+ };
3441
+ forceUpdate();
3442
+ };
3443
+ // Update if necessary, i.e. if the state has changed between render and this effect
3444
+ listener(currentLayout.actions.getCurrentLayoutState());
3445
+ currentLayout.addLayoutStateListener(listener);
3446
+ return () => {
3447
+ mounted = false;
3448
+ currentLayout.removeLayoutStateListener(listener);
3449
+ };
3450
+ }, [currentLayout, selector]);
3451
+ return state.current.value;
3452
+ }
3453
+ function useSelectedPanels() {
3454
+ const currentLayout = useGuaranteedContext(CurrentLayoutContext);
3455
+ const [selectedPanelIds, setSelectedPanelIdsState] = useState(() => currentLayout.getSelectedPanelIds());
3456
+ useLayoutEffect(() => {
3457
+ const listener = newIds => {
3458
+ setSelectedPanelIdsState(newIds);
3459
+ };
3460
+ currentLayout.addSelectedPanelIdsListener(listener);
3461
+ return () => {
3462
+ currentLayout.removeSelectedPanelIdsListener(listener);
3463
+ };
3464
+ }, [currentLayout]);
3465
+ const setSelectedPanelIds = useGuaranteedContext(CurrentLayoutContext).setSelectedPanelIds;
3466
+ const getSelectedPanelIds = useGuaranteedContext(CurrentLayoutContext).getSelectedPanelIds;
3467
+ const {
3468
+ getCurrentLayoutState: getCurrentLayout
3469
+ } = useCurrentLayoutActions();
3470
+ const selectAllPanels = useCallback(() => {
3471
+ // eslint-disable-next-line no-restricted-syntax
3472
+ const panelIds = getLeaves(getCurrentLayout().selectedLayout?.data?.layout ?? null);
3473
+ setSelectedPanelIds(panelIds);
3474
+ }, [getCurrentLayout, setSelectedPanelIds]);
3475
+ const togglePanelSelected = useCallback((panelId, containingTabId) => {
3476
+ setSelectedPanelIds(selectedIds => {
3477
+ const {
3478
+ selectedLayout
3479
+ } = getCurrentLayout();
3480
+ if (!selectedLayout?.data) {
3481
+ return selectedIds;
3482
+ }
3483
+ return toggleSelectedPanel(panelId, containingTabId, selectedLayout.data.configById, selectedIds);
3484
+ });
3485
+ }, [setSelectedPanelIds, getCurrentLayout]);
3486
+ return useShallowMemo({
3487
+ getSelectedPanelIds,
3488
+ selectedPanelIds,
3489
+ setSelectedPanelIds,
3490
+ selectAllPanels,
3491
+ togglePanelSelected
3492
+ });
3493
+ }
3494
+
3495
+ // This Source Code Form is subject to the terms of the Mozilla Public
3496
+ // License, v2.0. If a copy of the MPL was not distributed with this
3497
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3498
+
3499
+
3500
+ // individual app configuration values are basic primitive types
3501
+
3502
+ // Exposes an interface for reading and writing user-configurable options and other persistent application state.
3503
+
3504
+ const AppConfigurationContext = /*#__PURE__*/createContext(undefined);
3505
+ AppConfigurationContext.displayName = "AppConfigurationContext";
3506
+ function useAppConfiguration() {
3507
+ const storage = useContext(AppConfigurationContext);
3508
+ if (!storage) {
3509
+ throw new Error("An AppConfigurationContext provider is required to useAppConfiguration");
3510
+ }
3511
+ return storage;
3512
+ }
3513
+
3514
+ // This Source Code Form is subject to the terms of the Mozilla Public
3515
+ // License, v2.0. If a copy of the MPL was not distributed with this
3516
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3517
+ //
3518
+ // This file incorporates work covered by the following copyright and
3519
+ // permission notice:
3520
+ //
3521
+ // Copyright 2018-2021 Cruise LLC
3522
+ //
3523
+ // This source code is licensed under the Apache License, Version 2.0,
3524
+ // found at http://www.apache.org/licenses/LICENSE-2.0
3525
+ // You may not use this file except in compliance with the License.
3526
+
3527
+ function formatFrame({
3528
+ sec,
3529
+ nsec
3530
+ }) {
3531
+ return `${sec}.${String.prototype.padStart.call(nsec, 9, "0")}`;
3532
+ }
3533
+
3534
+ // This Source Code Form is subject to the terms of the Mozilla Public
3535
+ // License, v2.0. If a copy of the MPL was not distributed with this
3536
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3537
+ //
3538
+ // This file incorporates work covered by the following copyright and
3539
+ // permission notice:
3540
+ //
3541
+ // Copyright 2018-2021 Cruise LLC
3542
+ //
3543
+ // This source code is licensed under the Apache License, Version 2.0,
3544
+ // found at http://www.apache.org/licenses/LICENSE-2.0
3545
+ // You may not use this file except in compliance with the License.
3546
+
3547
+ const DRIFT_THRESHOLD_SEC = 1; // Maximum amount of drift allowed.
3548
+ const WAIT_FOR_SEEK_SEC = 1; // How long we wait for a change in `lastSeekTime` before warning.
3549
+
3550
+ Logger$1.getLogger("src/index.ts");
3551
+
3552
+ // Logs a warning when there is a significant difference (more than `DRIFT_THRESHOLD_SEC`) between
3553
+ // a message's timestamp and `player.currentTime` OR when messages went back in time,
3554
+ // except when `player.lastSeekTime` changes, in which case panels should be clearing out their stored data.
3555
+ //
3556
+ // This is to ensure that other mechanisms that we have in place for either discarding old messages
3557
+ // or forcing an update of `player.lastSeekTime` are working properly.
3558
+ class MessageOrderTracker {
3559
+ #lastMessages = [];
3560
+ #lastCurrentTime;
3561
+ #lastMessageTime;
3562
+ #lastMessageTopic;
3563
+ #lastLastSeekTime;
3564
+ #warningTimeout;
3565
+
3566
+ /**
3567
+ * Set this to `true` to debug out-of-order messages. It is disabled by default in production
3568
+ * because logging messages to the console prevents them from getting garbage-collected as long as
3569
+ * the console is not cleared.
3570
+ */
3571
+ #trackIncorrectMessages = false;
3572
+ #incorrectMessages = [];
3573
+ update(playerState) {
3574
+ if (!playerState.activeData) {
3575
+ return [];
3576
+ }
3577
+ const problems = [];
3578
+ const {
3579
+ messages,
3580
+ currentTime,
3581
+ lastSeekTime
3582
+ } = playerState.activeData;
3583
+ let didSeek = false;
3584
+ if (this.#lastLastSeekTime !== lastSeekTime) {
3585
+ this.#lastLastSeekTime = lastSeekTime;
3586
+ if (this.#warningTimeout) {
3587
+ clearTimeout(this.#warningTimeout);
3588
+ this.#warningTimeout = undefined;
3589
+ this.#incorrectMessages = [];
3590
+ }
3591
+ this.#warningTimeout = this.#lastMessageTime = this.#lastCurrentTime = undefined;
3592
+ this.#lastMessages = [];
3593
+ didSeek = true;
3594
+ }
3595
+ if (this.#lastMessages !== messages || this.#lastCurrentTime !== currentTime) {
3596
+ this.#lastMessages = messages;
3597
+ this.#lastCurrentTime = currentTime;
3598
+ for (const message of messages) {
3599
+ const messageTime = message.receiveTime;
3600
+
3601
+ // The first emit after a seek occurs from a backfill. This backfill might produce messages
3602
+ // much older than the seek time.
3603
+ if (!didSeek) {
3604
+ const currentTimeDrift = Math.abs(dist.toSec(dist.subtract(messageTime, currentTime)));
3605
+ if (currentTimeDrift > DRIFT_THRESHOLD_SEC) {
3606
+ if (this.#trackIncorrectMessages) {
3607
+ this.#incorrectMessages.push(message);
3608
+ }
3609
+ if (!this.#warningTimeout) {
3610
+ this.#warningTimeout = setTimeout(() => {
3611
+ // timeout has fired, we need to clear so a new timeout registers if there are more messages
3612
+ this.#warningTimeout = undefined;
3613
+ // reset incorrect message queue before posting warning so we never keep
3614
+ // incorrectMessages around. The browser console will keep messages in memory when
3615
+ // logged, so disable logging of messages unless explicitly enabled.
3616
+ // const info = {
3617
+ // topic: message.topic,
3618
+ // currentTime,
3619
+ // lastSeekTime,
3620
+ // messageTime,
3621
+ // incorrectMessages: this.#trackIncorrectMessages
3622
+ // ? this.#incorrectMessages
3623
+ // : "not being tracked"
3624
+ // };
3625
+ this.#incorrectMessages = [];
3626
+ // log.warn(
3627
+ // `Message receiveTime very different from player.currentTime; without updating lastSeekTime`,
3628
+ // info
3629
+ // );
3630
+ }, WAIT_FOR_SEEK_SEC * 1000);
3631
+ }
3632
+ }
3633
+ }
3634
+ if (this.#lastMessageTime && this.#lastMessageTopic != undefined && dist.isLessThan(messageTime, this.#lastMessageTime)) {
3635
+ const formattedTime = formatFrame(messageTime);
3636
+ const lastMessageTime = formatFrame(this.#lastMessageTime);
3637
+ const errorMessage = `Processed a message on ${message.topic} at ${formattedTime} which is earlier than ` + `last processed message on ${this.#lastMessageTopic} at ${lastMessageTime}.`;
3638
+ problems.push({
3639
+ severity: "warn",
3640
+ message: "Data went back in time",
3641
+ error: new Error(errorMessage)
3642
+ });
3643
+ }
3644
+ this.#lastMessageTopic = message.topic;
3645
+ this.#lastMessageTime = messageTime;
3646
+ }
3647
+ }
3648
+ return problems;
3649
+ }
3650
+ }
3651
+
3652
+ // This Source Code Form is subject to the terms of the Mozilla Public
3653
+ // License, v2.0. If a copy of the MPL was not distributed with this
3654
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3655
+ //
3656
+ // This file incorporates work covered by the following copyright and
3657
+ // permission notice:
3658
+ //
3659
+ // Copyright 2019-2021 Cruise LLC
3660
+ //
3661
+ // This source code is licensed under the Apache License, Version 2.0,
3662
+ // found at http://www.apache.org/licenses/LICENSE-2.0
3663
+ // You may not use this file except in compliance with the License.
3664
+
3665
+ const inWebWorker = () => {
3666
+ return typeof global.postMessage !== "undefined" && typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
3667
+ };
3668
+
3669
+ // This Source Code Form is subject to the terms of the Mozilla Public
3670
+ // License, v2.0. If a copy of the MPL was not distributed with this
3671
+ // file, You can obtain one at http://mozilla.org/MPL/2.0/
3672
+ //
3673
+ // This file incorporates work covered by the following copyright and
3674
+ // permission notice:
3675
+ //
3676
+ // Copyright 2018-2021 Cruise LLC
3677
+ //
3678
+ // This source code is licensed under the Apache License, Version 2.0,
3679
+ // found at http://www.apache.org/licenses/LICENSE-2.0
3680
+ // You may not use this file except in compliance with the License.
3681
+
3682
+ const defaultNotificationHandler = (message, details, type, severity) => {
3683
+ if (inWebWorker()) {
3684
+ const webWorkerError = "Web Worker has uninitialized sendNotification function; this means this error message cannot show up in the UI (so we show it here in the console instead).";
3685
+ if (process.env.NODE_ENV === "test") {
3686
+ throw new Error(webWorkerError);
3687
+ } else {
3688
+ const consoleFn = severity === "error" ? console.error : severity === "warn" ? console.warn : console.info;
3689
+ consoleFn(webWorkerError, message, details, type);
3690
+ }
3691
+ return;
3692
+ } else if (process.env.NODE_ENV === "test") {
3693
+ return;
3694
+ }
3695
+ console.error("Notification before error display is mounted", message, details, type);
3696
+ };
3697
+ let addNotification = defaultNotificationHandler;
3698
+
3699
+ // Call this to add an notification to the application nav bar error component if mounted.
3700
+ // If the component is not mounted, use the console as a fallback.
3701
+ function sendNotification(message, details, type, severity) {
3702
+ // We only want to send non-user errors and warnings to Sentry
3703
+ if (type === "app") {
3704
+ if (severity === "warn" || severity === "error") {
3705
+ reportError(new AppError(details, message));
3706
+ }
3707
+ }
3708
+ addNotification(message, details, type, severity);
3709
+ }
3710
+ sendNotification.expectCalledDuringTest = () => {
3711
+ throw new Error("Should be overriden in setupTestFramework.ts");
3712
+ };
3713
+
3714
+ /******************************************************************************
3715
+ Copyright (c) Microsoft Corporation.
3716
+
3717
+ Permission to use, copy, modify, and/or distribute this software for any
3718
+ purpose with or without fee is hereby granted.
3719
+
3720
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3721
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3722
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3723
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3724
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3725
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3726
+ PERFORMANCE OF THIS SOFTWARE.
3727
+ ***************************************************************************** */
3728
+ /* global Reflect, Promise, SuppressedError, Symbol */
3729
+
3730
+ var extendStatics = function(d, b) {
3731
+ extendStatics = Object.setPrototypeOf ||
3732
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3733
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
3734
+ return extendStatics(d, b);
3735
+ };
3736
+
3737
+ function __extends(d, b) {
3738
+ if (typeof b !== "function" && b !== null)
3739
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
3740
+ extendStatics(d, b);
3741
+ function __() { this.constructor = d; }
3742
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3743
+ }
3744
+
3745
+ var __assign = function() {
3746
+ __assign = Object.assign || function __assign(t) {
3747
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3748
+ s = arguments[i];
3749
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3750
+ }
3751
+ return t;
3752
+ };
3753
+ return __assign.apply(this, arguments);
3754
+ };
3755
+
3756
+ function __rest(s, e) {
3757
+ var t = {};
3758
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3759
+ t[p] = s[p];
3760
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
3761
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3762
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3763
+ t[p[i]] = s[p[i]];
3764
+ }
3765
+ return t;
3766
+ }
3767
+
3768
+ function __decorate(decorators, target, key, desc) {
3769
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3770
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3771
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3772
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3773
+ }
3774
+
3775
+ function __param(paramIndex, decorator) {
3776
+ return function (target, key) { decorator(target, key, paramIndex); }
3777
+ }
3778
+
3779
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3780
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3781
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
3782
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
3783
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
3784
+ var _, done = false;
3785
+ for (var i = decorators.length - 1; i >= 0; i--) {
3786
+ var context = {};
3787
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
3788
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
3789
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
3790
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
3791
+ if (kind === "accessor") {
3792
+ if (result === void 0) continue;
3793
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
3794
+ if (_ = accept(result.get)) descriptor.get = _;
3795
+ if (_ = accept(result.set)) descriptor.set = _;
3796
+ if (_ = accept(result.init)) initializers.unshift(_);
3797
+ }
3798
+ else if (_ = accept(result)) {
3799
+ if (kind === "field") initializers.unshift(_);
3800
+ else descriptor[key] = _;
3801
+ }
3802
+ }
3803
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
3804
+ done = true;
3805
+ }
3806
+ function __runInitializers(thisArg, initializers, value) {
3807
+ var useValue = arguments.length > 2;
3808
+ for (var i = 0; i < initializers.length; i++) {
3809
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
3810
+ }
3811
+ return useValue ? value : void 0;
3812
+ }
3813
+ function __propKey(x) {
3814
+ return typeof x === "symbol" ? x : "".concat(x);
3815
+ }
3816
+ function __setFunctionName(f, name, prefix) {
3817
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
3818
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
3819
+ }
3820
+ function __metadata(metadataKey, metadataValue) {
3821
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
3822
+ }
3823
+
3824
+ function __awaiter(thisArg, _arguments, P, generator) {
3825
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3826
+ return new (P || (P = Promise))(function (resolve, reject) {
3827
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3828
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3829
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3830
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3831
+ });
3832
+ }
3833
+
3834
+ function __generator(thisArg, body) {
3835
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3836
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
3837
+ function verb(n) { return function (v) { return step([n, v]); }; }
3838
+ function step(op) {
3839
+ if (f) throw new TypeError("Generator is already executing.");
3840
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
3841
+ 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;
3842
+ if (y = 0, t) op = [op[0] & 2, t.value];
3843
+ switch (op[0]) {
3844
+ case 0: case 1: t = op; break;
3845
+ case 4: _.label++; return { value: op[1], done: false };
3846
+ case 5: _.label++; y = op[1]; op = [0]; continue;
3847
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
3848
+ default:
3849
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
3850
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
3851
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
3852
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
3853
+ if (t[2]) _.ops.pop();
3854
+ _.trys.pop(); continue;
3855
+ }
3856
+ op = body.call(thisArg, _);
3857
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
3858
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
3859
+ }
3860
+ }
3861
+
3862
+ var __createBinding = Object.create ? (function(o, m, k, k2) {
3863
+ if (k2 === undefined) k2 = k;
3864
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3865
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3866
+ desc = { enumerable: true, get: function() { return m[k]; } };
3867
+ }
3868
+ Object.defineProperty(o, k2, desc);
3869
+ }) : (function(o, m, k, k2) {
3870
+ if (k2 === undefined) k2 = k;
3871
+ o[k2] = m[k];
3872
+ });
3873
+
3874
+ function __exportStar(m, o) {
3875
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
3876
+ }
3877
+
3878
+ function __values(o) {
3879
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3880
+ if (m) return m.call(o);
3881
+ if (o && typeof o.length === "number") return {
3882
+ next: function () {
3883
+ if (o && i >= o.length) o = void 0;
3884
+ return { value: o && o[i++], done: !o };
3885
+ }
3886
+ };
3887
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3888
+ }
3889
+
3890
+ function __read(o, n) {
3891
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3892
+ if (!m) return o;
3893
+ var i = m.call(o), r, ar = [], e;
3894
+ try {
3895
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
3896
+ }
3897
+ catch (error) { e = { error: error }; }
3898
+ finally {
3899
+ try {
3900
+ if (r && !r.done && (m = i["return"])) m.call(i);
3901
+ }
3902
+ finally { if (e) throw e.error; }
3903
+ }
3904
+ return ar;
3905
+ }
3906
+
3907
+ /** @deprecated */
3908
+ function __spread() {
3909
+ for (var ar = [], i = 0; i < arguments.length; i++)
3910
+ ar = ar.concat(__read(arguments[i]));
3911
+ return ar;
3912
+ }
3913
+
3914
+ /** @deprecated */
3915
+ function __spreadArrays() {
3916
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
3917
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
3918
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
3919
+ r[k] = a[j];
3920
+ return r;
3921
+ }
3922
+
3923
+ function __spreadArray(to, from, pack) {
3924
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3925
+ if (ar || !(i in from)) {
3926
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3927
+ ar[i] = from[i];
3928
+ }
3929
+ }
3930
+ return to.concat(ar || Array.prototype.slice.call(from));
3931
+ }
3932
+
3933
+ function __await(v) {
3934
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
3935
+ }
3936
+
3937
+ function __asyncGenerator(thisArg, _arguments, generator) {
3938
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3939
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
3940
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
3941
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
3942
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
3943
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
3944
+ function fulfill(value) { resume("next", value); }
3945
+ function reject(value) { resume("throw", value); }
3946
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
3947
+ }
3948
+
3949
+ function __asyncDelegator(o) {
3950
+ var i, p;
3951
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
3952
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
3953
+ }
3954
+
3955
+ function __asyncValues(o) {
3956
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3957
+ var m = o[Symbol.asyncIterator], i;
3958
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
3959
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
3960
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
3961
+ }
3962
+
3963
+ function __makeTemplateObject(cooked, raw) {
3964
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3965
+ return cooked;
3966
+ }
3967
+ var __setModuleDefault = Object.create ? (function(o, v) {
3968
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
3969
+ }) : function(o, v) {
3970
+ o["default"] = v;
3971
+ };
3972
+
3973
+ function __importStar(mod) {
3974
+ if (mod && mod.__esModule) return mod;
3975
+ var result = {};
3976
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
3977
+ __setModuleDefault(result, mod);
3978
+ return result;
3979
+ }
3980
+
3981
+ function __importDefault(mod) {
3982
+ return (mod && mod.__esModule) ? mod : { default: mod };
3983
+ }
3984
+
3985
+ function __classPrivateFieldGet(receiver, state, kind, f) {
3986
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3987
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3988
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3989
+ }
3990
+
3991
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
3992
+ if (kind === "m") throw new TypeError("Private method is not writable");
3993
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3994
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3995
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3996
+ }
3997
+
3998
+ function __classPrivateFieldIn(state, receiver) {
3999
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
4000
+ return typeof state === "function" ? receiver === state : state.has(receiver);
4001
+ }
4002
+
4003
+ function __addDisposableResource(env, value, async) {
4004
+ if (value !== null && value !== void 0) {
4005
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4006
+ var dispose;
4007
+ if (async) {
4008
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
4009
+ dispose = value[Symbol.asyncDispose];
4010
+ }
4011
+ if (dispose === void 0) {
4012
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
4013
+ dispose = value[Symbol.dispose];
4014
+ }
4015
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
4016
+ env.stack.push({ value: value, dispose: dispose, async: async });
4017
+ }
4018
+ else if (async) {
4019
+ env.stack.push({ async: true });
4020
+ }
4021
+ return value;
4022
+ }
4023
+
4024
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
4025
+ var e = new Error(message);
4026
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4027
+ };
4028
+
4029
+ function __disposeResources(env) {
4030
+ function fail(e) {
4031
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
4032
+ env.hasError = true;
4033
+ }
4034
+ function next() {
4035
+ while (env.stack.length) {
4036
+ var rec = env.stack.pop();
4037
+ try {
4038
+ var result = rec.dispose && rec.dispose.call(rec.value);
4039
+ if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
4040
+ }
4041
+ catch (e) {
4042
+ fail(e);
4043
+ }
4044
+ }
4045
+ if (env.hasError) throw env.error;
4046
+ }
4047
+ return next();
4048
+ }
4049
+
4050
+ var tslib_es6 = {
4051
+ __extends,
4052
+ __assign,
4053
+ __rest,
4054
+ __decorate,
4055
+ __param,
4056
+ __metadata,
4057
+ __awaiter,
4058
+ __generator,
4059
+ __createBinding,
4060
+ __exportStar,
4061
+ __values,
4062
+ __read,
4063
+ __spread,
4064
+ __spreadArrays,
4065
+ __spreadArray,
4066
+ __await,
4067
+ __asyncGenerator,
4068
+ __asyncDelegator,
4069
+ __asyncValues,
4070
+ __makeTemplateObject,
4071
+ __importStar,
4072
+ __importDefault,
4073
+ __classPrivateFieldGet,
4074
+ __classPrivateFieldSet,
4075
+ __classPrivateFieldIn,
4076
+ __addDisposableResource,
4077
+ __disposeResources,
4078
+ };
4079
+
4080
+ var tslib_es6$1 = /*#__PURE__*/Object.freeze({
4081
+ __proto__: null,
4082
+ __addDisposableResource: __addDisposableResource,
4083
+ get __assign () { return __assign; },
4084
+ __asyncDelegator: __asyncDelegator,
4085
+ __asyncGenerator: __asyncGenerator,
4086
+ __asyncValues: __asyncValues,
4087
+ __await: __await,
4088
+ __awaiter: __awaiter,
4089
+ __classPrivateFieldGet: __classPrivateFieldGet,
4090
+ __classPrivateFieldIn: __classPrivateFieldIn,
4091
+ __classPrivateFieldSet: __classPrivateFieldSet,
4092
+ __createBinding: __createBinding,
4093
+ __decorate: __decorate,
4094
+ __disposeResources: __disposeResources,
4095
+ __esDecorate: __esDecorate,
4096
+ __exportStar: __exportStar,
4097
+ __extends: __extends,
4098
+ __generator: __generator,
4099
+ __importDefault: __importDefault,
4100
+ __importStar: __importStar,
4101
+ __makeTemplateObject: __makeTemplateObject,
4102
+ __metadata: __metadata,
4103
+ __param: __param,
4104
+ __propKey: __propKey,
4105
+ __read: __read,
4106
+ __rest: __rest,
4107
+ __runInitializers: __runInitializers,
4108
+ __setFunctionName: __setFunctionName,
4109
+ __spread: __spread,
4110
+ __spreadArray: __spreadArray,
4111
+ __spreadArrays: __spreadArrays,
4112
+ __values: __values,
4113
+ default: tslib_es6
4114
+ });
4115
+
4116
+ export { arrayPush as $, AppError as A, inlineTabPanelLayouts as B, getAllPanelIds as C, getConfigsForNestedPanelsInsideTab as D, reorderTabWithinTabPanel as E, moveTabBetweenTabPanels as F, isTabPanelConfig as G, DEFAULT_TAB_PANEL_CONFIG as H, addPanelToTab as I, createAddUpdates as J, filterMap as K, Logger$1 as L, uniq as M, useShallowMemo as N, CurrentLayoutContext as O, MessageOrderTracker as P, AppConfigurationContext as Q, __rest as R, __spreadArray as S, TAB_PANEL_TYPE as T, uint8ArrayToUint16Array as U, isSymbol as V, toString as W, keys as X, getSymbols as Y, stubArray as Z, __assign as _, baseEach as a, baseGetAllKeys as a0, getAllKeys as a1, arrayMap as a2, baseUniq as a3, useMustNotChange as a4, useCurrentLayoutActions as a5, useCurrentLayoutSelector as a6, usePanelMosaicId as a7, useSelectedPanels as a8, PANEL_TITLE_CONFIG_KEY as a9, noop as aa, useAppConfiguration as ab, useValueChangedDebugLog as ac, useJsonTreeTheme as ad, tslib_es6$1 as ae, baseFlatten as b, baseIteratee as c, dist as d, estimateObjectSize as e, baseDifference as f, getTag as g, baseKeys as h, i420ToRgbaToPointcloudWorker as i, baseIsEqual as j, castPath as k, baseGet as l, hasIn as m, shallowequal$1 as n, getPanelIdsInsideTabPanels as o, getPanelTypeFromId as p, removePanelFromTabPanel as q, reportError as r, sendNotification as s, toKey as t, useGuaranteedContext as u, getPanelIdForType as v, getPathFromNode as w, updateTabPanelLayout as x, getSaveConfigsPayloadForAddedPanel as y, replaceAndRemovePanels as z };