watermark-js-plus 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/ie/index.cjs.js +4451 -0
  2. package/dist/ie/index.cjs.js.map +1 -0
  3. package/dist/ie/index.cjs.min.js +1 -0
  4. package/dist/ie/index.esm.js +4447 -0
  5. package/dist/ie/index.esm.js.map +1 -0
  6. package/dist/ie/index.esm.min.js +1 -0
  7. package/dist/ie/index.iife.js +4456 -0
  8. package/dist/ie/index.iife.js.map +1 -0
  9. package/dist/ie/index.iife.min.js +1 -0
  10. package/dist/ie/index.umd.js +4457 -0
  11. package/dist/ie/index.umd.js.map +1 -0
  12. package/dist/ie/index.umd.min.js +1 -0
  13. package/dist/ie/types/src/core/blind.d.ts +18 -0
  14. package/dist/ie/types/src/core/canvas.d.ts +51 -0
  15. package/dist/ie/types/src/core/image.d.ts +22 -0
  16. package/dist/ie/types/src/core/layout/grid.d.ts +14 -0
  17. package/dist/ie/types/src/core/layout/index.d.ts +4 -0
  18. package/dist/ie/types/src/core/watermark.d.ts +48 -0
  19. package/dist/ie/types/src/index.d.ts +5 -0
  20. package/dist/ie/types/src/index.ie.d.ts +6 -0
  21. package/dist/ie/types/src/style/index.d.ts +1 -0
  22. package/dist/ie/types/src/types/index.d.ts +127 -0
  23. package/dist/ie/types/src/utils/bootstrap.d.ts +2 -0
  24. package/dist/ie/types/src/utils/index.d.ts +14 -0
  25. package/dist/ie/types/src/utils/initialization.d.ts +19 -0
  26. package/dist/ie/types/tests/core/blind.test.d.ts +1 -0
  27. package/dist/ie/types/tests/core/image.test.d.ts +1 -0
  28. package/dist/ie/types/tests/core/watermark.test.d.ts +1 -0
  29. package/dist/ie/types/tests/utils/index.d.ts +1 -0
  30. package/dist/ie/types/tests/utils/index.test.d.ts +1 -0
  31. package/dist/index.cjs.js +21 -10
  32. package/dist/index.cjs.js.map +1 -1
  33. package/dist/index.cjs.min.js +1 -1
  34. package/dist/index.esm.js +21 -10
  35. package/dist/index.esm.js.map +1 -1
  36. package/dist/index.esm.min.js +1 -1
  37. package/dist/index.iife.js +21 -10
  38. package/dist/index.iife.js.map +1 -1
  39. package/dist/index.iife.min.js +1 -1
  40. package/dist/index.umd.js +21 -10
  41. package/dist/index.umd.js.map +1 -1
  42. package/dist/index.umd.min.js +1 -1
  43. package/dist/types/src/core/watermark.d.ts +1 -0
  44. package/dist/types/src/index.ie.d.ts +6 -0
  45. package/package.json +31 -22
  46. package/dist/types/docs/components/config.d.ts +0 -72
  47. package/dist/types/jest.setup.d.ts +0 -1
