@nuxt/kit 3.5.2 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +33 -5
  2. package/dist/index.mjs +2050 -36
  3. package/package.json +16 -16
package/dist/index.mjs CHANGED
@@ -6,7 +6,6 @@ import { dirname, normalize, join, relative, isAbsolute, resolve, basename, pars
6
6
  import { consola } from 'consola';
7
7
  import { getContext } from 'unctx';
8
8
  import satisfies from 'semver/functions/satisfies.js';
9
- import lodashTemplate from 'lodash.template';
10
9
  import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
11
10
  import { pathToFileURL, fileURLToPath } from 'node:url';
12
11
  import { interopDefault, resolvePath as resolvePath$1 } from 'mlly';
@@ -37,12 +36,14 @@ function tryUseNuxt() {
37
36
  return nuxtCtx.tryUse();
38
37
  }
39
38
 
39
+ function normalizeSemanticVersion(version) {
40
+ return version.replace(/-[0-9]+\.[0-9a-f]+/, "");
41
+ }
40
42
  async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
41
43
  const issues = [];
42
44
  if (constraints.nuxt) {
43
45
  const nuxtVersion = getNuxtVersion(nuxt);
44
- const nuxtSemanticVersion = nuxtVersion.replace(/-[0-9]+\.[0-9a-f]+/, "");
45
- if (!satisfies(nuxtSemanticVersion, constraints.nuxt, { includePrerelease: true })) {
46
+ if (!satisfies(normalizeSemanticVersion(nuxtVersion), constraints.nuxt, { includePrerelease: true })) {
46
47
  issues.push({
47
48
  name: "nuxt",
48
49
  message: `Nuxt version \`${constraints.nuxt}\` is required but currently using \`${nuxtVersion}\``
@@ -93,21 +94,1989 @@ function getNuxtVersion(nuxt = useNuxt()) {
93
94
  return version;
94
95
  }
95
96
 
96
- async function compileTemplate(template, ctx) {
97
- const data = { ...ctx, options: template.options };
98
- if (template.src) {
97
+ /** Detect free variable `global` from Node.js. */
98
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
99
+
100
+ const freeGlobal$1 = freeGlobal;
101
+
102
+ /** Detect free variable `self`. */
103
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
104
+
105
+ /** Used as a reference to the global object. */
106
+ var root = freeGlobal$1 || freeSelf || Function('return this')();
107
+
108
+ const root$1 = root;
109
+
110
+ /** Built-in value references. */
111
+ var Symbol = root$1.Symbol;
112
+
113
+ const Symbol$1 = Symbol;
114
+
115
+ /** Used for built-in method references. */
116
+ var objectProto$b = Object.prototype;
117
+
118
+ /** Used to check objects for own properties. */
119
+ var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
120
+
121
+ /**
122
+ * Used to resolve the
123
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
124
+ * of values.
125
+ */
126
+ var nativeObjectToString$1 = objectProto$b.toString;
127
+
128
+ /** Built-in value references. */
129
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
130
+
131
+ /**
132
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
133
+ *
134
+ * @private
135
+ * @param {*} value The value to query.
136
+ * @returns {string} Returns the raw `toStringTag`.
137
+ */
138
+ function getRawTag(value) {
139
+ var isOwn = hasOwnProperty$9.call(value, symToStringTag$1),
140
+ tag = value[symToStringTag$1];
141
+
142
+ try {
143
+ value[symToStringTag$1] = undefined;
144
+ var unmasked = true;
145
+ } catch (e) {}
146
+
147
+ var result = nativeObjectToString$1.call(value);
148
+ if (unmasked) {
149
+ if (isOwn) {
150
+ value[symToStringTag$1] = tag;
151
+ } else {
152
+ delete value[symToStringTag$1];
153
+ }
154
+ }
155
+ return result;
156
+ }
157
+
158
+ /** Used for built-in method references. */
159
+ var objectProto$a = Object.prototype;
160
+
161
+ /**
162
+ * Used to resolve the
163
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
164
+ * of values.
165
+ */
166
+ var nativeObjectToString = objectProto$a.toString;
167
+
168
+ /**
169
+ * Converts `value` to a string using `Object.prototype.toString`.
170
+ *
171
+ * @private
172
+ * @param {*} value The value to convert.
173
+ * @returns {string} Returns the converted string.
174
+ */
175
+ function objectToString(value) {
176
+ return nativeObjectToString.call(value);
177
+ }
178
+
179
+ /** `Object#toString` result references. */
180
+ var nullTag = '[object Null]',
181
+ undefinedTag = '[object Undefined]';
182
+
183
+ /** Built-in value references. */
184
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
185
+
186
+ /**
187
+ * The base implementation of `getTag` without fallbacks for buggy environments.
188
+ *
189
+ * @private
190
+ * @param {*} value The value to query.
191
+ * @returns {string} Returns the `toStringTag`.
192
+ */
193
+ function baseGetTag(value) {
194
+ if (value == null) {
195
+ return value === undefined ? undefinedTag : nullTag;
196
+ }
197
+ return (symToStringTag && symToStringTag in Object(value))
198
+ ? getRawTag(value)
199
+ : objectToString(value);
200
+ }
201
+
202
+ /**
203
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
204
+ * and has a `typeof` result of "object".
205
+ *
206
+ * @static
207
+ * @memberOf _
208
+ * @since 4.0.0
209
+ * @category Lang
210
+ * @param {*} value The value to check.
211
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
212
+ * @example
213
+ *
214
+ * _.isObjectLike({});
215
+ * // => true
216
+ *
217
+ * _.isObjectLike([1, 2, 3]);
218
+ * // => true
219
+ *
220
+ * _.isObjectLike(_.noop);
221
+ * // => false
222
+ *
223
+ * _.isObjectLike(null);
224
+ * // => false
225
+ */
226
+ function isObjectLike(value) {
227
+ return value != null && typeof value == 'object';
228
+ }
229
+
230
+ /** `Object#toString` result references. */
231
+ var symbolTag = '[object Symbol]';
232
+
233
+ /**
234
+ * Checks if `value` is classified as a `Symbol` primitive or object.
235
+ *
236
+ * @static
237
+ * @memberOf _
238
+ * @since 4.0.0
239
+ * @category Lang
240
+ * @param {*} value The value to check.
241
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
242
+ * @example
243
+ *
244
+ * _.isSymbol(Symbol.iterator);
245
+ * // => true
246
+ *
247
+ * _.isSymbol('abc');
248
+ * // => false
249
+ */
250
+ function isSymbol(value) {
251
+ return typeof value == 'symbol' ||
252
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
253
+ }
254
+
255
+ /**
256
+ * A specialized version of `_.map` for arrays without support for iteratee
257
+ * shorthands.
258
+ *
259
+ * @private
260
+ * @param {Array} [array] The array to iterate over.
261
+ * @param {Function} iteratee The function invoked per iteration.
262
+ * @returns {Array} Returns the new mapped array.
263
+ */
264
+ function arrayMap(array, iteratee) {
265
+ var index = -1,
266
+ length = array == null ? 0 : array.length,
267
+ result = Array(length);
268
+
269
+ while (++index < length) {
270
+ result[index] = iteratee(array[index], index, array);
271
+ }
272
+ return result;
273
+ }
274
+
275
+ /**
276
+ * Checks if `value` is classified as an `Array` object.
277
+ *
278
+ * @static
279
+ * @memberOf _
280
+ * @since 0.1.0
281
+ * @category Lang
282
+ * @param {*} value The value to check.
283
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
284
+ * @example
285
+ *
286
+ * _.isArray([1, 2, 3]);
287
+ * // => true
288
+ *
289
+ * _.isArray(document.body.children);
290
+ * // => false
291
+ *
292
+ * _.isArray('abc');
293
+ * // => false
294
+ *
295
+ * _.isArray(_.noop);
296
+ * // => false
297
+ */
298
+ var isArray = Array.isArray;
299
+
300
+ const isArray$1 = isArray;
301
+
302
+ /** Used as references for various `Number` constants. */
303
+ var INFINITY = 1 / 0;
304
+
305
+ /** Used to convert symbols to primitives and strings. */
306
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
307
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
308
+
309
+ /**
310
+ * The base implementation of `_.toString` which doesn't convert nullish
311
+ * values to empty strings.
312
+ *
313
+ * @private
314
+ * @param {*} value The value to process.
315
+ * @returns {string} Returns the string.
316
+ */
317
+ function baseToString(value) {
318
+ // Exit early for strings to avoid a performance hit in some environments.
319
+ if (typeof value == 'string') {
320
+ return value;
321
+ }
322
+ if (isArray$1(value)) {
323
+ // Recursively convert values (susceptible to call stack limits).
324
+ return arrayMap(value, baseToString) + '';
325
+ }
326
+ if (isSymbol(value)) {
327
+ return symbolToString ? symbolToString.call(value) : '';
328
+ }
329
+ var result = (value + '');
330
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
331
+ }
332
+
333
+ /**
334
+ * Checks if `value` is the
335
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
336
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
337
+ *
338
+ * @static
339
+ * @memberOf _
340
+ * @since 0.1.0
341
+ * @category Lang
342
+ * @param {*} value The value to check.
343
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
344
+ * @example
345
+ *
346
+ * _.isObject({});
347
+ * // => true
348
+ *
349
+ * _.isObject([1, 2, 3]);
350
+ * // => true
351
+ *
352
+ * _.isObject(_.noop);
353
+ * // => true
354
+ *
355
+ * _.isObject(null);
356
+ * // => false
357
+ */
358
+ function isObject(value) {
359
+ var type = typeof value;
360
+ return value != null && (type == 'object' || type == 'function');
361
+ }
362
+
363
+ /**
364
+ * This method returns the first argument it receives.
365
+ *
366
+ * @static
367
+ * @since 0.1.0
368
+ * @memberOf _
369
+ * @category Util
370
+ * @param {*} value Any value.
371
+ * @returns {*} Returns `value`.
372
+ * @example
373
+ *
374
+ * var object = { 'a': 1 };
375
+ *
376
+ * console.log(_.identity(object) === object);
377
+ * // => true
378
+ */
379
+ function identity(value) {
380
+ return value;
381
+ }
382
+
383
+ /** `Object#toString` result references. */
384
+ var asyncTag = '[object AsyncFunction]',
385
+ funcTag$1 = '[object Function]',
386
+ genTag = '[object GeneratorFunction]',
387
+ proxyTag = '[object Proxy]';
388
+
389
+ /**
390
+ * Checks if `value` is classified as a `Function` object.
391
+ *
392
+ * @static
393
+ * @memberOf _
394
+ * @since 0.1.0
395
+ * @category Lang
396
+ * @param {*} value The value to check.
397
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
398
+ * @example
399
+ *
400
+ * _.isFunction(_);
401
+ * // => true
402
+ *
403
+ * _.isFunction(/abc/);
404
+ * // => false
405
+ */
406
+ function isFunction(value) {
407
+ if (!isObject(value)) {
408
+ return false;
409
+ }
410
+ // The use of `Object#toString` avoids issues with the `typeof` operator
411
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
412
+ var tag = baseGetTag(value);
413
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
414
+ }
415
+
416
+ /** Used to detect overreaching core-js shims. */
417
+ var coreJsData = root$1['__core-js_shared__'];
418
+
419
+ const coreJsData$1 = coreJsData;
420
+
421
+ /** Used to detect methods masquerading as native. */
422
+ var maskSrcKey = (function() {
423
+ var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
424
+ return uid ? ('Symbol(src)_1.' + uid) : '';
425
+ }());
426
+
427
+ /**
428
+ * Checks if `func` has its source masked.
429
+ *
430
+ * @private
431
+ * @param {Function} func The function to check.
432
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
433
+ */
434
+ function isMasked(func) {
435
+ return !!maskSrcKey && (maskSrcKey in func);
436
+ }
437
+
438
+ /** Used for built-in method references. */
439
+ var funcProto$2 = Function.prototype;
440
+
441
+ /** Used to resolve the decompiled source of functions. */
442
+ var funcToString$2 = funcProto$2.toString;
443
+
444
+ /**
445
+ * Converts `func` to its source code.
446
+ *
447
+ * @private
448
+ * @param {Function} func The function to convert.
449
+ * @returns {string} Returns the source code.
450
+ */
451
+ function toSource(func) {
452
+ if (func != null) {
453
+ try {
454
+ return funcToString$2.call(func);
455
+ } catch (e) {}
99
456
  try {
100
- const srcContents = await promises.readFile(template.src, "utf-8");
101
- return lodashTemplate(srcContents, {})(data);
457
+ return (func + '');
458
+ } catch (e) {}
459
+ }
460
+ return '';
461
+ }
462
+
463
+ /**
464
+ * Used to match `RegExp`
465
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
466
+ */
467
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
468
+
469
+ /** Used to detect host constructors (Safari). */
470
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
471
+
472
+ /** Used for built-in method references. */
473
+ var funcProto$1 = Function.prototype,
474
+ objectProto$9 = Object.prototype;
475
+
476
+ /** Used to resolve the decompiled source of functions. */
477
+ var funcToString$1 = funcProto$1.toString;
478
+
479
+ /** Used to check objects for own properties. */
480
+ var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
481
+
482
+ /** Used to detect if a method is native. */
483
+ var reIsNative = RegExp('^' +
484
+ funcToString$1.call(hasOwnProperty$8).replace(reRegExpChar, '\\$&')
485
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
486
+ );
487
+
488
+ /**
489
+ * The base implementation of `_.isNative` without bad shim checks.
490
+ *
491
+ * @private
492
+ * @param {*} value The value to check.
493
+ * @returns {boolean} Returns `true` if `value` is a native function,
494
+ * else `false`.
495
+ */
496
+ function baseIsNative(value) {
497
+ if (!isObject(value) || isMasked(value)) {
498
+ return false;
499
+ }
500
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
501
+ return pattern.test(toSource(value));
502
+ }
503
+
504
+ /**
505
+ * Gets the value at `key` of `object`.
506
+ *
507
+ * @private
508
+ * @param {Object} [object] The object to query.
509
+ * @param {string} key The key of the property to get.
510
+ * @returns {*} Returns the property value.
511
+ */
512
+ function getValue(object, key) {
513
+ return object == null ? undefined : object[key];
514
+ }
515
+
516
+ /**
517
+ * Gets the native function at `key` of `object`.
518
+ *
519
+ * @private
520
+ * @param {Object} object The object to query.
521
+ * @param {string} key The key of the method to get.
522
+ * @returns {*} Returns the function if it's native, else `undefined`.
523
+ */
524
+ function getNative(object, key) {
525
+ var value = getValue(object, key);
526
+ return baseIsNative(value) ? value : undefined;
527
+ }
528
+
529
+ /**
530
+ * A faster alternative to `Function#apply`, this function invokes `func`
531
+ * with the `this` binding of `thisArg` and the arguments of `args`.
532
+ *
533
+ * @private
534
+ * @param {Function} func The function to invoke.
535
+ * @param {*} thisArg The `this` binding of `func`.
536
+ * @param {Array} args The arguments to invoke `func` with.
537
+ * @returns {*} Returns the result of `func`.
538
+ */
539
+ function apply(func, thisArg, args) {
540
+ switch (args.length) {
541
+ case 0: return func.call(thisArg);
542
+ case 1: return func.call(thisArg, args[0]);
543
+ case 2: return func.call(thisArg, args[0], args[1]);
544
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
545
+ }
546
+ return func.apply(thisArg, args);
547
+ }
548
+
549
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
550
+ var HOT_COUNT = 800,
551
+ HOT_SPAN = 16;
552
+
553
+ /* Built-in method references for those with the same name as other `lodash` methods. */
554
+ var nativeNow = Date.now;
555
+
556
+ /**
557
+ * Creates a function that'll short out and invoke `identity` instead
558
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
559
+ * milliseconds.
560
+ *
561
+ * @private
562
+ * @param {Function} func The function to restrict.
563
+ * @returns {Function} Returns the new shortable function.
564
+ */
565
+ function shortOut(func) {
566
+ var count = 0,
567
+ lastCalled = 0;
568
+
569
+ return function() {
570
+ var stamp = nativeNow(),
571
+ remaining = HOT_SPAN - (stamp - lastCalled);
572
+
573
+ lastCalled = stamp;
574
+ if (remaining > 0) {
575
+ if (++count >= HOT_COUNT) {
576
+ return arguments[0];
577
+ }
578
+ } else {
579
+ count = 0;
580
+ }
581
+ return func.apply(undefined, arguments);
582
+ };
583
+ }
584
+
585
+ /**
586
+ * Creates a function that returns `value`.
587
+ *
588
+ * @static
589
+ * @memberOf _
590
+ * @since 2.4.0
591
+ * @category Util
592
+ * @param {*} value The value to return from the new function.
593
+ * @returns {Function} Returns the new constant function.
594
+ * @example
595
+ *
596
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
597
+ *
598
+ * console.log(objects);
599
+ * // => [{ 'a': 1 }, { 'a': 1 }]
600
+ *
601
+ * console.log(objects[0] === objects[1]);
602
+ * // => true
603
+ */
604
+ function constant(value) {
605
+ return function() {
606
+ return value;
607
+ };
608
+ }
609
+
610
+ var defineProperty = (function() {
611
+ try {
612
+ var func = getNative(Object, 'defineProperty');
613
+ func({}, '', {});
614
+ return func;
615
+ } catch (e) {}
616
+ }());
617
+
618
+ const defineProperty$1 = defineProperty;
619
+
620
+ /**
621
+ * The base implementation of `setToString` without support for hot loop shorting.
622
+ *
623
+ * @private
624
+ * @param {Function} func The function to modify.
625
+ * @param {Function} string The `toString` result.
626
+ * @returns {Function} Returns `func`.
627
+ */
628
+ var baseSetToString = !defineProperty$1 ? identity : function(func, string) {
629
+ return defineProperty$1(func, 'toString', {
630
+ 'configurable': true,
631
+ 'enumerable': false,
632
+ 'value': constant(string),
633
+ 'writable': true
634
+ });
635
+ };
636
+
637
+ const baseSetToString$1 = baseSetToString;
638
+
639
+ /**
640
+ * Sets the `toString` method of `func` to return `string`.
641
+ *
642
+ * @private
643
+ * @param {Function} func The function to modify.
644
+ * @param {Function} string The `toString` result.
645
+ * @returns {Function} Returns `func`.
646
+ */
647
+ var setToString = shortOut(baseSetToString$1);
648
+
649
+ const setToString$1 = setToString;
650
+
651
+ /** Used as references for various `Number` constants. */
652
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
653
+
654
+ /** Used to detect unsigned integer values. */
655
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
656
+
657
+ /**
658
+ * Checks if `value` is a valid array-like index.
659
+ *
660
+ * @private
661
+ * @param {*} value The value to check.
662
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
663
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
664
+ */
665
+ function isIndex(value, length) {
666
+ var type = typeof value;
667
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
668
+
669
+ return !!length &&
670
+ (type == 'number' ||
671
+ (type != 'symbol' && reIsUint.test(value))) &&
672
+ (value > -1 && value % 1 == 0 && value < length);
673
+ }
674
+
675
+ /**
676
+ * The base implementation of `assignValue` and `assignMergeValue` without
677
+ * value checks.
678
+ *
679
+ * @private
680
+ * @param {Object} object The object to modify.
681
+ * @param {string} key The key of the property to assign.
682
+ * @param {*} value The value to assign.
683
+ */
684
+ function baseAssignValue(object, key, value) {
685
+ if (key == '__proto__' && defineProperty$1) {
686
+ defineProperty$1(object, key, {
687
+ 'configurable': true,
688
+ 'enumerable': true,
689
+ 'value': value,
690
+ 'writable': true
691
+ });
692
+ } else {
693
+ object[key] = value;
694
+ }
695
+ }
696
+
697
+ /**
698
+ * Performs a
699
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
700
+ * comparison between two values to determine if they are equivalent.
701
+ *
702
+ * @static
703
+ * @memberOf _
704
+ * @since 4.0.0
705
+ * @category Lang
706
+ * @param {*} value The value to compare.
707
+ * @param {*} other The other value to compare.
708
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
709
+ * @example
710
+ *
711
+ * var object = { 'a': 1 };
712
+ * var other = { 'a': 1 };
713
+ *
714
+ * _.eq(object, object);
715
+ * // => true
716
+ *
717
+ * _.eq(object, other);
718
+ * // => false
719
+ *
720
+ * _.eq('a', 'a');
721
+ * // => true
722
+ *
723
+ * _.eq('a', Object('a'));
724
+ * // => false
725
+ *
726
+ * _.eq(NaN, NaN);
727
+ * // => true
728
+ */
729
+ function eq(value, other) {
730
+ return value === other || (value !== value && other !== other);
731
+ }
732
+
733
+ /** Used for built-in method references. */
734
+ var objectProto$8 = Object.prototype;
735
+
736
+ /** Used to check objects for own properties. */
737
+ var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
738
+
739
+ /**
740
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
741
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
742
+ * for equality comparisons.
743
+ *
744
+ * @private
745
+ * @param {Object} object The object to modify.
746
+ * @param {string} key The key of the property to assign.
747
+ * @param {*} value The value to assign.
748
+ */
749
+ function assignValue(object, key, value) {
750
+ var objValue = object[key];
751
+ if (!(hasOwnProperty$7.call(object, key) && eq(objValue, value)) ||
752
+ (value === undefined && !(key in object))) {
753
+ baseAssignValue(object, key, value);
754
+ }
755
+ }
756
+
757
+ /**
758
+ * Copies properties of `source` to `object`.
759
+ *
760
+ * @private
761
+ * @param {Object} source The object to copy properties from.
762
+ * @param {Array} props The property identifiers to copy.
763
+ * @param {Object} [object={}] The object to copy properties to.
764
+ * @param {Function} [customizer] The function to customize copied values.
765
+ * @returns {Object} Returns `object`.
766
+ */
767
+ function copyObject(source, props, object, customizer) {
768
+ var isNew = !object;
769
+ object || (object = {});
770
+
771
+ var index = -1,
772
+ length = props.length;
773
+
774
+ while (++index < length) {
775
+ var key = props[index];
776
+
777
+ var newValue = customizer
778
+ ? customizer(object[key], source[key], key, object, source)
779
+ : undefined;
780
+
781
+ if (newValue === undefined) {
782
+ newValue = source[key];
783
+ }
784
+ if (isNew) {
785
+ baseAssignValue(object, key, newValue);
786
+ } else {
787
+ assignValue(object, key, newValue);
788
+ }
789
+ }
790
+ return object;
791
+ }
792
+
793
+ /* Built-in method references for those with the same name as other `lodash` methods. */
794
+ var nativeMax = Math.max;
795
+
796
+ /**
797
+ * A specialized version of `baseRest` which transforms the rest array.
798
+ *
799
+ * @private
800
+ * @param {Function} func The function to apply a rest parameter to.
801
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
802
+ * @param {Function} transform The rest array transform.
803
+ * @returns {Function} Returns the new function.
804
+ */
805
+ function overRest(func, start, transform) {
806
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
807
+ return function() {
808
+ var args = arguments,
809
+ index = -1,
810
+ length = nativeMax(args.length - start, 0),
811
+ array = Array(length);
812
+
813
+ while (++index < length) {
814
+ array[index] = args[start + index];
815
+ }
816
+ index = -1;
817
+ var otherArgs = Array(start + 1);
818
+ while (++index < start) {
819
+ otherArgs[index] = args[index];
820
+ }
821
+ otherArgs[start] = transform(array);
822
+ return apply(func, this, otherArgs);
823
+ };
824
+ }
825
+
826
+ /**
827
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
828
+ *
829
+ * @private
830
+ * @param {Function} func The function to apply a rest parameter to.
831
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
832
+ * @returns {Function} Returns the new function.
833
+ */
834
+ function baseRest(func, start) {
835
+ return setToString$1(overRest(func, start, identity), func + '');
836
+ }
837
+
838
+ /** Used as references for various `Number` constants. */
839
+ var MAX_SAFE_INTEGER = 9007199254740991;
840
+
841
+ /**
842
+ * Checks if `value` is a valid array-like length.
843
+ *
844
+ * **Note:** This method is loosely based on
845
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
846
+ *
847
+ * @static
848
+ * @memberOf _
849
+ * @since 4.0.0
850
+ * @category Lang
851
+ * @param {*} value The value to check.
852
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
853
+ * @example
854
+ *
855
+ * _.isLength(3);
856
+ * // => true
857
+ *
858
+ * _.isLength(Number.MIN_VALUE);
859
+ * // => false
860
+ *
861
+ * _.isLength(Infinity);
862
+ * // => false
863
+ *
864
+ * _.isLength('3');
865
+ * // => false
866
+ */
867
+ function isLength(value) {
868
+ return typeof value == 'number' &&
869
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
870
+ }
871
+
872
+ /**
873
+ * Checks if `value` is array-like. A value is considered array-like if it's
874
+ * not a function and has a `value.length` that's an integer greater than or
875
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
876
+ *
877
+ * @static
878
+ * @memberOf _
879
+ * @since 4.0.0
880
+ * @category Lang
881
+ * @param {*} value The value to check.
882
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
883
+ * @example
884
+ *
885
+ * _.isArrayLike([1, 2, 3]);
886
+ * // => true
887
+ *
888
+ * _.isArrayLike(document.body.children);
889
+ * // => true
890
+ *
891
+ * _.isArrayLike('abc');
892
+ * // => true
893
+ *
894
+ * _.isArrayLike(_.noop);
895
+ * // => false
896
+ */
897
+ function isArrayLike(value) {
898
+ return value != null && isLength(value.length) && !isFunction(value);
899
+ }
900
+
901
+ /**
902
+ * Checks if the given arguments are from an iteratee call.
903
+ *
904
+ * @private
905
+ * @param {*} value The potential iteratee value argument.
906
+ * @param {*} index The potential iteratee index or key argument.
907
+ * @param {*} object The potential iteratee object argument.
908
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
909
+ * else `false`.
910
+ */
911
+ function isIterateeCall(value, index, object) {
912
+ if (!isObject(object)) {
913
+ return false;
914
+ }
915
+ var type = typeof index;
916
+ if (type == 'number'
917
+ ? (isArrayLike(object) && isIndex(index, object.length))
918
+ : (type == 'string' && index in object)
919
+ ) {
920
+ return eq(object[index], value);
921
+ }
922
+ return false;
923
+ }
924
+
925
+ /**
926
+ * Creates a function like `_.assign`.
927
+ *
928
+ * @private
929
+ * @param {Function} assigner The function to assign values.
930
+ * @returns {Function} Returns the new assigner function.
931
+ */
932
+ function createAssigner(assigner) {
933
+ return baseRest(function(object, sources) {
934
+ var index = -1,
935
+ length = sources.length,
936
+ customizer = length > 1 ? sources[length - 1] : undefined,
937
+ guard = length > 2 ? sources[2] : undefined;
938
+
939
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
940
+ ? (length--, customizer)
941
+ : undefined;
942
+
943
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
944
+ customizer = length < 3 ? undefined : customizer;
945
+ length = 1;
946
+ }
947
+ object = Object(object);
948
+ while (++index < length) {
949
+ var source = sources[index];
950
+ if (source) {
951
+ assigner(object, source, index, customizer);
952
+ }
953
+ }
954
+ return object;
955
+ });
956
+ }
957
+
958
+ /** Used for built-in method references. */
959
+ var objectProto$7 = Object.prototype;
960
+
961
+ /**
962
+ * Checks if `value` is likely a prototype object.
963
+ *
964
+ * @private
965
+ * @param {*} value The value to check.
966
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
967
+ */
968
+ function isPrototype(value) {
969
+ var Ctor = value && value.constructor,
970
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
971
+
972
+ return value === proto;
973
+ }
974
+
975
+ /**
976
+ * The base implementation of `_.times` without support for iteratee shorthands
977
+ * or max array length checks.
978
+ *
979
+ * @private
980
+ * @param {number} n The number of times to invoke `iteratee`.
981
+ * @param {Function} iteratee The function invoked per iteration.
982
+ * @returns {Array} Returns the array of results.
983
+ */
984
+ function baseTimes(n, iteratee) {
985
+ var index = -1,
986
+ result = Array(n);
987
+
988
+ while (++index < n) {
989
+ result[index] = iteratee(index);
990
+ }
991
+ return result;
992
+ }
993
+
994
+ /** `Object#toString` result references. */
995
+ var argsTag$1 = '[object Arguments]';
996
+
997
+ /**
998
+ * The base implementation of `_.isArguments`.
999
+ *
1000
+ * @private
1001
+ * @param {*} value The value to check.
1002
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1003
+ */
1004
+ function baseIsArguments(value) {
1005
+ return isObjectLike(value) && baseGetTag(value) == argsTag$1;
1006
+ }
1007
+
1008
+ /** Used for built-in method references. */
1009
+ var objectProto$6 = Object.prototype;
1010
+
1011
+ /** Used to check objects for own properties. */
1012
+ var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
1013
+
1014
+ /** Built-in value references. */
1015
+ var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
1016
+
1017
+ /**
1018
+ * Checks if `value` is likely an `arguments` object.
1019
+ *
1020
+ * @static
1021
+ * @memberOf _
1022
+ * @since 0.1.0
1023
+ * @category Lang
1024
+ * @param {*} value The value to check.
1025
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1026
+ * else `false`.
1027
+ * @example
1028
+ *
1029
+ * _.isArguments(function() { return arguments; }());
1030
+ * // => true
1031
+ *
1032
+ * _.isArguments([1, 2, 3]);
1033
+ * // => false
1034
+ */
1035
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1036
+ return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
1037
+ !propertyIsEnumerable.call(value, 'callee');
1038
+ };
1039
+
1040
+ const isArguments$1 = isArguments;
1041
+
1042
+ /**
1043
+ * This method returns `false`.
1044
+ *
1045
+ * @static
1046
+ * @memberOf _
1047
+ * @since 4.13.0
1048
+ * @category Util
1049
+ * @returns {boolean} Returns `false`.
1050
+ * @example
1051
+ *
1052
+ * _.times(2, _.stubFalse);
1053
+ * // => [false, false]
1054
+ */
1055
+ function stubFalse() {
1056
+ return false;
1057
+ }
1058
+
1059
+ /** Detect free variable `exports`. */
1060
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1061
+
1062
+ /** Detect free variable `module`. */
1063
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1064
+
1065
+ /** Detect the popular CommonJS extension `module.exports`. */
1066
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1067
+
1068
+ /** Built-in value references. */
1069
+ var Buffer = moduleExports$1 ? root$1.Buffer : undefined;
1070
+
1071
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1072
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1073
+
1074
+ /**
1075
+ * Checks if `value` is a buffer.
1076
+ *
1077
+ * @static
1078
+ * @memberOf _
1079
+ * @since 4.3.0
1080
+ * @category Lang
1081
+ * @param {*} value The value to check.
1082
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1083
+ * @example
1084
+ *
1085
+ * _.isBuffer(new Buffer(2));
1086
+ * // => true
1087
+ *
1088
+ * _.isBuffer(new Uint8Array(2));
1089
+ * // => false
1090
+ */
1091
+ var isBuffer = nativeIsBuffer || stubFalse;
1092
+
1093
+ const isBuffer$1 = isBuffer;
1094
+
1095
+ /** `Object#toString` result references. */
1096
+ var argsTag = '[object Arguments]',
1097
+ arrayTag = '[object Array]',
1098
+ boolTag = '[object Boolean]',
1099
+ dateTag = '[object Date]',
1100
+ errorTag$1 = '[object Error]',
1101
+ funcTag = '[object Function]',
1102
+ mapTag = '[object Map]',
1103
+ numberTag = '[object Number]',
1104
+ objectTag$1 = '[object Object]',
1105
+ regexpTag = '[object RegExp]',
1106
+ setTag = '[object Set]',
1107
+ stringTag = '[object String]',
1108
+ weakMapTag = '[object WeakMap]';
1109
+
1110
+ var arrayBufferTag = '[object ArrayBuffer]',
1111
+ dataViewTag = '[object DataView]',
1112
+ float32Tag = '[object Float32Array]',
1113
+ float64Tag = '[object Float64Array]',
1114
+ int8Tag = '[object Int8Array]',
1115
+ int16Tag = '[object Int16Array]',
1116
+ int32Tag = '[object Int32Array]',
1117
+ uint8Tag = '[object Uint8Array]',
1118
+ uint8ClampedTag = '[object Uint8ClampedArray]',
1119
+ uint16Tag = '[object Uint16Array]',
1120
+ uint32Tag = '[object Uint32Array]';
1121
+
1122
+ /** Used to identify `toStringTag` values of typed arrays. */
1123
+ var typedArrayTags = {};
1124
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1125
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1126
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1127
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1128
+ typedArrayTags[uint32Tag] = true;
1129
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1130
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1131
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
1132
+ typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
1133
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
1134
+ typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
1135
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
1136
+ typedArrayTags[weakMapTag] = false;
1137
+
1138
+ /**
1139
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
1140
+ *
1141
+ * @private
1142
+ * @param {*} value The value to check.
1143
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1144
+ */
1145
+ function baseIsTypedArray(value) {
1146
+ return isObjectLike(value) &&
1147
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1148
+ }
1149
+
1150
+ /**
1151
+ * The base implementation of `_.unary` without support for storing metadata.
1152
+ *
1153
+ * @private
1154
+ * @param {Function} func The function to cap arguments for.
1155
+ * @returns {Function} Returns the new capped function.
1156
+ */
1157
+ function baseUnary(func) {
1158
+ return function(value) {
1159
+ return func(value);
1160
+ };
1161
+ }
1162
+
1163
+ /** Detect free variable `exports`. */
1164
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
1165
+
1166
+ /** Detect free variable `module`. */
1167
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
1168
+
1169
+ /** Detect the popular CommonJS extension `module.exports`. */
1170
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1171
+
1172
+ /** Detect free variable `process` from Node.js. */
1173
+ var freeProcess = moduleExports && freeGlobal$1.process;
1174
+
1175
+ /** Used to access faster Node.js helpers. */
1176
+ var nodeUtil = (function() {
1177
+ try {
1178
+ // Use `util.types` for Node.js 10+.
1179
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
1180
+
1181
+ if (types) {
1182
+ return types;
1183
+ }
1184
+
1185
+ // Legacy `process.binding('util')` for Node.js < 10.
1186
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
1187
+ } catch (e) {}
1188
+ }());
1189
+
1190
+ const nodeUtil$1 = nodeUtil;
1191
+
1192
+ /* Node.js helper references. */
1193
+ var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
1194
+
1195
+ /**
1196
+ * Checks if `value` is classified as a typed array.
1197
+ *
1198
+ * @static
1199
+ * @memberOf _
1200
+ * @since 3.0.0
1201
+ * @category Lang
1202
+ * @param {*} value The value to check.
1203
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1204
+ * @example
1205
+ *
1206
+ * _.isTypedArray(new Uint8Array);
1207
+ * // => true
1208
+ *
1209
+ * _.isTypedArray([]);
1210
+ * // => false
1211
+ */
1212
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1213
+
1214
+ const isTypedArray$1 = isTypedArray;
1215
+
1216
+ /** Used for built-in method references. */
1217
+ var objectProto$5 = Object.prototype;
1218
+
1219
+ /** Used to check objects for own properties. */
1220
+ var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
1221
+
1222
+ /**
1223
+ * Creates an array of the enumerable property names of the array-like `value`.
1224
+ *
1225
+ * @private
1226
+ * @param {*} value The value to query.
1227
+ * @param {boolean} inherited Specify returning inherited property names.
1228
+ * @returns {Array} Returns the array of property names.
1229
+ */
1230
+ function arrayLikeKeys(value, inherited) {
1231
+ var isArr = isArray$1(value),
1232
+ isArg = !isArr && isArguments$1(value),
1233
+ isBuff = !isArr && !isArg && isBuffer$1(value),
1234
+ isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
1235
+ skipIndexes = isArr || isArg || isBuff || isType,
1236
+ result = skipIndexes ? baseTimes(value.length, String) : [],
1237
+ length = result.length;
1238
+
1239
+ for (var key in value) {
1240
+ if ((inherited || hasOwnProperty$5.call(value, key)) &&
1241
+ !(skipIndexes && (
1242
+ // Safari 9 has enumerable `arguments.length` in strict mode.
1243
+ key == 'length' ||
1244
+ // Node.js 0.10 has enumerable non-index properties on buffers.
1245
+ (isBuff && (key == 'offset' || key == 'parent')) ||
1246
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
1247
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1248
+ // Skip index properties.
1249
+ isIndex(key, length)
1250
+ ))) {
1251
+ result.push(key);
1252
+ }
1253
+ }
1254
+ return result;
1255
+ }
1256
+
1257
+ /**
1258
+ * Creates a unary function that invokes `func` with its argument transformed.
1259
+ *
1260
+ * @private
1261
+ * @param {Function} func The function to wrap.
1262
+ * @param {Function} transform The argument transform.
1263
+ * @returns {Function} Returns the new function.
1264
+ */
1265
+ function overArg(func, transform) {
1266
+ return function(arg) {
1267
+ return func(transform(arg));
1268
+ };
1269
+ }
1270
+
1271
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1272
+ var nativeKeys = overArg(Object.keys, Object);
1273
+
1274
+ const nativeKeys$1 = nativeKeys;
1275
+
1276
+ /** Used for built-in method references. */
1277
+ var objectProto$4 = Object.prototype;
1278
+
1279
+ /** Used to check objects for own properties. */
1280
+ var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
1281
+
1282
+ /**
1283
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1284
+ *
1285
+ * @private
1286
+ * @param {Object} object The object to query.
1287
+ * @returns {Array} Returns the array of property names.
1288
+ */
1289
+ function baseKeys(object) {
1290
+ if (!isPrototype(object)) {
1291
+ return nativeKeys$1(object);
1292
+ }
1293
+ var result = [];
1294
+ for (var key in Object(object)) {
1295
+ if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
1296
+ result.push(key);
1297
+ }
1298
+ }
1299
+ return result;
1300
+ }
1301
+
1302
+ /**
1303
+ * Creates an array of the own enumerable property names of `object`.
1304
+ *
1305
+ * **Note:** Non-object values are coerced to objects. See the
1306
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1307
+ * for more details.
1308
+ *
1309
+ * @static
1310
+ * @since 0.1.0
1311
+ * @memberOf _
1312
+ * @category Object
1313
+ * @param {Object} object The object to query.
1314
+ * @returns {Array} Returns the array of property names.
1315
+ * @example
1316
+ *
1317
+ * function Foo() {
1318
+ * this.a = 1;
1319
+ * this.b = 2;
1320
+ * }
1321
+ *
1322
+ * Foo.prototype.c = 3;
1323
+ *
1324
+ * _.keys(new Foo);
1325
+ * // => ['a', 'b'] (iteration order is not guaranteed)
1326
+ *
1327
+ * _.keys('hi');
1328
+ * // => ['0', '1']
1329
+ */
1330
+ function keys(object) {
1331
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1332
+ }
1333
+
1334
+ /**
1335
+ * This function is like
1336
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1337
+ * except that it includes inherited enumerable properties.
1338
+ *
1339
+ * @private
1340
+ * @param {Object} object The object to query.
1341
+ * @returns {Array} Returns the array of property names.
1342
+ */
1343
+ function nativeKeysIn(object) {
1344
+ var result = [];
1345
+ if (object != null) {
1346
+ for (var key in Object(object)) {
1347
+ result.push(key);
1348
+ }
1349
+ }
1350
+ return result;
1351
+ }
1352
+
1353
+ /** Used for built-in method references. */
1354
+ var objectProto$3 = Object.prototype;
1355
+
1356
+ /** Used to check objects for own properties. */
1357
+ var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
1358
+
1359
+ /**
1360
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1361
+ *
1362
+ * @private
1363
+ * @param {Object} object The object to query.
1364
+ * @returns {Array} Returns the array of property names.
1365
+ */
1366
+ function baseKeysIn(object) {
1367
+ if (!isObject(object)) {
1368
+ return nativeKeysIn(object);
1369
+ }
1370
+ var isProto = isPrototype(object),
1371
+ result = [];
1372
+
1373
+ for (var key in object) {
1374
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
1375
+ result.push(key);
1376
+ }
1377
+ }
1378
+ return result;
1379
+ }
1380
+
1381
+ /**
1382
+ * Creates an array of the own and inherited enumerable property names of `object`.
1383
+ *
1384
+ * **Note:** Non-object values are coerced to objects.
1385
+ *
1386
+ * @static
1387
+ * @memberOf _
1388
+ * @since 3.0.0
1389
+ * @category Object
1390
+ * @param {Object} object The object to query.
1391
+ * @returns {Array} Returns the array of property names.
1392
+ * @example
1393
+ *
1394
+ * function Foo() {
1395
+ * this.a = 1;
1396
+ * this.b = 2;
1397
+ * }
1398
+ *
1399
+ * Foo.prototype.c = 3;
1400
+ *
1401
+ * _.keysIn(new Foo);
1402
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
1403
+ */
1404
+ function keysIn(object) {
1405
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
1406
+ }
1407
+
1408
+ /**
1409
+ * This method is like `_.assignIn` except that it accepts `customizer`
1410
+ * which is invoked to produce the assigned values. If `customizer` returns
1411
+ * `undefined`, assignment is handled by the method instead. The `customizer`
1412
+ * is invoked with five arguments: (objValue, srcValue, key, object, source).
1413
+ *
1414
+ * **Note:** This method mutates `object`.
1415
+ *
1416
+ * @static
1417
+ * @memberOf _
1418
+ * @since 4.0.0
1419
+ * @alias extendWith
1420
+ * @category Object
1421
+ * @param {Object} object The destination object.
1422
+ * @param {...Object} sources The source objects.
1423
+ * @param {Function} [customizer] The function to customize assigned values.
1424
+ * @returns {Object} Returns `object`.
1425
+ * @see _.assignWith
1426
+ * @example
1427
+ *
1428
+ * function customizer(objValue, srcValue) {
1429
+ * return _.isUndefined(objValue) ? srcValue : objValue;
1430
+ * }
1431
+ *
1432
+ * var defaults = _.partialRight(_.assignInWith, customizer);
1433
+ *
1434
+ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
1435
+ * // => { 'a': 1, 'b': 2 }
1436
+ */
1437
+ var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
1438
+ copyObject(source, keysIn(source), object, customizer);
1439
+ });
1440
+
1441
+ const extendWith = assignInWith;
1442
+
1443
+ /**
1444
+ * Converts `value` to a string. An empty string is returned for `null`
1445
+ * and `undefined` values. The sign of `-0` is preserved.
1446
+ *
1447
+ * @static
1448
+ * @memberOf _
1449
+ * @since 4.0.0
1450
+ * @category Lang
1451
+ * @param {*} value The value to convert.
1452
+ * @returns {string} Returns the converted string.
1453
+ * @example
1454
+ *
1455
+ * _.toString(null);
1456
+ * // => ''
1457
+ *
1458
+ * _.toString(-0);
1459
+ * // => '-0'
1460
+ *
1461
+ * _.toString([1, 2, 3]);
1462
+ * // => '1,2,3'
1463
+ */
1464
+ function toString(value) {
1465
+ return value == null ? '' : baseToString(value);
1466
+ }
1467
+
1468
+ /** Built-in value references. */
1469
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
1470
+
1471
+ const getPrototype$1 = getPrototype;
1472
+
1473
+ /** `Object#toString` result references. */
1474
+ var objectTag = '[object Object]';
1475
+
1476
+ /** Used for built-in method references. */
1477
+ var funcProto = Function.prototype,
1478
+ objectProto$2 = Object.prototype;
1479
+
1480
+ /** Used to resolve the decompiled source of functions. */
1481
+ var funcToString = funcProto.toString;
1482
+
1483
+ /** Used to check objects for own properties. */
1484
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
1485
+
1486
+ /** Used to infer the `Object` constructor. */
1487
+ var objectCtorString = funcToString.call(Object);
1488
+
1489
+ /**
1490
+ * Checks if `value` is a plain object, that is, an object created by the
1491
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
1492
+ *
1493
+ * @static
1494
+ * @memberOf _
1495
+ * @since 0.8.0
1496
+ * @category Lang
1497
+ * @param {*} value The value to check.
1498
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1499
+ * @example
1500
+ *
1501
+ * function Foo() {
1502
+ * this.a = 1;
1503
+ * }
1504
+ *
1505
+ * _.isPlainObject(new Foo);
1506
+ * // => false
1507
+ *
1508
+ * _.isPlainObject([1, 2, 3]);
1509
+ * // => false
1510
+ *
1511
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
1512
+ * // => true
1513
+ *
1514
+ * _.isPlainObject(Object.create(null));
1515
+ * // => true
1516
+ */
1517
+ function isPlainObject(value) {
1518
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
1519
+ return false;
1520
+ }
1521
+ var proto = getPrototype$1(value);
1522
+ if (proto === null) {
1523
+ return true;
1524
+ }
1525
+ var Ctor = hasOwnProperty$2.call(proto, 'constructor') && proto.constructor;
1526
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
1527
+ funcToString.call(Ctor) == objectCtorString;
1528
+ }
1529
+
1530
+ /** `Object#toString` result references. */
1531
+ var domExcTag = '[object DOMException]',
1532
+ errorTag = '[object Error]';
1533
+
1534
+ /**
1535
+ * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
1536
+ * `SyntaxError`, `TypeError`, or `URIError` object.
1537
+ *
1538
+ * @static
1539
+ * @memberOf _
1540
+ * @since 3.0.0
1541
+ * @category Lang
1542
+ * @param {*} value The value to check.
1543
+ * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
1544
+ * @example
1545
+ *
1546
+ * _.isError(new Error);
1547
+ * // => true
1548
+ *
1549
+ * _.isError(Error);
1550
+ * // => false
1551
+ */
1552
+ function isError(value) {
1553
+ if (!isObjectLike(value)) {
1554
+ return false;
1555
+ }
1556
+ var tag = baseGetTag(value);
1557
+ return tag == errorTag || tag == domExcTag ||
1558
+ (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
1559
+ }
1560
+
1561
+ /**
1562
+ * Attempts to invoke `func`, returning either the result or the caught error
1563
+ * object. Any additional arguments are provided to `func` when it's invoked.
1564
+ *
1565
+ * @static
1566
+ * @memberOf _
1567
+ * @since 3.0.0
1568
+ * @category Util
1569
+ * @param {Function} func The function to attempt.
1570
+ * @param {...*} [args] The arguments to invoke `func` with.
1571
+ * @returns {*} Returns the `func` result or error object.
1572
+ * @example
1573
+ *
1574
+ * // Avoid throwing errors for invalid selectors.
1575
+ * var elements = _.attempt(function(selector) {
1576
+ * return document.querySelectorAll(selector);
1577
+ * }, '>_>');
1578
+ *
1579
+ * if (_.isError(elements)) {
1580
+ * elements = [];
1581
+ * }
1582
+ */
1583
+ var attempt = baseRest(function(func, args) {
1584
+ try {
1585
+ return apply(func, undefined, args);
1586
+ } catch (e) {
1587
+ return isError(e) ? e : new Error(e);
1588
+ }
1589
+ });
1590
+
1591
+ const attempt$1 = attempt;
1592
+
1593
+ /**
1594
+ * The base implementation of `_.propertyOf` without support for deep paths.
1595
+ *
1596
+ * @private
1597
+ * @param {Object} object The object to query.
1598
+ * @returns {Function} Returns the new accessor function.
1599
+ */
1600
+ function basePropertyOf(object) {
1601
+ return function(key) {
1602
+ return object == null ? undefined : object[key];
1603
+ };
1604
+ }
1605
+
1606
+ /** Used to map characters to HTML entities. */
1607
+ var htmlEscapes = {
1608
+ '&': '&amp;',
1609
+ '<': '&lt;',
1610
+ '>': '&gt;',
1611
+ '"': '&quot;',
1612
+ "'": '&#39;'
1613
+ };
1614
+
1615
+ /**
1616
+ * Used by `_.escape` to convert characters to HTML entities.
1617
+ *
1618
+ * @private
1619
+ * @param {string} chr The matched character to escape.
1620
+ * @returns {string} Returns the escaped character.
1621
+ */
1622
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
1623
+
1624
+ const escapeHtmlChar$1 = escapeHtmlChar;
1625
+
1626
+ /** Used to match HTML entities and HTML characters. */
1627
+ var reUnescapedHtml = /[&<>"']/g,
1628
+ reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
1629
+
1630
+ /**
1631
+ * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
1632
+ * corresponding HTML entities.
1633
+ *
1634
+ * **Note:** No other characters are escaped. To escape additional
1635
+ * characters use a third-party library like [_he_](https://mths.be/he).
1636
+ *
1637
+ * Though the ">" character is escaped for symmetry, characters like
1638
+ * ">" and "/" don't need escaping in HTML and have no special meaning
1639
+ * unless they're part of a tag or unquoted attribute value. See
1640
+ * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
1641
+ * (under "semi-related fun fact") for more details.
1642
+ *
1643
+ * When working with HTML you should always
1644
+ * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
1645
+ * XSS vectors.
1646
+ *
1647
+ * @static
1648
+ * @since 0.1.0
1649
+ * @memberOf _
1650
+ * @category String
1651
+ * @param {string} [string=''] The string to escape.
1652
+ * @returns {string} Returns the escaped string.
1653
+ * @example
1654
+ *
1655
+ * _.escape('fred, barney, & pebbles');
1656
+ * // => 'fred, barney, &amp; pebbles'
1657
+ */
1658
+ function escape(string) {
1659
+ string = toString(string);
1660
+ return (string && reHasUnescapedHtml.test(string))
1661
+ ? string.replace(reUnescapedHtml, escapeHtmlChar$1)
1662
+ : string;
1663
+ }
1664
+
1665
+ /**
1666
+ * The base implementation of `_.values` and `_.valuesIn` which creates an
1667
+ * array of `object` property values corresponding to the property names
1668
+ * of `props`.
1669
+ *
1670
+ * @private
1671
+ * @param {Object} object The object to query.
1672
+ * @param {Array} props The property names to get values for.
1673
+ * @returns {Object} Returns the array of property values.
1674
+ */
1675
+ function baseValues(object, props) {
1676
+ return arrayMap(props, function(key) {
1677
+ return object[key];
1678
+ });
1679
+ }
1680
+
1681
+ /** Used for built-in method references. */
1682
+ var objectProto$1 = Object.prototype;
1683
+
1684
+ /** Used to check objects for own properties. */
1685
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1686
+
1687
+ /**
1688
+ * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
1689
+ * of source objects to the destination object for all destination properties
1690
+ * that resolve to `undefined`.
1691
+ *
1692
+ * @private
1693
+ * @param {*} objValue The destination value.
1694
+ * @param {*} srcValue The source value.
1695
+ * @param {string} key The key of the property to assign.
1696
+ * @param {Object} object The parent object of `objValue`.
1697
+ * @returns {*} Returns the value to assign.
1698
+ */
1699
+ function customDefaultsAssignIn(objValue, srcValue, key, object) {
1700
+ if (objValue === undefined ||
1701
+ (eq(objValue, objectProto$1[key]) && !hasOwnProperty$1.call(object, key))) {
1702
+ return srcValue;
1703
+ }
1704
+ return objValue;
1705
+ }
1706
+
1707
+ /** Used to escape characters for inclusion in compiled string literals. */
1708
+ var stringEscapes = {
1709
+ '\\': '\\',
1710
+ "'": "'",
1711
+ '\n': 'n',
1712
+ '\r': 'r',
1713
+ '\u2028': 'u2028',
1714
+ '\u2029': 'u2029'
1715
+ };
1716
+
1717
+ /**
1718
+ * Used by `_.template` to escape characters for inclusion in compiled string literals.
1719
+ *
1720
+ * @private
1721
+ * @param {string} chr The matched character to escape.
1722
+ * @returns {string} Returns the escaped character.
1723
+ */
1724
+ function escapeStringChar(chr) {
1725
+ return '\\' + stringEscapes[chr];
1726
+ }
1727
+
1728
+ /** Used to match template delimiters. */
1729
+ var reInterpolate = /<%=([\s\S]+?)%>/g;
1730
+
1731
+ const reInterpolate$1 = reInterpolate;
1732
+
1733
+ /** Used to match template delimiters. */
1734
+ var reEscape = /<%-([\s\S]+?)%>/g;
1735
+
1736
+ const reEscape$1 = reEscape;
1737
+
1738
+ /** Used to match template delimiters. */
1739
+ var reEvaluate = /<%([\s\S]+?)%>/g;
1740
+
1741
+ const reEvaluate$1 = reEvaluate;
1742
+
1743
+ /**
1744
+ * By default, the template delimiters used by lodash are like those in
1745
+ * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1746
+ * following template settings to use alternative delimiters.
1747
+ *
1748
+ * @static
1749
+ * @memberOf _
1750
+ * @type {Object}
1751
+ */
1752
+ var templateSettings = {
1753
+
1754
+ /**
1755
+ * Used to detect `data` property values to be HTML-escaped.
1756
+ *
1757
+ * @memberOf _.templateSettings
1758
+ * @type {RegExp}
1759
+ */
1760
+ 'escape': reEscape$1,
1761
+
1762
+ /**
1763
+ * Used to detect code to be evaluated.
1764
+ *
1765
+ * @memberOf _.templateSettings
1766
+ * @type {RegExp}
1767
+ */
1768
+ 'evaluate': reEvaluate$1,
1769
+
1770
+ /**
1771
+ * Used to detect `data` property values to inject.
1772
+ *
1773
+ * @memberOf _.templateSettings
1774
+ * @type {RegExp}
1775
+ */
1776
+ 'interpolate': reInterpolate$1,
1777
+
1778
+ /**
1779
+ * Used to reference the data object in the template text.
1780
+ *
1781
+ * @memberOf _.templateSettings
1782
+ * @type {string}
1783
+ */
1784
+ 'variable': '',
1785
+
1786
+ /**
1787
+ * Used to import variables into the compiled template.
1788
+ *
1789
+ * @memberOf _.templateSettings
1790
+ * @type {Object}
1791
+ */
1792
+ 'imports': {
1793
+
1794
+ /**
1795
+ * A reference to the `lodash` function.
1796
+ *
1797
+ * @memberOf _.templateSettings.imports
1798
+ * @type {Function}
1799
+ */
1800
+ '_': { 'escape': escape }
1801
+ }
1802
+ };
1803
+
1804
+ const templateSettings$1 = templateSettings;
1805
+
1806
+ /** Error message constants. */
1807
+ var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
1808
+
1809
+ /** Used to match empty string literals in compiled template source. */
1810
+ var reEmptyStringLeading = /\b__p \+= '';/g,
1811
+ reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
1812
+ reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
1813
+
1814
+ /**
1815
+ * Used to validate the `validate` option in `_.template` variable.
1816
+ *
1817
+ * Forbids characters which could potentially change the meaning of the function argument definition:
1818
+ * - "()," (modification of function parameters)
1819
+ * - "=" (default value)
1820
+ * - "[]{}" (destructuring of function parameters)
1821
+ * - "/" (beginning of a comment)
1822
+ * - whitespace
1823
+ */
1824
+ var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
1825
+
1826
+ /**
1827
+ * Used to match
1828
+ * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
1829
+ */
1830
+ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
1831
+
1832
+ /** Used to ensure capturing order of template delimiters. */
1833
+ var reNoMatch = /($^)/;
1834
+
1835
+ /** Used to match unescaped characters in compiled string literals. */
1836
+ var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
1837
+
1838
+ /** Used for built-in method references. */
1839
+ var objectProto = Object.prototype;
1840
+
1841
+ /** Used to check objects for own properties. */
1842
+ var hasOwnProperty = objectProto.hasOwnProperty;
1843
+
1844
+ /**
1845
+ * Creates a compiled template function that can interpolate data properties
1846
+ * in "interpolate" delimiters, HTML-escape interpolated data properties in
1847
+ * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
1848
+ * properties may be accessed as free variables in the template. If a setting
1849
+ * object is given, it takes precedence over `_.templateSettings` values.
1850
+ *
1851
+ * **Note:** In the development build `_.template` utilizes
1852
+ * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
1853
+ * for easier debugging.
1854
+ *
1855
+ * For more information on precompiling templates see
1856
+ * [lodash's custom builds documentation](https://lodash.com/custom-builds).
1857
+ *
1858
+ * For more information on Chrome extension sandboxes see
1859
+ * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
1860
+ *
1861
+ * @static
1862
+ * @since 0.1.0
1863
+ * @memberOf _
1864
+ * @category String
1865
+ * @param {string} [string=''] The template string.
1866
+ * @param {Object} [options={}] The options object.
1867
+ * @param {RegExp} [options.escape=_.templateSettings.escape]
1868
+ * The HTML "escape" delimiter.
1869
+ * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
1870
+ * The "evaluate" delimiter.
1871
+ * @param {Object} [options.imports=_.templateSettings.imports]
1872
+ * An object to import into the template as free variables.
1873
+ * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
1874
+ * The "interpolate" delimiter.
1875
+ * @param {string} [options.sourceURL='templateSources[n]']
1876
+ * The sourceURL of the compiled template.
1877
+ * @param {string} [options.variable='obj']
1878
+ * The data object variable name.
1879
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1880
+ * @returns {Function} Returns the compiled template function.
1881
+ * @example
1882
+ *
1883
+ * // Use the "interpolate" delimiter to create a compiled template.
1884
+ * var compiled = _.template('hello <%= user %>!');
1885
+ * compiled({ 'user': 'fred' });
1886
+ * // => 'hello fred!'
1887
+ *
1888
+ * // Use the HTML "escape" delimiter to escape data property values.
1889
+ * var compiled = _.template('<b><%- value %></b>');
1890
+ * compiled({ 'value': '<script>' });
1891
+ * // => '<b>&lt;script&gt;</b>'
1892
+ *
1893
+ * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
1894
+ * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
1895
+ * compiled({ 'users': ['fred', 'barney'] });
1896
+ * // => '<li>fred</li><li>barney</li>'
1897
+ *
1898
+ * // Use the internal `print` function in "evaluate" delimiters.
1899
+ * var compiled = _.template('<% print("hello " + user); %>!');
1900
+ * compiled({ 'user': 'barney' });
1901
+ * // => 'hello barney!'
1902
+ *
1903
+ * // Use the ES template literal delimiter as an "interpolate" delimiter.
1904
+ * // Disable support by replacing the "interpolate" delimiter.
1905
+ * var compiled = _.template('hello ${ user }!');
1906
+ * compiled({ 'user': 'pebbles' });
1907
+ * // => 'hello pebbles!'
1908
+ *
1909
+ * // Use backslashes to treat delimiters as plain text.
1910
+ * var compiled = _.template('<%= "\\<%- value %\\>" %>');
1911
+ * compiled({ 'value': 'ignored' });
1912
+ * // => '<%- value %>'
1913
+ *
1914
+ * // Use the `imports` option to import `jQuery` as `jq`.
1915
+ * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
1916
+ * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
1917
+ * compiled({ 'users': ['fred', 'barney'] });
1918
+ * // => '<li>fred</li><li>barney</li>'
1919
+ *
1920
+ * // Use the `sourceURL` option to specify a custom sourceURL for the template.
1921
+ * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
1922
+ * compiled(data);
1923
+ * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
1924
+ *
1925
+ * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
1926
+ * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
1927
+ * compiled.source;
1928
+ * // => function(data) {
1929
+ * // var __t, __p = '';
1930
+ * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
1931
+ * // return __p;
1932
+ * // }
1933
+ *
1934
+ * // Use custom template delimiters.
1935
+ * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
1936
+ * var compiled = _.template('hello {{ user }}!');
1937
+ * compiled({ 'user': 'mustache' });
1938
+ * // => 'hello mustache!'
1939
+ *
1940
+ * // Use the `source` property to inline compiled templates for meaningful
1941
+ * // line numbers in error messages and stack traces.
1942
+ * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
1943
+ * var JST = {\
1944
+ * "main": ' + _.template(mainText).source + '\
1945
+ * };\
1946
+ * ');
1947
+ */
1948
+ function template(string, options, guard) {
1949
+ // Based on John Resig's `tmpl` implementation
1950
+ // (http://ejohn.org/blog/javascript-micro-templating/)
1951
+ // and Laura Doktorova's doT.js (https://github.com/olado/doT).
1952
+ var settings = templateSettings$1.imports._.templateSettings || templateSettings$1;
1953
+
1954
+ if (guard && isIterateeCall(string, options, guard)) {
1955
+ options = undefined;
1956
+ }
1957
+ string = toString(string);
1958
+ options = extendWith({}, options, settings, customDefaultsAssignIn);
1959
+
1960
+ var imports = extendWith({}, options.imports, settings.imports, customDefaultsAssignIn),
1961
+ importsKeys = keys(imports),
1962
+ importsValues = baseValues(imports, importsKeys);
1963
+
1964
+ var isEscaping,
1965
+ isEvaluating,
1966
+ index = 0,
1967
+ interpolate = options.interpolate || reNoMatch,
1968
+ source = "__p += '";
1969
+
1970
+ // Compile the regexp to match each delimiter.
1971
+ var reDelimiters = RegExp(
1972
+ (options.escape || reNoMatch).source + '|' +
1973
+ interpolate.source + '|' +
1974
+ (interpolate === reInterpolate$1 ? reEsTemplate : reNoMatch).source + '|' +
1975
+ (options.evaluate || reNoMatch).source + '|$'
1976
+ , 'g');
1977
+
1978
+ // Use a sourceURL for easier debugging.
1979
+ // The sourceURL gets injected into the source that's eval-ed, so be careful
1980
+ // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
1981
+ // and escape the comment, thus injecting code that gets evaled.
1982
+ var sourceURL = hasOwnProperty.call(options, 'sourceURL')
1983
+ ? ('//# sourceURL=' +
1984
+ (options.sourceURL + '').replace(/\s/g, ' ') +
1985
+ '\n')
1986
+ : '';
1987
+
1988
+ string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
1989
+ interpolateValue || (interpolateValue = esTemplateValue);
1990
+
1991
+ // Escape characters that can't be included in string literals.
1992
+ source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
1993
+
1994
+ // Replace delimiters with snippets.
1995
+ if (escapeValue) {
1996
+ isEscaping = true;
1997
+ source += "' +\n__e(" + escapeValue + ") +\n'";
1998
+ }
1999
+ if (evaluateValue) {
2000
+ isEvaluating = true;
2001
+ source += "';\n" + evaluateValue + ";\n__p += '";
2002
+ }
2003
+ if (interpolateValue) {
2004
+ source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
2005
+ }
2006
+ index = offset + match.length;
2007
+
2008
+ // The JS engine embedded in Adobe products needs `match` returned in
2009
+ // order to produce the correct `offset` value.
2010
+ return match;
2011
+ });
2012
+
2013
+ source += "';\n";
2014
+
2015
+ // If `variable` is not specified wrap a with-statement around the generated
2016
+ // code to add the data object to the top of the scope chain.
2017
+ var variable = hasOwnProperty.call(options, 'variable') && options.variable;
2018
+ if (!variable) {
2019
+ source = 'with (obj) {\n' + source + '\n}\n';
2020
+ }
2021
+ // Throw an error if a forbidden character was found in `variable`, to prevent
2022
+ // potential command injection attacks.
2023
+ else if (reForbiddenIdentifierChars.test(variable)) {
2024
+ throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
2025
+ }
2026
+
2027
+ // Cleanup code by stripping empty strings.
2028
+ source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
2029
+ .replace(reEmptyStringMiddle, '$1')
2030
+ .replace(reEmptyStringTrailing, '$1;');
2031
+
2032
+ // Frame code as the function body.
2033
+ source = 'function(' + (variable || 'obj') + ') {\n' +
2034
+ (variable
2035
+ ? ''
2036
+ : 'obj || (obj = {});\n'
2037
+ ) +
2038
+ "var __t, __p = ''" +
2039
+ (isEscaping
2040
+ ? ', __e = _.escape'
2041
+ : ''
2042
+ ) +
2043
+ (isEvaluating
2044
+ ? ', __j = Array.prototype.join;\n' +
2045
+ "function print() { __p += __j.call(arguments, '') }\n"
2046
+ : ';\n'
2047
+ ) +
2048
+ source +
2049
+ 'return __p\n}';
2050
+
2051
+ var result = attempt$1(function() {
2052
+ return Function(importsKeys, sourceURL + 'return ' + source)
2053
+ .apply(undefined, importsValues);
2054
+ });
2055
+
2056
+ // Provide the compiled function's source by its `toString` method or
2057
+ // the `source` property as a convenience for inlining compiled templates.
2058
+ result.source = source;
2059
+ if (isError(result)) {
2060
+ throw result;
2061
+ }
2062
+ return result;
2063
+ }
2064
+
2065
+ async function compileTemplate(template$1, ctx) {
2066
+ const data = { ...ctx, options: template$1.options };
2067
+ if (template$1.src) {
2068
+ try {
2069
+ const srcContents = await promises.readFile(template$1.src, "utf-8");
2070
+ return template(srcContents, {})(data);
102
2071
  } catch (err) {
103
- console.error("Error compiling template: ", template);
2072
+ console.error("Error compiling template: ", template$1);
104
2073
  throw err;
105
2074
  }
106
2075
  }
107
- if (template.getContents) {
108
- return template.getContents(data);
2076
+ if (template$1.getContents) {
2077
+ return template$1.getContents(data);
109
2078
  }
110
- throw new Error("Invalid template: " + JSON.stringify(template));
2079
+ throw new Error("Invalid template: " + JSON.stringify(template$1));
111
2080
  }
112
2081
  const serialize = (data) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, (r) => JSON.parse(r).replace(/^{(.*)}$/, "$1"));
113
2082
  const importSources = (sources, { lazy = false } = {}) => {
@@ -125,18 +2094,19 @@ const importName = genSafeVariableName;
125
2094
  const templateUtils = { serialize, importName, importSources };
126
2095
 
127
2096
  function defineNuxtModule(definition) {
128
- if (!definition.meta) {
129
- definition.meta = {};
2097
+ if (typeof definition === "function") {
2098
+ return defineNuxtModule({ setup: definition });
130
2099
  }
131
- if (definition.meta.configKey === void 0) {
132
- definition.meta.configKey = definition.meta.name;
2100
+ const module = defu(definition, { meta: {} });
2101
+ if (module.meta.configKey === void 0) {
2102
+ module.meta.configKey = module.meta.name;
133
2103
  }
134
2104
  async function getOptions(inlineOptions, nuxt = useNuxt()) {
135
- const configKey = definition.meta.configKey || definition.meta.name;
136
- const _defaults = definition.defaults instanceof Function ? definition.defaults(nuxt) : definition.defaults;
2105
+ const configKey = module.meta.configKey || module.meta.name;
2106
+ const _defaults = module.defaults instanceof Function ? module.defaults(nuxt) : module.defaults;
137
2107
  let _options = defu(inlineOptions, nuxt.options[configKey], _defaults);
138
- if (definition.schema) {
139
- _options = await applyDefaults(definition.schema, _options);
2108
+ if (module.schema) {
2109
+ _options = await applyDefaults(module.schema, _options);
140
2110
  }
141
2111
  return Promise.resolve(_options);
142
2112
  }
@@ -144,7 +2114,7 @@ function defineNuxtModule(definition) {
144
2114
  if (!nuxt) {
145
2115
  nuxt = tryUseNuxt() || this.nuxt;
146
2116
  }
147
- const uniqueKey = definition.meta.name || definition.meta.configKey;
2117
+ const uniqueKey = module.meta.name || module.meta.configKey;
148
2118
  if (uniqueKey) {
149
2119
  nuxt.options._requiredModules = nuxt.options._requiredModules || {};
150
2120
  if (nuxt.options._requiredModules[uniqueKey]) {
@@ -152,22 +2122,22 @@ function defineNuxtModule(definition) {
152
2122
  }
153
2123
  nuxt.options._requiredModules[uniqueKey] = true;
154
2124
  }
155
- if (definition.meta.compatibility) {
156
- const issues = await checkNuxtCompatibility(definition.meta.compatibility, nuxt);
2125
+ if (module.meta.compatibility) {
2126
+ const issues = await checkNuxtCompatibility(module.meta.compatibility, nuxt);
157
2127
  if (issues.length) {
158
- logger.warn(`Module \`${definition.meta.name}\` is disabled due to incompatibility issues:
2128
+ logger.warn(`Module \`${module.meta.name}\` is disabled due to incompatibility issues:
159
2129
  ${issues.toString()}`);
160
2130
  return;
161
2131
  }
162
2132
  }
163
2133
  nuxt2Shims(nuxt);
164
2134
  const _options = await getOptions(inlineOptions, nuxt);
165
- if (definition.hooks) {
166
- nuxt.hooks.addHooks(definition.hooks);
2135
+ if (module.hooks) {
2136
+ nuxt.hooks.addHooks(module.hooks);
167
2137
  }
168
2138
  const key = `nuxt:module:${uniqueKey || Math.round(Math.random() * 1e4)}`;
169
2139
  const mark = performance.mark(key);
170
- const res = await definition.setup?.call(null, _options, nuxt) ?? {};
2140
+ const res = await module.setup?.call(null, _options, nuxt) ?? {};
171
2141
  const perf = performance.measure(key, mark?.name);
172
2142
  const setupTime = perf ? Math.round(perf.duration * 100) / 100 : 0;
173
2143
  if (setupTime > 5e3) {
@@ -184,7 +2154,7 @@ ${issues.toString()}`);
184
2154
  }
185
2155
  });
186
2156
  }
187
- normalizedModule.getMeta = () => Promise.resolve(definition.meta);
2157
+ normalizedModule.getMeta = () => Promise.resolve(module.meta);
188
2158
  normalizedModule.getOptions = getOptions;
189
2159
  return normalizedModule;
190
2160
  }
@@ -434,9 +2404,8 @@ async function resolveFiles(path, pattern, opts = {}) {
434
2404
  return files.map((p) => resolve(path, p)).filter((p) => !isIgnored(p)).sort();
435
2405
  }
436
2406
 
437
- async function installModule(moduleToInstall, _inlineOptions, _nuxt) {
438
- const nuxt = useNuxt();
439
- const { nuxtModule, inlineOptions } = await normalizeModule(moduleToInstall, _inlineOptions);
2407
+ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2408
+ const { nuxtModule, buildTimeModuleMeta } = await loadNuxtModuleInstance(moduleToInstall, nuxt);
440
2409
  const res = (isNuxt2() ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : await nuxtModule(inlineOptions, nuxt)) ?? {};
441
2410
  if (res === false) {
442
2411
  return;
@@ -446,7 +2415,7 @@ async function installModule(moduleToInstall, _inlineOptions, _nuxt) {
446
2415
  }
447
2416
  nuxt.options._installedModules = nuxt.options._installedModules || [];
448
2417
  nuxt.options._installedModules.push({
449
- meta: await nuxtModule.getMeta?.(),
2418
+ meta: defu(await nuxtModule.getMeta?.(), buildTimeModuleMeta),
450
2419
  timings: res.timings,
451
2420
  entryPath: typeof moduleToInstall === "string" ? resolveAlias(moduleToInstall) : void 0
452
2421
  });
@@ -458,8 +2427,8 @@ const normalizeModuleTranspilePath = (p) => {
458
2427
  }
459
2428
  return p.split("node_modules/").pop();
460
2429
  };
461
- async function normalizeModule(nuxtModule, inlineOptions) {
462
- const nuxt = useNuxt();
2430
+ async function loadNuxtModuleInstance(nuxtModule, nuxt = useNuxt()) {
2431
+ let buildTimeModuleMeta = {};
463
2432
  if (typeof nuxtModule === "string") {
464
2433
  const src = await resolvePath(nuxtModule);
465
2434
  try {
@@ -468,11 +2437,45 @@ async function normalizeModule(nuxtModule, inlineOptions) {
468
2437
  console.error(`Error while requiring module \`${nuxtModule}\`: ${error}`);
469
2438
  throw error;
470
2439
  }
2440
+ if (existsSync(join(dirname(src), "module.json"))) {
2441
+ buildTimeModuleMeta = JSON.parse(await promises.readFile(join(dirname(src), "module.json"), "utf-8"));
2442
+ }
471
2443
  }
472
2444
  if (typeof nuxtModule !== "function") {
473
2445
  throw new TypeError("Nuxt module should be a function: " + nuxtModule);
474
2446
  }
475
- return { nuxtModule, inlineOptions };
2447
+ return { nuxtModule, buildTimeModuleMeta };
2448
+ }
2449
+
2450
+ function hasNuxtModule(moduleName, nuxt = useNuxt()) {
2451
+ return nuxt.options._installedModules.some(({ meta }) => meta.name === moduleName) || nuxt.options.modules.includes(moduleName);
2452
+ }
2453
+ async function hasNuxtModuleCompatibility(module, semverVersion, nuxt = useNuxt()) {
2454
+ const version = await getNuxtModuleVersion(module, nuxt);
2455
+ if (!version) {
2456
+ return false;
2457
+ }
2458
+ return satisfies(normalizeSemanticVersion(version), semverVersion, {
2459
+ includePrerelease: true
2460
+ });
2461
+ }
2462
+ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
2463
+ const moduleMeta = (typeof module === "string" ? { name: module } : await module.getMeta?.()) || {};
2464
+ if (moduleMeta.version) {
2465
+ return moduleMeta.version;
2466
+ }
2467
+ if (!moduleMeta.name) {
2468
+ return false;
2469
+ }
2470
+ const version = nuxt.options._installedModules.filter((m) => m.meta.name === moduleMeta.name).map((m) => m.meta.version)?.[0];
2471
+ if (version) {
2472
+ return version;
2473
+ }
2474
+ if (typeof module !== "string" && nuxt.options.modules.includes(moduleMeta.name)) {
2475
+ const { buildTimeModuleMeta } = await loadNuxtModuleInstance(moduleMeta.name, nuxt);
2476
+ return buildTimeModuleMeta.version || false;
2477
+ }
2478
+ return false;
476
2479
  }
477
2480
 
478
2481
  async function loadNuxtConfig(opts) {
@@ -705,6 +2708,17 @@ function addTemplate(_template) {
705
2708
  nuxt.options.build.templates.push(template);
706
2709
  return template;
707
2710
  }
2711
+ function addTypeTemplate(_template) {
2712
+ const nuxt = useNuxt();
2713
+ const template = addTemplate(_template);
2714
+ if (!template.filename.endsWith(".d.ts")) {
2715
+ throw new Error(`Invalid type template. Filename must end with .d.ts : "${template.filename}"`);
2716
+ }
2717
+ nuxt.hook("prepare:types", ({ references }) => {
2718
+ references.push({ path: template.dst });
2719
+ });
2720
+ return template;
2721
+ }
708
2722
  function normalizeTemplate(template) {
709
2723
  if (!template) {
710
2724
  throw new Error("Invalid template: " + JSON.stringify(template));
@@ -886,4 +2900,4 @@ function useNitro() {
886
2900
  return nuxt._nitro;
887
2901
  }
888
2902
 
889
- export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtVersion, hasNuxtCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };
2903
+ export { addBuildPlugin, addComponent, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addServerHandler, addServerPlugin, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createResolver, defineNuxtModule, extendNuxtSchema, extendPages, extendRouteRules, extendViteConfig, extendWebpackConfig, findPath, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule$1 as importModule, installModule, isIgnored, isNuxt2, isNuxt3, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveModule, resolvePath, templateUtils, tryImportModule$1 as tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateTemplates, useLogger, useNitro, useNuxt };