webgal-parser 4.3.13-1 → 4.3.13-3

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,1706 @@
1
+ var commandType;
2
+ (function (commandType) {
3
+ commandType[commandType["say"] = 0] = "say";
4
+ commandType[commandType["changeBg"] = 1] = "changeBg";
5
+ commandType[commandType["changeFigure"] = 2] = "changeFigure";
6
+ commandType[commandType["bgm"] = 3] = "bgm";
7
+ commandType[commandType["video"] = 4] = "video";
8
+ commandType[commandType["pixi"] = 5] = "pixi";
9
+ commandType[commandType["pixiInit"] = 6] = "pixiInit";
10
+ commandType[commandType["intro"] = 7] = "intro";
11
+ commandType[commandType["miniAvatar"] = 8] = "miniAvatar";
12
+ commandType[commandType["changeScene"] = 9] = "changeScene";
13
+ commandType[commandType["choose"] = 10] = "choose";
14
+ commandType[commandType["end"] = 11] = "end";
15
+ commandType[commandType["setComplexAnimation"] = 12] = "setComplexAnimation";
16
+ commandType[commandType["setFilter"] = 13] = "setFilter";
17
+ commandType[commandType["label"] = 14] = "label";
18
+ commandType[commandType["jumpLabel"] = 15] = "jumpLabel";
19
+ commandType[commandType["chooseLabel"] = 16] = "chooseLabel";
20
+ commandType[commandType["setVar"] = 17] = "setVar";
21
+ commandType[commandType["if"] = 18] = "if";
22
+ commandType[commandType["callScene"] = 19] = "callScene";
23
+ commandType[commandType["showVars"] = 20] = "showVars";
24
+ commandType[commandType["unlockCg"] = 21] = "unlockCg";
25
+ commandType[commandType["unlockBgm"] = 22] = "unlockBgm";
26
+ commandType[commandType["filmMode"] = 23] = "filmMode";
27
+ commandType[commandType["setTextbox"] = 24] = "setTextbox";
28
+ commandType[commandType["setAnimation"] = 25] = "setAnimation";
29
+ commandType[commandType["playEffect"] = 26] = "playEffect";
30
+ commandType[commandType["setTempAnimation"] = 27] = "setTempAnimation";
31
+ commandType[commandType["comment"] = 28] = "comment";
32
+ })(commandType || (commandType = {}));
33
+
34
+ /**
35
+ * 处理命令
36
+ * @param commandRaw
37
+ * @param ADD_NEXT_ARG_LIST
38
+ * @param SCRIPT_CONFIG
39
+ * @return {parsedCommand} 处理后的命令
40
+ */
41
+ const commandParser = (commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) => {
42
+ let returnCommand = {
43
+ type: commandType.say,
44
+ additionalArgs: []
45
+ };
46
+ // 开始处理命令内容
47
+ const type = getCommandType(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
48
+ returnCommand.type = type;
49
+ // 如果是对话,加上额外的参数
50
+ if (type === commandType.say) {
51
+ returnCommand.additionalArgs.push({
52
+ key: "speaker",
53
+ value: commandRaw
54
+ });
55
+ }
56
+ returnCommand = addNextArg(returnCommand, type, ADD_NEXT_ARG_LIST);
57
+ return returnCommand;
58
+ };
59
+ /**
60
+ * 根据command原始值判断是什么命令
61
+ * @param command command原始值
62
+ * @param ADD_NEXT_ARG_LIST
63
+ * @param SCRIPT_CONFIG
64
+ * @return {commandType} 得到的command类型
65
+ */
66
+ function getCommandType(command, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
67
+ // if (command.match(/if/)) {
68
+ // return commandType.if;
69
+ // }
70
+ const commandMap = new Map();
71
+ SCRIPT_CONFIG.forEach((e) => {
72
+ commandMap.set(e.scriptString, e.scriptType);
73
+ });
74
+ if (commandMap.has(command)) {
75
+ return commandMap.get(command);
76
+ }
77
+ else
78
+ return commandType.say;
79
+ }
80
+ function addNextArg(commandToParse, thisCommandType, ADD_NEXT_ARG_LIST) {
81
+ if (ADD_NEXT_ARG_LIST.includes(thisCommandType)) {
82
+ commandToParse.additionalArgs.push({
83
+ key: "next",
84
+ value: true
85
+ });
86
+ }
87
+ return commandToParse;
88
+ }
89
+
90
+ /**
91
+ * 内置资源类型的枚举
92
+ */
93
+ var fileType;
94
+ (function (fileType) {
95
+ fileType[fileType["background"] = 0] = "background";
96
+ fileType[fileType["bgm"] = 1] = "bgm";
97
+ fileType[fileType["figure"] = 2] = "figure";
98
+ fileType[fileType["scene"] = 3] = "scene";
99
+ fileType[fileType["tex"] = 4] = "tex";
100
+ fileType[fileType["vocal"] = 5] = "vocal";
101
+ fileType[fileType["video"] = 6] = "video";
102
+ })(fileType || (fileType = {}));
103
+
104
+ /**
105
+ * 参数解析器
106
+ * @param argsRaw 原始参数字符串
107
+ * @param assetSetter
108
+ * @return {Array<arg>} 解析后的参数列表
109
+ */
110
+ function argsParser(argsRaw, assetSetter) {
111
+ const returnArrayList = [];
112
+ // 处理参数
113
+ // 不要去空格
114
+ let newArgsRaw = argsRaw.replace(/ /g, " ");
115
+ // 分割参数列表
116
+ let rawArgsList = newArgsRaw.split(" -");
117
+ // 去除空字符串
118
+ rawArgsList = rawArgsList.filter((e) => {
119
+ return e !== "";
120
+ });
121
+ rawArgsList.forEach((e) => {
122
+ const argName = e.split("=")[0];
123
+ const argValue = e.split("=")[1];
124
+ // 判断是不是语音参数
125
+ if (e.match(/.ogg|.mp3|.wav/)) {
126
+ returnArrayList.push({
127
+ key: "vocal",
128
+ value: assetSetter(e, fileType.vocal)
129
+ });
130
+ }
131
+ else {
132
+ // 判断是不是省略参数
133
+ if (argValue === undefined) {
134
+ returnArrayList.push({
135
+ key: argName,
136
+ value: true
137
+ });
138
+ }
139
+ else {
140
+ // 是字符串描述的布尔值
141
+ if (argValue === "true" || argValue === "false") {
142
+ returnArrayList.push({
143
+ key: argName,
144
+ value: argValue === "true"
145
+ });
146
+ }
147
+ else {
148
+ // 是数字
149
+ if (!isNaN(Number(argValue))) {
150
+ returnArrayList.push({
151
+ key: argName,
152
+ value: Number(argValue)
153
+ });
154
+ }
155
+ else {
156
+ // 是普通参数
157
+ returnArrayList.push({
158
+ key: argName,
159
+ value: argValue
160
+ });
161
+ }
162
+ }
163
+ }
164
+ }
165
+ });
166
+ return returnArrayList;
167
+ }
168
+
169
+ /**
170
+ * 解析语句内容的函数,主要作用是把文件名改为绝对地址或相对地址(根据使用情况而定)
171
+ * @param contentRaw 原始语句内容
172
+ * @param type 语句类型
173
+ * @param assetSetter
174
+ * @return {string} 解析后的语句内容
175
+ */
176
+ const contentParser = (contentRaw, type, assetSetter) => {
177
+ if (contentRaw === "none" || contentRaw === "") {
178
+ return "";
179
+ }
180
+ switch (type) {
181
+ case commandType.playEffect:
182
+ return assetSetter(contentRaw, fileType.vocal);
183
+ case commandType.changeBg:
184
+ return assetSetter(contentRaw, fileType.background);
185
+ case commandType.changeFigure:
186
+ return assetSetter(contentRaw, fileType.figure);
187
+ case commandType.bgm:
188
+ return assetSetter(contentRaw, fileType.bgm);
189
+ case commandType.callScene:
190
+ return assetSetter(contentRaw, fileType.scene);
191
+ case commandType.changeScene:
192
+ return assetSetter(contentRaw, fileType.scene);
193
+ case commandType.miniAvatar:
194
+ return assetSetter(contentRaw, fileType.figure);
195
+ case commandType.video:
196
+ return assetSetter(contentRaw, fileType.video);
197
+ case commandType.choose:
198
+ return getChooseContent(contentRaw, assetSetter);
199
+ case commandType.unlockBgm:
200
+ return assetSetter(contentRaw, fileType.bgm);
201
+ case commandType.unlockCg:
202
+ return assetSetter(contentRaw, fileType.background);
203
+ default:
204
+ return contentRaw;
205
+ }
206
+ };
207
+ function getChooseContent(contentRaw, assetSetter) {
208
+ const chooseList = contentRaw.split("|");
209
+ const chooseKeyList = [];
210
+ const chooseValueList = [];
211
+ for (const e of chooseList) {
212
+ chooseKeyList.push(e.split(":")[0]);
213
+ chooseValueList.push(e.split(":")[1]);
214
+ }
215
+ const parsedChooseList = chooseValueList.map((e) => {
216
+ if (e.match(/\./)) {
217
+ return assetSetter(e, fileType.scene);
218
+ }
219
+ else {
220
+ return e;
221
+ }
222
+ });
223
+ let ret = "";
224
+ for (let i = 0; i < chooseKeyList.length; i++) {
225
+ if (i !== 0) {
226
+ ret = ret + "|";
227
+ }
228
+ ret = ret + `${chooseKeyList[i]}:${parsedChooseList[i]}`;
229
+ }
230
+ return ret;
231
+ }
232
+
233
+ /**
234
+ * 根据语句类型、语句内容、参数列表,扫描该语句可能携带的资源
235
+ * @param command 语句类型
236
+ * @param content 语句内容
237
+ * @param args 参数列表
238
+ * @return {Array<IAsset>} 语句携带的参数列表
239
+ */
240
+ const assetsScanner = (command, content, args) => {
241
+ const returnAssetsList = [];
242
+ if (command === commandType.say) {
243
+ args.forEach((e) => {
244
+ if (e.key === 'vocal') {
245
+ returnAssetsList.push({
246
+ name: e.value,
247
+ url: e.value,
248
+ lineNumber: 0,
249
+ type: fileType.vocal,
250
+ });
251
+ }
252
+ });
253
+ }
254
+ if (content === 'none' || content === '') {
255
+ return returnAssetsList;
256
+ }
257
+ // 处理语句携带的资源
258
+ if (command === commandType.changeBg) {
259
+ returnAssetsList.push({
260
+ name: content,
261
+ url: content,
262
+ lineNumber: 0,
263
+ type: fileType.background,
264
+ });
265
+ }
266
+ if (command === commandType.changeFigure) {
267
+ returnAssetsList.push({
268
+ name: content,
269
+ url: content,
270
+ lineNumber: 0,
271
+ type: fileType.figure,
272
+ });
273
+ }
274
+ if (command === commandType.miniAvatar) {
275
+ returnAssetsList.push({
276
+ name: content,
277
+ url: content,
278
+ lineNumber: 0,
279
+ type: fileType.figure,
280
+ });
281
+ }
282
+ if (command === commandType.video) {
283
+ returnAssetsList.push({
284
+ name: content,
285
+ url: content,
286
+ lineNumber: 0,
287
+ type: fileType.video,
288
+ });
289
+ }
290
+ if (command === commandType.bgm) {
291
+ returnAssetsList.push({
292
+ name: content,
293
+ url: content,
294
+ lineNumber: 0,
295
+ type: fileType.bgm,
296
+ });
297
+ }
298
+ return returnAssetsList;
299
+ };
300
+
301
+ /**
302
+ * 扫描子场景
303
+ * @param content 语句内容
304
+ * @return {Array<string>} 子场景列表
305
+ */
306
+ const subSceneScanner = (command, content) => {
307
+ const subSceneList = [];
308
+ if (command === commandType.changeScene || command === commandType.callScene) {
309
+ subSceneList.push(content);
310
+ }
311
+ if (command === commandType.choose) {
312
+ const chooseList = content.split('|');
313
+ const chooseValue = chooseList.map((e) => e.split(':')[1]);
314
+ chooseValue.forEach((e) => {
315
+ if (e.match(/\./)) {
316
+ subSceneList.push(e);
317
+ }
318
+ });
319
+ }
320
+ return subSceneList;
321
+ };
322
+
323
+ /**
324
+ * 语句解析器
325
+ * @param sentenceRaw 原始语句
326
+ * @param assetSetter
327
+ * @param ADD_NEXT_ARG_LIST
328
+ * @param SCRIPT_CONFIG
329
+ */
330
+ const scriptParser = (sentenceRaw, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) => {
331
+ let command; // 默认为对话
332
+ let content; // 语句内容
333
+ let subScene; // 语句携带的子场景(可能没有)
334
+ const args = []; // 语句参数列表
335
+ let sentenceAssets; // 语句携带的资源列表
336
+ let parsedCommand; // 解析后的命令
337
+ let commandRaw;
338
+ // 正式开始解析
339
+ // 去分号,前面已做,这里不再需要
340
+ let newSentenceRaw = sentenceRaw.split(";")[0];
341
+ if (newSentenceRaw === "") {
342
+ // 注释提前返回
343
+ return {
344
+ command: commandType.comment,
345
+ commandRaw: "comment",
346
+ content: sentenceRaw.split(";")[1] ?? "",
347
+ args: [{ key: "next", value: true }],
348
+ sentenceAssets: [],
349
+ subScene: [] // 语句携带的子场景
350
+ };
351
+ }
352
+ // 截取命令
353
+ const getCommandResult = /:/.exec(newSentenceRaw);
354
+ /**
355
+ * 拆分命令和语句,同时处理连续对话。
356
+ */
357
+ // 没有command,说明这是一条连续对话或单条语句
358
+ if (getCommandResult === null) {
359
+ commandRaw = newSentenceRaw;
360
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
361
+ command = parsedCommand.type;
362
+ for (const e of parsedCommand.additionalArgs) {
363
+ // 由于是连续对话,所以我们去除 speaker 参数。
364
+ if (command === commandType.say && e.key === "speaker") {
365
+ continue;
366
+ }
367
+ args.push(e);
368
+ }
369
+ }
370
+ else {
371
+ commandRaw = newSentenceRaw.substring(0, getCommandResult.index);
372
+ // 划分命令区域和content区域
373
+ newSentenceRaw = newSentenceRaw.substring(getCommandResult.index + 1, newSentenceRaw.length);
374
+ parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
375
+ command = parsedCommand.type;
376
+ for (const e of parsedCommand.additionalArgs) {
377
+ args.push(e);
378
+ }
379
+ }
380
+ // 截取参数区域
381
+ const getArgsResult = / -/.exec(newSentenceRaw);
382
+ // 获取到参数
383
+ if (getArgsResult) {
384
+ const argsRaw = newSentenceRaw.substring(getArgsResult.index, sentenceRaw.length);
385
+ newSentenceRaw = newSentenceRaw.substring(0, getArgsResult.index);
386
+ for (const e of argsParser(argsRaw, assetSetter)) {
387
+ args.push(e);
388
+ }
389
+ }
390
+ content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
391
+ sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
392
+ subScene = subSceneScanner(command, content); // 扫描语句携带子场景
393
+ return {
394
+ command: command,
395
+ commandRaw: commandRaw,
396
+ content: content,
397
+ args: args,
398
+ sentenceAssets: sentenceAssets,
399
+ subScene: subScene // 语句携带的子场景
400
+ };
401
+ };
402
+
403
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
404
+
405
+ /** Detect free variable `global` from Node.js. */
406
+
407
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
408
+
409
+ var _freeGlobal = freeGlobal$1;
410
+
411
+ var freeGlobal = _freeGlobal;
412
+
413
+ /** Detect free variable `self`. */
414
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
415
+
416
+ /** Used as a reference to the global object. */
417
+ var root$4 = freeGlobal || freeSelf || Function('return this')();
418
+
419
+ var _root = root$4;
420
+
421
+ var root$3 = _root;
422
+
423
+ /** Built-in value references. */
424
+ var Symbol$2 = root$3.Symbol;
425
+
426
+ var _Symbol = Symbol$2;
427
+
428
+ var Symbol$1 = _Symbol;
429
+
430
+ /** Used for built-in method references. */
431
+ var objectProto$4 = Object.prototype;
432
+
433
+ /** Used to check objects for own properties. */
434
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
435
+
436
+ /**
437
+ * Used to resolve the
438
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
439
+ * of values.
440
+ */
441
+ var nativeObjectToString$1 = objectProto$4.toString;
442
+
443
+ /** Built-in value references. */
444
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
445
+
446
+ /**
447
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
448
+ *
449
+ * @private
450
+ * @param {*} value The value to query.
451
+ * @returns {string} Returns the raw `toStringTag`.
452
+ */
453
+ function getRawTag$1(value) {
454
+ var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
455
+ tag = value[symToStringTag$1];
456
+
457
+ try {
458
+ value[symToStringTag$1] = undefined;
459
+ var unmasked = true;
460
+ } catch (e) {}
461
+
462
+ var result = nativeObjectToString$1.call(value);
463
+ if (unmasked) {
464
+ if (isOwn) {
465
+ value[symToStringTag$1] = tag;
466
+ } else {
467
+ delete value[symToStringTag$1];
468
+ }
469
+ }
470
+ return result;
471
+ }
472
+
473
+ var _getRawTag = getRawTag$1;
474
+
475
+ /** Used for built-in method references. */
476
+
477
+ var objectProto$3 = Object.prototype;
478
+
479
+ /**
480
+ * Used to resolve the
481
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
482
+ * of values.
483
+ */
484
+ var nativeObjectToString = objectProto$3.toString;
485
+
486
+ /**
487
+ * Converts `value` to a string using `Object.prototype.toString`.
488
+ *
489
+ * @private
490
+ * @param {*} value The value to convert.
491
+ * @returns {string} Returns the converted string.
492
+ */
493
+ function objectToString$1(value) {
494
+ return nativeObjectToString.call(value);
495
+ }
496
+
497
+ var _objectToString = objectToString$1;
498
+
499
+ var Symbol = _Symbol,
500
+ getRawTag = _getRawTag,
501
+ objectToString = _objectToString;
502
+
503
+ /** `Object#toString` result references. */
504
+ var nullTag = '[object Null]',
505
+ undefinedTag = '[object Undefined]';
506
+
507
+ /** Built-in value references. */
508
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
509
+
510
+ /**
511
+ * The base implementation of `getTag` without fallbacks for buggy environments.
512
+ *
513
+ * @private
514
+ * @param {*} value The value to query.
515
+ * @returns {string} Returns the `toStringTag`.
516
+ */
517
+ function baseGetTag$1(value) {
518
+ if (value == null) {
519
+ return value === undefined ? undefinedTag : nullTag;
520
+ }
521
+ return (symToStringTag && symToStringTag in Object(value))
522
+ ? getRawTag(value)
523
+ : objectToString(value);
524
+ }
525
+
526
+ var _baseGetTag = baseGetTag$1;
527
+
528
+ /**
529
+ * Checks if `value` is the
530
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
531
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
532
+ *
533
+ * @static
534
+ * @memberOf _
535
+ * @since 0.1.0
536
+ * @category Lang
537
+ * @param {*} value The value to check.
538
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
539
+ * @example
540
+ *
541
+ * _.isObject({});
542
+ * // => true
543
+ *
544
+ * _.isObject([1, 2, 3]);
545
+ * // => true
546
+ *
547
+ * _.isObject(_.noop);
548
+ * // => true
549
+ *
550
+ * _.isObject(null);
551
+ * // => false
552
+ */
553
+
554
+ function isObject$2(value) {
555
+ var type = typeof value;
556
+ return value != null && (type == 'object' || type == 'function');
557
+ }
558
+
559
+ var isObject_1 = isObject$2;
560
+
561
+ var baseGetTag = _baseGetTag,
562
+ isObject$1 = isObject_1;
563
+
564
+ /** `Object#toString` result references. */
565
+ var asyncTag = '[object AsyncFunction]',
566
+ funcTag = '[object Function]',
567
+ genTag = '[object GeneratorFunction]',
568
+ proxyTag = '[object Proxy]';
569
+
570
+ /**
571
+ * Checks if `value` is classified as a `Function` object.
572
+ *
573
+ * @static
574
+ * @memberOf _
575
+ * @since 0.1.0
576
+ * @category Lang
577
+ * @param {*} value The value to check.
578
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
579
+ * @example
580
+ *
581
+ * _.isFunction(_);
582
+ * // => true
583
+ *
584
+ * _.isFunction(/abc/);
585
+ * // => false
586
+ */
587
+ function isFunction$1(value) {
588
+ if (!isObject$1(value)) {
589
+ return false;
590
+ }
591
+ // The use of `Object#toString` avoids issues with the `typeof` operator
592
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
593
+ var tag = baseGetTag(value);
594
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
595
+ }
596
+
597
+ var isFunction_1 = isFunction$1;
598
+
599
+ var root$2 = _root;
600
+
601
+ /** Used to detect overreaching core-js shims. */
602
+ var coreJsData$1 = root$2['__core-js_shared__'];
603
+
604
+ var _coreJsData = coreJsData$1;
605
+
606
+ var coreJsData = _coreJsData;
607
+
608
+ /** Used to detect methods masquerading as native. */
609
+ var maskSrcKey = (function() {
610
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
611
+ return uid ? ('Symbol(src)_1.' + uid) : '';
612
+ }());
613
+
614
+ /**
615
+ * Checks if `func` has its source masked.
616
+ *
617
+ * @private
618
+ * @param {Function} func The function to check.
619
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
620
+ */
621
+ function isMasked$1(func) {
622
+ return !!maskSrcKey && (maskSrcKey in func);
623
+ }
624
+
625
+ var _isMasked = isMasked$1;
626
+
627
+ /** Used for built-in method references. */
628
+
629
+ var funcProto$1 = Function.prototype;
630
+
631
+ /** Used to resolve the decompiled source of functions. */
632
+ var funcToString$1 = funcProto$1.toString;
633
+
634
+ /**
635
+ * Converts `func` to its source code.
636
+ *
637
+ * @private
638
+ * @param {Function} func The function to convert.
639
+ * @returns {string} Returns the source code.
640
+ */
641
+ function toSource$1(func) {
642
+ if (func != null) {
643
+ try {
644
+ return funcToString$1.call(func);
645
+ } catch (e) {}
646
+ try {
647
+ return (func + '');
648
+ } catch (e) {}
649
+ }
650
+ return '';
651
+ }
652
+
653
+ var _toSource = toSource$1;
654
+
655
+ var isFunction = isFunction_1,
656
+ isMasked = _isMasked,
657
+ isObject = isObject_1,
658
+ toSource = _toSource;
659
+
660
+ /**
661
+ * Used to match `RegExp`
662
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
663
+ */
664
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
665
+
666
+ /** Used to detect host constructors (Safari). */
667
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
668
+
669
+ /** Used for built-in method references. */
670
+ var funcProto = Function.prototype,
671
+ objectProto$2 = Object.prototype;
672
+
673
+ /** Used to resolve the decompiled source of functions. */
674
+ var funcToString = funcProto.toString;
675
+
676
+ /** Used to check objects for own properties. */
677
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
678
+
679
+ /** Used to detect if a method is native. */
680
+ var reIsNative = RegExp('^' +
681
+ funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
682
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
683
+ );
684
+
685
+ /**
686
+ * The base implementation of `_.isNative` without bad shim checks.
687
+ *
688
+ * @private
689
+ * @param {*} value The value to check.
690
+ * @returns {boolean} Returns `true` if `value` is a native function,
691
+ * else `false`.
692
+ */
693
+ function baseIsNative$1(value) {
694
+ if (!isObject(value) || isMasked(value)) {
695
+ return false;
696
+ }
697
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
698
+ return pattern.test(toSource(value));
699
+ }
700
+
701
+ var _baseIsNative = baseIsNative$1;
702
+
703
+ /**
704
+ * Gets the value at `key` of `object`.
705
+ *
706
+ * @private
707
+ * @param {Object} [object] The object to query.
708
+ * @param {string} key The key of the property to get.
709
+ * @returns {*} Returns the property value.
710
+ */
711
+
712
+ function getValue$1(object, key) {
713
+ return object == null ? undefined : object[key];
714
+ }
715
+
716
+ var _getValue = getValue$1;
717
+
718
+ var baseIsNative = _baseIsNative,
719
+ getValue = _getValue;
720
+
721
+ /**
722
+ * Gets the native function at `key` of `object`.
723
+ *
724
+ * @private
725
+ * @param {Object} object The object to query.
726
+ * @param {string} key The key of the method to get.
727
+ * @returns {*} Returns the function if it's native, else `undefined`.
728
+ */
729
+ function getNative$3(object, key) {
730
+ var value = getValue(object, key);
731
+ return baseIsNative(value) ? value : undefined;
732
+ }
733
+
734
+ var _getNative = getNative$3;
735
+
736
+ var getNative$2 = _getNative;
737
+
738
+ /* Built-in method references that are verified to be native. */
739
+ var nativeCreate$4 = getNative$2(Object, 'create');
740
+
741
+ var _nativeCreate = nativeCreate$4;
742
+
743
+ var nativeCreate$3 = _nativeCreate;
744
+
745
+ /**
746
+ * Removes all key-value entries from the hash.
747
+ *
748
+ * @private
749
+ * @name clear
750
+ * @memberOf Hash
751
+ */
752
+ function hashClear$1() {
753
+ this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
754
+ this.size = 0;
755
+ }
756
+
757
+ var _hashClear = hashClear$1;
758
+
759
+ /**
760
+ * Removes `key` and its value from the hash.
761
+ *
762
+ * @private
763
+ * @name delete
764
+ * @memberOf Hash
765
+ * @param {Object} hash The hash to modify.
766
+ * @param {string} key The key of the value to remove.
767
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
768
+ */
769
+
770
+ function hashDelete$1(key) {
771
+ var result = this.has(key) && delete this.__data__[key];
772
+ this.size -= result ? 1 : 0;
773
+ return result;
774
+ }
775
+
776
+ var _hashDelete = hashDelete$1;
777
+
778
+ var nativeCreate$2 = _nativeCreate;
779
+
780
+ /** Used to stand-in for `undefined` hash values. */
781
+ var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
782
+
783
+ /** Used for built-in method references. */
784
+ var objectProto$1 = Object.prototype;
785
+
786
+ /** Used to check objects for own properties. */
787
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
788
+
789
+ /**
790
+ * Gets the hash value for `key`.
791
+ *
792
+ * @private
793
+ * @name get
794
+ * @memberOf Hash
795
+ * @param {string} key The key of the value to get.
796
+ * @returns {*} Returns the entry value.
797
+ */
798
+ function hashGet$1(key) {
799
+ var data = this.__data__;
800
+ if (nativeCreate$2) {
801
+ var result = data[key];
802
+ return result === HASH_UNDEFINED$2 ? undefined : result;
803
+ }
804
+ return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
805
+ }
806
+
807
+ var _hashGet = hashGet$1;
808
+
809
+ var nativeCreate$1 = _nativeCreate;
810
+
811
+ /** Used for built-in method references. */
812
+ var objectProto = Object.prototype;
813
+
814
+ /** Used to check objects for own properties. */
815
+ var hasOwnProperty = objectProto.hasOwnProperty;
816
+
817
+ /**
818
+ * Checks if a hash value for `key` exists.
819
+ *
820
+ * @private
821
+ * @name has
822
+ * @memberOf Hash
823
+ * @param {string} key The key of the entry to check.
824
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
825
+ */
826
+ function hashHas$1(key) {
827
+ var data = this.__data__;
828
+ return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
829
+ }
830
+
831
+ var _hashHas = hashHas$1;
832
+
833
+ var nativeCreate = _nativeCreate;
834
+
835
+ /** Used to stand-in for `undefined` hash values. */
836
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
837
+
838
+ /**
839
+ * Sets the hash `key` to `value`.
840
+ *
841
+ * @private
842
+ * @name set
843
+ * @memberOf Hash
844
+ * @param {string} key The key of the value to set.
845
+ * @param {*} value The value to set.
846
+ * @returns {Object} Returns the hash instance.
847
+ */
848
+ function hashSet$1(key, value) {
849
+ var data = this.__data__;
850
+ this.size += this.has(key) ? 0 : 1;
851
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
852
+ return this;
853
+ }
854
+
855
+ var _hashSet = hashSet$1;
856
+
857
+ var hashClear = _hashClear,
858
+ hashDelete = _hashDelete,
859
+ hashGet = _hashGet,
860
+ hashHas = _hashHas,
861
+ hashSet = _hashSet;
862
+
863
+ /**
864
+ * Creates a hash object.
865
+ *
866
+ * @private
867
+ * @constructor
868
+ * @param {Array} [entries] The key-value pairs to cache.
869
+ */
870
+ function Hash$1(entries) {
871
+ var index = -1,
872
+ length = entries == null ? 0 : entries.length;
873
+
874
+ this.clear();
875
+ while (++index < length) {
876
+ var entry = entries[index];
877
+ this.set(entry[0], entry[1]);
878
+ }
879
+ }
880
+
881
+ // Add methods to `Hash`.
882
+ Hash$1.prototype.clear = hashClear;
883
+ Hash$1.prototype['delete'] = hashDelete;
884
+ Hash$1.prototype.get = hashGet;
885
+ Hash$1.prototype.has = hashHas;
886
+ Hash$1.prototype.set = hashSet;
887
+
888
+ var _Hash = Hash$1;
889
+
890
+ /**
891
+ * Removes all key-value entries from the list cache.
892
+ *
893
+ * @private
894
+ * @name clear
895
+ * @memberOf ListCache
896
+ */
897
+
898
+ function listCacheClear$1() {
899
+ this.__data__ = [];
900
+ this.size = 0;
901
+ }
902
+
903
+ var _listCacheClear = listCacheClear$1;
904
+
905
+ /**
906
+ * Performs a
907
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
908
+ * comparison between two values to determine if they are equivalent.
909
+ *
910
+ * @static
911
+ * @memberOf _
912
+ * @since 4.0.0
913
+ * @category Lang
914
+ * @param {*} value The value to compare.
915
+ * @param {*} other The other value to compare.
916
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
917
+ * @example
918
+ *
919
+ * var object = { 'a': 1 };
920
+ * var other = { 'a': 1 };
921
+ *
922
+ * _.eq(object, object);
923
+ * // => true
924
+ *
925
+ * _.eq(object, other);
926
+ * // => false
927
+ *
928
+ * _.eq('a', 'a');
929
+ * // => true
930
+ *
931
+ * _.eq('a', Object('a'));
932
+ * // => false
933
+ *
934
+ * _.eq(NaN, NaN);
935
+ * // => true
936
+ */
937
+
938
+ function eq$1(value, other) {
939
+ return value === other || (value !== value && other !== other);
940
+ }
941
+
942
+ var eq_1 = eq$1;
943
+
944
+ var eq = eq_1;
945
+
946
+ /**
947
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
948
+ *
949
+ * @private
950
+ * @param {Array} array The array to inspect.
951
+ * @param {*} key The key to search for.
952
+ * @returns {number} Returns the index of the matched value, else `-1`.
953
+ */
954
+ function assocIndexOf$4(array, key) {
955
+ var length = array.length;
956
+ while (length--) {
957
+ if (eq(array[length][0], key)) {
958
+ return length;
959
+ }
960
+ }
961
+ return -1;
962
+ }
963
+
964
+ var _assocIndexOf = assocIndexOf$4;
965
+
966
+ var assocIndexOf$3 = _assocIndexOf;
967
+
968
+ /** Used for built-in method references. */
969
+ var arrayProto = Array.prototype;
970
+
971
+ /** Built-in value references. */
972
+ var splice = arrayProto.splice;
973
+
974
+ /**
975
+ * Removes `key` and its value from the list cache.
976
+ *
977
+ * @private
978
+ * @name delete
979
+ * @memberOf ListCache
980
+ * @param {string} key The key of the value to remove.
981
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
982
+ */
983
+ function listCacheDelete$1(key) {
984
+ var data = this.__data__,
985
+ index = assocIndexOf$3(data, key);
986
+
987
+ if (index < 0) {
988
+ return false;
989
+ }
990
+ var lastIndex = data.length - 1;
991
+ if (index == lastIndex) {
992
+ data.pop();
993
+ } else {
994
+ splice.call(data, index, 1);
995
+ }
996
+ --this.size;
997
+ return true;
998
+ }
999
+
1000
+ var _listCacheDelete = listCacheDelete$1;
1001
+
1002
+ var assocIndexOf$2 = _assocIndexOf;
1003
+
1004
+ /**
1005
+ * Gets the list cache value for `key`.
1006
+ *
1007
+ * @private
1008
+ * @name get
1009
+ * @memberOf ListCache
1010
+ * @param {string} key The key of the value to get.
1011
+ * @returns {*} Returns the entry value.
1012
+ */
1013
+ function listCacheGet$1(key) {
1014
+ var data = this.__data__,
1015
+ index = assocIndexOf$2(data, key);
1016
+
1017
+ return index < 0 ? undefined : data[index][1];
1018
+ }
1019
+
1020
+ var _listCacheGet = listCacheGet$1;
1021
+
1022
+ var assocIndexOf$1 = _assocIndexOf;
1023
+
1024
+ /**
1025
+ * Checks if a list cache value for `key` exists.
1026
+ *
1027
+ * @private
1028
+ * @name has
1029
+ * @memberOf ListCache
1030
+ * @param {string} key The key of the entry to check.
1031
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1032
+ */
1033
+ function listCacheHas$1(key) {
1034
+ return assocIndexOf$1(this.__data__, key) > -1;
1035
+ }
1036
+
1037
+ var _listCacheHas = listCacheHas$1;
1038
+
1039
+ var assocIndexOf = _assocIndexOf;
1040
+
1041
+ /**
1042
+ * Sets the list cache `key` to `value`.
1043
+ *
1044
+ * @private
1045
+ * @name set
1046
+ * @memberOf ListCache
1047
+ * @param {string} key The key of the value to set.
1048
+ * @param {*} value The value to set.
1049
+ * @returns {Object} Returns the list cache instance.
1050
+ */
1051
+ function listCacheSet$1(key, value) {
1052
+ var data = this.__data__,
1053
+ index = assocIndexOf(data, key);
1054
+
1055
+ if (index < 0) {
1056
+ ++this.size;
1057
+ data.push([key, value]);
1058
+ } else {
1059
+ data[index][1] = value;
1060
+ }
1061
+ return this;
1062
+ }
1063
+
1064
+ var _listCacheSet = listCacheSet$1;
1065
+
1066
+ var listCacheClear = _listCacheClear,
1067
+ listCacheDelete = _listCacheDelete,
1068
+ listCacheGet = _listCacheGet,
1069
+ listCacheHas = _listCacheHas,
1070
+ listCacheSet = _listCacheSet;
1071
+
1072
+ /**
1073
+ * Creates an list cache object.
1074
+ *
1075
+ * @private
1076
+ * @constructor
1077
+ * @param {Array} [entries] The key-value pairs to cache.
1078
+ */
1079
+ function ListCache$1(entries) {
1080
+ var index = -1,
1081
+ length = entries == null ? 0 : entries.length;
1082
+
1083
+ this.clear();
1084
+ while (++index < length) {
1085
+ var entry = entries[index];
1086
+ this.set(entry[0], entry[1]);
1087
+ }
1088
+ }
1089
+
1090
+ // Add methods to `ListCache`.
1091
+ ListCache$1.prototype.clear = listCacheClear;
1092
+ ListCache$1.prototype['delete'] = listCacheDelete;
1093
+ ListCache$1.prototype.get = listCacheGet;
1094
+ ListCache$1.prototype.has = listCacheHas;
1095
+ ListCache$1.prototype.set = listCacheSet;
1096
+
1097
+ var _ListCache = ListCache$1;
1098
+
1099
+ var getNative$1 = _getNative,
1100
+ root$1 = _root;
1101
+
1102
+ /* Built-in method references that are verified to be native. */
1103
+ var Map$2 = getNative$1(root$1, 'Map');
1104
+
1105
+ var _Map = Map$2;
1106
+
1107
+ var Hash = _Hash,
1108
+ ListCache = _ListCache,
1109
+ Map$1 = _Map;
1110
+
1111
+ /**
1112
+ * Removes all key-value entries from the map.
1113
+ *
1114
+ * @private
1115
+ * @name clear
1116
+ * @memberOf MapCache
1117
+ */
1118
+ function mapCacheClear$1() {
1119
+ this.size = 0;
1120
+ this.__data__ = {
1121
+ 'hash': new Hash,
1122
+ 'map': new (Map$1 || ListCache),
1123
+ 'string': new Hash
1124
+ };
1125
+ }
1126
+
1127
+ var _mapCacheClear = mapCacheClear$1;
1128
+
1129
+ /**
1130
+ * Checks if `value` is suitable for use as unique object key.
1131
+ *
1132
+ * @private
1133
+ * @param {*} value The value to check.
1134
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1135
+ */
1136
+
1137
+ function isKeyable$1(value) {
1138
+ var type = typeof value;
1139
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1140
+ ? (value !== '__proto__')
1141
+ : (value === null);
1142
+ }
1143
+
1144
+ var _isKeyable = isKeyable$1;
1145
+
1146
+ var isKeyable = _isKeyable;
1147
+
1148
+ /**
1149
+ * Gets the data for `map`.
1150
+ *
1151
+ * @private
1152
+ * @param {Object} map The map to query.
1153
+ * @param {string} key The reference key.
1154
+ * @returns {*} Returns the map data.
1155
+ */
1156
+ function getMapData$4(map, key) {
1157
+ var data = map.__data__;
1158
+ return isKeyable(key)
1159
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1160
+ : data.map;
1161
+ }
1162
+
1163
+ var _getMapData = getMapData$4;
1164
+
1165
+ var getMapData$3 = _getMapData;
1166
+
1167
+ /**
1168
+ * Removes `key` and its value from the map.
1169
+ *
1170
+ * @private
1171
+ * @name delete
1172
+ * @memberOf MapCache
1173
+ * @param {string} key The key of the value to remove.
1174
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1175
+ */
1176
+ function mapCacheDelete$1(key) {
1177
+ var result = getMapData$3(this, key)['delete'](key);
1178
+ this.size -= result ? 1 : 0;
1179
+ return result;
1180
+ }
1181
+
1182
+ var _mapCacheDelete = mapCacheDelete$1;
1183
+
1184
+ var getMapData$2 = _getMapData;
1185
+
1186
+ /**
1187
+ * Gets the map value for `key`.
1188
+ *
1189
+ * @private
1190
+ * @name get
1191
+ * @memberOf MapCache
1192
+ * @param {string} key The key of the value to get.
1193
+ * @returns {*} Returns the entry value.
1194
+ */
1195
+ function mapCacheGet$1(key) {
1196
+ return getMapData$2(this, key).get(key);
1197
+ }
1198
+
1199
+ var _mapCacheGet = mapCacheGet$1;
1200
+
1201
+ var getMapData$1 = _getMapData;
1202
+
1203
+ /**
1204
+ * Checks if a map value for `key` exists.
1205
+ *
1206
+ * @private
1207
+ * @name has
1208
+ * @memberOf MapCache
1209
+ * @param {string} key The key of the entry to check.
1210
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1211
+ */
1212
+ function mapCacheHas$1(key) {
1213
+ return getMapData$1(this, key).has(key);
1214
+ }
1215
+
1216
+ var _mapCacheHas = mapCacheHas$1;
1217
+
1218
+ var getMapData = _getMapData;
1219
+
1220
+ /**
1221
+ * Sets the map `key` to `value`.
1222
+ *
1223
+ * @private
1224
+ * @name set
1225
+ * @memberOf MapCache
1226
+ * @param {string} key The key of the value to set.
1227
+ * @param {*} value The value to set.
1228
+ * @returns {Object} Returns the map cache instance.
1229
+ */
1230
+ function mapCacheSet$1(key, value) {
1231
+ var data = getMapData(this, key),
1232
+ size = data.size;
1233
+
1234
+ data.set(key, value);
1235
+ this.size += data.size == size ? 0 : 1;
1236
+ return this;
1237
+ }
1238
+
1239
+ var _mapCacheSet = mapCacheSet$1;
1240
+
1241
+ var mapCacheClear = _mapCacheClear,
1242
+ mapCacheDelete = _mapCacheDelete,
1243
+ mapCacheGet = _mapCacheGet,
1244
+ mapCacheHas = _mapCacheHas,
1245
+ mapCacheSet = _mapCacheSet;
1246
+
1247
+ /**
1248
+ * Creates a map cache object to store key-value pairs.
1249
+ *
1250
+ * @private
1251
+ * @constructor
1252
+ * @param {Array} [entries] The key-value pairs to cache.
1253
+ */
1254
+ function MapCache$1(entries) {
1255
+ var index = -1,
1256
+ length = entries == null ? 0 : entries.length;
1257
+
1258
+ this.clear();
1259
+ while (++index < length) {
1260
+ var entry = entries[index];
1261
+ this.set(entry[0], entry[1]);
1262
+ }
1263
+ }
1264
+
1265
+ // Add methods to `MapCache`.
1266
+ MapCache$1.prototype.clear = mapCacheClear;
1267
+ MapCache$1.prototype['delete'] = mapCacheDelete;
1268
+ MapCache$1.prototype.get = mapCacheGet;
1269
+ MapCache$1.prototype.has = mapCacheHas;
1270
+ MapCache$1.prototype.set = mapCacheSet;
1271
+
1272
+ var _MapCache = MapCache$1;
1273
+
1274
+ /** Used to stand-in for `undefined` hash values. */
1275
+
1276
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1277
+
1278
+ /**
1279
+ * Adds `value` to the array cache.
1280
+ *
1281
+ * @private
1282
+ * @name add
1283
+ * @memberOf SetCache
1284
+ * @alias push
1285
+ * @param {*} value The value to cache.
1286
+ * @returns {Object} Returns the cache instance.
1287
+ */
1288
+ function setCacheAdd$1(value) {
1289
+ this.__data__.set(value, HASH_UNDEFINED);
1290
+ return this;
1291
+ }
1292
+
1293
+ var _setCacheAdd = setCacheAdd$1;
1294
+
1295
+ /**
1296
+ * Checks if `value` is in the array cache.
1297
+ *
1298
+ * @private
1299
+ * @name has
1300
+ * @memberOf SetCache
1301
+ * @param {*} value The value to search for.
1302
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1303
+ */
1304
+
1305
+ function setCacheHas$1(value) {
1306
+ return this.__data__.has(value);
1307
+ }
1308
+
1309
+ var _setCacheHas = setCacheHas$1;
1310
+
1311
+ var MapCache = _MapCache,
1312
+ setCacheAdd = _setCacheAdd,
1313
+ setCacheHas = _setCacheHas;
1314
+
1315
+ /**
1316
+ *
1317
+ * Creates an array cache object to store unique values.
1318
+ *
1319
+ * @private
1320
+ * @constructor
1321
+ * @param {Array} [values] The values to cache.
1322
+ */
1323
+ function SetCache$1(values) {
1324
+ var index = -1,
1325
+ length = values == null ? 0 : values.length;
1326
+
1327
+ this.__data__ = new MapCache;
1328
+ while (++index < length) {
1329
+ this.add(values[index]);
1330
+ }
1331
+ }
1332
+
1333
+ // Add methods to `SetCache`.
1334
+ SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
1335
+ SetCache$1.prototype.has = setCacheHas;
1336
+
1337
+ var _SetCache = SetCache$1;
1338
+
1339
+ /**
1340
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
1341
+ * support for iteratee shorthands.
1342
+ *
1343
+ * @private
1344
+ * @param {Array} array The array to inspect.
1345
+ * @param {Function} predicate The function invoked per iteration.
1346
+ * @param {number} fromIndex The index to search from.
1347
+ * @param {boolean} [fromRight] Specify iterating from right to left.
1348
+ * @returns {number} Returns the index of the matched value, else `-1`.
1349
+ */
1350
+
1351
+ function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
1352
+ var length = array.length,
1353
+ index = fromIndex + (fromRight ? 1 : -1);
1354
+
1355
+ while ((fromRight ? index-- : ++index < length)) {
1356
+ if (predicate(array[index], index, array)) {
1357
+ return index;
1358
+ }
1359
+ }
1360
+ return -1;
1361
+ }
1362
+
1363
+ var _baseFindIndex = baseFindIndex$1;
1364
+
1365
+ /**
1366
+ * The base implementation of `_.isNaN` without support for number objects.
1367
+ *
1368
+ * @private
1369
+ * @param {*} value The value to check.
1370
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
1371
+ */
1372
+
1373
+ function baseIsNaN$1(value) {
1374
+ return value !== value;
1375
+ }
1376
+
1377
+ var _baseIsNaN = baseIsNaN$1;
1378
+
1379
+ /**
1380
+ * A specialized version of `_.indexOf` which performs strict equality
1381
+ * comparisons of values, i.e. `===`.
1382
+ *
1383
+ * @private
1384
+ * @param {Array} array The array to inspect.
1385
+ * @param {*} value The value to search for.
1386
+ * @param {number} fromIndex The index to search from.
1387
+ * @returns {number} Returns the index of the matched value, else `-1`.
1388
+ */
1389
+
1390
+ function strictIndexOf$1(array, value, fromIndex) {
1391
+ var index = fromIndex - 1,
1392
+ length = array.length;
1393
+
1394
+ while (++index < length) {
1395
+ if (array[index] === value) {
1396
+ return index;
1397
+ }
1398
+ }
1399
+ return -1;
1400
+ }
1401
+
1402
+ var _strictIndexOf = strictIndexOf$1;
1403
+
1404
+ var baseFindIndex = _baseFindIndex,
1405
+ baseIsNaN = _baseIsNaN,
1406
+ strictIndexOf = _strictIndexOf;
1407
+
1408
+ /**
1409
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1410
+ *
1411
+ * @private
1412
+ * @param {Array} array The array to inspect.
1413
+ * @param {*} value The value to search for.
1414
+ * @param {number} fromIndex The index to search from.
1415
+ * @returns {number} Returns the index of the matched value, else `-1`.
1416
+ */
1417
+ function baseIndexOf$1(array, value, fromIndex) {
1418
+ return value === value
1419
+ ? strictIndexOf(array, value, fromIndex)
1420
+ : baseFindIndex(array, baseIsNaN, fromIndex);
1421
+ }
1422
+
1423
+ var _baseIndexOf = baseIndexOf$1;
1424
+
1425
+ var baseIndexOf = _baseIndexOf;
1426
+
1427
+ /**
1428
+ * A specialized version of `_.includes` for arrays without support for
1429
+ * specifying an index to search from.
1430
+ *
1431
+ * @private
1432
+ * @param {Array} [array] The array to inspect.
1433
+ * @param {*} target The value to search for.
1434
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
1435
+ */
1436
+ function arrayIncludes$1(array, value) {
1437
+ var length = array == null ? 0 : array.length;
1438
+ return !!length && baseIndexOf(array, value, 0) > -1;
1439
+ }
1440
+
1441
+ var _arrayIncludes = arrayIncludes$1;
1442
+
1443
+ /**
1444
+ * This function is like `arrayIncludes` except that it accepts a comparator.
1445
+ *
1446
+ * @private
1447
+ * @param {Array} [array] The array to inspect.
1448
+ * @param {*} target The value to search for.
1449
+ * @param {Function} comparator The comparator invoked per element.
1450
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
1451
+ */
1452
+
1453
+ function arrayIncludesWith$1(array, value, comparator) {
1454
+ var index = -1,
1455
+ length = array == null ? 0 : array.length;
1456
+
1457
+ while (++index < length) {
1458
+ if (comparator(value, array[index])) {
1459
+ return true;
1460
+ }
1461
+ }
1462
+ return false;
1463
+ }
1464
+
1465
+ var _arrayIncludesWith = arrayIncludesWith$1;
1466
+
1467
+ /**
1468
+ * Checks if a `cache` value for `key` exists.
1469
+ *
1470
+ * @private
1471
+ * @param {Object} cache The cache to query.
1472
+ * @param {string} key The key of the entry to check.
1473
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1474
+ */
1475
+
1476
+ function cacheHas$1(cache, key) {
1477
+ return cache.has(key);
1478
+ }
1479
+
1480
+ var _cacheHas = cacheHas$1;
1481
+
1482
+ var getNative = _getNative,
1483
+ root = _root;
1484
+
1485
+ /* Built-in method references that are verified to be native. */
1486
+ var Set$1 = getNative(root, 'Set');
1487
+
1488
+ var _Set = Set$1;
1489
+
1490
+ /**
1491
+ * This method returns `undefined`.
1492
+ *
1493
+ * @static
1494
+ * @memberOf _
1495
+ * @since 2.3.0
1496
+ * @category Util
1497
+ * @example
1498
+ *
1499
+ * _.times(2, _.noop);
1500
+ * // => [undefined, undefined]
1501
+ */
1502
+
1503
+ function noop$1() {
1504
+ // No operation performed.
1505
+ }
1506
+
1507
+ var noop_1 = noop$1;
1508
+
1509
+ /**
1510
+ * Converts `set` to an array of its values.
1511
+ *
1512
+ * @private
1513
+ * @param {Object} set The set to convert.
1514
+ * @returns {Array} Returns the values.
1515
+ */
1516
+
1517
+ function setToArray$2(set) {
1518
+ var index = -1,
1519
+ result = Array(set.size);
1520
+
1521
+ set.forEach(function(value) {
1522
+ result[++index] = value;
1523
+ });
1524
+ return result;
1525
+ }
1526
+
1527
+ var _setToArray = setToArray$2;
1528
+
1529
+ var Set = _Set,
1530
+ noop = noop_1,
1531
+ setToArray$1 = _setToArray;
1532
+
1533
+ /** Used as references for various `Number` constants. */
1534
+ var INFINITY = 1 / 0;
1535
+
1536
+ /**
1537
+ * Creates a set object of `values`.
1538
+ *
1539
+ * @private
1540
+ * @param {Array} values The values to add to the set.
1541
+ * @returns {Object} Returns the new set.
1542
+ */
1543
+ var createSet$1 = !(Set && (1 / setToArray$1(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
1544
+ return new Set(values);
1545
+ };
1546
+
1547
+ var _createSet = createSet$1;
1548
+
1549
+ var SetCache = _SetCache,
1550
+ arrayIncludes = _arrayIncludes,
1551
+ arrayIncludesWith = _arrayIncludesWith,
1552
+ cacheHas = _cacheHas,
1553
+ createSet = _createSet,
1554
+ setToArray = _setToArray;
1555
+
1556
+ /** Used as the size to enable large array optimizations. */
1557
+ var LARGE_ARRAY_SIZE = 200;
1558
+
1559
+ /**
1560
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
1561
+ *
1562
+ * @private
1563
+ * @param {Array} array The array to inspect.
1564
+ * @param {Function} [iteratee] The iteratee invoked per element.
1565
+ * @param {Function} [comparator] The comparator invoked per element.
1566
+ * @returns {Array} Returns the new duplicate free array.
1567
+ */
1568
+ function baseUniq$1(array, iteratee, comparator) {
1569
+ var index = -1,
1570
+ includes = arrayIncludes,
1571
+ length = array.length,
1572
+ isCommon = true,
1573
+ result = [],
1574
+ seen = result;
1575
+
1576
+ if (comparator) {
1577
+ isCommon = false;
1578
+ includes = arrayIncludesWith;
1579
+ }
1580
+ else if (length >= LARGE_ARRAY_SIZE) {
1581
+ var set = iteratee ? null : createSet(array);
1582
+ if (set) {
1583
+ return setToArray(set);
1584
+ }
1585
+ isCommon = false;
1586
+ includes = cacheHas;
1587
+ seen = new SetCache;
1588
+ }
1589
+ else {
1590
+ seen = iteratee ? [] : result;
1591
+ }
1592
+ outer:
1593
+ while (++index < length) {
1594
+ var value = array[index],
1595
+ computed = iteratee ? iteratee(value) : value;
1596
+
1597
+ value = (comparator || value !== 0) ? value : 0;
1598
+ if (isCommon && computed === computed) {
1599
+ var seenIndex = seen.length;
1600
+ while (seenIndex--) {
1601
+ if (seen[seenIndex] === computed) {
1602
+ continue outer;
1603
+ }
1604
+ }
1605
+ if (iteratee) {
1606
+ seen.push(computed);
1607
+ }
1608
+ result.push(value);
1609
+ }
1610
+ else if (!includes(seen, computed, comparator)) {
1611
+ if (seen !== result) {
1612
+ seen.push(computed);
1613
+ }
1614
+ result.push(value);
1615
+ }
1616
+ }
1617
+ return result;
1618
+ }
1619
+
1620
+ var _baseUniq = baseUniq$1;
1621
+
1622
+ var baseUniq = _baseUniq;
1623
+
1624
+ /**
1625
+ * This method is like `_.uniq` except that it accepts `comparator` which
1626
+ * is invoked to compare elements of `array`. The order of result values is
1627
+ * determined by the order they occur in the array.The comparator is invoked
1628
+ * with two arguments: (arrVal, othVal).
1629
+ *
1630
+ * @static
1631
+ * @memberOf _
1632
+ * @since 4.0.0
1633
+ * @category Array
1634
+ * @param {Array} array The array to inspect.
1635
+ * @param {Function} [comparator] The comparator invoked per element.
1636
+ * @returns {Array} Returns the new duplicate free array.
1637
+ * @example
1638
+ *
1639
+ * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
1640
+ *
1641
+ * _.uniqWith(objects, _.isEqual);
1642
+ * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
1643
+ */
1644
+ function uniqWith(array, comparator) {
1645
+ comparator = typeof comparator == 'function' ? comparator : undefined;
1646
+ return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
1647
+ }
1648
+
1649
+ var uniqWith_1 = uniqWith;
1650
+
1651
+ /**
1652
+ * 场景解析器
1653
+ * @param rawScene 原始场景
1654
+ * @param sceneName 场景名称
1655
+ * @param sceneUrl 场景url
1656
+ * @param assetsPrefetcher
1657
+ * @param assetSetter
1658
+ * @param ADD_NEXT_ARG_LIST
1659
+ * @param SCRIPT_CONFIG
1660
+ * @return {IScene} 解析后的场景
1661
+ */
1662
+ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) => {
1663
+ const rawSentenceList = rawScene.split("\n"); // 原始句子列表
1664
+ // 去分号留到后面去做了,现在注释要单独处理
1665
+ const rawSentenceListWithoutEmpty = rawSentenceList;
1666
+ // .map((sentence) => sentence.split(";")[0])
1667
+ // .filter((sentence) => sentence.trim() !== "");
1668
+ let assetsList = []; // 场景资源列表
1669
+ let subSceneList = []; // 子场景列表
1670
+ const sentenceList = rawSentenceListWithoutEmpty.map((sentence) => {
1671
+ const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);
1672
+ // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
1673
+ assetsList = [...assetsList, ...returnSentence.sentenceAssets];
1674
+ subSceneList = [...subSceneList, ...returnSentence.subScene];
1675
+ return returnSentence;
1676
+ });
1677
+ // 开始资源的预加载
1678
+ assetsList = uniqWith_1(assetsList); // 去重
1679
+ assetsPrefetcher(assetsList);
1680
+ return {
1681
+ sceneName: sceneName,
1682
+ sceneUrl: sceneUrl,
1683
+ sentenceList: sentenceList,
1684
+ assetsList: assetsList,
1685
+ subSceneList: subSceneList // 子场景列表
1686
+ };
1687
+ };
1688
+
1689
+ class SceneParser {
1690
+ assetsPrefetcher;
1691
+ assetSetter;
1692
+ ADD_NEXT_ARG_LIST;
1693
+ SCRIPT_CONFIG;
1694
+ constructor(assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG) {
1695
+ this.assetsPrefetcher = assetsPrefetcher;
1696
+ this.assetSetter = assetSetter;
1697
+ this.ADD_NEXT_ARG_LIST = ADD_NEXT_ARG_LIST;
1698
+ this.SCRIPT_CONFIG = SCRIPT_CONFIG;
1699
+ }
1700
+ parse(rawScene, sceneName, sceneUrl) {
1701
+ return sceneParser(rawScene, sceneName, sceneUrl, this.assetsPrefetcher, this.assetSetter, this.ADD_NEXT_ARG_LIST, this.SCRIPT_CONFIG);
1702
+ }
1703
+ }
1704
+
1705
+ export { SceneParser as default };
1706
+ //# sourceMappingURL=index.js.map