@localazy/cdn-client 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2487 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
8
+ /* @localazy/cdn-client@1.1.1
9
+ * (c) 2024 Localazy <team@localazy.com>
10
+ * @license MIT */
11
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
12
+ const axios = require("axios");
13
+ class Api {
14
+ constructor(context) {
15
+ __publicField(this, "context");
16
+ this.context = context;
17
+ }
18
+ async fetchLocale(options) {
19
+ const config = { reference: options };
20
+ if (this.context.cache.has(options)) {
21
+ return new Promise((resolve) => {
22
+ resolve({
23
+ data: this.context.cache.get(options),
24
+ config
25
+ });
26
+ });
27
+ }
28
+ const responseType = /\.(json|json5)$/.test(options.metafileFile.file) ? "json" : "text";
29
+ return this.context.client.get(options.metafileLocale.uri, { ...config, responseType });
30
+ }
31
+ async fetchMetafile(config) {
32
+ return this.context.client.get(
33
+ this.context.metafile.params.jsonPath,
34
+ config
35
+ );
36
+ }
37
+ }
38
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
39
+ function getDefaultExportFromCjs(x) {
40
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
41
+ }
42
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
43
+ var _freeGlobal = freeGlobal$1;
44
+ var freeGlobal = _freeGlobal;
45
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
46
+ var root$8 = freeGlobal || freeSelf || Function("return this")();
47
+ var _root = root$8;
48
+ var root$7 = _root;
49
+ var Symbol$6 = root$7.Symbol;
50
+ var _Symbol = Symbol$6;
51
+ var Symbol$5 = _Symbol;
52
+ var objectProto$f = Object.prototype;
53
+ var hasOwnProperty$c = objectProto$f.hasOwnProperty;
54
+ var nativeObjectToString$1 = objectProto$f.toString;
55
+ var symToStringTag$1 = Symbol$5 ? Symbol$5.toStringTag : void 0;
56
+ function getRawTag$1(value) {
57
+ var isOwn = hasOwnProperty$c.call(value, symToStringTag$1), tag = value[symToStringTag$1];
58
+ try {
59
+ value[symToStringTag$1] = void 0;
60
+ var unmasked = true;
61
+ } catch (e) {
62
+ }
63
+ var result = nativeObjectToString$1.call(value);
64
+ if (unmasked) {
65
+ if (isOwn) {
66
+ value[symToStringTag$1] = tag;
67
+ } else {
68
+ delete value[symToStringTag$1];
69
+ }
70
+ }
71
+ return result;
72
+ }
73
+ var _getRawTag = getRawTag$1;
74
+ var objectProto$e = Object.prototype;
75
+ var nativeObjectToString = objectProto$e.toString;
76
+ function objectToString$1(value) {
77
+ return nativeObjectToString.call(value);
78
+ }
79
+ var _objectToString = objectToString$1;
80
+ var Symbol$4 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
81
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
82
+ var symToStringTag = Symbol$4 ? Symbol$4.toStringTag : void 0;
83
+ function baseGetTag$7(value) {
84
+ if (value == null) {
85
+ return value === void 0 ? undefinedTag : nullTag;
86
+ }
87
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
88
+ }
89
+ var _baseGetTag = baseGetTag$7;
90
+ function isObject$7(value) {
91
+ var type = typeof value;
92
+ return value != null && (type == "object" || type == "function");
93
+ }
94
+ var isObject_1 = isObject$7;
95
+ var baseGetTag$6 = _baseGetTag, isObject$6 = isObject_1;
96
+ var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
97
+ function isFunction$2(value) {
98
+ if (!isObject$6(value)) {
99
+ return false;
100
+ }
101
+ var tag = baseGetTag$6(value);
102
+ return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
103
+ }
104
+ var isFunction_1 = isFunction$2;
105
+ const isFunction$3 = /* @__PURE__ */ getDefaultExportFromCjs(isFunction_1);
106
+ var root$6 = _root;
107
+ var coreJsData$1 = root$6["__core-js_shared__"];
108
+ var _coreJsData = coreJsData$1;
109
+ var coreJsData = _coreJsData;
110
+ var maskSrcKey = function() {
111
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
112
+ return uid ? "Symbol(src)_1." + uid : "";
113
+ }();
114
+ function isMasked$1(func) {
115
+ return !!maskSrcKey && maskSrcKey in func;
116
+ }
117
+ var _isMasked = isMasked$1;
118
+ var funcProto$2 = Function.prototype;
119
+ var funcToString$2 = funcProto$2.toString;
120
+ function toSource$2(func) {
121
+ if (func != null) {
122
+ try {
123
+ return funcToString$2.call(func);
124
+ } catch (e) {
125
+ }
126
+ try {
127
+ return func + "";
128
+ } catch (e) {
129
+ }
130
+ }
131
+ return "";
132
+ }
133
+ var _toSource = toSource$2;
134
+ var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$5 = isObject_1, toSource$1 = _toSource;
135
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
136
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
137
+ var funcProto$1 = Function.prototype, objectProto$d = Object.prototype;
138
+ var funcToString$1 = funcProto$1.toString;
139
+ var hasOwnProperty$b = objectProto$d.hasOwnProperty;
140
+ var reIsNative = RegExp(
141
+ "^" + funcToString$1.call(hasOwnProperty$b).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
142
+ );
143
+ function baseIsNative$1(value) {
144
+ if (!isObject$5(value) || isMasked(value)) {
145
+ return false;
146
+ }
147
+ var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
148
+ return pattern.test(toSource$1(value));
149
+ }
150
+ var _baseIsNative = baseIsNative$1;
151
+ function getValue$1(object, key) {
152
+ return object == null ? void 0 : object[key];
153
+ }
154
+ var _getValue = getValue$1;
155
+ var baseIsNative = _baseIsNative, getValue = _getValue;
156
+ function getNative$7(object, key) {
157
+ var value = getValue(object, key);
158
+ return baseIsNative(value) ? value : void 0;
159
+ }
160
+ var _getNative = getNative$7;
161
+ var getNative$6 = _getNative;
162
+ var nativeCreate$4 = getNative$6(Object, "create");
163
+ var _nativeCreate = nativeCreate$4;
164
+ var nativeCreate$3 = _nativeCreate;
165
+ function hashClear$1() {
166
+ this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
167
+ this.size = 0;
168
+ }
169
+ var _hashClear = hashClear$1;
170
+ function hashDelete$1(key) {
171
+ var result = this.has(key) && delete this.__data__[key];
172
+ this.size -= result ? 1 : 0;
173
+ return result;
174
+ }
175
+ var _hashDelete = hashDelete$1;
176
+ var nativeCreate$2 = _nativeCreate;
177
+ var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
178
+ var objectProto$c = Object.prototype;
179
+ var hasOwnProperty$a = objectProto$c.hasOwnProperty;
180
+ function hashGet$1(key) {
181
+ var data = this.__data__;
182
+ if (nativeCreate$2) {
183
+ var result = data[key];
184
+ return result === HASH_UNDEFINED$2 ? void 0 : result;
185
+ }
186
+ return hasOwnProperty$a.call(data, key) ? data[key] : void 0;
187
+ }
188
+ var _hashGet = hashGet$1;
189
+ var nativeCreate$1 = _nativeCreate;
190
+ var objectProto$b = Object.prototype;
191
+ var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
192
+ function hashHas$1(key) {
193
+ var data = this.__data__;
194
+ return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$9.call(data, key);
195
+ }
196
+ var _hashHas = hashHas$1;
197
+ var nativeCreate = _nativeCreate;
198
+ var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
199
+ function hashSet$1(key, value) {
200
+ var data = this.__data__;
201
+ this.size += this.has(key) ? 0 : 1;
202
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED$1 : value;
203
+ return this;
204
+ }
205
+ var _hashSet = hashSet$1;
206
+ var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
207
+ function Hash$1(entries) {
208
+ var index = -1, length = entries == null ? 0 : entries.length;
209
+ this.clear();
210
+ while (++index < length) {
211
+ var entry = entries[index];
212
+ this.set(entry[0], entry[1]);
213
+ }
214
+ }
215
+ Hash$1.prototype.clear = hashClear;
216
+ Hash$1.prototype["delete"] = hashDelete;
217
+ Hash$1.prototype.get = hashGet;
218
+ Hash$1.prototype.has = hashHas;
219
+ Hash$1.prototype.set = hashSet;
220
+ var _Hash = Hash$1;
221
+ function listCacheClear$1() {
222
+ this.__data__ = [];
223
+ this.size = 0;
224
+ }
225
+ var _listCacheClear = listCacheClear$1;
226
+ function eq$3(value, other) {
227
+ return value === other || value !== value && other !== other;
228
+ }
229
+ var eq_1 = eq$3;
230
+ var eq$2 = eq_1;
231
+ function assocIndexOf$4(array, key) {
232
+ var length = array.length;
233
+ while (length--) {
234
+ if (eq$2(array[length][0], key)) {
235
+ return length;
236
+ }
237
+ }
238
+ return -1;
239
+ }
240
+ var _assocIndexOf = assocIndexOf$4;
241
+ var assocIndexOf$3 = _assocIndexOf;
242
+ var arrayProto = Array.prototype;
243
+ var splice = arrayProto.splice;
244
+ function listCacheDelete$1(key) {
245
+ var data = this.__data__, index = assocIndexOf$3(data, key);
246
+ if (index < 0) {
247
+ return false;
248
+ }
249
+ var lastIndex = data.length - 1;
250
+ if (index == lastIndex) {
251
+ data.pop();
252
+ } else {
253
+ splice.call(data, index, 1);
254
+ }
255
+ --this.size;
256
+ return true;
257
+ }
258
+ var _listCacheDelete = listCacheDelete$1;
259
+ var assocIndexOf$2 = _assocIndexOf;
260
+ function listCacheGet$1(key) {
261
+ var data = this.__data__, index = assocIndexOf$2(data, key);
262
+ return index < 0 ? void 0 : data[index][1];
263
+ }
264
+ var _listCacheGet = listCacheGet$1;
265
+ var assocIndexOf$1 = _assocIndexOf;
266
+ function listCacheHas$1(key) {
267
+ return assocIndexOf$1(this.__data__, key) > -1;
268
+ }
269
+ var _listCacheHas = listCacheHas$1;
270
+ var assocIndexOf = _assocIndexOf;
271
+ function listCacheSet$1(key, value) {
272
+ var data = this.__data__, index = assocIndexOf(data, key);
273
+ if (index < 0) {
274
+ ++this.size;
275
+ data.push([key, value]);
276
+ } else {
277
+ data[index][1] = value;
278
+ }
279
+ return this;
280
+ }
281
+ var _listCacheSet = listCacheSet$1;
282
+ var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
283
+ function ListCache$4(entries) {
284
+ var index = -1, length = entries == null ? 0 : entries.length;
285
+ this.clear();
286
+ while (++index < length) {
287
+ var entry = entries[index];
288
+ this.set(entry[0], entry[1]);
289
+ }
290
+ }
291
+ ListCache$4.prototype.clear = listCacheClear;
292
+ ListCache$4.prototype["delete"] = listCacheDelete;
293
+ ListCache$4.prototype.get = listCacheGet;
294
+ ListCache$4.prototype.has = listCacheHas;
295
+ ListCache$4.prototype.set = listCacheSet;
296
+ var _ListCache = ListCache$4;
297
+ var getNative$5 = _getNative, root$5 = _root;
298
+ var Map$4 = getNative$5(root$5, "Map");
299
+ var _Map = Map$4;
300
+ var Hash = _Hash, ListCache$3 = _ListCache, Map$3 = _Map;
301
+ function mapCacheClear$1() {
302
+ this.size = 0;
303
+ this.__data__ = {
304
+ "hash": new Hash(),
305
+ "map": new (Map$3 || ListCache$3)(),
306
+ "string": new Hash()
307
+ };
308
+ }
309
+ var _mapCacheClear = mapCacheClear$1;
310
+ function isKeyable$1(value) {
311
+ var type = typeof value;
312
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
313
+ }
314
+ var _isKeyable = isKeyable$1;
315
+ var isKeyable = _isKeyable;
316
+ function getMapData$4(map, key) {
317
+ var data = map.__data__;
318
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
319
+ }
320
+ var _getMapData = getMapData$4;
321
+ var getMapData$3 = _getMapData;
322
+ function mapCacheDelete$1(key) {
323
+ var result = getMapData$3(this, key)["delete"](key);
324
+ this.size -= result ? 1 : 0;
325
+ return result;
326
+ }
327
+ var _mapCacheDelete = mapCacheDelete$1;
328
+ var getMapData$2 = _getMapData;
329
+ function mapCacheGet$1(key) {
330
+ return getMapData$2(this, key).get(key);
331
+ }
332
+ var _mapCacheGet = mapCacheGet$1;
333
+ var getMapData$1 = _getMapData;
334
+ function mapCacheHas$1(key) {
335
+ return getMapData$1(this, key).has(key);
336
+ }
337
+ var _mapCacheHas = mapCacheHas$1;
338
+ var getMapData = _getMapData;
339
+ function mapCacheSet$1(key, value) {
340
+ var data = getMapData(this, key), size = data.size;
341
+ data.set(key, value);
342
+ this.size += data.size == size ? 0 : 1;
343
+ return this;
344
+ }
345
+ var _mapCacheSet = mapCacheSet$1;
346
+ var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
347
+ function MapCache$3(entries) {
348
+ var index = -1, length = entries == null ? 0 : entries.length;
349
+ this.clear();
350
+ while (++index < length) {
351
+ var entry = entries[index];
352
+ this.set(entry[0], entry[1]);
353
+ }
354
+ }
355
+ MapCache$3.prototype.clear = mapCacheClear;
356
+ MapCache$3.prototype["delete"] = mapCacheDelete;
357
+ MapCache$3.prototype.get = mapCacheGet;
358
+ MapCache$3.prototype.has = mapCacheHas;
359
+ MapCache$3.prototype.set = mapCacheSet;
360
+ var _MapCache = MapCache$3;
361
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
362
+ function setCacheAdd$1(value) {
363
+ this.__data__.set(value, HASH_UNDEFINED);
364
+ return this;
365
+ }
366
+ var _setCacheAdd = setCacheAdd$1;
367
+ function setCacheHas$1(value) {
368
+ return this.__data__.has(value);
369
+ }
370
+ var _setCacheHas = setCacheHas$1;
371
+ var MapCache$2 = _MapCache, setCacheAdd = _setCacheAdd, setCacheHas = _setCacheHas;
372
+ function SetCache$2(values) {
373
+ var index = -1, length = values == null ? 0 : values.length;
374
+ this.__data__ = new MapCache$2();
375
+ while (++index < length) {
376
+ this.add(values[index]);
377
+ }
378
+ }
379
+ SetCache$2.prototype.add = SetCache$2.prototype.push = setCacheAdd;
380
+ SetCache$2.prototype.has = setCacheHas;
381
+ var _SetCache = SetCache$2;
382
+ function baseFindIndex$2(array, predicate, fromIndex, fromRight) {
383
+ var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
384
+ while (fromRight ? index-- : ++index < length) {
385
+ if (predicate(array[index], index, array)) {
386
+ return index;
387
+ }
388
+ }
389
+ return -1;
390
+ }
391
+ var _baseFindIndex = baseFindIndex$2;
392
+ function baseIsNaN$1(value) {
393
+ return value !== value;
394
+ }
395
+ var _baseIsNaN = baseIsNaN$1;
396
+ function strictIndexOf$1(array, value, fromIndex) {
397
+ var index = fromIndex - 1, length = array.length;
398
+ while (++index < length) {
399
+ if (array[index] === value) {
400
+ return index;
401
+ }
402
+ }
403
+ return -1;
404
+ }
405
+ var _strictIndexOf = strictIndexOf$1;
406
+ var baseFindIndex$1 = _baseFindIndex, baseIsNaN = _baseIsNaN, strictIndexOf = _strictIndexOf;
407
+ function baseIndexOf$1(array, value, fromIndex) {
408
+ return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex$1(array, baseIsNaN, fromIndex);
409
+ }
410
+ var _baseIndexOf = baseIndexOf$1;
411
+ var baseIndexOf = _baseIndexOf;
412
+ function arrayIncludes$1(array, value) {
413
+ var length = array == null ? 0 : array.length;
414
+ return !!length && baseIndexOf(array, value, 0) > -1;
415
+ }
416
+ var _arrayIncludes = arrayIncludes$1;
417
+ function arrayIncludesWith$1(array, value, comparator) {
418
+ var index = -1, length = array == null ? 0 : array.length;
419
+ while (++index < length) {
420
+ if (comparator(value, array[index])) {
421
+ return true;
422
+ }
423
+ }
424
+ return false;
425
+ }
426
+ var _arrayIncludesWith = arrayIncludesWith$1;
427
+ function cacheHas$2(cache, key) {
428
+ return cache.has(key);
429
+ }
430
+ var _cacheHas = cacheHas$2;
431
+ var getNative$4 = _getNative, root$4 = _root;
432
+ var Set$2 = getNative$4(root$4, "Set");
433
+ var _Set = Set$2;
434
+ function noop$1() {
435
+ }
436
+ var noop_1 = noop$1;
437
+ function setToArray$3(set) {
438
+ var index = -1, result = Array(set.size);
439
+ set.forEach(function(value) {
440
+ result[++index] = value;
441
+ });
442
+ return result;
443
+ }
444
+ var _setToArray = setToArray$3;
445
+ var Set$1 = _Set, noop = noop_1, setToArray$2 = _setToArray;
446
+ var INFINITY$3 = 1 / 0;
447
+ var createSet$1 = !(Set$1 && 1 / setToArray$2(new Set$1([, -0]))[1] == INFINITY$3) ? noop : function(values) {
448
+ return new Set$1(values);
449
+ };
450
+ var _createSet = createSet$1;
451
+ var SetCache$1 = _SetCache, arrayIncludes = _arrayIncludes, arrayIncludesWith = _arrayIncludesWith, cacheHas$1 = _cacheHas, createSet = _createSet, setToArray$1 = _setToArray;
452
+ var LARGE_ARRAY_SIZE$1 = 200;
453
+ function baseUniq$2(array, iteratee, comparator) {
454
+ var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
455
+ if (comparator) {
456
+ isCommon = false;
457
+ includes = arrayIncludesWith;
458
+ } else if (length >= LARGE_ARRAY_SIZE$1) {
459
+ var set = iteratee ? null : createSet(array);
460
+ if (set) {
461
+ return setToArray$1(set);
462
+ }
463
+ isCommon = false;
464
+ includes = cacheHas$1;
465
+ seen = new SetCache$1();
466
+ } else {
467
+ seen = iteratee ? [] : result;
468
+ }
469
+ outer:
470
+ while (++index < length) {
471
+ var value = array[index], computed = iteratee ? iteratee(value) : value;
472
+ value = comparator || value !== 0 ? value : 0;
473
+ if (isCommon && computed === computed) {
474
+ var seenIndex = seen.length;
475
+ while (seenIndex--) {
476
+ if (seen[seenIndex] === computed) {
477
+ continue outer;
478
+ }
479
+ }
480
+ if (iteratee) {
481
+ seen.push(computed);
482
+ }
483
+ result.push(value);
484
+ } else if (!includes(seen, computed, comparator)) {
485
+ if (seen !== result) {
486
+ seen.push(computed);
487
+ }
488
+ result.push(value);
489
+ }
490
+ }
491
+ return result;
492
+ }
493
+ var _baseUniq = baseUniq$2;
494
+ var baseUniq$1 = _baseUniq;
495
+ function uniq(array) {
496
+ return array && array.length ? baseUniq$1(array) : [];
497
+ }
498
+ var uniq_1 = uniq;
499
+ const uniq$1 = /* @__PURE__ */ getDefaultExportFromCjs(uniq_1);
500
+ class MemoryCacheAdapter {
501
+ constructor() {
502
+ __publicField(this, "map");
503
+ this.map = /* @__PURE__ */ new Map();
504
+ }
505
+ get(key) {
506
+ return this.map.get(key);
507
+ }
508
+ has(key) {
509
+ return this.map.has(key);
510
+ }
511
+ set(key, value) {
512
+ this.map.set(key, value);
513
+ }
514
+ flush() {
515
+ this.map = /* @__PURE__ */ new Map();
516
+ }
517
+ }
518
+ class LocalesCache {
519
+ constructor(context) {
520
+ __publicField(this, "context");
521
+ __publicField(this, "cacheAdapter");
522
+ this.context = context;
523
+ this.cacheAdapter = new MemoryCacheAdapter();
524
+ }
525
+ setIfMissed(options) {
526
+ const { metafileFile, metafileLocale, data } = options;
527
+ const key = this.keyFromMetafile({
528
+ metafileFile,
529
+ metafileLocale
530
+ });
531
+ if (!this.cacheAdapter.has(key)) {
532
+ this.cacheAdapter.set(key, data);
533
+ }
534
+ }
535
+ has(options) {
536
+ const key = this.keyFromMetafile(options);
537
+ return this.cacheAdapter.has(key);
538
+ }
539
+ get(options) {
540
+ const key = this.keyFromMetafile(options);
541
+ return this.cacheAdapter.get(key);
542
+ }
543
+ flush() {
544
+ this.cacheAdapter.flush();
545
+ }
546
+ keyFromMetafile(options) {
547
+ const { metafileFile, metafileLocale } = options;
548
+ const productFlavors = [...uniq$1(metafileFile.productFlavors)].sort().join("-");
549
+ const indices = [
550
+ this.context.metafile.params.cdnId,
551
+ metafileFile.id,
552
+ metafileFile.file,
553
+ metafileFile.path,
554
+ metafileFile.library,
555
+ metafileFile.module,
556
+ metafileFile.buildType,
557
+ productFlavors,
558
+ metafileLocale.locale,
559
+ metafileLocale.timestamp.toString()
560
+ ];
561
+ return indices.filter((key) => key !== "").join("-");
562
+ }
563
+ }
564
+ var isArray$b = Array.isArray;
565
+ var isArray_1 = isArray$b;
566
+ const isArray$c = /* @__PURE__ */ getDefaultExportFromCjs(isArray_1);
567
+ function isObjectLike$9(value) {
568
+ return value != null && typeof value == "object";
569
+ }
570
+ var isObjectLike_1 = isObjectLike$9;
571
+ var baseGetTag$5 = _baseGetTag, isArray$a = isArray_1, isObjectLike$8 = isObjectLike_1;
572
+ var stringTag$4 = "[object String]";
573
+ function isString(value) {
574
+ return typeof value == "string" || !isArray$a(value) && isObjectLike$8(value) && baseGetTag$5(value) == stringTag$4;
575
+ }
576
+ var isString_1 = isString;
577
+ const isString$1 = /* @__PURE__ */ getDefaultExportFromCjs(isString_1);
578
+ class CdnBase {
579
+ constructor(context) {
580
+ __publicField(this, "context");
581
+ this.context = context;
582
+ }
583
+ }
584
+ class CdnCache extends CdnBase {
585
+ constructor() {
586
+ super(...arguments);
587
+ __publicField(this, "flush", () => {
588
+ this.context.cache.flush();
589
+ });
590
+ }
591
+ }
592
+ var ListCache$2 = _ListCache;
593
+ function stackClear$1() {
594
+ this.__data__ = new ListCache$2();
595
+ this.size = 0;
596
+ }
597
+ var _stackClear = stackClear$1;
598
+ function stackDelete$1(key) {
599
+ var data = this.__data__, result = data["delete"](key);
600
+ this.size = data.size;
601
+ return result;
602
+ }
603
+ var _stackDelete = stackDelete$1;
604
+ function stackGet$1(key) {
605
+ return this.__data__.get(key);
606
+ }
607
+ var _stackGet = stackGet$1;
608
+ function stackHas$1(key) {
609
+ return this.__data__.has(key);
610
+ }
611
+ var _stackHas = stackHas$1;
612
+ var ListCache$1 = _ListCache, Map$2 = _Map, MapCache$1 = _MapCache;
613
+ var LARGE_ARRAY_SIZE = 200;
614
+ function stackSet$1(key, value) {
615
+ var data = this.__data__;
616
+ if (data instanceof ListCache$1) {
617
+ var pairs = data.__data__;
618
+ if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
619
+ pairs.push([key, value]);
620
+ this.size = ++data.size;
621
+ return this;
622
+ }
623
+ data = this.__data__ = new MapCache$1(pairs);
624
+ }
625
+ data.set(key, value);
626
+ this.size = data.size;
627
+ return this;
628
+ }
629
+ var _stackSet = stackSet$1;
630
+ var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
631
+ function Stack$3(entries) {
632
+ var data = this.__data__ = new ListCache(entries);
633
+ this.size = data.size;
634
+ }
635
+ Stack$3.prototype.clear = stackClear;
636
+ Stack$3.prototype["delete"] = stackDelete;
637
+ Stack$3.prototype.get = stackGet;
638
+ Stack$3.prototype.has = stackHas;
639
+ Stack$3.prototype.set = stackSet;
640
+ var _Stack = Stack$3;
641
+ function arraySome$1(array, predicate) {
642
+ var index = -1, length = array == null ? 0 : array.length;
643
+ while (++index < length) {
644
+ if (predicate(array[index], index, array)) {
645
+ return true;
646
+ }
647
+ }
648
+ return false;
649
+ }
650
+ var _arraySome = arraySome$1;
651
+ var SetCache = _SetCache, arraySome = _arraySome, cacheHas = _cacheHas;
652
+ var COMPARE_PARTIAL_FLAG$5 = 1, COMPARE_UNORDERED_FLAG$3 = 2;
653
+ function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
654
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, arrLength = array.length, othLength = other.length;
655
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
656
+ return false;
657
+ }
658
+ var arrStacked = stack.get(array);
659
+ var othStacked = stack.get(other);
660
+ if (arrStacked && othStacked) {
661
+ return arrStacked == other && othStacked == array;
662
+ }
663
+ var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : void 0;
664
+ stack.set(array, other);
665
+ stack.set(other, array);
666
+ while (++index < arrLength) {
667
+ var arrValue = array[index], othValue = other[index];
668
+ if (customizer) {
669
+ var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
670
+ }
671
+ if (compared !== void 0) {
672
+ if (compared) {
673
+ continue;
674
+ }
675
+ result = false;
676
+ break;
677
+ }
678
+ if (seen) {
679
+ if (!arraySome(other, function(othValue2, othIndex) {
680
+ if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
681
+ return seen.push(othIndex);
682
+ }
683
+ })) {
684
+ result = false;
685
+ break;
686
+ }
687
+ } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
688
+ result = false;
689
+ break;
690
+ }
691
+ }
692
+ stack["delete"](array);
693
+ stack["delete"](other);
694
+ return result;
695
+ }
696
+ var _equalArrays = equalArrays$2;
697
+ var root$3 = _root;
698
+ var Uint8Array$2 = root$3.Uint8Array;
699
+ var _Uint8Array = Uint8Array$2;
700
+ function mapToArray$1(map) {
701
+ var index = -1, result = Array(map.size);
702
+ map.forEach(function(value, key) {
703
+ result[++index] = [key, value];
704
+ });
705
+ return result;
706
+ }
707
+ var _mapToArray = mapToArray$1;
708
+ var Symbol$3 = _Symbol, Uint8Array$1 = _Uint8Array, eq$1 = eq_1, equalArrays$1 = _equalArrays, mapToArray = _mapToArray, setToArray = _setToArray;
709
+ var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
710
+ var boolTag$3 = "[object Boolean]", dateTag$3 = "[object Date]", errorTag$2 = "[object Error]", mapTag$5 = "[object Map]", numberTag$3 = "[object Number]", regexpTag$3 = "[object RegExp]", setTag$5 = "[object Set]", stringTag$3 = "[object String]", symbolTag$3 = "[object Symbol]";
711
+ var arrayBufferTag$3 = "[object ArrayBuffer]", dataViewTag$4 = "[object DataView]";
712
+ var symbolProto$2 = Symbol$3 ? Symbol$3.prototype : void 0, symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : void 0;
713
+ function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
714
+ switch (tag) {
715
+ case dataViewTag$4:
716
+ if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
717
+ return false;
718
+ }
719
+ object = object.buffer;
720
+ other = other.buffer;
721
+ case arrayBufferTag$3:
722
+ if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) {
723
+ return false;
724
+ }
725
+ return true;
726
+ case boolTag$3:
727
+ case dateTag$3:
728
+ case numberTag$3:
729
+ return eq$1(+object, +other);
730
+ case errorTag$2:
731
+ return object.name == other.name && object.message == other.message;
732
+ case regexpTag$3:
733
+ case stringTag$3:
734
+ return object == other + "";
735
+ case mapTag$5:
736
+ var convert = mapToArray;
737
+ case setTag$5:
738
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
739
+ convert || (convert = setToArray);
740
+ if (object.size != other.size && !isPartial) {
741
+ return false;
742
+ }
743
+ var stacked = stack.get(object);
744
+ if (stacked) {
745
+ return stacked == other;
746
+ }
747
+ bitmask |= COMPARE_UNORDERED_FLAG$2;
748
+ stack.set(object, other);
749
+ var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
750
+ stack["delete"](object);
751
+ return result;
752
+ case symbolTag$3:
753
+ if (symbolValueOf$1) {
754
+ return symbolValueOf$1.call(object) == symbolValueOf$1.call(other);
755
+ }
756
+ }
757
+ return false;
758
+ }
759
+ var _equalByTag = equalByTag$1;
760
+ function arrayPush$2(array, values) {
761
+ var index = -1, length = values.length, offset = array.length;
762
+ while (++index < length) {
763
+ array[offset + index] = values[index];
764
+ }
765
+ return array;
766
+ }
767
+ var _arrayPush = arrayPush$2;
768
+ var arrayPush$1 = _arrayPush, isArray$9 = isArray_1;
769
+ function baseGetAllKeys$2(object, keysFunc, symbolsFunc) {
770
+ var result = keysFunc(object);
771
+ return isArray$9(object) ? result : arrayPush$1(result, symbolsFunc(object));
772
+ }
773
+ var _baseGetAllKeys = baseGetAllKeys$2;
774
+ function arrayFilter$2(array, predicate) {
775
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
776
+ while (++index < length) {
777
+ var value = array[index];
778
+ if (predicate(value, index, array)) {
779
+ result[resIndex++] = value;
780
+ }
781
+ }
782
+ return result;
783
+ }
784
+ var _arrayFilter = arrayFilter$2;
785
+ function stubArray$2() {
786
+ return [];
787
+ }
788
+ var stubArray_1 = stubArray$2;
789
+ var arrayFilter$1 = _arrayFilter, stubArray$1 = stubArray_1;
790
+ var objectProto$a = Object.prototype;
791
+ var propertyIsEnumerable$1 = objectProto$a.propertyIsEnumerable;
792
+ var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
793
+ var getSymbols$3 = !nativeGetSymbols$1 ? stubArray$1 : function(object) {
794
+ if (object == null) {
795
+ return [];
796
+ }
797
+ object = Object(object);
798
+ return arrayFilter$1(nativeGetSymbols$1(object), function(symbol) {
799
+ return propertyIsEnumerable$1.call(object, symbol);
800
+ });
801
+ };
802
+ var _getSymbols = getSymbols$3;
803
+ function baseTimes$1(n, iteratee) {
804
+ var index = -1, result = Array(n);
805
+ while (++index < n) {
806
+ result[index] = iteratee(index);
807
+ }
808
+ return result;
809
+ }
810
+ var _baseTimes = baseTimes$1;
811
+ var baseGetTag$4 = _baseGetTag, isObjectLike$7 = isObjectLike_1;
812
+ var argsTag$3 = "[object Arguments]";
813
+ function baseIsArguments$1(value) {
814
+ return isObjectLike$7(value) && baseGetTag$4(value) == argsTag$3;
815
+ }
816
+ var _baseIsArguments = baseIsArguments$1;
817
+ var baseIsArguments = _baseIsArguments, isObjectLike$6 = isObjectLike_1;
818
+ var objectProto$9 = Object.prototype;
819
+ var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
820
+ var propertyIsEnumerable = objectProto$9.propertyIsEnumerable;
821
+ var isArguments$2 = baseIsArguments(/* @__PURE__ */ function() {
822
+ return arguments;
823
+ }()) ? baseIsArguments : function(value) {
824
+ return isObjectLike$6(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
825
+ };
826
+ var isArguments_1 = isArguments$2;
827
+ var isBuffer$3 = { exports: {} };
828
+ function stubFalse() {
829
+ return false;
830
+ }
831
+ var stubFalse_1 = stubFalse;
832
+ isBuffer$3.exports;
833
+ (function(module2, exports2) {
834
+ var root2 = _root, stubFalse2 = stubFalse_1;
835
+ var freeExports = exports2 && !exports2.nodeType && exports2;
836
+ var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
837
+ var moduleExports = freeModule && freeModule.exports === freeExports;
838
+ var Buffer2 = moduleExports ? root2.Buffer : void 0;
839
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
840
+ var isBuffer2 = nativeIsBuffer || stubFalse2;
841
+ module2.exports = isBuffer2;
842
+ })(isBuffer$3, isBuffer$3.exports);
843
+ var isBufferExports = isBuffer$3.exports;
844
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
845
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
846
+ function isIndex$2(value, length) {
847
+ var type = typeof value;
848
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
849
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
850
+ }
851
+ var _isIndex = isIndex$2;
852
+ var MAX_SAFE_INTEGER = 9007199254740991;
853
+ function isLength$3(value) {
854
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
855
+ }
856
+ var isLength_1 = isLength$3;
857
+ var baseGetTag$3 = _baseGetTag, isLength$2 = isLength_1, isObjectLike$5 = isObjectLike_1;
858
+ var argsTag$2 = "[object Arguments]", arrayTag$2 = "[object Array]", boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", errorTag$1 = "[object Error]", funcTag$1 = "[object Function]", mapTag$4 = "[object Map]", numberTag$2 = "[object Number]", objectTag$4 = "[object Object]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", weakMapTag$2 = "[object WeakMap]";
859
+ var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$3 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
860
+ var typedArrayTags = {};
861
+ typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
862
+ typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] = typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] = typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] = typedArrayTags[objectTag$4] = typedArrayTags[regexpTag$2] = typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] = typedArrayTags[weakMapTag$2] = false;
863
+ function baseIsTypedArray$1(value) {
864
+ return isObjectLike$5(value) && isLength$2(value.length) && !!typedArrayTags[baseGetTag$3(value)];
865
+ }
866
+ var _baseIsTypedArray = baseIsTypedArray$1;
867
+ function baseUnary$3(func) {
868
+ return function(value) {
869
+ return func(value);
870
+ };
871
+ }
872
+ var _baseUnary = baseUnary$3;
873
+ var _nodeUtil = { exports: {} };
874
+ _nodeUtil.exports;
875
+ (function(module2, exports2) {
876
+ var freeGlobal2 = _freeGlobal;
877
+ var freeExports = exports2 && !exports2.nodeType && exports2;
878
+ var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
879
+ var moduleExports = freeModule && freeModule.exports === freeExports;
880
+ var freeProcess = moduleExports && freeGlobal2.process;
881
+ var nodeUtil2 = function() {
882
+ try {
883
+ var types = freeModule && freeModule.require && freeModule.require("util").types;
884
+ if (types) {
885
+ return types;
886
+ }
887
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
888
+ } catch (e) {
889
+ }
890
+ }();
891
+ module2.exports = nodeUtil2;
892
+ })(_nodeUtil, _nodeUtil.exports);
893
+ var _nodeUtilExports = _nodeUtil.exports;
894
+ var baseIsTypedArray = _baseIsTypedArray, baseUnary$2 = _baseUnary, nodeUtil$2 = _nodeUtilExports;
895
+ var nodeIsTypedArray = nodeUtil$2 && nodeUtil$2.isTypedArray;
896
+ var isTypedArray$2 = nodeIsTypedArray ? baseUnary$2(nodeIsTypedArray) : baseIsTypedArray;
897
+ var isTypedArray_1 = isTypedArray$2;
898
+ var baseTimes = _baseTimes, isArguments$1 = isArguments_1, isArray$8 = isArray_1, isBuffer$2 = isBufferExports, isIndex$1 = _isIndex, isTypedArray$1 = isTypedArray_1;
899
+ var objectProto$8 = Object.prototype;
900
+ var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
901
+ function arrayLikeKeys$2(value, inherited) {
902
+ var isArr = isArray$8(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$2(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
903
+ for (var key in value) {
904
+ if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
905
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
906
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
907
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
908
+ isIndex$1(key, length)))) {
909
+ result.push(key);
910
+ }
911
+ }
912
+ return result;
913
+ }
914
+ var _arrayLikeKeys = arrayLikeKeys$2;
915
+ var objectProto$7 = Object.prototype;
916
+ function isPrototype$3(value) {
917
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$7;
918
+ return value === proto;
919
+ }
920
+ var _isPrototype = isPrototype$3;
921
+ function overArg$2(func, transform) {
922
+ return function(arg) {
923
+ return func(transform(arg));
924
+ };
925
+ }
926
+ var _overArg = overArg$2;
927
+ var overArg$1 = _overArg;
928
+ var nativeKeys$1 = overArg$1(Object.keys, Object);
929
+ var _nativeKeys = nativeKeys$1;
930
+ var isPrototype$2 = _isPrototype, nativeKeys = _nativeKeys;
931
+ var objectProto$6 = Object.prototype;
932
+ var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
933
+ function baseKeys$1(object) {
934
+ if (!isPrototype$2(object)) {
935
+ return nativeKeys(object);
936
+ }
937
+ var result = [];
938
+ for (var key in Object(object)) {
939
+ if (hasOwnProperty$6.call(object, key) && key != "constructor") {
940
+ result.push(key);
941
+ }
942
+ }
943
+ return result;
944
+ }
945
+ var _baseKeys = baseKeys$1;
946
+ var isFunction = isFunction_1, isLength$1 = isLength_1;
947
+ function isArrayLike$4(value) {
948
+ return value != null && isLength$1(value.length) && !isFunction(value);
949
+ }
950
+ var isArrayLike_1 = isArrayLike$4;
951
+ var arrayLikeKeys$1 = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike$3 = isArrayLike_1;
952
+ function keys$6(object) {
953
+ return isArrayLike$3(object) ? arrayLikeKeys$1(object) : baseKeys(object);
954
+ }
955
+ var keys_1 = keys$6;
956
+ var baseGetAllKeys$1 = _baseGetAllKeys, getSymbols$2 = _getSymbols, keys$5 = keys_1;
957
+ function getAllKeys$2(object) {
958
+ return baseGetAllKeys$1(object, keys$5, getSymbols$2);
959
+ }
960
+ var _getAllKeys = getAllKeys$2;
961
+ var getAllKeys$1 = _getAllKeys;
962
+ var COMPARE_PARTIAL_FLAG$3 = 1;
963
+ var objectProto$5 = Object.prototype;
964
+ var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
965
+ function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
966
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys$1(object), objLength = objProps.length, othProps = getAllKeys$1(other), othLength = othProps.length;
967
+ if (objLength != othLength && !isPartial) {
968
+ return false;
969
+ }
970
+ var index = objLength;
971
+ while (index--) {
972
+ var key = objProps[index];
973
+ if (!(isPartial ? key in other : hasOwnProperty$5.call(other, key))) {
974
+ return false;
975
+ }
976
+ }
977
+ var objStacked = stack.get(object);
978
+ var othStacked = stack.get(other);
979
+ if (objStacked && othStacked) {
980
+ return objStacked == other && othStacked == object;
981
+ }
982
+ var result = true;
983
+ stack.set(object, other);
984
+ stack.set(other, object);
985
+ var skipCtor = isPartial;
986
+ while (++index < objLength) {
987
+ key = objProps[index];
988
+ var objValue = object[key], othValue = other[key];
989
+ if (customizer) {
990
+ var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
991
+ }
992
+ if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
993
+ result = false;
994
+ break;
995
+ }
996
+ skipCtor || (skipCtor = key == "constructor");
997
+ }
998
+ if (result && !skipCtor) {
999
+ var objCtor = object.constructor, othCtor = other.constructor;
1000
+ if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
1001
+ result = false;
1002
+ }
1003
+ }
1004
+ stack["delete"](object);
1005
+ stack["delete"](other);
1006
+ return result;
1007
+ }
1008
+ var _equalObjects = equalObjects$1;
1009
+ var getNative$3 = _getNative, root$2 = _root;
1010
+ var DataView$1 = getNative$3(root$2, "DataView");
1011
+ var _DataView = DataView$1;
1012
+ var getNative$2 = _getNative, root$1 = _root;
1013
+ var Promise$2 = getNative$2(root$1, "Promise");
1014
+ var _Promise = Promise$2;
1015
+ var getNative$1 = _getNative, root = _root;
1016
+ var WeakMap$1 = getNative$1(root, "WeakMap");
1017
+ var _WeakMap = WeakMap$1;
1018
+ var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set = _Set, WeakMap = _WeakMap, baseGetTag$2 = _baseGetTag, toSource = _toSource;
1019
+ var mapTag$3 = "[object Map]", objectTag$3 = "[object Object]", promiseTag = "[object Promise]", setTag$3 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
1020
+ var dataViewTag$2 = "[object DataView]";
1021
+ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap);
1022
+ var getTag$4 = baseGetTag$2;
1023
+ if (DataView && getTag$4(new DataView(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag$4(new Map$1()) != mapTag$3 || Promise$1 && getTag$4(Promise$1.resolve()) != promiseTag || Set && getTag$4(new Set()) != setTag$3 || WeakMap && getTag$4(new WeakMap()) != weakMapTag$1) {
1024
+ getTag$4 = function(value) {
1025
+ var result = baseGetTag$2(value), Ctor = result == objectTag$3 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
1026
+ if (ctorString) {
1027
+ switch (ctorString) {
1028
+ case dataViewCtorString:
1029
+ return dataViewTag$2;
1030
+ case mapCtorString:
1031
+ return mapTag$3;
1032
+ case promiseCtorString:
1033
+ return promiseTag;
1034
+ case setCtorString:
1035
+ return setTag$3;
1036
+ case weakMapCtorString:
1037
+ return weakMapTag$1;
1038
+ }
1039
+ }
1040
+ return result;
1041
+ };
1042
+ }
1043
+ var _getTag = getTag$4;
1044
+ var Stack$2 = _Stack, equalArrays = _equalArrays, equalByTag = _equalByTag, equalObjects = _equalObjects, getTag$3 = _getTag, isArray$7 = isArray_1, isBuffer$1 = isBufferExports, isTypedArray = isTypedArray_1;
1045
+ var COMPARE_PARTIAL_FLAG$2 = 1;
1046
+ var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", objectTag$2 = "[object Object]";
1047
+ var objectProto$4 = Object.prototype;
1048
+ var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
1049
+ function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
1050
+ var objIsArr = isArray$7(object), othIsArr = isArray$7(other), objTag = objIsArr ? arrayTag$1 : getTag$3(object), othTag = othIsArr ? arrayTag$1 : getTag$3(other);
1051
+ objTag = objTag == argsTag$1 ? objectTag$2 : objTag;
1052
+ othTag = othTag == argsTag$1 ? objectTag$2 : othTag;
1053
+ var objIsObj = objTag == objectTag$2, othIsObj = othTag == objectTag$2, isSameTag = objTag == othTag;
1054
+ if (isSameTag && isBuffer$1(object)) {
1055
+ if (!isBuffer$1(other)) {
1056
+ return false;
1057
+ }
1058
+ objIsArr = true;
1059
+ objIsObj = false;
1060
+ }
1061
+ if (isSameTag && !objIsObj) {
1062
+ stack || (stack = new Stack$2());
1063
+ return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1064
+ }
1065
+ if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
1066
+ var objIsWrapped = objIsObj && hasOwnProperty$4.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$4.call(other, "__wrapped__");
1067
+ if (objIsWrapped || othIsWrapped) {
1068
+ var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
1069
+ stack || (stack = new Stack$2());
1070
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1071
+ }
1072
+ }
1073
+ if (!isSameTag) {
1074
+ return false;
1075
+ }
1076
+ stack || (stack = new Stack$2());
1077
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1078
+ }
1079
+ var _baseIsEqualDeep = baseIsEqualDeep$1;
1080
+ var baseIsEqualDeep = _baseIsEqualDeep, isObjectLike$4 = isObjectLike_1;
1081
+ function baseIsEqual$2(value, other, bitmask, customizer, stack) {
1082
+ if (value === other) {
1083
+ return true;
1084
+ }
1085
+ if (value == null || other == null || !isObjectLike$4(value) && !isObjectLike$4(other)) {
1086
+ return value !== value && other !== other;
1087
+ }
1088
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$2, stack);
1089
+ }
1090
+ var _baseIsEqual = baseIsEqual$2;
1091
+ var Stack$1 = _Stack, baseIsEqual$1 = _baseIsEqual;
1092
+ var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
1093
+ function baseIsMatch$1(object, source, matchData, customizer) {
1094
+ var index = matchData.length, length = index, noCustomizer = !customizer;
1095
+ if (object == null) {
1096
+ return !length;
1097
+ }
1098
+ object = Object(object);
1099
+ while (index--) {
1100
+ var data = matchData[index];
1101
+ if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
1102
+ return false;
1103
+ }
1104
+ }
1105
+ while (++index < length) {
1106
+ data = matchData[index];
1107
+ var key = data[0], objValue = object[key], srcValue = data[1];
1108
+ if (noCustomizer && data[2]) {
1109
+ if (objValue === void 0 && !(key in object)) {
1110
+ return false;
1111
+ }
1112
+ } else {
1113
+ var stack = new Stack$1();
1114
+ if (customizer) {
1115
+ var result = customizer(objValue, srcValue, key, object, source, stack);
1116
+ }
1117
+ if (!(result === void 0 ? baseIsEqual$1(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
1118
+ return false;
1119
+ }
1120
+ }
1121
+ }
1122
+ return true;
1123
+ }
1124
+ var _baseIsMatch = baseIsMatch$1;
1125
+ var isObject$4 = isObject_1;
1126
+ function isStrictComparable$2(value) {
1127
+ return value === value && !isObject$4(value);
1128
+ }
1129
+ var _isStrictComparable = isStrictComparable$2;
1130
+ var isStrictComparable$1 = _isStrictComparable, keys$4 = keys_1;
1131
+ function getMatchData$1(object) {
1132
+ var result = keys$4(object), length = result.length;
1133
+ while (length--) {
1134
+ var key = result[length], value = object[key];
1135
+ result[length] = [key, value, isStrictComparable$1(value)];
1136
+ }
1137
+ return result;
1138
+ }
1139
+ var _getMatchData = getMatchData$1;
1140
+ function matchesStrictComparable$2(key, srcValue) {
1141
+ return function(object) {
1142
+ if (object == null) {
1143
+ return false;
1144
+ }
1145
+ return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
1146
+ };
1147
+ }
1148
+ var _matchesStrictComparable = matchesStrictComparable$2;
1149
+ var baseIsMatch = _baseIsMatch, getMatchData = _getMatchData, matchesStrictComparable$1 = _matchesStrictComparable;
1150
+ function baseMatches$2(source) {
1151
+ var matchData = getMatchData(source);
1152
+ if (matchData.length == 1 && matchData[0][2]) {
1153
+ return matchesStrictComparable$1(matchData[0][0], matchData[0][1]);
1154
+ }
1155
+ return function(object) {
1156
+ return object === source || baseIsMatch(object, source, matchData);
1157
+ };
1158
+ }
1159
+ var _baseMatches = baseMatches$2;
1160
+ var baseGetTag$1 = _baseGetTag, isObjectLike$3 = isObjectLike_1;
1161
+ var symbolTag$2 = "[object Symbol]";
1162
+ function isSymbol$4(value) {
1163
+ return typeof value == "symbol" || isObjectLike$3(value) && baseGetTag$1(value) == symbolTag$2;
1164
+ }
1165
+ var isSymbol_1 = isSymbol$4;
1166
+ var isArray$6 = isArray_1, isSymbol$3 = isSymbol_1;
1167
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
1168
+ function isKey$3(value, object) {
1169
+ if (isArray$6(value)) {
1170
+ return false;
1171
+ }
1172
+ var type = typeof value;
1173
+ if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$3(value)) {
1174
+ return true;
1175
+ }
1176
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
1177
+ }
1178
+ var _isKey = isKey$3;
1179
+ var MapCache = _MapCache;
1180
+ var FUNC_ERROR_TEXT = "Expected a function";
1181
+ function memoize$1(func, resolver) {
1182
+ if (typeof func != "function" || resolver != null && typeof resolver != "function") {
1183
+ throw new TypeError(FUNC_ERROR_TEXT);
1184
+ }
1185
+ var memoized = function() {
1186
+ var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
1187
+ if (cache.has(key)) {
1188
+ return cache.get(key);
1189
+ }
1190
+ var result = func.apply(this, args);
1191
+ memoized.cache = cache.set(key, result) || cache;
1192
+ return result;
1193
+ };
1194
+ memoized.cache = new (memoize$1.Cache || MapCache)();
1195
+ return memoized;
1196
+ }
1197
+ memoize$1.Cache = MapCache;
1198
+ var memoize_1 = memoize$1;
1199
+ var memoize = memoize_1;
1200
+ var MAX_MEMOIZE_SIZE = 500;
1201
+ function memoizeCapped$1(func) {
1202
+ var result = memoize(func, function(key) {
1203
+ if (cache.size === MAX_MEMOIZE_SIZE) {
1204
+ cache.clear();
1205
+ }
1206
+ return key;
1207
+ });
1208
+ var cache = result.cache;
1209
+ return result;
1210
+ }
1211
+ var _memoizeCapped = memoizeCapped$1;
1212
+ var memoizeCapped = _memoizeCapped;
1213
+ var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1214
+ var reEscapeChar = /\\(\\)?/g;
1215
+ var stringToPath$1 = memoizeCapped(function(string) {
1216
+ var result = [];
1217
+ if (string.charCodeAt(0) === 46) {
1218
+ result.push("");
1219
+ }
1220
+ string.replace(rePropName, function(match, number, quote, subString) {
1221
+ result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
1222
+ });
1223
+ return result;
1224
+ });
1225
+ var _stringToPath = stringToPath$1;
1226
+ function arrayMap$1(array, iteratee) {
1227
+ var index = -1, length = array == null ? 0 : array.length, result = Array(length);
1228
+ while (++index < length) {
1229
+ result[index] = iteratee(array[index], index, array);
1230
+ }
1231
+ return result;
1232
+ }
1233
+ var _arrayMap = arrayMap$1;
1234
+ var Symbol$2 = _Symbol, arrayMap = _arrayMap, isArray$5 = isArray_1, isSymbol$2 = isSymbol_1;
1235
+ var INFINITY$2 = 1 / 0;
1236
+ var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
1237
+ function baseToString$1(value) {
1238
+ if (typeof value == "string") {
1239
+ return value;
1240
+ }
1241
+ if (isArray$5(value)) {
1242
+ return arrayMap(value, baseToString$1) + "";
1243
+ }
1244
+ if (isSymbol$2(value)) {
1245
+ return symbolToString ? symbolToString.call(value) : "";
1246
+ }
1247
+ var result = value + "";
1248
+ return result == "0" && 1 / value == -INFINITY$2 ? "-0" : result;
1249
+ }
1250
+ var _baseToString = baseToString$1;
1251
+ var baseToString = _baseToString;
1252
+ function toString$1(value) {
1253
+ return value == null ? "" : baseToString(value);
1254
+ }
1255
+ var toString_1 = toString$1;
1256
+ var isArray$4 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString = toString_1;
1257
+ function castPath$2(value, object) {
1258
+ if (isArray$4(value)) {
1259
+ return value;
1260
+ }
1261
+ return isKey$2(value, object) ? [value] : stringToPath(toString(value));
1262
+ }
1263
+ var _castPath = castPath$2;
1264
+ var isSymbol$1 = isSymbol_1;
1265
+ var INFINITY$1 = 1 / 0;
1266
+ function toKey$4(value) {
1267
+ if (typeof value == "string" || isSymbol$1(value)) {
1268
+ return value;
1269
+ }
1270
+ var result = value + "";
1271
+ return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
1272
+ }
1273
+ var _toKey = toKey$4;
1274
+ var castPath$1 = _castPath, toKey$3 = _toKey;
1275
+ function baseGet$2(object, path) {
1276
+ path = castPath$1(path, object);
1277
+ var index = 0, length = path.length;
1278
+ while (object != null && index < length) {
1279
+ object = object[toKey$3(path[index++])];
1280
+ }
1281
+ return index && index == length ? object : void 0;
1282
+ }
1283
+ var _baseGet = baseGet$2;
1284
+ var baseGet$1 = _baseGet;
1285
+ function get$1(object, path, defaultValue) {
1286
+ var result = object == null ? void 0 : baseGet$1(object, path);
1287
+ return result === void 0 ? defaultValue : result;
1288
+ }
1289
+ var get_1 = get$1;
1290
+ function baseHasIn$1(object, key) {
1291
+ return object != null && key in Object(object);
1292
+ }
1293
+ var _baseHasIn = baseHasIn$1;
1294
+ var castPath = _castPath, isArguments = isArguments_1, isArray$3 = isArray_1, isIndex = _isIndex, isLength = isLength_1, toKey$2 = _toKey;
1295
+ function hasPath$1(object, path, hasFunc) {
1296
+ path = castPath(path, object);
1297
+ var index = -1, length = path.length, result = false;
1298
+ while (++index < length) {
1299
+ var key = toKey$2(path[index]);
1300
+ if (!(result = object != null && hasFunc(object, key))) {
1301
+ break;
1302
+ }
1303
+ object = object[key];
1304
+ }
1305
+ if (result || ++index != length) {
1306
+ return result;
1307
+ }
1308
+ length = object == null ? 0 : object.length;
1309
+ return !!length && isLength(length) && isIndex(key, length) && (isArray$3(object) || isArguments(object));
1310
+ }
1311
+ var _hasPath = hasPath$1;
1312
+ var baseHasIn = _baseHasIn, hasPath = _hasPath;
1313
+ function hasIn$1(object, path) {
1314
+ return object != null && hasPath(object, path, baseHasIn);
1315
+ }
1316
+ var hasIn_1 = hasIn$1;
1317
+ var baseIsEqual = _baseIsEqual, get = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$1 = _toKey;
1318
+ var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
1319
+ function baseMatchesProperty$1(path, srcValue) {
1320
+ if (isKey$1(path) && isStrictComparable(srcValue)) {
1321
+ return matchesStrictComparable(toKey$1(path), srcValue);
1322
+ }
1323
+ return function(object) {
1324
+ var objValue = get(object, path);
1325
+ return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
1326
+ };
1327
+ }
1328
+ var _baseMatchesProperty = baseMatchesProperty$1;
1329
+ function identity$1(value) {
1330
+ return value;
1331
+ }
1332
+ var identity_1 = identity$1;
1333
+ function baseProperty$1(key) {
1334
+ return function(object) {
1335
+ return object == null ? void 0 : object[key];
1336
+ };
1337
+ }
1338
+ var _baseProperty = baseProperty$1;
1339
+ var baseGet = _baseGet;
1340
+ function basePropertyDeep$1(path) {
1341
+ return function(object) {
1342
+ return baseGet(object, path);
1343
+ };
1344
+ }
1345
+ var _basePropertyDeep = basePropertyDeep$1;
1346
+ var baseProperty = _baseProperty, basePropertyDeep = _basePropertyDeep, isKey = _isKey, toKey = _toKey;
1347
+ function property$1(path) {
1348
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
1349
+ }
1350
+ var property_1 = property$1;
1351
+ var baseMatches$1 = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity = identity_1, isArray$2 = isArray_1, property = property_1;
1352
+ function baseIteratee$4(value) {
1353
+ if (typeof value == "function") {
1354
+ return value;
1355
+ }
1356
+ if (value == null) {
1357
+ return identity;
1358
+ }
1359
+ if (typeof value == "object") {
1360
+ return isArray$2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches$1(value);
1361
+ }
1362
+ return property(value);
1363
+ }
1364
+ var _baseIteratee = baseIteratee$4;
1365
+ var baseIteratee$3 = _baseIteratee, baseUniq = _baseUniq;
1366
+ function uniqBy(array, iteratee) {
1367
+ return array && array.length ? baseUniq(array, baseIteratee$3(iteratee)) : [];
1368
+ }
1369
+ var uniqBy_1 = uniqBy;
1370
+ const uniqBy$1 = /* @__PURE__ */ getDefaultExportFromCjs(uniqBy_1);
1371
+ class MetafileLocale {
1372
+ constructor(options, baseLocale) {
1373
+ __publicField(this, "language");
1374
+ __publicField(this, "region");
1375
+ __publicField(this, "script");
1376
+ __publicField(this, "isRtl");
1377
+ __publicField(this, "name");
1378
+ __publicField(this, "localizedName");
1379
+ __publicField(this, "uri");
1380
+ __publicField(this, "timestamp");
1381
+ __publicField(this, "baseLocale");
1382
+ this.language = options.language;
1383
+ this.region = options.region;
1384
+ this.script = options.script;
1385
+ this.isRtl = options.isRtl;
1386
+ this.name = options.name;
1387
+ this.localizedName = options.localizedName;
1388
+ this.uri = options.uri;
1389
+ this.timestamp = options.timestamp;
1390
+ this.baseLocale = baseLocale;
1391
+ }
1392
+ get locale() {
1393
+ if (this.language && this.region && this.script) {
1394
+ return `${this.language}_${this.region}#${this.script}`;
1395
+ }
1396
+ if (this.language && this.script) {
1397
+ return `${this.language}#${this.script}`;
1398
+ }
1399
+ if (this.language && this.region) {
1400
+ return `${this.language}_${this.region}`;
1401
+ }
1402
+ return this.language;
1403
+ }
1404
+ get isBaseLocale() {
1405
+ return this.locale === this.baseLocale;
1406
+ }
1407
+ toCdnLocale() {
1408
+ return {
1409
+ locale: this.locale,
1410
+ isBaseLocale: this.isBaseLocale,
1411
+ language: this.language,
1412
+ region: this.region,
1413
+ script: this.script,
1414
+ isRtl: this.isRtl,
1415
+ name: this.name,
1416
+ localizedName: this.localizedName
1417
+ };
1418
+ }
1419
+ }
1420
+ class MetafileFile {
1421
+ constructor(options) {
1422
+ __publicField(this, "id");
1423
+ __publicField(this, "file");
1424
+ __publicField(this, "path");
1425
+ __publicField(this, "library");
1426
+ __publicField(this, "module");
1427
+ __publicField(this, "buildType");
1428
+ __publicField(this, "timestamp");
1429
+ __publicField(this, "productFlavors");
1430
+ __publicField(this, "locales");
1431
+ __publicField(this, "baseUrl");
1432
+ this.id = options.id;
1433
+ this.file = options.file;
1434
+ this.path = options.path;
1435
+ this.library = options.library;
1436
+ this.module = options.module;
1437
+ this.buildType = options.buildType;
1438
+ this.timestamp = options.timestamp;
1439
+ this.productFlavors = options.productFlavors;
1440
+ this.locales = options.locales;
1441
+ this.baseUrl = options.baseUrl;
1442
+ }
1443
+ toCdnFile() {
1444
+ return {
1445
+ id: this.id,
1446
+ file: this.file,
1447
+ path: this.path,
1448
+ library: this.library,
1449
+ module: this.module,
1450
+ buildType: this.buildType,
1451
+ productFlavors: this.productFlavors,
1452
+ locales: this.locales.map((locale) => ({
1453
+ locale: locale.locale,
1454
+ isBaseLocale: locale.isBaseLocale,
1455
+ uri: `${this.baseUrl}${locale.uri}`
1456
+ }))
1457
+ };
1458
+ }
1459
+ }
1460
+ class MetafileData {
1461
+ constructor(options, params) {
1462
+ __publicField(this, "projectUrl");
1463
+ __publicField(this, "baseLocale");
1464
+ __publicField(this, "locales");
1465
+ __publicField(this, "timestamp");
1466
+ __publicField(this, "files");
1467
+ __publicField(this, "filesMap");
1468
+ this.projectUrl = options.projectUrl;
1469
+ this.timestamp = options.timestamp;
1470
+ this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);
1471
+ this.filesMap = MetafileData.filesMapFactory(this.files);
1472
+ this.locales = MetafileData.localesFactory(this.files);
1473
+ this.baseLocale = this.locales.find((locale) => locale.isBaseLocale);
1474
+ }
1475
+ static createEmpty(params) {
1476
+ return new MetafileData(
1477
+ {
1478
+ projectUrl: "",
1479
+ baseLocale: "",
1480
+ timestamp: 0,
1481
+ files: {}
1482
+ },
1483
+ params
1484
+ );
1485
+ }
1486
+ static filesFactory(files, baseLocale, params) {
1487
+ return Object.keys(files).reduce(
1488
+ (acc, cur) => {
1489
+ const locales = files[cur].locales.map(
1490
+ (locale) => new MetafileLocale(locale, baseLocale)
1491
+ );
1492
+ acc.push(
1493
+ new MetafileFile({
1494
+ ...files[cur],
1495
+ id: cur,
1496
+ locales,
1497
+ baseUrl: params.baseUrl
1498
+ })
1499
+ );
1500
+ return acc;
1501
+ },
1502
+ []
1503
+ );
1504
+ }
1505
+ static filesMapFactory(files) {
1506
+ return files.reduce(
1507
+ (acc, cur) => {
1508
+ acc[cur.id] = cur;
1509
+ return acc;
1510
+ },
1511
+ {}
1512
+ );
1513
+ }
1514
+ static localesFactory(files) {
1515
+ const locales = files.reduce(
1516
+ (acc, cur) => {
1517
+ acc.push(
1518
+ ...cur.locales.map(
1519
+ (locale) => locale.toCdnLocale()
1520
+ )
1521
+ );
1522
+ return acc;
1523
+ },
1524
+ []
1525
+ );
1526
+ return uniqBy$1(locales, (cdnLocale) => cdnLocale.locale);
1527
+ }
1528
+ }
1529
+ class MetafileParams {
1530
+ constructor(metafileUrl) {
1531
+ __publicField(this, "options");
1532
+ this.options = MetafileParams.parseMetafileUrl(metafileUrl);
1533
+ }
1534
+ get url() {
1535
+ return this.options.url;
1536
+ }
1537
+ get baseUrl() {
1538
+ return this.options.baseUrl;
1539
+ }
1540
+ get cdnId() {
1541
+ return this.options.cdnId;
1542
+ }
1543
+ get jsonPath() {
1544
+ return this.options.jsonPath;
1545
+ }
1546
+ static parseMetafileUrl(metafileUrl) {
1547
+ let url;
1548
+ try {
1549
+ url = new URL(metafileUrl);
1550
+ } catch (e) {
1551
+ throw new Error('Invalid param: "options.metafile" cannot be parsed as url.');
1552
+ }
1553
+ const matches2 = url.pathname.match(/^\/(.*?)\/(.*?)\.(v2.json|js|ts)$/);
1554
+ if (matches2 === null || matches2.length !== 4) {
1555
+ throw new Error('Invalid param: "options.metafile" contains invalid metafile url.');
1556
+ }
1557
+ const cdnId = matches2[1];
1558
+ const tagId = matches2[2];
1559
+ return {
1560
+ url: metafileUrl,
1561
+ baseUrl: url.origin,
1562
+ cdnId,
1563
+ jsonPath: `/${cdnId}/${tagId}.v2.json`
1564
+ };
1565
+ }
1566
+ }
1567
+ class MetafileContext {
1568
+ constructor(options) {
1569
+ __publicField(this, "params");
1570
+ __publicField(this, "parsedData");
1571
+ __publicField(this, "data");
1572
+ this.params = new MetafileParams(options.metafile);
1573
+ this.parsedData = null;
1574
+ this.data = MetafileData.createEmpty(this.params);
1575
+ }
1576
+ setMetafile(metafile) {
1577
+ this.parsedData = metafile;
1578
+ this.data = new MetafileData(metafile, this.params);
1579
+ }
1580
+ }
1581
+ class ResponseFactory {
1582
+ constructor(context) {
1583
+ __publicField(this, "context");
1584
+ this.context = context;
1585
+ }
1586
+ createCdnResponse(options) {
1587
+ const { responses, hasSingleFileResponse, hasSingleLocaleResponse } = options;
1588
+ if (responses.length === 0) {
1589
+ return {};
1590
+ }
1591
+ this.cacheResponses(responses);
1592
+ return hasSingleFileResponse && hasSingleLocaleResponse ? responses[0].data : ResponseFactory.transformResponsesToOutput(options);
1593
+ }
1594
+ cacheResponses(responses) {
1595
+ responses.forEach((response) => {
1596
+ const {
1597
+ metafileFile,
1598
+ metafileLocale
1599
+ } = ResponseFactory.extractReference(response);
1600
+ if (metafileFile && metafileLocale) {
1601
+ this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response.data });
1602
+ }
1603
+ });
1604
+ }
1605
+ static transformResponsesToOutput(options) {
1606
+ const { responses, hasSingleFileResponse } = options;
1607
+ return responses.reduce(
1608
+ (acc, cur) => {
1609
+ const {
1610
+ metafileFile,
1611
+ metafileLocale
1612
+ } = ResponseFactory.extractReference(cur);
1613
+ if (metafileFile && metafileLocale) {
1614
+ if (hasSingleFileResponse) {
1615
+ acc[metafileLocale.locale] = cur.data;
1616
+ } else {
1617
+ if (!acc[metafileFile.id]) {
1618
+ acc[metafileFile.id] = {};
1619
+ }
1620
+ acc[metafileFile.id][metafileLocale.locale] = cur.data;
1621
+ }
1622
+ }
1623
+ return acc;
1624
+ },
1625
+ {}
1626
+ );
1627
+ }
1628
+ static extractReference(response) {
1629
+ var _a, _b;
1630
+ const metafileFile = (_a = response.config.reference) == null ? void 0 : _a.metafileFile;
1631
+ const metafileLocale = (_b = response.config.reference) == null ? void 0 : _b.metafileLocale;
1632
+ const { data } = response;
1633
+ return {
1634
+ metafileFile,
1635
+ metafileLocale,
1636
+ data
1637
+ };
1638
+ }
1639
+ }
1640
+ class Context {
1641
+ constructor(options) {
1642
+ __publicField(this, "metafile");
1643
+ __publicField(this, "cdn");
1644
+ __publicField(this, "client");
1645
+ __publicField(this, "api");
1646
+ __publicField(this, "cache");
1647
+ __publicField(this, "responseFactory");
1648
+ this.metafile = options.metafileContext;
1649
+ this.cdn = options.cdn;
1650
+ this.client = options.client;
1651
+ this.api = new Api(this);
1652
+ this.cache = new LocalesCache(this);
1653
+ this.responseFactory = new ResponseFactory(this);
1654
+ }
1655
+ }
1656
+ function createBaseFor$1(fromRight) {
1657
+ return function(object, iteratee, keysFunc) {
1658
+ var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
1659
+ while (length--) {
1660
+ var key = props[fromRight ? length : ++index];
1661
+ if (iteratee(iterable[key], key, iterable) === false) {
1662
+ break;
1663
+ }
1664
+ }
1665
+ return object;
1666
+ };
1667
+ }
1668
+ var _createBaseFor = createBaseFor$1;
1669
+ var createBaseFor = _createBaseFor;
1670
+ var baseFor$1 = createBaseFor();
1671
+ var _baseFor = baseFor$1;
1672
+ var baseFor = _baseFor, keys$3 = keys_1;
1673
+ function baseForOwn$1(object, iteratee) {
1674
+ return object && baseFor(object, iteratee, keys$3);
1675
+ }
1676
+ var _baseForOwn = baseForOwn$1;
1677
+ var isArrayLike$2 = isArrayLike_1;
1678
+ function createBaseEach$1(eachFunc, fromRight) {
1679
+ return function(collection, iteratee) {
1680
+ if (collection == null) {
1681
+ return collection;
1682
+ }
1683
+ if (!isArrayLike$2(collection)) {
1684
+ return eachFunc(collection, iteratee);
1685
+ }
1686
+ var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
1687
+ while (fromRight ? index-- : ++index < length) {
1688
+ if (iteratee(iterable[index], index, iterable) === false) {
1689
+ break;
1690
+ }
1691
+ }
1692
+ return collection;
1693
+ };
1694
+ }
1695
+ var _createBaseEach = createBaseEach$1;
1696
+ var baseForOwn = _baseForOwn, createBaseEach = _createBaseEach;
1697
+ var baseEach$1 = createBaseEach(baseForOwn);
1698
+ var _baseEach = baseEach$1;
1699
+ var baseEach = _baseEach;
1700
+ function baseFilter$1(collection, predicate) {
1701
+ var result = [];
1702
+ baseEach(collection, function(value, index, collection2) {
1703
+ if (predicate(value, index, collection2)) {
1704
+ result.push(value);
1705
+ }
1706
+ });
1707
+ return result;
1708
+ }
1709
+ var _baseFilter = baseFilter$1;
1710
+ var arrayFilter = _arrayFilter, baseFilter = _baseFilter, baseIteratee$2 = _baseIteratee, isArray$1 = isArray_1;
1711
+ function filter(collection, predicate) {
1712
+ var func = isArray$1(collection) ? arrayFilter : baseFilter;
1713
+ return func(collection, baseIteratee$2(predicate));
1714
+ }
1715
+ var filter_1 = filter;
1716
+ const filter$1 = /* @__PURE__ */ getDefaultExportFromCjs(filter_1);
1717
+ var baseIteratee$1 = _baseIteratee, isArrayLike$1 = isArrayLike_1, keys$2 = keys_1;
1718
+ function createFind$1(findIndexFunc) {
1719
+ return function(collection, predicate, fromIndex) {
1720
+ var iterable = Object(collection);
1721
+ if (!isArrayLike$1(collection)) {
1722
+ var iteratee = baseIteratee$1(predicate);
1723
+ collection = keys$2(collection);
1724
+ predicate = function(key) {
1725
+ return iteratee(iterable[key], key, iterable);
1726
+ };
1727
+ }
1728
+ var index = findIndexFunc(collection, predicate, fromIndex);
1729
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : void 0;
1730
+ };
1731
+ }
1732
+ var _createFind = createFind$1;
1733
+ var reWhitespace = /\s/;
1734
+ function trimmedEndIndex$1(string) {
1735
+ var index = string.length;
1736
+ while (index-- && reWhitespace.test(string.charAt(index))) {
1737
+ }
1738
+ return index;
1739
+ }
1740
+ var _trimmedEndIndex = trimmedEndIndex$1;
1741
+ var trimmedEndIndex = _trimmedEndIndex;
1742
+ var reTrimStart = /^\s+/;
1743
+ function baseTrim$1(string) {
1744
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
1745
+ }
1746
+ var _baseTrim = baseTrim$1;
1747
+ var baseTrim = _baseTrim, isObject$3 = isObject_1, isSymbol = isSymbol_1;
1748
+ var NAN = 0 / 0;
1749
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1750
+ var reIsBinary = /^0b[01]+$/i;
1751
+ var reIsOctal = /^0o[0-7]+$/i;
1752
+ var freeParseInt = parseInt;
1753
+ function toNumber$1(value) {
1754
+ if (typeof value == "number") {
1755
+ return value;
1756
+ }
1757
+ if (isSymbol(value)) {
1758
+ return NAN;
1759
+ }
1760
+ if (isObject$3(value)) {
1761
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
1762
+ value = isObject$3(other) ? other + "" : other;
1763
+ }
1764
+ if (typeof value != "string") {
1765
+ return value === 0 ? value : +value;
1766
+ }
1767
+ value = baseTrim(value);
1768
+ var isBinary = reIsBinary.test(value);
1769
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
1770
+ }
1771
+ var toNumber_1 = toNumber$1;
1772
+ var toNumber = toNumber_1;
1773
+ var INFINITY = 1 / 0, MAX_INTEGER = 17976931348623157e292;
1774
+ function toFinite$1(value) {
1775
+ if (!value) {
1776
+ return value === 0 ? value : 0;
1777
+ }
1778
+ value = toNumber(value);
1779
+ if (value === INFINITY || value === -INFINITY) {
1780
+ var sign = value < 0 ? -1 : 1;
1781
+ return sign * MAX_INTEGER;
1782
+ }
1783
+ return value === value ? value : 0;
1784
+ }
1785
+ var toFinite_1 = toFinite$1;
1786
+ var toFinite = toFinite_1;
1787
+ function toInteger$1(value) {
1788
+ var result = toFinite(value), remainder = result % 1;
1789
+ return result === result ? remainder ? result - remainder : result : 0;
1790
+ }
1791
+ var toInteger_1 = toInteger$1;
1792
+ var baseFindIndex = _baseFindIndex, baseIteratee = _baseIteratee, toInteger = toInteger_1;
1793
+ var nativeMax = Math.max;
1794
+ function findIndex$1(array, predicate, fromIndex) {
1795
+ var length = array == null ? 0 : array.length;
1796
+ if (!length) {
1797
+ return -1;
1798
+ }
1799
+ var index = fromIndex == null ? 0 : toInteger(fromIndex);
1800
+ if (index < 0) {
1801
+ index = nativeMax(length + index, 0);
1802
+ }
1803
+ return baseFindIndex(array, baseIteratee(predicate), index);
1804
+ }
1805
+ var findIndex_1 = findIndex$1;
1806
+ var createFind = _createFind, findIndex = findIndex_1;
1807
+ var find = createFind(findIndex);
1808
+ var find_1 = find;
1809
+ const find$1 = /* @__PURE__ */ getDefaultExportFromCjs(find_1);
1810
+ var overArg = _overArg;
1811
+ var getPrototype$3 = overArg(Object.getPrototypeOf, Object);
1812
+ var _getPrototype = getPrototype$3;
1813
+ var baseGetTag = _baseGetTag, getPrototype$2 = _getPrototype, isObjectLike$2 = isObjectLike_1;
1814
+ var objectTag$1 = "[object Object]";
1815
+ var funcProto = Function.prototype, objectProto$3 = Object.prototype;
1816
+ var funcToString = funcProto.toString;
1817
+ var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
1818
+ var objectCtorString = funcToString.call(Object);
1819
+ function isPlainObject(value) {
1820
+ if (!isObjectLike$2(value) || baseGetTag(value) != objectTag$1) {
1821
+ return false;
1822
+ }
1823
+ var proto = getPrototype$2(value);
1824
+ if (proto === null) {
1825
+ return true;
1826
+ }
1827
+ var Ctor = hasOwnProperty$3.call(proto, "constructor") && proto.constructor;
1828
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
1829
+ }
1830
+ var isPlainObject_1 = isPlainObject;
1831
+ const isPlainObject$1 = /* @__PURE__ */ getDefaultExportFromCjs(isPlainObject_1);
1832
+ function arrayEach$1(array, iteratee) {
1833
+ var index = -1, length = array == null ? 0 : array.length;
1834
+ while (++index < length) {
1835
+ if (iteratee(array[index], index, array) === false) {
1836
+ break;
1837
+ }
1838
+ }
1839
+ return array;
1840
+ }
1841
+ var _arrayEach = arrayEach$1;
1842
+ var getNative = _getNative;
1843
+ var defineProperty$1 = function() {
1844
+ try {
1845
+ var func = getNative(Object, "defineProperty");
1846
+ func({}, "", {});
1847
+ return func;
1848
+ } catch (e) {
1849
+ }
1850
+ }();
1851
+ var _defineProperty = defineProperty$1;
1852
+ var defineProperty = _defineProperty;
1853
+ function baseAssignValue$2(object, key, value) {
1854
+ if (key == "__proto__" && defineProperty) {
1855
+ defineProperty(object, key, {
1856
+ "configurable": true,
1857
+ "enumerable": true,
1858
+ "value": value,
1859
+ "writable": true
1860
+ });
1861
+ } else {
1862
+ object[key] = value;
1863
+ }
1864
+ }
1865
+ var _baseAssignValue = baseAssignValue$2;
1866
+ var baseAssignValue$1 = _baseAssignValue, eq = eq_1;
1867
+ var objectProto$2 = Object.prototype;
1868
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
1869
+ function assignValue$2(object, key, value) {
1870
+ var objValue = object[key];
1871
+ if (!(hasOwnProperty$2.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
1872
+ baseAssignValue$1(object, key, value);
1873
+ }
1874
+ }
1875
+ var _assignValue = assignValue$2;
1876
+ var assignValue$1 = _assignValue, baseAssignValue = _baseAssignValue;
1877
+ function copyObject$4(source, props, object, customizer) {
1878
+ var isNew = !object;
1879
+ object || (object = {});
1880
+ var index = -1, length = props.length;
1881
+ while (++index < length) {
1882
+ var key = props[index];
1883
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
1884
+ if (newValue === void 0) {
1885
+ newValue = source[key];
1886
+ }
1887
+ if (isNew) {
1888
+ baseAssignValue(object, key, newValue);
1889
+ } else {
1890
+ assignValue$1(object, key, newValue);
1891
+ }
1892
+ }
1893
+ return object;
1894
+ }
1895
+ var _copyObject = copyObject$4;
1896
+ var copyObject$3 = _copyObject, keys$1 = keys_1;
1897
+ function baseAssign$1(object, source) {
1898
+ return object && copyObject$3(source, keys$1(source), object);
1899
+ }
1900
+ var _baseAssign = baseAssign$1;
1901
+ function nativeKeysIn$1(object) {
1902
+ var result = [];
1903
+ if (object != null) {
1904
+ for (var key in Object(object)) {
1905
+ result.push(key);
1906
+ }
1907
+ }
1908
+ return result;
1909
+ }
1910
+ var _nativeKeysIn = nativeKeysIn$1;
1911
+ var isObject$2 = isObject_1, isPrototype$1 = _isPrototype, nativeKeysIn = _nativeKeysIn;
1912
+ var objectProto$1 = Object.prototype;
1913
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1914
+ function baseKeysIn$1(object) {
1915
+ if (!isObject$2(object)) {
1916
+ return nativeKeysIn(object);
1917
+ }
1918
+ var isProto = isPrototype$1(object), result = [];
1919
+ for (var key in object) {
1920
+ if (!(key == "constructor" && (isProto || !hasOwnProperty$1.call(object, key)))) {
1921
+ result.push(key);
1922
+ }
1923
+ }
1924
+ return result;
1925
+ }
1926
+ var _baseKeysIn = baseKeysIn$1;
1927
+ var arrayLikeKeys = _arrayLikeKeys, baseKeysIn = _baseKeysIn, isArrayLike = isArrayLike_1;
1928
+ function keysIn$3(object) {
1929
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
1930
+ }
1931
+ var keysIn_1 = keysIn$3;
1932
+ var copyObject$2 = _copyObject, keysIn$2 = keysIn_1;
1933
+ function baseAssignIn$1(object, source) {
1934
+ return object && copyObject$2(source, keysIn$2(source), object);
1935
+ }
1936
+ var _baseAssignIn = baseAssignIn$1;
1937
+ var _cloneBuffer = { exports: {} };
1938
+ _cloneBuffer.exports;
1939
+ (function(module2, exports2) {
1940
+ var root2 = _root;
1941
+ var freeExports = exports2 && !exports2.nodeType && exports2;
1942
+ var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
1943
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1944
+ var Buffer2 = moduleExports ? root2.Buffer : void 0, allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : void 0;
1945
+ function cloneBuffer2(buffer, isDeep) {
1946
+ if (isDeep) {
1947
+ return buffer.slice();
1948
+ }
1949
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
1950
+ buffer.copy(result);
1951
+ return result;
1952
+ }
1953
+ module2.exports = cloneBuffer2;
1954
+ })(_cloneBuffer, _cloneBuffer.exports);
1955
+ var _cloneBufferExports = _cloneBuffer.exports;
1956
+ function copyArray$1(source, array) {
1957
+ var index = -1, length = source.length;
1958
+ array || (array = Array(length));
1959
+ while (++index < length) {
1960
+ array[index] = source[index];
1961
+ }
1962
+ return array;
1963
+ }
1964
+ var _copyArray = copyArray$1;
1965
+ var copyObject$1 = _copyObject, getSymbols$1 = _getSymbols;
1966
+ function copySymbols$1(source, object) {
1967
+ return copyObject$1(source, getSymbols$1(source), object);
1968
+ }
1969
+ var _copySymbols = copySymbols$1;
1970
+ var arrayPush = _arrayPush, getPrototype$1 = _getPrototype, getSymbols = _getSymbols, stubArray = stubArray_1;
1971
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1972
+ var getSymbolsIn$2 = !nativeGetSymbols ? stubArray : function(object) {
1973
+ var result = [];
1974
+ while (object) {
1975
+ arrayPush(result, getSymbols(object));
1976
+ object = getPrototype$1(object);
1977
+ }
1978
+ return result;
1979
+ };
1980
+ var _getSymbolsIn = getSymbolsIn$2;
1981
+ var copyObject = _copyObject, getSymbolsIn$1 = _getSymbolsIn;
1982
+ function copySymbolsIn$1(source, object) {
1983
+ return copyObject(source, getSymbolsIn$1(source), object);
1984
+ }
1985
+ var _copySymbolsIn = copySymbolsIn$1;
1986
+ var baseGetAllKeys = _baseGetAllKeys, getSymbolsIn = _getSymbolsIn, keysIn$1 = keysIn_1;
1987
+ function getAllKeysIn$1(object) {
1988
+ return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
1989
+ }
1990
+ var _getAllKeysIn = getAllKeysIn$1;
1991
+ var objectProto = Object.prototype;
1992
+ var hasOwnProperty = objectProto.hasOwnProperty;
1993
+ function initCloneArray$1(array) {
1994
+ var length = array.length, result = new array.constructor(length);
1995
+ if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) {
1996
+ result.index = array.index;
1997
+ result.input = array.input;
1998
+ }
1999
+ return result;
2000
+ }
2001
+ var _initCloneArray = initCloneArray$1;
2002
+ var Uint8Array2 = _Uint8Array;
2003
+ function cloneArrayBuffer$3(arrayBuffer) {
2004
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2005
+ new Uint8Array2(result).set(new Uint8Array2(arrayBuffer));
2006
+ return result;
2007
+ }
2008
+ var _cloneArrayBuffer = cloneArrayBuffer$3;
2009
+ var cloneArrayBuffer$2 = _cloneArrayBuffer;
2010
+ function cloneDataView$1(dataView, isDeep) {
2011
+ var buffer = isDeep ? cloneArrayBuffer$2(dataView.buffer) : dataView.buffer;
2012
+ return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
2013
+ }
2014
+ var _cloneDataView = cloneDataView$1;
2015
+ var reFlags = /\w*$/;
2016
+ function cloneRegExp$1(regexp) {
2017
+ var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
2018
+ result.lastIndex = regexp.lastIndex;
2019
+ return result;
2020
+ }
2021
+ var _cloneRegExp = cloneRegExp$1;
2022
+ var Symbol$1 = _Symbol;
2023
+ var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
2024
+ function cloneSymbol$1(symbol) {
2025
+ return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
2026
+ }
2027
+ var _cloneSymbol = cloneSymbol$1;
2028
+ var cloneArrayBuffer$1 = _cloneArrayBuffer;
2029
+ function cloneTypedArray$1(typedArray, isDeep) {
2030
+ var buffer = isDeep ? cloneArrayBuffer$1(typedArray.buffer) : typedArray.buffer;
2031
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2032
+ }
2033
+ var _cloneTypedArray = cloneTypedArray$1;
2034
+ var cloneArrayBuffer = _cloneArrayBuffer, cloneDataView = _cloneDataView, cloneRegExp = _cloneRegExp, cloneSymbol = _cloneSymbol, cloneTypedArray = _cloneTypedArray;
2035
+ var boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]";
2036
+ var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
2037
+ function initCloneByTag$1(object, tag, isDeep) {
2038
+ var Ctor = object.constructor;
2039
+ switch (tag) {
2040
+ case arrayBufferTag$1:
2041
+ return cloneArrayBuffer(object);
2042
+ case boolTag$1:
2043
+ case dateTag$1:
2044
+ return new Ctor(+object);
2045
+ case dataViewTag$1:
2046
+ return cloneDataView(object, isDeep);
2047
+ case float32Tag$1:
2048
+ case float64Tag$1:
2049
+ case int8Tag$1:
2050
+ case int16Tag$1:
2051
+ case int32Tag$1:
2052
+ case uint8Tag$1:
2053
+ case uint8ClampedTag$1:
2054
+ case uint16Tag$1:
2055
+ case uint32Tag$1:
2056
+ return cloneTypedArray(object, isDeep);
2057
+ case mapTag$2:
2058
+ return new Ctor();
2059
+ case numberTag$1:
2060
+ case stringTag$1:
2061
+ return new Ctor(object);
2062
+ case regexpTag$1:
2063
+ return cloneRegExp(object);
2064
+ case setTag$2:
2065
+ return new Ctor();
2066
+ case symbolTag$1:
2067
+ return cloneSymbol(object);
2068
+ }
2069
+ }
2070
+ var _initCloneByTag = initCloneByTag$1;
2071
+ var isObject$1 = isObject_1;
2072
+ var objectCreate = Object.create;
2073
+ var baseCreate$1 = /* @__PURE__ */ function() {
2074
+ function object() {
2075
+ }
2076
+ return function(proto) {
2077
+ if (!isObject$1(proto)) {
2078
+ return {};
2079
+ }
2080
+ if (objectCreate) {
2081
+ return objectCreate(proto);
2082
+ }
2083
+ object.prototype = proto;
2084
+ var result = new object();
2085
+ object.prototype = void 0;
2086
+ return result;
2087
+ };
2088
+ }();
2089
+ var _baseCreate = baseCreate$1;
2090
+ var baseCreate = _baseCreate, getPrototype = _getPrototype, isPrototype = _isPrototype;
2091
+ function initCloneObject$1(object) {
2092
+ return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
2093
+ }
2094
+ var _initCloneObject = initCloneObject$1;
2095
+ var getTag$2 = _getTag, isObjectLike$1 = isObjectLike_1;
2096
+ var mapTag$1 = "[object Map]";
2097
+ function baseIsMap$1(value) {
2098
+ return isObjectLike$1(value) && getTag$2(value) == mapTag$1;
2099
+ }
2100
+ var _baseIsMap = baseIsMap$1;
2101
+ var baseIsMap = _baseIsMap, baseUnary$1 = _baseUnary, nodeUtil$1 = _nodeUtilExports;
2102
+ var nodeIsMap = nodeUtil$1 && nodeUtil$1.isMap;
2103
+ var isMap$1 = nodeIsMap ? baseUnary$1(nodeIsMap) : baseIsMap;
2104
+ var isMap_1 = isMap$1;
2105
+ var getTag$1 = _getTag, isObjectLike = isObjectLike_1;
2106
+ var setTag$1 = "[object Set]";
2107
+ function baseIsSet$1(value) {
2108
+ return isObjectLike(value) && getTag$1(value) == setTag$1;
2109
+ }
2110
+ var _baseIsSet = baseIsSet$1;
2111
+ var baseIsSet = _baseIsSet, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
2112
+ var nodeIsSet = nodeUtil && nodeUtil.isSet;
2113
+ var isSet$1 = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
2114
+ var isSet_1 = isSet$1;
2115
+ var Stack = _Stack, arrayEach = _arrayEach, assignValue = _assignValue, baseAssign = _baseAssign, baseAssignIn = _baseAssignIn, cloneBuffer = _cloneBufferExports, copyArray = _copyArray, copySymbols = _copySymbols, copySymbolsIn = _copySymbolsIn, getAllKeys = _getAllKeys, getAllKeysIn = _getAllKeysIn, getTag = _getTag, initCloneArray = _initCloneArray, initCloneByTag = _initCloneByTag, initCloneObject = _initCloneObject, isArray = isArray_1, isBuffer = isBufferExports, isMap = isMap_1, isObject = isObject_1, isSet = isSet_1, keys = keys_1, keysIn = keysIn_1;
2116
+ var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
2117
+ var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
2118
+ var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
2119
+ var cloneableTags = {};
2120
+ cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
2121
+ cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
2122
+ function baseClone$1(value, bitmask, customizer, key, object, stack) {
2123
+ var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
2124
+ if (customizer) {
2125
+ result = object ? customizer(value, key, object, stack) : customizer(value);
2126
+ }
2127
+ if (result !== void 0) {
2128
+ return result;
2129
+ }
2130
+ if (!isObject(value)) {
2131
+ return value;
2132
+ }
2133
+ var isArr = isArray(value);
2134
+ if (isArr) {
2135
+ result = initCloneArray(value);
2136
+ if (!isDeep) {
2137
+ return copyArray(value, result);
2138
+ }
2139
+ } else {
2140
+ var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
2141
+ if (isBuffer(value)) {
2142
+ return cloneBuffer(value, isDeep);
2143
+ }
2144
+ if (tag == objectTag || tag == argsTag || isFunc && !object) {
2145
+ result = isFlat || isFunc ? {} : initCloneObject(value);
2146
+ if (!isDeep) {
2147
+ return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
2148
+ }
2149
+ } else {
2150
+ if (!cloneableTags[tag]) {
2151
+ return object ? value : {};
2152
+ }
2153
+ result = initCloneByTag(value, tag, isDeep);
2154
+ }
2155
+ }
2156
+ stack || (stack = new Stack());
2157
+ var stacked = stack.get(value);
2158
+ if (stacked) {
2159
+ return stacked;
2160
+ }
2161
+ stack.set(value, result);
2162
+ if (isSet(value)) {
2163
+ value.forEach(function(subValue) {
2164
+ result.add(baseClone$1(subValue, bitmask, customizer, subValue, value, stack));
2165
+ });
2166
+ } else if (isMap(value)) {
2167
+ value.forEach(function(subValue, key2) {
2168
+ result.set(key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
2169
+ });
2170
+ }
2171
+ var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
2172
+ var props = isArr ? void 0 : keysFunc(value);
2173
+ arrayEach(props || value, function(subValue, key2) {
2174
+ if (props) {
2175
+ key2 = subValue;
2176
+ subValue = value[key2];
2177
+ }
2178
+ assignValue(result, key2, baseClone$1(subValue, bitmask, customizer, key2, value, stack));
2179
+ });
2180
+ return result;
2181
+ }
2182
+ var _baseClone = baseClone$1;
2183
+ var baseClone = _baseClone, baseMatches = _baseMatches;
2184
+ var CLONE_DEEP_FLAG = 1;
2185
+ function matches(source) {
2186
+ return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
2187
+ }
2188
+ var matches_1 = matches;
2189
+ const matches$1 = /* @__PURE__ */ getDefaultExportFromCjs(matches_1);
2190
+ const _CdnMetafileFiles = class _CdnMetafileFiles extends CdnBase {
2191
+ constructor() {
2192
+ super(...arguments);
2193
+ __publicField(this, "list", () => _CdnMetafileFiles.transformFiles(this.context.metafile.data.files));
2194
+ __publicField(this, "filter", (options) => {
2195
+ if (!options) {
2196
+ throw new Error('Invalid param: missing required "options" parameter.');
2197
+ }
2198
+ if (!isFunction$3(options) && !isPlainObject$1(options)) {
2199
+ throw new Error('Invalid param: "options" must be function or object.');
2200
+ }
2201
+ const files = _CdnMetafileFiles.transformFiles(this.context.metafile.data.files);
2202
+ if (isFunction$3(options)) {
2203
+ return files.filter(options);
2204
+ }
2205
+ return filter$1(files, matches$1(options));
2206
+ });
2207
+ __publicField(this, "find", (options) => {
2208
+ if (!options) {
2209
+ throw new Error('Invalid param: missing required "options" parameter.');
2210
+ }
2211
+ if (!isFunction$3(options) && !isPlainObject$1(options)) {
2212
+ throw new Error('Invalid param: "options" must be function or object.');
2213
+ }
2214
+ const files = _CdnMetafileFiles.transformFiles(this.context.metafile.data.files);
2215
+ if (isFunction$3(options)) {
2216
+ return files.find(options);
2217
+ }
2218
+ return find$1(files, matches$1(options));
2219
+ });
2220
+ __publicField(this, "first", () => {
2221
+ if (this.context.metafile.data.files.length === 0) {
2222
+ throw new Error("File is missing in downloaded metafile.");
2223
+ }
2224
+ const files = _CdnMetafileFiles.transformFiles(this.context.metafile.data.files);
2225
+ return files[0];
2226
+ });
2227
+ }
2228
+ };
2229
+ __publicField(_CdnMetafileFiles, "transformFiles", (files) => files.map(
2230
+ (file) => file.toCdnFile()
2231
+ ));
2232
+ let CdnMetafileFiles = _CdnMetafileFiles;
2233
+ class CdnMetafile extends CdnBase {
2234
+ constructor(context) {
2235
+ super(context);
2236
+ __publicField(this, "files");
2237
+ __publicField(this, "locales", (options) => {
2238
+ const { excludeBaseLocale } = options || {};
2239
+ const { locales } = this.context.metafile.data;
2240
+ return excludeBaseLocale ? locales.filter((cdnLocale) => !cdnLocale.isBaseLocale) : locales;
2241
+ });
2242
+ __publicField(this, "refresh", async (config) => {
2243
+ const response = await this.context.api.fetchMetafile(config);
2244
+ this.context.metafile.setMetafile(response.data);
2245
+ });
2246
+ __publicField(this, "switch", async (options, config) => {
2247
+ this.context.metafile.params = new MetafileParams(options.metafile);
2248
+ await this.refresh(config);
2249
+ });
2250
+ this.files = new CdnMetafileFiles(context);
2251
+ }
2252
+ get projectUrl() {
2253
+ return this.context.metafile.data.projectUrl;
2254
+ }
2255
+ get baseLocale() {
2256
+ return this.context.metafile.data.baseLocale;
2257
+ }
2258
+ get url() {
2259
+ return this.context.metafile.params.url;
2260
+ }
2261
+ }
2262
+ function isUndefined(value) {
2263
+ return value === void 0;
2264
+ }
2265
+ var isUndefined_1 = isUndefined;
2266
+ const isUndefined$1 = /* @__PURE__ */ getDefaultExportFromCjs(isUndefined_1);
2267
+ class LocalesMap {
2268
+ constructor(options) {
2269
+ __publicField(this, "data");
2270
+ __publicField(this, "context");
2271
+ this.context = options.context;
2272
+ this.data = options.data || {};
2273
+ }
2274
+ }
2275
+ class Request {
2276
+ constructor(context) {
2277
+ __publicField(this, "files");
2278
+ __publicField(this, "localesMap");
2279
+ __publicField(this, "hasSingleFileResponse");
2280
+ __publicField(this, "hasSingleLocaleResponse");
2281
+ __publicField(this, "context");
2282
+ this.files = [];
2283
+ this.localesMap = new LocalesMap({ context });
2284
+ this.hasSingleFileResponse = false;
2285
+ this.hasSingleLocaleResponse = false;
2286
+ this.context = context;
2287
+ }
2288
+ async execute() {
2289
+ return this.context.responseFactory.createCdnResponse({
2290
+ responses: await Promise.all(this.getPromises()),
2291
+ localesMap: this.localesMap,
2292
+ hasSingleFileResponse: this.hasSingleFileResponse,
2293
+ hasSingleLocaleResponse: this.hasSingleLocaleResponse
2294
+ });
2295
+ }
2296
+ getPromises() {
2297
+ return this.files.reduce(
2298
+ (acc, cur) => {
2299
+ if (this.localesMap.data[cur.id]) {
2300
+ acc.push(
2301
+ ...this.localesMap.data[cur.id].map(
2302
+ (metafileLocale) => this.context.api.fetchLocale({
2303
+ metafileFile: cur,
2304
+ metafileLocale
2305
+ })
2306
+ )
2307
+ );
2308
+ }
2309
+ return acc;
2310
+ },
2311
+ []
2312
+ );
2313
+ }
2314
+ }
2315
+ class RequestBuilder {
2316
+ constructor(context) {
2317
+ __publicField(this, "context");
2318
+ __publicField(this, "request");
2319
+ this.context = context;
2320
+ this.request = new Request(this.context);
2321
+ }
2322
+ addFiles(files) {
2323
+ if (!(isPlainObject$1(files) || isString$1(files) || isUndefined$1(files) || isArray$c(files))) {
2324
+ throw new Error('Invalid param: "request.files" must be object, array, string or undefined.');
2325
+ }
2326
+ if (isArray$c(files)) {
2327
+ files.forEach((i) => {
2328
+ if (!(isPlainObject$1(i) || isString$1(i))) {
2329
+ throw new Error('Invalid param: array "request.files" must contain objects or strings.');
2330
+ }
2331
+ });
2332
+ }
2333
+ if (isString$1(files)) {
2334
+ this.request.hasSingleFileResponse = true;
2335
+ const file = this.context.metafile.data.files.find(
2336
+ (i) => i.id === files
2337
+ );
2338
+ if (!(file instanceof MetafileFile)) {
2339
+ throw new Error(`File not found: "${files}".`);
2340
+ }
2341
+ this.request.files = [file];
2342
+ } else if (isUndefined$1(files)) {
2343
+ this.request.files = [...this.context.metafile.data.files];
2344
+ } else if (isArray$c(files)) {
2345
+ this.request.files = files.map((file) => {
2346
+ let metafileFile;
2347
+ if (isString$1(file)) {
2348
+ const foundFile = this.context.metafile.data.files.find(
2349
+ (i) => i.id === file
2350
+ );
2351
+ if (isUndefined$1(foundFile)) {
2352
+ throw new Error(`File not found: "${file}".`);
2353
+ }
2354
+ metafileFile = foundFile;
2355
+ } else {
2356
+ const foundFile = this.context.metafile.data.files.find(
2357
+ (i) => i.id === file.id
2358
+ );
2359
+ if (isUndefined$1(foundFile)) {
2360
+ throw new Error(`File not found: "${file.id}".`);
2361
+ }
2362
+ metafileFile = foundFile;
2363
+ }
2364
+ return metafileFile;
2365
+ });
2366
+ } else if (isPlainObject$1(files)) {
2367
+ this.request.hasSingleFileResponse = true;
2368
+ const foundFile = this.context.metafile.data.files.find(
2369
+ (i) => i.id === files.id
2370
+ );
2371
+ if (isUndefined$1(foundFile)) {
2372
+ throw new Error(`File not found: "${files.id}".`);
2373
+ }
2374
+ this.request.files = [foundFile];
2375
+ }
2376
+ return this;
2377
+ }
2378
+ addLocales(locales, excludeBaseLocale) {
2379
+ if (!(isString$1(locales) || isUndefined$1(locales) || isArray$c(locales))) {
2380
+ throw new Error('Invalid param: "request.locales" must be array, string or undefined.');
2381
+ }
2382
+ if (isArray$c(locales)) {
2383
+ locales.forEach((i) => {
2384
+ if (!isString$1(i)) {
2385
+ throw new Error('Invalid param: array "request.locales" must contain strings.');
2386
+ }
2387
+ });
2388
+ }
2389
+ if (isString$1(locales)) {
2390
+ this.request.hasSingleLocaleResponse = true;
2391
+ this.request.files.reduce(
2392
+ (acc, cur) => {
2393
+ acc.data[cur.id] = cur.locales.filter(
2394
+ (metafileLocale) => metafileLocale.locale === locales
2395
+ );
2396
+ return acc;
2397
+ },
2398
+ this.request.localesMap
2399
+ );
2400
+ } else if (isUndefined$1(locales)) {
2401
+ this.request.files.reduce(
2402
+ (acc, cur) => {
2403
+ acc.data[cur.id] = excludeBaseLocale ? cur.locales.filter((metafileLocale) => !metafileLocale.isBaseLocale) : cur.locales;
2404
+ return acc;
2405
+ },
2406
+ this.request.localesMap
2407
+ );
2408
+ } else if (isArray$c(locales)) {
2409
+ this.request.files.reduce(
2410
+ (acc, cur) => {
2411
+ acc.data[cur.id] = cur.locales.filter(
2412
+ (metafileLocale) => locales.includes(metafileLocale.locale)
2413
+ );
2414
+ return acc;
2415
+ },
2416
+ this.request.localesMap
2417
+ );
2418
+ }
2419
+ return this;
2420
+ }
2421
+ getCdnRequest() {
2422
+ const result = this.request;
2423
+ this.request = new Request(this.context);
2424
+ return result;
2425
+ }
2426
+ }
2427
+ class AxiosHttpAdapter {
2428
+ constructor(baseUrl, config) {
2429
+ __publicField(this, "client");
2430
+ this.client = AxiosHttpAdapter.clientFactory(baseUrl, config);
2431
+ }
2432
+ static clientFactory(baseURL, config) {
2433
+ const clientConfig = { baseURL, ...config };
2434
+ return axios.create(clientConfig);
2435
+ }
2436
+ get(url, config) {
2437
+ return this.client.get(url, config);
2438
+ }
2439
+ }
2440
+ class CdnClient {
2441
+ constructor(options, config) {
2442
+ __publicField(this, "metafile");
2443
+ __publicField(this, "cache");
2444
+ __publicField(this, "context");
2445
+ __publicField(this, "fetch", async (options) => {
2446
+ const { files, locales, excludeBaseLocale } = options || {};
2447
+ const requestBuilder = new RequestBuilder(this.context).addFiles(files).addLocales(locales, excludeBaseLocale);
2448
+ return requestBuilder.getCdnRequest().execute();
2449
+ });
2450
+ const metafileContext = new MetafileContext(options);
2451
+ const client = new AxiosHttpAdapter(metafileContext.params.baseUrl, config);
2452
+ this.context = new Context({ metafileContext, cdn: this, client });
2453
+ this.metafile = new CdnMetafile(this.context);
2454
+ this.cache = new CdnCache(this.context);
2455
+ }
2456
+ static async create(options, config) {
2457
+ if (!options) {
2458
+ throw new Error('Invalid param: missing required "options" parameter.');
2459
+ }
2460
+ if (!isString$1(options.metafile)) {
2461
+ throw new Error('Invalid param: "options.metafile" must be string.');
2462
+ }
2463
+ const cdn = new CdnClient(options, config);
2464
+ await cdn.metafile.refresh(config);
2465
+ return cdn;
2466
+ }
2467
+ }
2468
+ exports.Api = Api;
2469
+ exports.AxiosHttpAdapter = AxiosHttpAdapter;
2470
+ exports.CdnBase = CdnBase;
2471
+ exports.CdnCache = CdnCache;
2472
+ exports.CdnClient = CdnClient;
2473
+ exports.CdnMetafile = CdnMetafile;
2474
+ exports.CdnMetafileFiles = CdnMetafileFiles;
2475
+ exports.Context = Context;
2476
+ exports.LocalesCache = LocalesCache;
2477
+ exports.LocalesMap = LocalesMap;
2478
+ exports.MemoryCacheAdapter = MemoryCacheAdapter;
2479
+ exports.MetafileContext = MetafileContext;
2480
+ exports.MetafileData = MetafileData;
2481
+ exports.MetafileFile = MetafileFile;
2482
+ exports.MetafileLocale = MetafileLocale;
2483
+ exports.MetafileParams = MetafileParams;
2484
+ exports.Request = Request;
2485
+ exports.RequestBuilder = RequestBuilder;
2486
+ exports.ResponseFactory = ResponseFactory;
2487
+ //# sourceMappingURL=localazy-cdn.cjs.map