@@ -0,0 +1,4451 @@
1
+ /*!
2
+ * watermark-js-plus v1.5.3
3
+ * (c) 2022-2024 Michael Sun
4
+ * Released under the MIT License.
5
+ */
6
+ 'use strict';
7
+
8
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
9
+
10
+ var check = function (it) {
11
+ return it && it.Math === Math && it;
12
+ };
13
+
14
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
15
+ var globalThis_1 =
16
+ // eslint-disable-next-line es/no-global-this -- safe
17
+ check(typeof globalThis == 'object' && globalThis) ||
18
+ check(typeof window == 'object' && window) ||
19
+ // eslint-disable-next-line no-restricted-globals -- safe
20
+ check(typeof self == 'object' && self) ||
21
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
22
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
23
+ // eslint-disable-next-line no-new-func -- fallback
24
+ (function () { return this; })() || Function('return this')();
25
+
26
+ var objectGetOwnPropertyDescriptor = {};
27
+
28
+ var fails$b = function (exec) {
29
+ try {
30
+ return !!exec();
31
+ } catch (error) {
32
+ return true;
33
+ }
34
+ };
35
+
36
+ var fails$a = fails$b;
37
+
38
+ // Detect IE8's incomplete defineProperty implementation
39
+ var descriptors = !fails$a(function () {
40
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
41
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
42
+ });
43
+
44
+ var fails$9 = fails$b;
45
+
46
+ var functionBindNative = !fails$9(function () {
47
+ // eslint-disable-next-line es/no-function-prototype-bind -- safe
48
+ var test = (function () { /* empty */ }).bind();
49
+ // eslint-disable-next-line no-prototype-builtins -- safe
50
+ return typeof test != 'function' || test.hasOwnProperty('prototype');
51
+ });
52
+
53
+ var NATIVE_BIND$3 = functionBindNative;
54
+
55
+ var call$c = Function.prototype.call;
56
+
57
+ var functionCall = NATIVE_BIND$3 ? call$c.bind(call$c) : function () {
58
+ return call$c.apply(call$c, arguments);
59
+ };
60
+
61
+ var objectPropertyIsEnumerable = {};
62
+
63
+ var $propertyIsEnumerable = {}.propertyIsEnumerable;
64
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
65
+ var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor;
66
+
67
+ // Nashorn ~ JDK8 bug
68
+ var NASHORN_BUG = getOwnPropertyDescriptor$2 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
69
+
70
+ // `Object.prototype.propertyIsEnumerable` method implementation
71
+ // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
72
+ objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
73
+ var descriptor = getOwnPropertyDescriptor$2(this, V);
74
+ return !!descriptor && descriptor.enumerable;
75
+ } : $propertyIsEnumerable;
76
+
77
+ var createPropertyDescriptor$3 = function (bitmap, value) {
78
+ return {
79
+ enumerable: !(bitmap & 1),
80
+ configurable: !(bitmap & 2),
81
+ writable: !(bitmap & 4),
82
+ value: value
83
+ };
84
+ };
85
+
86
+ var NATIVE_BIND$2 = functionBindNative;
87
+
88
+ var FunctionPrototype$2 = Function.prototype;
89
+ var call$b = FunctionPrototype$2.call;
90
+ var uncurryThisWithBind = NATIVE_BIND$2 && FunctionPrototype$2.bind.bind(call$b, call$b);
91
+
92
+ var functionUncurryThis = NATIVE_BIND$2 ? uncurryThisWithBind : function (fn) {
93
+ return function () {
94
+ return call$b.apply(fn, arguments);
95
+ };
96
+ };
97
+
98
+ var uncurryThis$d = functionUncurryThis;
99
+
100
+ var toString$1 = uncurryThis$d({}.toString);
101
+ var stringSlice$1 = uncurryThis$d(''.slice);
102
+
103
+ var classofRaw$2 = function (it) {
104
+ return stringSlice$1(toString$1(it), 8, -1);
105
+ };
106
+
107
+ var uncurryThis$c = functionUncurryThis;
108
+ var fails$8 = fails$b;
109
+ var classof$4 = classofRaw$2;
110
+
111
+ var $Object$3 = Object;
112
+ var split = uncurryThis$c(''.split);
113
+
114
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
115
+ var indexedObject = fails$8(function () {
116
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
117
+ // eslint-disable-next-line no-prototype-builtins -- safe
118
+ return !$Object$3('z').propertyIsEnumerable(0);
119
+ }) ? function (it) {
120
+ return classof$4(it) === 'String' ? split(it, '') : $Object$3(it);
121
+ } : $Object$3;
122
+
123
+ // we can't use just `it == null` since of `document.all` special case
124
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
125
+ var isNullOrUndefined$4 = function (it) {
126
+ return it === null || it === undefined;
127
+ };
128
+
129
+ var isNullOrUndefined$3 = isNullOrUndefined$4;
130
+
131
+ var $TypeError$c = TypeError;
132
+
133
+ // `RequireObjectCoercible` abstract operation
134
+ // https://tc39.es/ecma262/#sec-requireobjectcoercible
135
+ var requireObjectCoercible$3 = function (it) {
136
+ if (isNullOrUndefined$3(it)) throw new $TypeError$c("Can't call method on " + it);
137
+ return it;
138
+ };
139
+
140
+ // toObject with fallback for non-array-like ES3 strings
141
+ var IndexedObject = indexedObject;
142
+ var requireObjectCoercible$2 = requireObjectCoercible$3;
143
+
144
+ var toIndexedObject$4 = function (it) {
145
+ return IndexedObject(requireObjectCoercible$2(it));
146
+ };
147
+
148
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
149
+ var documentAll = typeof document == 'object' && document.all;
150
+
151
+ // `IsCallable` abstract operation
152
+ // https://tc39.es/ecma262/#sec-iscallable
153
+ // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
154
+ var isCallable$g = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
155
+ return typeof argument == 'function' || argument === documentAll;
156
+ } : function (argument) {
157
+ return typeof argument == 'function';
158
+ };
159
+
160
+ var isCallable$f = isCallable$g;
161
+
162
+ var isObject$9 = function (it) {
163
+ return typeof it == 'object' ? it !== null : isCallable$f(it);
164
+ };
165
+
166
+ var globalThis$i = globalThis_1;
167
+ var isCallable$e = isCallable$g;
168
+
169
+ var aFunction = function (argument) {
170
+ return isCallable$e(argument) ? argument : undefined;
171
+ };
172
+
173
+ var getBuiltIn$7 = function (namespace, method) {
174
+ return arguments.length < 2 ? aFunction(globalThis$i[namespace]) : globalThis$i[namespace] && globalThis$i[namespace][method];
175
+ };
176
+
177
+ var uncurryThis$b = functionUncurryThis;
178
+
179
+ var objectIsPrototypeOf = uncurryThis$b({}.isPrototypeOf);
180
+
181
+ var globalThis$h = globalThis_1;
182
+
183
+ var navigator = globalThis$h.navigator;
184
+ var userAgent$5 = navigator && navigator.userAgent;
185
+
186
+ var environmentUserAgent = userAgent$5 ? String(userAgent$5) : '';
187
+
188
+ var globalThis$g = globalThis_1;
189
+ var userAgent$4 = environmentUserAgent;
190
+
191
+ var process$3 = globalThis$g.process;
192
+ var Deno$1 = globalThis$g.Deno;
193
+ var versions = process$3 && process$3.versions || Deno$1 && Deno$1.version;
194
+ var v8 = versions && versions.v8;
195
+ var match, version;
196
+
197
+ if (v8) {
198
+ match = v8.split('.');
199
+ // in old Chrome, versions of V8 isn't V8 = Chrome / 10
200
+ // but their correct versions are not interesting for us
201
+ version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
202
+ }
203
+
204
+ // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
205
+ // so check `userAgent` even if `.v8` exists, but 0
206
+ if (!version && userAgent$4) {
207
+ match = userAgent$4.match(/Edge\/(\d+)/);
208
+ if (!match || match[1] >= 74) {
209
+ match = userAgent$4.match(/Chrome\/(\d+)/);
210
+ if (match) version = +match[1];
211
+ }
212
+ }
213
+
214
+ var environmentV8Version = version;
215
+
216
+ /* eslint-disable es/no-symbol -- required for testing */
217
+ var V8_VERSION$1 = environmentV8Version;
218
+ var fails$7 = fails$b;
219
+ var globalThis$f = globalThis_1;
220
+
221
+ var $String$4 = globalThis$f.String;
222
+
223
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
224
+ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$7(function () {
225
+ var symbol = Symbol('symbol detection');
226
+ // Chrome 38 Symbol has incorrect toString conversion
227
+ // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
228
+ // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
229
+ // of course, fail.
230
+ return !$String$4(symbol) || !(Object(symbol) instanceof Symbol) ||
231
+ // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
232
+ !Symbol.sham && V8_VERSION$1 && V8_VERSION$1 < 41;
233
+ });
234
+
235
+ /* eslint-disable es/no-symbol -- required for testing */
236
+ var NATIVE_SYMBOL$1 = symbolConstructorDetection;
237
+
238
+ var useSymbolAsUid = NATIVE_SYMBOL$1
239
+ && !Symbol.sham
240
+ && typeof Symbol.iterator == 'symbol';
241
+
242
+ var getBuiltIn$6 = getBuiltIn$7;
243
+ var isCallable$d = isCallable$g;
244
+ var isPrototypeOf$2 = objectIsPrototypeOf;
245
+ var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
246
+
247
+ var $Object$2 = Object;
248
+
249
+ var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
250
+ return typeof it == 'symbol';
251
+ } : function (it) {
252
+ var $Symbol = getBuiltIn$6('Symbol');
253
+ return isCallable$d($Symbol) && isPrototypeOf$2($Symbol.prototype, $Object$2(it));
254
+ };
255
+
256
+ var $String$3 = String;
257
+
258
+ var tryToString$4 = function (argument) {
259
+ try {
260
+ return $String$3(argument);
261
+ } catch (error) {
262
+ return 'Object';
263
+ }
264
+ };
265
+
266
+ var isCallable$c = isCallable$g;
267
+ var tryToString$3 = tryToString$4;
268
+
269
+ var $TypeError$b = TypeError;
270
+
271
+ // `Assert: IsCallable(argument) is true`
272
+ var aCallable$8 = function (argument) {
273
+ if (isCallable$c(argument)) return argument;
274
+ throw new $TypeError$b(tryToString$3(argument) + ' is not a function');
275
+ };
276
+
277
+ var aCallable$7 = aCallable$8;
278
+ var isNullOrUndefined$2 = isNullOrUndefined$4;
279
+
280
+ // `GetMethod` abstract operation
281
+ // https://tc39.es/ecma262/#sec-getmethod
282
+ var getMethod$3 = function (V, P) {
283
+ var func = V[P];
284
+ return isNullOrUndefined$2(func) ? undefined : aCallable$7(func);
285
+ };
286
+
287
+ var call$a = functionCall;
288
+ var isCallable$b = isCallable$g;
289
+ var isObject$8 = isObject$9;
290
+
291
+ var $TypeError$a = TypeError;
292
+
293
+ // `OrdinaryToPrimitive` abstract operation
294
+ // https://tc39.es/ecma262/#sec-ordinarytoprimitive
295
+ var ordinaryToPrimitive$1 = function (input, pref) {
296
+ var fn, val;
297
+ if (pref === 'string' && isCallable$b(fn = input.toString) && !isObject$8(val = call$a(fn, input))) return val;
298
+ if (isCallable$b(fn = input.valueOf) && !isObject$8(val = call$a(fn, input))) return val;
299
+ if (pref !== 'string' && isCallable$b(fn = input.toString) && !isObject$8(val = call$a(fn, input))) return val;
300
+ throw new $TypeError$a("Can't convert object to primitive value");
301
+ };
302
+
303
+ var sharedStore = {exports: {}};
304
+
305
+ var globalThis$e = globalThis_1;
306
+
307
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
308
+ var defineProperty$4 = Object.defineProperty;
309
+
310
+ var defineGlobalProperty$3 = function (key, value) {
311
+ try {
312
+ defineProperty$4(globalThis$e, key, { value: value, configurable: true, writable: true });
313
+ } catch (error) {
314
+ globalThis$e[key] = value;
315
+ } return value;
316
+ };
317
+
318
+ var globalThis$d = globalThis_1;
319
+ var defineGlobalProperty$2 = defineGlobalProperty$3;
320
+
321
+ var SHARED = '__core-js_shared__';
322
+ var store$3 = sharedStore.exports = globalThis$d[SHARED] || defineGlobalProperty$2(SHARED, {});
323
+
324
+ (store$3.versions || (store$3.versions = [])).push({
325
+ version: '3.38.0',
326
+ mode: 'global',
327
+ copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
328
+ license: 'https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE',
329
+ source: 'https://github.com/zloirock/core-js'
330
+ });
331
+
332
+ var sharedStoreExports = sharedStore.exports;
333
+
334
+ var store$2 = sharedStoreExports;
335
+
336
+ var shared$3 = function (key, value) {
337
+ return store$2[key] || (store$2[key] = value || {});
338
+ };
339
+
340
+ var requireObjectCoercible$1 = requireObjectCoercible$3;
341
+
342
+ var $Object$1 = Object;
343
+
344
+ // `ToObject` abstract operation
345
+ // https://tc39.es/ecma262/#sec-toobject
346
+ var toObject$3 = function (argument) {
347
+ return $Object$1(requireObjectCoercible$1(argument));
348
+ };
349
+
350
+ var uncurryThis$a = functionUncurryThis;
351
+ var toObject$2 = toObject$3;
352
+
353
+ var hasOwnProperty = uncurryThis$a({}.hasOwnProperty);
354
+
355
+ // `HasOwnProperty` abstract operation
356
+ // https://tc39.es/ecma262/#sec-hasownproperty
357
+ // eslint-disable-next-line es/no-object-hasown -- safe
358
+ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
359
+ return hasOwnProperty(toObject$2(it), key);
360
+ };
361
+
362
+ var uncurryThis$9 = functionUncurryThis;
363
+
364
+ var id = 0;
365
+ var postfix = Math.random();
366
+ var toString = uncurryThis$9(1.0.toString);
367
+
368
+ var uid$2 = function (key) {
369
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
370
+ };
371
+
372
+ var globalThis$c = globalThis_1;
373
+ var shared$2 = shared$3;
374
+ var hasOwn$8 = hasOwnProperty_1;
375
+ var uid$1 = uid$2;
376
+ var NATIVE_SYMBOL = symbolConstructorDetection;
377
+ var USE_SYMBOL_AS_UID = useSymbolAsUid;
378
+
379
+ var Symbol$1 = globalThis$c.Symbol;
380
+ var WellKnownSymbolsStore = shared$2('wks');
381
+ var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
382
+
383
+ var wellKnownSymbol$b = function (name) {
384
+ if (!hasOwn$8(WellKnownSymbolsStore, name)) {
385
+ WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn$8(Symbol$1, name)
386
+ ? Symbol$1[name]
387
+ : createWellKnownSymbol('Symbol.' + name);
388
+ } return WellKnownSymbolsStore[name];
389
+ };
390
+
391
+ var call$9 = functionCall;
392
+ var isObject$7 = isObject$9;
393
+ var isSymbol$1 = isSymbol$2;
394
+ var getMethod$2 = getMethod$3;
395
+ var ordinaryToPrimitive = ordinaryToPrimitive$1;
396
+ var wellKnownSymbol$a = wellKnownSymbol$b;
397
+
398
+ var $TypeError$9 = TypeError;
399
+ var TO_PRIMITIVE = wellKnownSymbol$a('toPrimitive');
400
+
401
+ // `ToPrimitive` abstract operation
402
+ // https://tc39.es/ecma262/#sec-toprimitive
403
+ var toPrimitive$1 = function (input, pref) {
404
+ if (!isObject$7(input) || isSymbol$1(input)) return input;
405
+ var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
406
+ var result;
407
+ if (exoticToPrim) {
408
+ if (pref === undefined) pref = 'default';
409
+ result = call$9(exoticToPrim, input, pref);
410
+ if (!isObject$7(result) || isSymbol$1(result)) return result;
411
+ throw new $TypeError$9("Can't convert object to primitive value");
412
+ }
413
+ if (pref === undefined) pref = 'number';
414
+ return ordinaryToPrimitive(input, pref);
415
+ };
416
+
417
+ var toPrimitive = toPrimitive$1;
418
+ var isSymbol = isSymbol$2;
419
+
420
+ // `ToPropertyKey` abstract operation
421
+ // https://tc39.es/ecma262/#sec-topropertykey
422
+ var toPropertyKey$2 = function (argument) {
423
+ var key = toPrimitive(argument, 'string');
424
+ return isSymbol(key) ? key : key + '';
425
+ };
426
+
427
+ var globalThis$b = globalThis_1;
428
+ var isObject$6 = isObject$9;
429
+
430
+ var document$3 = globalThis$b.document;
431
+ // typeof document.createElement is 'object' in old IE
432
+ var EXISTS$1 = isObject$6(document$3) && isObject$6(document$3.createElement);
433
+
434
+ var documentCreateElement$1 = function (it) {
435
+ return EXISTS$1 ? document$3.createElement(it) : {};
436
+ };
437
+
438
+ var DESCRIPTORS$a = descriptors;
439
+ var fails$6 = fails$b;
440
+ var createElement$1 = documentCreateElement$1;
441
+
442
+ // Thanks to IE8 for its funny defineProperty
443
+ var ie8DomDefine = !DESCRIPTORS$a && !fails$6(function () {
444
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
445
+ return Object.defineProperty(createElement$1('div'), 'a', {
446
+ get: function () { return 7; }
447
+ }).a !== 7;
448
+ });
449
+
450
+ var DESCRIPTORS$9 = descriptors;
451
+ var call$8 = functionCall;
452
+ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
453
+ var createPropertyDescriptor$2 = createPropertyDescriptor$3;
454
+ var toIndexedObject$3 = toIndexedObject$4;
455
+ var toPropertyKey$1 = toPropertyKey$2;
456
+ var hasOwn$7 = hasOwnProperty_1;
457
+ var IE8_DOM_DEFINE$1 = ie8DomDefine;
458
+
459
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
460
+ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
461
+
462
+ // `Object.getOwnPropertyDescriptor` method
463
+ // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
464
+ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$9 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
465
+ O = toIndexedObject$3(O);
466
+ P = toPropertyKey$1(P);
467
+ if (IE8_DOM_DEFINE$1) try {
468
+ return $getOwnPropertyDescriptor$1(O, P);
469
+ } catch (error) { /* empty */ }
470
+ if (hasOwn$7(O, P)) return createPropertyDescriptor$2(!call$8(propertyIsEnumerableModule.f, O, P), O[P]);
471
+ };
472
+
473
+ var objectDefineProperty = {};
474
+
475
+ var DESCRIPTORS$8 = descriptors;
476
+ var fails$5 = fails$b;
477
+
478
+ // V8 ~ Chrome 36-
479
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3334
480
+ var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$5(function () {
481
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
482
+ return Object.defineProperty(function () { /* empty */ }, 'prototype', {
483
+ value: 42,
484
+ writable: false
485
+ }).prototype !== 42;
486
+ });
487
+
488
+ var isObject$5 = isObject$9;
489
+
490
+ var $String$2 = String;
491
+ var $TypeError$8 = TypeError;
492
+
493
+ // `Assert: Type(argument) is Object`
494
+ var anObject$a = function (argument) {
495
+ if (isObject$5(argument)) return argument;
496
+ throw new $TypeError$8($String$2(argument) + ' is not an object');
497
+ };
498
+
499
+ var DESCRIPTORS$7 = descriptors;
500
+ var IE8_DOM_DEFINE = ie8DomDefine;
501
+ var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
502
+ var anObject$9 = anObject$a;
503
+ var toPropertyKey = toPropertyKey$2;
504
+
505
+ var $TypeError$7 = TypeError;
506
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
507
+ var $defineProperty = Object.defineProperty;
508
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
509
+ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
510
+ var ENUMERABLE = 'enumerable';
511
+ var CONFIGURABLE$1 = 'configurable';
512
+ var WRITABLE = 'writable';
513
+
514
+ // `Object.defineProperty` method
515
+ // https://tc39.es/ecma262/#sec-object.defineproperty
516
+ objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
517
+ anObject$9(O);
518
+ P = toPropertyKey(P);
519
+ anObject$9(Attributes);
520
+ if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
521
+ var current = $getOwnPropertyDescriptor(O, P);
522
+ if (current && current[WRITABLE]) {
523
+ O[P] = Attributes.value;
524
+ Attributes = {
525
+ configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
526
+ enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
527
+ writable: false
528
+ };
529
+ }
530
+ } return $defineProperty(O, P, Attributes);
531
+ } : $defineProperty : function defineProperty(O, P, Attributes) {
532
+ anObject$9(O);
533
+ P = toPropertyKey(P);
534
+ anObject$9(Attributes);
535
+ if (IE8_DOM_DEFINE) try {
536
+ return $defineProperty(O, P, Attributes);
537
+ } catch (error) { /* empty */ }
538
+ if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$7('Accessors not supported');
539
+ if ('value' in Attributes) O[P] = Attributes.value;
540
+ return O;
541
+ };
542
+
543
+ var DESCRIPTORS$6 = descriptors;
544
+ var definePropertyModule$4 = objectDefineProperty;
545
+ var createPropertyDescriptor$1 = createPropertyDescriptor$3;
546
+
547
+ var createNonEnumerableProperty$2 = DESCRIPTORS$6 ? function (object, key, value) {
548
+ return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
549
+ } : function (object, key, value) {
550
+ object[key] = value;
551
+ return object;
552
+ };
553
+
554
+ var makeBuiltIn$3 = {exports: {}};
555
+
556
+ var DESCRIPTORS$5 = descriptors;
557
+ var hasOwn$6 = hasOwnProperty_1;
558
+
559
+ var FunctionPrototype$1 = Function.prototype;
560
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
561
+ var getDescriptor = DESCRIPTORS$5 && Object.getOwnPropertyDescriptor;
562
+
563
+ var EXISTS = hasOwn$6(FunctionPrototype$1, 'name');
564
+ // additional protection from minified / mangled / dropped function names
565
+ var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
566
+ var CONFIGURABLE = EXISTS && (!DESCRIPTORS$5 || (DESCRIPTORS$5 && getDescriptor(FunctionPrototype$1, 'name').configurable));
567
+
568
+ var functionName = {
569
+ EXISTS: EXISTS,
570
+ PROPER: PROPER,
571
+ CONFIGURABLE: CONFIGURABLE
572
+ };
573
+
574
+ var uncurryThis$8 = functionUncurryThis;
575
+ var isCallable$a = isCallable$g;
576
+ var store$1 = sharedStoreExports;
577
+
578
+ var functionToString = uncurryThis$8(Function.toString);
579
+
580
+ // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
581
+ if (!isCallable$a(store$1.inspectSource)) {
582
+ store$1.inspectSource = function (it) {
583
+ return functionToString(it);
584
+ };
585
+ }
586
+
587
+ var inspectSource$3 = store$1.inspectSource;
588
+
589
+ var globalThis$a = globalThis_1;
590
+ var isCallable$9 = isCallable$g;
591
+
592
+ var WeakMap$1 = globalThis$a.WeakMap;
593
+
594
+ var weakMapBasicDetection = isCallable$9(WeakMap$1) && /native code/.test(String(WeakMap$1));
595
+
596
+ var shared$1 = shared$3;
597
+ var uid = uid$2;
598
+
599
+ var keys = shared$1('keys');
600
+
601
+ var sharedKey$2 = function (key) {
602
+ return keys[key] || (keys[key] = uid(key));
603
+ };
604
+
605
+ var hiddenKeys$4 = {};
606
+
607
+ var NATIVE_WEAK_MAP = weakMapBasicDetection;
608
+ var globalThis$9 = globalThis_1;
609
+ var isObject$4 = isObject$9;
610
+ var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
611
+ var hasOwn$5 = hasOwnProperty_1;
612
+ var shared = sharedStoreExports;
613
+ var sharedKey$1 = sharedKey$2;
614
+ var hiddenKeys$3 = hiddenKeys$4;
615
+
616
+ var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
617
+ var TypeError$2 = globalThis$9.TypeError;
618
+ var WeakMap = globalThis$9.WeakMap;
619
+ var set$1, get, has;
620
+
621
+ var enforce = function (it) {
622
+ return has(it) ? get(it) : set$1(it, {});
623
+ };
624
+
625
+ var getterFor = function (TYPE) {
626
+ return function (it) {
627
+ var state;
628
+ if (!isObject$4(it) || (state = get(it)).type !== TYPE) {
629
+ throw new TypeError$2('Incompatible receiver, ' + TYPE + ' required');
630
+ } return state;
631
+ };
632
+ };
633
+
634
+ if (NATIVE_WEAK_MAP || shared.state) {
635
+ var store = shared.state || (shared.state = new WeakMap());
636
+ /* eslint-disable no-self-assign -- prototype methods protection */
637
+ store.get = store.get;
638
+ store.has = store.has;
639
+ store.set = store.set;
640
+ /* eslint-enable no-self-assign -- prototype methods protection */
641
+ set$1 = function (it, metadata) {
642
+ if (store.has(it)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED);
643
+ metadata.facade = it;
644
+ store.set(it, metadata);
645
+ return metadata;
646
+ };
647
+ get = function (it) {
648
+ return store.get(it) || {};
649
+ };
650
+ has = function (it) {
651
+ return store.has(it);
652
+ };
653
+ } else {
654
+ var STATE = sharedKey$1('state');
655
+ hiddenKeys$3[STATE] = true;
656
+ set$1 = function (it, metadata) {
657
+ if (hasOwn$5(it, STATE)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED);
658
+ metadata.facade = it;
659
+ createNonEnumerableProperty$1(it, STATE, metadata);
660
+ return metadata;
661
+ };
662
+ get = function (it) {
663
+ return hasOwn$5(it, STATE) ? it[STATE] : {};
664
+ };
665
+ has = function (it) {
666
+ return hasOwn$5(it, STATE);
667
+ };
668
+ }
669
+
670
+ var internalState = {
671
+ set: set$1,
672
+ get: get,
673
+ has: has,
674
+ enforce: enforce,
675
+ getterFor: getterFor
676
+ };
677
+
678
+ var uncurryThis$7 = functionUncurryThis;
679
+ var fails$4 = fails$b;
680
+ var isCallable$8 = isCallable$g;
681
+ var hasOwn$4 = hasOwnProperty_1;
682
+ var DESCRIPTORS$4 = descriptors;
683
+ var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
684
+ var inspectSource$2 = inspectSource$3;
685
+ var InternalStateModule$1 = internalState;
686
+
687
+ var enforceInternalState = InternalStateModule$1.enforce;
688
+ var getInternalState = InternalStateModule$1.get;
689
+ var $String$1 = String;
690
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
691
+ var defineProperty$3 = Object.defineProperty;
692
+ var stringSlice = uncurryThis$7(''.slice);
693
+ var replace = uncurryThis$7(''.replace);
694
+ var join = uncurryThis$7([].join);
695
+
696
+ var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$4(function () {
697
+ return defineProperty$3(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
698
+ });
699
+
700
+ var TEMPLATE = String(String).split('String');
701
+
702
+ var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
703
+ if (stringSlice($String$1(name), 0, 7) === 'Symbol(') {
704
+ name = '[' + replace($String$1(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
705
+ }
706
+ if (options && options.getter) name = 'get ' + name;
707
+ if (options && options.setter) name = 'set ' + name;
708
+ if (!hasOwn$4(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
709
+ if (DESCRIPTORS$4) defineProperty$3(value, 'name', { value: name, configurable: true });
710
+ else value.name = name;
711
+ }
712
+ if (CONFIGURABLE_LENGTH && options && hasOwn$4(options, 'arity') && value.length !== options.arity) {
713
+ defineProperty$3(value, 'length', { value: options.arity });
714
+ }
715
+ try {
716
+ if (options && hasOwn$4(options, 'constructor') && options.constructor) {
717
+ if (DESCRIPTORS$4) defineProperty$3(value, 'prototype', { writable: false });
718
+ // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
719
+ } else if (value.prototype) value.prototype = undefined;
720
+ } catch (error) { /* empty */ }
721
+ var state = enforceInternalState(value);
722
+ if (!hasOwn$4(state, 'source')) {
723
+ state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
724
+ } return value;
725
+ };
726
+
727
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
728
+ // eslint-disable-next-line no-extend-native -- required
729
+ Function.prototype.toString = makeBuiltIn$2(function toString() {
730
+ return isCallable$8(this) && getInternalState(this).source || inspectSource$2(this);
731
+ }, 'toString');
732
+
733
+ var makeBuiltInExports = makeBuiltIn$3.exports;
734
+
735
+ var isCallable$7 = isCallable$g;
736
+ var definePropertyModule$3 = objectDefineProperty;
737
+ var makeBuiltIn$1 = makeBuiltInExports;
738
+ var defineGlobalProperty$1 = defineGlobalProperty$3;
739
+
740
+ var defineBuiltIn$3 = function (O, key, value, options) {
741
+ if (!options) options = {};
742
+ var simple = options.enumerable;
743
+ var name = options.name !== undefined ? options.name : key;
744
+ if (isCallable$7(value)) makeBuiltIn$1(value, name, options);
745
+ if (options.global) {
746
+ if (simple) O[key] = value;
747
+ else defineGlobalProperty$1(key, value);
748
+ } else {
749
+ try {
750
+ if (!options.unsafe) delete O[key];
751
+ else if (O[key]) simple = true;
752
+ } catch (error) { /* empty */ }
753
+ if (simple) O[key] = value;
754
+ else definePropertyModule$3.f(O, key, {
755
+ value: value,
756
+ enumerable: false,
757
+ configurable: !options.nonConfigurable,
758
+ writable: !options.nonWritable
759
+ });
760
+ } return O;
761
+ };
762
+
763
+ var objectGetOwnPropertyNames = {};
764
+
765
+ var ceil = Math.ceil;
766
+ var floor = Math.floor;
767
+
768
+ // `Math.trunc` method
769
+ // https://tc39.es/ecma262/#sec-math.trunc
770
+ // eslint-disable-next-line es/no-math-trunc -- safe
771
+ var mathTrunc = Math.trunc || function trunc(x) {
772
+ var n = +x;
773
+ return (n > 0 ? floor : ceil)(n);
774
+ };
775
+
776
+ var trunc = mathTrunc;
777
+
778
+ // `ToIntegerOrInfinity` abstract operation
779
+ // https://tc39.es/ecma262/#sec-tointegerorinfinity
780
+ var toIntegerOrInfinity$2 = function (argument) {
781
+ var number = +argument;
782
+ // eslint-disable-next-line no-self-compare -- NaN check
783
+ return number !== number || number === 0 ? 0 : trunc(number);
784
+ };
785
+
786
+ var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
787
+
788
+ var max = Math.max;
789
+ var min$1 = Math.min;
790
+
791
+ // Helper for a popular repeating case of the spec:
792
+ // Let integer be ? ToInteger(index).
793
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
794
+ var toAbsoluteIndex$2 = function (index, length) {
795
+ var integer = toIntegerOrInfinity$1(index);
796
+ return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
797
+ };
798
+
799
+ var toIntegerOrInfinity = toIntegerOrInfinity$2;
800
+
801
+ var min = Math.min;
802
+
803
+ // `ToLength` abstract operation
804
+ // https://tc39.es/ecma262/#sec-tolength
805
+ var toLength$1 = function (argument) {
806
+ var len = toIntegerOrInfinity(argument);
807
+ return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
808
+ };
809
+
810
+ var toLength = toLength$1;
811
+
812
+ // `LengthOfArrayLike` abstract operation
813
+ // https://tc39.es/ecma262/#sec-lengthofarraylike
814
+ var lengthOfArrayLike$4 = function (obj) {
815
+ return toLength(obj.length);
816
+ };
817
+
818
+ var toIndexedObject$2 = toIndexedObject$4;
819
+ var toAbsoluteIndex$1 = toAbsoluteIndex$2;
820
+ var lengthOfArrayLike$3 = lengthOfArrayLike$4;
821
+
822
+ // `Array.prototype.{ indexOf, includes }` methods implementation
823
+ var createMethod = function (IS_INCLUDES) {
824
+ return function ($this, el, fromIndex) {
825
+ var O = toIndexedObject$2($this);
826
+ var length = lengthOfArrayLike$3(O);
827
+ if (length === 0) return !IS_INCLUDES && -1;
828
+ var index = toAbsoluteIndex$1(fromIndex, length);
829
+ var value;
830
+ // Array#includes uses SameValueZero equality algorithm
831
+ // eslint-disable-next-line no-self-compare -- NaN check
832
+ if (IS_INCLUDES && el !== el) while (length > index) {
833
+ value = O[index++];
834
+ // eslint-disable-next-line no-self-compare -- NaN check
835
+ if (value !== value) return true;
836
+ // Array#indexOf ignores holes, Array#includes - not
837
+ } else for (;length > index; index++) {
838
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
839
+ } return !IS_INCLUDES && -1;
840
+ };
841
+ };
842
+
843
+ var arrayIncludes = {
844
+ // `Array.prototype.includes` method
845
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
846
+ includes: createMethod(true),
847
+ // `Array.prototype.indexOf` method
848
+ // https://tc39.es/ecma262/#sec-array.prototype.indexof
849
+ indexOf: createMethod(false)
850
+ };
851
+
852
+ var uncurryThis$6 = functionUncurryThis;
853
+ var hasOwn$3 = hasOwnProperty_1;
854
+ var toIndexedObject$1 = toIndexedObject$4;
855
+ var indexOf = arrayIncludes.indexOf;
856
+ var hiddenKeys$2 = hiddenKeys$4;
857
+
858
+ var push = uncurryThis$6([].push);
859
+
860
+ var objectKeysInternal = function (object, names) {
861
+ var O = toIndexedObject$1(object);
862
+ var i = 0;
863
+ var result = [];
864
+ var key;
865
+ for (key in O) !hasOwn$3(hiddenKeys$2, key) && hasOwn$3(O, key) && push(result, key);
866
+ // Don't enum bug & hidden keys
867
+ while (names.length > i) if (hasOwn$3(O, key = names[i++])) {
868
+ ~indexOf(result, key) || push(result, key);
869
+ }
870
+ return result;
871
+ };
872
+
873
+ // IE8- don't enum bug keys
874
+ var enumBugKeys$3 = [
875
+ 'constructor',
876
+ 'hasOwnProperty',
877
+ 'isPrototypeOf',
878
+ 'propertyIsEnumerable',
879
+ 'toLocaleString',
880
+ 'toString',
881
+ 'valueOf'
882
+ ];
883
+
884
+ var internalObjectKeys$1 = objectKeysInternal;
885
+ var enumBugKeys$2 = enumBugKeys$3;
886
+
887
+ var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
888
+
889
+ // `Object.getOwnPropertyNames` method
890
+ // https://tc39.es/ecma262/#sec-object.getownpropertynames
891
+ // eslint-disable-next-line es/no-object-getownpropertynames -- safe
892
+ objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
893
+ return internalObjectKeys$1(O, hiddenKeys$1);
894
+ };
895
+
896
+ var objectGetOwnPropertySymbols = {};
897
+
898
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
899
+ objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
900
+
901
+ var getBuiltIn$5 = getBuiltIn$7;
902
+ var uncurryThis$5 = functionUncurryThis;
903
+ var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
904
+ var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
905
+ var anObject$8 = anObject$a;
906
+
907
+ var concat = uncurryThis$5([].concat);
908
+
909
+ // all object keys, includes non-enumerable and symbols
910
+ var ownKeys$1 = getBuiltIn$5('Reflect', 'ownKeys') || function ownKeys(it) {
911
+ var keys = getOwnPropertyNamesModule.f(anObject$8(it));
912
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
913
+ return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
914
+ };
915
+
916
+ var hasOwn$2 = hasOwnProperty_1;
917
+ var ownKeys = ownKeys$1;
918
+ var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
919
+ var definePropertyModule$2 = objectDefineProperty;
920
+
921
+ var copyConstructorProperties$1 = function (target, source, exceptions) {
922
+ var keys = ownKeys(source);
923
+ var defineProperty = definePropertyModule$2.f;
924
+ var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
925
+ for (var i = 0; i < keys.length; i++) {
926
+ var key = keys[i];
927
+ if (!hasOwn$2(target, key) && !(exceptions && hasOwn$2(exceptions, key))) {
928
+ defineProperty(target, key, getOwnPropertyDescriptor(source, key));
929
+ }
930
+ }
931
+ };
932
+
933
+ var fails$3 = fails$b;
934
+ var isCallable$6 = isCallable$g;
935
+
936
+ var replacement = /#|\.prototype\./;
937
+
938
+ var isForced$2 = function (feature, detection) {
939
+ var value = data[normalize(feature)];
940
+ return value === POLYFILL ? true
941
+ : value === NATIVE ? false
942
+ : isCallable$6(detection) ? fails$3(detection)
943
+ : !!detection;
944
+ };
945
+
946
+ var normalize = isForced$2.normalize = function (string) {
947
+ return String(string).replace(replacement, '.').toLowerCase();
948
+ };
949
+
950
+ var data = isForced$2.data = {};
951
+ var NATIVE = isForced$2.NATIVE = 'N';
952
+ var POLYFILL = isForced$2.POLYFILL = 'P';
953
+
954
+ var isForced_1 = isForced$2;
955
+
956
+ var globalThis$8 = globalThis_1;
957
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
958
+ var createNonEnumerableProperty = createNonEnumerableProperty$2;
959
+ var defineBuiltIn$2 = defineBuiltIn$3;
960
+ var defineGlobalProperty = defineGlobalProperty$3;
961
+ var copyConstructorProperties = copyConstructorProperties$1;
962
+ var isForced$1 = isForced_1;
963
+
964
+ /*
965
+ options.target - name of the target object
966
+ options.global - target is the global object
967
+ options.stat - export as static methods of target
968
+ options.proto - export as prototype methods of target
969
+ options.real - real prototype method for the `pure` version
970
+ options.forced - export even if the native feature is available
971
+ options.bind - bind methods to the target, required for the `pure` version
972
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
973
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
974
+ options.sham - add a flag to not completely full polyfills
975
+ options.enumerable - export as enumerable property
976
+ options.dontCallGetSet - prevent calling a getter on target
977
+ options.name - the .name of the function if it does not match the key
978
+ */
979
+ var _export = function (options, source) {
980
+ var TARGET = options.target;
981
+ var GLOBAL = options.global;
982
+ var STATIC = options.stat;
983
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
984
+ if (GLOBAL) {
985
+ target = globalThis$8;
986
+ } else if (STATIC) {
987
+ target = globalThis$8[TARGET] || defineGlobalProperty(TARGET, {});
988
+ } else {
989
+ target = globalThis$8[TARGET] && globalThis$8[TARGET].prototype;
990
+ }
991
+ if (target) for (key in source) {
992
+ sourceProperty = source[key];
993
+ if (options.dontCallGetSet) {
994
+ descriptor = getOwnPropertyDescriptor$1(target, key);
995
+ targetProperty = descriptor && descriptor.value;
996
+ } else targetProperty = target[key];
997
+ FORCED = isForced$1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
998
+ // contained in target
999
+ if (!FORCED && targetProperty !== undefined) {
1000
+ if (typeof sourceProperty == typeof targetProperty) continue;
1001
+ copyConstructorProperties(sourceProperty, targetProperty);
1002
+ }
1003
+ // add a flag to not completely full polyfills
1004
+ if (options.sham || (targetProperty && targetProperty.sham)) {
1005
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
1006
+ }
1007
+ defineBuiltIn$2(target, key, sourceProperty, options);
1008
+ }
1009
+ };
1010
+
1011
+ var classofRaw$1 = classofRaw$2;
1012
+ var uncurryThis$4 = functionUncurryThis;
1013
+
1014
+ var functionUncurryThisClause = function (fn) {
1015
+ // Nashorn bug:
1016
+ // https://github.com/zloirock/core-js/issues/1128
1017
+ // https://github.com/zloirock/core-js/issues/1130
1018
+ if (classofRaw$1(fn) === 'Function') return uncurryThis$4(fn);
1019
+ };
1020
+
1021
+ var uncurryThis$3 = functionUncurryThisClause;
1022
+ var aCallable$6 = aCallable$8;
1023
+ var NATIVE_BIND$1 = functionBindNative;
1024
+
1025
+ var bind$5 = uncurryThis$3(uncurryThis$3.bind);
1026
+
1027
+ // optional / simple context binding
1028
+ var functionBindContext = function (fn, that) {
1029
+ aCallable$6(fn);
1030
+ return that === undefined ? fn : NATIVE_BIND$1 ? bind$5(fn, that) : function (/* ...args */) {
1031
+ return fn.apply(that, arguments);
1032
+ };
1033
+ };
1034
+
1035
+ var call$7 = functionCall;
1036
+ var anObject$7 = anObject$a;
1037
+ var getMethod$1 = getMethod$3;
1038
+
1039
+ var iteratorClose$2 = function (iterator, kind, value) {
1040
+ var innerResult, innerError;
1041
+ anObject$7(iterator);
1042
+ try {
1043
+ innerResult = getMethod$1(iterator, 'return');
1044
+ if (!innerResult) {
1045
+ if (kind === 'throw') throw value;
1046
+ return value;
1047
+ }
1048
+ innerResult = call$7(innerResult, iterator);
1049
+ } catch (error) {
1050
+ innerError = true;
1051
+ innerResult = error;
1052
+ }
1053
+ if (kind === 'throw') throw value;
1054
+ if (innerError) throw innerResult;
1055
+ anObject$7(innerResult);
1056
+ return value;
1057
+ };
1058
+
1059
+ var anObject$6 = anObject$a;
1060
+ var iteratorClose$1 = iteratorClose$2;
1061
+
1062
+ // call something on iterator step with safe closing on error
1063
+ var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
1064
+ try {
1065
+ return ENTRIES ? fn(anObject$6(value)[0], value[1]) : fn(value);
1066
+ } catch (error) {
1067
+ iteratorClose$1(iterator, 'throw', error);
1068
+ }
1069
+ };
1070
+
1071
+ var iterators = {};
1072
+
1073
+ var wellKnownSymbol$9 = wellKnownSymbol$b;
1074
+ var Iterators$1 = iterators;
1075
+
1076
+ var ITERATOR$2 = wellKnownSymbol$9('iterator');
1077
+ var ArrayPrototype$1 = Array.prototype;
1078
+
1079
+ // check on default Array iterator
1080
+ var isArrayIteratorMethod$2 = function (it) {
1081
+ return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$1[ITERATOR$2] === it);
1082
+ };
1083
+
1084
+ var wellKnownSymbol$8 = wellKnownSymbol$b;
1085
+
1086
+ var TO_STRING_TAG$2 = wellKnownSymbol$8('toStringTag');
1087
+ var test = {};
1088
+
1089
+ test[TO_STRING_TAG$2] = 'z';
1090
+
1091
+ var toStringTagSupport = String(test) === '[object z]';
1092
+
1093
+ var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1094
+ var isCallable$5 = isCallable$g;
1095
+ var classofRaw = classofRaw$2;
1096
+ var wellKnownSymbol$7 = wellKnownSymbol$b;
1097
+
1098
+ var TO_STRING_TAG$1 = wellKnownSymbol$7('toStringTag');
1099
+ var $Object = Object;
1100
+
1101
+ // ES3 wrong here
1102
+ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
1103
+
1104
+ // fallback for IE11 Script Access Denied error
1105
+ var tryGet = function (it, key) {
1106
+ try {
1107
+ return it[key];
1108
+ } catch (error) { /* empty */ }
1109
+ };
1110
+
1111
+ // getting tag from ES6+ `Object.prototype.toString`
1112
+ var classof$3 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1113
+ var O, tag, result;
1114
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1115
+ // @@toStringTag case
1116
+ : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG$1)) == 'string' ? tag
1117
+ // builtinTag case
1118
+ : CORRECT_ARGUMENTS ? classofRaw(O)
1119
+ // ES3 arguments fallback
1120
+ : (result = classofRaw(O)) === 'Object' && isCallable$5(O.callee) ? 'Arguments' : result;
1121
+ };
1122
+
1123
+ var uncurryThis$2 = functionUncurryThis;
1124
+ var fails$2 = fails$b;
1125
+ var isCallable$4 = isCallable$g;
1126
+ var classof$2 = classof$3;
1127
+ var getBuiltIn$4 = getBuiltIn$7;
1128
+ var inspectSource$1 = inspectSource$3;
1129
+
1130
+ var noop = function () { /* empty */ };
1131
+ var construct = getBuiltIn$4('Reflect', 'construct');
1132
+ var constructorRegExp = /^\s*(?:class|function)\b/;
1133
+ var exec = uncurryThis$2(constructorRegExp.exec);
1134
+ var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
1135
+
1136
+ var isConstructorModern = function isConstructor(argument) {
1137
+ if (!isCallable$4(argument)) return false;
1138
+ try {
1139
+ construct(noop, [], argument);
1140
+ return true;
1141
+ } catch (error) {
1142
+ return false;
1143
+ }
1144
+ };
1145
+
1146
+ var isConstructorLegacy = function isConstructor(argument) {
1147
+ if (!isCallable$4(argument)) return false;
1148
+ switch (classof$2(argument)) {
1149
+ case 'AsyncFunction':
1150
+ case 'GeneratorFunction':
1151
+ case 'AsyncGeneratorFunction': return false;
1152
+ }
1153
+ try {
1154
+ // we can't check .prototype since constructors produced by .bind haven't it
1155
+ // `Function#toString` throws on some built-it function in some legacy engines
1156
+ // (for example, `DOMQuad` and similar in FF41-)
1157
+ return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource$1(argument));
1158
+ } catch (error) {
1159
+ return true;
1160
+ }
1161
+ };
1162
+
1163
+ isConstructorLegacy.sham = true;
1164
+
1165
+ // `IsConstructor` abstract operation
1166
+ // https://tc39.es/ecma262/#sec-isconstructor
1167
+ var isConstructor$2 = !construct || fails$2(function () {
1168
+ var called;
1169
+ return isConstructorModern(isConstructorModern.call)
1170
+ || !isConstructorModern(Object)
1171
+ || !isConstructorModern(function () { called = true; })
1172
+ || called;
1173
+ }) ? isConstructorLegacy : isConstructorModern;
1174
+
1175
+ var DESCRIPTORS$3 = descriptors;
1176
+ var definePropertyModule$1 = objectDefineProperty;
1177
+ var createPropertyDescriptor = createPropertyDescriptor$3;
1178
+
1179
+ var createProperty$1 = function (object, key, value) {
1180
+ if (DESCRIPTORS$3) definePropertyModule$1.f(object, key, createPropertyDescriptor(0, value));
1181
+ else object[key] = value;
1182
+ };
1183
+
1184
+ var classof$1 = classof$3;
1185
+ var getMethod = getMethod$3;
1186
+ var isNullOrUndefined$1 = isNullOrUndefined$4;
1187
+ var Iterators = iterators;
1188
+ var wellKnownSymbol$6 = wellKnownSymbol$b;
1189
+
1190
+ var ITERATOR$1 = wellKnownSymbol$6('iterator');
1191
+
1192
+ var getIteratorMethod$3 = function (it) {
1193
+ if (!isNullOrUndefined$1(it)) return getMethod(it, ITERATOR$1)
1194
+ || getMethod(it, '@@iterator')
1195
+ || Iterators[classof$1(it)];
1196
+ };
1197
+
1198
+ var call$6 = functionCall;
1199
+ var aCallable$5 = aCallable$8;
1200
+ var anObject$5 = anObject$a;
1201
+ var tryToString$2 = tryToString$4;
1202
+ var getIteratorMethod$2 = getIteratorMethod$3;
1203
+
1204
+ var $TypeError$6 = TypeError;
1205
+
1206
+ var getIterator$2 = function (argument, usingIterator) {
1207
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$2(argument) : usingIterator;
1208
+ if (aCallable$5(iteratorMethod)) return anObject$5(call$6(iteratorMethod, argument));
1209
+ throw new $TypeError$6(tryToString$2(argument) + ' is not iterable');
1210
+ };
1211
+
1212
+ var bind$4 = functionBindContext;
1213
+ var call$5 = functionCall;
1214
+ var toObject$1 = toObject$3;
1215
+ var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
1216
+ var isArrayIteratorMethod$1 = isArrayIteratorMethod$2;
1217
+ var isConstructor$1 = isConstructor$2;
1218
+ var lengthOfArrayLike$2 = lengthOfArrayLike$4;
1219
+ var createProperty = createProperty$1;
1220
+ var getIterator$1 = getIterator$2;
1221
+ var getIteratorMethod$1 = getIteratorMethod$3;
1222
+
1223
+ var $Array = Array;
1224
+
1225
+ // `Array.from` method implementation
1226
+ // https://tc39.es/ecma262/#sec-array.from
1227
+ var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
1228
+ var O = toObject$1(arrayLike);
1229
+ var IS_CONSTRUCTOR = isConstructor$1(this);
1230
+ var argumentsLength = arguments.length;
1231
+ var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
1232
+ var mapping = mapfn !== undefined;
1233
+ if (mapping) mapfn = bind$4(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
1234
+ var iteratorMethod = getIteratorMethod$1(O);
1235
+ var index = 0;
1236
+ var length, result, step, iterator, next, value;
1237
+ // if the target is not iterable or it's an array with the default iterator - use a simple case
1238
+ if (iteratorMethod && !(this === $Array && isArrayIteratorMethod$1(iteratorMethod))) {
1239
+ result = IS_CONSTRUCTOR ? new this() : [];
1240
+ iterator = getIterator$1(O, iteratorMethod);
1241
+ next = iterator.next;
1242
+ for (;!(step = call$5(next, iterator)).done; index++) {
1243
+ value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
1244
+ createProperty(result, index, value);
1245
+ }
1246
+ } else {
1247
+ length = lengthOfArrayLike$2(O);
1248
+ result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
1249
+ for (;length > index; index++) {
1250
+ value = mapping ? mapfn(O[index], index) : O[index];
1251
+ createProperty(result, index, value);
1252
+ }
1253
+ }
1254
+ result.length = index;
1255
+ return result;
1256
+ };
1257
+
1258
+ var wellKnownSymbol$5 = wellKnownSymbol$b;
1259
+
1260
+ var ITERATOR = wellKnownSymbol$5('iterator');
1261
+ var SAFE_CLOSING = false;
1262
+
1263
+ try {
1264
+ var called = 0;
1265
+ var iteratorWithReturn = {
1266
+ next: function () {
1267
+ return { done: !!called++ };
1268
+ },
1269
+ 'return': function () {
1270
+ SAFE_CLOSING = true;
1271
+ }
1272
+ };
1273
+ iteratorWithReturn[ITERATOR] = function () {
1274
+ return this;
1275
+ };
1276
+ // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
1277
+ Array.from(iteratorWithReturn, function () { throw 2; });
1278
+ } catch (error) { /* empty */ }
1279
+
1280
+ var checkCorrectnessOfIteration$2 = function (exec, SKIP_CLOSING) {
1281
+ try {
1282
+ if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
1283
+ } catch (error) { return false; } // workaround of old WebKit + `eval` bug
1284
+ var ITERATION_SUPPORT = false;
1285
+ try {
1286
+ var object = {};
1287
+ object[ITERATOR] = function () {
1288
+ return {
1289
+ next: function () {
1290
+ return { done: ITERATION_SUPPORT = true };
1291
+ }
1292
+ };
1293
+ };
1294
+ exec(object);
1295
+ } catch (error) { /* empty */ }
1296
+ return ITERATION_SUPPORT;
1297
+ };
1298
+
1299
+ var $$8 = _export;
1300
+ var from = arrayFrom;
1301
+ var checkCorrectnessOfIteration$1 = checkCorrectnessOfIteration$2;
1302
+
1303
+ var INCORRECT_ITERATION = !checkCorrectnessOfIteration$1(function (iterable) {
1304
+ // eslint-disable-next-line es/no-array-from -- required for testing
1305
+ Array.from(iterable);
1306
+ });
1307
+
1308
+ // `Array.from` method
1309
+ // https://tc39.es/ecma262/#sec-array.from
1310
+ $$8({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
1311
+ from: from
1312
+ });
1313
+
1314
+ /* global Bun, Deno -- detection */
1315
+ var globalThis$7 = globalThis_1;
1316
+ var userAgent$3 = environmentUserAgent;
1317
+ var classof = classofRaw$2;
1318
+
1319
+ var userAgentStartsWith = function (string) {
1320
+ return userAgent$3.slice(0, string.length) === string;
1321
+ };
1322
+
1323
+ var environment = (function () {
1324
+ if (userAgentStartsWith('Bun/')) return 'BUN';
1325
+ if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE';
1326
+ if (userAgentStartsWith('Deno/')) return 'DENO';
1327
+ if (userAgentStartsWith('Node.js/')) return 'NODE';
1328
+ if (globalThis$7.Bun && typeof Bun.version == 'string') return 'BUN';
1329
+ if (globalThis$7.Deno && typeof Deno.version == 'object') return 'DENO';
1330
+ if (classof(globalThis$7.process) === 'process') return 'NODE';
1331
+ if (globalThis$7.window && globalThis$7.document) return 'BROWSER';
1332
+ return 'REST';
1333
+ })();
1334
+
1335
+ var ENVIRONMENT$1 = environment;
1336
+
1337
+ var environmentIsNode = ENVIRONMENT$1 === 'NODE';
1338
+
1339
+ var uncurryThis$1 = functionUncurryThis;
1340
+ var aCallable$4 = aCallable$8;
1341
+
1342
+ var functionUncurryThisAccessor = function (object, key, method) {
1343
+ try {
1344
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1345
+ return uncurryThis$1(aCallable$4(Object.getOwnPropertyDescriptor(object, key)[method]));
1346
+ } catch (error) { /* empty */ }
1347
+ };
1348
+
1349
+ var isObject$3 = isObject$9;
1350
+
1351
+ var isPossiblePrototype$1 = function (argument) {
1352
+ return isObject$3(argument) || argument === null;
1353
+ };
1354
+
1355
+ var isPossiblePrototype = isPossiblePrototype$1;
1356
+
1357
+ var $String = String;
1358
+ var $TypeError$5 = TypeError;
1359
+
1360
+ var aPossiblePrototype$1 = function (argument) {
1361
+ if (isPossiblePrototype(argument)) return argument;
1362
+ throw new $TypeError$5("Can't set " + $String(argument) + ' as a prototype');
1363
+ };
1364
+
1365
+ /* eslint-disable no-proto -- safe */
1366
+ var uncurryThisAccessor = functionUncurryThisAccessor;
1367
+ var isObject$2 = isObject$9;
1368
+ var requireObjectCoercible = requireObjectCoercible$3;
1369
+ var aPossiblePrototype = aPossiblePrototype$1;
1370
+
1371
+ // `Object.setPrototypeOf` method
1372
+ // https://tc39.es/ecma262/#sec-object.setprototypeof
1373
+ // Works with __proto__ only. Old v8 can't work with null proto objects.
1374
+ // eslint-disable-next-line es/no-object-setprototypeof -- safe
1375
+ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
1376
+ var CORRECT_SETTER = false;
1377
+ var test = {};
1378
+ var setter;
1379
+ try {
1380
+ setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
1381
+ setter(test, []);
1382
+ CORRECT_SETTER = test instanceof Array;
1383
+ } catch (error) { /* empty */ }
1384
+ return function setPrototypeOf(O, proto) {
1385
+ requireObjectCoercible(O);
1386
+ aPossiblePrototype(proto);
1387
+ if (!isObject$2(O)) return O;
1388
+ if (CORRECT_SETTER) setter(O, proto);
1389
+ else O.__proto__ = proto;
1390
+ return O;
1391
+ };
1392
+ }() : undefined);
1393
+
1394
+ var defineProperty$2 = objectDefineProperty.f;
1395
+ var hasOwn$1 = hasOwnProperty_1;
1396
+ var wellKnownSymbol$4 = wellKnownSymbol$b;
1397
+
1398
+ var TO_STRING_TAG = wellKnownSymbol$4('toStringTag');
1399
+
1400
+ var setToStringTag$1 = function (target, TAG, STATIC) {
1401
+ if (target && !STATIC) target = target.prototype;
1402
+ if (target && !hasOwn$1(target, TO_STRING_TAG)) {
1403
+ defineProperty$2(target, TO_STRING_TAG, { configurable: true, value: TAG });
1404
+ }
1405
+ };
1406
+
1407
+ var makeBuiltIn = makeBuiltInExports;
1408
+ var defineProperty$1 = objectDefineProperty;
1409
+
1410
+ var defineBuiltInAccessor$1 = function (target, name, descriptor) {
1411
+ if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
1412
+ if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
1413
+ return defineProperty$1.f(target, name, descriptor);
1414
+ };
1415
+
1416
+ var getBuiltIn$3 = getBuiltIn$7;
1417
+ var defineBuiltInAccessor = defineBuiltInAccessor$1;
1418
+ var wellKnownSymbol$3 = wellKnownSymbol$b;
1419
+ var DESCRIPTORS$2 = descriptors;
1420
+
1421
+ var SPECIES$2 = wellKnownSymbol$3('species');
1422
+
1423
+ var setSpecies$1 = function (CONSTRUCTOR_NAME) {
1424
+ var Constructor = getBuiltIn$3(CONSTRUCTOR_NAME);
1425
+
1426
+ if (DESCRIPTORS$2 && Constructor && !Constructor[SPECIES$2]) {
1427
+ defineBuiltInAccessor(Constructor, SPECIES$2, {
1428
+ configurable: true,
1429
+ get: function () { return this; }
1430
+ });
1431
+ }
1432
+ };
1433
+
1434
+ var isPrototypeOf$1 = objectIsPrototypeOf;
1435
+
1436
+ var $TypeError$4 = TypeError;
1437
+
1438
+ var anInstance$1 = function (it, Prototype) {
1439
+ if (isPrototypeOf$1(Prototype, it)) return it;
1440
+ throw new $TypeError$4('Incorrect invocation');
1441
+ };
1442
+
1443
+ var isConstructor = isConstructor$2;
1444
+ var tryToString$1 = tryToString$4;
1445
+
1446
+ var $TypeError$3 = TypeError;
1447
+
1448
+ // `Assert: IsConstructor(argument) is true`
1449
+ var aConstructor$1 = function (argument) {
1450
+ if (isConstructor(argument)) return argument;
1451
+ throw new $TypeError$3(tryToString$1(argument) + ' is not a constructor');
1452
+ };
1453
+
1454
+ var anObject$4 = anObject$a;
1455
+ var aConstructor = aConstructor$1;
1456
+ var isNullOrUndefined = isNullOrUndefined$4;
1457
+ var wellKnownSymbol$2 = wellKnownSymbol$b;
1458
+
1459
+ var SPECIES$1 = wellKnownSymbol$2('species');
1460
+
1461
+ // `SpeciesConstructor` abstract operation
1462
+ // https://tc39.es/ecma262/#sec-speciesconstructor
1463
+ var speciesConstructor$1 = function (O, defaultConstructor) {
1464
+ var C = anObject$4(O).constructor;
1465
+ var S;
1466
+ return C === undefined || isNullOrUndefined(S = anObject$4(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
1467
+ };
1468
+
1469
+ var NATIVE_BIND = functionBindNative;
1470
+
1471
+ var FunctionPrototype = Function.prototype;
1472
+ var apply$1 = FunctionPrototype.apply;
1473
+ var call$4 = FunctionPrototype.call;
1474
+
1475
+ // eslint-disable-next-line es/no-reflect -- safe
1476
+ var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call$4.bind(apply$1) : function () {
1477
+ return call$4.apply(apply$1, arguments);
1478
+ });
1479
+
1480
+ var getBuiltIn$2 = getBuiltIn$7;
1481
+
1482
+ var html$2 = getBuiltIn$2('document', 'documentElement');
1483
+
1484
+ var uncurryThis = functionUncurryThis;
1485
+
1486
+ var arraySlice$1 = uncurryThis([].slice);
1487
+
1488
+ var $TypeError$2 = TypeError;
1489
+
1490
+ var validateArgumentsLength$1 = function (passed, required) {
1491
+ if (passed < required) throw new $TypeError$2('Not enough arguments');
1492
+ return passed;
1493
+ };
1494
+
1495
+ var userAgent$2 = environmentUserAgent;
1496
+
1497
+ // eslint-disable-next-line redos/no-vulnerable -- safe
1498
+ var environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$2);
1499
+
1500
+ var globalThis$6 = globalThis_1;
1501
+ var apply = functionApply;
1502
+ var bind$3 = functionBindContext;
1503
+ var isCallable$3 = isCallable$g;
1504
+ var hasOwn = hasOwnProperty_1;
1505
+ var fails$1 = fails$b;
1506
+ var html$1 = html$2;
1507
+ var arraySlice = arraySlice$1;
1508
+ var createElement = documentCreateElement$1;
1509
+ var validateArgumentsLength = validateArgumentsLength$1;
1510
+ var IS_IOS$1 = environmentIsIos;
1511
+ var IS_NODE$2 = environmentIsNode;
1512
+
1513
+ var set = globalThis$6.setImmediate;
1514
+ var clear = globalThis$6.clearImmediate;
1515
+ var process$2 = globalThis$6.process;
1516
+ var Dispatch = globalThis$6.Dispatch;
1517
+ var Function$1 = globalThis$6.Function;
1518
+ var MessageChannel = globalThis$6.MessageChannel;
1519
+ var String$1 = globalThis$6.String;
1520
+ var counter = 0;
1521
+ var queue$2 = {};
1522
+ var ONREADYSTATECHANGE = 'onreadystatechange';
1523
+ var $location, defer, channel, port;
1524
+
1525
+ fails$1(function () {
1526
+ // Deno throws a ReferenceError on `location` access without `--location` flag
1527
+ $location = globalThis$6.location;
1528
+ });
1529
+
1530
+ var run = function (id) {
1531
+ if (hasOwn(queue$2, id)) {
1532
+ var fn = queue$2[id];
1533
+ delete queue$2[id];
1534
+ fn();
1535
+ }
1536
+ };
1537
+
1538
+ var runner = function (id) {
1539
+ return function () {
1540
+ run(id);
1541
+ };
1542
+ };
1543
+
1544
+ var eventListener = function (event) {
1545
+ run(event.data);
1546
+ };
1547
+
1548
+ var globalPostMessageDefer = function (id) {
1549
+ // old engines have not location.origin
1550
+ globalThis$6.postMessage(String$1(id), $location.protocol + '//' + $location.host);
1551
+ };
1552
+
1553
+ // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
1554
+ if (!set || !clear) {
1555
+ set = function setImmediate(handler) {
1556
+ validateArgumentsLength(arguments.length, 1);
1557
+ var fn = isCallable$3(handler) ? handler : Function$1(handler);
1558
+ var args = arraySlice(arguments, 1);
1559
+ queue$2[++counter] = function () {
1560
+ apply(fn, undefined, args);
1561
+ };
1562
+ defer(counter);
1563
+ return counter;
1564
+ };
1565
+ clear = function clearImmediate(id) {
1566
+ delete queue$2[id];
1567
+ };
1568
+ // Node.js 0.8-
1569
+ if (IS_NODE$2) {
1570
+ defer = function (id) {
1571
+ process$2.nextTick(runner(id));
1572
+ };
1573
+ // Sphere (JS game engine) Dispatch API
1574
+ } else if (Dispatch && Dispatch.now) {
1575
+ defer = function (id) {
1576
+ Dispatch.now(runner(id));
1577
+ };
1578
+ // Browsers with MessageChannel, includes WebWorkers
1579
+ // except iOS - https://github.com/zloirock/core-js/issues/624
1580
+ } else if (MessageChannel && !IS_IOS$1) {
1581
+ channel = new MessageChannel();
1582
+ port = channel.port2;
1583
+ channel.port1.onmessage = eventListener;
1584
+ defer = bind$3(port.postMessage, port);
1585
+ // Browsers with postMessage, skip WebWorkers
1586
+ // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
1587
+ } else if (
1588
+ globalThis$6.addEventListener &&
1589
+ isCallable$3(globalThis$6.postMessage) &&
1590
+ !globalThis$6.importScripts &&
1591
+ $location && $location.protocol !== 'file:' &&
1592
+ !fails$1(globalPostMessageDefer)
1593
+ ) {
1594
+ defer = globalPostMessageDefer;
1595
+ globalThis$6.addEventListener('message', eventListener, false);
1596
+ // IE8-
1597
+ } else if (ONREADYSTATECHANGE in createElement('script')) {
1598
+ defer = function (id) {
1599
+ html$1.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
1600
+ html$1.removeChild(this);
1601
+ run(id);
1602
+ };
1603
+ };
1604
+ // Rest old browsers
1605
+ } else {
1606
+ defer = function (id) {
1607
+ setTimeout(runner(id), 0);
1608
+ };
1609
+ }
1610
+ }
1611
+
1612
+ var task$1 = {
1613
+ set: set,
1614
+ clear: clear
1615
+ };
1616
+
1617
+ var globalThis$5 = globalThis_1;
1618
+ var DESCRIPTORS$1 = descriptors;
1619
+
1620
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1621
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1622
+
1623
+ // Avoid NodeJS experimental warning
1624
+ var safeGetBuiltIn$1 = function (name) {
1625
+ if (!DESCRIPTORS$1) return globalThis$5[name];
1626
+ var descriptor = getOwnPropertyDescriptor(globalThis$5, name);
1627
+ return descriptor && descriptor.value;
1628
+ };
1629
+
1630
+ var Queue$2 = function () {
1631
+ this.head = null;
1632
+ this.tail = null;
1633
+ };
1634
+
1635
+ Queue$2.prototype = {
1636
+ add: function (item) {
1637
+ var entry = { item: item, next: null };
1638
+ var tail = this.tail;
1639
+ if (tail) tail.next = entry;
1640
+ else this.head = entry;
1641
+ this.tail = entry;
1642
+ },
1643
+ get: function () {
1644
+ var entry = this.head;
1645
+ if (entry) {
1646
+ var next = this.head = entry.next;
1647
+ if (next === null) this.tail = null;
1648
+ return entry.item;
1649
+ }
1650
+ }
1651
+ };
1652
+
1653
+ var queue$1 = Queue$2;
1654
+
1655
+ var userAgent$1 = environmentUserAgent;
1656
+
1657
+ var environmentIsIosPebble = /ipad|iphone|ipod/i.test(userAgent$1) && typeof Pebble != 'undefined';
1658
+
1659
+ var userAgent = environmentUserAgent;
1660
+
1661
+ var environmentIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent);
1662
+
1663
+ var globalThis$4 = globalThis_1;
1664
+ var safeGetBuiltIn = safeGetBuiltIn$1;
1665
+ var bind$2 = functionBindContext;
1666
+ var macrotask = task$1.set;
1667
+ var Queue$1 = queue$1;
1668
+ var IS_IOS = environmentIsIos;
1669
+ var IS_IOS_PEBBLE = environmentIsIosPebble;
1670
+ var IS_WEBOS_WEBKIT = environmentIsWebosWebkit;
1671
+ var IS_NODE$1 = environmentIsNode;
1672
+
1673
+ var MutationObserver$1 = globalThis$4.MutationObserver || globalThis$4.WebKitMutationObserver;
1674
+ var document$2 = globalThis$4.document;
1675
+ var process$1 = globalThis$4.process;
1676
+ var Promise$1 = globalThis$4.Promise;
1677
+ var microtask$1 = safeGetBuiltIn('queueMicrotask');
1678
+ var notify$1, toggle, node, promise, then;
1679
+
1680
+ // modern engines have queueMicrotask method
1681
+ if (!microtask$1) {
1682
+ var queue = new Queue$1();
1683
+
1684
+ var flush = function () {
1685
+ var parent, fn;
1686
+ if (IS_NODE$1 && (parent = process$1.domain)) parent.exit();
1687
+ while (fn = queue.get()) try {
1688
+ fn();
1689
+ } catch (error) {
1690
+ if (queue.head) notify$1();
1691
+ throw error;
1692
+ }
1693
+ if (parent) parent.enter();
1694
+ };
1695
+
1696
+ // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
1697
+ // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
1698
+ if (!IS_IOS && !IS_NODE$1 && !IS_WEBOS_WEBKIT && MutationObserver$1 && document$2) {
1699
+ toggle = true;
1700
+ node = document$2.createTextNode('');
1701
+ new MutationObserver$1(flush).observe(node, { characterData: true });
1702
+ notify$1 = function () {
1703
+ node.data = toggle = !toggle;
1704
+ };
1705
+ // environments with maybe non-completely correct, but existent Promise
1706
+ } else if (!IS_IOS_PEBBLE && Promise$1 && Promise$1.resolve) {
1707
+ // Promise.resolve without an argument throws an error in LG WebOS 2
1708
+ promise = Promise$1.resolve(undefined);
1709
+ // workaround of WebKit ~ iOS Safari 10.1 bug
1710
+ promise.constructor = Promise$1;
1711
+ then = bind$2(promise.then, promise);
1712
+ notify$1 = function () {
1713
+ then(flush);
1714
+ };
1715
+ // Node.js without promises
1716
+ } else if (IS_NODE$1) {
1717
+ notify$1 = function () {
1718
+ process$1.nextTick(flush);
1719
+ };
1720
+ // for other environments - macrotask based on:
1721
+ // - setImmediate
1722
+ // - MessageChannel
1723
+ // - window.postMessage
1724
+ // - onreadystatechange
1725
+ // - setTimeout
1726
+ } else {
1727
+ // `webpack` dev server bug on IE global methods - use bind(fn, global)
1728
+ macrotask = bind$2(macrotask, globalThis$4);
1729
+ notify$1 = function () {
1730
+ macrotask(flush);
1731
+ };
1732
+ }
1733
+
1734
+ microtask$1 = function (fn) {
1735
+ if (!queue.head) notify$1();
1736
+ queue.add(fn);
1737
+ };
1738
+ }
1739
+
1740
+ var microtask_1 = microtask$1;
1741
+
1742
+ var hostReportErrors$1 = function (a, b) {
1743
+ try {
1744
+ // eslint-disable-next-line no-console -- safe
1745
+ arguments.length === 1 ? (void 0) : (void 0);
1746
+ } catch (error) { /* empty */ }
1747
+ };
1748
+
1749
+ var perform$3 = function (exec) {
1750
+ try {
1751
+ return { error: false, value: exec() };
1752
+ } catch (error) {
1753
+ return { error: true, value: error };
1754
+ }
1755
+ };
1756
+
1757
+ var globalThis$3 = globalThis_1;
1758
+
1759
+ var promiseNativeConstructor = globalThis$3.Promise;
1760
+
1761
+ var globalThis$2 = globalThis_1;
1762
+ var NativePromiseConstructor$3 = promiseNativeConstructor;
1763
+ var isCallable$2 = isCallable$g;
1764
+ var isForced = isForced_1;
1765
+ var inspectSource = inspectSource$3;
1766
+ var wellKnownSymbol$1 = wellKnownSymbol$b;
1767
+ var ENVIRONMENT = environment;
1768
+ var V8_VERSION = environmentV8Version;
1769
+
1770
+ NativePromiseConstructor$3 && NativePromiseConstructor$3.prototype;
1771
+ var SPECIES = wellKnownSymbol$1('species');
1772
+ var SUBCLASSING = false;
1773
+ var NATIVE_PROMISE_REJECTION_EVENT$1 = isCallable$2(globalThis$2.PromiseRejectionEvent);
1774
+
1775
+ var FORCED_PROMISE_CONSTRUCTOR$5 = isForced('Promise', function () {
1776
+ var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor$3);
1777
+ var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor$3);
1778
+ // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
1779
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
1780
+ // We can't detect it synchronously, so just check versions
1781
+ if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
1782
+ // We can't use @@species feature detection in V8 since it causes
1783
+ // deoptimization and performance degradation
1784
+ // https://github.com/zloirock/core-js/issues/679
1785
+ if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
1786
+ // Detect correctness of subclassing with @@species support
1787
+ var promise = new NativePromiseConstructor$3(function (resolve) { resolve(1); });
1788
+ var FakePromise = function (exec) {
1789
+ exec(function () { /* empty */ }, function () { /* empty */ });
1790
+ };
1791
+ var constructor = promise.constructor = {};
1792
+ constructor[SPECIES] = FakePromise;
1793
+ SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
1794
+ if (!SUBCLASSING) return true;
1795
+ // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
1796
+ } return !GLOBAL_CORE_JS_PROMISE && (ENVIRONMENT === 'BROWSER' || ENVIRONMENT === 'DENO') && !NATIVE_PROMISE_REJECTION_EVENT$1;
1797
+ });
1798
+
1799
+ var promiseConstructorDetection = {
1800
+ CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR$5,
1801
+ REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT$1,
1802
+ SUBCLASSING: SUBCLASSING
1803
+ };
1804
+
1805
+ var newPromiseCapability$2 = {};
1806
+
1807
+ var aCallable$3 = aCallable$8;
1808
+
1809
+ var $TypeError$1 = TypeError;
1810
+
1811
+ var PromiseCapability = function (C) {
1812
+ var resolve, reject;
1813
+ this.promise = new C(function ($$resolve, $$reject) {
1814
+ if (resolve !== undefined || reject !== undefined) throw new $TypeError$1('Bad Promise constructor');
1815
+ resolve = $$resolve;
1816
+ reject = $$reject;
1817
+ });
1818
+ this.resolve = aCallable$3(resolve);
1819
+ this.reject = aCallable$3(reject);
1820
+ };
1821
+
1822
+ // `NewPromiseCapability` abstract operation
1823
+ // https://tc39.es/ecma262/#sec-newpromisecapability
1824
+ newPromiseCapability$2.f = function (C) {
1825
+ return new PromiseCapability(C);
1826
+ };
1827
+
1828
+ var $$7 = _export;
1829
+ var IS_NODE = environmentIsNode;
1830
+ var globalThis$1 = globalThis_1;
1831
+ var call$3 = functionCall;
1832
+ var defineBuiltIn$1 = defineBuiltIn$3;
1833
+ var setPrototypeOf = objectSetPrototypeOf;
1834
+ var setToStringTag = setToStringTag$1;
1835
+ var setSpecies = setSpecies$1;
1836
+ var aCallable$2 = aCallable$8;
1837
+ var isCallable$1 = isCallable$g;
1838
+ var isObject$1 = isObject$9;
1839
+ var anInstance = anInstance$1;
1840
+ var speciesConstructor = speciesConstructor$1;
1841
+ var task = task$1.set;
1842
+ var microtask = microtask_1;
1843
+ var hostReportErrors = hostReportErrors$1;
1844
+ var perform$2 = perform$3;
1845
+ var Queue = queue$1;
1846
+ var InternalStateModule = internalState;
1847
+ var NativePromiseConstructor$2 = promiseNativeConstructor;
1848
+ var PromiseConstructorDetection = promiseConstructorDetection;
1849
+ var newPromiseCapabilityModule$3 = newPromiseCapability$2;
1850
+
1851
+ var PROMISE = 'Promise';
1852
+ var FORCED_PROMISE_CONSTRUCTOR$4 = PromiseConstructorDetection.CONSTRUCTOR;
1853
+ var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
1854
+ var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
1855
+ var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
1856
+ var setInternalState = InternalStateModule.set;
1857
+ var NativePromisePrototype$1 = NativePromiseConstructor$2 && NativePromiseConstructor$2.prototype;
1858
+ var PromiseConstructor = NativePromiseConstructor$2;
1859
+ var PromisePrototype = NativePromisePrototype$1;
1860
+ var TypeError$1 = globalThis$1.TypeError;
1861
+ var document$1 = globalThis$1.document;
1862
+ var process = globalThis$1.process;
1863
+ var newPromiseCapability$1 = newPromiseCapabilityModule$3.f;
1864
+ var newGenericPromiseCapability = newPromiseCapability$1;
1865
+
1866
+ var DISPATCH_EVENT = !!(document$1 && document$1.createEvent && globalThis$1.dispatchEvent);
1867
+ var UNHANDLED_REJECTION = 'unhandledrejection';
1868
+ var REJECTION_HANDLED = 'rejectionhandled';
1869
+ var PENDING = 0;
1870
+ var FULFILLED = 1;
1871
+ var REJECTED = 2;
1872
+ var HANDLED = 1;
1873
+ var UNHANDLED = 2;
1874
+
1875
+ var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
1876
+
1877
+ // helpers
1878
+ var isThenable = function (it) {
1879
+ var then;
1880
+ return isObject$1(it) && isCallable$1(then = it.then) ? then : false;
1881
+ };
1882
+
1883
+ var callReaction = function (reaction, state) {
1884
+ var value = state.value;
1885
+ var ok = state.state === FULFILLED;
1886
+ var handler = ok ? reaction.ok : reaction.fail;
1887
+ var resolve = reaction.resolve;
1888
+ var reject = reaction.reject;
1889
+ var domain = reaction.domain;
1890
+ var result, then, exited;
1891
+ try {
1892
+ if (handler) {
1893
+ if (!ok) {
1894
+ if (state.rejection === UNHANDLED) onHandleUnhandled(state);
1895
+ state.rejection = HANDLED;
1896
+ }
1897
+ if (handler === true) result = value;
1898
+ else {
1899
+ if (domain) domain.enter();
1900
+ result = handler(value); // can throw
1901
+ if (domain) {
1902
+ domain.exit();
1903
+ exited = true;
1904
+ }
1905
+ }
1906
+ if (result === reaction.promise) {
1907
+ reject(new TypeError$1('Promise-chain cycle'));
1908
+ } else if (then = isThenable(result)) {
1909
+ call$3(then, result, resolve, reject);
1910
+ } else resolve(result);
1911
+ } else reject(value);
1912
+ } catch (error) {
1913
+ if (domain && !exited) domain.exit();
1914
+ reject(error);
1915
+ }
1916
+ };
1917
+
1918
+ var notify = function (state, isReject) {
1919
+ if (state.notified) return;
1920
+ state.notified = true;
1921
+ microtask(function () {
1922
+ var reactions = state.reactions;
1923
+ var reaction;
1924
+ while (reaction = reactions.get()) {
1925
+ callReaction(reaction, state);
1926
+ }
1927
+ state.notified = false;
1928
+ if (isReject && !state.rejection) onUnhandled(state);
1929
+ });
1930
+ };
1931
+
1932
+ var dispatchEvent = function (name, promise, reason) {
1933
+ var event, handler;
1934
+ if (DISPATCH_EVENT) {
1935
+ event = document$1.createEvent('Event');
1936
+ event.promise = promise;
1937
+ event.reason = reason;
1938
+ event.initEvent(name, false, true);
1939
+ globalThis$1.dispatchEvent(event);
1940
+ } else event = { promise: promise, reason: reason };
1941
+ if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis$1['on' + name])) handler(event);
1942
+ else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
1943
+ };
1944
+
1945
+ var onUnhandled = function (state) {
1946
+ call$3(task, globalThis$1, function () {
1947
+ var promise = state.facade;
1948
+ var value = state.value;
1949
+ var IS_UNHANDLED = isUnhandled(state);
1950
+ var result;
1951
+ if (IS_UNHANDLED) {
1952
+ result = perform$2(function () {
1953
+ if (IS_NODE) {
1954
+ process.emit('unhandledRejection', value, promise);
1955
+ } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
1956
+ });
1957
+ // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
1958
+ state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
1959
+ if (result.error) throw result.value;
1960
+ }
1961
+ });
1962
+ };
1963
+
1964
+ var isUnhandled = function (state) {
1965
+ return state.rejection !== HANDLED && !state.parent;
1966
+ };
1967
+
1968
+ var onHandleUnhandled = function (state) {
1969
+ call$3(task, globalThis$1, function () {
1970
+ var promise = state.facade;
1971
+ if (IS_NODE) {
1972
+ process.emit('rejectionHandled', promise);
1973
+ } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
1974
+ });
1975
+ };
1976
+
1977
+ var bind$1 = function (fn, state, unwrap) {
1978
+ return function (value) {
1979
+ fn(state, value, unwrap);
1980
+ };
1981
+ };
1982
+
1983
+ var internalReject = function (state, value, unwrap) {
1984
+ if (state.done) return;
1985
+ state.done = true;
1986
+ if (unwrap) state = unwrap;
1987
+ state.value = value;
1988
+ state.state = REJECTED;
1989
+ notify(state, true);
1990
+ };
1991
+
1992
+ var internalResolve = function (state, value, unwrap) {
1993
+ if (state.done) return;
1994
+ state.done = true;
1995
+ if (unwrap) state = unwrap;
1996
+ try {
1997
+ if (state.facade === value) throw new TypeError$1("Promise can't be resolved itself");
1998
+ var then = isThenable(value);
1999
+ if (then) {
2000
+ microtask(function () {
2001
+ var wrapper = { done: false };
2002
+ try {
2003
+ call$3(then, value,
2004
+ bind$1(internalResolve, wrapper, state),
2005
+ bind$1(internalReject, wrapper, state)
2006
+ );
2007
+ } catch (error) {
2008
+ internalReject(wrapper, error, state);
2009
+ }
2010
+ });
2011
+ } else {
2012
+ state.value = value;
2013
+ state.state = FULFILLED;
2014
+ notify(state, false);
2015
+ }
2016
+ } catch (error) {
2017
+ internalReject({ done: false }, error, state);
2018
+ }
2019
+ };
2020
+
2021
+ // constructor polyfill
2022
+ if (FORCED_PROMISE_CONSTRUCTOR$4) {
2023
+ // 25.4.3.1 Promise(executor)
2024
+ PromiseConstructor = function Promise(executor) {
2025
+ anInstance(this, PromisePrototype);
2026
+ aCallable$2(executor);
2027
+ call$3(Internal, this);
2028
+ var state = getInternalPromiseState(this);
2029
+ try {
2030
+ executor(bind$1(internalResolve, state), bind$1(internalReject, state));
2031
+ } catch (error) {
2032
+ internalReject(state, error);
2033
+ }
2034
+ };
2035
+
2036
+ PromisePrototype = PromiseConstructor.prototype;
2037
+
2038
+ // eslint-disable-next-line no-unused-vars -- required for `.length`
2039
+ Internal = function Promise(executor) {
2040
+ setInternalState(this, {
2041
+ type: PROMISE,
2042
+ done: false,
2043
+ notified: false,
2044
+ parent: false,
2045
+ reactions: new Queue(),
2046
+ rejection: false,
2047
+ state: PENDING,
2048
+ value: undefined
2049
+ });
2050
+ };
2051
+
2052
+ // `Promise.prototype.then` method
2053
+ // https://tc39.es/ecma262/#sec-promise.prototype.then
2054
+ Internal.prototype = defineBuiltIn$1(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
2055
+ var state = getInternalPromiseState(this);
2056
+ var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
2057
+ state.parent = true;
2058
+ reaction.ok = isCallable$1(onFulfilled) ? onFulfilled : true;
2059
+ reaction.fail = isCallable$1(onRejected) && onRejected;
2060
+ reaction.domain = IS_NODE ? process.domain : undefined;
2061
+ if (state.state === PENDING) state.reactions.add(reaction);
2062
+ else microtask(function () {
2063
+ callReaction(reaction, state);
2064
+ });
2065
+ return reaction.promise;
2066
+ });
2067
+
2068
+ OwnPromiseCapability = function () {
2069
+ var promise = new Internal();
2070
+ var state = getInternalPromiseState(promise);
2071
+ this.promise = promise;
2072
+ this.resolve = bind$1(internalResolve, state);
2073
+ this.reject = bind$1(internalReject, state);
2074
+ };
2075
+
2076
+ newPromiseCapabilityModule$3.f = newPromiseCapability$1 = function (C) {
2077
+ return C === PromiseConstructor || C === PromiseWrapper
2078
+ ? new OwnPromiseCapability(C)
2079
+ : newGenericPromiseCapability(C);
2080
+ };
2081
+
2082
+ if (isCallable$1(NativePromiseConstructor$2) && NativePromisePrototype$1 !== Object.prototype) {
2083
+ nativeThen = NativePromisePrototype$1.then;
2084
+
2085
+ if (!NATIVE_PROMISE_SUBCLASSING) {
2086
+ // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
2087
+ defineBuiltIn$1(NativePromisePrototype$1, 'then', function then(onFulfilled, onRejected) {
2088
+ var that = this;
2089
+ return new PromiseConstructor(function (resolve, reject) {
2090
+ call$3(nativeThen, that, resolve, reject);
2091
+ }).then(onFulfilled, onRejected);
2092
+ // https://github.com/zloirock/core-js/issues/640
2093
+ }, { unsafe: true });
2094
+ }
2095
+
2096
+ // make `.constructor === Promise` work for native promise-based APIs
2097
+ try {
2098
+ delete NativePromisePrototype$1.constructor;
2099
+ } catch (error) { /* empty */ }
2100
+
2101
+ // make `instanceof Promise` work for native promise-based APIs
2102
+ if (setPrototypeOf) {
2103
+ setPrototypeOf(NativePromisePrototype$1, PromisePrototype);
2104
+ }
2105
+ }
2106
+ }
2107
+
2108
+ $$7({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
2109
+ Promise: PromiseConstructor
2110
+ });
2111
+
2112
+ setToStringTag(PromiseConstructor, PROMISE, false);
2113
+ setSpecies(PROMISE);
2114
+
2115
+ var bind = functionBindContext;
2116
+ var call$2 = functionCall;
2117
+ var anObject$3 = anObject$a;
2118
+ var tryToString = tryToString$4;
2119
+ var isArrayIteratorMethod = isArrayIteratorMethod$2;
2120
+ var lengthOfArrayLike$1 = lengthOfArrayLike$4;
2121
+ var isPrototypeOf = objectIsPrototypeOf;
2122
+ var getIterator = getIterator$2;
2123
+ var getIteratorMethod = getIteratorMethod$3;
2124
+ var iteratorClose = iteratorClose$2;
2125
+
2126
+ var $TypeError = TypeError;
2127
+
2128
+ var Result = function (stopped, result) {
2129
+ this.stopped = stopped;
2130
+ this.result = result;
2131
+ };
2132
+
2133
+ var ResultPrototype = Result.prototype;
2134
+
2135
+ var iterate$2 = function (iterable, unboundFunction, options) {
2136
+ var that = options && options.that;
2137
+ var AS_ENTRIES = !!(options && options.AS_ENTRIES);
2138
+ var IS_RECORD = !!(options && options.IS_RECORD);
2139
+ var IS_ITERATOR = !!(options && options.IS_ITERATOR);
2140
+ var INTERRUPTED = !!(options && options.INTERRUPTED);
2141
+ var fn = bind(unboundFunction, that);
2142
+ var iterator, iterFn, index, length, result, next, step;
2143
+
2144
+ var stop = function (condition) {
2145
+ if (iterator) iteratorClose(iterator, 'normal', condition);
2146
+ return new Result(true, condition);
2147
+ };
2148
+
2149
+ var callFn = function (value) {
2150
+ if (AS_ENTRIES) {
2151
+ anObject$3(value);
2152
+ return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
2153
+ } return INTERRUPTED ? fn(value, stop) : fn(value);
2154
+ };
2155
+
2156
+ if (IS_RECORD) {
2157
+ iterator = iterable.iterator;
2158
+ } else if (IS_ITERATOR) {
2159
+ iterator = iterable;
2160
+ } else {
2161
+ iterFn = getIteratorMethod(iterable);
2162
+ if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable');
2163
+ // optimisation for array iterators
2164
+ if (isArrayIteratorMethod(iterFn)) {
2165
+ for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
2166
+ result = callFn(iterable[index]);
2167
+ if (result && isPrototypeOf(ResultPrototype, result)) return result;
2168
+ } return new Result(false);
2169
+ }
2170
+ iterator = getIterator(iterable, iterFn);
2171
+ }
2172
+
2173
+ next = IS_RECORD ? iterable.next : iterator.next;
2174
+ while (!(step = call$2(next, iterator)).done) {
2175
+ try {
2176
+ result = callFn(step.value);
2177
+ } catch (error) {
2178
+ iteratorClose(iterator, 'throw', error);
2179
+ }
2180
+ if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
2181
+ } return new Result(false);
2182
+ };
2183
+
2184
+ var NativePromiseConstructor$1 = promiseNativeConstructor;
2185
+ var checkCorrectnessOfIteration = checkCorrectnessOfIteration$2;
2186
+ var FORCED_PROMISE_CONSTRUCTOR$3 = promiseConstructorDetection.CONSTRUCTOR;
2187
+
2188
+ var promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR$3 || !checkCorrectnessOfIteration(function (iterable) {
2189
+ NativePromiseConstructor$1.all(iterable).then(undefined, function () { /* empty */ });
2190
+ });
2191
+
2192
+ var $$6 = _export;
2193
+ var call$1 = functionCall;
2194
+ var aCallable$1 = aCallable$8;
2195
+ var newPromiseCapabilityModule$2 = newPromiseCapability$2;
2196
+ var perform$1 = perform$3;
2197
+ var iterate$1 = iterate$2;
2198
+ var PROMISE_STATICS_INCORRECT_ITERATION$1 = promiseStaticsIncorrectIteration;
2199
+
2200
+ // `Promise.all` method
2201
+ // https://tc39.es/ecma262/#sec-promise.all
2202
+ $$6({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION$1 }, {
2203
+ all: function all(iterable) {
2204
+ var C = this;
2205
+ var capability = newPromiseCapabilityModule$2.f(C);
2206
+ var resolve = capability.resolve;
2207
+ var reject = capability.reject;
2208
+ var result = perform$1(function () {
2209
+ var $promiseResolve = aCallable$1(C.resolve);
2210
+ var values = [];
2211
+ var counter = 0;
2212
+ var remaining = 1;
2213
+ iterate$1(iterable, function (promise) {
2214
+ var index = counter++;
2215
+ var alreadyCalled = false;
2216
+ remaining++;
2217
+ call$1($promiseResolve, C, promise).then(function (value) {
2218
+ if (alreadyCalled) return;
2219
+ alreadyCalled = true;
2220
+ values[index] = value;
2221
+ --remaining || resolve(values);
2222
+ }, reject);
2223
+ });
2224
+ --remaining || resolve(values);
2225
+ });
2226
+ if (result.error) reject(result.value);
2227
+ return capability.promise;
2228
+ }
2229
+ });
2230
+
2231
+ var $$5 = _export;
2232
+ var FORCED_PROMISE_CONSTRUCTOR$2 = promiseConstructorDetection.CONSTRUCTOR;
2233
+ var NativePromiseConstructor = promiseNativeConstructor;
2234
+ var getBuiltIn$1 = getBuiltIn$7;
2235
+ var isCallable = isCallable$g;
2236
+ var defineBuiltIn = defineBuiltIn$3;
2237
+
2238
+ var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
2239
+
2240
+ // `Promise.prototype.catch` method
2241
+ // https://tc39.es/ecma262/#sec-promise.prototype.catch
2242
+ $$5({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR$2, real: true }, {
2243
+ 'catch': function (onRejected) {
2244
+ return this.then(undefined, onRejected);
2245
+ }
2246
+ });
2247
+
2248
+ // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
2249
+ if (isCallable(NativePromiseConstructor)) {
2250
+ var method = getBuiltIn$1('Promise').prototype['catch'];
2251
+ if (NativePromisePrototype['catch'] !== method) {
2252
+ defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
2253
+ }
2254
+ }
2255
+
2256
+ var $$4 = _export;
2257
+ var call = functionCall;
2258
+ var aCallable = aCallable$8;
2259
+ var newPromiseCapabilityModule$1 = newPromiseCapability$2;
2260
+ var perform = perform$3;
2261
+ var iterate = iterate$2;
2262
+ var PROMISE_STATICS_INCORRECT_ITERATION = promiseStaticsIncorrectIteration;
2263
+
2264
+ // `Promise.race` method
2265
+ // https://tc39.es/ecma262/#sec-promise.race
2266
+ $$4({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
2267
+ race: function race(iterable) {
2268
+ var C = this;
2269
+ var capability = newPromiseCapabilityModule$1.f(C);
2270
+ var reject = capability.reject;
2271
+ var result = perform(function () {
2272
+ var $promiseResolve = aCallable(C.resolve);
2273
+ iterate(iterable, function (promise) {
2274
+ call($promiseResolve, C, promise).then(capability.resolve, reject);
2275
+ });
2276
+ });
2277
+ if (result.error) reject(result.value);
2278
+ return capability.promise;
2279
+ }
2280
+ });
2281
+
2282
+ var $$3 = _export;
2283
+ var newPromiseCapabilityModule = newPromiseCapability$2;
2284
+ var FORCED_PROMISE_CONSTRUCTOR$1 = promiseConstructorDetection.CONSTRUCTOR;
2285
+
2286
+ // `Promise.reject` method
2287
+ // https://tc39.es/ecma262/#sec-promise.reject
2288
+ $$3({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR$1 }, {
2289
+ reject: function reject(r) {
2290
+ var capability = newPromiseCapabilityModule.f(this);
2291
+ var capabilityReject = capability.reject;
2292
+ capabilityReject(r);
2293
+ return capability.promise;
2294
+ }
2295
+ });
2296
+
2297
+ var anObject$2 = anObject$a;
2298
+ var isObject = isObject$9;
2299
+ var newPromiseCapability = newPromiseCapability$2;
2300
+
2301
+ var promiseResolve$1 = function (C, x) {
2302
+ anObject$2(C);
2303
+ if (isObject(x) && x.constructor === C) return x;
2304
+ var promiseCapability = newPromiseCapability.f(C);
2305
+ var resolve = promiseCapability.resolve;
2306
+ resolve(x);
2307
+ return promiseCapability.promise;
2308
+ };
2309
+
2310
+ var $$2 = _export;
2311
+ var getBuiltIn = getBuiltIn$7;
2312
+ var FORCED_PROMISE_CONSTRUCTOR = promiseConstructorDetection.CONSTRUCTOR;
2313
+ var promiseResolve = promiseResolve$1;
2314
+
2315
+ getBuiltIn('Promise');
2316
+
2317
+ // `Promise.resolve` method
2318
+ // https://tc39.es/ecma262/#sec-promise.resolve
2319
+ $$2({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
2320
+ resolve: function resolve(x) {
2321
+ return promiseResolve(this, x);
2322
+ }
2323
+ });
2324
+
2325
+ var objectDefineProperties = {};
2326
+
2327
+ var internalObjectKeys = objectKeysInternal;
2328
+ var enumBugKeys$1 = enumBugKeys$3;
2329
+
2330
+ // `Object.keys` method
2331
+ // https://tc39.es/ecma262/#sec-object.keys
2332
+ // eslint-disable-next-line es/no-object-keys -- safe
2333
+ var objectKeys$1 = Object.keys || function keys(O) {
2334
+ return internalObjectKeys(O, enumBugKeys$1);
2335
+ };
2336
+
2337
+ var DESCRIPTORS = descriptors;
2338
+ var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
2339
+ var definePropertyModule = objectDefineProperty;
2340
+ var anObject$1 = anObject$a;
2341
+ var toIndexedObject = toIndexedObject$4;
2342
+ var objectKeys = objectKeys$1;
2343
+
2344
+ // `Object.defineProperties` method
2345
+ // https://tc39.es/ecma262/#sec-object.defineproperties
2346
+ // eslint-disable-next-line es/no-object-defineproperties -- safe
2347
+ objectDefineProperties.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
2348
+ anObject$1(O);
2349
+ var props = toIndexedObject(Properties);
2350
+ var keys = objectKeys(Properties);
2351
+ var length = keys.length;
2352
+ var index = 0;
2353
+ var key;
2354
+ while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
2355
+ return O;
2356
+ };
2357
+
2358
+ /* global ActiveXObject -- old IE, WSH */
2359
+ var anObject = anObject$a;
2360
+ var definePropertiesModule = objectDefineProperties;
2361
+ var enumBugKeys = enumBugKeys$3;
2362
+ var hiddenKeys = hiddenKeys$4;
2363
+ var html = html$2;
2364
+ var documentCreateElement = documentCreateElement$1;
2365
+ var sharedKey = sharedKey$2;
2366
+
2367
+ var GT = '>';
2368
+ var LT = '<';
2369
+ var PROTOTYPE = 'prototype';
2370
+ var SCRIPT = 'script';
2371
+ var IE_PROTO = sharedKey('IE_PROTO');
2372
+
2373
+ var EmptyConstructor = function () { /* empty */ };
2374
+
2375
+ var scriptTag = function (content) {
2376
+ return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
2377
+ };
2378
+
2379
+ // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
2380
+ var NullProtoObjectViaActiveX = function (activeXDocument) {
2381
+ activeXDocument.write(scriptTag(''));
2382
+ activeXDocument.close();
2383
+ var temp = activeXDocument.parentWindow.Object;
2384
+ // eslint-disable-next-line no-useless-assignment -- avoid memory leak
2385
+ activeXDocument = null;
2386
+ return temp;
2387
+ };
2388
+
2389
+ // Create object with fake `null` prototype: use iframe Object with cleared prototype
2390
+ var NullProtoObjectViaIFrame = function () {
2391
+ // Thrash, waste and sodomy: IE GC bug
2392
+ var iframe = documentCreateElement('iframe');
2393
+ var JS = 'java' + SCRIPT + ':';
2394
+ var iframeDocument;
2395
+ iframe.style.display = 'none';
2396
+ html.appendChild(iframe);
2397
+ // https://github.com/zloirock/core-js/issues/475
2398
+ iframe.src = String(JS);
2399
+ iframeDocument = iframe.contentWindow.document;
2400
+ iframeDocument.open();
2401
+ iframeDocument.write(scriptTag('document.F=Object'));
2402
+ iframeDocument.close();
2403
+ return iframeDocument.F;
2404
+ };
2405
+
2406
+ // Check for document.domain and active x support
2407
+ // No need to use active x approach when document.domain is not set
2408
+ // see https://github.com/es-shims/es5-shim/issues/150
2409
+ // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
2410
+ // avoid IE GC bug
2411
+ var activeXDocument;
2412
+ var NullProtoObject = function () {
2413
+ try {
2414
+ activeXDocument = new ActiveXObject('htmlfile');
2415
+ } catch (error) { /* ignore */ }
2416
+ NullProtoObject = typeof document != 'undefined'
2417
+ ? document.domain && activeXDocument
2418
+ ? NullProtoObjectViaActiveX(activeXDocument) // old IE
2419
+ : NullProtoObjectViaIFrame()
2420
+ : NullProtoObjectViaActiveX(activeXDocument); // WSH
2421
+ var length = enumBugKeys.length;
2422
+ while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
2423
+ return NullProtoObject();
2424
+ };
2425
+
2426
+ hiddenKeys[IE_PROTO] = true;
2427
+
2428
+ // `Object.create` method
2429
+ // https://tc39.es/ecma262/#sec-object.create
2430
+ // eslint-disable-next-line es/no-object-create -- safe
2431
+ var objectCreate = Object.create || function create(O, Properties) {
2432
+ var result;
2433
+ if (O !== null) {
2434
+ EmptyConstructor[PROTOTYPE] = anObject(O);
2435
+ result = new EmptyConstructor();
2436
+ EmptyConstructor[PROTOTYPE] = null;
2437
+ // add "__proto__" for Object.getPrototypeOf polyfill
2438
+ result[IE_PROTO] = O;
2439
+ } else result = NullProtoObject();
2440
+ return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
2441
+ };
2442
+
2443
+ var wellKnownSymbol = wellKnownSymbol$b;
2444
+ var create = objectCreate;
2445
+ var defineProperty = objectDefineProperty.f;
2446
+
2447
+ var UNSCOPABLES = wellKnownSymbol('unscopables');
2448
+ var ArrayPrototype = Array.prototype;
2449
+
2450
+ // Array.prototype[@@unscopables]
2451
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2452
+ if (ArrayPrototype[UNSCOPABLES] === undefined) {
2453
+ defineProperty(ArrayPrototype, UNSCOPABLES, {
2454
+ configurable: true,
2455
+ value: create(null)
2456
+ });
2457
+ }
2458
+
2459
+ // add a key to Array.prototype[@@unscopables]
2460
+ var addToUnscopables$2 = function (key) {
2461
+ ArrayPrototype[UNSCOPABLES][key] = true;
2462
+ };
2463
+
2464
+ var $$1 = _export;
2465
+ var $includes = arrayIncludes.includes;
2466
+ var fails = fails$b;
2467
+ var addToUnscopables$1 = addToUnscopables$2;
2468
+
2469
+ // FF99+ bug
2470
+ var BROKEN_ON_SPARSE = fails(function () {
2471
+ // eslint-disable-next-line es/no-array-prototype-includes -- detection
2472
+ return !Array(1).includes();
2473
+ });
2474
+
2475
+ // `Array.prototype.includes` method
2476
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
2477
+ $$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
2478
+ includes: function includes(el /* , fromIndex = 0 */) {
2479
+ return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
2480
+ }
2481
+ });
2482
+
2483
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2484
+ addToUnscopables$1('includes');
2485
+
2486
+ var toObject = toObject$3;
2487
+ var toAbsoluteIndex = toAbsoluteIndex$2;
2488
+ var lengthOfArrayLike = lengthOfArrayLike$4;
2489
+
2490
+ // `Array.prototype.fill` method implementation
2491
+ // https://tc39.es/ecma262/#sec-array.prototype.fill
2492
+ var arrayFill = function fill(value /* , start = 0, end = @length */) {
2493
+ var O = toObject(this);
2494
+ var length = lengthOfArrayLike(O);
2495
+ var argumentsLength = arguments.length;
2496
+ var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
2497
+ var end = argumentsLength > 2 ? arguments[2] : undefined;
2498
+ var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
2499
+ while (endPos > index) O[index++] = value;
2500
+ return O;
2501
+ };
2502
+
2503
+ var $ = _export;
2504
+ var fill = arrayFill;
2505
+ var addToUnscopables = addToUnscopables$2;
2506
+
2507
+ // `Array.prototype.fill` method
2508
+ // https://tc39.es/ecma262/#sec-array.prototype.fill
2509
+ $({ target: 'Array', proto: true }, {
2510
+ fill: fill
2511
+ });
2512
+
2513
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2514
+ addToUnscopables('fill');
2515
+
2516
+ /* eslint-disable no-prototype-builtins */
2517
+ var g =
2518
+ (typeof globalThis !== 'undefined' && globalThis) ||
2519
+ (typeof self !== 'undefined' && self) ||
2520
+ // eslint-disable-next-line no-undef
2521
+ (typeof global !== 'undefined' && global) ||
2522
+ {};
2523
+
2524
+ var support = {
2525
+ searchParams: 'URLSearchParams' in g,
2526
+ iterable: 'Symbol' in g && 'iterator' in Symbol,
2527
+ blob:
2528
+ 'FileReader' in g &&
2529
+ 'Blob' in g &&
2530
+ (function() {
2531
+ try {
2532
+ new Blob();
2533
+ return true
2534
+ } catch (e) {
2535
+ return false
2536
+ }
2537
+ })(),
2538
+ formData: 'FormData' in g,
2539
+ arrayBuffer: 'ArrayBuffer' in g
2540
+ };
2541
+
2542
+ function isDataView(obj) {
2543
+ return obj && DataView.prototype.isPrototypeOf(obj)
2544
+ }
2545
+
2546
+ if (support.arrayBuffer) {
2547
+ var viewClasses = [
2548
+ '[object Int8Array]',
2549
+ '[object Uint8Array]',
2550
+ '[object Uint8ClampedArray]',
2551
+ '[object Int16Array]',
2552
+ '[object Uint16Array]',
2553
+ '[object Int32Array]',
2554
+ '[object Uint32Array]',
2555
+ '[object Float32Array]',
2556
+ '[object Float64Array]'
2557
+ ];
2558
+
2559
+ var isArrayBufferView =
2560
+ ArrayBuffer.isView ||
2561
+ function(obj) {
2562
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
2563
+ };
2564
+ }
2565
+
2566
+ function normalizeName(name) {
2567
+ if (typeof name !== 'string') {
2568
+ name = String(name);
2569
+ }
2570
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
2571
+ throw new TypeError('Invalid character in header field name: "' + name + '"')
2572
+ }
2573
+ return name.toLowerCase()
2574
+ }
2575
+
2576
+ function normalizeValue(value) {
2577
+ if (typeof value !== 'string') {
2578
+ value = String(value);
2579
+ }
2580
+ return value
2581
+ }
2582
+
2583
+ // Build a destructive iterator for the value list
2584
+ function iteratorFor(items) {
2585
+ var iterator = {
2586
+ next: function() {
2587
+ var value = items.shift();
2588
+ return {done: value === undefined, value: value}
2589
+ }
2590
+ };
2591
+
2592
+ if (support.iterable) {
2593
+ iterator[Symbol.iterator] = function() {
2594
+ return iterator
2595
+ };
2596
+ }
2597
+
2598
+ return iterator
2599
+ }
2600
+
2601
+ function Headers(headers) {
2602
+ this.map = {};
2603
+
2604
+ if (headers instanceof Headers) {
2605
+ headers.forEach(function(value, name) {
2606
+ this.append(name, value);
2607
+ }, this);
2608
+ } else if (Array.isArray(headers)) {
2609
+ headers.forEach(function(header) {
2610
+ if (header.length != 2) {
2611
+ throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
2612
+ }
2613
+ this.append(header[0], header[1]);
2614
+ }, this);
2615
+ } else if (headers) {
2616
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
2617
+ this.append(name, headers[name]);
2618
+ }, this);
2619
+ }
2620
+ }
2621
+
2622
+ Headers.prototype.append = function(name, value) {
2623
+ name = normalizeName(name);
2624
+ value = normalizeValue(value);
2625
+ var oldValue = this.map[name];
2626
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
2627
+ };
2628
+
2629
+ Headers.prototype['delete'] = function(name) {
2630
+ delete this.map[normalizeName(name)];
2631
+ };
2632
+
2633
+ Headers.prototype.get = function(name) {
2634
+ name = normalizeName(name);
2635
+ return this.has(name) ? this.map[name] : null
2636
+ };
2637
+
2638
+ Headers.prototype.has = function(name) {
2639
+ return this.map.hasOwnProperty(normalizeName(name))
2640
+ };
2641
+
2642
+ Headers.prototype.set = function(name, value) {
2643
+ this.map[normalizeName(name)] = normalizeValue(value);
2644
+ };
2645
+
2646
+ Headers.prototype.forEach = function(callback, thisArg) {
2647
+ for (var name in this.map) {
2648
+ if (this.map.hasOwnProperty(name)) {
2649
+ callback.call(thisArg, this.map[name], name, this);
2650
+ }
2651
+ }
2652
+ };
2653
+
2654
+ Headers.prototype.keys = function() {
2655
+ var items = [];
2656
+ this.forEach(function(value, name) {
2657
+ items.push(name);
2658
+ });
2659
+ return iteratorFor(items)
2660
+ };
2661
+
2662
+ Headers.prototype.values = function() {
2663
+ var items = [];
2664
+ this.forEach(function(value) {
2665
+ items.push(value);
2666
+ });
2667
+ return iteratorFor(items)
2668
+ };
2669
+
2670
+ Headers.prototype.entries = function() {
2671
+ var items = [];
2672
+ this.forEach(function(value, name) {
2673
+ items.push([name, value]);
2674
+ });
2675
+ return iteratorFor(items)
2676
+ };
2677
+
2678
+ if (support.iterable) {
2679
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
2680
+ }
2681
+
2682
+ function consumed(body) {
2683
+ if (body._noBody) return
2684
+ if (body.bodyUsed) {
2685
+ return Promise.reject(new TypeError('Already read'))
2686
+ }
2687
+ body.bodyUsed = true;
2688
+ }
2689
+
2690
+ function fileReaderReady(reader) {
2691
+ return new Promise(function(resolve, reject) {
2692
+ reader.onload = function() {
2693
+ resolve(reader.result);
2694
+ };
2695
+ reader.onerror = function() {
2696
+ reject(reader.error);
2697
+ };
2698
+ })
2699
+ }
2700
+
2701
+ function readBlobAsArrayBuffer(blob) {
2702
+ var reader = new FileReader();
2703
+ var promise = fileReaderReady(reader);
2704
+ reader.readAsArrayBuffer(blob);
2705
+ return promise
2706
+ }
2707
+
2708
+ function readBlobAsText(blob) {
2709
+ var reader = new FileReader();
2710
+ var promise = fileReaderReady(reader);
2711
+ var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
2712
+ var encoding = match ? match[1] : 'utf-8';
2713
+ reader.readAsText(blob, encoding);
2714
+ return promise
2715
+ }
2716
+
2717
+ function readArrayBufferAsText(buf) {
2718
+ var view = new Uint8Array(buf);
2719
+ var chars = new Array(view.length);
2720
+
2721
+ for (var i = 0; i < view.length; i++) {
2722
+ chars[i] = String.fromCharCode(view[i]);
2723
+ }
2724
+ return chars.join('')
2725
+ }
2726
+
2727
+ function bufferClone(buf) {
2728
+ if (buf.slice) {
2729
+ return buf.slice(0)
2730
+ } else {
2731
+ var view = new Uint8Array(buf.byteLength);
2732
+ view.set(new Uint8Array(buf));
2733
+ return view.buffer
2734
+ }
2735
+ }
2736
+
2737
+ function Body() {
2738
+ this.bodyUsed = false;
2739
+
2740
+ this._initBody = function(body) {
2741
+ /*
2742
+ fetch-mock wraps the Response object in an ES6 Proxy to
2743
+ provide useful test harness features such as flush. However, on
2744
+ ES5 browsers without fetch or Proxy support pollyfills must be used;
2745
+ the proxy-pollyfill is unable to proxy an attribute unless it exists
2746
+ on the object before the Proxy is created. This change ensures
2747
+ Response.bodyUsed exists on the instance, while maintaining the
2748
+ semantic of setting Request.bodyUsed in the constructor before
2749
+ _initBody is called.
2750
+ */
2751
+ // eslint-disable-next-line no-self-assign
2752
+ this.bodyUsed = this.bodyUsed;
2753
+ this._bodyInit = body;
2754
+ if (!body) {
2755
+ this._noBody = true;
2756
+ this._bodyText = '';
2757
+ } else if (typeof body === 'string') {
2758
+ this._bodyText = body;
2759
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
2760
+ this._bodyBlob = body;
2761
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
2762
+ this._bodyFormData = body;
2763
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
2764
+ this._bodyText = body.toString();
2765
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
2766
+ this._bodyArrayBuffer = bufferClone(body.buffer);
2767
+ // IE 10-11 can't handle a DataView body.
2768
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
2769
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
2770
+ this._bodyArrayBuffer = bufferClone(body);
2771
+ } else {
2772
+ this._bodyText = body = Object.prototype.toString.call(body);
2773
+ }
2774
+
2775
+ if (!this.headers.get('content-type')) {
2776
+ if (typeof body === 'string') {
2777
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
2778
+ } else if (this._bodyBlob && this._bodyBlob.type) {
2779
+ this.headers.set('content-type', this._bodyBlob.type);
2780
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
2781
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
2782
+ }
2783
+ }
2784
+ };
2785
+
2786
+ if (support.blob) {
2787
+ this.blob = function() {
2788
+ var rejected = consumed(this);
2789
+ if (rejected) {
2790
+ return rejected
2791
+ }
2792
+
2793
+ if (this._bodyBlob) {
2794
+ return Promise.resolve(this._bodyBlob)
2795
+ } else if (this._bodyArrayBuffer) {
2796
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]))
2797
+ } else if (this._bodyFormData) {
2798
+ throw new Error('could not read FormData body as blob')
2799
+ } else {
2800
+ return Promise.resolve(new Blob([this._bodyText]))
2801
+ }
2802
+ };
2803
+ }
2804
+
2805
+ this.arrayBuffer = function() {
2806
+ if (this._bodyArrayBuffer) {
2807
+ var isConsumed = consumed(this);
2808
+ if (isConsumed) {
2809
+ return isConsumed
2810
+ } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
2811
+ return Promise.resolve(
2812
+ this._bodyArrayBuffer.buffer.slice(
2813
+ this._bodyArrayBuffer.byteOffset,
2814
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
2815
+ )
2816
+ )
2817
+ } else {
2818
+ return Promise.resolve(this._bodyArrayBuffer)
2819
+ }
2820
+ } else if (support.blob) {
2821
+ return this.blob().then(readBlobAsArrayBuffer)
2822
+ } else {
2823
+ throw new Error('could not read as ArrayBuffer')
2824
+ }
2825
+ };
2826
+
2827
+ this.text = function() {
2828
+ var rejected = consumed(this);
2829
+ if (rejected) {
2830
+ return rejected
2831
+ }
2832
+
2833
+ if (this._bodyBlob) {
2834
+ return readBlobAsText(this._bodyBlob)
2835
+ } else if (this._bodyArrayBuffer) {
2836
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
2837
+ } else if (this._bodyFormData) {
2838
+ throw new Error('could not read FormData body as text')
2839
+ } else {
2840
+ return Promise.resolve(this._bodyText)
2841
+ }
2842
+ };
2843
+
2844
+ if (support.formData) {
2845
+ this.formData = function() {
2846
+ return this.text().then(decode)
2847
+ };
2848
+ }
2849
+
2850
+ this.json = function() {
2851
+ return this.text().then(JSON.parse)
2852
+ };
2853
+
2854
+ return this
2855
+ }
2856
+
2857
+ // HTTP methods whose capitalization should be normalized
2858
+ var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
2859
+
2860
+ function normalizeMethod(method) {
2861
+ var upcased = method.toUpperCase();
2862
+ return methods.indexOf(upcased) > -1 ? upcased : method
2863
+ }
2864
+
2865
+ function Request(input, options) {
2866
+ if (!(this instanceof Request)) {
2867
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
2868
+ }
2869
+
2870
+ options = options || {};
2871
+ var body = options.body;
2872
+
2873
+ if (input instanceof Request) {
2874
+ if (input.bodyUsed) {
2875
+ throw new TypeError('Already read')
2876
+ }
2877
+ this.url = input.url;
2878
+ this.credentials = input.credentials;
2879
+ if (!options.headers) {
2880
+ this.headers = new Headers(input.headers);
2881
+ }
2882
+ this.method = input.method;
2883
+ this.mode = input.mode;
2884
+ this.signal = input.signal;
2885
+ if (!body && input._bodyInit != null) {
2886
+ body = input._bodyInit;
2887
+ input.bodyUsed = true;
2888
+ }
2889
+ } else {
2890
+ this.url = String(input);
2891
+ }
2892
+
2893
+ this.credentials = options.credentials || this.credentials || 'same-origin';
2894
+ if (options.headers || !this.headers) {
2895
+ this.headers = new Headers(options.headers);
2896
+ }
2897
+ this.method = normalizeMethod(options.method || this.method || 'GET');
2898
+ this.mode = options.mode || this.mode || null;
2899
+ this.signal = options.signal || this.signal || (function () {
2900
+ if ('AbortController' in g) {
2901
+ var ctrl = new AbortController();
2902
+ return ctrl.signal;
2903
+ }
2904
+ }());
2905
+ this.referrer = null;
2906
+
2907
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
2908
+ throw new TypeError('Body not allowed for GET or HEAD requests')
2909
+ }
2910
+ this._initBody(body);
2911
+
2912
+ if (this.method === 'GET' || this.method === 'HEAD') {
2913
+ if (options.cache === 'no-store' || options.cache === 'no-cache') {
2914
+ // Search for a '_' parameter in the query string
2915
+ var reParamSearch = /([?&])_=[^&]*/;
2916
+ if (reParamSearch.test(this.url)) {
2917
+ // If it already exists then set the value with the current time
2918
+ this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
2919
+ } else {
2920
+ // Otherwise add a new '_' parameter to the end with the current time
2921
+ var reQueryString = /\?/;
2922
+ this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
2923
+ }
2924
+ }
2925
+ }
2926
+ }
2927
+
2928
+ Request.prototype.clone = function() {
2929
+ return new Request(this, {body: this._bodyInit})
2930
+ };
2931
+
2932
+ function decode(body) {
2933
+ var form = new FormData();
2934
+ body
2935
+ .trim()
2936
+ .split('&')
2937
+ .forEach(function(bytes) {
2938
+ if (bytes) {
2939
+ var split = bytes.split('=');
2940
+ var name = split.shift().replace(/\+/g, ' ');
2941
+ var value = split.join('=').replace(/\+/g, ' ');
2942
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
2943
+ }
2944
+ });
2945
+ return form
2946
+ }
2947
+
2948
+ function parseHeaders(rawHeaders) {
2949
+ var headers = new Headers();
2950
+ // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
2951
+ // https://tools.ietf.org/html/rfc7230#section-3.2
2952
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
2953
+ // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
2954
+ // https://github.com/github/fetch/issues/748
2955
+ // https://github.com/zloirock/core-js/issues/751
2956
+ preProcessedHeaders
2957
+ .split('\r')
2958
+ .map(function(header) {
2959
+ return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
2960
+ })
2961
+ .forEach(function(line) {
2962
+ var parts = line.split(':');
2963
+ var key = parts.shift().trim();
2964
+ if (key) {
2965
+ var value = parts.join(':').trim();
2966
+ try {
2967
+ headers.append(key, value);
2968
+ } catch (error) {
2969
+ }
2970
+ }
2971
+ });
2972
+ return headers
2973
+ }
2974
+
2975
+ Body.call(Request.prototype);
2976
+
2977
+ function Response(bodyInit, options) {
2978
+ if (!(this instanceof Response)) {
2979
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
2980
+ }
2981
+ if (!options) {
2982
+ options = {};
2983
+ }
2984
+
2985
+ this.type = 'default';
2986
+ this.status = options.status === undefined ? 200 : options.status;
2987
+ if (this.status < 200 || this.status > 599) {
2988
+ throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
2989
+ }
2990
+ this.ok = this.status >= 200 && this.status < 300;
2991
+ this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
2992
+ this.headers = new Headers(options.headers);
2993
+ this.url = options.url || '';
2994
+ this._initBody(bodyInit);
2995
+ }
2996
+
2997
+ Body.call(Response.prototype);
2998
+
2999
+ Response.prototype.clone = function() {
3000
+ return new Response(this._bodyInit, {
3001
+ status: this.status,
3002
+ statusText: this.statusText,
3003
+ headers: new Headers(this.headers),
3004
+ url: this.url
3005
+ })
3006
+ };
3007
+
3008
+ Response.error = function() {
3009
+ var response = new Response(null, {status: 200, statusText: ''});
3010
+ response.ok = false;
3011
+ response.status = 0;
3012
+ response.type = 'error';
3013
+ return response
3014
+ };
3015
+
3016
+ var redirectStatuses = [301, 302, 303, 307, 308];
3017
+
3018
+ Response.redirect = function(url, status) {
3019
+ if (redirectStatuses.indexOf(status) === -1) {
3020
+ throw new RangeError('Invalid status code')
3021
+ }
3022
+
3023
+ return new Response(null, {status: status, headers: {location: url}})
3024
+ };
3025
+
3026
+ var DOMException = g.DOMException;
3027
+ try {
3028
+ new DOMException();
3029
+ } catch (err) {
3030
+ DOMException = function(message, name) {
3031
+ this.message = message;
3032
+ this.name = name;
3033
+ var error = Error(message);
3034
+ this.stack = error.stack;
3035
+ };
3036
+ DOMException.prototype = Object.create(Error.prototype);
3037
+ DOMException.prototype.constructor = DOMException;
3038
+ }
3039
+
3040
+ function fetch$1(input, init) {
3041
+ return new Promise(function(resolve, reject) {
3042
+ var request = new Request(input, init);
3043
+
3044
+ if (request.signal && request.signal.aborted) {
3045
+ return reject(new DOMException('Aborted', 'AbortError'))
3046
+ }
3047
+
3048
+ var xhr = new XMLHttpRequest();
3049
+
3050
+ function abortXhr() {
3051
+ xhr.abort();
3052
+ }
3053
+
3054
+ xhr.onload = function() {
3055
+ var options = {
3056
+ statusText: xhr.statusText,
3057
+ headers: parseHeaders(xhr.getAllResponseHeaders() || '')
3058
+ };
3059
+ // This check if specifically for when a user fetches a file locally from the file system
3060
+ // Only if the status is out of a normal range
3061
+ if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
3062
+ options.status = 200;
3063
+ } else {
3064
+ options.status = xhr.status;
3065
+ }
3066
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
3067
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
3068
+ setTimeout(function() {
3069
+ resolve(new Response(body, options));
3070
+ }, 0);
3071
+ };
3072
+
3073
+ xhr.onerror = function() {
3074
+ setTimeout(function() {
3075
+ reject(new TypeError('Network request failed'));
3076
+ }, 0);
3077
+ };
3078
+
3079
+ xhr.ontimeout = function() {
3080
+ setTimeout(function() {
3081
+ reject(new TypeError('Network request timed out'));
3082
+ }, 0);
3083
+ };
3084
+
3085
+ xhr.onabort = function() {
3086
+ setTimeout(function() {
3087
+ reject(new DOMException('Aborted', 'AbortError'));
3088
+ }, 0);
3089
+ };
3090
+
3091
+ function fixUrl(url) {
3092
+ try {
3093
+ return url === '' && g.location.href ? g.location.href : url
3094
+ } catch (e) {
3095
+ return url
3096
+ }
3097
+ }
3098
+
3099
+ xhr.open(request.method, fixUrl(request.url), true);
3100
+
3101
+ if (request.credentials === 'include') {
3102
+ xhr.withCredentials = true;
3103
+ } else if (request.credentials === 'omit') {
3104
+ xhr.withCredentials = false;
3105
+ }
3106
+
3107
+ if ('responseType' in xhr) {
3108
+ if (support.blob) {
3109
+ xhr.responseType = 'blob';
3110
+ } else if (
3111
+ support.arrayBuffer
3112
+ ) {
3113
+ xhr.responseType = 'arraybuffer';
3114
+ }
3115
+ }
3116
+
3117
+ if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
3118
+ var names = [];
3119
+ Object.getOwnPropertyNames(init.headers).forEach(function(name) {
3120
+ names.push(normalizeName(name));
3121
+ xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
3122
+ });
3123
+ request.headers.forEach(function(value, name) {
3124
+ if (names.indexOf(name) === -1) {
3125
+ xhr.setRequestHeader(name, value);
3126
+ }
3127
+ });
3128
+ } else {
3129
+ request.headers.forEach(function(value, name) {
3130
+ xhr.setRequestHeader(name, value);
3131
+ });
3132
+ }
3133
+
3134
+ if (request.signal) {
3135
+ request.signal.addEventListener('abort', abortXhr);
3136
+
3137
+ xhr.onreadystatechange = function() {
3138
+ // DONE (success or failure)
3139
+ if (xhr.readyState === 4) {
3140
+ request.signal.removeEventListener('abort', abortXhr);
3141
+ }
3142
+ };
3143
+ }
3144
+
3145
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
3146
+ })
3147
+ }
3148
+
3149
+ fetch$1.polyfill = true;
3150
+
3151
+ if (!g.fetch) {
3152
+ g.fetch = fetch$1;
3153
+ g.Headers = Headers;
3154
+ g.Request = Request;
3155
+ g.Response = Response;
3156
+ }
3157
+
3158
+ function styleInject(css, ref) {
3159
+ if ( ref === void 0 ) ref = {};
3160
+ var insertAt = ref.insertAt;
3161
+
3162
+ if (typeof document === 'undefined') { return; }
3163
+
3164
+ var head = document.head || document.getElementsByTagName('head')[0];
3165
+ var style = document.createElement('style');
3166
+ style.type = 'text/css';
3167
+
3168
+ if (insertAt === 'top') {
3169
+ if (head.firstChild) {
3170
+ head.insertBefore(style, head.firstChild);
3171
+ } else {
3172
+ head.appendChild(style);
3173
+ }
3174
+ } else {
3175
+ head.appendChild(style);
3176
+ }
3177
+
3178
+ if (style.styleSheet) {
3179
+ style.styleSheet.cssText = css;
3180
+ } else {
3181
+ style.appendChild(document.createTextNode(css));
3182
+ }
3183
+ }
3184
+
3185
+ var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:0 0}75%{background-position:100% -100%}to{background-position:0 0}}";
3186
+ styleInject(css_248z);
3187
+
3188
+ /******************************************************************************
3189
+ Copyright (c) Microsoft Corporation.
3190
+
3191
+ Permission to use, copy, modify, and/or distribute this software for any
3192
+ purpose with or without fee is hereby granted.
3193
+
3194
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3195
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3196
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3197
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3198
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3199
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3200
+ PERFORMANCE OF THIS SOFTWARE.
3201
+ ***************************************************************************** */
3202
+ /* global Reflect, Promise */
3203
+
3204
+ var extendStatics = function(d, b) {
3205
+ extendStatics = Object.setPrototypeOf ||
3206
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3207
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
3208
+ return extendStatics(d, b);
3209
+ };
3210
+
3211
+ function __extends(d, b) {
3212
+ if (typeof b !== "function" && b !== null)
3213
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
3214
+ extendStatics(d, b);
3215
+ function __() { this.constructor = d; }
3216
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3217
+ }
3218
+
3219
+ var __assign = function() {
3220
+ __assign = Object.assign || function __assign(t) {
3221
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3222
+ s = arguments[i];
3223
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3224
+ }
3225
+ return t;
3226
+ };
3227
+ return __assign.apply(this, arguments);
3228
+ };
3229
+
3230
+ function __awaiter(thisArg, _arguments, P, generator) {
3231
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3232
+ return new (P || (P = Promise))(function (resolve, reject) {
3233
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3234
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3235
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3236
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3237
+ });
3238
+ }
3239
+
3240
+ function __generator(thisArg, body) {
3241
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3242
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
3243
+ function verb(n) { return function (v) { return step([n, v]); }; }
3244
+ function step(op) {
3245
+ if (f) throw new TypeError("Generator is already executing.");
3246
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
3247
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3248
+ if (y = 0, t) op = [op[0] & 2, t.value];
3249
+ switch (op[0]) {
3250
+ case 0: case 1: t = op; break;
3251
+ case 4: _.label++; return { value: op[1], done: false };
3252
+ case 5: _.label++; y = op[1]; op = [0]; continue;
3253
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
3254
+ default:
3255
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
3256
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
3257
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
3258
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
3259
+ if (t[2]) _.ops.pop();
3260
+ _.trys.pop(); continue;
3261
+ }
3262
+ op = body.call(thisArg, _);
3263
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
3264
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
3265
+ }
3266
+ }
3267
+
3268
+ var convertImage = function (canvas) {
3269
+ return canvas.toDataURL('image/png', 1);
3270
+ };
3271
+ var isFunction = function (value) {
3272
+ return typeof value === 'function';
3273
+ };
3274
+ var isUndefined = function (value) {
3275
+ return value === undefined;
3276
+ };
3277
+ var isString = function (value) {
3278
+ return typeof value === 'string';
3279
+ };
3280
+ var createSVGElement = function (tagName, attrs, namespaceURI) {
3281
+ if (attrs === void 0) { attrs = {}; }
3282
+ if (namespaceURI === void 0) { namespaceURI = 'http://www.w3.org/2000/svg'; }
3283
+ var element = document.createElementNS(namespaceURI, tagName);
3284
+ for (var attr in attrs) {
3285
+ element.setAttribute(attr, attrs[attr]);
3286
+ }
3287
+ return element;
3288
+ };
3289
+ var getMultiLineData = function (ctx, text, maxWidth) {
3290
+ var result = [];
3291
+ var str = '';
3292
+ for (var i = 0, len = text.length; i < len; i++) {
3293
+ str += text.charAt(i);
3294
+ if (ctx.measureText(str).width > maxWidth) {
3295
+ result.push(str.substring(0, str.length - 1));
3296
+ str = '';
3297
+ i--;
3298
+ }
3299
+ }
3300
+ result.push(str);
3301
+ return result;
3302
+ };
3303
+ var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0, void 0, void 0, function () {
3304
+ var svgElement, bodyElement, rect, rectWidth, rectHeight, width, height, foreignObjectElement;
3305
+ var _a;
3306
+ return __generator(this, function (_b) {
3307
+ switch (_b.label) {
3308
+ case 0:
3309
+ svgElement = createSVGElement('svg', {
3310
+ xmlns: 'http://www.w3.org/2000/svg'
3311
+ });
3312
+ bodyElement = document.createElement('div');
3313
+ bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
3314
+ bodyElement.style.cssText = "\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font: ".concat(ctx.font, ";\n color: ").concat(options.fontColor, ";\n");
3315
+ bodyElement.innerHTML = "<div class='rich-text-content'>".concat(options.content, "</div>");
3316
+ document.body.appendChild(bodyElement);
3317
+ // convert all images to base64
3318
+ return [4 /*yield*/, convertImgToBase64(bodyElement)];
3319
+ case 1:
3320
+ // convert all images to base64
3321
+ _b.sent();
3322
+ rect = (_a = bodyElement.querySelector('.rich-text-content')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
3323
+ rectWidth = rect === null || rect === void 0 ? void 0 : rect.width;
3324
+ rectHeight = rect === null || rect === void 0 ? void 0 : rect.height;
3325
+ document.body.removeChild(bodyElement);
3326
+ width = options.richTextWidth || rectWidth || options.width;
3327
+ height = options.richTextHeight || rectHeight || options.height;
3328
+ svgElement.setAttribute('width', width.toString());
3329
+ svgElement.setAttribute('height', height.toString());
3330
+ foreignObjectElement = createSVGElement('foreignObject', {
3331
+ width: width.toString(),
3332
+ height: height.toString()
3333
+ });
3334
+ foreignObjectElement.appendChild(bodyElement);
3335
+ svgElement.appendChild(foreignObjectElement);
3336
+ return [2 /*return*/, {
3337
+ element: svgElement,
3338
+ width: width,
3339
+ height: height
3340
+ }];
3341
+ }
3342
+ });
3343
+ }); };
3344
+ function convertImgToBase64(bodyElement) {
3345
+ return __awaiter(this, void 0, void 0, function () {
3346
+ var imgElements, _loop_1, _i, _a, img;
3347
+ return __generator(this, function (_b) {
3348
+ switch (_b.label) {
3349
+ case 0:
3350
+ imgElements = bodyElement.querySelectorAll('img');
3351
+ _loop_1 = function (img) {
3352
+ var src, response, blob_1, imgData, error_1;
3353
+ return __generator(this, function (_c) {
3354
+ switch (_c.label) {
3355
+ case 0:
3356
+ src = img.getAttribute('src');
3357
+ if (!src) return [3 /*break*/, 6];
3358
+ _c.label = 1;
3359
+ case 1:
3360
+ _c.trys.push([1, 5, , 6]);
3361
+ return [4 /*yield*/, fetch(src)];
3362
+ case 2:
3363
+ response = _c.sent();
3364
+ return [4 /*yield*/, response.blob()];
3365
+ case 3:
3366
+ blob_1 = _c.sent();
3367
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
3368
+ var reader = new FileReader();
3369
+ reader.onloadend = function () { return resolve(reader.result); };
3370
+ reader.onerror = reject;
3371
+ reader.readAsDataURL(blob_1);
3372
+ })];
3373
+ case 4:
3374
+ imgData = _c.sent();
3375
+ if (isString(imgData)) {
3376
+ img.setAttribute('src', imgData);
3377
+ }
3378
+ return [3 /*break*/, 6];
3379
+ case 5:
3380
+ error_1 = _c.sent();
3381
+ console.error("Error converting ".concat(src, " to base64:"), error_1);
3382
+ return [3 /*break*/, 6];
3383
+ case 6: return [2 /*return*/];
3384
+ }
3385
+ });
3386
+ };
3387
+ _i = 0, _a = Array.from(imgElements);
3388
+ _b.label = 1;
3389
+ case 1:
3390
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
3391
+ img = _a[_i];
3392
+ return [5 /*yield**/, _loop_1(img)];
3393
+ case 2:
3394
+ _b.sent();
3395
+ _b.label = 3;
3396
+ case 3:
3397
+ _i++;
3398
+ return [3 /*break*/, 1];
3399
+ case 4: return [2 /*return*/];
3400
+ }
3401
+ });
3402
+ });
3403
+ }
3404
+ var convertSVGToImage = function (svg) {
3405
+ var richContent = svg.outerHTML.replace(/<img(.*?)>/g, '<img$1/>').replace(/\n/g, '').replace(/\t/g, '').replace(/#/g, '%23');
3406
+ return "data:image/svg+xml;charset=utf-8,".concat(richContent);
3407
+ };
3408
+ var getValue = function (v1, v2) {
3409
+ if (isUndefined(v1)) {
3410
+ return v2;
3411
+ }
3412
+ else {
3413
+ return v1;
3414
+ }
3415
+ };
3416
+ var loadImage = function (url, width, height) {
3417
+ if (width === void 0) { width = undefined; }
3418
+ if (height === void 0) { height = undefined; }
3419
+ var image = new Image();
3420
+ image.setAttribute('crossOrigin', 'Anonymous');
3421
+ !isUndefined(width) && (image.width = width);
3422
+ !isUndefined(height) && (image.height = height);
3423
+ image.src = url;
3424
+ return new Promise(function (resolve) {
3425
+ image.onload = function () {
3426
+ resolve(image);
3427
+ };
3428
+ });
3429
+ };
3430
+ var generateMatrix = function (rows, columns, value) {
3431
+ return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
3432
+ };
3433
+
3434
+ var initialOptions = {
3435
+ width: 300,
3436
+ height: 300,
3437
+ rotate: 45,
3438
+ layout: 'default',
3439
+ auxiliaryLine: false,
3440
+ translatePlacement: 'middle',
3441
+ contentType: 'text',
3442
+ content: 'hello watermark-js-plus',
3443
+ textType: 'fill',
3444
+ imageWidth: 0,
3445
+ imageHeight: 0,
3446
+ lineHeight: 30,
3447
+ zIndex: 2147483647,
3448
+ backgroundPosition: '0 0',
3449
+ backgroundRepeat: 'repeat',
3450
+ fontSize: '20px',
3451
+ fontFamily: 'sans-serif',
3452
+ fontStyle: '',
3453
+ fontVariant: '',
3454
+ fontColor: '#000',
3455
+ fontWeight: 'normal',
3456
+ filter: 'none',
3457
+ letterSpacing: '0px',
3458
+ wordSpacing: '0px',
3459
+ globalAlpha: 0.5,
3460
+ mode: 'default',
3461
+ mutationObserve: true,
3462
+ movable: false,
3463
+ parent: 'body',
3464
+ onSuccess: function () { },
3465
+ onBeforeDestroy: function () { },
3466
+ onDestroyed: function () { },
3467
+ onObserveError: function () { }
3468
+ };
3469
+ var generateRecommendOptions = function (canvas, options, args) {
3470
+ var ctx = canvas.getContext('2d');
3471
+ if (ctx === null) {
3472
+ throw new Error('get context error');
3473
+ }
3474
+ ctx.font = "".concat(options.fontStyle, " ").concat(options.fontVariant, " ").concat(options.fontWeight, " ").concat(options.fontSize, " ").concat(options.fontFamily);
3475
+ ctx.filter = options.filter;
3476
+ // @ts-ignore
3477
+ ctx.letterSpacing = options.letterSpacing;
3478
+ ctx.wordSpacing = options.wordSpacing;
3479
+ if (options === null || options === void 0 ? void 0 : options.rotate) {
3480
+ options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
3481
+ }
3482
+ if (isUndefined(args.textRowMaxWidth)) {
3483
+ options.textRowMaxWidth = options.width;
3484
+ }
3485
+ var result = {
3486
+ image: {
3487
+ rect: {
3488
+ width: options.imageWidth,
3489
+ height: options.imageHeight
3490
+ },
3491
+ position: {
3492
+ x: 0,
3493
+ y: 0
3494
+ }
3495
+ },
3496
+ textLine: {
3497
+ data: [],
3498
+ yOffsetValue: 0
3499
+ },
3500
+ advancedStyleParams: {
3501
+ linear: {
3502
+ x0: 0,
3503
+ x1: 0
3504
+ },
3505
+ radial: {
3506
+ x0: 0,
3507
+ y0: 0,
3508
+ r0: 0,
3509
+ x1: 0,
3510
+ y1: 0,
3511
+ r1: 0
3512
+ },
3513
+ conic: {
3514
+ x: 0,
3515
+ y: 0,
3516
+ startAngle: 0
3517
+ },
3518
+ pattern: {}
3519
+ }
3520
+ };
3521
+ switch (options.contentType) {
3522
+ case 'text':
3523
+ result.textLine.data = [options.content];
3524
+ break;
3525
+ case 'multi-line-text':
3526
+ result.textLine.data = getMultiLineData(ctx, options.content, options.textRowMaxWidth);
3527
+ break;
3528
+ // case 'image':
3529
+ // break
3530
+ // case 'rich-text':
3531
+ // break
3532
+ }
3533
+ var translateX = options.width / 2;
3534
+ var translateY = options.height / 2;
3535
+ var textBaseline = 'middle';
3536
+ var textAlign = 'center';
3537
+ if (!isUndefined(args === null || args === void 0 ? void 0 : args.translateX) && !isUndefined(args === null || args === void 0 ? void 0 : args.translateY)) {
3538
+ translateX = args === null || args === void 0 ? void 0 : args.translateX;
3539
+ translateY = args === null || args === void 0 ? void 0 : args.translateY;
3540
+ textBaseline = 'top';
3541
+ textAlign = 'left';
3542
+ }
3543
+ else {
3544
+ // default middle
3545
+ // translateX = options.width / 2
3546
+ // translateY = options.height / 2
3547
+ // TextBaselineType = 'middle'
3548
+ // textAlign = 'center'
3549
+ result.advancedStyleParams.linear.x0 = -options.width / 2;
3550
+ result.advancedStyleParams.linear.x1 = options.width / 2;
3551
+ // result.advancedStyleParams.radial.x0 = 0
3552
+ // result.advancedStyleParams.radial.y0 = 0
3553
+ result.advancedStyleParams.radial.r0 = 0;
3554
+ // result.advancedStyleParams.radial.x1 = 0
3555
+ // result.advancedStyleParams.radial.y1 = 0
3556
+ result.advancedStyleParams.radial.r1 = options.width / 2;
3557
+ // result.advancedStyleParams.conic.x = 0
3558
+ // result.advancedStyleParams.conic.y = 0
3559
+ }
3560
+ switch (args.translatePlacement) {
3561
+ case 'top':
3562
+ translateX = options.width / 2;
3563
+ translateY = 0;
3564
+ textBaseline = 'top';
3565
+ // textAlign = 'center'
3566
+ result.advancedStyleParams.linear.x0 = -options.width / 2;
3567
+ result.advancedStyleParams.linear.x1 = options.width / 2;
3568
+ // result.advancedStyleParams.radial.x0 = 0
3569
+ result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
3570
+ // result.advancedStyleParams.radial.r0 = 0
3571
+ // result.advancedStyleParams.radial.x1 = 0
3572
+ // result.advancedStyleParams.radial.y1 = 0
3573
+ result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
3574
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3575
+ // result.advancedStyleParams.conic.x = 0
3576
+ result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
3577
+ break;
3578
+ case 'top-start':
3579
+ translateX = 0;
3580
+ translateY = 0;
3581
+ textBaseline = 'top';
3582
+ textAlign = 'start';
3583
+ result.advancedStyleParams.linear.x0 = 0;
3584
+ result.advancedStyleParams.linear.x1 = options.width;
3585
+ result.advancedStyleParams.radial.x0 = options.width / 2;
3586
+ result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
3587
+ // result.advancedStyleParams.radial.r0 = 0
3588
+ result.advancedStyleParams.radial.x1 = options.width / 2;
3589
+ result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
3590
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3591
+ result.advancedStyleParams.conic.x = options.width / 2;
3592
+ result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
3593
+ break;
3594
+ case 'top-end':
3595
+ translateX = options.width;
3596
+ translateY = 0;
3597
+ textBaseline = 'top';
3598
+ textAlign = 'end';
3599
+ result.advancedStyleParams.linear.x0 = 0;
3600
+ result.advancedStyleParams.linear.x1 = -options.width;
3601
+ result.advancedStyleParams.radial.x0 = -options.width / 2;
3602
+ result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
3603
+ // result.advancedStyleParams.radial.r0 = 0
3604
+ result.advancedStyleParams.radial.x1 = -options.width / 2;
3605
+ result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
3606
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3607
+ result.advancedStyleParams.conic.x = -options.width / 2;
3608
+ result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
3609
+ break;
3610
+ case 'bottom':
3611
+ translateX = options.width / 2;
3612
+ translateY = options.height;
3613
+ textBaseline = 'bottom';
3614
+ // textAlign = 'center'
3615
+ result.advancedStyleParams.linear.x0 = -options.width / 2;
3616
+ result.advancedStyleParams.linear.x1 = options.width / 2;
3617
+ // result.advancedStyleParams.radial.x0 = 0
3618
+ result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
3619
+ // result.advancedStyleParams.radial.r0 = 0
3620
+ // result.advancedStyleParams.radial.x1 = 0
3621
+ result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
3622
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3623
+ result.advancedStyleParams.conic.x = 0;
3624
+ result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
3625
+ break;
3626
+ case 'bottom-start':
3627
+ translateX = 0;
3628
+ translateY = options.height;
3629
+ textBaseline = 'bottom';
3630
+ textAlign = 'start';
3631
+ result.advancedStyleParams.linear.x0 = 0;
3632
+ result.advancedStyleParams.linear.x1 = options.width;
3633
+ result.advancedStyleParams.radial.x0 = options.width / 2;
3634
+ result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
3635
+ // result.advancedStyleParams.radial.r0 = 0
3636
+ result.advancedStyleParams.radial.x1 = options.width / 2;
3637
+ result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
3638
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3639
+ result.advancedStyleParams.conic.x = options.width / 2;
3640
+ result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
3641
+ break;
3642
+ case 'bottom-end':
3643
+ translateX = options.width;
3644
+ translateY = options.height;
3645
+ textBaseline = 'bottom';
3646
+ textAlign = 'end';
3647
+ result.advancedStyleParams.linear.x0 = 0;
3648
+ result.advancedStyleParams.linear.x1 = -options.width;
3649
+ result.advancedStyleParams.radial.x0 = -options.width / 2;
3650
+ result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
3651
+ // result.advancedStyleParams.radial.r0 = 0
3652
+ result.advancedStyleParams.radial.x1 = -options.width / 2;
3653
+ result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
3654
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3655
+ result.advancedStyleParams.conic.x = -options.width / 2;
3656
+ result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
3657
+ break;
3658
+ case 'left':
3659
+ translateX = 0;
3660
+ translateY = options.height / 2;
3661
+ // TextBaselineType = 'middle'
3662
+ textAlign = 'start';
3663
+ result.advancedStyleParams.linear.x0 = 0;
3664
+ result.advancedStyleParams.linear.x1 = options.width;
3665
+ result.advancedStyleParams.radial.x0 = options.width / 2;
3666
+ // result.advancedStyleParams.radial.y0 = 0
3667
+ // result.advancedStyleParams.radial.r0 = 0
3668
+ result.advancedStyleParams.radial.x1 = options.width / 2;
3669
+ // result.advancedStyleParams.radial.y1 = 0
3670
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3671
+ result.advancedStyleParams.conic.x = options.width / 2;
3672
+ result.advancedStyleParams.conic.y = 0;
3673
+ break;
3674
+ case 'right':
3675
+ translateX = options.width;
3676
+ translateY = options.height / 2;
3677
+ // TextBaselineType = 'middle'
3678
+ textAlign = 'end';
3679
+ result.advancedStyleParams.linear.x0 = 0;
3680
+ result.advancedStyleParams.linear.x1 = -options.width;
3681
+ result.advancedStyleParams.radial.x0 = -options.width / 2;
3682
+ // result.advancedStyleParams.radial.y0 = 0
3683
+ // result.advancedStyleParams.radial.r0 = 0
3684
+ result.advancedStyleParams.radial.x1 = -options.width / 2;
3685
+ // result.advancedStyleParams.radial.y1 = 0
3686
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3687
+ result.advancedStyleParams.conic.x = -options.width / 2;
3688
+ result.advancedStyleParams.conic.y = 0;
3689
+ break;
3690
+ }
3691
+ options.translateX = translateX;
3692
+ options.translateY = translateY;
3693
+ isUndefined(args === null || args === void 0 ? void 0 : args.textBaseline) && (options.textBaseline = textBaseline);
3694
+ isUndefined(args === null || args === void 0 ? void 0 : args.textAlign) && (options.textAlign = textAlign);
3695
+ if (['text', 'multi-line-text'].includes(options.contentType)) {
3696
+ switch (options.textBaseline) {
3697
+ case 'middle':
3698
+ result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight / 2;
3699
+ break;
3700
+ case 'bottom':
3701
+ case 'alphabetic':
3702
+ case 'ideographic':
3703
+ result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
3704
+ break;
3705
+ case 'top':
3706
+ case 'hanging':
3707
+ result.textLine.yOffsetValue = -options.lineHeight / 2 + parseInt(options.fontSize) / 2;
3708
+ break;
3709
+ }
3710
+ }
3711
+ return result;
3712
+ };
3713
+
3714
+ var bootstrap = (function () {
3715
+ if (typeof window !== 'undefined') {
3716
+ Object.defineProperty(window, 'MutationObserver', {
3717
+ writable: false,
3718
+ configurable: false
3719
+ });
3720
+ Object.defineProperty(window, 'requestAnimationFrame', {
3721
+ writable: false,
3722
+ configurable: false
3723
+ });
3724
+ }
3725
+ });
3726
+
3727
+ var WatermarkCanvas = /** @class */ (function () {
3728
+ function WatermarkCanvas(args, options) {
3729
+ this.props = args;
3730
+ this.options = options;
3731
+ this.canvas = WatermarkCanvas.createCanvas(this.options.width, this.options.height);
3732
+ this.recommendOptions = generateRecommendOptions(this.canvas, this.options, this.props);
3733
+ }
3734
+ /**
3735
+ * Create an HD canvas.
3736
+ * @param width - width of canvas
3737
+ * @param height - height of canvas
3738
+ */
3739
+ WatermarkCanvas.createCanvas = function (width, height) {
3740
+ var _a;
3741
+ var ratio = window.devicePixelRatio || 1;
3742
+ var canvas = document.createElement('canvas');
3743
+ canvas.width = width * ratio; // actual rendered pixel
3744
+ canvas.height = height * ratio; // actual rendered pixel
3745
+ canvas.style.width = "".concat(width, "px"); // control display size
3746
+ canvas.style.height = "".concat(height, "px"); // control display size
3747
+ (_a = canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.setTransform(ratio, 0, 0, ratio, 0, 0);
3748
+ return canvas;
3749
+ };
3750
+ /**
3751
+ * Clean the canvas
3752
+ * @param canvas
3753
+ */
3754
+ WatermarkCanvas.clearCanvas = function (canvas) {
3755
+ var ctx = canvas.getContext('2d');
3756
+ if (ctx === null) {
3757
+ throw new Error('get context error');
3758
+ }
3759
+ ctx.restore();
3760
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
3761
+ };
3762
+ WatermarkCanvas.prototype.getCanvas = function () {
3763
+ return this.canvas;
3764
+ };
3765
+ WatermarkCanvas.prototype.clear = function () {
3766
+ WatermarkCanvas.clearCanvas(this.canvas);
3767
+ };
3768
+ WatermarkCanvas.prototype.draw = function () {
3769
+ var _this = this;
3770
+ var ctx = this.canvas.getContext('2d');
3771
+ if (ctx === null) {
3772
+ throw new Error('get context error');
3773
+ }
3774
+ if (this.options.auxiliaryLine) {
3775
+ ctx.beginPath();
3776
+ ctx.rect(0, 0, this.options.width, this.options.height);
3777
+ ctx.lineWidth = 1;
3778
+ ctx.strokeStyle = '#000';
3779
+ ctx.stroke();
3780
+ ctx.closePath();
3781
+ ctx.beginPath();
3782
+ ctx.rect(this.options.translateX, this.options.translateY, 1, 1);
3783
+ ctx.lineWidth = 1;
3784
+ ctx.strokeStyle = '#f00';
3785
+ ctx.stroke();
3786
+ ctx.closePath();
3787
+ }
3788
+ this.setStyle(ctx);
3789
+ ctx.save();
3790
+ ctx.translate(this.options.translateX, this.options.translateY);
3791
+ ctx.rotate(this.options.rotate);
3792
+ return new Promise(function (resolve) {
3793
+ switch (_this.options.contentType) {
3794
+ case 'text':
3795
+ _this.drawText(ctx, resolve);
3796
+ break;
3797
+ case 'image':
3798
+ _this.drawImage(ctx, resolve);
3799
+ break;
3800
+ case 'multi-line-text':
3801
+ _this.drawMultiLineText(ctx, resolve);
3802
+ break;
3803
+ case 'rich-text':
3804
+ _this.drawRichText(ctx, resolve);
3805
+ break;
3806
+ }
3807
+ });
3808
+ };
3809
+ WatermarkCanvas.prototype.setStyle = function (ctx) {
3810
+ var _a;
3811
+ var propName = 'fillStyle';
3812
+ if (this.options.textType === 'stroke') {
3813
+ propName = 'strokeStyle';
3814
+ }
3815
+ var style = this.options.fontColor;
3816
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) {
3817
+ switch (this.options.advancedStyle.type) {
3818
+ case 'linear':
3819
+ style = this.createLinearGradient(ctx);
3820
+ break;
3821
+ case 'radial':
3822
+ style = this.createRadialGradient(ctx);
3823
+ break;
3824
+ case 'conic':
3825
+ style = this.createConicGradient(ctx);
3826
+ break;
3827
+ case 'pattern':
3828
+ style = this.createPattern(ctx);
3829
+ break;
3830
+ }
3831
+ }
3832
+ ctx[propName] && style && (ctx[propName] = style);
3833
+ this.options.textAlign && (ctx.textAlign = this.options.textAlign);
3834
+ this.options.textBaseline && (ctx.textBaseline = this.options.textBaseline);
3835
+ ctx.globalAlpha = this.options.globalAlpha;
3836
+ if (this.options.shadowStyle) {
3837
+ ctx.shadowBlur = getValue(this.options.shadowStyle.shadowBlur, 0);
3838
+ ctx.shadowColor = getValue(this.options.shadowStyle.shadowColor, '#00000000');
3839
+ ctx.shadowOffsetX = getValue(this.options.shadowStyle.shadowOffsetX, 0);
3840
+ ctx.shadowOffsetY = getValue(this.options.shadowStyle.shadowOffsetY, 0);
3841
+ }
3842
+ if (isFunction(this.options.extraDrawFunc)) {
3843
+ this.options.extraDrawFunc(ctx);
3844
+ }
3845
+ };
3846
+ WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
3847
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
3848
+ var gradient = ctx.createLinearGradient(getValue((_c = (_b = (_a = this.options.advancedStyle) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.linear) === null || _c === void 0 ? void 0 : _c.x0, this.recommendOptions.advancedStyleParams.linear.x0), getValue((_f = (_e = (_d = this.options.advancedStyle) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.linear) === null || _f === void 0 ? void 0 : _f.y0, 0), getValue((_j = (_h = (_g = this.options.advancedStyle) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.linear) === null || _j === void 0 ? void 0 : _j.x1, this.recommendOptions.advancedStyleParams.linear.x1), getValue((_m = (_l = (_k = this.options.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.linear) === null || _m === void 0 ? void 0 : _m.y1, 0));
3849
+ (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
3850
+ gradient.addColorStop(item.offset, item.color);
3851
+ });
3852
+ return gradient;
3853
+ };
3854
+ WatermarkCanvas.prototype.createConicGradient = function (ctx) {
3855
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
3856
+ var gradient = ctx.createConicGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.conic) === null || _d === void 0 ? void 0 : _d.startAngle, 0), getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.conic) === null || _h === void 0 ? void 0 : _h.x, this.recommendOptions.advancedStyleParams.conic.x), getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.conic) === null || _m === void 0 ? void 0 : _m.y, this.recommendOptions.advancedStyleParams.conic.y));
3857
+ (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
3858
+ gradient.addColorStop(item.offset, item.color);
3859
+ });
3860
+ return gradient;
3861
+ };
3862
+ WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
3863
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
3864
+ var gradient = ctx.createRadialGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.radial) === null || _d === void 0 ? void 0 : _d.x0, this.recommendOptions.advancedStyleParams.radial.x0), getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.radial) === null || _h === void 0 ? void 0 : _h.y0, this.recommendOptions.advancedStyleParams.radial.y0), getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.radial) === null || _m === void 0 ? void 0 : _m.r0, this.recommendOptions.advancedStyleParams.radial.r0), getValue((_r = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.params) === null || _q === void 0 ? void 0 : _q.radial) === null || _r === void 0 ? void 0 : _r.x1, this.recommendOptions.advancedStyleParams.radial.x1), getValue((_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.advancedStyle) === null || _t === void 0 ? void 0 : _t.params) === null || _u === void 0 ? void 0 : _u.radial) === null || _v === void 0 ? void 0 : _v.y1, this.recommendOptions.advancedStyleParams.radial.y1), getValue((_z = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.advancedStyle) === null || _x === void 0 ? void 0 : _x.params) === null || _y === void 0 ? void 0 : _y.radial) === null || _z === void 0 ? void 0 : _z.r1, this.recommendOptions.advancedStyleParams.radial.r1));
3865
+ (_2 = (_1 = (_0 = this.options) === null || _0 === void 0 ? void 0 : _0.advancedStyle) === null || _1 === void 0 ? void 0 : _1.colorStops) === null || _2 === void 0 ? void 0 : _2.forEach(function (item) {
3866
+ gradient.addColorStop(item.offset, item.color);
3867
+ });
3868
+ return gradient;
3869
+ };
3870
+ WatermarkCanvas.prototype.createPattern = function (ctx) {
3871
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3872
+ return ctx.createPattern((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.pattern) === null || _d === void 0 ? void 0 : _d.image, ((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.pattern) === null || _h === void 0 ? void 0 : _h.repetition) || '');
3873
+ };
3874
+ WatermarkCanvas.prototype.setText = function (ctx, params) {
3875
+ var methodName = 'fillText';
3876
+ if (this.options.textType === 'stroke') {
3877
+ methodName = 'strokeText';
3878
+ }
3879
+ ctx[methodName] && ctx[methodName](params.text, params.x, params.y, params.maxWidth);
3880
+ };
3881
+ WatermarkCanvas.prototype.drawText = function (ctx, resolve) {
3882
+ this.setText(ctx, {
3883
+ text: this.options.content,
3884
+ x: 0,
3885
+ y: 0 - this.recommendOptions.textLine.yOffsetValue,
3886
+ maxWidth: this.options.textRowMaxWidth || this.options.width
3887
+ });
3888
+ resolve(ctx.canvas);
3889
+ };
3890
+ WatermarkCanvas.prototype.drawImage = function (ctx, resolve) {
3891
+ var _this = this;
3892
+ loadImage(this.options.image).then(function (image) {
3893
+ var _a = _this.getImageRect(image), imageWidth = _a.width, imageHeight = _a.height;
3894
+ var imagePosition = _this.getDrawImagePosition(imageWidth, imageHeight);
3895
+ ctx.drawImage(image, imagePosition.x, imagePosition.y, imageWidth, imageHeight);
3896
+ resolve(ctx.canvas);
3897
+ });
3898
+ };
3899
+ WatermarkCanvas.prototype.drawMultiLineText = function (ctx, resolve) {
3900
+ var _this = this;
3901
+ // image.width = this.options.width
3902
+ // image.height = this.options.height
3903
+ // const element = createCustomContentSvg(context, this.options)
3904
+ // image.src = convertSVGToImage(element)
3905
+ // image.onload = () => {
3906
+ // context.translate(this.options.width / 2, this.options.height / 2)
3907
+ // context.rotate(this.options.rotate)
3908
+ // context.drawImage(
3909
+ // image,
3910
+ // -this.options.width / 2,
3911
+ // -this.options.height / 2,
3912
+ // context.canvas.width,
3913
+ // context.canvas.height
3914
+ // )
3915
+ // resolve(canvas)
3916
+ // }
3917
+ var lines = this.recommendOptions.textLine.data;
3918
+ var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
3919
+ lines.forEach(function (text, index) {
3920
+ _this.setText(ctx, { text: text, x: 0, y: _this.options.lineHeight * index - yOffsetValue, maxWidth: _this.options.textRowMaxWidth || _this.options.width });
3921
+ });
3922
+ resolve(ctx.canvas);
3923
+ };
3924
+ WatermarkCanvas.prototype.drawRichText = function (ctx, resolve) {
3925
+ return __awaiter(this, void 0, void 0, function () {
3926
+ var obj;
3927
+ var _this = this;
3928
+ return __generator(this, function (_a) {
3929
+ switch (_a.label) {
3930
+ case 0: return [4 /*yield*/, createCustomContentSVG(ctx, this.options)];
3931
+ case 1:
3932
+ obj = _a.sent();
3933
+ loadImage(convertSVGToImage(obj.element), obj.width, obj.height).then(function (image) {
3934
+ var imagePosition = _this.getDrawImagePosition(image.width, image.height);
3935
+ ctx.drawImage(image, imagePosition.x, imagePosition.y, image.width, image.height);
3936
+ resolve(ctx.canvas);
3937
+ });
3938
+ return [2 /*return*/];
3939
+ }
3940
+ });
3941
+ });
3942
+ };
3943
+ WatermarkCanvas.prototype.getImageRect = function (image) {
3944
+ var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
3945
+ switch (true) {
3946
+ case rect.width !== 0 && rect.height === 0:
3947
+ rect.height = rect.width * image.height / image.width;
3948
+ break;
3949
+ case rect.width === 0 && rect.height !== 0:
3950
+ rect.width = rect.height * image.width / image.height;
3951
+ break;
3952
+ case rect.width === 0 && rect.height === 0:
3953
+ rect.width = image.width;
3954
+ rect.height = image.height;
3955
+ break;
3956
+ }
3957
+ return rect;
3958
+ };
3959
+ WatermarkCanvas.prototype.getDrawImagePosition = function (imageWidth, imageHeight) {
3960
+ var _a, _b;
3961
+ var result = {
3962
+ x: -imageWidth / 2,
3963
+ y: -imageHeight / 2
3964
+ };
3965
+ switch (this.options.translatePlacement) {
3966
+ case 'top':
3967
+ result.x = -imageWidth / 2;
3968
+ result.y = 0;
3969
+ break;
3970
+ case 'top-start':
3971
+ result.x = 0;
3972
+ result.y = 0;
3973
+ break;
3974
+ case 'top-end':
3975
+ result.x = -imageWidth;
3976
+ result.y = 0;
3977
+ break;
3978
+ case 'bottom':
3979
+ result.x = -imageWidth / 2;
3980
+ result.y = -imageHeight;
3981
+ break;
3982
+ case 'bottom-start':
3983
+ result.x = 0;
3984
+ result.y = -imageHeight;
3985
+ break;
3986
+ case 'bottom-end':
3987
+ result.x = -imageWidth;
3988
+ result.y = -imageHeight;
3989
+ break;
3990
+ case 'left':
3991
+ result.x = 0;
3992
+ result.y = -imageHeight / 2;
3993
+ break;
3994
+ case 'right':
3995
+ result.x = -imageWidth;
3996
+ result.y = -imageHeight / 2;
3997
+ break;
3998
+ }
3999
+ !isUndefined((_a = this.props) === null || _a === void 0 ? void 0 : _a.translateX) && (result.x = 0);
4000
+ !isUndefined((_b = this.props) === null || _b === void 0 ? void 0 : _b.translateY) && (result.y = 0);
4001
+ return result;
4002
+ };
4003
+ return WatermarkCanvas;
4004
+ }());
4005
+
4006
+ var GridLayout = /** @class */ (function () {
4007
+ function GridLayout(args, partialCanvas) {
4008
+ var _a, _b, _c, _d;
4009
+ this.options = args;
4010
+ this.partialWidth = this.options.width;
4011
+ this.partialHeight = this.options.height;
4012
+ this.rows = ((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.rows) || 1;
4013
+ this.cols = ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.cols) || 1;
4014
+ this.matrix = ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.matrix) || generateMatrix(this.rows, this.cols, 1);
4015
+ this.gap = ((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.gap) || [0, 0];
4016
+ this.partialCanvas = partialCanvas;
4017
+ }
4018
+ GridLayout.prototype.draw = function () {
4019
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4020
+ var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) || (this.partialWidth * this.cols + this.gap[0] * this.cols), ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.height) || (this.partialHeight * this.rows + this.gap[1] * this.rows));
4021
+ var layoutContext = layoutCanvas.getContext('2d');
4022
+ if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
4023
+ layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.drawImage((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.backgroundImage, 0, 0, (_e = this.options.gridLayoutOptions) === null || _e === void 0 ? void 0 : _e.width, (_f = this.options.gridLayoutOptions) === null || _f === void 0 ? void 0 : _f.height);
4024
+ }
4025
+ for (var rowIndex = 0; rowIndex < this.rows; rowIndex++) {
4026
+ for (var colIndex = 0; colIndex < this.cols; colIndex++) {
4027
+ if (!((_h = (_g = this.matrix) === null || _g === void 0 ? void 0 : _g[rowIndex]) === null || _h === void 0 ? void 0 : _h[colIndex])) {
4028
+ continue;
4029
+ }
4030
+ layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.drawImage(this.partialCanvas, this.partialWidth * colIndex + this.gap[0] * colIndex, this.partialHeight * rowIndex + this.gap[1] * rowIndex, this.partialWidth, this.partialHeight);
4031
+ }
4032
+ }
4033
+ return layoutCanvas;
4034
+ };
4035
+ return GridLayout;
4036
+ }());
4037
+
4038
+ var renderLayout = function (options, partialCanvas) {
4039
+ switch (options.layout) {
4040
+ case 'grid':
4041
+ return new GridLayout(options, partialCanvas).draw();
4042
+ default:
4043
+ return partialCanvas;
4044
+ }
4045
+ };
4046
+ var generateBackgroundSize = function (options) {
4047
+ var _a, _b, _c;
4048
+ switch (options.layout) {
4049
+ case 'grid':
4050
+ {
4051
+ var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
4052
+ var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
4053
+ var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
4054
+ return [
4055
+ options.width * cols + gap[0] * cols,
4056
+ options.height * rows + gap[1] * rows
4057
+ ];
4058
+ }
4059
+ default:
4060
+ return [
4061
+ options.width,
4062
+ options.height
4063
+ ];
4064
+ }
4065
+ };
4066
+
4067
+ /**
4068
+ * Watermark class
4069
+ */
4070
+ var Watermark = /** @class */ (function () {
4071
+ /**
4072
+ * Watermark constructor
4073
+ * @param args - watermark args
4074
+ */
4075
+ function Watermark(args) {
4076
+ if (args === void 0) { args = {}; }
4077
+ this.parentElement = document.body;
4078
+ this.isCreating = false;
4079
+ this.props = args;
4080
+ this.options = __assign(__assign({}, initialOptions), args);
4081
+ this.changeParentElement(this.options.parent);
4082
+ this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4083
+ bootstrap();
4084
+ }
4085
+ /**
4086
+ * Change watermark options
4087
+ * @param args
4088
+ * @param mode
4089
+ * @param redraw
4090
+ */
4091
+ Watermark.prototype.changeOptions = function () {
4092
+ return __awaiter(this, arguments, void 0, function (args, mode, redraw) {
4093
+ if (args === void 0) { args = {}; }
4094
+ if (mode === void 0) { mode = 'overwrite'; }
4095
+ if (redraw === void 0) { redraw = true; }
4096
+ return __generator(this, function (_a) {
4097
+ switch (_a.label) {
4098
+ case 0:
4099
+ this.initConfigData(args, mode);
4100
+ if (!redraw) return [3 /*break*/, 2];
4101
+ this.remove();
4102
+ return [4 /*yield*/, this.create()];
4103
+ case 1:
4104
+ _a.sent();
4105
+ _a.label = 2;
4106
+ case 2: return [2 /*return*/];
4107
+ }
4108
+ });
4109
+ });
4110
+ };
4111
+ /**
4112
+ * Creating a watermark.
4113
+ */
4114
+ Watermark.prototype.create = function () {
4115
+ return __awaiter(this, void 0, void 0, function () {
4116
+ var firstDraw, image, watermarkInnerDom, parentElementType, backgroundSize;
4117
+ var _a, _b, _c, _d, _e, _f, _g;
4118
+ return __generator(this, function (_h) {
4119
+ switch (_h.label) {
4120
+ case 0:
4121
+ if (this.isCreating) {
4122
+ return [2 /*return*/];
4123
+ }
4124
+ this.isCreating = true;
4125
+ if (!this.validateUnique()) {
4126
+ this.isCreating = false;
4127
+ return [2 /*return*/];
4128
+ }
4129
+ if (!this.validateContent()) {
4130
+ this.isCreating = false;
4131
+ return [2 /*return*/];
4132
+ }
4133
+ firstDraw = isUndefined(this.watermarkDom);
4134
+ return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
4135
+ case 1:
4136
+ _h.sent();
4137
+ this.layoutCanvas = renderLayout(this.options, (_b = this.watermarkCanvas) === null || _b === void 0 ? void 0 : _b.getCanvas());
4138
+ image = convertImage(this.layoutCanvas);
4139
+ (_c = this.watermarkCanvas) === null || _c === void 0 ? void 0 : _c.clear();
4140
+ this.watermarkDom = document.createElement('div');
4141
+ watermarkInnerDom = document.createElement('div');
4142
+ this.watermarkDom.__WATERMARK__ = 'watermark';
4143
+ this.watermarkDom.__WATERMARK__INSTANCE__ = this;
4144
+ parentElementType = this.checkParentElementType();
4145
+ this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
4146
+ backgroundSize = generateBackgroundSize(this.options);
4147
+ watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(this.options.movable ? 'animation: 200s ease 0s infinite normal none running watermark !important;' : '', "\n ");
4148
+ this.watermarkDom.appendChild(watermarkInnerDom);
4149
+ this.parentElement.appendChild(this.watermarkDom);
4150
+ if (this.options.mutationObserve) {
4151
+ try {
4152
+ this.bindMutationObserve();
4153
+ }
4154
+ catch (e) {
4155
+ (_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
4156
+ }
4157
+ }
4158
+ firstDraw && ((_g = (_f = this.options).onSuccess) === null || _g === void 0 ? void 0 : _g.call(_f));
4159
+ this.isCreating = false;
4160
+ return [2 /*return*/];
4161
+ }
4162
+ });
4163
+ });
4164
+ };
4165
+ /**
4166
+ * Delete this watermark.
4167
+ */
4168
+ Watermark.prototype.destroy = function () {
4169
+ this.remove();
4170
+ this.watermarkDom = undefined;
4171
+ };
4172
+ Watermark.prototype.check = function () {
4173
+ return __awaiter(this, void 0, void 0, function () {
4174
+ return __generator(this, function (_a) {
4175
+ switch (_a.label) {
4176
+ case 0:
4177
+ if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
4178
+ this.remove();
4179
+ return [4 /*yield*/, this.create()];
4180
+ case 1:
4181
+ _a.sent();
4182
+ _a.label = 2;
4183
+ case 2: return [2 /*return*/];
4184
+ }
4185
+ });
4186
+ });
4187
+ };
4188
+ Watermark.prototype.remove = function () {
4189
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4190
+ (_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
4191
+ (_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
4192
+ (_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
4193
+ this.unbindCheckWatermarkElementEvent();
4194
+ (_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
4195
+ (_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
4196
+ };
4197
+ Watermark.prototype.initConfigData = function (args, mode) {
4198
+ var _this = this;
4199
+ if (mode === void 0) { mode = 'overwrite'; }
4200
+ if (mode === 'append') {
4201
+ Object.keys(args).forEach(function (key) {
4202
+ _this.props && (_this.props[key] = args[key]);
4203
+ });
4204
+ }
4205
+ else {
4206
+ this.props = args;
4207
+ }
4208
+ this.options = __assign(__assign({}, initialOptions), this.props);
4209
+ this.changeParentElement(this.options.parent);
4210
+ this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4211
+ };
4212
+ Watermark.prototype.changeParentElement = function (parent) {
4213
+ if (typeof parent === 'string') {
4214
+ var parentElement = document.querySelector(parent);
4215
+ parentElement && (this.parentElement = parentElement);
4216
+ }
4217
+ else {
4218
+ this.parentElement = parent;
4219
+ }
4220
+ if (!this.parentElement) {
4221
+ console.error('[WatermarkJsPlus]: please pass a valid parent element.');
4222
+ }
4223
+ };
4224
+ Watermark.prototype.validateUnique = function () {
4225
+ var result = true;
4226
+ Array.from(this.parentElement.childNodes).forEach(function (node) {
4227
+ if (!result) {
4228
+ return;
4229
+ }
4230
+ if (Object.hasOwnProperty.call(node, '__WATERMARK__')) {
4231
+ result = false;
4232
+ // throw new Error('duplicate watermark error')
4233
+ }
4234
+ });
4235
+ return result;
4236
+ };
4237
+ Watermark.prototype.validateContent = function () {
4238
+ switch (this.options.contentType) {
4239
+ case 'image':
4240
+ return Object.hasOwnProperty.call(this.options, 'image');
4241
+ case 'multi-line-text':
4242
+ case 'rich-text':
4243
+ case 'text':
4244
+ return this.options.content.length > 0;
4245
+ }
4246
+ return false;
4247
+ };
4248
+ Watermark.prototype.checkParentElementType = function () {
4249
+ if (['html', 'body'].includes(this.parentElement.tagName.toLocaleLowerCase())) {
4250
+ return 'root';
4251
+ }
4252
+ return 'custom';
4253
+ };
4254
+ Watermark.prototype.checkWatermarkElement = function () {
4255
+ return __awaiter(this, void 0, void 0, function () {
4256
+ return __generator(this, function (_a) {
4257
+ switch (_a.label) {
4258
+ case 0:
4259
+ if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
4260
+ this.remove();
4261
+ return [4 /*yield*/, this.create()];
4262
+ case 1:
4263
+ _a.sent();
4264
+ _a.label = 2;
4265
+ case 2:
4266
+ this.bindCheckWatermarkElementEvent();
4267
+ return [2 /*return*/];
4268
+ }
4269
+ });
4270
+ });
4271
+ };
4272
+ Watermark.prototype.bindMutationObserve = function () {
4273
+ var _this = this;
4274
+ if (!this.watermarkDom) {
4275
+ return;
4276
+ }
4277
+ this.bindCheckWatermarkElementEvent();
4278
+ this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
4279
+ return __generator(this, function (_a) {
4280
+ switch (_a.label) {
4281
+ case 0:
4282
+ if (!(mutationsList.length > 0)) return [3 /*break*/, 2];
4283
+ this.remove();
4284
+ return [4 /*yield*/, this.create()];
4285
+ case 1:
4286
+ _a.sent();
4287
+ _a.label = 2;
4288
+ case 2: return [2 /*return*/];
4289
+ }
4290
+ });
4291
+ }); });
4292
+ this.observer.observe(this.watermarkDom, {
4293
+ attributes: true, // 属性的变动
4294
+ childList: true, // 子节点的变动(指新增,删除或者更改)
4295
+ subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
4296
+ characterData: true // 节点内容或节点文本的变动。
4297
+ });
4298
+ this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
4299
+ var _i, mutationsList_1, item;
4300
+ var _a;
4301
+ return __generator(this, function (_b) {
4302
+ switch (_b.label) {
4303
+ case 0:
4304
+ _i = 0, mutationsList_1 = mutationsList;
4305
+ _b.label = 1;
4306
+ case 1:
4307
+ if (!(_i < mutationsList_1.length)) return [3 /*break*/, 4];
4308
+ item = mutationsList_1[_i];
4309
+ if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
4310
+ ((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
4311
+ (item.type === 'childList' && item.target === this.parentElement && item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
4312
+ this.remove();
4313
+ return [4 /*yield*/, this.create()];
4314
+ case 2:
4315
+ _b.sent();
4316
+ _b.label = 3;
4317
+ case 3:
4318
+ _i++;
4319
+ return [3 /*break*/, 1];
4320
+ case 4: return [2 /*return*/];
4321
+ }
4322
+ });
4323
+ }); });
4324
+ this.parentObserve.observe(this.parentElement, {
4325
+ attributes: true, // 属性的变动
4326
+ childList: true, // 子节点的变动(指新增,删除或者更改)
4327
+ subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
4328
+ characterData: true // 节点内容或节点文本的变动。
4329
+ });
4330
+ };
4331
+ Watermark.prototype.bindCheckWatermarkElementEvent = function () {
4332
+ this.unbindCheckWatermarkElementEvent();
4333
+ this.checkWatermarkElementRequestID = requestAnimationFrame(this.checkWatermarkElement.bind(this));
4334
+ };
4335
+ Watermark.prototype.unbindCheckWatermarkElementEvent = function () {
4336
+ if (!isUndefined(this.checkWatermarkElementRequestID)) {
4337
+ cancelAnimationFrame(this.checkWatermarkElementRequestID);
4338
+ }
4339
+ };
4340
+ return Watermark;
4341
+ }());
4342
+
4343
+ /**
4344
+ * BlindWatermark class
4345
+ */
4346
+ var BlindWatermark = /** @class */ (function (_super) {
4347
+ __extends(BlindWatermark, _super);
4348
+ /**
4349
+ * BlindWatermark constructor
4350
+ * @param props - blind watermark options
4351
+ */
4352
+ function BlindWatermark(props) {
4353
+ if (props === void 0) { props = {}; }
4354
+ var defaultProps = {
4355
+ globalAlpha: 0.005,
4356
+ mode: 'blind'
4357
+ };
4358
+ return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
4359
+ }
4360
+ /**
4361
+ * Decode blind watermark.
4362
+ * @param props - decode options
4363
+ */
4364
+ BlindWatermark.decode = function (props) {
4365
+ var _a = props.url, url = _a === void 0 ? '' : _a, _b = props.fillColor, fillColor = _b === void 0 ? '#000' : _b, _c = props.compositeOperation, compositeOperation = _c === void 0 ? 'color-burn' : _c, _d = props.mode, mode = _d === void 0 ? 'canvas' : _d, _e = props.compositeTimes, compositeTimes = _e === void 0 ? 3 : _e, onSuccess = props.onSuccess;
4366
+ if (!url) {
4367
+ return;
4368
+ }
4369
+ if (mode === 'canvas') {
4370
+ var img_1 = new Image();
4371
+ img_1.src = url;
4372
+ img_1.addEventListener('load', function () {
4373
+ var width = img_1.width, height = img_1.height;
4374
+ var canvas = WatermarkCanvas.createCanvas(width, height);
4375
+ var ctx = canvas.getContext('2d');
4376
+ if (!ctx) {
4377
+ throw new Error('get context error');
4378
+ }
4379
+ ctx.drawImage(img_1, 0, 0, width, height);
4380
+ ctx.globalCompositeOperation = compositeOperation;
4381
+ ctx.fillStyle = fillColor;
4382
+ for (var i = 0; i < compositeTimes; i++) {
4383
+ ctx.fillRect(0, 0, width, height);
4384
+ }
4385
+ var resultImage = convertImage(canvas);
4386
+ if (isFunction(onSuccess)) {
4387
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(resultImage);
4388
+ }
4389
+ });
4390
+ }
4391
+ };
4392
+ return BlindWatermark;
4393
+ }(Watermark));
4394
+
4395
+ /**
4396
+ * ImageWatermark class
4397
+ */
4398
+ var ImageWatermark = /** @class */ (function () {
4399
+ /**
4400
+ * ImageWatermark constructor
4401
+ * @param args - image watermark args
4402
+ */
4403
+ function ImageWatermark(args) {
4404
+ if (args === void 0) { args = {}; }
4405
+ var _a;
4406
+ this.drew = false;
4407
+ this.props = args;
4408
+ this.options = __assign(__assign({}, initialOptions), args);
4409
+ this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4410
+ this.originalSrc = (_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.src;
4411
+ this.backgroundImage = this.getBackgroundImage();
4412
+ }
4413
+ ImageWatermark.prototype.create = function () {
4414
+ return __awaiter(this, void 0, void 0, function () {
4415
+ var _a, _b, _c, _d, _e;
4416
+ return __generator(this, function (_f) {
4417
+ switch (_f.label) {
4418
+ case 0:
4419
+ if (this.drew) {
4420
+ return [2 /*return*/];
4421
+ }
4422
+ return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
4423
+ case 1:
4424
+ _f.sent();
4425
+ this.options.layout = 'grid';
4426
+ this.options.gridLayoutOptions = __assign(__assign({}, this.options.gridLayoutOptions), { width: (_b = this.backgroundImage) === null || _b === void 0 ? void 0 : _b.width, height: (_c = this.backgroundImage) === null || _c === void 0 ? void 0 : _c.height, backgroundImage: this.backgroundImage });
4427
+ this.layoutCanvas = renderLayout(this.options, (_d = this.watermarkCanvas) === null || _d === void 0 ? void 0 : _d.getCanvas());
4428
+ this.options.dom.src = convertImage(this.layoutCanvas);
4429
+ (_e = this.watermarkCanvas) === null || _e === void 0 ? void 0 : _e.clear();
4430
+ this.drew = true;
4431
+ return [2 /*return*/];
4432
+ }
4433
+ });
4434
+ });
4435
+ };
4436
+ ImageWatermark.prototype.destroy = function () {
4437
+ this.options.dom.src = this.originalSrc;
4438
+ this.drew = false;
4439
+ };
4440
+ ImageWatermark.prototype.getBackgroundImage = function () {
4441
+ if (this.options.dom) {
4442
+ return this.options.dom;
4443
+ }
4444
+ };
4445
+ return ImageWatermark;
4446
+ }());
4447
+
4448
+ exports.BlindWatermark = BlindWatermark;
4449
+ exports.ImageWatermark = ImageWatermark;
4450
+ exports.Watermark = Watermark;
4451
+ //# sourceMappingURL=index.cjs.js.map