@bigbinary/neeto-templates-frontend 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2928 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var neetoCist = require('@bigbinary/neeto-cist');
7
+ var neetoui = require('@bigbinary/neetoui');
8
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
9
+ var neetoIcons = require('@bigbinary/neeto-icons');
10
+ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
11
+ var Scrollable = require('@bigbinary/neeto-molecules/Scrollable');
12
+ var reactI18next = require('react-i18next');
13
+ var ramda = require('ramda');
14
+ var reactQuery = require('react-query');
15
+ var axios = require('axios');
16
+ var require$$0 = require('util');
17
+ var constants = require('@bigbinary/neeto-commons-frontend/constants');
18
+ var CustomSVG = require('images/dashboard/custom');
19
+ var classnames = require('classnames');
20
+ var utils$3 = require('@bigbinary/neeto-commons-frontend/utils');
21
+
22
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
+
24
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
25
+ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
26
+ var Scrollable__default = /*#__PURE__*/_interopDefaultLegacy(Scrollable);
27
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
28
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
29
+ var CustomSVG__default = /*#__PURE__*/_interopDefaultLegacy(CustomSVG);
30
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
31
+
32
+ function _arrayWithHoles(arr) {
33
+ if (Array.isArray(arr)) return arr;
34
+ }
35
+
36
+ function _iterableToArrayLimit(arr, i) {
37
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
38
+ if (null != _i) {
39
+ var _s,
40
+ _e,
41
+ _x,
42
+ _r,
43
+ _arr = [],
44
+ _n = !0,
45
+ _d = !1;
46
+ try {
47
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
48
+ if (Object(_i) !== _i) return;
49
+ _n = !1;
50
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
51
+ } catch (err) {
52
+ _d = !0, _e = err;
53
+ } finally {
54
+ try {
55
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
56
+ } finally {
57
+ if (_d) throw _e;
58
+ }
59
+ }
60
+ return _arr;
61
+ }
62
+ }
63
+
64
+ function _arrayLikeToArray(arr, len) {
65
+ if (len == null || len > arr.length) len = arr.length;
66
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
67
+ return arr2;
68
+ }
69
+
70
+ function _unsupportedIterableToArray(o, minLen) {
71
+ if (!o) return;
72
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
73
+ var n = Object.prototype.toString.call(o).slice(8, -1);
74
+ if (n === "Object" && o.constructor) n = o.constructor.name;
75
+ if (n === "Map" || n === "Set") return Array.from(o);
76
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
77
+ }
78
+
79
+ function _nonIterableRest() {
80
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
81
+ }
82
+
83
+ function _slicedToArray(arr, i) {
84
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
85
+ }
86
+
87
+ var TEMPLATE_SCREENS = {
88
+ LIST: "List",
89
+ PREVIEW: "Preview"
90
+ };
91
+ var PREVIEW_URL = "/:publicLinkId?embedPreview=true&templateView=true";
92
+ var DEFAULT_CATEGORY = {
93
+ id: "all",
94
+ name: "All"
95
+ };
96
+ var INFINITE_SCROLL_DELAY = 500;
97
+
98
+ function _typeof(obj) {
99
+ "@babel/helpers - typeof";
100
+
101
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
102
+ return typeof obj;
103
+ } : function (obj) {
104
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
105
+ }, _typeof(obj);
106
+ }
107
+
108
+ function _toPrimitive(input, hint) {
109
+ if (_typeof(input) !== "object" || input === null) return input;
110
+ var prim = input[Symbol.toPrimitive];
111
+ if (prim !== undefined) {
112
+ var res = prim.call(input, hint || "default");
113
+ if (_typeof(res) !== "object") return res;
114
+ throw new TypeError("@@toPrimitive must return a primitive value.");
115
+ }
116
+ return (hint === "string" ? String : Number)(input);
117
+ }
118
+
119
+ function _toPropertyKey(arg) {
120
+ var key = _toPrimitive(arg, "string");
121
+ return _typeof(key) === "symbol" ? key : String(key);
122
+ }
123
+
124
+ function _defineProperty(obj, key, value) {
125
+ key = _toPropertyKey(key);
126
+ if (key in obj) {
127
+ Object.defineProperty(obj, key, {
128
+ value: value,
129
+ enumerable: true,
130
+ configurable: true,
131
+ writable: true
132
+ });
133
+ } else {
134
+ obj[key] = value;
135
+ }
136
+ return obj;
137
+ }
138
+
139
+ function _arrayWithoutHoles(arr) {
140
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
141
+ }
142
+
143
+ function _iterableToArray(iter) {
144
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
145
+ }
146
+
147
+ function _nonIterableSpread() {
148
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
149
+ }
150
+
151
+ function _toConsumableArray(arr) {
152
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
153
+ }
154
+
155
+ function createObserverCache() {
156
+ var cachesByRoot = new Map();
157
+
158
+ function getObserver(_ref) {
159
+ var root = _ref.root,
160
+ rootMargin = _ref.rootMargin,
161
+ threshold = _ref.threshold;
162
+ var cacheByRoot = cachesByRoot.get(root);
163
+
164
+ if (!cacheByRoot) {
165
+ cacheByRoot = new Map();
166
+ cachesByRoot.set(root, cacheByRoot);
167
+ }
168
+
169
+ var cacheKey = JSON.stringify({
170
+ rootMargin: rootMargin,
171
+ threshold: threshold
172
+ });
173
+ var cachedObserver = cacheByRoot.get(cacheKey);
174
+
175
+ if (!cachedObserver) {
176
+ var entryCallbacks = new Map();
177
+ var observer = new IntersectionObserver(function (entries) {
178
+ entries.forEach(function (entry) {
179
+ var callback = entryCallbacks.get(entry.target);
180
+ callback == null ? void 0 : callback(entry);
181
+ });
182
+ }, {
183
+ root: root,
184
+ rootMargin: rootMargin,
185
+ threshold: threshold
186
+ });
187
+ cachedObserver = {
188
+ observer: observer,
189
+ entryCallbacks: entryCallbacks
190
+ };
191
+ cacheByRoot.set(cacheKey, cachedObserver);
192
+ }
193
+
194
+ return {
195
+ observe: function observe(node, callback) {
196
+ var _cachedObserver, _cachedObserver2;
197
+
198
+ (_cachedObserver = cachedObserver) == null ? void 0 : _cachedObserver.entryCallbacks.set(node, callback);
199
+ (_cachedObserver2 = cachedObserver) == null ? void 0 : _cachedObserver2.observer.observe(node);
200
+ },
201
+ unobserve: function unobserve(node) {
202
+ var _cachedObserver3, _cachedObserver4;
203
+
204
+ (_cachedObserver3 = cachedObserver) == null ? void 0 : _cachedObserver3.entryCallbacks["delete"](node);
205
+ (_cachedObserver4 = cachedObserver) == null ? void 0 : _cachedObserver4.observer.unobserve(node);
206
+ }
207
+ };
208
+ }
209
+
210
+ return {
211
+ getObserver: getObserver
212
+ };
213
+ }
214
+
215
+ var DEFAULT_ROOT_MARGIN = '0px';
216
+ var DEFAULT_THRESHOLD = [0];
217
+ var observerCache = /*#__PURE__*/createObserverCache(); // For more info:
218
+ // https://developers.google.com/web/updates/2016/04/intersectionobserver
219
+ // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
220
+
221
+ function useIntersectionObserver(args) {
222
+ var _args$rootMargin, _args$threshold;
223
+
224
+ var rootMargin = (_args$rootMargin = args == null ? void 0 : args.rootMargin) != null ? _args$rootMargin : DEFAULT_ROOT_MARGIN;
225
+ var threshold = (_args$threshold = args == null ? void 0 : args.threshold) != null ? _args$threshold : DEFAULT_THRESHOLD;
226
+ var nodeRef = React.useRef(null);
227
+ var rootRef = React.useRef(null);
228
+ var observerRef = React.useRef(null);
229
+
230
+ var _useState = React.useState(),
231
+ entry = _useState[0],
232
+ setEntry = _useState[1];
233
+
234
+ var observe = React.useCallback(function () {
235
+ var node = nodeRef.current;
236
+
237
+ if (!node) {
238
+ setEntry(undefined);
239
+ return;
240
+ }
241
+
242
+ var observer = observerCache.getObserver({
243
+ root: rootRef.current,
244
+ rootMargin: rootMargin,
245
+ threshold: threshold
246
+ });
247
+ observer.observe(node, function (observedEntry) {
248
+ setEntry(observedEntry);
249
+ });
250
+ observerRef.current = observer;
251
+ }, [rootMargin, threshold]);
252
+ var unobserve = React.useCallback(function () {
253
+ var currentObserver = observerRef.current;
254
+ var node = nodeRef.current;
255
+
256
+ if (node) {
257
+ currentObserver == null ? void 0 : currentObserver.unobserve(node);
258
+ }
259
+
260
+ observerRef.current = null;
261
+ }, []); // React will call the ref callback with the DOM element when the component mounts,
262
+ // and call it with null when it unmounts.
263
+ // So, we don't need an useEffect etc to unobserve nodes.
264
+ // When nodeRef.current is null, it will be unobserved and observe function
265
+ // won't do anything.
266
+
267
+ var refCallback = React.useCallback(function (node) {
268
+ unobserve();
269
+ nodeRef.current = node;
270
+ observe();
271
+ }, [observe, unobserve]);
272
+ var rootRefCallback = React.useCallback(function (rootNode) {
273
+ unobserve();
274
+ rootRef.current = rootNode;
275
+ observe();
276
+ }, [observe, unobserve]);
277
+ return [refCallback, {
278
+ entry: entry,
279
+ rootRef: rootRefCallback
280
+ }];
281
+ }
282
+
283
+ function _extends() {
284
+ _extends = Object.assign || function (target) {
285
+ for (var i = 1; i < arguments.length; i++) {
286
+ var source = arguments[i];
287
+
288
+ for (var key in source) {
289
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
290
+ target[key] = source[key];
291
+ }
292
+ }
293
+ }
294
+
295
+ return target;
296
+ };
297
+
298
+ return _extends.apply(this, arguments);
299
+ }
300
+
301
+ function useTrackVisibility(args) {
302
+ var _result$entry;
303
+
304
+ var _useIntersectionObser = useIntersectionObserver(args),
305
+ ref = _useIntersectionObser[0],
306
+ result = _useIntersectionObser[1];
307
+
308
+ var isVisible = Boolean((_result$entry = result.entry) == null ? void 0 : _result$entry.isIntersecting);
309
+
310
+ var _useState = React.useState(isVisible),
311
+ wasEverVisible = _useState[0],
312
+ setWasEverVisible = _useState[1];
313
+
314
+ if (isVisible && !wasEverVisible) {
315
+ setWasEverVisible(true);
316
+ }
317
+
318
+ return [ref, _extends({}, result, {
319
+ isVisible: isVisible,
320
+ wasEverVisible: wasEverVisible
321
+ })];
322
+ }
323
+
324
+ var DEFAULT_DELAY_IN_MS = 100;
325
+
326
+ function useInfiniteScroll(_ref) {
327
+ var loading = _ref.loading,
328
+ hasNextPage = _ref.hasNextPage,
329
+ onLoadMore = _ref.onLoadMore,
330
+ rootMargin = _ref.rootMargin,
331
+ disabled = _ref.disabled,
332
+ _ref$delayInMs = _ref.delayInMs,
333
+ delayInMs = _ref$delayInMs === void 0 ? DEFAULT_DELAY_IN_MS : _ref$delayInMs;
334
+
335
+ var _useTrackVisibility = useTrackVisibility({
336
+ rootMargin: rootMargin
337
+ }),
338
+ ref = _useTrackVisibility[0],
339
+ _useTrackVisibility$ = _useTrackVisibility[1],
340
+ rootRef = _useTrackVisibility$.rootRef,
341
+ isVisible = _useTrackVisibility$.isVisible;
342
+
343
+ var shouldLoadMore = !disabled && !loading && isVisible && hasNextPage; // eslint-disable-next-line consistent-return
344
+
345
+ React.useEffect(function () {
346
+ if (shouldLoadMore) {
347
+ // When we trigger 'onLoadMore' and new items are added to the list,
348
+ // right before they become rendered on the screen, 'loading' becomes false
349
+ // and 'isVisible' can be true for a brief time, based on the scroll position.
350
+ // So, it triggers 'onLoadMore' just after the first one is finished.
351
+ // We use a small delay here to prevent this kind of situations.
352
+ // It can be configured by hook args.
353
+ var timer = setTimeout(function () {
354
+ onLoadMore();
355
+ }, delayInMs);
356
+ return function () {
357
+ clearTimeout(timer);
358
+ };
359
+ }
360
+ }, [onLoadMore, shouldLoadMore, delayInMs]);
361
+ return [ref, {
362
+ rootRef: rootRef
363
+ }];
364
+ }
365
+
366
+ function _objectWithoutPropertiesLoose(source, excluded) {
367
+ if (source == null) return {};
368
+ var target = {};
369
+ var sourceKeys = Object.keys(source);
370
+ var key, i;
371
+ for (i = 0; i < sourceKeys.length; i++) {
372
+ key = sourceKeys[i];
373
+ if (excluded.indexOf(key) >= 0) continue;
374
+ target[key] = source[key];
375
+ }
376
+ return target;
377
+ }
378
+
379
+ function _objectWithoutProperties(source, excluded) {
380
+ if (source == null) return {};
381
+ var target = _objectWithoutPropertiesLoose(source, excluded);
382
+ var key, i;
383
+ if (Object.getOwnPropertySymbols) {
384
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
385
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
386
+ key = sourceSymbolKeys[i];
387
+ if (excluded.indexOf(key) >= 0) continue;
388
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
389
+ target[key] = source[key];
390
+ }
391
+ }
392
+ return target;
393
+ }
394
+
395
+ /* eslint complexity: [2, 18], max-statements: [2, 33] */
396
+ var shams = function hasSymbols() {
397
+ if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
398
+ if (typeof Symbol.iterator === 'symbol') { return true; }
399
+
400
+ var obj = {};
401
+ var sym = Symbol('test');
402
+ var symObj = Object(sym);
403
+ if (typeof sym === 'string') { return false; }
404
+
405
+ if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
406
+ if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
407
+
408
+ // temp disabled per https://github.com/ljharb/object.assign/issues/17
409
+ // if (sym instanceof Symbol) { return false; }
410
+ // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
411
+ // if (!(symObj instanceof Symbol)) { return false; }
412
+
413
+ // if (typeof Symbol.prototype.toString !== 'function') { return false; }
414
+ // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
415
+
416
+ var symVal = 42;
417
+ obj[sym] = symVal;
418
+ for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
419
+ if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
420
+
421
+ if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
422
+
423
+ var syms = Object.getOwnPropertySymbols(obj);
424
+ if (syms.length !== 1 || syms[0] !== sym) { return false; }
425
+
426
+ if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
427
+
428
+ if (typeof Object.getOwnPropertyDescriptor === 'function') {
429
+ var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
430
+ if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
431
+ }
432
+
433
+ return true;
434
+ };
435
+
436
+ var origSymbol = typeof Symbol !== 'undefined' && Symbol;
437
+ var hasSymbolSham = shams;
438
+
439
+ var hasSymbols$1 = function hasNativeSymbols() {
440
+ if (typeof origSymbol !== 'function') { return false; }
441
+ if (typeof Symbol !== 'function') { return false; }
442
+ if (typeof origSymbol('foo') !== 'symbol') { return false; }
443
+ if (typeof Symbol('bar') !== 'symbol') { return false; }
444
+
445
+ return hasSymbolSham();
446
+ };
447
+
448
+ var test = {
449
+ foo: {}
450
+ };
451
+
452
+ var $Object = Object;
453
+
454
+ var hasProto$1 = function hasProto() {
455
+ return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
456
+ };
457
+
458
+ /* eslint no-invalid-this: 1 */
459
+
460
+ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
461
+ var slice = Array.prototype.slice;
462
+ var toStr$1 = Object.prototype.toString;
463
+ var funcType = '[object Function]';
464
+
465
+ var implementation$1 = function bind(that) {
466
+ var target = this;
467
+ if (typeof target !== 'function' || toStr$1.call(target) !== funcType) {
468
+ throw new TypeError(ERROR_MESSAGE + target);
469
+ }
470
+ var args = slice.call(arguments, 1);
471
+
472
+ var bound;
473
+ var binder = function () {
474
+ if (this instanceof bound) {
475
+ var result = target.apply(
476
+ this,
477
+ args.concat(slice.call(arguments))
478
+ );
479
+ if (Object(result) === result) {
480
+ return result;
481
+ }
482
+ return this;
483
+ } else {
484
+ return target.apply(
485
+ that,
486
+ args.concat(slice.call(arguments))
487
+ );
488
+ }
489
+ };
490
+
491
+ var boundLength = Math.max(0, target.length - args.length);
492
+ var boundArgs = [];
493
+ for (var i = 0; i < boundLength; i++) {
494
+ boundArgs.push('$' + i);
495
+ }
496
+
497
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
498
+
499
+ if (target.prototype) {
500
+ var Empty = function Empty() {};
501
+ Empty.prototype = target.prototype;
502
+ bound.prototype = new Empty();
503
+ Empty.prototype = null;
504
+ }
505
+
506
+ return bound;
507
+ };
508
+
509
+ var implementation = implementation$1;
510
+
511
+ var functionBind = Function.prototype.bind || implementation;
512
+
513
+ var bind$1 = functionBind;
514
+
515
+ var src = bind$1.call(Function.call, Object.prototype.hasOwnProperty);
516
+
517
+ var undefined$1;
518
+
519
+ var $SyntaxError = SyntaxError;
520
+ var $Function = Function;
521
+ var $TypeError$1 = TypeError;
522
+
523
+ // eslint-disable-next-line consistent-return
524
+ var getEvalledConstructor = function (expressionSyntax) {
525
+ try {
526
+ return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
527
+ } catch (e) {}
528
+ };
529
+
530
+ var $gOPD = Object.getOwnPropertyDescriptor;
531
+ if ($gOPD) {
532
+ try {
533
+ $gOPD({}, '');
534
+ } catch (e) {
535
+ $gOPD = null; // this is IE 8, which has a broken gOPD
536
+ }
537
+ }
538
+
539
+ var throwTypeError = function () {
540
+ throw new $TypeError$1();
541
+ };
542
+ var ThrowTypeError = $gOPD
543
+ ? (function () {
544
+ try {
545
+ // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
546
+ arguments.callee; // IE 8 does not throw here
547
+ return throwTypeError;
548
+ } catch (calleeThrows) {
549
+ try {
550
+ // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
551
+ return $gOPD(arguments, 'callee').get;
552
+ } catch (gOPDthrows) {
553
+ return throwTypeError;
554
+ }
555
+ }
556
+ }())
557
+ : throwTypeError;
558
+
559
+ var hasSymbols = hasSymbols$1();
560
+ var hasProto = hasProto$1();
561
+
562
+ var getProto = Object.getPrototypeOf || (
563
+ hasProto
564
+ ? function (x) { return x.__proto__; } // eslint-disable-line no-proto
565
+ : null
566
+ );
567
+
568
+ var needsEval = {};
569
+
570
+ var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined$1 : getProto(Uint8Array);
571
+
572
+ var INTRINSICS = {
573
+ '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
574
+ '%Array%': Array,
575
+ '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
576
+ '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined$1,
577
+ '%AsyncFromSyncIteratorPrototype%': undefined$1,
578
+ '%AsyncFunction%': needsEval,
579
+ '%AsyncGenerator%': needsEval,
580
+ '%AsyncGeneratorFunction%': needsEval,
581
+ '%AsyncIteratorPrototype%': needsEval,
582
+ '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
583
+ '%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
584
+ '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined$1 : BigInt64Array,
585
+ '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined$1 : BigUint64Array,
586
+ '%Boolean%': Boolean,
587
+ '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
588
+ '%Date%': Date,
589
+ '%decodeURI%': decodeURI,
590
+ '%decodeURIComponent%': decodeURIComponent,
591
+ '%encodeURI%': encodeURI,
592
+ '%encodeURIComponent%': encodeURIComponent,
593
+ '%Error%': Error,
594
+ '%eval%': eval, // eslint-disable-line no-eval
595
+ '%EvalError%': EvalError,
596
+ '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
597
+ '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
598
+ '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
599
+ '%Function%': $Function,
600
+ '%GeneratorFunction%': needsEval,
601
+ '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
602
+ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
603
+ '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
604
+ '%isFinite%': isFinite,
605
+ '%isNaN%': isNaN,
606
+ '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
607
+ '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
608
+ '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
609
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
610
+ '%Math%': Math,
611
+ '%Number%': Number,
612
+ '%Object%': Object,
613
+ '%parseFloat%': parseFloat,
614
+ '%parseInt%': parseInt,
615
+ '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
616
+ '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
617
+ '%RangeError%': RangeError,
618
+ '%ReferenceError%': ReferenceError,
619
+ '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
620
+ '%RegExp%': RegExp,
621
+ '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
622
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
623
+ '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
624
+ '%String%': String,
625
+ '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined$1,
626
+ '%Symbol%': hasSymbols ? Symbol : undefined$1,
627
+ '%SyntaxError%': $SyntaxError,
628
+ '%ThrowTypeError%': ThrowTypeError,
629
+ '%TypedArray%': TypedArray,
630
+ '%TypeError%': $TypeError$1,
631
+ '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
632
+ '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
633
+ '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
634
+ '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
635
+ '%URIError%': URIError,
636
+ '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
637
+ '%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
638
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
639
+ };
640
+
641
+ if (getProto) {
642
+ try {
643
+ null.error; // eslint-disable-line no-unused-expressions
644
+ } catch (e) {
645
+ // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
646
+ var errorProto = getProto(getProto(e));
647
+ INTRINSICS['%Error.prototype%'] = errorProto;
648
+ }
649
+ }
650
+
651
+ var doEval = function doEval(name) {
652
+ var value;
653
+ if (name === '%AsyncFunction%') {
654
+ value = getEvalledConstructor('async function () {}');
655
+ } else if (name === '%GeneratorFunction%') {
656
+ value = getEvalledConstructor('function* () {}');
657
+ } else if (name === '%AsyncGeneratorFunction%') {
658
+ value = getEvalledConstructor('async function* () {}');
659
+ } else if (name === '%AsyncGenerator%') {
660
+ var fn = doEval('%AsyncGeneratorFunction%');
661
+ if (fn) {
662
+ value = fn.prototype;
663
+ }
664
+ } else if (name === '%AsyncIteratorPrototype%') {
665
+ var gen = doEval('%AsyncGenerator%');
666
+ if (gen && getProto) {
667
+ value = getProto(gen.prototype);
668
+ }
669
+ }
670
+
671
+ INTRINSICS[name] = value;
672
+
673
+ return value;
674
+ };
675
+
676
+ var LEGACY_ALIASES = {
677
+ '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
678
+ '%ArrayPrototype%': ['Array', 'prototype'],
679
+ '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
680
+ '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
681
+ '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
682
+ '%ArrayProto_values%': ['Array', 'prototype', 'values'],
683
+ '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
684
+ '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
685
+ '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
686
+ '%BooleanPrototype%': ['Boolean', 'prototype'],
687
+ '%DataViewPrototype%': ['DataView', 'prototype'],
688
+ '%DatePrototype%': ['Date', 'prototype'],
689
+ '%ErrorPrototype%': ['Error', 'prototype'],
690
+ '%EvalErrorPrototype%': ['EvalError', 'prototype'],
691
+ '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
692
+ '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
693
+ '%FunctionPrototype%': ['Function', 'prototype'],
694
+ '%Generator%': ['GeneratorFunction', 'prototype'],
695
+ '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
696
+ '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
697
+ '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
698
+ '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
699
+ '%JSONParse%': ['JSON', 'parse'],
700
+ '%JSONStringify%': ['JSON', 'stringify'],
701
+ '%MapPrototype%': ['Map', 'prototype'],
702
+ '%NumberPrototype%': ['Number', 'prototype'],
703
+ '%ObjectPrototype%': ['Object', 'prototype'],
704
+ '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
705
+ '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
706
+ '%PromisePrototype%': ['Promise', 'prototype'],
707
+ '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
708
+ '%Promise_all%': ['Promise', 'all'],
709
+ '%Promise_reject%': ['Promise', 'reject'],
710
+ '%Promise_resolve%': ['Promise', 'resolve'],
711
+ '%RangeErrorPrototype%': ['RangeError', 'prototype'],
712
+ '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
713
+ '%RegExpPrototype%': ['RegExp', 'prototype'],
714
+ '%SetPrototype%': ['Set', 'prototype'],
715
+ '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
716
+ '%StringPrototype%': ['String', 'prototype'],
717
+ '%SymbolPrototype%': ['Symbol', 'prototype'],
718
+ '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
719
+ '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
720
+ '%TypeErrorPrototype%': ['TypeError', 'prototype'],
721
+ '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
722
+ '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
723
+ '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
724
+ '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
725
+ '%URIErrorPrototype%': ['URIError', 'prototype'],
726
+ '%WeakMapPrototype%': ['WeakMap', 'prototype'],
727
+ '%WeakSetPrototype%': ['WeakSet', 'prototype']
728
+ };
729
+
730
+ var bind = functionBind;
731
+ var hasOwn$1 = src;
732
+ var $concat$1 = bind.call(Function.call, Array.prototype.concat);
733
+ var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
734
+ var $replace$1 = bind.call(Function.call, String.prototype.replace);
735
+ var $strSlice = bind.call(Function.call, String.prototype.slice);
736
+ var $exec = bind.call(Function.call, RegExp.prototype.exec);
737
+
738
+ /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
739
+ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
740
+ var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
741
+ var stringToPath = function stringToPath(string) {
742
+ var first = $strSlice(string, 0, 1);
743
+ var last = $strSlice(string, -1);
744
+ if (first === '%' && last !== '%') {
745
+ throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
746
+ } else if (last === '%' && first !== '%') {
747
+ throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
748
+ }
749
+ var result = [];
750
+ $replace$1(string, rePropName, function (match, number, quote, subString) {
751
+ result[result.length] = quote ? $replace$1(subString, reEscapeChar, '$1') : number || match;
752
+ });
753
+ return result;
754
+ };
755
+ /* end adaptation */
756
+
757
+ var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
758
+ var intrinsicName = name;
759
+ var alias;
760
+ if (hasOwn$1(LEGACY_ALIASES, intrinsicName)) {
761
+ alias = LEGACY_ALIASES[intrinsicName];
762
+ intrinsicName = '%' + alias[0] + '%';
763
+ }
764
+
765
+ if (hasOwn$1(INTRINSICS, intrinsicName)) {
766
+ var value = INTRINSICS[intrinsicName];
767
+ if (value === needsEval) {
768
+ value = doEval(intrinsicName);
769
+ }
770
+ if (typeof value === 'undefined' && !allowMissing) {
771
+ throw new $TypeError$1('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
772
+ }
773
+
774
+ return {
775
+ alias: alias,
776
+ name: intrinsicName,
777
+ value: value
778
+ };
779
+ }
780
+
781
+ throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
782
+ };
783
+
784
+ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
785
+ if (typeof name !== 'string' || name.length === 0) {
786
+ throw new $TypeError$1('intrinsic name must be a non-empty string');
787
+ }
788
+ if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
789
+ throw new $TypeError$1('"allowMissing" argument must be a boolean');
790
+ }
791
+
792
+ if ($exec(/^%?[^%]*%?$/, name) === null) {
793
+ throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
794
+ }
795
+ var parts = stringToPath(name);
796
+ var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
797
+
798
+ var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
799
+ var intrinsicRealName = intrinsic.name;
800
+ var value = intrinsic.value;
801
+ var skipFurtherCaching = false;
802
+
803
+ var alias = intrinsic.alias;
804
+ if (alias) {
805
+ intrinsicBaseName = alias[0];
806
+ $spliceApply(parts, $concat$1([0, 1], alias));
807
+ }
808
+
809
+ for (var i = 1, isOwn = true; i < parts.length; i += 1) {
810
+ var part = parts[i];
811
+ var first = $strSlice(part, 0, 1);
812
+ var last = $strSlice(part, -1);
813
+ if (
814
+ (
815
+ (first === '"' || first === "'" || first === '`')
816
+ || (last === '"' || last === "'" || last === '`')
817
+ )
818
+ && first !== last
819
+ ) {
820
+ throw new $SyntaxError('property names with quotes must have matching quotes');
821
+ }
822
+ if (part === 'constructor' || !isOwn) {
823
+ skipFurtherCaching = true;
824
+ }
825
+
826
+ intrinsicBaseName += '.' + part;
827
+ intrinsicRealName = '%' + intrinsicBaseName + '%';
828
+
829
+ if (hasOwn$1(INTRINSICS, intrinsicRealName)) {
830
+ value = INTRINSICS[intrinsicRealName];
831
+ } else if (value != null) {
832
+ if (!(part in value)) {
833
+ if (!allowMissing) {
834
+ throw new $TypeError$1('base intrinsic for ' + name + ' exists, but the property is not available.');
835
+ }
836
+ return void undefined$1;
837
+ }
838
+ if ($gOPD && (i + 1) >= parts.length) {
839
+ var desc = $gOPD(value, part);
840
+ isOwn = !!desc;
841
+
842
+ // By convention, when a data property is converted to an accessor
843
+ // property to emulate a data property that does not suffer from
844
+ // the override mistake, that accessor's getter is marked with
845
+ // an `originalValue` property. Here, when we detect this, we
846
+ // uphold the illusion by pretending to see that original data
847
+ // property, i.e., returning the value rather than the getter
848
+ // itself.
849
+ if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
850
+ value = desc.get;
851
+ } else {
852
+ value = value[part];
853
+ }
854
+ } else {
855
+ isOwn = hasOwn$1(value, part);
856
+ value = value[part];
857
+ }
858
+
859
+ if (isOwn && !skipFurtherCaching) {
860
+ INTRINSICS[intrinsicRealName] = value;
861
+ }
862
+ }
863
+ }
864
+ return value;
865
+ };
866
+
867
+ var callBind$1 = {exports: {}};
868
+
869
+ callBind$1.exports;
870
+
871
+ (function (module) {
872
+
873
+ var bind = functionBind;
874
+ var GetIntrinsic = getIntrinsic;
875
+
876
+ var $apply = GetIntrinsic('%Function.prototype.apply%');
877
+ var $call = GetIntrinsic('%Function.prototype.call%');
878
+ var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
879
+
880
+ var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
881
+ var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
882
+ var $max = GetIntrinsic('%Math.max%');
883
+
884
+ if ($defineProperty) {
885
+ try {
886
+ $defineProperty({}, 'a', { value: 1 });
887
+ } catch (e) {
888
+ // IE 8 has a broken defineProperty
889
+ $defineProperty = null;
890
+ }
891
+ }
892
+
893
+ module.exports = function callBind(originalFunction) {
894
+ var func = $reflectApply(bind, $call, arguments);
895
+ if ($gOPD && $defineProperty) {
896
+ var desc = $gOPD(func, 'length');
897
+ if (desc.configurable) {
898
+ // original length, plus the receiver, minus any additional arguments (after the receiver)
899
+ $defineProperty(
900
+ func,
901
+ 'length',
902
+ { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
903
+ );
904
+ }
905
+ }
906
+ return func;
907
+ };
908
+
909
+ var applyBind = function applyBind() {
910
+ return $reflectApply(bind, $apply, arguments);
911
+ };
912
+
913
+ if ($defineProperty) {
914
+ $defineProperty(module.exports, 'apply', { value: applyBind });
915
+ } else {
916
+ module.exports.apply = applyBind;
917
+ }
918
+ } (callBind$1));
919
+
920
+ var callBindExports = callBind$1.exports;
921
+
922
+ var GetIntrinsic$1 = getIntrinsic;
923
+
924
+ var callBind = callBindExports;
925
+
926
+ var $indexOf = callBind(GetIntrinsic$1('String.prototype.indexOf'));
927
+
928
+ var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
929
+ var intrinsic = GetIntrinsic$1(name, !!allowMissing);
930
+ if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
931
+ return callBind(intrinsic);
932
+ }
933
+ return intrinsic;
934
+ };
935
+
936
+ var util_inspect = require$$0__default["default"].inspect;
937
+
938
+ var hasMap = typeof Map === 'function' && Map.prototype;
939
+ var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
940
+ var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
941
+ var mapForEach = hasMap && Map.prototype.forEach;
942
+ var hasSet = typeof Set === 'function' && Set.prototype;
943
+ var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
944
+ var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
945
+ var setForEach = hasSet && Set.prototype.forEach;
946
+ var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
947
+ var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
948
+ var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
949
+ var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
950
+ var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
951
+ var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
952
+ var booleanValueOf = Boolean.prototype.valueOf;
953
+ var objectToString = Object.prototype.toString;
954
+ var functionToString = Function.prototype.toString;
955
+ var $match = String.prototype.match;
956
+ var $slice = String.prototype.slice;
957
+ var $replace = String.prototype.replace;
958
+ var $toUpperCase = String.prototype.toUpperCase;
959
+ var $toLowerCase = String.prototype.toLowerCase;
960
+ var $test = RegExp.prototype.test;
961
+ var $concat = Array.prototype.concat;
962
+ var $join = Array.prototype.join;
963
+ var $arrSlice = Array.prototype.slice;
964
+ var $floor = Math.floor;
965
+ var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
966
+ var gOPS = Object.getOwnPropertySymbols;
967
+ var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
968
+ var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
969
+ // ie, `has-tostringtag/shams
970
+ var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
971
+ ? Symbol.toStringTag
972
+ : null;
973
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
974
+
975
+ var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
976
+ [].__proto__ === Array.prototype // eslint-disable-line no-proto
977
+ ? function (O) {
978
+ return O.__proto__; // eslint-disable-line no-proto
979
+ }
980
+ : null
981
+ );
982
+
983
+ function addNumericSeparator(num, str) {
984
+ if (
985
+ num === Infinity
986
+ || num === -Infinity
987
+ || num !== num
988
+ || (num && num > -1000 && num < 1000)
989
+ || $test.call(/e/, str)
990
+ ) {
991
+ return str;
992
+ }
993
+ var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
994
+ if (typeof num === 'number') {
995
+ var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
996
+ if (int !== num) {
997
+ var intStr = String(int);
998
+ var dec = $slice.call(str, intStr.length + 1);
999
+ return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
1000
+ }
1001
+ }
1002
+ return $replace.call(str, sepRegex, '$&_');
1003
+ }
1004
+
1005
+ var utilInspect = util_inspect;
1006
+ var inspectCustom = utilInspect.custom;
1007
+ var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
1008
+
1009
+ var objectInspect = function inspect_(obj, options, depth, seen) {
1010
+ var opts = options || {};
1011
+
1012
+ if (has$3(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
1013
+ throw new TypeError('option "quoteStyle" must be "single" or "double"');
1014
+ }
1015
+ if (
1016
+ has$3(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
1017
+ ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
1018
+ : opts.maxStringLength !== null
1019
+ )
1020
+ ) {
1021
+ throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
1022
+ }
1023
+ var customInspect = has$3(opts, 'customInspect') ? opts.customInspect : true;
1024
+ if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
1025
+ throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
1026
+ }
1027
+
1028
+ if (
1029
+ has$3(opts, 'indent')
1030
+ && opts.indent !== null
1031
+ && opts.indent !== '\t'
1032
+ && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
1033
+ ) {
1034
+ throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
1035
+ }
1036
+ if (has$3(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
1037
+ throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
1038
+ }
1039
+ var numericSeparator = opts.numericSeparator;
1040
+
1041
+ if (typeof obj === 'undefined') {
1042
+ return 'undefined';
1043
+ }
1044
+ if (obj === null) {
1045
+ return 'null';
1046
+ }
1047
+ if (typeof obj === 'boolean') {
1048
+ return obj ? 'true' : 'false';
1049
+ }
1050
+
1051
+ if (typeof obj === 'string') {
1052
+ return inspectString(obj, opts);
1053
+ }
1054
+ if (typeof obj === 'number') {
1055
+ if (obj === 0) {
1056
+ return Infinity / obj > 0 ? '0' : '-0';
1057
+ }
1058
+ var str = String(obj);
1059
+ return numericSeparator ? addNumericSeparator(obj, str) : str;
1060
+ }
1061
+ if (typeof obj === 'bigint') {
1062
+ var bigIntStr = String(obj) + 'n';
1063
+ return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
1064
+ }
1065
+
1066
+ var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
1067
+ if (typeof depth === 'undefined') { depth = 0; }
1068
+ if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
1069
+ return isArray$3(obj) ? '[Array]' : '[Object]';
1070
+ }
1071
+
1072
+ var indent = getIndent(opts, depth);
1073
+
1074
+ if (typeof seen === 'undefined') {
1075
+ seen = [];
1076
+ } else if (indexOf(seen, obj) >= 0) {
1077
+ return '[Circular]';
1078
+ }
1079
+
1080
+ function inspect(value, from, noIndent) {
1081
+ if (from) {
1082
+ seen = $arrSlice.call(seen);
1083
+ seen.push(from);
1084
+ }
1085
+ if (noIndent) {
1086
+ var newOpts = {
1087
+ depth: opts.depth
1088
+ };
1089
+ if (has$3(opts, 'quoteStyle')) {
1090
+ newOpts.quoteStyle = opts.quoteStyle;
1091
+ }
1092
+ return inspect_(value, newOpts, depth + 1, seen);
1093
+ }
1094
+ return inspect_(value, opts, depth + 1, seen);
1095
+ }
1096
+
1097
+ if (typeof obj === 'function' && !isRegExp$1(obj)) { // in older engines, regexes are callable
1098
+ var name = nameOf(obj);
1099
+ var keys = arrObjKeys(obj, inspect);
1100
+ return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
1101
+ }
1102
+ if (isSymbol(obj)) {
1103
+ var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
1104
+ return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
1105
+ }
1106
+ if (isElement(obj)) {
1107
+ var s = '<' + $toLowerCase.call(String(obj.nodeName));
1108
+ var attrs = obj.attributes || [];
1109
+ for (var i = 0; i < attrs.length; i++) {
1110
+ s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
1111
+ }
1112
+ s += '>';
1113
+ if (obj.childNodes && obj.childNodes.length) { s += '...'; }
1114
+ s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
1115
+ return s;
1116
+ }
1117
+ if (isArray$3(obj)) {
1118
+ if (obj.length === 0) { return '[]'; }
1119
+ var xs = arrObjKeys(obj, inspect);
1120
+ if (indent && !singleLineValues(xs)) {
1121
+ return '[' + indentedJoin(xs, indent) + ']';
1122
+ }
1123
+ return '[ ' + $join.call(xs, ', ') + ' ]';
1124
+ }
1125
+ if (isError(obj)) {
1126
+ var parts = arrObjKeys(obj, inspect);
1127
+ if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
1128
+ return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
1129
+ }
1130
+ if (parts.length === 0) { return '[' + String(obj) + ']'; }
1131
+ return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
1132
+ }
1133
+ if (typeof obj === 'object' && customInspect) {
1134
+ if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
1135
+ return utilInspect(obj, { depth: maxDepth - depth });
1136
+ } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
1137
+ return obj.inspect();
1138
+ }
1139
+ }
1140
+ if (isMap(obj)) {
1141
+ var mapParts = [];
1142
+ if (mapForEach) {
1143
+ mapForEach.call(obj, function (value, key) {
1144
+ mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
1145
+ });
1146
+ }
1147
+ return collectionOf('Map', mapSize.call(obj), mapParts, indent);
1148
+ }
1149
+ if (isSet(obj)) {
1150
+ var setParts = [];
1151
+ if (setForEach) {
1152
+ setForEach.call(obj, function (value) {
1153
+ setParts.push(inspect(value, obj));
1154
+ });
1155
+ }
1156
+ return collectionOf('Set', setSize.call(obj), setParts, indent);
1157
+ }
1158
+ if (isWeakMap(obj)) {
1159
+ return weakCollectionOf('WeakMap');
1160
+ }
1161
+ if (isWeakSet(obj)) {
1162
+ return weakCollectionOf('WeakSet');
1163
+ }
1164
+ if (isWeakRef(obj)) {
1165
+ return weakCollectionOf('WeakRef');
1166
+ }
1167
+ if (isNumber(obj)) {
1168
+ return markBoxed(inspect(Number(obj)));
1169
+ }
1170
+ if (isBigInt(obj)) {
1171
+ return markBoxed(inspect(bigIntValueOf.call(obj)));
1172
+ }
1173
+ if (isBoolean(obj)) {
1174
+ return markBoxed(booleanValueOf.call(obj));
1175
+ }
1176
+ if (isString(obj)) {
1177
+ return markBoxed(inspect(String(obj)));
1178
+ }
1179
+ if (!isDate(obj) && !isRegExp$1(obj)) {
1180
+ var ys = arrObjKeys(obj, inspect);
1181
+ var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
1182
+ var protoTag = obj instanceof Object ? '' : 'null prototype';
1183
+ var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
1184
+ var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
1185
+ var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
1186
+ if (ys.length === 0) { return tag + '{}'; }
1187
+ if (indent) {
1188
+ return tag + '{' + indentedJoin(ys, indent) + '}';
1189
+ }
1190
+ return tag + '{ ' + $join.call(ys, ', ') + ' }';
1191
+ }
1192
+ return String(obj);
1193
+ };
1194
+
1195
+ function wrapQuotes(s, defaultStyle, opts) {
1196
+ var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
1197
+ return quoteChar + s + quoteChar;
1198
+ }
1199
+
1200
+ function quote(s) {
1201
+ return $replace.call(String(s), /"/g, '&quot;');
1202
+ }
1203
+
1204
+ function isArray$3(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1205
+ function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1206
+ function isRegExp$1(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1207
+ function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1208
+ function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1209
+ function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1210
+ function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1211
+
1212
+ // Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
1213
+ function isSymbol(obj) {
1214
+ if (hasShammedSymbols) {
1215
+ return obj && typeof obj === 'object' && obj instanceof Symbol;
1216
+ }
1217
+ if (typeof obj === 'symbol') {
1218
+ return true;
1219
+ }
1220
+ if (!obj || typeof obj !== 'object' || !symToString) {
1221
+ return false;
1222
+ }
1223
+ try {
1224
+ symToString.call(obj);
1225
+ return true;
1226
+ } catch (e) {}
1227
+ return false;
1228
+ }
1229
+
1230
+ function isBigInt(obj) {
1231
+ if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
1232
+ return false;
1233
+ }
1234
+ try {
1235
+ bigIntValueOf.call(obj);
1236
+ return true;
1237
+ } catch (e) {}
1238
+ return false;
1239
+ }
1240
+
1241
+ var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
1242
+ function has$3(obj, key) {
1243
+ return hasOwn.call(obj, key);
1244
+ }
1245
+
1246
+ function toStr(obj) {
1247
+ return objectToString.call(obj);
1248
+ }
1249
+
1250
+ function nameOf(f) {
1251
+ if (f.name) { return f.name; }
1252
+ var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
1253
+ if (m) { return m[1]; }
1254
+ return null;
1255
+ }
1256
+
1257
+ function indexOf(xs, x) {
1258
+ if (xs.indexOf) { return xs.indexOf(x); }
1259
+ for (var i = 0, l = xs.length; i < l; i++) {
1260
+ if (xs[i] === x) { return i; }
1261
+ }
1262
+ return -1;
1263
+ }
1264
+
1265
+ function isMap(x) {
1266
+ if (!mapSize || !x || typeof x !== 'object') {
1267
+ return false;
1268
+ }
1269
+ try {
1270
+ mapSize.call(x);
1271
+ try {
1272
+ setSize.call(x);
1273
+ } catch (s) {
1274
+ return true;
1275
+ }
1276
+ return x instanceof Map; // core-js workaround, pre-v2.5.0
1277
+ } catch (e) {}
1278
+ return false;
1279
+ }
1280
+
1281
+ function isWeakMap(x) {
1282
+ if (!weakMapHas || !x || typeof x !== 'object') {
1283
+ return false;
1284
+ }
1285
+ try {
1286
+ weakMapHas.call(x, weakMapHas);
1287
+ try {
1288
+ weakSetHas.call(x, weakSetHas);
1289
+ } catch (s) {
1290
+ return true;
1291
+ }
1292
+ return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
1293
+ } catch (e) {}
1294
+ return false;
1295
+ }
1296
+
1297
+ function isWeakRef(x) {
1298
+ if (!weakRefDeref || !x || typeof x !== 'object') {
1299
+ return false;
1300
+ }
1301
+ try {
1302
+ weakRefDeref.call(x);
1303
+ return true;
1304
+ } catch (e) {}
1305
+ return false;
1306
+ }
1307
+
1308
+ function isSet(x) {
1309
+ if (!setSize || !x || typeof x !== 'object') {
1310
+ return false;
1311
+ }
1312
+ try {
1313
+ setSize.call(x);
1314
+ try {
1315
+ mapSize.call(x);
1316
+ } catch (m) {
1317
+ return true;
1318
+ }
1319
+ return x instanceof Set; // core-js workaround, pre-v2.5.0
1320
+ } catch (e) {}
1321
+ return false;
1322
+ }
1323
+
1324
+ function isWeakSet(x) {
1325
+ if (!weakSetHas || !x || typeof x !== 'object') {
1326
+ return false;
1327
+ }
1328
+ try {
1329
+ weakSetHas.call(x, weakSetHas);
1330
+ try {
1331
+ weakMapHas.call(x, weakMapHas);
1332
+ } catch (s) {
1333
+ return true;
1334
+ }
1335
+ return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
1336
+ } catch (e) {}
1337
+ return false;
1338
+ }
1339
+
1340
+ function isElement(x) {
1341
+ if (!x || typeof x !== 'object') { return false; }
1342
+ if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
1343
+ return true;
1344
+ }
1345
+ return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
1346
+ }
1347
+
1348
+ function inspectString(str, opts) {
1349
+ if (str.length > opts.maxStringLength) {
1350
+ var remaining = str.length - opts.maxStringLength;
1351
+ var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
1352
+ return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
1353
+ }
1354
+ // eslint-disable-next-line no-control-regex
1355
+ var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
1356
+ return wrapQuotes(s, 'single', opts);
1357
+ }
1358
+
1359
+ function lowbyte(c) {
1360
+ var n = c.charCodeAt(0);
1361
+ var x = {
1362
+ 8: 'b',
1363
+ 9: 't',
1364
+ 10: 'n',
1365
+ 12: 'f',
1366
+ 13: 'r'
1367
+ }[n];
1368
+ if (x) { return '\\' + x; }
1369
+ return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
1370
+ }
1371
+
1372
+ function markBoxed(str) {
1373
+ return 'Object(' + str + ')';
1374
+ }
1375
+
1376
+ function weakCollectionOf(type) {
1377
+ return type + ' { ? }';
1378
+ }
1379
+
1380
+ function collectionOf(type, size, entries, indent) {
1381
+ var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
1382
+ return type + ' (' + size + ') {' + joinedEntries + '}';
1383
+ }
1384
+
1385
+ function singleLineValues(xs) {
1386
+ for (var i = 0; i < xs.length; i++) {
1387
+ if (indexOf(xs[i], '\n') >= 0) {
1388
+ return false;
1389
+ }
1390
+ }
1391
+ return true;
1392
+ }
1393
+
1394
+ function getIndent(opts, depth) {
1395
+ var baseIndent;
1396
+ if (opts.indent === '\t') {
1397
+ baseIndent = '\t';
1398
+ } else if (typeof opts.indent === 'number' && opts.indent > 0) {
1399
+ baseIndent = $join.call(Array(opts.indent + 1), ' ');
1400
+ } else {
1401
+ return null;
1402
+ }
1403
+ return {
1404
+ base: baseIndent,
1405
+ prev: $join.call(Array(depth + 1), baseIndent)
1406
+ };
1407
+ }
1408
+
1409
+ function indentedJoin(xs, indent) {
1410
+ if (xs.length === 0) { return ''; }
1411
+ var lineJoiner = '\n' + indent.prev + indent.base;
1412
+ return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
1413
+ }
1414
+
1415
+ function arrObjKeys(obj, inspect) {
1416
+ var isArr = isArray$3(obj);
1417
+ var xs = [];
1418
+ if (isArr) {
1419
+ xs.length = obj.length;
1420
+ for (var i = 0; i < obj.length; i++) {
1421
+ xs[i] = has$3(obj, i) ? inspect(obj[i], obj) : '';
1422
+ }
1423
+ }
1424
+ var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
1425
+ var symMap;
1426
+ if (hasShammedSymbols) {
1427
+ symMap = {};
1428
+ for (var k = 0; k < syms.length; k++) {
1429
+ symMap['$' + syms[k]] = syms[k];
1430
+ }
1431
+ }
1432
+
1433
+ for (var key in obj) { // eslint-disable-line no-restricted-syntax
1434
+ if (!has$3(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
1435
+ if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
1436
+ if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
1437
+ // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
1438
+ continue; // eslint-disable-line no-restricted-syntax, no-continue
1439
+ } else if ($test.call(/[^\w$]/, key)) {
1440
+ xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
1441
+ } else {
1442
+ xs.push(key + ': ' + inspect(obj[key], obj));
1443
+ }
1444
+ }
1445
+ if (typeof gOPS === 'function') {
1446
+ for (var j = 0; j < syms.length; j++) {
1447
+ if (isEnumerable.call(obj, syms[j])) {
1448
+ xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
1449
+ }
1450
+ }
1451
+ }
1452
+ return xs;
1453
+ }
1454
+
1455
+ var GetIntrinsic = getIntrinsic;
1456
+ var callBound = callBound$1;
1457
+ var inspect = objectInspect;
1458
+
1459
+ var $TypeError = GetIntrinsic('%TypeError%');
1460
+ var $WeakMap = GetIntrinsic('%WeakMap%', true);
1461
+ var $Map = GetIntrinsic('%Map%', true);
1462
+
1463
+ var $weakMapGet = callBound('WeakMap.prototype.get', true);
1464
+ var $weakMapSet = callBound('WeakMap.prototype.set', true);
1465
+ var $weakMapHas = callBound('WeakMap.prototype.has', true);
1466
+ var $mapGet = callBound('Map.prototype.get', true);
1467
+ var $mapSet = callBound('Map.prototype.set', true);
1468
+ var $mapHas = callBound('Map.prototype.has', true);
1469
+
1470
+ /*
1471
+ * This function traverses the list returning the node corresponding to the
1472
+ * given key.
1473
+ *
1474
+ * That node is also moved to the head of the list, so that if it's accessed
1475
+ * again we don't need to traverse the whole list. By doing so, all the recently
1476
+ * used nodes can be accessed relatively quickly.
1477
+ */
1478
+ var listGetNode = function (list, key) { // eslint-disable-line consistent-return
1479
+ for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
1480
+ if (curr.key === key) {
1481
+ prev.next = curr.next;
1482
+ curr.next = list.next;
1483
+ list.next = curr; // eslint-disable-line no-param-reassign
1484
+ return curr;
1485
+ }
1486
+ }
1487
+ };
1488
+
1489
+ var listGet = function (objects, key) {
1490
+ var node = listGetNode(objects, key);
1491
+ return node && node.value;
1492
+ };
1493
+ var listSet = function (objects, key, value) {
1494
+ var node = listGetNode(objects, key);
1495
+ if (node) {
1496
+ node.value = value;
1497
+ } else {
1498
+ // Prepend the new node to the beginning of the list
1499
+ objects.next = { // eslint-disable-line no-param-reassign
1500
+ key: key,
1501
+ next: objects.next,
1502
+ value: value
1503
+ };
1504
+ }
1505
+ };
1506
+ var listHas = function (objects, key) {
1507
+ return !!listGetNode(objects, key);
1508
+ };
1509
+
1510
+ var sideChannel = function getSideChannel() {
1511
+ var $wm;
1512
+ var $m;
1513
+ var $o;
1514
+ var channel = {
1515
+ assert: function (key) {
1516
+ if (!channel.has(key)) {
1517
+ throw new $TypeError('Side channel does not contain ' + inspect(key));
1518
+ }
1519
+ },
1520
+ get: function (key) { // eslint-disable-line consistent-return
1521
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1522
+ if ($wm) {
1523
+ return $weakMapGet($wm, key);
1524
+ }
1525
+ } else if ($Map) {
1526
+ if ($m) {
1527
+ return $mapGet($m, key);
1528
+ }
1529
+ } else {
1530
+ if ($o) { // eslint-disable-line no-lonely-if
1531
+ return listGet($o, key);
1532
+ }
1533
+ }
1534
+ },
1535
+ has: function (key) {
1536
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1537
+ if ($wm) {
1538
+ return $weakMapHas($wm, key);
1539
+ }
1540
+ } else if ($Map) {
1541
+ if ($m) {
1542
+ return $mapHas($m, key);
1543
+ }
1544
+ } else {
1545
+ if ($o) { // eslint-disable-line no-lonely-if
1546
+ return listHas($o, key);
1547
+ }
1548
+ }
1549
+ return false;
1550
+ },
1551
+ set: function (key, value) {
1552
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1553
+ if (!$wm) {
1554
+ $wm = new $WeakMap();
1555
+ }
1556
+ $weakMapSet($wm, key, value);
1557
+ } else if ($Map) {
1558
+ if (!$m) {
1559
+ $m = new $Map();
1560
+ }
1561
+ $mapSet($m, key, value);
1562
+ } else {
1563
+ if (!$o) {
1564
+ /*
1565
+ * Initialize the linked list as an empty node, so that we don't have
1566
+ * to special-case handling of the first node: we can always refer to
1567
+ * it as (previous node).next, instead of something like (list).head
1568
+ */
1569
+ $o = { key: {}, next: null };
1570
+ }
1571
+ listSet($o, key, value);
1572
+ }
1573
+ }
1574
+ };
1575
+ return channel;
1576
+ };
1577
+
1578
+ var replace = String.prototype.replace;
1579
+ var percentTwenties = /%20/g;
1580
+
1581
+ var Format = {
1582
+ RFC1738: 'RFC1738',
1583
+ RFC3986: 'RFC3986'
1584
+ };
1585
+
1586
+ var formats$3 = {
1587
+ 'default': Format.RFC3986,
1588
+ formatters: {
1589
+ RFC1738: function (value) {
1590
+ return replace.call(value, percentTwenties, '+');
1591
+ },
1592
+ RFC3986: function (value) {
1593
+ return String(value);
1594
+ }
1595
+ },
1596
+ RFC1738: Format.RFC1738,
1597
+ RFC3986: Format.RFC3986
1598
+ };
1599
+
1600
+ var formats$2 = formats$3;
1601
+
1602
+ var has$2 = Object.prototype.hasOwnProperty;
1603
+ var isArray$2 = Array.isArray;
1604
+
1605
+ var hexTable = (function () {
1606
+ var array = [];
1607
+ for (var i = 0; i < 256; ++i) {
1608
+ array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
1609
+ }
1610
+
1611
+ return array;
1612
+ }());
1613
+
1614
+ var compactQueue = function compactQueue(queue) {
1615
+ while (queue.length > 1) {
1616
+ var item = queue.pop();
1617
+ var obj = item.obj[item.prop];
1618
+
1619
+ if (isArray$2(obj)) {
1620
+ var compacted = [];
1621
+
1622
+ for (var j = 0; j < obj.length; ++j) {
1623
+ if (typeof obj[j] !== 'undefined') {
1624
+ compacted.push(obj[j]);
1625
+ }
1626
+ }
1627
+
1628
+ item.obj[item.prop] = compacted;
1629
+ }
1630
+ }
1631
+ };
1632
+
1633
+ var arrayToObject = function arrayToObject(source, options) {
1634
+ var obj = options && options.plainObjects ? Object.create(null) : {};
1635
+ for (var i = 0; i < source.length; ++i) {
1636
+ if (typeof source[i] !== 'undefined') {
1637
+ obj[i] = source[i];
1638
+ }
1639
+ }
1640
+
1641
+ return obj;
1642
+ };
1643
+
1644
+ var merge = function merge(target, source, options) {
1645
+ /* eslint no-param-reassign: 0 */
1646
+ if (!source) {
1647
+ return target;
1648
+ }
1649
+
1650
+ if (typeof source !== 'object') {
1651
+ if (isArray$2(target)) {
1652
+ target.push(source);
1653
+ } else if (target && typeof target === 'object') {
1654
+ if ((options && (options.plainObjects || options.allowPrototypes)) || !has$2.call(Object.prototype, source)) {
1655
+ target[source] = true;
1656
+ }
1657
+ } else {
1658
+ return [target, source];
1659
+ }
1660
+
1661
+ return target;
1662
+ }
1663
+
1664
+ if (!target || typeof target !== 'object') {
1665
+ return [target].concat(source);
1666
+ }
1667
+
1668
+ var mergeTarget = target;
1669
+ if (isArray$2(target) && !isArray$2(source)) {
1670
+ mergeTarget = arrayToObject(target, options);
1671
+ }
1672
+
1673
+ if (isArray$2(target) && isArray$2(source)) {
1674
+ source.forEach(function (item, i) {
1675
+ if (has$2.call(target, i)) {
1676
+ var targetItem = target[i];
1677
+ if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
1678
+ target[i] = merge(targetItem, item, options);
1679
+ } else {
1680
+ target.push(item);
1681
+ }
1682
+ } else {
1683
+ target[i] = item;
1684
+ }
1685
+ });
1686
+ return target;
1687
+ }
1688
+
1689
+ return Object.keys(source).reduce(function (acc, key) {
1690
+ var value = source[key];
1691
+
1692
+ if (has$2.call(acc, key)) {
1693
+ acc[key] = merge(acc[key], value, options);
1694
+ } else {
1695
+ acc[key] = value;
1696
+ }
1697
+ return acc;
1698
+ }, mergeTarget);
1699
+ };
1700
+
1701
+ var assign = function assignSingleSource(target, source) {
1702
+ return Object.keys(source).reduce(function (acc, key) {
1703
+ acc[key] = source[key];
1704
+ return acc;
1705
+ }, target);
1706
+ };
1707
+
1708
+ var decode = function (str, decoder, charset) {
1709
+ var strWithoutPlus = str.replace(/\+/g, ' ');
1710
+ if (charset === 'iso-8859-1') {
1711
+ // unescape never throws, no try...catch needed:
1712
+ return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
1713
+ }
1714
+ // utf-8
1715
+ try {
1716
+ return decodeURIComponent(strWithoutPlus);
1717
+ } catch (e) {
1718
+ return strWithoutPlus;
1719
+ }
1720
+ };
1721
+
1722
+ var encode = function encode(str, defaultEncoder, charset, kind, format) {
1723
+ // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
1724
+ // It has been adapted here for stricter adherence to RFC 3986
1725
+ if (str.length === 0) {
1726
+ return str;
1727
+ }
1728
+
1729
+ var string = str;
1730
+ if (typeof str === 'symbol') {
1731
+ string = Symbol.prototype.toString.call(str);
1732
+ } else if (typeof str !== 'string') {
1733
+ string = String(str);
1734
+ }
1735
+
1736
+ if (charset === 'iso-8859-1') {
1737
+ return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
1738
+ return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
1739
+ });
1740
+ }
1741
+
1742
+ var out = '';
1743
+ for (var i = 0; i < string.length; ++i) {
1744
+ var c = string.charCodeAt(i);
1745
+
1746
+ if (
1747
+ c === 0x2D // -
1748
+ || c === 0x2E // .
1749
+ || c === 0x5F // _
1750
+ || c === 0x7E // ~
1751
+ || (c >= 0x30 && c <= 0x39) // 0-9
1752
+ || (c >= 0x41 && c <= 0x5A) // a-z
1753
+ || (c >= 0x61 && c <= 0x7A) // A-Z
1754
+ || (format === formats$2.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
1755
+ ) {
1756
+ out += string.charAt(i);
1757
+ continue;
1758
+ }
1759
+
1760
+ if (c < 0x80) {
1761
+ out = out + hexTable[c];
1762
+ continue;
1763
+ }
1764
+
1765
+ if (c < 0x800) {
1766
+ out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
1767
+ continue;
1768
+ }
1769
+
1770
+ if (c < 0xD800 || c >= 0xE000) {
1771
+ out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
1772
+ continue;
1773
+ }
1774
+
1775
+ i += 1;
1776
+ c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
1777
+ /* eslint operator-linebreak: [2, "before"] */
1778
+ out += hexTable[0xF0 | (c >> 18)]
1779
+ + hexTable[0x80 | ((c >> 12) & 0x3F)]
1780
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
1781
+ + hexTable[0x80 | (c & 0x3F)];
1782
+ }
1783
+
1784
+ return out;
1785
+ };
1786
+
1787
+ var compact = function compact(value) {
1788
+ var queue = [{ obj: { o: value }, prop: 'o' }];
1789
+ var refs = [];
1790
+
1791
+ for (var i = 0; i < queue.length; ++i) {
1792
+ var item = queue[i];
1793
+ var obj = item.obj[item.prop];
1794
+
1795
+ var keys = Object.keys(obj);
1796
+ for (var j = 0; j < keys.length; ++j) {
1797
+ var key = keys[j];
1798
+ var val = obj[key];
1799
+ if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
1800
+ queue.push({ obj: obj, prop: key });
1801
+ refs.push(val);
1802
+ }
1803
+ }
1804
+ }
1805
+
1806
+ compactQueue(queue);
1807
+
1808
+ return value;
1809
+ };
1810
+
1811
+ var isRegExp = function isRegExp(obj) {
1812
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
1813
+ };
1814
+
1815
+ var isBuffer = function isBuffer(obj) {
1816
+ if (!obj || typeof obj !== 'object') {
1817
+ return false;
1818
+ }
1819
+
1820
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
1821
+ };
1822
+
1823
+ var combine = function combine(a, b) {
1824
+ return [].concat(a, b);
1825
+ };
1826
+
1827
+ var maybeMap = function maybeMap(val, fn) {
1828
+ if (isArray$2(val)) {
1829
+ var mapped = [];
1830
+ for (var i = 0; i < val.length; i += 1) {
1831
+ mapped.push(fn(val[i]));
1832
+ }
1833
+ return mapped;
1834
+ }
1835
+ return fn(val);
1836
+ };
1837
+
1838
+ var utils$2 = {
1839
+ arrayToObject: arrayToObject,
1840
+ assign: assign,
1841
+ combine: combine,
1842
+ compact: compact,
1843
+ decode: decode,
1844
+ encode: encode,
1845
+ isBuffer: isBuffer,
1846
+ isRegExp: isRegExp,
1847
+ maybeMap: maybeMap,
1848
+ merge: merge
1849
+ };
1850
+
1851
+ var getSideChannel = sideChannel;
1852
+ var utils$1 = utils$2;
1853
+ var formats$1 = formats$3;
1854
+ var has$1 = Object.prototype.hasOwnProperty;
1855
+
1856
+ var arrayPrefixGenerators = {
1857
+ brackets: function brackets(prefix) {
1858
+ return prefix + '[]';
1859
+ },
1860
+ comma: 'comma',
1861
+ indices: function indices(prefix, key) {
1862
+ return prefix + '[' + key + ']';
1863
+ },
1864
+ repeat: function repeat(prefix) {
1865
+ return prefix;
1866
+ }
1867
+ };
1868
+
1869
+ var isArray$1 = Array.isArray;
1870
+ var split = String.prototype.split;
1871
+ var push = Array.prototype.push;
1872
+ var pushToArray = function (arr, valueOrArray) {
1873
+ push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
1874
+ };
1875
+
1876
+ var toISO = Date.prototype.toISOString;
1877
+
1878
+ var defaultFormat = formats$1['default'];
1879
+ var defaults$1 = {
1880
+ addQueryPrefix: false,
1881
+ allowDots: false,
1882
+ charset: 'utf-8',
1883
+ charsetSentinel: false,
1884
+ delimiter: '&',
1885
+ encode: true,
1886
+ encoder: utils$1.encode,
1887
+ encodeValuesOnly: false,
1888
+ format: defaultFormat,
1889
+ formatter: formats$1.formatters[defaultFormat],
1890
+ // deprecated
1891
+ indices: false,
1892
+ serializeDate: function serializeDate(date) {
1893
+ return toISO.call(date);
1894
+ },
1895
+ skipNulls: false,
1896
+ strictNullHandling: false
1897
+ };
1898
+
1899
+ var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
1900
+ return typeof v === 'string'
1901
+ || typeof v === 'number'
1902
+ || typeof v === 'boolean'
1903
+ || typeof v === 'symbol'
1904
+ || typeof v === 'bigint';
1905
+ };
1906
+
1907
+ var sentinel = {};
1908
+
1909
+ var stringify$1 = function stringify(
1910
+ object,
1911
+ prefix,
1912
+ generateArrayPrefix,
1913
+ commaRoundTrip,
1914
+ strictNullHandling,
1915
+ skipNulls,
1916
+ encoder,
1917
+ filter,
1918
+ sort,
1919
+ allowDots,
1920
+ serializeDate,
1921
+ format,
1922
+ formatter,
1923
+ encodeValuesOnly,
1924
+ charset,
1925
+ sideChannel
1926
+ ) {
1927
+ var obj = object;
1928
+
1929
+ var tmpSc = sideChannel;
1930
+ var step = 0;
1931
+ var findFlag = false;
1932
+ while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
1933
+ // Where object last appeared in the ref tree
1934
+ var pos = tmpSc.get(object);
1935
+ step += 1;
1936
+ if (typeof pos !== 'undefined') {
1937
+ if (pos === step) {
1938
+ throw new RangeError('Cyclic object value');
1939
+ } else {
1940
+ findFlag = true; // Break while
1941
+ }
1942
+ }
1943
+ if (typeof tmpSc.get(sentinel) === 'undefined') {
1944
+ step = 0;
1945
+ }
1946
+ }
1947
+
1948
+ if (typeof filter === 'function') {
1949
+ obj = filter(prefix, obj);
1950
+ } else if (obj instanceof Date) {
1951
+ obj = serializeDate(obj);
1952
+ } else if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
1953
+ obj = utils$1.maybeMap(obj, function (value) {
1954
+ if (value instanceof Date) {
1955
+ return serializeDate(value);
1956
+ }
1957
+ return value;
1958
+ });
1959
+ }
1960
+
1961
+ if (obj === null) {
1962
+ if (strictNullHandling) {
1963
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, 'key', format) : prefix;
1964
+ }
1965
+
1966
+ obj = '';
1967
+ }
1968
+
1969
+ if (isNonNullishPrimitive(obj) || utils$1.isBuffer(obj)) {
1970
+ if (encoder) {
1971
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, 'key', format);
1972
+ if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
1973
+ var valuesArray = split.call(String(obj), ',');
1974
+ var valuesJoined = '';
1975
+ for (var i = 0; i < valuesArray.length; ++i) {
1976
+ valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults$1.encoder, charset, 'value', format));
1977
+ }
1978
+ return [formatter(keyValue) + (commaRoundTrip && isArray$1(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
1979
+ }
1980
+ return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder, charset, 'value', format))];
1981
+ }
1982
+ return [formatter(prefix) + '=' + formatter(String(obj))];
1983
+ }
1984
+
1985
+ var values = [];
1986
+
1987
+ if (typeof obj === 'undefined') {
1988
+ return values;
1989
+ }
1990
+
1991
+ var objKeys;
1992
+ if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
1993
+ // we need to join elements in
1994
+ objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
1995
+ } else if (isArray$1(filter)) {
1996
+ objKeys = filter;
1997
+ } else {
1998
+ var keys = Object.keys(obj);
1999
+ objKeys = sort ? keys.sort(sort) : keys;
2000
+ }
2001
+
2002
+ var adjustedPrefix = commaRoundTrip && isArray$1(obj) && obj.length === 1 ? prefix + '[]' : prefix;
2003
+
2004
+ for (var j = 0; j < objKeys.length; ++j) {
2005
+ var key = objKeys[j];
2006
+ var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
2007
+
2008
+ if (skipNulls && value === null) {
2009
+ continue;
2010
+ }
2011
+
2012
+ var keyPrefix = isArray$1(obj)
2013
+ ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
2014
+ : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
2015
+
2016
+ sideChannel.set(object, step);
2017
+ var valueSideChannel = getSideChannel();
2018
+ valueSideChannel.set(sentinel, sideChannel);
2019
+ pushToArray(values, stringify(
2020
+ value,
2021
+ keyPrefix,
2022
+ generateArrayPrefix,
2023
+ commaRoundTrip,
2024
+ strictNullHandling,
2025
+ skipNulls,
2026
+ encoder,
2027
+ filter,
2028
+ sort,
2029
+ allowDots,
2030
+ serializeDate,
2031
+ format,
2032
+ formatter,
2033
+ encodeValuesOnly,
2034
+ charset,
2035
+ valueSideChannel
2036
+ ));
2037
+ }
2038
+
2039
+ return values;
2040
+ };
2041
+
2042
+ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
2043
+ if (!opts) {
2044
+ return defaults$1;
2045
+ }
2046
+
2047
+ if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
2048
+ throw new TypeError('Encoder has to be a function.');
2049
+ }
2050
+
2051
+ var charset = opts.charset || defaults$1.charset;
2052
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
2053
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
2054
+ }
2055
+
2056
+ var format = formats$1['default'];
2057
+ if (typeof opts.format !== 'undefined') {
2058
+ if (!has$1.call(formats$1.formatters, opts.format)) {
2059
+ throw new TypeError('Unknown format option provided.');
2060
+ }
2061
+ format = opts.format;
2062
+ }
2063
+ var formatter = formats$1.formatters[format];
2064
+
2065
+ var filter = defaults$1.filter;
2066
+ if (typeof opts.filter === 'function' || isArray$1(opts.filter)) {
2067
+ filter = opts.filter;
2068
+ }
2069
+
2070
+ return {
2071
+ addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix,
2072
+ allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots,
2073
+ charset: charset,
2074
+ charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel,
2075
+ delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter,
2076
+ encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode,
2077
+ encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder,
2078
+ encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly,
2079
+ filter: filter,
2080
+ format: format,
2081
+ formatter: formatter,
2082
+ serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate,
2083
+ skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls,
2084
+ sort: typeof opts.sort === 'function' ? opts.sort : null,
2085
+ strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling
2086
+ };
2087
+ };
2088
+
2089
+ var stringify_1 = function (object, opts) {
2090
+ var obj = object;
2091
+ var options = normalizeStringifyOptions(opts);
2092
+
2093
+ var objKeys;
2094
+ var filter;
2095
+
2096
+ if (typeof options.filter === 'function') {
2097
+ filter = options.filter;
2098
+ obj = filter('', obj);
2099
+ } else if (isArray$1(options.filter)) {
2100
+ filter = options.filter;
2101
+ objKeys = filter;
2102
+ }
2103
+
2104
+ var keys = [];
2105
+
2106
+ if (typeof obj !== 'object' || obj === null) {
2107
+ return '';
2108
+ }
2109
+
2110
+ var arrayFormat;
2111
+ if (opts && opts.arrayFormat in arrayPrefixGenerators) {
2112
+ arrayFormat = opts.arrayFormat;
2113
+ } else if (opts && 'indices' in opts) {
2114
+ arrayFormat = opts.indices ? 'indices' : 'repeat';
2115
+ } else {
2116
+ arrayFormat = 'indices';
2117
+ }
2118
+
2119
+ var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
2120
+ if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
2121
+ throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
2122
+ }
2123
+ var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
2124
+
2125
+ if (!objKeys) {
2126
+ objKeys = Object.keys(obj);
2127
+ }
2128
+
2129
+ if (options.sort) {
2130
+ objKeys.sort(options.sort);
2131
+ }
2132
+
2133
+ var sideChannel = getSideChannel();
2134
+ for (var i = 0; i < objKeys.length; ++i) {
2135
+ var key = objKeys[i];
2136
+
2137
+ if (options.skipNulls && obj[key] === null) {
2138
+ continue;
2139
+ }
2140
+ pushToArray(keys, stringify$1(
2141
+ obj[key],
2142
+ key,
2143
+ generateArrayPrefix,
2144
+ commaRoundTrip,
2145
+ options.strictNullHandling,
2146
+ options.skipNulls,
2147
+ options.encode ? options.encoder : null,
2148
+ options.filter,
2149
+ options.sort,
2150
+ options.allowDots,
2151
+ options.serializeDate,
2152
+ options.format,
2153
+ options.formatter,
2154
+ options.encodeValuesOnly,
2155
+ options.charset,
2156
+ sideChannel
2157
+ ));
2158
+ }
2159
+
2160
+ var joined = keys.join(options.delimiter);
2161
+ var prefix = options.addQueryPrefix === true ? '?' : '';
2162
+
2163
+ if (options.charsetSentinel) {
2164
+ if (options.charset === 'iso-8859-1') {
2165
+ // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
2166
+ prefix += 'utf8=%26%2310003%3B&';
2167
+ } else {
2168
+ // encodeURIComponent('✓')
2169
+ prefix += 'utf8=%E2%9C%93&';
2170
+ }
2171
+ }
2172
+
2173
+ return joined.length > 0 ? prefix + joined : '';
2174
+ };
2175
+
2176
+ var utils = utils$2;
2177
+
2178
+ var has = Object.prototype.hasOwnProperty;
2179
+ var isArray = Array.isArray;
2180
+
2181
+ var defaults = {
2182
+ allowDots: false,
2183
+ allowPrototypes: false,
2184
+ allowSparse: false,
2185
+ arrayLimit: 20,
2186
+ charset: 'utf-8',
2187
+ charsetSentinel: false,
2188
+ comma: false,
2189
+ decoder: utils.decode,
2190
+ delimiter: '&',
2191
+ depth: 5,
2192
+ ignoreQueryPrefix: false,
2193
+ interpretNumericEntities: false,
2194
+ parameterLimit: 1000,
2195
+ parseArrays: true,
2196
+ plainObjects: false,
2197
+ strictNullHandling: false
2198
+ };
2199
+
2200
+ var interpretNumericEntities = function (str) {
2201
+ return str.replace(/&#(\d+);/g, function ($0, numberStr) {
2202
+ return String.fromCharCode(parseInt(numberStr, 10));
2203
+ });
2204
+ };
2205
+
2206
+ var parseArrayValue = function (val, options) {
2207
+ if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
2208
+ return val.split(',');
2209
+ }
2210
+
2211
+ return val;
2212
+ };
2213
+
2214
+ // This is what browsers will submit when the ✓ character occurs in an
2215
+ // application/x-www-form-urlencoded body and the encoding of the page containing
2216
+ // the form is iso-8859-1, or when the submitted form has an accept-charset
2217
+ // attribute of iso-8859-1. Presumably also with other charsets that do not contain
2218
+ // the ✓ character, such as us-ascii.
2219
+ var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
2220
+
2221
+ // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
2222
+ var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
2223
+
2224
+ var parseValues = function parseQueryStringValues(str, options) {
2225
+ var obj = {};
2226
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
2227
+ var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
2228
+ var parts = cleanStr.split(options.delimiter, limit);
2229
+ var skipIndex = -1; // Keep track of where the utf8 sentinel was found
2230
+ var i;
2231
+
2232
+ var charset = options.charset;
2233
+ if (options.charsetSentinel) {
2234
+ for (i = 0; i < parts.length; ++i) {
2235
+ if (parts[i].indexOf('utf8=') === 0) {
2236
+ if (parts[i] === charsetSentinel) {
2237
+ charset = 'utf-8';
2238
+ } else if (parts[i] === isoSentinel) {
2239
+ charset = 'iso-8859-1';
2240
+ }
2241
+ skipIndex = i;
2242
+ i = parts.length; // The eslint settings do not allow break;
2243
+ }
2244
+ }
2245
+ }
2246
+
2247
+ for (i = 0; i < parts.length; ++i) {
2248
+ if (i === skipIndex) {
2249
+ continue;
2250
+ }
2251
+ var part = parts[i];
2252
+
2253
+ var bracketEqualsPos = part.indexOf(']=');
2254
+ var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
2255
+
2256
+ var key, val;
2257
+ if (pos === -1) {
2258
+ key = options.decoder(part, defaults.decoder, charset, 'key');
2259
+ val = options.strictNullHandling ? null : '';
2260
+ } else {
2261
+ key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
2262
+ val = utils.maybeMap(
2263
+ parseArrayValue(part.slice(pos + 1), options),
2264
+ function (encodedVal) {
2265
+ return options.decoder(encodedVal, defaults.decoder, charset, 'value');
2266
+ }
2267
+ );
2268
+ }
2269
+
2270
+ if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
2271
+ val = interpretNumericEntities(val);
2272
+ }
2273
+
2274
+ if (part.indexOf('[]=') > -1) {
2275
+ val = isArray(val) ? [val] : val;
2276
+ }
2277
+
2278
+ if (has.call(obj, key)) {
2279
+ obj[key] = utils.combine(obj[key], val);
2280
+ } else {
2281
+ obj[key] = val;
2282
+ }
2283
+ }
2284
+
2285
+ return obj;
2286
+ };
2287
+
2288
+ var parseObject = function (chain, val, options, valuesParsed) {
2289
+ var leaf = valuesParsed ? val : parseArrayValue(val, options);
2290
+
2291
+ for (var i = chain.length - 1; i >= 0; --i) {
2292
+ var obj;
2293
+ var root = chain[i];
2294
+
2295
+ if (root === '[]' && options.parseArrays) {
2296
+ obj = [].concat(leaf);
2297
+ } else {
2298
+ obj = options.plainObjects ? Object.create(null) : {};
2299
+ var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
2300
+ var index = parseInt(cleanRoot, 10);
2301
+ if (!options.parseArrays && cleanRoot === '') {
2302
+ obj = { 0: leaf };
2303
+ } else if (
2304
+ !isNaN(index)
2305
+ && root !== cleanRoot
2306
+ && String(index) === cleanRoot
2307
+ && index >= 0
2308
+ && (options.parseArrays && index <= options.arrayLimit)
2309
+ ) {
2310
+ obj = [];
2311
+ obj[index] = leaf;
2312
+ } else if (cleanRoot !== '__proto__') {
2313
+ obj[cleanRoot] = leaf;
2314
+ }
2315
+ }
2316
+
2317
+ leaf = obj;
2318
+ }
2319
+
2320
+ return leaf;
2321
+ };
2322
+
2323
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
2324
+ if (!givenKey) {
2325
+ return;
2326
+ }
2327
+
2328
+ // Transform dot notation to bracket notation
2329
+ var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
2330
+
2331
+ // The regex chunks
2332
+
2333
+ var brackets = /(\[[^[\]]*])/;
2334
+ var child = /(\[[^[\]]*])/g;
2335
+
2336
+ // Get the parent
2337
+
2338
+ var segment = options.depth > 0 && brackets.exec(key);
2339
+ var parent = segment ? key.slice(0, segment.index) : key;
2340
+
2341
+ // Stash the parent if it exists
2342
+
2343
+ var keys = [];
2344
+ if (parent) {
2345
+ // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
2346
+ if (!options.plainObjects && has.call(Object.prototype, parent)) {
2347
+ if (!options.allowPrototypes) {
2348
+ return;
2349
+ }
2350
+ }
2351
+
2352
+ keys.push(parent);
2353
+ }
2354
+
2355
+ // Loop through children appending to the array until we hit depth
2356
+
2357
+ var i = 0;
2358
+ while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
2359
+ i += 1;
2360
+ if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
2361
+ if (!options.allowPrototypes) {
2362
+ return;
2363
+ }
2364
+ }
2365
+ keys.push(segment[1]);
2366
+ }
2367
+
2368
+ // If there's a remainder, just add whatever is left
2369
+
2370
+ if (segment) {
2371
+ keys.push('[' + key.slice(segment.index) + ']');
2372
+ }
2373
+
2374
+ return parseObject(keys, val, options, valuesParsed);
2375
+ };
2376
+
2377
+ var normalizeParseOptions = function normalizeParseOptions(opts) {
2378
+ if (!opts) {
2379
+ return defaults;
2380
+ }
2381
+
2382
+ if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
2383
+ throw new TypeError('Decoder has to be a function.');
2384
+ }
2385
+
2386
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
2387
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
2388
+ }
2389
+ var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
2390
+
2391
+ return {
2392
+ allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
2393
+ allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
2394
+ allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
2395
+ arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
2396
+ charset: charset,
2397
+ charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
2398
+ comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
2399
+ decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
2400
+ delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
2401
+ // eslint-disable-next-line no-implicit-coercion, no-extra-parens
2402
+ depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
2403
+ ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
2404
+ interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
2405
+ parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
2406
+ parseArrays: opts.parseArrays !== false,
2407
+ plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
2408
+ strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
2409
+ };
2410
+ };
2411
+
2412
+ var parse$1 = function (str, opts) {
2413
+ var options = normalizeParseOptions(opts);
2414
+
2415
+ if (str === '' || str === null || typeof str === 'undefined') {
2416
+ return options.plainObjects ? Object.create(null) : {};
2417
+ }
2418
+
2419
+ var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
2420
+ var obj = options.plainObjects ? Object.create(null) : {};
2421
+
2422
+ // Iterate over the keys and setup the new object
2423
+
2424
+ var keys = Object.keys(tempObj);
2425
+ for (var i = 0; i < keys.length; ++i) {
2426
+ var key = keys[i];
2427
+ var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
2428
+ obj = utils.merge(obj, newObj, options);
2429
+ }
2430
+
2431
+ if (options.allowSparse === true) {
2432
+ return obj;
2433
+ }
2434
+
2435
+ return utils.compact(obj);
2436
+ };
2437
+
2438
+ var stringify = stringify_1;
2439
+ var parse = parse$1;
2440
+ var formats = formats$3;
2441
+
2442
+ var lib = {
2443
+ formats: formats,
2444
+ parse: parse,
2445
+ stringify: stringify
2446
+ };
2447
+
2448
+ var generatePath = function generatePath(path, params) {
2449
+ return Object.entries(params).reduce(function (acc, _ref) {
2450
+ var _ref2 = _slicedToArray(_ref, 2),
2451
+ name = _ref2[0],
2452
+ value = _ref2[1];
2453
+ return acc.replace(":".concat(name), value);
2454
+ }, path);
2455
+ };
2456
+
2457
+ var _excluded = ["url"];
2458
+ var list = function list(_ref) {
2459
+ var url = _ref.url,
2460
+ params = _objectWithoutProperties(_ref, _excluded);
2461
+ return axios__default["default"].get(url, {
2462
+ params: params,
2463
+ paramsSerializer: function paramsSerializer(params) {
2464
+ return lib.stringify(params, {
2465
+ arrayFormat: "brackets"
2466
+ });
2467
+ }
2468
+ });
2469
+ };
2470
+ var create = function create(_ref2) {
2471
+ var id = _ref2.id,
2472
+ url = _ref2.url;
2473
+ return axios__default["default"].post(url, {
2474
+ createTemplate: {
2475
+ id: id
2476
+ }
2477
+ });
2478
+ };
2479
+ var fetch = function fetch(resourceId, url) {
2480
+ return axios__default["default"].get(generatePath(url, {
2481
+ resourceId: resourceId
2482
+ }));
2483
+ };
2484
+ var update = function update(_ref3) {
2485
+ var resourceId = _ref3.resourceId,
2486
+ payload = _ref3.payload,
2487
+ url = _ref3.url;
2488
+ return axios__default["default"].put(generatePath(url, {
2489
+ resourceId: resourceId
2490
+ }), payload);
2491
+ };
2492
+ var templatesApi = {
2493
+ list: list,
2494
+ create: create,
2495
+ update: update,
2496
+ fetch: fetch
2497
+ };
2498
+
2499
+ var QUERY_KEYS = {
2500
+ TEMPLATES: "templates",
2501
+ TEMPLATE_TAGS: "template-tags"
2502
+ };
2503
+
2504
+ var queryClient = new reactQuery.QueryClient({
2505
+ defaultOptions: {
2506
+ queries: {
2507
+ staleTime: constants.DEFAULT_STALE_TIME
2508
+ }
2509
+ }
2510
+ });
2511
+
2512
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2513
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2514
+ var useFetchTemplates = function useFetchTemplates(_ref) {
2515
+ var url = _ref.url,
2516
+ searchTerm = _ref.searchTerm,
2517
+ category = _ref.category;
2518
+ return reactQuery.useInfiniteQuery([QUERY_KEYS.TEMPLATES, searchTerm, category], function (_ref2) {
2519
+ var _ref2$pageParam = _ref2.pageParam,
2520
+ pageParam = _ref2$pageParam === void 0 ? 1 : _ref2$pageParam;
2521
+ return templatesApi.list({
2522
+ pageNumber: pageParam,
2523
+ searchTerm: searchTerm,
2524
+ category: category,
2525
+ url: url
2526
+ });
2527
+ }, {
2528
+ getNextPageParam: function getNextPageParam(lastPage) {
2529
+ return lastPage.hasNextPage ? lastPage.pageNumber + 1 : undefined;
2530
+ },
2531
+ select: function select(data) {
2532
+ var templates = data.pages.flatMap(ramda.prop("templates"));
2533
+ var lastPage = data.pages[data.pages.length - 1];
2534
+ return {
2535
+ templates: templates,
2536
+ hasNextPage: lastPage.hasNextPage,
2537
+ pageNumber: lastPage.pageNumber,
2538
+ tags: lastPage.tags,
2539
+ templatesCount: lastPage.templatesCount
2540
+ };
2541
+ }
2542
+ });
2543
+ };
2544
+ var useCreateTemplate = function useCreateTemplate(_ref3, options) {
2545
+ var resourceQueryKey = _ref3.resourceQueryKey;
2546
+ return reactQuery.useMutation(templatesApi.create, _objectSpread$1(_objectSpread$1({}, options), {}, {
2547
+ onSuccess: function onSuccess() {
2548
+ queryClient.invalidateQueries([resourceQueryKey]);
2549
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2550
+ args[_key] = arguments[_key];
2551
+ }
2552
+ options === null || options === void 0 ? void 0 : options.onSuccess.apply(options, args);
2553
+ }
2554
+ }));
2555
+ };
2556
+
2557
+ var BlankCard = function BlankCard(_ref) {
2558
+ var Icon = _ref.icon,
2559
+ title = _ref.title,
2560
+ description = _ref.description,
2561
+ _ref$onClick = _ref.onClick,
2562
+ onClick = _ref$onClick === void 0 ? neetoCist.noop : _ref$onClick,
2563
+ _ref$disabled = _ref.disabled,
2564
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
2565
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2566
+ className: "neeto-ui-rounded-lg neeto-ui-bg-white hover:neeto-ui-bg-white neeto-ui-border-primary-500 outline-none flex cursor-pointer flex-col items-center justify-center border border-dashed p-6 transition-all duration-300 ease-in-out hover:border-solid focus:border-solid",
2567
+ "data-cy": "start-from-scratch-button",
2568
+ tabIndex: 0,
2569
+ onClick: !disabled ? onClick : neetoCist.noop
2570
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2571
+ className: "neeto-ui-text-primary-500 mb-4"
2572
+ }, /*#__PURE__*/React__default["default"].createElement(Icon, {
2573
+ size: 40
2574
+ })), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2575
+ className: "text-center",
2576
+ lineHeight: "normal",
2577
+ style: "h5",
2578
+ weight: "semibold"
2579
+ }, title), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2580
+ className: "neeto-ui-text-gray-600 text-center",
2581
+ lineHeight: "leading-4",
2582
+ style: "body3"
2583
+ }, description));
2584
+ };
2585
+
2586
+ var ButtonLoader = function ButtonLoader() {
2587
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2588
+ role: "status"
2589
+ }, /*#__PURE__*/React__default["default"].createElement("svg", {
2590
+ "aria-hidden": "true",
2591
+ className: "neeto-ui-text-gray-400 inline h-5 w-5 animate-spin",
2592
+ fill: "none",
2593
+ viewBox: "0 0 100 101",
2594
+ xmlns: "http://www.w3.org/2000/svg"
2595
+ }, /*#__PURE__*/React__default["default"].createElement("path", {
2596
+ d: "M100 50.59c0 27.615-22.386 50.001-50 50.001s-50-22.386-50-50 22.386-50 50-50 50 22.386 50 50zm-90.919 0c0 22.6 18.32 40.92 40.919 40.92 22.599 0 40.919-18.32 40.919-40.92 0-22.598-18.32-40.918-40.919-40.918-22.599 0-40.919 18.32-40.919 40.919z",
2597
+ fill: "currentColor"
2598
+ }), /*#__PURE__*/React__default["default"].createElement("path", {
2599
+ d: "M93.968 39.04c2.425-.636 3.894-3.128 3.04-5.486A50 50 0 0041.735 1.279c-2.474.414-3.922 2.919-3.285 5.344.637 2.426 3.12 3.849 5.6 3.484a40.916 40.916 0 0144.131 25.769c.902 2.34 3.361 3.802 5.787 3.165z",
2600
+ fill: "#3642df"
2601
+ })));
2602
+ };
2603
+
2604
+ var Menu = neetoui.Dropdown.Menu,
2605
+ MenuItem = neetoui.Dropdown.MenuItem;
2606
+ var Card = function Card(_ref) {
2607
+ var template = _ref.template,
2608
+ onClick = _ref.onClick,
2609
+ afterCreate = _ref.afterCreate,
2610
+ resourceQueryKey = _ref.resourceQueryKey,
2611
+ url = _ref.url;
2612
+ var _useTranslation = reactI18next.useTranslation(),
2613
+ t = _useTranslation.t;
2614
+ var _useCreateTemplate = useCreateTemplate({
2615
+ resourceQueryKey: resourceQueryKey
2616
+ }),
2617
+ createTemplate = _useCreateTemplate.mutate,
2618
+ isCreating = _useCreateTemplate.isLoading;
2619
+ var handleCreateTemplate = function handleCreateTemplate(e, templateId) {
2620
+ e.stopPropagation();
2621
+ createTemplate({
2622
+ id: templateId,
2623
+ url: url
2624
+ }, {
2625
+ onSuccess: function onSuccess(response) {
2626
+ return afterCreate(response);
2627
+ }
2628
+ });
2629
+ };
2630
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2631
+ className: "neeto-template neeto-ui-bg-white outline-none neeto-ui-shadow-sm hover:neeto-ui-border-gray-400 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex cursor-pointer flex-col overflow-hidden border transition-colors duration-300 ease-in-out",
2632
+ "data-cy": "template-card",
2633
+ tabIndex: 0,
2634
+ onClick: onClick
2635
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2636
+ className: "neeto-template__header"
2637
+ }, /*#__PURE__*/React__default["default"].createElement("img", {
2638
+ className: "neeto-template__image",
2639
+ "data-cy": "template-thumbnail-image",
2640
+ src: template.imageUrl || "https://d2v7kzglnr2dnh.cloudfront.net/images/neetoForm/default-form-template.svg"
2641
+ })), /*#__PURE__*/React__default["default"].createElement("div", {
2642
+ className: "neeto-template__description neeto-ui-bg-white flex items-center justify-between gap-2 rounded-b-lg p-2 py-1.5"
2643
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2644
+ className: "neeto-ui-text-gray-800 line-clamp-2",
2645
+ "data-cy": "template-card-title",
2646
+ lineHeight: "normal",
2647
+ style: "body2"
2648
+ }, template.title), /*#__PURE__*/React__default["default"].createElement(neetoui.Dropdown, {
2649
+ buttonProps: {
2650
+ className: "flex-shrink-0",
2651
+ size: "small"
2652
+ },
2653
+ buttonStyle: "text",
2654
+ icon: neetoIcons.MenuHorizontal,
2655
+ onClick: function onClick(e) {
2656
+ return e.stopPropagation();
2657
+ }
2658
+ }, /*#__PURE__*/React__default["default"].createElement(Menu, null, /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
2659
+ "data-cy": "use-this-template-button",
2660
+ onClick: function onClick(e) {
2661
+ return handleCreateTemplate(e, template.id);
2662
+ }
2663
+ }, t("neetoTemplate.templates.editTemplate"), isCreating && /*#__PURE__*/React__default["default"].createElement(ButtonLoader, null)), /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
2664
+ "data-cy": "template-preview-button"
2665
+ }, t("neetoTemplate.templates.preview"))))));
2666
+ };
2667
+
2668
+ var CategoryItem = function CategoryItem(_ref) {
2669
+ var label = _ref.label,
2670
+ count = _ref.count,
2671
+ isActive = _ref.isActive,
2672
+ setCurrentCategory = _ref.setCurrentCategory;
2673
+ return /*#__PURE__*/React__default["default"].createElement("button", {
2674
+ "data-cy": "category-".concat(utils$3.joinHyphenCase(label)),
2675
+ tabIndex: 0,
2676
+ className: classnames__default["default"]("neeto-ui-rounded-lg outline-none flex w-full items-center justify-between gap-2 border border-solid px-3 py-2 text-sm font-medium leading-4 transition-all duration-300 ease-in-out", {
2677
+ "neeto-ui-text-gray-700 hover:neeto-ui-bg-gray-200 focus:neeto-ui-bg-gray-200 border-transparent": !isActive,
2678
+ "neeto-ui-text-gray-800 neeto-ui-bg-white neeto-ui-border-gray-300 focus:neeto-ui-border-gray-500": isActive
2679
+ }),
2680
+ onClick: setCurrentCategory
2681
+ }, /*#__PURE__*/React__default["default"].createElement("span", null, label), /*#__PURE__*/React__default["default"].createElement("span", null, count));
2682
+ };
2683
+
2684
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2685
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2686
+ var List = function List(_ref) {
2687
+ var setCurrentScreen = _ref.setCurrentScreen,
2688
+ setSelectedTemplate = _ref.setSelectedTemplate,
2689
+ onCreate = _ref.onCreate,
2690
+ isCreating = _ref.isCreating,
2691
+ afterCreate = _ref.afterCreate,
2692
+ entity = _ref.entity,
2693
+ resourceQueryKey = _ref.resourceQueryKey,
2694
+ url = _ref.url;
2695
+ var _useTranslation = reactI18next.useTranslation(),
2696
+ t = _useTranslation.t;
2697
+ var _useState = React.useState(DEFAULT_CATEGORY),
2698
+ _useState2 = _slicedToArray(_useState, 2),
2699
+ currentCategory = _useState2[0],
2700
+ _setCurrentCategory = _useState2[1];
2701
+ var _useState3 = React.useState(""),
2702
+ _useState4 = _slicedToArray(_useState3, 2),
2703
+ searchTerm = _useState4[0],
2704
+ setSearchTerm = _useState4[1];
2705
+ var debouncedSearch = reactUtils.useDebounce(searchTerm).trim();
2706
+ var _useFetchTemplates = useFetchTemplates({
2707
+ url: url,
2708
+ searchTerm: debouncedSearch,
2709
+ category: currentCategory
2710
+ }),
2711
+ _useFetchTemplates$ha = _useFetchTemplates.hasNextPage,
2712
+ hasNextPage = _useFetchTemplates$ha === void 0 ? false : _useFetchTemplates$ha,
2713
+ fetchNextPage = _useFetchTemplates.fetchNextPage,
2714
+ isTemplatesLoading = _useFetchTemplates.isLoading,
2715
+ data = _useFetchTemplates.data;
2716
+ var _useInfiniteScroll = useInfiniteScroll({
2717
+ loading: isTemplatesLoading,
2718
+ hasNextPage: hasNextPage,
2719
+ onLoadMore: fetchNextPage,
2720
+ rootMargin: "0px 0px 700px 0px",
2721
+ delayInMs: INFINITE_SCROLL_DELAY
2722
+ }),
2723
+ _useInfiniteScroll2 = _slicedToArray(_useInfiniteScroll, 2),
2724
+ sentryRef = _useInfiniteScroll2[0],
2725
+ rootRef = _useInfiniteScroll2[1].rootRef;
2726
+ var handleCardClick = function handleCardClick(template) {
2727
+ setCurrentScreen(TEMPLATE_SCREENS.PREVIEW);
2728
+ setSelectedTemplate(template);
2729
+ };
2730
+ if (isTemplatesLoading) {
2731
+ return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
2732
+ }
2733
+ var tags = data.tags,
2734
+ templates = data.templates,
2735
+ templatesCount = data.templatesCount;
2736
+ var categories = [_objectSpread(_objectSpread({}, DEFAULT_CATEGORY), {}, {
2737
+ count: templatesCount
2738
+ })].concat(_toConsumableArray(tags));
2739
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2740
+ className: "neeto-ui-bg-gray-100 gap-18 relative flex min-h-full items-start p-16"
2741
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2742
+ className: "top-18 sticky left-0 w-80 flex-shrink-0 space-y-8"
2743
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2744
+ className: "space-y-4"
2745
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2746
+ className: "space-y-1"
2747
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2748
+ "data-cy": "create-new-form-title",
2749
+ style: "h2",
2750
+ weight: "semibold"
2751
+ }, t("neetoTemplate.templates.createNewEntity", {
2752
+ entity: entity
2753
+ })), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2754
+ lineHeight: "normal",
2755
+ style: "body2"
2756
+ }, t("neetoTemplate.templates.description"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Input, {
2757
+ placeholder: t("neetoTemplate.templates.search"),
2758
+ prefix: /*#__PURE__*/React__default["default"].createElement(neetoIcons.Search, null),
2759
+ type: "search",
2760
+ value: searchTerm,
2761
+ onChange: function onChange(_ref2) {
2762
+ var value = _ref2.target.value;
2763
+ return setSearchTerm(value);
2764
+ }
2765
+ })), /*#__PURE__*/React__default["default"].createElement("div", {
2766
+ className: "space-y-3"
2767
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2768
+ className: "uppercase",
2769
+ "data-cy": "template-categories-label",
2770
+ style: "h6"
2771
+ }, t("neetoTemplate.templates.categories")), /*#__PURE__*/React__default["default"].createElement("div", {
2772
+ className: "space-y-2"
2773
+ }, categories.map(function (_ref3) {
2774
+ var id = _ref3.id,
2775
+ name = _ref3.name,
2776
+ count = _ref3.count;
2777
+ return /*#__PURE__*/React__default["default"].createElement(CategoryItem, {
2778
+ count: count,
2779
+ isActive: currentCategory.id === id,
2780
+ key: id,
2781
+ label: name,
2782
+ setCurrentCategory: function setCurrentCategory() {
2783
+ return _setCurrentCategory({
2784
+ id: id,
2785
+ name: name
2786
+ });
2787
+ }
2788
+ });
2789
+ })))), /*#__PURE__*/React__default["default"].createElement(Scrollable__default["default"], {
2790
+ ref: rootRef
2791
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2792
+ className: "flex-grow space-y-6"
2793
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2794
+ className: "grid grid-cols-2 gap-6 md:grid-cols-3 2xl:grid-cols-4"
2795
+ }, /*#__PURE__*/React__default["default"].createElement(BlankCard, {
2796
+ description: t("neetoTemplate.templates.blankCard.description"),
2797
+ disabled: isCreating,
2798
+ icon: isCreating ? neetoui.Spinner : CustomSVG__default["default"],
2799
+ title: t("neetoTemplate.templates.blankCard.title"),
2800
+ onClick: onCreate
2801
+ }), templates === null || templates === void 0 ? void 0 : templates.map(function (template, index) {
2802
+ return /*#__PURE__*/React__default["default"].createElement(Card, {
2803
+ key: index,
2804
+ template: template,
2805
+ afterCreate: afterCreate,
2806
+ resourceQueryKey: resourceQueryKey,
2807
+ url: url,
2808
+ onClick: function onClick() {
2809
+ return handleCardClick(template);
2810
+ }
2811
+ });
2812
+ })), hasNextPage && /*#__PURE__*/React__default["default"].createElement("div", {
2813
+ className: "my-10 text-center",
2814
+ ref: sentryRef
2815
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Spinner, null)))));
2816
+ };
2817
+
2818
+ var Preview = function Preview(_ref) {
2819
+ var selectedTemplate = _ref.selectedTemplate,
2820
+ setCurrentScreen = _ref.setCurrentScreen,
2821
+ afterCreate = _ref.afterCreate,
2822
+ resourceQueryKey = _ref.resourceQueryKey,
2823
+ url = _ref.url;
2824
+ var _useTranslation = reactI18next.useTranslation(),
2825
+ t = _useTranslation.t;
2826
+ var _useCreateTemplate = useCreateTemplate({
2827
+ resourceQueryKey: resourceQueryKey
2828
+ }),
2829
+ createTemplate = _useCreateTemplate.mutate,
2830
+ isCreating = _useCreateTemplate.isLoading;
2831
+ var handleCreateTemplate = function handleCreateTemplate() {
2832
+ createTemplate({
2833
+ id: selectedTemplate.id,
2834
+ url: url
2835
+ }, {
2836
+ onSuccess: function onSuccess(response) {
2837
+ return afterCreate(response);
2838
+ }
2839
+ });
2840
+ };
2841
+ var title = selectedTemplate.title,
2842
+ publicLinkId = selectedTemplate.publicLinkId;
2843
+ return /*#__PURE__*/React__default["default"].createElement("div", {
2844
+ className: "m-auto flex h-full w-full max-w-5xl flex-col space-y-8 py-20"
2845
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2846
+ className: "flex items-center justify-between gap-6"
2847
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
2848
+ className: "flex items-center gap-2"
2849
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2850
+ "data-cy": "preview-template-back-button",
2851
+ icon: neetoIcons.LeftArrow,
2852
+ style: "text",
2853
+ onClick: function onClick() {
2854
+ return setCurrentScreen(TEMPLATE_SCREENS.LIST);
2855
+ }
2856
+ }), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
2857
+ className: "leading-none",
2858
+ "data-cy": "preview-template-title",
2859
+ style: "h2",
2860
+ weight: "semibold"
2861
+ }, title)), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
2862
+ "data-cy": "preview-use-template-button",
2863
+ label: t("neetoTemplate.v2.form.templates.editTemplate"),
2864
+ loading: isCreating,
2865
+ onClick: handleCreateTemplate
2866
+ })), /*#__PURE__*/React__default["default"].createElement("div", {
2867
+ className: "nf-share-preview neeto-ui-rounded-sm sticky top-10"
2868
+ }, /*#__PURE__*/React__default["default"].createElement("iframe", {
2869
+ className: "w-full flex-1 shadow-inner",
2870
+ "data-cy": "iframe-id",
2871
+ src: utils$3.buildUrl(PREVIEW_URL, {
2872
+ publicLinkId: publicLinkId
2873
+ })
2874
+ })));
2875
+ };
2876
+
2877
+ var CreateTemplateModal = function CreateTemplateModal(_ref) {
2878
+ var isOpen = _ref.isOpen,
2879
+ onClose = _ref.onClose,
2880
+ isCreating = _ref.isCreating,
2881
+ entity = _ref.entity,
2882
+ resourceQueryKey = _ref.resourceQueryKey,
2883
+ _ref$onCreate = _ref.onCreate,
2884
+ onCreate = _ref$onCreate === void 0 ? neetoCist.noop : _ref$onCreate,
2885
+ _ref$afterCreate = _ref.afterCreate,
2886
+ afterCreate = _ref$afterCreate === void 0 ? neetoCist.noop : _ref$afterCreate,
2887
+ _ref$url = _ref.url,
2888
+ url = _ref$url === void 0 ? "" : _ref$url;
2889
+ var _useState = React.useState(TEMPLATE_SCREENS.LIST),
2890
+ _useState2 = _slicedToArray(_useState, 2),
2891
+ currentScreen = _useState2[0],
2892
+ setCurrentScreen = _useState2[1];
2893
+ var _useState3 = React.useState({}),
2894
+ _useState4 = _slicedToArray(_useState3, 2),
2895
+ selectedTemplate = _useState4[0],
2896
+ setSelectedTemplate = _useState4[1];
2897
+ var onModalClose = function onModalClose() {
2898
+ onClose();
2899
+ setTimeout(function () {
2900
+ setCurrentScreen(TEMPLATE_SCREENS.LIST);
2901
+ }, 300); //To accommodate the animation duration.
2902
+ };
2903
+
2904
+ return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal, {
2905
+ className: "h-screen w-screen overflow-y-auto",
2906
+ isOpen: isOpen,
2907
+ size: "fullScreen",
2908
+ onClose: onModalClose
2909
+ }, currentScreen === TEMPLATE_SCREENS.LIST ? /*#__PURE__*/React__default["default"].createElement(List, {
2910
+ setCurrentScreen: setCurrentScreen,
2911
+ setSelectedTemplate: setSelectedTemplate,
2912
+ isCreating: isCreating,
2913
+ afterCreate: afterCreate,
2914
+ onCreate: onCreate,
2915
+ entity: entity,
2916
+ resourceQueryKey: resourceQueryKey,
2917
+ url: url
2918
+ }) : /*#__PURE__*/React__default["default"].createElement(Preview, {
2919
+ selectedTemplate: selectedTemplate,
2920
+ setCurrentScreen: setCurrentScreen,
2921
+ afterCreate: afterCreate,
2922
+ resourceQueryKey: resourceQueryKey,
2923
+ url: url
2924
+ }));
2925
+ };
2926
+
2927
+ exports.Templates = CreateTemplateModal;
2928
+ //# sourceMappingURL=index.cjs.js.map