@everymatrix/player-withdrawal 0.0.163

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4872 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.app = factory());
5
+ }(this, (function () { 'use strict';
6
+
7
+ function noop$1() { }
8
+ function add_location(element, file, line, column, char) {
9
+ element.__svelte_meta = {
10
+ loc: { file, line, column, char }
11
+ };
12
+ }
13
+ function run(fn) {
14
+ return fn();
15
+ }
16
+ function blank_object() {
17
+ return Object.create(null);
18
+ }
19
+ function run_all(fns) {
20
+ fns.forEach(run);
21
+ }
22
+ function is_function(thing) {
23
+ return typeof thing === 'function';
24
+ }
25
+ function safe_not_equal(a, b) {
26
+ return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
27
+ }
28
+ function is_empty(obj) {
29
+ return Object.keys(obj).length === 0;
30
+ }
31
+ function subscribe(store, ...callbacks) {
32
+ if (store == null) {
33
+ return noop$1;
34
+ }
35
+ const unsub = store.subscribe(...callbacks);
36
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
37
+ }
38
+
39
+ function append(target, node) {
40
+ target.appendChild(node);
41
+ }
42
+ function insert(target, node, anchor) {
43
+ target.insertBefore(node, anchor || null);
44
+ }
45
+ function detach(node) {
46
+ node.parentNode.removeChild(node);
47
+ }
48
+ function element(name) {
49
+ return document.createElement(name);
50
+ }
51
+ function svg_element(name) {
52
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
53
+ }
54
+ function text(data) {
55
+ return document.createTextNode(data);
56
+ }
57
+ function space() {
58
+ return text(' ');
59
+ }
60
+ function listen(node, event, handler, options) {
61
+ node.addEventListener(event, handler, options);
62
+ return () => node.removeEventListener(event, handler, options);
63
+ }
64
+ function attr(node, attribute, value) {
65
+ if (value == null)
66
+ node.removeAttribute(attribute);
67
+ else if (node.getAttribute(attribute) !== value)
68
+ node.setAttribute(attribute, value);
69
+ }
70
+ function children(element) {
71
+ return Array.from(element.childNodes);
72
+ }
73
+ function custom_event(type, detail) {
74
+ const e = document.createEvent('CustomEvent');
75
+ e.initCustomEvent(type, false, false, detail);
76
+ return e;
77
+ }
78
+ function attribute_to_object(attributes) {
79
+ const result = {};
80
+ for (const attribute of attributes) {
81
+ result[attribute.name] = attribute.value;
82
+ }
83
+ return result;
84
+ }
85
+
86
+ let current_component;
87
+ function set_current_component(component) {
88
+ current_component = component;
89
+ }
90
+ function get_current_component() {
91
+ if (!current_component)
92
+ throw new Error('Function called outside component initialization');
93
+ return current_component;
94
+ }
95
+ function onMount(fn) {
96
+ get_current_component().$$.on_mount.push(fn);
97
+ }
98
+
99
+ const dirty_components = [];
100
+ const binding_callbacks = [];
101
+ const render_callbacks = [];
102
+ const flush_callbacks = [];
103
+ const resolved_promise = Promise.resolve();
104
+ let update_scheduled = false;
105
+ function schedule_update() {
106
+ if (!update_scheduled) {
107
+ update_scheduled = true;
108
+ resolved_promise.then(flush);
109
+ }
110
+ }
111
+ function add_render_callback(fn) {
112
+ render_callbacks.push(fn);
113
+ }
114
+ let flushing = false;
115
+ const seen_callbacks = new Set();
116
+ function flush() {
117
+ if (flushing)
118
+ return;
119
+ flushing = true;
120
+ do {
121
+ // first, call beforeUpdate functions
122
+ // and update components
123
+ for (let i = 0; i < dirty_components.length; i += 1) {
124
+ const component = dirty_components[i];
125
+ set_current_component(component);
126
+ update(component.$$);
127
+ }
128
+ set_current_component(null);
129
+ dirty_components.length = 0;
130
+ while (binding_callbacks.length)
131
+ binding_callbacks.pop()();
132
+ // then, once components are updated, call
133
+ // afterUpdate functions. This may cause
134
+ // subsequent updates...
135
+ for (let i = 0; i < render_callbacks.length; i += 1) {
136
+ const callback = render_callbacks[i];
137
+ if (!seen_callbacks.has(callback)) {
138
+ // ...so guard against infinite loops
139
+ seen_callbacks.add(callback);
140
+ callback();
141
+ }
142
+ }
143
+ render_callbacks.length = 0;
144
+ } while (dirty_components.length);
145
+ while (flush_callbacks.length) {
146
+ flush_callbacks.pop()();
147
+ }
148
+ update_scheduled = false;
149
+ flushing = false;
150
+ seen_callbacks.clear();
151
+ }
152
+ function update($$) {
153
+ if ($$.fragment !== null) {
154
+ $$.update();
155
+ run_all($$.before_update);
156
+ const dirty = $$.dirty;
157
+ $$.dirty = [-1];
158
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
159
+ $$.after_update.forEach(add_render_callback);
160
+ }
161
+ }
162
+ const outroing = new Set();
163
+ function transition_in(block, local) {
164
+ if (block && block.i) {
165
+ outroing.delete(block);
166
+ block.i(local);
167
+ }
168
+ }
169
+
170
+ const globals = (typeof window !== 'undefined'
171
+ ? window
172
+ : typeof globalThis !== 'undefined'
173
+ ? globalThis
174
+ : global);
175
+ function mount_component(component, target, anchor, customElement) {
176
+ const { fragment, on_mount, on_destroy, after_update } = component.$$;
177
+ fragment && fragment.m(target, anchor);
178
+ if (!customElement) {
179
+ // onMount happens before the initial afterUpdate
180
+ add_render_callback(() => {
181
+ const new_on_destroy = on_mount.map(run).filter(is_function);
182
+ if (on_destroy) {
183
+ on_destroy.push(...new_on_destroy);
184
+ }
185
+ else {
186
+ // Edge case - component was destroyed immediately,
187
+ // most likely as a result of a binding initialising
188
+ run_all(new_on_destroy);
189
+ }
190
+ component.$$.on_mount = [];
191
+ });
192
+ }
193
+ after_update.forEach(add_render_callback);
194
+ }
195
+ function destroy_component(component, detaching) {
196
+ const $$ = component.$$;
197
+ if ($$.fragment !== null) {
198
+ run_all($$.on_destroy);
199
+ $$.fragment && $$.fragment.d(detaching);
200
+ // TODO null out other refs, including component.$$ (but need to
201
+ // preserve final state?)
202
+ $$.on_destroy = $$.fragment = null;
203
+ $$.ctx = [];
204
+ }
205
+ }
206
+ function make_dirty(component, i) {
207
+ if (component.$$.dirty[0] === -1) {
208
+ dirty_components.push(component);
209
+ schedule_update();
210
+ component.$$.dirty.fill(0);
211
+ }
212
+ component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
213
+ }
214
+ function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
215
+ const parent_component = current_component;
216
+ set_current_component(component);
217
+ const $$ = component.$$ = {
218
+ fragment: null,
219
+ ctx: null,
220
+ // state
221
+ props,
222
+ update: noop$1,
223
+ not_equal,
224
+ bound: blank_object(),
225
+ // lifecycle
226
+ on_mount: [],
227
+ on_destroy: [],
228
+ on_disconnect: [],
229
+ before_update: [],
230
+ after_update: [],
231
+ context: new Map(parent_component ? parent_component.$$.context : options.context || []),
232
+ // everything else
233
+ callbacks: blank_object(),
234
+ dirty,
235
+ skip_bound: false
236
+ };
237
+ let ready = false;
238
+ $$.ctx = instance
239
+ ? instance(component, options.props || {}, (i, ret, ...rest) => {
240
+ const value = rest.length ? rest[0] : ret;
241
+ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
242
+ if (!$$.skip_bound && $$.bound[i])
243
+ $$.bound[i](value);
244
+ if (ready)
245
+ make_dirty(component, i);
246
+ }
247
+ return ret;
248
+ })
249
+ : [];
250
+ $$.update();
251
+ ready = true;
252
+ run_all($$.before_update);
253
+ // `false` as a special case of no DOM component
254
+ $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
255
+ if (options.target) {
256
+ if (options.hydrate) {
257
+ const nodes = children(options.target);
258
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
259
+ $$.fragment && $$.fragment.l(nodes);
260
+ nodes.forEach(detach);
261
+ }
262
+ else {
263
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
264
+ $$.fragment && $$.fragment.c();
265
+ }
266
+ if (options.intro)
267
+ transition_in(component.$$.fragment);
268
+ mount_component(component, options.target, options.anchor, options.customElement);
269
+ flush();
270
+ }
271
+ set_current_component(parent_component);
272
+ }
273
+ let SvelteElement;
274
+ if (typeof HTMLElement === 'function') {
275
+ SvelteElement = class extends HTMLElement {
276
+ constructor() {
277
+ super();
278
+ this.attachShadow({ mode: 'open' });
279
+ }
280
+ connectedCallback() {
281
+ const { on_mount } = this.$$;
282
+ this.$$.on_disconnect = on_mount.map(run).filter(is_function);
283
+ // @ts-ignore todo: improve typings
284
+ for (const key in this.$$.slotted) {
285
+ // @ts-ignore todo: improve typings
286
+ this.appendChild(this.$$.slotted[key]);
287
+ }
288
+ }
289
+ attributeChangedCallback(attr, _oldValue, newValue) {
290
+ this[attr] = newValue;
291
+ }
292
+ disconnectedCallback() {
293
+ run_all(this.$$.on_disconnect);
294
+ }
295
+ $destroy() {
296
+ destroy_component(this, 1);
297
+ this.$destroy = noop$1;
298
+ }
299
+ $on(type, callback) {
300
+ // TODO should this delegate to addEventListener?
301
+ const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
302
+ callbacks.push(callback);
303
+ return () => {
304
+ const index = callbacks.indexOf(callback);
305
+ if (index !== -1)
306
+ callbacks.splice(index, 1);
307
+ };
308
+ }
309
+ $set($$props) {
310
+ if (this.$$set && !is_empty($$props)) {
311
+ this.$$.skip_bound = true;
312
+ this.$$set($$props);
313
+ this.$$.skip_bound = false;
314
+ }
315
+ }
316
+ };
317
+ }
318
+
319
+ function dispatch_dev(type, detail) {
320
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.37.0' }, detail)));
321
+ }
322
+ function append_dev(target, node) {
323
+ dispatch_dev('SvelteDOMInsert', { target, node });
324
+ append(target, node);
325
+ }
326
+ function insert_dev(target, node, anchor) {
327
+ dispatch_dev('SvelteDOMInsert', { target, node, anchor });
328
+ insert(target, node, anchor);
329
+ }
330
+ function detach_dev(node) {
331
+ dispatch_dev('SvelteDOMRemove', { node });
332
+ detach(node);
333
+ }
334
+ function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {
335
+ const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : [];
336
+ if (has_prevent_default)
337
+ modifiers.push('preventDefault');
338
+ if (has_stop_propagation)
339
+ modifiers.push('stopPropagation');
340
+ dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
341
+ const dispose = listen(node, event, handler, options);
342
+ return () => {
343
+ dispatch_dev('SvelteDOMRemoveEventListener', { node, event, handler, modifiers });
344
+ dispose();
345
+ };
346
+ }
347
+ function attr_dev(node, attribute, value) {
348
+ attr(node, attribute, value);
349
+ if (value == null)
350
+ dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
351
+ else
352
+ dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
353
+ }
354
+ function validate_slots(name, slot, keys) {
355
+ for (const slot_key of Object.keys(slot)) {
356
+ if (!~keys.indexOf(slot_key)) {
357
+ console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
358
+ }
359
+ }
360
+ }
361
+
362
+ var global$1 =
363
+ (typeof globalThis !== 'undefined' && globalThis) ||
364
+ (typeof self !== 'undefined' && self) ||
365
+ (typeof global$1 !== 'undefined' && global$1);
366
+
367
+ var support = {
368
+ searchParams: 'URLSearchParams' in global$1,
369
+ iterable: 'Symbol' in global$1 && 'iterator' in Symbol,
370
+ blob:
371
+ 'FileReader' in global$1 &&
372
+ 'Blob' in global$1 &&
373
+ (function() {
374
+ try {
375
+ new Blob();
376
+ return true
377
+ } catch (e) {
378
+ return false
379
+ }
380
+ })(),
381
+ formData: 'FormData' in global$1,
382
+ arrayBuffer: 'ArrayBuffer' in global$1
383
+ };
384
+
385
+ function isDataView(obj) {
386
+ return obj && DataView.prototype.isPrototypeOf(obj)
387
+ }
388
+
389
+ if (support.arrayBuffer) {
390
+ var viewClasses = [
391
+ '[object Int8Array]',
392
+ '[object Uint8Array]',
393
+ '[object Uint8ClampedArray]',
394
+ '[object Int16Array]',
395
+ '[object Uint16Array]',
396
+ '[object Int32Array]',
397
+ '[object Uint32Array]',
398
+ '[object Float32Array]',
399
+ '[object Float64Array]'
400
+ ];
401
+
402
+ var isArrayBufferView =
403
+ ArrayBuffer.isView ||
404
+ function(obj) {
405
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
406
+ };
407
+ }
408
+
409
+ function normalizeName(name) {
410
+ if (typeof name !== 'string') {
411
+ name = String(name);
412
+ }
413
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
414
+ throw new TypeError('Invalid character in header field name: "' + name + '"')
415
+ }
416
+ return name.toLowerCase()
417
+ }
418
+
419
+ function normalizeValue(value) {
420
+ if (typeof value !== 'string') {
421
+ value = String(value);
422
+ }
423
+ return value
424
+ }
425
+
426
+ // Build a destructive iterator for the value list
427
+ function iteratorFor(items) {
428
+ var iterator = {
429
+ next: function() {
430
+ var value = items.shift();
431
+ return {done: value === undefined, value: value}
432
+ }
433
+ };
434
+
435
+ if (support.iterable) {
436
+ iterator[Symbol.iterator] = function() {
437
+ return iterator
438
+ };
439
+ }
440
+
441
+ return iterator
442
+ }
443
+
444
+ function Headers(headers) {
445
+ this.map = {};
446
+
447
+ if (headers instanceof Headers) {
448
+ headers.forEach(function(value, name) {
449
+ this.append(name, value);
450
+ }, this);
451
+ } else if (Array.isArray(headers)) {
452
+ headers.forEach(function(header) {
453
+ this.append(header[0], header[1]);
454
+ }, this);
455
+ } else if (headers) {
456
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
457
+ this.append(name, headers[name]);
458
+ }, this);
459
+ }
460
+ }
461
+
462
+ Headers.prototype.append = function(name, value) {
463
+ name = normalizeName(name);
464
+ value = normalizeValue(value);
465
+ var oldValue = this.map[name];
466
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
467
+ };
468
+
469
+ Headers.prototype['delete'] = function(name) {
470
+ delete this.map[normalizeName(name)];
471
+ };
472
+
473
+ Headers.prototype.get = function(name) {
474
+ name = normalizeName(name);
475
+ return this.has(name) ? this.map[name] : null
476
+ };
477
+
478
+ Headers.prototype.has = function(name) {
479
+ return this.map.hasOwnProperty(normalizeName(name))
480
+ };
481
+
482
+ Headers.prototype.set = function(name, value) {
483
+ this.map[normalizeName(name)] = normalizeValue(value);
484
+ };
485
+
486
+ Headers.prototype.forEach = function(callback, thisArg) {
487
+ for (var name in this.map) {
488
+ if (this.map.hasOwnProperty(name)) {
489
+ callback.call(thisArg, this.map[name], name, this);
490
+ }
491
+ }
492
+ };
493
+
494
+ Headers.prototype.keys = function() {
495
+ var items = [];
496
+ this.forEach(function(value, name) {
497
+ items.push(name);
498
+ });
499
+ return iteratorFor(items)
500
+ };
501
+
502
+ Headers.prototype.values = function() {
503
+ var items = [];
504
+ this.forEach(function(value) {
505
+ items.push(value);
506
+ });
507
+ return iteratorFor(items)
508
+ };
509
+
510
+ Headers.prototype.entries = function() {
511
+ var items = [];
512
+ this.forEach(function(value, name) {
513
+ items.push([name, value]);
514
+ });
515
+ return iteratorFor(items)
516
+ };
517
+
518
+ if (support.iterable) {
519
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
520
+ }
521
+
522
+ function consumed(body) {
523
+ if (body.bodyUsed) {
524
+ return Promise.reject(new TypeError('Already read'))
525
+ }
526
+ body.bodyUsed = true;
527
+ }
528
+
529
+ function fileReaderReady(reader) {
530
+ return new Promise(function(resolve, reject) {
531
+ reader.onload = function() {
532
+ resolve(reader.result);
533
+ };
534
+ reader.onerror = function() {
535
+ reject(reader.error);
536
+ };
537
+ })
538
+ }
539
+
540
+ function readBlobAsArrayBuffer(blob) {
541
+ var reader = new FileReader();
542
+ var promise = fileReaderReady(reader);
543
+ reader.readAsArrayBuffer(blob);
544
+ return promise
545
+ }
546
+
547
+ function readBlobAsText(blob) {
548
+ var reader = new FileReader();
549
+ var promise = fileReaderReady(reader);
550
+ reader.readAsText(blob);
551
+ return promise
552
+ }
553
+
554
+ function readArrayBufferAsText(buf) {
555
+ var view = new Uint8Array(buf);
556
+ var chars = new Array(view.length);
557
+
558
+ for (var i = 0; i < view.length; i++) {
559
+ chars[i] = String.fromCharCode(view[i]);
560
+ }
561
+ return chars.join('')
562
+ }
563
+
564
+ function bufferClone(buf) {
565
+ if (buf.slice) {
566
+ return buf.slice(0)
567
+ } else {
568
+ var view = new Uint8Array(buf.byteLength);
569
+ view.set(new Uint8Array(buf));
570
+ return view.buffer
571
+ }
572
+ }
573
+
574
+ function Body() {
575
+ this.bodyUsed = false;
576
+
577
+ this._initBody = function(body) {
578
+ /*
579
+ fetch-mock wraps the Response object in an ES6 Proxy to
580
+ provide useful test harness features such as flush. However, on
581
+ ES5 browsers without fetch or Proxy support pollyfills must be used;
582
+ the proxy-pollyfill is unable to proxy an attribute unless it exists
583
+ on the object before the Proxy is created. This change ensures
584
+ Response.bodyUsed exists on the instance, while maintaining the
585
+ semantic of setting Request.bodyUsed in the constructor before
586
+ _initBody is called.
587
+ */
588
+ this.bodyUsed = this.bodyUsed;
589
+ this._bodyInit = body;
590
+ if (!body) {
591
+ this._bodyText = '';
592
+ } else if (typeof body === 'string') {
593
+ this._bodyText = body;
594
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
595
+ this._bodyBlob = body;
596
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
597
+ this._bodyFormData = body;
598
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
599
+ this._bodyText = body.toString();
600
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
601
+ this._bodyArrayBuffer = bufferClone(body.buffer);
602
+ // IE 10-11 can't handle a DataView body.
603
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
604
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
605
+ this._bodyArrayBuffer = bufferClone(body);
606
+ } else {
607
+ this._bodyText = body = Object.prototype.toString.call(body);
608
+ }
609
+
610
+ if (!this.headers.get('content-type')) {
611
+ if (typeof body === 'string') {
612
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
613
+ } else if (this._bodyBlob && this._bodyBlob.type) {
614
+ this.headers.set('content-type', this._bodyBlob.type);
615
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
616
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
617
+ }
618
+ }
619
+ };
620
+
621
+ if (support.blob) {
622
+ this.blob = function() {
623
+ var rejected = consumed(this);
624
+ if (rejected) {
625
+ return rejected
626
+ }
627
+
628
+ if (this._bodyBlob) {
629
+ return Promise.resolve(this._bodyBlob)
630
+ } else if (this._bodyArrayBuffer) {
631
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]))
632
+ } else if (this._bodyFormData) {
633
+ throw new Error('could not read FormData body as blob')
634
+ } else {
635
+ return Promise.resolve(new Blob([this._bodyText]))
636
+ }
637
+ };
638
+
639
+ this.arrayBuffer = function() {
640
+ if (this._bodyArrayBuffer) {
641
+ var isConsumed = consumed(this);
642
+ if (isConsumed) {
643
+ return isConsumed
644
+ }
645
+ if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
646
+ return Promise.resolve(
647
+ this._bodyArrayBuffer.buffer.slice(
648
+ this._bodyArrayBuffer.byteOffset,
649
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
650
+ )
651
+ )
652
+ } else {
653
+ return Promise.resolve(this._bodyArrayBuffer)
654
+ }
655
+ } else {
656
+ return this.blob().then(readBlobAsArrayBuffer)
657
+ }
658
+ };
659
+ }
660
+
661
+ this.text = function() {
662
+ var rejected = consumed(this);
663
+ if (rejected) {
664
+ return rejected
665
+ }
666
+
667
+ if (this._bodyBlob) {
668
+ return readBlobAsText(this._bodyBlob)
669
+ } else if (this._bodyArrayBuffer) {
670
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
671
+ } else if (this._bodyFormData) {
672
+ throw new Error('could not read FormData body as text')
673
+ } else {
674
+ return Promise.resolve(this._bodyText)
675
+ }
676
+ };
677
+
678
+ if (support.formData) {
679
+ this.formData = function() {
680
+ return this.text().then(decode)
681
+ };
682
+ }
683
+
684
+ this.json = function() {
685
+ return this.text().then(JSON.parse)
686
+ };
687
+
688
+ return this
689
+ }
690
+
691
+ // HTTP methods whose capitalization should be normalized
692
+ var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
693
+
694
+ function normalizeMethod(method) {
695
+ var upcased = method.toUpperCase();
696
+ return methods.indexOf(upcased) > -1 ? upcased : method
697
+ }
698
+
699
+ function Request(input, options) {
700
+ if (!(this instanceof Request)) {
701
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
702
+ }
703
+
704
+ options = options || {};
705
+ var body = options.body;
706
+
707
+ if (input instanceof Request) {
708
+ if (input.bodyUsed) {
709
+ throw new TypeError('Already read')
710
+ }
711
+ this.url = input.url;
712
+ this.credentials = input.credentials;
713
+ if (!options.headers) {
714
+ this.headers = new Headers(input.headers);
715
+ }
716
+ this.method = input.method;
717
+ this.mode = input.mode;
718
+ this.signal = input.signal;
719
+ if (!body && input._bodyInit != null) {
720
+ body = input._bodyInit;
721
+ input.bodyUsed = true;
722
+ }
723
+ } else {
724
+ this.url = String(input);
725
+ }
726
+
727
+ this.credentials = options.credentials || this.credentials || 'same-origin';
728
+ if (options.headers || !this.headers) {
729
+ this.headers = new Headers(options.headers);
730
+ }
731
+ this.method = normalizeMethod(options.method || this.method || 'GET');
732
+ this.mode = options.mode || this.mode || null;
733
+ this.signal = options.signal || this.signal;
734
+ this.referrer = null;
735
+
736
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
737
+ throw new TypeError('Body not allowed for GET or HEAD requests')
738
+ }
739
+ this._initBody(body);
740
+
741
+ if (this.method === 'GET' || this.method === 'HEAD') {
742
+ if (options.cache === 'no-store' || options.cache === 'no-cache') {
743
+ // Search for a '_' parameter in the query string
744
+ var reParamSearch = /([?&])_=[^&]*/;
745
+ if (reParamSearch.test(this.url)) {
746
+ // If it already exists then set the value with the current time
747
+ this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
748
+ } else {
749
+ // Otherwise add a new '_' parameter to the end with the current time
750
+ var reQueryString = /\?/;
751
+ this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
752
+ }
753
+ }
754
+ }
755
+ }
756
+
757
+ Request.prototype.clone = function() {
758
+ return new Request(this, {body: this._bodyInit})
759
+ };
760
+
761
+ function decode(body) {
762
+ var form = new FormData();
763
+ body
764
+ .trim()
765
+ .split('&')
766
+ .forEach(function(bytes) {
767
+ if (bytes) {
768
+ var split = bytes.split('=');
769
+ var name = split.shift().replace(/\+/g, ' ');
770
+ var value = split.join('=').replace(/\+/g, ' ');
771
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
772
+ }
773
+ });
774
+ return form
775
+ }
776
+
777
+ function parseHeaders(rawHeaders) {
778
+ var headers = new Headers();
779
+ // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
780
+ // https://tools.ietf.org/html/rfc7230#section-3.2
781
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
782
+ // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
783
+ // https://github.com/github/fetch/issues/748
784
+ // https://github.com/zloirock/core-js/issues/751
785
+ preProcessedHeaders
786
+ .split('\r')
787
+ .map(function(header) {
788
+ return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
789
+ })
790
+ .forEach(function(line) {
791
+ var parts = line.split(':');
792
+ var key = parts.shift().trim();
793
+ if (key) {
794
+ var value = parts.join(':').trim();
795
+ headers.append(key, value);
796
+ }
797
+ });
798
+ return headers
799
+ }
800
+
801
+ Body.call(Request.prototype);
802
+
803
+ function Response(bodyInit, options) {
804
+ if (!(this instanceof Response)) {
805
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
806
+ }
807
+ if (!options) {
808
+ options = {};
809
+ }
810
+
811
+ this.type = 'default';
812
+ this.status = options.status === undefined ? 200 : options.status;
813
+ this.ok = this.status >= 200 && this.status < 300;
814
+ this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
815
+ this.headers = new Headers(options.headers);
816
+ this.url = options.url || '';
817
+ this._initBody(bodyInit);
818
+ }
819
+
820
+ Body.call(Response.prototype);
821
+
822
+ Response.prototype.clone = function() {
823
+ return new Response(this._bodyInit, {
824
+ status: this.status,
825
+ statusText: this.statusText,
826
+ headers: new Headers(this.headers),
827
+ url: this.url
828
+ })
829
+ };
830
+
831
+ Response.error = function() {
832
+ var response = new Response(null, {status: 0, statusText: ''});
833
+ response.type = 'error';
834
+ return response
835
+ };
836
+
837
+ var redirectStatuses = [301, 302, 303, 307, 308];
838
+
839
+ Response.redirect = function(url, status) {
840
+ if (redirectStatuses.indexOf(status) === -1) {
841
+ throw new RangeError('Invalid status code')
842
+ }
843
+
844
+ return new Response(null, {status: status, headers: {location: url}})
845
+ };
846
+
847
+ var DOMException = global$1.DOMException;
848
+ try {
849
+ new DOMException();
850
+ } catch (err) {
851
+ DOMException = function(message, name) {
852
+ this.message = message;
853
+ this.name = name;
854
+ var error = Error(message);
855
+ this.stack = error.stack;
856
+ };
857
+ DOMException.prototype = Object.create(Error.prototype);
858
+ DOMException.prototype.constructor = DOMException;
859
+ }
860
+
861
+ function fetch$1(input, init) {
862
+ return new Promise(function(resolve, reject) {
863
+ var request = new Request(input, init);
864
+
865
+ if (request.signal && request.signal.aborted) {
866
+ return reject(new DOMException('Aborted', 'AbortError'))
867
+ }
868
+
869
+ var xhr = new XMLHttpRequest();
870
+
871
+ function abortXhr() {
872
+ xhr.abort();
873
+ }
874
+
875
+ xhr.onload = function() {
876
+ var options = {
877
+ status: xhr.status,
878
+ statusText: xhr.statusText,
879
+ headers: parseHeaders(xhr.getAllResponseHeaders() || '')
880
+ };
881
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
882
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
883
+ setTimeout(function() {
884
+ resolve(new Response(body, options));
885
+ }, 0);
886
+ };
887
+
888
+ xhr.onerror = function() {
889
+ setTimeout(function() {
890
+ reject(new TypeError('Network request failed'));
891
+ }, 0);
892
+ };
893
+
894
+ xhr.ontimeout = function() {
895
+ setTimeout(function() {
896
+ reject(new TypeError('Network request failed'));
897
+ }, 0);
898
+ };
899
+
900
+ xhr.onabort = function() {
901
+ setTimeout(function() {
902
+ reject(new DOMException('Aborted', 'AbortError'));
903
+ }, 0);
904
+ };
905
+
906
+ function fixUrl(url) {
907
+ try {
908
+ return url === '' && global$1.location.href ? global$1.location.href : url
909
+ } catch (e) {
910
+ return url
911
+ }
912
+ }
913
+
914
+ xhr.open(request.method, fixUrl(request.url), true);
915
+
916
+ if (request.credentials === 'include') {
917
+ xhr.withCredentials = true;
918
+ } else if (request.credentials === 'omit') {
919
+ xhr.withCredentials = false;
920
+ }
921
+
922
+ if ('responseType' in xhr) {
923
+ if (support.blob) {
924
+ xhr.responseType = 'blob';
925
+ } else if (
926
+ support.arrayBuffer &&
927
+ request.headers.get('Content-Type') &&
928
+ request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
929
+ ) {
930
+ xhr.responseType = 'arraybuffer';
931
+ }
932
+ }
933
+
934
+ if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
935
+ Object.getOwnPropertyNames(init.headers).forEach(function(name) {
936
+ xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
937
+ });
938
+ } else {
939
+ request.headers.forEach(function(value, name) {
940
+ xhr.setRequestHeader(name, value);
941
+ });
942
+ }
943
+
944
+ if (request.signal) {
945
+ request.signal.addEventListener('abort', abortXhr);
946
+
947
+ xhr.onreadystatechange = function() {
948
+ // DONE (success or failure)
949
+ if (xhr.readyState === 4) {
950
+ request.signal.removeEventListener('abort', abortXhr);
951
+ }
952
+ };
953
+ }
954
+
955
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
956
+ })
957
+ }
958
+
959
+ fetch$1.polyfill = true;
960
+
961
+ if (!global$1.fetch) {
962
+ global$1.fetch = fetch$1;
963
+ global$1.Headers = Headers;
964
+ global$1.Request = Request;
965
+ global$1.Response = Response;
966
+ }
967
+
968
+ // the whatwg-fetch polyfill installs the fetch() function
969
+ // on the global object (window or self)
970
+ //
971
+ // Return that as the export for use in Webpack, Browserify etc.
972
+
973
+ self.fetch.bind(self);
974
+
975
+ /*! *****************************************************************************
976
+ Copyright (c) Microsoft Corporation.
977
+
978
+ Permission to use, copy, modify, and/or distribute this software for any
979
+ purpose with or without fee is hereby granted.
980
+
981
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
982
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
983
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
984
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
985
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
986
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
987
+ PERFORMANCE OF THIS SOFTWARE.
988
+ ***************************************************************************** */
989
+ /* global Reflect, Promise */
990
+
991
+ var extendStatics$1 = function(d, b) {
992
+ extendStatics$1 = Object.setPrototypeOf ||
993
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
994
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
995
+ return extendStatics$1(d, b);
996
+ };
997
+
998
+ function __extends$1(d, b) {
999
+ if (typeof b !== "function" && b !== null)
1000
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1001
+ extendStatics$1(d, b);
1002
+ function __() { this.constructor = d; }
1003
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1004
+ }
1005
+
1006
+ function __values(o) {
1007
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1008
+ if (m) return m.call(o);
1009
+ if (o && typeof o.length === "number") return {
1010
+ next: function () {
1011
+ if (o && i >= o.length) o = void 0;
1012
+ return { value: o && o[i++], done: !o };
1013
+ }
1014
+ };
1015
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1016
+ }
1017
+
1018
+ function __read(o, n) {
1019
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
1020
+ if (!m) return o;
1021
+ var i = m.call(o), r, ar = [], e;
1022
+ try {
1023
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1024
+ }
1025
+ catch (error) { e = { error: error }; }
1026
+ finally {
1027
+ try {
1028
+ if (r && !r.done && (m = i["return"])) m.call(i);
1029
+ }
1030
+ finally { if (e) throw e.error; }
1031
+ }
1032
+ return ar;
1033
+ }
1034
+
1035
+ function __spreadArray$1(to, from) {
1036
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1037
+ to[j] = from[i];
1038
+ return to;
1039
+ }
1040
+
1041
+ function isFunction(value) {
1042
+ return typeof value === 'function';
1043
+ }
1044
+
1045
+ function createErrorClass(createImpl) {
1046
+ var _super = function (instance) {
1047
+ Error.call(instance);
1048
+ instance.stack = new Error().stack;
1049
+ };
1050
+ var ctorFunc = createImpl(_super);
1051
+ ctorFunc.prototype = Object.create(Error.prototype);
1052
+ ctorFunc.prototype.constructor = ctorFunc;
1053
+ return ctorFunc;
1054
+ }
1055
+
1056
+ var UnsubscriptionError = createErrorClass(function (_super) {
1057
+ return function UnsubscriptionErrorImpl(errors) {
1058
+ _super(this);
1059
+ this.message = errors
1060
+ ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
1061
+ : '';
1062
+ this.name = 'UnsubscriptionError';
1063
+ this.errors = errors;
1064
+ };
1065
+ });
1066
+
1067
+ function arrRemove(arr, item) {
1068
+ if (arr) {
1069
+ var index = arr.indexOf(item);
1070
+ 0 <= index && arr.splice(index, 1);
1071
+ }
1072
+ }
1073
+
1074
+ var Subscription = (function () {
1075
+ function Subscription(initialTeardown) {
1076
+ this.initialTeardown = initialTeardown;
1077
+ this.closed = false;
1078
+ this._parentage = null;
1079
+ this._teardowns = null;
1080
+ }
1081
+ Subscription.prototype.unsubscribe = function () {
1082
+ var e_1, _a, e_2, _b;
1083
+ var errors;
1084
+ if (!this.closed) {
1085
+ this.closed = true;
1086
+ var _parentage = this._parentage;
1087
+ if (_parentage) {
1088
+ this._parentage = null;
1089
+ if (Array.isArray(_parentage)) {
1090
+ try {
1091
+ for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
1092
+ var parent_1 = _parentage_1_1.value;
1093
+ parent_1.remove(this);
1094
+ }
1095
+ }
1096
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1097
+ finally {
1098
+ try {
1099
+ if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
1100
+ }
1101
+ finally { if (e_1) throw e_1.error; }
1102
+ }
1103
+ }
1104
+ else {
1105
+ _parentage.remove(this);
1106
+ }
1107
+ }
1108
+ var initialTeardown = this.initialTeardown;
1109
+ if (isFunction(initialTeardown)) {
1110
+ try {
1111
+ initialTeardown();
1112
+ }
1113
+ catch (e) {
1114
+ errors = e instanceof UnsubscriptionError ? e.errors : [e];
1115
+ }
1116
+ }
1117
+ var _teardowns = this._teardowns;
1118
+ if (_teardowns) {
1119
+ this._teardowns = null;
1120
+ try {
1121
+ for (var _teardowns_1 = __values(_teardowns), _teardowns_1_1 = _teardowns_1.next(); !_teardowns_1_1.done; _teardowns_1_1 = _teardowns_1.next()) {
1122
+ var teardown_1 = _teardowns_1_1.value;
1123
+ try {
1124
+ execTeardown(teardown_1);
1125
+ }
1126
+ catch (err) {
1127
+ errors = errors !== null && errors !== void 0 ? errors : [];
1128
+ if (err instanceof UnsubscriptionError) {
1129
+ errors = __spreadArray$1(__spreadArray$1([], __read(errors)), __read(err.errors));
1130
+ }
1131
+ else {
1132
+ errors.push(err);
1133
+ }
1134
+ }
1135
+ }
1136
+ }
1137
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1138
+ finally {
1139
+ try {
1140
+ if (_teardowns_1_1 && !_teardowns_1_1.done && (_b = _teardowns_1.return)) _b.call(_teardowns_1);
1141
+ }
1142
+ finally { if (e_2) throw e_2.error; }
1143
+ }
1144
+ }
1145
+ if (errors) {
1146
+ throw new UnsubscriptionError(errors);
1147
+ }
1148
+ }
1149
+ };
1150
+ Subscription.prototype.add = function (teardown) {
1151
+ var _a;
1152
+ if (teardown && teardown !== this) {
1153
+ if (this.closed) {
1154
+ execTeardown(teardown);
1155
+ }
1156
+ else {
1157
+ if (teardown instanceof Subscription) {
1158
+ if (teardown.closed || teardown._hasParent(this)) {
1159
+ return;
1160
+ }
1161
+ teardown._addParent(this);
1162
+ }
1163
+ (this._teardowns = (_a = this._teardowns) !== null && _a !== void 0 ? _a : []).push(teardown);
1164
+ }
1165
+ }
1166
+ };
1167
+ Subscription.prototype._hasParent = function (parent) {
1168
+ var _parentage = this._parentage;
1169
+ return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
1170
+ };
1171
+ Subscription.prototype._addParent = function (parent) {
1172
+ var _parentage = this._parentage;
1173
+ this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
1174
+ };
1175
+ Subscription.prototype._removeParent = function (parent) {
1176
+ var _parentage = this._parentage;
1177
+ if (_parentage === parent) {
1178
+ this._parentage = null;
1179
+ }
1180
+ else if (Array.isArray(_parentage)) {
1181
+ arrRemove(_parentage, parent);
1182
+ }
1183
+ };
1184
+ Subscription.prototype.remove = function (teardown) {
1185
+ var _teardowns = this._teardowns;
1186
+ _teardowns && arrRemove(_teardowns, teardown);
1187
+ if (teardown instanceof Subscription) {
1188
+ teardown._removeParent(this);
1189
+ }
1190
+ };
1191
+ Subscription.EMPTY = (function () {
1192
+ var empty = new Subscription();
1193
+ empty.closed = true;
1194
+ return empty;
1195
+ })();
1196
+ return Subscription;
1197
+ }());
1198
+ var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
1199
+ function isSubscription(value) {
1200
+ return (value instanceof Subscription ||
1201
+ (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
1202
+ }
1203
+ function execTeardown(teardown) {
1204
+ if (isFunction(teardown)) {
1205
+ teardown();
1206
+ }
1207
+ else {
1208
+ teardown.unsubscribe();
1209
+ }
1210
+ }
1211
+
1212
+ var config = {
1213
+ onUnhandledError: null,
1214
+ onStoppedNotification: null,
1215
+ Promise: undefined,
1216
+ useDeprecatedSynchronousErrorHandling: false,
1217
+ useDeprecatedNextContext: false,
1218
+ };
1219
+
1220
+ var timeoutProvider = {
1221
+ setTimeout: function () {
1222
+ var args = [];
1223
+ for (var _i = 0; _i < arguments.length; _i++) {
1224
+ args[_i] = arguments[_i];
1225
+ }
1226
+ return (setTimeout).apply(void 0, __spreadArray$1([], __read(args)));
1227
+ },
1228
+ clearTimeout: function (handle) {
1229
+ return (clearTimeout)(handle);
1230
+ },
1231
+ delegate: undefined,
1232
+ };
1233
+
1234
+ function reportUnhandledError(err) {
1235
+ timeoutProvider.setTimeout(function () {
1236
+ {
1237
+ throw err;
1238
+ }
1239
+ });
1240
+ }
1241
+
1242
+ function noop() { }
1243
+
1244
+ function errorContext(cb) {
1245
+ {
1246
+ cb();
1247
+ }
1248
+ }
1249
+
1250
+ var Subscriber = (function (_super) {
1251
+ __extends$1(Subscriber, _super);
1252
+ function Subscriber(destination) {
1253
+ var _this = _super.call(this) || this;
1254
+ _this.isStopped = false;
1255
+ if (destination) {
1256
+ _this.destination = destination;
1257
+ if (isSubscription(destination)) {
1258
+ destination.add(_this);
1259
+ }
1260
+ }
1261
+ else {
1262
+ _this.destination = EMPTY_OBSERVER;
1263
+ }
1264
+ return _this;
1265
+ }
1266
+ Subscriber.create = function (next, error, complete) {
1267
+ return new SafeSubscriber(next, error, complete);
1268
+ };
1269
+ Subscriber.prototype.next = function (value) {
1270
+ if (this.isStopped) ;
1271
+ else {
1272
+ this._next(value);
1273
+ }
1274
+ };
1275
+ Subscriber.prototype.error = function (err) {
1276
+ if (this.isStopped) ;
1277
+ else {
1278
+ this.isStopped = true;
1279
+ this._error(err);
1280
+ }
1281
+ };
1282
+ Subscriber.prototype.complete = function () {
1283
+ if (this.isStopped) ;
1284
+ else {
1285
+ this.isStopped = true;
1286
+ this._complete();
1287
+ }
1288
+ };
1289
+ Subscriber.prototype.unsubscribe = function () {
1290
+ if (!this.closed) {
1291
+ this.isStopped = true;
1292
+ _super.prototype.unsubscribe.call(this);
1293
+ this.destination = null;
1294
+ }
1295
+ };
1296
+ Subscriber.prototype._next = function (value) {
1297
+ this.destination.next(value);
1298
+ };
1299
+ Subscriber.prototype._error = function (err) {
1300
+ try {
1301
+ this.destination.error(err);
1302
+ }
1303
+ finally {
1304
+ this.unsubscribe();
1305
+ }
1306
+ };
1307
+ Subscriber.prototype._complete = function () {
1308
+ try {
1309
+ this.destination.complete();
1310
+ }
1311
+ finally {
1312
+ this.unsubscribe();
1313
+ }
1314
+ };
1315
+ return Subscriber;
1316
+ }(Subscription));
1317
+ var SafeSubscriber = (function (_super) {
1318
+ __extends$1(SafeSubscriber, _super);
1319
+ function SafeSubscriber(observerOrNext, error, complete) {
1320
+ var _this = _super.call(this) || this;
1321
+ var next;
1322
+ if (isFunction(observerOrNext)) {
1323
+ next = observerOrNext;
1324
+ }
1325
+ else if (observerOrNext) {
1326
+ (next = observerOrNext.next, error = observerOrNext.error, complete = observerOrNext.complete);
1327
+ var context_1;
1328
+ if (_this && config.useDeprecatedNextContext) {
1329
+ context_1 = Object.create(observerOrNext);
1330
+ context_1.unsubscribe = function () { return _this.unsubscribe(); };
1331
+ }
1332
+ else {
1333
+ context_1 = observerOrNext;
1334
+ }
1335
+ next = next === null || next === void 0 ? void 0 : next.bind(context_1);
1336
+ error = error === null || error === void 0 ? void 0 : error.bind(context_1);
1337
+ complete = complete === null || complete === void 0 ? void 0 : complete.bind(context_1);
1338
+ }
1339
+ _this.destination = {
1340
+ next: next ? wrapForErrorHandling(next) : noop,
1341
+ error: wrapForErrorHandling(error !== null && error !== void 0 ? error : defaultErrorHandler),
1342
+ complete: complete ? wrapForErrorHandling(complete) : noop,
1343
+ };
1344
+ return _this;
1345
+ }
1346
+ return SafeSubscriber;
1347
+ }(Subscriber));
1348
+ function wrapForErrorHandling(handler, instance) {
1349
+ return function () {
1350
+ var args = [];
1351
+ for (var _i = 0; _i < arguments.length; _i++) {
1352
+ args[_i] = arguments[_i];
1353
+ }
1354
+ try {
1355
+ handler.apply(void 0, __spreadArray$1([], __read(args)));
1356
+ }
1357
+ catch (err) {
1358
+ {
1359
+ reportUnhandledError(err);
1360
+ }
1361
+ }
1362
+ };
1363
+ }
1364
+ function defaultErrorHandler(err) {
1365
+ throw err;
1366
+ }
1367
+ var EMPTY_OBSERVER = {
1368
+ closed: true,
1369
+ next: noop,
1370
+ error: defaultErrorHandler,
1371
+ complete: noop,
1372
+ };
1373
+
1374
+ var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
1375
+
1376
+ function identity(x) {
1377
+ return x;
1378
+ }
1379
+
1380
+ function pipeFromArray(fns) {
1381
+ if (fns.length === 0) {
1382
+ return identity;
1383
+ }
1384
+ if (fns.length === 1) {
1385
+ return fns[0];
1386
+ }
1387
+ return function piped(input) {
1388
+ return fns.reduce(function (prev, fn) { return fn(prev); }, input);
1389
+ };
1390
+ }
1391
+
1392
+ var Observable = (function () {
1393
+ function Observable(subscribe) {
1394
+ if (subscribe) {
1395
+ this._subscribe = subscribe;
1396
+ }
1397
+ }
1398
+ Observable.prototype.lift = function (operator) {
1399
+ var observable = new Observable();
1400
+ observable.source = this;
1401
+ observable.operator = operator;
1402
+ return observable;
1403
+ };
1404
+ Observable.prototype.subscribe = function (observerOrNext, error, complete) {
1405
+ var _this = this;
1406
+ var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
1407
+ errorContext(function () {
1408
+ var _a = _this, operator = _a.operator, source = _a.source;
1409
+ subscriber.add(operator
1410
+ ?
1411
+ operator.call(subscriber, source)
1412
+ : source
1413
+ ?
1414
+ _this._subscribe(subscriber)
1415
+ :
1416
+ _this._trySubscribe(subscriber));
1417
+ });
1418
+ return subscriber;
1419
+ };
1420
+ Observable.prototype._trySubscribe = function (sink) {
1421
+ try {
1422
+ return this._subscribe(sink);
1423
+ }
1424
+ catch (err) {
1425
+ sink.error(err);
1426
+ }
1427
+ };
1428
+ Observable.prototype.forEach = function (next, promiseCtor) {
1429
+ var _this = this;
1430
+ promiseCtor = getPromiseCtor(promiseCtor);
1431
+ return new promiseCtor(function (resolve, reject) {
1432
+ var subscription;
1433
+ subscription = _this.subscribe(function (value) {
1434
+ try {
1435
+ next(value);
1436
+ }
1437
+ catch (err) {
1438
+ reject(err);
1439
+ subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
1440
+ }
1441
+ }, reject, resolve);
1442
+ });
1443
+ };
1444
+ Observable.prototype._subscribe = function (subscriber) {
1445
+ var _a;
1446
+ return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
1447
+ };
1448
+ Observable.prototype[observable] = function () {
1449
+ return this;
1450
+ };
1451
+ Observable.prototype.pipe = function () {
1452
+ var operations = [];
1453
+ for (var _i = 0; _i < arguments.length; _i++) {
1454
+ operations[_i] = arguments[_i];
1455
+ }
1456
+ return pipeFromArray(operations)(this);
1457
+ };
1458
+ Observable.prototype.toPromise = function (promiseCtor) {
1459
+ var _this = this;
1460
+ promiseCtor = getPromiseCtor(promiseCtor);
1461
+ return new promiseCtor(function (resolve, reject) {
1462
+ var value;
1463
+ _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
1464
+ });
1465
+ };
1466
+ Observable.create = function (subscribe) {
1467
+ return new Observable(subscribe);
1468
+ };
1469
+ return Observable;
1470
+ }());
1471
+ function getPromiseCtor(promiseCtor) {
1472
+ var _a;
1473
+ return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
1474
+ }
1475
+ function isObserver(value) {
1476
+ return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
1477
+ }
1478
+ function isSubscriber(value) {
1479
+ return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
1480
+ }
1481
+
1482
+ var ObjectUnsubscribedError = createErrorClass(function (_super) {
1483
+ return function ObjectUnsubscribedErrorImpl() {
1484
+ _super(this);
1485
+ this.name = 'ObjectUnsubscribedError';
1486
+ this.message = 'object unsubscribed';
1487
+ };
1488
+ });
1489
+
1490
+ var Subject = (function (_super) {
1491
+ __extends$1(Subject, _super);
1492
+ function Subject() {
1493
+ var _this = _super.call(this) || this;
1494
+ _this.closed = false;
1495
+ _this.observers = [];
1496
+ _this.isStopped = false;
1497
+ _this.hasError = false;
1498
+ _this.thrownError = null;
1499
+ return _this;
1500
+ }
1501
+ Subject.prototype.lift = function (operator) {
1502
+ var subject = new AnonymousSubject(this, this);
1503
+ subject.operator = operator;
1504
+ return subject;
1505
+ };
1506
+ Subject.prototype._throwIfClosed = function () {
1507
+ if (this.closed) {
1508
+ throw new ObjectUnsubscribedError();
1509
+ }
1510
+ };
1511
+ Subject.prototype.next = function (value) {
1512
+ var _this = this;
1513
+ errorContext(function () {
1514
+ var e_1, _a;
1515
+ _this._throwIfClosed();
1516
+ if (!_this.isStopped) {
1517
+ var copy = _this.observers.slice();
1518
+ try {
1519
+ for (var copy_1 = __values(copy), copy_1_1 = copy_1.next(); !copy_1_1.done; copy_1_1 = copy_1.next()) {
1520
+ var observer = copy_1_1.value;
1521
+ observer.next(value);
1522
+ }
1523
+ }
1524
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1525
+ finally {
1526
+ try {
1527
+ if (copy_1_1 && !copy_1_1.done && (_a = copy_1.return)) _a.call(copy_1);
1528
+ }
1529
+ finally { if (e_1) throw e_1.error; }
1530
+ }
1531
+ }
1532
+ });
1533
+ };
1534
+ Subject.prototype.error = function (err) {
1535
+ var _this = this;
1536
+ errorContext(function () {
1537
+ _this._throwIfClosed();
1538
+ if (!_this.isStopped) {
1539
+ _this.hasError = _this.isStopped = true;
1540
+ _this.thrownError = err;
1541
+ var observers = _this.observers;
1542
+ while (observers.length) {
1543
+ observers.shift().error(err);
1544
+ }
1545
+ }
1546
+ });
1547
+ };
1548
+ Subject.prototype.complete = function () {
1549
+ var _this = this;
1550
+ errorContext(function () {
1551
+ _this._throwIfClosed();
1552
+ if (!_this.isStopped) {
1553
+ _this.isStopped = true;
1554
+ var observers = _this.observers;
1555
+ while (observers.length) {
1556
+ observers.shift().complete();
1557
+ }
1558
+ }
1559
+ });
1560
+ };
1561
+ Subject.prototype.unsubscribe = function () {
1562
+ this.isStopped = this.closed = true;
1563
+ this.observers = null;
1564
+ };
1565
+ Object.defineProperty(Subject.prototype, "observed", {
1566
+ get: function () {
1567
+ var _a;
1568
+ return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
1569
+ },
1570
+ enumerable: false,
1571
+ configurable: true
1572
+ });
1573
+ Subject.prototype._trySubscribe = function (subscriber) {
1574
+ this._throwIfClosed();
1575
+ return _super.prototype._trySubscribe.call(this, subscriber);
1576
+ };
1577
+ Subject.prototype._subscribe = function (subscriber) {
1578
+ this._throwIfClosed();
1579
+ this._checkFinalizedStatuses(subscriber);
1580
+ return this._innerSubscribe(subscriber);
1581
+ };
1582
+ Subject.prototype._innerSubscribe = function (subscriber) {
1583
+ var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
1584
+ return hasError || isStopped
1585
+ ? EMPTY_SUBSCRIPTION
1586
+ : (observers.push(subscriber), new Subscription(function () { return arrRemove(observers, subscriber); }));
1587
+ };
1588
+ Subject.prototype._checkFinalizedStatuses = function (subscriber) {
1589
+ var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
1590
+ if (hasError) {
1591
+ subscriber.error(thrownError);
1592
+ }
1593
+ else if (isStopped) {
1594
+ subscriber.complete();
1595
+ }
1596
+ };
1597
+ Subject.prototype.asObservable = function () {
1598
+ var observable = new Observable();
1599
+ observable.source = this;
1600
+ return observable;
1601
+ };
1602
+ Subject.create = function (destination, source) {
1603
+ return new AnonymousSubject(destination, source);
1604
+ };
1605
+ return Subject;
1606
+ }(Observable));
1607
+ var AnonymousSubject = (function (_super) {
1608
+ __extends$1(AnonymousSubject, _super);
1609
+ function AnonymousSubject(destination, source) {
1610
+ var _this = _super.call(this) || this;
1611
+ _this.destination = destination;
1612
+ _this.source = source;
1613
+ return _this;
1614
+ }
1615
+ AnonymousSubject.prototype.next = function (value) {
1616
+ var _a, _b;
1617
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
1618
+ };
1619
+ AnonymousSubject.prototype.error = function (err) {
1620
+ var _a, _b;
1621
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
1622
+ };
1623
+ AnonymousSubject.prototype.complete = function () {
1624
+ var _a, _b;
1625
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
1626
+ };
1627
+ AnonymousSubject.prototype._subscribe = function (subscriber) {
1628
+ var _a, _b;
1629
+ return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
1630
+ };
1631
+ return AnonymousSubject;
1632
+ }(Subject));
1633
+
1634
+ var dateTimestampProvider = {
1635
+ now: function () {
1636
+ return (dateTimestampProvider.delegate || Date).now();
1637
+ },
1638
+ delegate: undefined,
1639
+ };
1640
+
1641
+ var ReplaySubject = (function (_super) {
1642
+ __extends$1(ReplaySubject, _super);
1643
+ function ReplaySubject(_bufferSize, _windowTime, _timestampProvider) {
1644
+ if (_bufferSize === void 0) { _bufferSize = Infinity; }
1645
+ if (_windowTime === void 0) { _windowTime = Infinity; }
1646
+ if (_timestampProvider === void 0) { _timestampProvider = dateTimestampProvider; }
1647
+ var _this = _super.call(this) || this;
1648
+ _this._bufferSize = _bufferSize;
1649
+ _this._windowTime = _windowTime;
1650
+ _this._timestampProvider = _timestampProvider;
1651
+ _this._buffer = [];
1652
+ _this._infiniteTimeWindow = true;
1653
+ _this._infiniteTimeWindow = _windowTime === Infinity;
1654
+ _this._bufferSize = Math.max(1, _bufferSize);
1655
+ _this._windowTime = Math.max(1, _windowTime);
1656
+ return _this;
1657
+ }
1658
+ ReplaySubject.prototype.next = function (value) {
1659
+ var _a = this, isStopped = _a.isStopped, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow, _timestampProvider = _a._timestampProvider, _windowTime = _a._windowTime;
1660
+ if (!isStopped) {
1661
+ _buffer.push(value);
1662
+ !_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);
1663
+ }
1664
+ this._trimBuffer();
1665
+ _super.prototype.next.call(this, value);
1666
+ };
1667
+ ReplaySubject.prototype._subscribe = function (subscriber) {
1668
+ this._throwIfClosed();
1669
+ this._trimBuffer();
1670
+ var subscription = this._innerSubscribe(subscriber);
1671
+ var _a = this, _infiniteTimeWindow = _a._infiniteTimeWindow, _buffer = _a._buffer;
1672
+ var copy = _buffer.slice();
1673
+ for (var i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {
1674
+ subscriber.next(copy[i]);
1675
+ }
1676
+ this._checkFinalizedStatuses(subscriber);
1677
+ return subscription;
1678
+ };
1679
+ ReplaySubject.prototype._trimBuffer = function () {
1680
+ var _a = this, _bufferSize = _a._bufferSize, _timestampProvider = _a._timestampProvider, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow;
1681
+ var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;
1682
+ _bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);
1683
+ if (!_infiniteTimeWindow) {
1684
+ var now = _timestampProvider.now();
1685
+ var last = 0;
1686
+ for (var i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) {
1687
+ last = i;
1688
+ }
1689
+ last && _buffer.splice(0, last + 1);
1690
+ }
1691
+ };
1692
+ return ReplaySubject;
1693
+ }(Subject));
1694
+
1695
+ let topics = [];
1696
+ let subjects = {};
1697
+
1698
+ /**
1699
+ * @name topic
1700
+ * @description A small wrapper over the rxjs to offer the topic method on top of it
1701
+ * @param event [String] Event name
1702
+ * @param step [String] How many values to be buffed for new subscribers - default 0
1703
+ * @returns ReplaySubject
1704
+ */
1705
+
1706
+ const topic = (event, step = 0) => {
1707
+ if (topics.indexOf(event) == -1) {
1708
+ let replaySubject = new ReplaySubject(step);
1709
+
1710
+ subjects[event] = replaySubject;
1711
+
1712
+ topics.push(event);
1713
+ }
1714
+
1715
+ return subjects[event];
1716
+ };
1717
+
1718
+ const subscriber_queue = [];
1719
+ /**
1720
+ * Creates a `Readable` store that allows reading by subscription.
1721
+ * @param value initial value
1722
+ * @param {StartStopNotifier}start start and stop notifications for subscriptions
1723
+ */
1724
+ function readable(value, start) {
1725
+ return {
1726
+ subscribe: writable(value, start).subscribe
1727
+ };
1728
+ }
1729
+ /**
1730
+ * Create a `Writable` store that allows both updating and reading by subscription.
1731
+ * @param {*=}value initial value
1732
+ * @param {StartStopNotifier=}start start and stop notifications for subscriptions
1733
+ */
1734
+ function writable(value, start = noop$1) {
1735
+ let stop;
1736
+ const subscribers = [];
1737
+ function set(new_value) {
1738
+ if (safe_not_equal(value, new_value)) {
1739
+ value = new_value;
1740
+ if (stop) { // store is ready
1741
+ const run_queue = !subscriber_queue.length;
1742
+ for (let i = 0; i < subscribers.length; i += 1) {
1743
+ const s = subscribers[i];
1744
+ s[1]();
1745
+ subscriber_queue.push(s, value);
1746
+ }
1747
+ if (run_queue) {
1748
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
1749
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
1750
+ }
1751
+ subscriber_queue.length = 0;
1752
+ }
1753
+ }
1754
+ }
1755
+ }
1756
+ function update(fn) {
1757
+ set(fn(value));
1758
+ }
1759
+ function subscribe(run, invalidate = noop$1) {
1760
+ const subscriber = [run, invalidate];
1761
+ subscribers.push(subscriber);
1762
+ if (subscribers.length === 1) {
1763
+ stop = start(set) || noop$1;
1764
+ }
1765
+ run(value);
1766
+ return () => {
1767
+ const index = subscribers.indexOf(subscriber);
1768
+ if (index !== -1) {
1769
+ subscribers.splice(index, 1);
1770
+ }
1771
+ if (subscribers.length === 0) {
1772
+ stop();
1773
+ stop = null;
1774
+ }
1775
+ };
1776
+ }
1777
+ return { set, update, subscribe };
1778
+ }
1779
+ function derived(stores, fn, initial_value) {
1780
+ const single = !Array.isArray(stores);
1781
+ const stores_array = single
1782
+ ? [stores]
1783
+ : stores;
1784
+ const auto = fn.length < 2;
1785
+ return readable(initial_value, (set) => {
1786
+ let inited = false;
1787
+ const values = [];
1788
+ let pending = 0;
1789
+ let cleanup = noop$1;
1790
+ const sync = () => {
1791
+ if (pending) {
1792
+ return;
1793
+ }
1794
+ cleanup();
1795
+ const result = fn(single ? values[0] : values, set);
1796
+ if (auto) {
1797
+ set(result);
1798
+ }
1799
+ else {
1800
+ cleanup = is_function(result) ? result : noop$1;
1801
+ }
1802
+ };
1803
+ const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {
1804
+ values[i] = value;
1805
+ pending &= ~(1 << i);
1806
+ if (inited) {
1807
+ sync();
1808
+ }
1809
+ }, () => {
1810
+ pending |= (1 << i);
1811
+ }));
1812
+ inited = true;
1813
+ sync();
1814
+ return function stop() {
1815
+ run_all(unsubscribers);
1816
+ cleanup();
1817
+ };
1818
+ });
1819
+ }
1820
+
1821
+ var isMergeableObject = function isMergeableObject(value) {
1822
+ return isNonNullObject(value)
1823
+ && !isSpecial(value)
1824
+ };
1825
+
1826
+ function isNonNullObject(value) {
1827
+ return !!value && typeof value === 'object'
1828
+ }
1829
+
1830
+ function isSpecial(value) {
1831
+ var stringValue = Object.prototype.toString.call(value);
1832
+
1833
+ return stringValue === '[object RegExp]'
1834
+ || stringValue === '[object Date]'
1835
+ || isReactElement(value)
1836
+ }
1837
+
1838
+ // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
1839
+ var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
1840
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
1841
+
1842
+ function isReactElement(value) {
1843
+ return value.$$typeof === REACT_ELEMENT_TYPE
1844
+ }
1845
+
1846
+ function emptyTarget(val) {
1847
+ return Array.isArray(val) ? [] : {}
1848
+ }
1849
+
1850
+ function cloneUnlessOtherwiseSpecified(value, options) {
1851
+ return (options.clone !== false && options.isMergeableObject(value))
1852
+ ? deepmerge(emptyTarget(value), value, options)
1853
+ : value
1854
+ }
1855
+
1856
+ function defaultArrayMerge(target, source, options) {
1857
+ return target.concat(source).map(function(element) {
1858
+ return cloneUnlessOtherwiseSpecified(element, options)
1859
+ })
1860
+ }
1861
+
1862
+ function getMergeFunction(key, options) {
1863
+ if (!options.customMerge) {
1864
+ return deepmerge
1865
+ }
1866
+ var customMerge = options.customMerge(key);
1867
+ return typeof customMerge === 'function' ? customMerge : deepmerge
1868
+ }
1869
+
1870
+ function getEnumerableOwnPropertySymbols(target) {
1871
+ return Object.getOwnPropertySymbols
1872
+ ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
1873
+ return target.propertyIsEnumerable(symbol)
1874
+ })
1875
+ : []
1876
+ }
1877
+
1878
+ function getKeys(target) {
1879
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
1880
+ }
1881
+
1882
+ function propertyIsOnObject(object, property) {
1883
+ try {
1884
+ return property in object
1885
+ } catch(_) {
1886
+ return false
1887
+ }
1888
+ }
1889
+
1890
+ // Protects from prototype poisoning and unexpected merging up the prototype chain.
1891
+ function propertyIsUnsafe(target, key) {
1892
+ return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
1893
+ && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
1894
+ && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
1895
+ }
1896
+
1897
+ function mergeObject(target, source, options) {
1898
+ var destination = {};
1899
+ if (options.isMergeableObject(target)) {
1900
+ getKeys(target).forEach(function(key) {
1901
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
1902
+ });
1903
+ }
1904
+ getKeys(source).forEach(function(key) {
1905
+ if (propertyIsUnsafe(target, key)) {
1906
+ return
1907
+ }
1908
+
1909
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
1910
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
1911
+ } else {
1912
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
1913
+ }
1914
+ });
1915
+ return destination
1916
+ }
1917
+
1918
+ function deepmerge(target, source, options) {
1919
+ options = options || {};
1920
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
1921
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
1922
+ // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
1923
+ // implementations can use it. The caller may not replace it.
1924
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
1925
+
1926
+ var sourceIsArray = Array.isArray(source);
1927
+ var targetIsArray = Array.isArray(target);
1928
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
1929
+
1930
+ if (!sourceAndTargetTypesMatch) {
1931
+ return cloneUnlessOtherwiseSpecified(source, options)
1932
+ } else if (sourceIsArray) {
1933
+ return options.arrayMerge(target, source, options)
1934
+ } else {
1935
+ return mergeObject(target, source, options)
1936
+ }
1937
+ }
1938
+
1939
+ deepmerge.all = function deepmergeAll(array, options) {
1940
+ if (!Array.isArray(array)) {
1941
+ throw new Error('first argument should be an array')
1942
+ }
1943
+
1944
+ return array.reduce(function(prev, next) {
1945
+ return deepmerge(prev, next, options)
1946
+ }, {})
1947
+ };
1948
+
1949
+ var deepmerge_1 = deepmerge;
1950
+
1951
+ var cjs = deepmerge_1;
1952
+
1953
+ /*! *****************************************************************************
1954
+ Copyright (c) Microsoft Corporation.
1955
+
1956
+ Permission to use, copy, modify, and/or distribute this software for any
1957
+ purpose with or without fee is hereby granted.
1958
+
1959
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1960
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1961
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1962
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1963
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1964
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1965
+ PERFORMANCE OF THIS SOFTWARE.
1966
+ ***************************************************************************** */
1967
+ /* global Reflect, Promise */
1968
+
1969
+ var extendStatics = function(d, b) {
1970
+ extendStatics = Object.setPrototypeOf ||
1971
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1972
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1973
+ return extendStatics(d, b);
1974
+ };
1975
+
1976
+ function __extends(d, b) {
1977
+ if (typeof b !== "function" && b !== null)
1978
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1979
+ extendStatics(d, b);
1980
+ function __() { this.constructor = d; }
1981
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1982
+ }
1983
+
1984
+ var __assign = function() {
1985
+ __assign = Object.assign || function __assign(t) {
1986
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1987
+ s = arguments[i];
1988
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1989
+ }
1990
+ return t;
1991
+ };
1992
+ return __assign.apply(this, arguments);
1993
+ };
1994
+
1995
+ function __spreadArray(to, from) {
1996
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1997
+ to[j] = from[i];
1998
+ return to;
1999
+ }
2000
+
2001
+ var ErrorKind;
2002
+ (function (ErrorKind) {
2003
+ /** Argument is unclosed (e.g. `{0`) */
2004
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
2005
+ /** Argument is empty (e.g. `{}`). */
2006
+ ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
2007
+ /** Argument is malformed (e.g. `{foo!}``) */
2008
+ ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
2009
+ /** Expect an argument type (e.g. `{foo,}`) */
2010
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
2011
+ /** Unsupported argument type (e.g. `{foo,foo}`) */
2012
+ ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
2013
+ /** Expect an argument style (e.g. `{foo, number, }`) */
2014
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
2015
+ /** The number skeleton is invalid. */
2016
+ ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
2017
+ /** The date time skeleton is invalid. */
2018
+ ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
2019
+ /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */
2020
+ ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
2021
+ /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */
2022
+ ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
2023
+ /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */
2024
+ ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
2025
+ /** Missing select argument options (e.g. `{foo, select}`) */
2026
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
2027
+ /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */
2028
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
2029
+ /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */
2030
+ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
2031
+ /** Expecting a selector in `select` argument (e.g `{foo, select}`) */
2032
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
2033
+ /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */
2034
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
2035
+ /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */
2036
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
2037
+ /**
2038
+ * Expecting a message fragment after the `plural` or `selectordinal` selector
2039
+ * (e.g. `{foo, plural, one}`)
2040
+ */
2041
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
2042
+ /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */
2043
+ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
2044
+ /**
2045
+ * Duplicate selectors in `plural` or `selectordinal` argument.
2046
+ * (e.g. {foo, plural, one {#} one {#}})
2047
+ */
2048
+ ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
2049
+ /** Duplicate selectors in `select` argument.
2050
+ * (e.g. {foo, select, apple {apple} apple {apple}})
2051
+ */
2052
+ ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
2053
+ /** Plural or select argument option must have `other` clause. */
2054
+ ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
2055
+ /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */
2056
+ ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG";
2057
+ /** The tag name is invalid. (e.g. `<123>foo</123>`) */
2058
+ ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
2059
+ /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */
2060
+ ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
2061
+ /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */
2062
+ ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
2063
+ })(ErrorKind || (ErrorKind = {}));
2064
+
2065
+ var TYPE;
2066
+ (function (TYPE) {
2067
+ /**
2068
+ * Raw text
2069
+ */
2070
+ TYPE[TYPE["literal"] = 0] = "literal";
2071
+ /**
2072
+ * Variable w/o any format, e.g `var` in `this is a {var}`
2073
+ */
2074
+ TYPE[TYPE["argument"] = 1] = "argument";
2075
+ /**
2076
+ * Variable w/ number format
2077
+ */
2078
+ TYPE[TYPE["number"] = 2] = "number";
2079
+ /**
2080
+ * Variable w/ date format
2081
+ */
2082
+ TYPE[TYPE["date"] = 3] = "date";
2083
+ /**
2084
+ * Variable w/ time format
2085
+ */
2086
+ TYPE[TYPE["time"] = 4] = "time";
2087
+ /**
2088
+ * Variable w/ select format
2089
+ */
2090
+ TYPE[TYPE["select"] = 5] = "select";
2091
+ /**
2092
+ * Variable w/ plural format
2093
+ */
2094
+ TYPE[TYPE["plural"] = 6] = "plural";
2095
+ /**
2096
+ * Only possible within plural argument.
2097
+ * This is the `#` symbol that will be substituted with the count.
2098
+ */
2099
+ TYPE[TYPE["pound"] = 7] = "pound";
2100
+ /**
2101
+ * XML-like tag
2102
+ */
2103
+ TYPE[TYPE["tag"] = 8] = "tag";
2104
+ })(TYPE || (TYPE = {}));
2105
+ var SKELETON_TYPE;
2106
+ (function (SKELETON_TYPE) {
2107
+ SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
2108
+ SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
2109
+ })(SKELETON_TYPE || (SKELETON_TYPE = {}));
2110
+ /**
2111
+ * Type Guards
2112
+ */
2113
+ function isLiteralElement(el) {
2114
+ return el.type === TYPE.literal;
2115
+ }
2116
+ function isArgumentElement(el) {
2117
+ return el.type === TYPE.argument;
2118
+ }
2119
+ function isNumberElement(el) {
2120
+ return el.type === TYPE.number;
2121
+ }
2122
+ function isDateElement(el) {
2123
+ return el.type === TYPE.date;
2124
+ }
2125
+ function isTimeElement(el) {
2126
+ return el.type === TYPE.time;
2127
+ }
2128
+ function isSelectElement(el) {
2129
+ return el.type === TYPE.select;
2130
+ }
2131
+ function isPluralElement(el) {
2132
+ return el.type === TYPE.plural;
2133
+ }
2134
+ function isPoundElement(el) {
2135
+ return el.type === TYPE.pound;
2136
+ }
2137
+ function isTagElement(el) {
2138
+ return el.type === TYPE.tag;
2139
+ }
2140
+ function isNumberSkeleton(el) {
2141
+ return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);
2142
+ }
2143
+ function isDateTimeSkeleton(el) {
2144
+ return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
2145
+ }
2146
+
2147
+ // @generated from regex-gen.ts
2148
+ var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
2149
+
2150
+ /**
2151
+ * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2152
+ * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
2153
+ * with some tweaks
2154
+ */
2155
+ var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
2156
+ /**
2157
+ * Parse Date time skeleton into Intl.DateTimeFormatOptions
2158
+ * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2159
+ * @public
2160
+ * @param skeleton skeleton string
2161
+ */
2162
+ function parseDateTimeSkeleton(skeleton) {
2163
+ var result = {};
2164
+ skeleton.replace(DATE_TIME_REGEX, function (match) {
2165
+ var len = match.length;
2166
+ switch (match[0]) {
2167
+ // Era
2168
+ case 'G':
2169
+ result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
2170
+ break;
2171
+ // Year
2172
+ case 'y':
2173
+ result.year = len === 2 ? '2-digit' : 'numeric';
2174
+ break;
2175
+ case 'Y':
2176
+ case 'u':
2177
+ case 'U':
2178
+ case 'r':
2179
+ throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');
2180
+ // Quarter
2181
+ case 'q':
2182
+ case 'Q':
2183
+ throw new RangeError('`q/Q` (quarter) patterns are not supported');
2184
+ // Month
2185
+ case 'M':
2186
+ case 'L':
2187
+ result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
2188
+ break;
2189
+ // Week
2190
+ case 'w':
2191
+ case 'W':
2192
+ throw new RangeError('`w/W` (week) patterns are not supported');
2193
+ case 'd':
2194
+ result.day = ['numeric', '2-digit'][len - 1];
2195
+ break;
2196
+ case 'D':
2197
+ case 'F':
2198
+ case 'g':
2199
+ throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');
2200
+ // Weekday
2201
+ case 'E':
2202
+ result.weekday = len === 4 ? 'short' : len === 5 ? 'narrow' : 'short';
2203
+ break;
2204
+ case 'e':
2205
+ if (len < 4) {
2206
+ throw new RangeError('`e..eee` (weekday) patterns are not supported');
2207
+ }
2208
+ result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
2209
+ break;
2210
+ case 'c':
2211
+ if (len < 4) {
2212
+ throw new RangeError('`c..ccc` (weekday) patterns are not supported');
2213
+ }
2214
+ result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
2215
+ break;
2216
+ // Period
2217
+ case 'a': // AM, PM
2218
+ result.hour12 = true;
2219
+ break;
2220
+ case 'b': // am, pm, noon, midnight
2221
+ case 'B': // flexible day periods
2222
+ throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');
2223
+ // Hour
2224
+ case 'h':
2225
+ result.hourCycle = 'h12';
2226
+ result.hour = ['numeric', '2-digit'][len - 1];
2227
+ break;
2228
+ case 'H':
2229
+ result.hourCycle = 'h23';
2230
+ result.hour = ['numeric', '2-digit'][len - 1];
2231
+ break;
2232
+ case 'K':
2233
+ result.hourCycle = 'h11';
2234
+ result.hour = ['numeric', '2-digit'][len - 1];
2235
+ break;
2236
+ case 'k':
2237
+ result.hourCycle = 'h24';
2238
+ result.hour = ['numeric', '2-digit'][len - 1];
2239
+ break;
2240
+ case 'j':
2241
+ case 'J':
2242
+ case 'C':
2243
+ throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
2244
+ // Minute
2245
+ case 'm':
2246
+ result.minute = ['numeric', '2-digit'][len - 1];
2247
+ break;
2248
+ // Second
2249
+ case 's':
2250
+ result.second = ['numeric', '2-digit'][len - 1];
2251
+ break;
2252
+ case 'S':
2253
+ case 'A':
2254
+ throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead');
2255
+ // Zone
2256
+ case 'z': // 1..3, 4: specific non-location format
2257
+ result.timeZoneName = len < 4 ? 'short' : 'long';
2258
+ break;
2259
+ case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
2260
+ case 'O': // 1, 4: miliseconds in day short, long
2261
+ case 'v': // 1, 4: generic non-location format
2262
+ case 'V': // 1, 2, 3, 4: time zone ID or city
2263
+ case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
2264
+ case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
2265
+ throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead');
2266
+ }
2267
+ return '';
2268
+ });
2269
+ return result;
2270
+ }
2271
+
2272
+ // @generated from regex-gen.ts
2273
+ var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
2274
+
2275
+ function parseNumberSkeletonFromString(skeleton) {
2276
+ if (skeleton.length === 0) {
2277
+ throw new Error('Number skeleton cannot be empty');
2278
+ }
2279
+ // Parse the skeleton
2280
+ var stringTokens = skeleton
2281
+ .split(WHITE_SPACE_REGEX)
2282
+ .filter(function (x) { return x.length > 0; });
2283
+ var tokens = [];
2284
+ for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
2285
+ var stringToken = stringTokens_1[_i];
2286
+ var stemAndOptions = stringToken.split('/');
2287
+ if (stemAndOptions.length === 0) {
2288
+ throw new Error('Invalid number skeleton');
2289
+ }
2290
+ var stem = stemAndOptions[0], options = stemAndOptions.slice(1);
2291
+ for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
2292
+ var option = options_1[_a];
2293
+ if (option.length === 0) {
2294
+ throw new Error('Invalid number skeleton');
2295
+ }
2296
+ }
2297
+ tokens.push({ stem: stem, options: options });
2298
+ }
2299
+ return tokens;
2300
+ }
2301
+ function icuUnitToEcma(unit) {
2302
+ return unit.replace(/^(.*?)-/, '');
2303
+ }
2304
+ var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
2305
+ var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
2306
+ var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
2307
+ var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
2308
+ function parseSignificantPrecision(str) {
2309
+ var result = {};
2310
+ str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
2311
+ // @@@ case
2312
+ if (typeof g2 !== 'string') {
2313
+ result.minimumSignificantDigits = g1.length;
2314
+ result.maximumSignificantDigits = g1.length;
2315
+ }
2316
+ // @@@+ case
2317
+ else if (g2 === '+') {
2318
+ result.minimumSignificantDigits = g1.length;
2319
+ }
2320
+ // .### case
2321
+ else if (g1[0] === '#') {
2322
+ result.maximumSignificantDigits = g1.length;
2323
+ }
2324
+ // .@@## or .@@@ case
2325
+ else {
2326
+ result.minimumSignificantDigits = g1.length;
2327
+ result.maximumSignificantDigits =
2328
+ g1.length + (typeof g2 === 'string' ? g2.length : 0);
2329
+ }
2330
+ return '';
2331
+ });
2332
+ return result;
2333
+ }
2334
+ function parseSign(str) {
2335
+ switch (str) {
2336
+ case 'sign-auto':
2337
+ return {
2338
+ signDisplay: 'auto',
2339
+ };
2340
+ case 'sign-accounting':
2341
+ case '()':
2342
+ return {
2343
+ currencySign: 'accounting',
2344
+ };
2345
+ case 'sign-always':
2346
+ case '+!':
2347
+ return {
2348
+ signDisplay: 'always',
2349
+ };
2350
+ case 'sign-accounting-always':
2351
+ case '()!':
2352
+ return {
2353
+ signDisplay: 'always',
2354
+ currencySign: 'accounting',
2355
+ };
2356
+ case 'sign-except-zero':
2357
+ case '+?':
2358
+ return {
2359
+ signDisplay: 'exceptZero',
2360
+ };
2361
+ case 'sign-accounting-except-zero':
2362
+ case '()?':
2363
+ return {
2364
+ signDisplay: 'exceptZero',
2365
+ currencySign: 'accounting',
2366
+ };
2367
+ case 'sign-never':
2368
+ case '+_':
2369
+ return {
2370
+ signDisplay: 'never',
2371
+ };
2372
+ }
2373
+ }
2374
+ function parseConciseScientificAndEngineeringStem(stem) {
2375
+ // Engineering
2376
+ var result;
2377
+ if (stem[0] === 'E' && stem[1] === 'E') {
2378
+ result = {
2379
+ notation: 'engineering',
2380
+ };
2381
+ stem = stem.slice(2);
2382
+ }
2383
+ else if (stem[0] === 'E') {
2384
+ result = {
2385
+ notation: 'scientific',
2386
+ };
2387
+ stem = stem.slice(1);
2388
+ }
2389
+ if (result) {
2390
+ var signDisplay = stem.slice(0, 2);
2391
+ if (signDisplay === '+!') {
2392
+ result.signDisplay = 'always';
2393
+ stem = stem.slice(2);
2394
+ }
2395
+ else if (signDisplay === '+?') {
2396
+ result.signDisplay = 'exceptZero';
2397
+ stem = stem.slice(2);
2398
+ }
2399
+ if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
2400
+ throw new Error('Malformed concise eng/scientific notation');
2401
+ }
2402
+ result.minimumIntegerDigits = stem.length;
2403
+ }
2404
+ return result;
2405
+ }
2406
+ function parseNotationOptions(opt) {
2407
+ var result = {};
2408
+ var signOpts = parseSign(opt);
2409
+ if (signOpts) {
2410
+ return signOpts;
2411
+ }
2412
+ return result;
2413
+ }
2414
+ /**
2415
+ * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
2416
+ */
2417
+ function parseNumberSkeleton(tokens) {
2418
+ var result = {};
2419
+ for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
2420
+ var token = tokens_1[_i];
2421
+ switch (token.stem) {
2422
+ case 'percent':
2423
+ case '%':
2424
+ result.style = 'percent';
2425
+ continue;
2426
+ case '%x100':
2427
+ result.style = 'percent';
2428
+ result.scale = 100;
2429
+ continue;
2430
+ case 'currency':
2431
+ result.style = 'currency';
2432
+ result.currency = token.options[0];
2433
+ continue;
2434
+ case 'group-off':
2435
+ case ',_':
2436
+ result.useGrouping = false;
2437
+ continue;
2438
+ case 'precision-integer':
2439
+ case '.':
2440
+ result.maximumFractionDigits = 0;
2441
+ continue;
2442
+ case 'measure-unit':
2443
+ case 'unit':
2444
+ result.style = 'unit';
2445
+ result.unit = icuUnitToEcma(token.options[0]);
2446
+ continue;
2447
+ case 'compact-short':
2448
+ case 'K':
2449
+ result.notation = 'compact';
2450
+ result.compactDisplay = 'short';
2451
+ continue;
2452
+ case 'compact-long':
2453
+ case 'KK':
2454
+ result.notation = 'compact';
2455
+ result.compactDisplay = 'long';
2456
+ continue;
2457
+ case 'scientific':
2458
+ result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
2459
+ continue;
2460
+ case 'engineering':
2461
+ result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
2462
+ continue;
2463
+ case 'notation-simple':
2464
+ result.notation = 'standard';
2465
+ continue;
2466
+ // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
2467
+ case 'unit-width-narrow':
2468
+ result.currencyDisplay = 'narrowSymbol';
2469
+ result.unitDisplay = 'narrow';
2470
+ continue;
2471
+ case 'unit-width-short':
2472
+ result.currencyDisplay = 'code';
2473
+ result.unitDisplay = 'short';
2474
+ continue;
2475
+ case 'unit-width-full-name':
2476
+ result.currencyDisplay = 'name';
2477
+ result.unitDisplay = 'long';
2478
+ continue;
2479
+ case 'unit-width-iso-code':
2480
+ result.currencyDisplay = 'symbol';
2481
+ continue;
2482
+ case 'scale':
2483
+ result.scale = parseFloat(token.options[0]);
2484
+ continue;
2485
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
2486
+ case 'integer-width':
2487
+ if (token.options.length > 1) {
2488
+ throw new RangeError('integer-width stems only accept a single optional option');
2489
+ }
2490
+ token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) {
2491
+ if (g1) {
2492
+ result.minimumIntegerDigits = g2.length;
2493
+ }
2494
+ else if (g3 && g4) {
2495
+ throw new Error('We currently do not support maximum integer digits');
2496
+ }
2497
+ else if (g5) {
2498
+ throw new Error('We currently do not support exact integer digits');
2499
+ }
2500
+ return '';
2501
+ });
2502
+ continue;
2503
+ }
2504
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
2505
+ if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
2506
+ result.minimumIntegerDigits = token.stem.length;
2507
+ continue;
2508
+ }
2509
+ if (FRACTION_PRECISION_REGEX.test(token.stem)) {
2510
+ // Precision
2511
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision
2512
+ // precision-integer case
2513
+ if (token.options.length > 1) {
2514
+ throw new RangeError('Fraction-precision stems only accept a single optional option');
2515
+ }
2516
+ token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {
2517
+ // .000* case (before ICU67 it was .000+)
2518
+ if (g2 === '*') {
2519
+ result.minimumFractionDigits = g1.length;
2520
+ }
2521
+ // .### case
2522
+ else if (g3 && g3[0] === '#') {
2523
+ result.maximumFractionDigits = g3.length;
2524
+ }
2525
+ // .00## case
2526
+ else if (g4 && g5) {
2527
+ result.minimumFractionDigits = g4.length;
2528
+ result.maximumFractionDigits = g4.length + g5.length;
2529
+ }
2530
+ else {
2531
+ result.minimumFractionDigits = g1.length;
2532
+ result.maximumFractionDigits = g1.length;
2533
+ }
2534
+ return '';
2535
+ });
2536
+ if (token.options.length) {
2537
+ result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
2538
+ }
2539
+ continue;
2540
+ }
2541
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision
2542
+ if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
2543
+ result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
2544
+ continue;
2545
+ }
2546
+ var signOpts = parseSign(token.stem);
2547
+ if (signOpts) {
2548
+ result = __assign(__assign({}, result), signOpts);
2549
+ }
2550
+ var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
2551
+ if (conciseScientificAndEngineeringOpts) {
2552
+ result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);
2553
+ }
2554
+ }
2555
+ return result;
2556
+ }
2557
+
2558
+ var _a;
2559
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
2560
+ var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
2561
+ function createLocation(start, end) {
2562
+ return { start: start, end: end };
2563
+ }
2564
+ // #region Ponyfills
2565
+ // Consolidate these variables up top for easier toggling during debugging
2566
+ var hasNativeStartsWith = !!String.prototype.startsWith;
2567
+ var hasNativeFromCodePoint = !!String.fromCodePoint;
2568
+ var hasNativeFromEntries = !!Object.fromEntries;
2569
+ var hasNativeCodePointAt = !!String.prototype.codePointAt;
2570
+ var hasTrimStart = !!String.prototype.trimStart;
2571
+ var hasTrimEnd = !!String.prototype.trimEnd;
2572
+ var hasNativeIsSafeInteger = !!Number.isSafeInteger;
2573
+ var isSafeInteger = hasNativeIsSafeInteger
2574
+ ? Number.isSafeInteger
2575
+ : function (n) {
2576
+ return (typeof n === 'number' &&
2577
+ isFinite(n) &&
2578
+ Math.floor(n) === n &&
2579
+ Math.abs(n) <= 0x1fffffffffffff);
2580
+ };
2581
+ // IE11 does not support y and u.
2582
+ var REGEX_SUPPORTS_U_AND_Y = true;
2583
+ try {
2584
+ var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
2585
+ /**
2586
+ * legacy Edge or Xbox One browser
2587
+ * Unicode flag support: supported
2588
+ * Pattern_Syntax support: not supported
2589
+ * See https://github.com/formatjs/formatjs/issues/2822
2590
+ */
2591
+ REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
2592
+ }
2593
+ catch (_) {
2594
+ REGEX_SUPPORTS_U_AND_Y = false;
2595
+ }
2596
+ var startsWith = hasNativeStartsWith
2597
+ ? // Native
2598
+ function startsWith(s, search, position) {
2599
+ return s.startsWith(search, position);
2600
+ }
2601
+ : // For IE11
2602
+ function startsWith(s, search, position) {
2603
+ return s.slice(position, position + search.length) === search;
2604
+ };
2605
+ var fromCodePoint = hasNativeFromCodePoint
2606
+ ? String.fromCodePoint
2607
+ : // IE11
2608
+ function fromCodePoint() {
2609
+ var codePoints = [];
2610
+ for (var _i = 0; _i < arguments.length; _i++) {
2611
+ codePoints[_i] = arguments[_i];
2612
+ }
2613
+ var elements = '';
2614
+ var length = codePoints.length;
2615
+ var i = 0;
2616
+ var code;
2617
+ while (length > i) {
2618
+ code = codePoints[i++];
2619
+ if (code > 0x10ffff)
2620
+ throw RangeError(code + ' is not a valid code point');
2621
+ elements +=
2622
+ code < 0x10000
2623
+ ? String.fromCharCode(code)
2624
+ : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
2625
+ }
2626
+ return elements;
2627
+ };
2628
+ var fromEntries =
2629
+ // native
2630
+ hasNativeFromEntries
2631
+ ? Object.fromEntries
2632
+ : // Ponyfill
2633
+ function fromEntries(entries) {
2634
+ var obj = {};
2635
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
2636
+ var _a = entries_1[_i], k = _a[0], v = _a[1];
2637
+ obj[k] = v;
2638
+ }
2639
+ return obj;
2640
+ };
2641
+ var codePointAt = hasNativeCodePointAt
2642
+ ? // Native
2643
+ function codePointAt(s, index) {
2644
+ return s.codePointAt(index);
2645
+ }
2646
+ : // IE 11
2647
+ function codePointAt(s, index) {
2648
+ var size = s.length;
2649
+ if (index < 0 || index >= size) {
2650
+ return undefined;
2651
+ }
2652
+ var first = s.charCodeAt(index);
2653
+ var second;
2654
+ return first < 0xd800 ||
2655
+ first > 0xdbff ||
2656
+ index + 1 === size ||
2657
+ (second = s.charCodeAt(index + 1)) < 0xdc00 ||
2658
+ second > 0xdfff
2659
+ ? first
2660
+ : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
2661
+ };
2662
+ var trimStart = hasTrimStart
2663
+ ? // Native
2664
+ function trimStart(s) {
2665
+ return s.trimStart();
2666
+ }
2667
+ : // Ponyfill
2668
+ function trimStart(s) {
2669
+ return s.replace(SPACE_SEPARATOR_START_REGEX, '');
2670
+ };
2671
+ var trimEnd = hasTrimEnd
2672
+ ? // Native
2673
+ function trimEnd(s) {
2674
+ return s.trimEnd();
2675
+ }
2676
+ : // Ponyfill
2677
+ function trimEnd(s) {
2678
+ return s.replace(SPACE_SEPARATOR_END_REGEX, '');
2679
+ };
2680
+ // Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
2681
+ function RE(s, flag) {
2682
+ return new RegExp(s, flag);
2683
+ }
2684
+ // #endregion
2685
+ var matchIdentifierAtIndex;
2686
+ if (REGEX_SUPPORTS_U_AND_Y) {
2687
+ // Native
2688
+ var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
2689
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
2690
+ var _a;
2691
+ IDENTIFIER_PREFIX_RE_1.lastIndex = index;
2692
+ var match = IDENTIFIER_PREFIX_RE_1.exec(s);
2693
+ return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
2694
+ };
2695
+ }
2696
+ else {
2697
+ // IE11
2698
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
2699
+ var match = [];
2700
+ while (true) {
2701
+ var c = codePointAt(s, index);
2702
+ if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
2703
+ break;
2704
+ }
2705
+ match.push(c);
2706
+ index += c >= 0x10000 ? 2 : 1;
2707
+ }
2708
+ return fromCodePoint.apply(void 0, match);
2709
+ };
2710
+ }
2711
+ var Parser = /** @class */ (function () {
2712
+ function Parser(message, options) {
2713
+ if (options === void 0) { options = {}; }
2714
+ this.message = message;
2715
+ this.position = { offset: 0, line: 1, column: 1 };
2716
+ this.ignoreTag = !!options.ignoreTag;
2717
+ this.requiresOtherClause = !!options.requiresOtherClause;
2718
+ this.shouldParseSkeletons = !!options.shouldParseSkeletons;
2719
+ }
2720
+ Parser.prototype.parse = function () {
2721
+ if (this.offset() !== 0) {
2722
+ throw Error('parser can only be used once');
2723
+ }
2724
+ return this.parseMessage(0, '', false);
2725
+ };
2726
+ Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
2727
+ var elements = [];
2728
+ while (!this.isEOF()) {
2729
+ var char = this.char();
2730
+ if (char === 123 /* `{` */) {
2731
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
2732
+ if (result.err) {
2733
+ return result;
2734
+ }
2735
+ elements.push(result.val);
2736
+ }
2737
+ else if (char === 125 /* `}` */ && nestingLevel > 0) {
2738
+ break;
2739
+ }
2740
+ else if (char === 35 /* `#` */ &&
2741
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) {
2742
+ var position = this.clonePosition();
2743
+ this.bump();
2744
+ elements.push({
2745
+ type: TYPE.pound,
2746
+ location: createLocation(position, this.clonePosition()),
2747
+ });
2748
+ }
2749
+ else if (char === 60 /* `<` */ &&
2750
+ !this.ignoreTag &&
2751
+ this.peek() === 47 // char code for '/'
2752
+ ) {
2753
+ if (expectingCloseTag) {
2754
+ break;
2755
+ }
2756
+ else {
2757
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
2758
+ }
2759
+ }
2760
+ else if (char === 60 /* `<` */ &&
2761
+ !this.ignoreTag &&
2762
+ _isAlpha(this.peek() || 0)) {
2763
+ var result = this.parseTag(nestingLevel, parentArgType);
2764
+ if (result.err) {
2765
+ return result;
2766
+ }
2767
+ elements.push(result.val);
2768
+ }
2769
+ else {
2770
+ var result = this.parseLiteral(nestingLevel, parentArgType);
2771
+ if (result.err) {
2772
+ return result;
2773
+ }
2774
+ elements.push(result.val);
2775
+ }
2776
+ }
2777
+ return { val: elements, err: null };
2778
+ };
2779
+ /**
2780
+ * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
2781
+ * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
2782
+ * are accepted:
2783
+ *
2784
+ * ```
2785
+ * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
2786
+ * tagName ::= [a-z] (PENChar)*
2787
+ * PENChar ::=
2788
+ * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
2789
+ * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
2790
+ * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
2791
+ * ```
2792
+ *
2793
+ * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
2794
+ * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
2795
+ * since other tag-based engines like React allow it
2796
+ */
2797
+ Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
2798
+ var startPosition = this.clonePosition();
2799
+ this.bump(); // `<`
2800
+ var tagName = this.parseTagName();
2801
+ this.bumpSpace();
2802
+ if (this.bumpIf('/>')) {
2803
+ // Self closing tag
2804
+ return {
2805
+ val: {
2806
+ type: TYPE.literal,
2807
+ value: "<" + tagName + "/>",
2808
+ location: createLocation(startPosition, this.clonePosition()),
2809
+ },
2810
+ err: null,
2811
+ };
2812
+ }
2813
+ else if (this.bumpIf('>')) {
2814
+ var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
2815
+ if (childrenResult.err) {
2816
+ return childrenResult;
2817
+ }
2818
+ var children = childrenResult.val;
2819
+ // Expecting a close tag
2820
+ var endTagStartPosition = this.clonePosition();
2821
+ if (this.bumpIf('</')) {
2822
+ if (this.isEOF() || !_isAlpha(this.char())) {
2823
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
2824
+ }
2825
+ var closingTagNameStartPosition = this.clonePosition();
2826
+ var closingTagName = this.parseTagName();
2827
+ if (tagName !== closingTagName) {
2828
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
2829
+ }
2830
+ this.bumpSpace();
2831
+ if (!this.bumpIf('>')) {
2832
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
2833
+ }
2834
+ return {
2835
+ val: {
2836
+ type: TYPE.tag,
2837
+ value: tagName,
2838
+ children: children,
2839
+ location: createLocation(startPosition, this.clonePosition()),
2840
+ },
2841
+ err: null,
2842
+ };
2843
+ }
2844
+ else {
2845
+ return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
2846
+ }
2847
+ }
2848
+ else {
2849
+ return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
2850
+ }
2851
+ };
2852
+ /**
2853
+ * This method assumes that the caller has peeked ahead for the first tag character.
2854
+ */
2855
+ Parser.prototype.parseTagName = function () {
2856
+ var startOffset = this.offset();
2857
+ this.bump(); // the first tag name character
2858
+ while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
2859
+ this.bump();
2860
+ }
2861
+ return this.message.slice(startOffset, this.offset());
2862
+ };
2863
+ Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
2864
+ var start = this.clonePosition();
2865
+ var value = '';
2866
+ while (true) {
2867
+ var parseQuoteResult = this.tryParseQuote(parentArgType);
2868
+ if (parseQuoteResult) {
2869
+ value += parseQuoteResult;
2870
+ continue;
2871
+ }
2872
+ var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
2873
+ if (parseUnquotedResult) {
2874
+ value += parseUnquotedResult;
2875
+ continue;
2876
+ }
2877
+ var parseLeftAngleResult = this.tryParseLeftAngleBracket();
2878
+ if (parseLeftAngleResult) {
2879
+ value += parseLeftAngleResult;
2880
+ continue;
2881
+ }
2882
+ break;
2883
+ }
2884
+ var location = createLocation(start, this.clonePosition());
2885
+ return {
2886
+ val: { type: TYPE.literal, value: value, location: location },
2887
+ err: null,
2888
+ };
2889
+ };
2890
+ Parser.prototype.tryParseLeftAngleBracket = function () {
2891
+ if (!this.isEOF() &&
2892
+ this.char() === 60 /* `<` */ &&
2893
+ (this.ignoreTag ||
2894
+ // If at the opening tag or closing tag position, bail.
2895
+ !_isAlphaOrSlash(this.peek() || 0))) {
2896
+ this.bump(); // `<`
2897
+ return '<';
2898
+ }
2899
+ return null;
2900
+ };
2901
+ /**
2902
+ * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
2903
+ * a character that requires quoting (that is, "only where needed"), and works the same in
2904
+ * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
2905
+ */
2906
+ Parser.prototype.tryParseQuote = function (parentArgType) {
2907
+ if (this.isEOF() || this.char() !== 39 /* `'` */) {
2908
+ return null;
2909
+ }
2910
+ // Parse escaped char following the apostrophe, or early return if there is no escaped char.
2911
+ // Check if is valid escaped character
2912
+ switch (this.peek()) {
2913
+ case 39 /* `'` */:
2914
+ // double quote, should return as a single quote.
2915
+ this.bump();
2916
+ this.bump();
2917
+ return "'";
2918
+ // '{', '<', '>', '}'
2919
+ case 123:
2920
+ case 60:
2921
+ case 62:
2922
+ case 125:
2923
+ break;
2924
+ case 35: // '#'
2925
+ if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
2926
+ break;
2927
+ }
2928
+ return null;
2929
+ default:
2930
+ return null;
2931
+ }
2932
+ this.bump(); // apostrophe
2933
+ var codePoints = [this.char()]; // escaped char
2934
+ this.bump();
2935
+ // read chars until the optional closing apostrophe is found
2936
+ while (!this.isEOF()) {
2937
+ var ch = this.char();
2938
+ if (ch === 39 /* `'` */) {
2939
+ if (this.peek() === 39 /* `'` */) {
2940
+ codePoints.push(39);
2941
+ // Bump one more time because we need to skip 2 characters.
2942
+ this.bump();
2943
+ }
2944
+ else {
2945
+ // Optional closing apostrophe.
2946
+ this.bump();
2947
+ break;
2948
+ }
2949
+ }
2950
+ else {
2951
+ codePoints.push(ch);
2952
+ }
2953
+ this.bump();
2954
+ }
2955
+ return fromCodePoint.apply(void 0, codePoints);
2956
+ };
2957
+ Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
2958
+ if (this.isEOF()) {
2959
+ return null;
2960
+ }
2961
+ var ch = this.char();
2962
+ if (ch === 60 /* `<` */ ||
2963
+ ch === 123 /* `{` */ ||
2964
+ (ch === 35 /* `#` */ &&
2965
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
2966
+ (ch === 125 /* `}` */ && nestingLevel > 0)) {
2967
+ return null;
2968
+ }
2969
+ else {
2970
+ this.bump();
2971
+ return fromCodePoint(ch);
2972
+ }
2973
+ };
2974
+ Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
2975
+ var openingBracePosition = this.clonePosition();
2976
+ this.bump(); // `{`
2977
+ this.bumpSpace();
2978
+ if (this.isEOF()) {
2979
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2980
+ }
2981
+ if (this.char() === 125 /* `}` */) {
2982
+ this.bump();
2983
+ return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2984
+ }
2985
+ // argument name
2986
+ var value = this.parseIdentifierIfPossible().value;
2987
+ if (!value) {
2988
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
2989
+ }
2990
+ this.bumpSpace();
2991
+ if (this.isEOF()) {
2992
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
2993
+ }
2994
+ switch (this.char()) {
2995
+ // Simple argument: `{name}`
2996
+ case 125 /* `}` */: {
2997
+ this.bump(); // `}`
2998
+ return {
2999
+ val: {
3000
+ type: TYPE.argument,
3001
+ // value does not include the opening and closing braces.
3002
+ value: value,
3003
+ location: createLocation(openingBracePosition, this.clonePosition()),
3004
+ },
3005
+ err: null,
3006
+ };
3007
+ }
3008
+ // Argument with options: `{name, format, ...}`
3009
+ case 44 /* `,` */: {
3010
+ this.bump(); // `,`
3011
+ this.bumpSpace();
3012
+ if (this.isEOF()) {
3013
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
3014
+ }
3015
+ return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
3016
+ }
3017
+ default:
3018
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
3019
+ }
3020
+ };
3021
+ /**
3022
+ * Advance the parser until the end of the identifier, if it is currently on
3023
+ * an identifier character. Return an empty string otherwise.
3024
+ */
3025
+ Parser.prototype.parseIdentifierIfPossible = function () {
3026
+ var startingPosition = this.clonePosition();
3027
+ var startOffset = this.offset();
3028
+ var value = matchIdentifierAtIndex(this.message, startOffset);
3029
+ var endOffset = startOffset + value.length;
3030
+ this.bumpTo(endOffset);
3031
+ var endPosition = this.clonePosition();
3032
+ var location = createLocation(startingPosition, endPosition);
3033
+ return { value: value, location: location };
3034
+ };
3035
+ Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
3036
+ var _a;
3037
+ // Parse this range:
3038
+ // {name, type, style}
3039
+ // ^---^
3040
+ var typeStartPosition = this.clonePosition();
3041
+ var argType = this.parseIdentifierIfPossible().value;
3042
+ var typeEndPosition = this.clonePosition();
3043
+ switch (argType) {
3044
+ case '':
3045
+ // Expecting a style string number, date, time, plural, selectordinal, or select.
3046
+ return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
3047
+ case 'number':
3048
+ case 'date':
3049
+ case 'time': {
3050
+ // Parse this range:
3051
+ // {name, number, style}
3052
+ // ^-------^
3053
+ this.bumpSpace();
3054
+ var styleAndLocation = null;
3055
+ if (this.bumpIf(',')) {
3056
+ this.bumpSpace();
3057
+ var styleStartPosition = this.clonePosition();
3058
+ var result = this.parseSimpleArgStyleIfPossible();
3059
+ if (result.err) {
3060
+ return result;
3061
+ }
3062
+ var style = trimEnd(result.val);
3063
+ if (style.length === 0) {
3064
+ return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
3065
+ }
3066
+ var styleLocation = createLocation(styleStartPosition, this.clonePosition());
3067
+ styleAndLocation = { style: style, styleLocation: styleLocation };
3068
+ }
3069
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3070
+ if (argCloseResult.err) {
3071
+ return argCloseResult;
3072
+ }
3073
+ var location_1 = createLocation(openingBracePosition, this.clonePosition());
3074
+ // Extract style or skeleton
3075
+ if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
3076
+ // Skeleton starts with `::`.
3077
+ var skeleton = trimStart(styleAndLocation.style.slice(2));
3078
+ if (argType === 'number') {
3079
+ var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
3080
+ if (result.err) {
3081
+ return result;
3082
+ }
3083
+ return {
3084
+ val: { type: TYPE.number, value: value, location: location_1, style: result.val },
3085
+ err: null,
3086
+ };
3087
+ }
3088
+ else {
3089
+ if (skeleton.length === 0) {
3090
+ return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
3091
+ }
3092
+ var style = {
3093
+ type: SKELETON_TYPE.dateTime,
3094
+ pattern: skeleton,
3095
+ location: styleAndLocation.styleLocation,
3096
+ parsedOptions: this.shouldParseSkeletons
3097
+ ? parseDateTimeSkeleton(skeleton)
3098
+ : {},
3099
+ };
3100
+ var type = argType === 'date' ? TYPE.date : TYPE.time;
3101
+ return {
3102
+ val: { type: type, value: value, location: location_1, style: style },
3103
+ err: null,
3104
+ };
3105
+ }
3106
+ }
3107
+ // Regular style or no style.
3108
+ return {
3109
+ val: {
3110
+ type: argType === 'number'
3111
+ ? TYPE.number
3112
+ : argType === 'date'
3113
+ ? TYPE.date
3114
+ : TYPE.time,
3115
+ value: value,
3116
+ location: location_1,
3117
+ style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
3118
+ },
3119
+ err: null,
3120
+ };
3121
+ }
3122
+ case 'plural':
3123
+ case 'selectordinal':
3124
+ case 'select': {
3125
+ // Parse this range:
3126
+ // {name, plural, options}
3127
+ // ^---------^
3128
+ var typeEndPosition_1 = this.clonePosition();
3129
+ this.bumpSpace();
3130
+ if (!this.bumpIf(',')) {
3131
+ return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
3132
+ }
3133
+ this.bumpSpace();
3134
+ // Parse offset:
3135
+ // {name, plural, offset:1, options}
3136
+ // ^-----^
3137
+ //
3138
+ // or the first option:
3139
+ //
3140
+ // {name, plural, one {...} other {...}}
3141
+ // ^--^
3142
+ var identifierAndLocation = this.parseIdentifierIfPossible();
3143
+ var pluralOffset = 0;
3144
+ if (argType !== 'select' && identifierAndLocation.value === 'offset') {
3145
+ if (!this.bumpIf(':')) {
3146
+ return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
3147
+ }
3148
+ this.bumpSpace();
3149
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
3150
+ if (result.err) {
3151
+ return result;
3152
+ }
3153
+ // Parse another identifier for option parsing
3154
+ this.bumpSpace();
3155
+ identifierAndLocation = this.parseIdentifierIfPossible();
3156
+ pluralOffset = result.val;
3157
+ }
3158
+ var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
3159
+ if (optionsResult.err) {
3160
+ return optionsResult;
3161
+ }
3162
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3163
+ if (argCloseResult.err) {
3164
+ return argCloseResult;
3165
+ }
3166
+ var location_2 = createLocation(openingBracePosition, this.clonePosition());
3167
+ if (argType === 'select') {
3168
+ return {
3169
+ val: {
3170
+ type: TYPE.select,
3171
+ value: value,
3172
+ options: fromEntries(optionsResult.val),
3173
+ location: location_2,
3174
+ },
3175
+ err: null,
3176
+ };
3177
+ }
3178
+ else {
3179
+ return {
3180
+ val: {
3181
+ type: TYPE.plural,
3182
+ value: value,
3183
+ options: fromEntries(optionsResult.val),
3184
+ offset: pluralOffset,
3185
+ pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
3186
+ location: location_2,
3187
+ },
3188
+ err: null,
3189
+ };
3190
+ }
3191
+ }
3192
+ default:
3193
+ return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
3194
+ }
3195
+ };
3196
+ Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
3197
+ // Parse: {value, number, ::currency/GBP }
3198
+ //
3199
+ if (this.isEOF() || this.char() !== 125 /* `}` */) {
3200
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
3201
+ }
3202
+ this.bump(); // `}`
3203
+ return { val: true, err: null };
3204
+ };
3205
+ /**
3206
+ * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
3207
+ */
3208
+ Parser.prototype.parseSimpleArgStyleIfPossible = function () {
3209
+ var nestedBraces = 0;
3210
+ var startPosition = this.clonePosition();
3211
+ while (!this.isEOF()) {
3212
+ var ch = this.char();
3213
+ switch (ch) {
3214
+ case 39 /* `'` */: {
3215
+ // Treat apostrophe as quoting but include it in the style part.
3216
+ // Find the end of the quoted literal text.
3217
+ this.bump();
3218
+ var apostrophePosition = this.clonePosition();
3219
+ if (!this.bumpUntil("'")) {
3220
+ return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
3221
+ }
3222
+ this.bump();
3223
+ break;
3224
+ }
3225
+ case 123 /* `{` */: {
3226
+ nestedBraces += 1;
3227
+ this.bump();
3228
+ break;
3229
+ }
3230
+ case 125 /* `}` */: {
3231
+ if (nestedBraces > 0) {
3232
+ nestedBraces -= 1;
3233
+ }
3234
+ else {
3235
+ return {
3236
+ val: this.message.slice(startPosition.offset, this.offset()),
3237
+ err: null,
3238
+ };
3239
+ }
3240
+ break;
3241
+ }
3242
+ default:
3243
+ this.bump();
3244
+ break;
3245
+ }
3246
+ }
3247
+ return {
3248
+ val: this.message.slice(startPosition.offset, this.offset()),
3249
+ err: null,
3250
+ };
3251
+ };
3252
+ Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
3253
+ var tokens = [];
3254
+ try {
3255
+ tokens = parseNumberSkeletonFromString(skeleton);
3256
+ }
3257
+ catch (e) {
3258
+ return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
3259
+ }
3260
+ return {
3261
+ val: {
3262
+ type: SKELETON_TYPE.number,
3263
+ tokens: tokens,
3264
+ location: location,
3265
+ parsedOptions: this.shouldParseSkeletons
3266
+ ? parseNumberSkeleton(tokens)
3267
+ : {},
3268
+ },
3269
+ err: null,
3270
+ };
3271
+ };
3272
+ /**
3273
+ * @param nesting_level The current nesting level of messages.
3274
+ * This can be positive when parsing message fragment in select or plural argument options.
3275
+ * @param parent_arg_type The parent argument's type.
3276
+ * @param parsed_first_identifier If provided, this is the first identifier-like selector of
3277
+ * the argument. It is a by-product of a previous parsing attempt.
3278
+ * @param expecting_close_tag If true, this message is directly or indirectly nested inside
3279
+ * between a pair of opening and closing tags. The nested message will not parse beyond
3280
+ * the closing tag boundary.
3281
+ */
3282
+ Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
3283
+ var _a;
3284
+ var hasOtherClause = false;
3285
+ var options = [];
3286
+ var parsedSelectors = new Set();
3287
+ var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
3288
+ // Parse:
3289
+ // one {one apple}
3290
+ // ^--^
3291
+ while (true) {
3292
+ if (selector.length === 0) {
3293
+ var startPosition = this.clonePosition();
3294
+ if (parentArgType !== 'select' && this.bumpIf('=')) {
3295
+ // Try parse `={number}` selector
3296
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
3297
+ if (result.err) {
3298
+ return result;
3299
+ }
3300
+ selectorLocation = createLocation(startPosition, this.clonePosition());
3301
+ selector = this.message.slice(startPosition.offset, this.offset());
3302
+ }
3303
+ else {
3304
+ break;
3305
+ }
3306
+ }
3307
+ // Duplicate selector clauses
3308
+ if (parsedSelectors.has(selector)) {
3309
+ return this.error(parentArgType === 'select'
3310
+ ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
3311
+ : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
3312
+ }
3313
+ if (selector === 'other') {
3314
+ hasOtherClause = true;
3315
+ }
3316
+ // Parse:
3317
+ // one {one apple}
3318
+ // ^----------^
3319
+ this.bumpSpace();
3320
+ var openingBracePosition = this.clonePosition();
3321
+ if (!this.bumpIf('{')) {
3322
+ return this.error(parentArgType === 'select'
3323
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
3324
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
3325
+ }
3326
+ var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
3327
+ if (fragmentResult.err) {
3328
+ return fragmentResult;
3329
+ }
3330
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
3331
+ if (argCloseResult.err) {
3332
+ return argCloseResult;
3333
+ }
3334
+ options.push([
3335
+ selector,
3336
+ {
3337
+ value: fragmentResult.val,
3338
+ location: createLocation(openingBracePosition, this.clonePosition()),
3339
+ },
3340
+ ]);
3341
+ // Keep track of the existing selectors
3342
+ parsedSelectors.add(selector);
3343
+ // Prep next selector clause.
3344
+ this.bumpSpace();
3345
+ (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
3346
+ }
3347
+ if (options.length === 0) {
3348
+ return this.error(parentArgType === 'select'
3349
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
3350
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
3351
+ }
3352
+ if (this.requiresOtherClause && !hasOtherClause) {
3353
+ return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
3354
+ }
3355
+ return { val: options, err: null };
3356
+ };
3357
+ Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
3358
+ var sign = 1;
3359
+ var startingPosition = this.clonePosition();
3360
+ if (this.bumpIf('+')) ;
3361
+ else if (this.bumpIf('-')) {
3362
+ sign = -1;
3363
+ }
3364
+ var hasDigits = false;
3365
+ var decimal = 0;
3366
+ while (!this.isEOF()) {
3367
+ var ch = this.char();
3368
+ if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
3369
+ hasDigits = true;
3370
+ decimal = decimal * 10 + (ch - 48);
3371
+ this.bump();
3372
+ }
3373
+ else {
3374
+ break;
3375
+ }
3376
+ }
3377
+ var location = createLocation(startingPosition, this.clonePosition());
3378
+ if (!hasDigits) {
3379
+ return this.error(expectNumberError, location);
3380
+ }
3381
+ decimal *= sign;
3382
+ if (!isSafeInteger(decimal)) {
3383
+ return this.error(invalidNumberError, location);
3384
+ }
3385
+ return { val: decimal, err: null };
3386
+ };
3387
+ Parser.prototype.offset = function () {
3388
+ return this.position.offset;
3389
+ };
3390
+ Parser.prototype.isEOF = function () {
3391
+ return this.offset() === this.message.length;
3392
+ };
3393
+ Parser.prototype.clonePosition = function () {
3394
+ // This is much faster than `Object.assign` or spread.
3395
+ return {
3396
+ offset: this.position.offset,
3397
+ line: this.position.line,
3398
+ column: this.position.column,
3399
+ };
3400
+ };
3401
+ /**
3402
+ * Return the code point at the current position of the parser.
3403
+ * Throws if the index is out of bound.
3404
+ */
3405
+ Parser.prototype.char = function () {
3406
+ var offset = this.position.offset;
3407
+ if (offset >= this.message.length) {
3408
+ throw Error('out of bound');
3409
+ }
3410
+ var code = codePointAt(this.message, offset);
3411
+ if (code === undefined) {
3412
+ throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
3413
+ }
3414
+ return code;
3415
+ };
3416
+ Parser.prototype.error = function (kind, location) {
3417
+ return {
3418
+ val: null,
3419
+ err: {
3420
+ kind: kind,
3421
+ message: this.message,
3422
+ location: location,
3423
+ },
3424
+ };
3425
+ };
3426
+ /** Bump the parser to the next UTF-16 code unit. */
3427
+ Parser.prototype.bump = function () {
3428
+ if (this.isEOF()) {
3429
+ return;
3430
+ }
3431
+ var code = this.char();
3432
+ if (code === 10 /* '\n' */) {
3433
+ this.position.line += 1;
3434
+ this.position.column = 1;
3435
+ this.position.offset += 1;
3436
+ }
3437
+ else {
3438
+ this.position.column += 1;
3439
+ // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
3440
+ this.position.offset += code < 0x10000 ? 1 : 2;
3441
+ }
3442
+ };
3443
+ /**
3444
+ * If the substring starting at the current position of the parser has
3445
+ * the given prefix, then bump the parser to the character immediately
3446
+ * following the prefix and return true. Otherwise, don't bump the parser
3447
+ * and return false.
3448
+ */
3449
+ Parser.prototype.bumpIf = function (prefix) {
3450
+ if (startsWith(this.message, prefix, this.offset())) {
3451
+ for (var i = 0; i < prefix.length; i++) {
3452
+ this.bump();
3453
+ }
3454
+ return true;
3455
+ }
3456
+ return false;
3457
+ };
3458
+ /**
3459
+ * Bump the parser until the pattern character is found and return `true`.
3460
+ * Otherwise bump to the end of the file and return `false`.
3461
+ */
3462
+ Parser.prototype.bumpUntil = function (pattern) {
3463
+ var currentOffset = this.offset();
3464
+ var index = this.message.indexOf(pattern, currentOffset);
3465
+ if (index >= 0) {
3466
+ this.bumpTo(index);
3467
+ return true;
3468
+ }
3469
+ else {
3470
+ this.bumpTo(this.message.length);
3471
+ return false;
3472
+ }
3473
+ };
3474
+ /**
3475
+ * Bump the parser to the target offset.
3476
+ * If target offset is beyond the end of the input, bump the parser to the end of the input.
3477
+ */
3478
+ Parser.prototype.bumpTo = function (targetOffset) {
3479
+ if (this.offset() > targetOffset) {
3480
+ throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
3481
+ }
3482
+ targetOffset = Math.min(targetOffset, this.message.length);
3483
+ while (true) {
3484
+ var offset = this.offset();
3485
+ if (offset === targetOffset) {
3486
+ break;
3487
+ }
3488
+ if (offset > targetOffset) {
3489
+ throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
3490
+ }
3491
+ this.bump();
3492
+ if (this.isEOF()) {
3493
+ break;
3494
+ }
3495
+ }
3496
+ };
3497
+ /** advance the parser through all whitespace to the next non-whitespace code unit. */
3498
+ Parser.prototype.bumpSpace = function () {
3499
+ while (!this.isEOF() && _isWhiteSpace(this.char())) {
3500
+ this.bump();
3501
+ }
3502
+ };
3503
+ /**
3504
+ * Peek at the *next* Unicode codepoint in the input without advancing the parser.
3505
+ * If the input has been exhausted, then this returns null.
3506
+ */
3507
+ Parser.prototype.peek = function () {
3508
+ if (this.isEOF()) {
3509
+ return null;
3510
+ }
3511
+ var code = this.char();
3512
+ var offset = this.offset();
3513
+ var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
3514
+ return nextCode !== null && nextCode !== void 0 ? nextCode : null;
3515
+ };
3516
+ return Parser;
3517
+ }());
3518
+ /**
3519
+ * This check if codepoint is alphabet (lower & uppercase)
3520
+ * @param codepoint
3521
+ * @returns
3522
+ */
3523
+ function _isAlpha(codepoint) {
3524
+ return ((codepoint >= 97 && codepoint <= 122) ||
3525
+ (codepoint >= 65 && codepoint <= 90));
3526
+ }
3527
+ function _isAlphaOrSlash(codepoint) {
3528
+ return _isAlpha(codepoint) || codepoint === 47; /* '/' */
3529
+ }
3530
+ /** See `parseTag` function docs. */
3531
+ function _isPotentialElementNameChar(c) {
3532
+ return (c === 45 /* '-' */ ||
3533
+ c === 46 /* '.' */ ||
3534
+ (c >= 48 && c <= 57) /* 0..9 */ ||
3535
+ c === 95 /* '_' */ ||
3536
+ (c >= 97 && c <= 122) /** a..z */ ||
3537
+ (c >= 65 && c <= 90) /* A..Z */ ||
3538
+ c == 0xb7 ||
3539
+ (c >= 0xc0 && c <= 0xd6) ||
3540
+ (c >= 0xd8 && c <= 0xf6) ||
3541
+ (c >= 0xf8 && c <= 0x37d) ||
3542
+ (c >= 0x37f && c <= 0x1fff) ||
3543
+ (c >= 0x200c && c <= 0x200d) ||
3544
+ (c >= 0x203f && c <= 0x2040) ||
3545
+ (c >= 0x2070 && c <= 0x218f) ||
3546
+ (c >= 0x2c00 && c <= 0x2fef) ||
3547
+ (c >= 0x3001 && c <= 0xd7ff) ||
3548
+ (c >= 0xf900 && c <= 0xfdcf) ||
3549
+ (c >= 0xfdf0 && c <= 0xfffd) ||
3550
+ (c >= 0x10000 && c <= 0xeffff));
3551
+ }
3552
+ /**
3553
+ * Code point equivalent of regex `\p{White_Space}`.
3554
+ * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
3555
+ */
3556
+ function _isWhiteSpace(c) {
3557
+ return ((c >= 0x0009 && c <= 0x000d) ||
3558
+ c === 0x0020 ||
3559
+ c === 0x0085 ||
3560
+ (c >= 0x200e && c <= 0x200f) ||
3561
+ c === 0x2028 ||
3562
+ c === 0x2029);
3563
+ }
3564
+ /**
3565
+ * Code point equivalent of regex `\p{Pattern_Syntax}`.
3566
+ * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
3567
+ */
3568
+ function _isPatternSyntax(c) {
3569
+ return ((c >= 0x0021 && c <= 0x0023) ||
3570
+ c === 0x0024 ||
3571
+ (c >= 0x0025 && c <= 0x0027) ||
3572
+ c === 0x0028 ||
3573
+ c === 0x0029 ||
3574
+ c === 0x002a ||
3575
+ c === 0x002b ||
3576
+ c === 0x002c ||
3577
+ c === 0x002d ||
3578
+ (c >= 0x002e && c <= 0x002f) ||
3579
+ (c >= 0x003a && c <= 0x003b) ||
3580
+ (c >= 0x003c && c <= 0x003e) ||
3581
+ (c >= 0x003f && c <= 0x0040) ||
3582
+ c === 0x005b ||
3583
+ c === 0x005c ||
3584
+ c === 0x005d ||
3585
+ c === 0x005e ||
3586
+ c === 0x0060 ||
3587
+ c === 0x007b ||
3588
+ c === 0x007c ||
3589
+ c === 0x007d ||
3590
+ c === 0x007e ||
3591
+ c === 0x00a1 ||
3592
+ (c >= 0x00a2 && c <= 0x00a5) ||
3593
+ c === 0x00a6 ||
3594
+ c === 0x00a7 ||
3595
+ c === 0x00a9 ||
3596
+ c === 0x00ab ||
3597
+ c === 0x00ac ||
3598
+ c === 0x00ae ||
3599
+ c === 0x00b0 ||
3600
+ c === 0x00b1 ||
3601
+ c === 0x00b6 ||
3602
+ c === 0x00bb ||
3603
+ c === 0x00bf ||
3604
+ c === 0x00d7 ||
3605
+ c === 0x00f7 ||
3606
+ (c >= 0x2010 && c <= 0x2015) ||
3607
+ (c >= 0x2016 && c <= 0x2017) ||
3608
+ c === 0x2018 ||
3609
+ c === 0x2019 ||
3610
+ c === 0x201a ||
3611
+ (c >= 0x201b && c <= 0x201c) ||
3612
+ c === 0x201d ||
3613
+ c === 0x201e ||
3614
+ c === 0x201f ||
3615
+ (c >= 0x2020 && c <= 0x2027) ||
3616
+ (c >= 0x2030 && c <= 0x2038) ||
3617
+ c === 0x2039 ||
3618
+ c === 0x203a ||
3619
+ (c >= 0x203b && c <= 0x203e) ||
3620
+ (c >= 0x2041 && c <= 0x2043) ||
3621
+ c === 0x2044 ||
3622
+ c === 0x2045 ||
3623
+ c === 0x2046 ||
3624
+ (c >= 0x2047 && c <= 0x2051) ||
3625
+ c === 0x2052 ||
3626
+ c === 0x2053 ||
3627
+ (c >= 0x2055 && c <= 0x205e) ||
3628
+ (c >= 0x2190 && c <= 0x2194) ||
3629
+ (c >= 0x2195 && c <= 0x2199) ||
3630
+ (c >= 0x219a && c <= 0x219b) ||
3631
+ (c >= 0x219c && c <= 0x219f) ||
3632
+ c === 0x21a0 ||
3633
+ (c >= 0x21a1 && c <= 0x21a2) ||
3634
+ c === 0x21a3 ||
3635
+ (c >= 0x21a4 && c <= 0x21a5) ||
3636
+ c === 0x21a6 ||
3637
+ (c >= 0x21a7 && c <= 0x21ad) ||
3638
+ c === 0x21ae ||
3639
+ (c >= 0x21af && c <= 0x21cd) ||
3640
+ (c >= 0x21ce && c <= 0x21cf) ||
3641
+ (c >= 0x21d0 && c <= 0x21d1) ||
3642
+ c === 0x21d2 ||
3643
+ c === 0x21d3 ||
3644
+ c === 0x21d4 ||
3645
+ (c >= 0x21d5 && c <= 0x21f3) ||
3646
+ (c >= 0x21f4 && c <= 0x22ff) ||
3647
+ (c >= 0x2300 && c <= 0x2307) ||
3648
+ c === 0x2308 ||
3649
+ c === 0x2309 ||
3650
+ c === 0x230a ||
3651
+ c === 0x230b ||
3652
+ (c >= 0x230c && c <= 0x231f) ||
3653
+ (c >= 0x2320 && c <= 0x2321) ||
3654
+ (c >= 0x2322 && c <= 0x2328) ||
3655
+ c === 0x2329 ||
3656
+ c === 0x232a ||
3657
+ (c >= 0x232b && c <= 0x237b) ||
3658
+ c === 0x237c ||
3659
+ (c >= 0x237d && c <= 0x239a) ||
3660
+ (c >= 0x239b && c <= 0x23b3) ||
3661
+ (c >= 0x23b4 && c <= 0x23db) ||
3662
+ (c >= 0x23dc && c <= 0x23e1) ||
3663
+ (c >= 0x23e2 && c <= 0x2426) ||
3664
+ (c >= 0x2427 && c <= 0x243f) ||
3665
+ (c >= 0x2440 && c <= 0x244a) ||
3666
+ (c >= 0x244b && c <= 0x245f) ||
3667
+ (c >= 0x2500 && c <= 0x25b6) ||
3668
+ c === 0x25b7 ||
3669
+ (c >= 0x25b8 && c <= 0x25c0) ||
3670
+ c === 0x25c1 ||
3671
+ (c >= 0x25c2 && c <= 0x25f7) ||
3672
+ (c >= 0x25f8 && c <= 0x25ff) ||
3673
+ (c >= 0x2600 && c <= 0x266e) ||
3674
+ c === 0x266f ||
3675
+ (c >= 0x2670 && c <= 0x2767) ||
3676
+ c === 0x2768 ||
3677
+ c === 0x2769 ||
3678
+ c === 0x276a ||
3679
+ c === 0x276b ||
3680
+ c === 0x276c ||
3681
+ c === 0x276d ||
3682
+ c === 0x276e ||
3683
+ c === 0x276f ||
3684
+ c === 0x2770 ||
3685
+ c === 0x2771 ||
3686
+ c === 0x2772 ||
3687
+ c === 0x2773 ||
3688
+ c === 0x2774 ||
3689
+ c === 0x2775 ||
3690
+ (c >= 0x2794 && c <= 0x27bf) ||
3691
+ (c >= 0x27c0 && c <= 0x27c4) ||
3692
+ c === 0x27c5 ||
3693
+ c === 0x27c6 ||
3694
+ (c >= 0x27c7 && c <= 0x27e5) ||
3695
+ c === 0x27e6 ||
3696
+ c === 0x27e7 ||
3697
+ c === 0x27e8 ||
3698
+ c === 0x27e9 ||
3699
+ c === 0x27ea ||
3700
+ c === 0x27eb ||
3701
+ c === 0x27ec ||
3702
+ c === 0x27ed ||
3703
+ c === 0x27ee ||
3704
+ c === 0x27ef ||
3705
+ (c >= 0x27f0 && c <= 0x27ff) ||
3706
+ (c >= 0x2800 && c <= 0x28ff) ||
3707
+ (c >= 0x2900 && c <= 0x2982) ||
3708
+ c === 0x2983 ||
3709
+ c === 0x2984 ||
3710
+ c === 0x2985 ||
3711
+ c === 0x2986 ||
3712
+ c === 0x2987 ||
3713
+ c === 0x2988 ||
3714
+ c === 0x2989 ||
3715
+ c === 0x298a ||
3716
+ c === 0x298b ||
3717
+ c === 0x298c ||
3718
+ c === 0x298d ||
3719
+ c === 0x298e ||
3720
+ c === 0x298f ||
3721
+ c === 0x2990 ||
3722
+ c === 0x2991 ||
3723
+ c === 0x2992 ||
3724
+ c === 0x2993 ||
3725
+ c === 0x2994 ||
3726
+ c === 0x2995 ||
3727
+ c === 0x2996 ||
3728
+ c === 0x2997 ||
3729
+ c === 0x2998 ||
3730
+ (c >= 0x2999 && c <= 0x29d7) ||
3731
+ c === 0x29d8 ||
3732
+ c === 0x29d9 ||
3733
+ c === 0x29da ||
3734
+ c === 0x29db ||
3735
+ (c >= 0x29dc && c <= 0x29fb) ||
3736
+ c === 0x29fc ||
3737
+ c === 0x29fd ||
3738
+ (c >= 0x29fe && c <= 0x2aff) ||
3739
+ (c >= 0x2b00 && c <= 0x2b2f) ||
3740
+ (c >= 0x2b30 && c <= 0x2b44) ||
3741
+ (c >= 0x2b45 && c <= 0x2b46) ||
3742
+ (c >= 0x2b47 && c <= 0x2b4c) ||
3743
+ (c >= 0x2b4d && c <= 0x2b73) ||
3744
+ (c >= 0x2b74 && c <= 0x2b75) ||
3745
+ (c >= 0x2b76 && c <= 0x2b95) ||
3746
+ c === 0x2b96 ||
3747
+ (c >= 0x2b97 && c <= 0x2bff) ||
3748
+ (c >= 0x2e00 && c <= 0x2e01) ||
3749
+ c === 0x2e02 ||
3750
+ c === 0x2e03 ||
3751
+ c === 0x2e04 ||
3752
+ c === 0x2e05 ||
3753
+ (c >= 0x2e06 && c <= 0x2e08) ||
3754
+ c === 0x2e09 ||
3755
+ c === 0x2e0a ||
3756
+ c === 0x2e0b ||
3757
+ c === 0x2e0c ||
3758
+ c === 0x2e0d ||
3759
+ (c >= 0x2e0e && c <= 0x2e16) ||
3760
+ c === 0x2e17 ||
3761
+ (c >= 0x2e18 && c <= 0x2e19) ||
3762
+ c === 0x2e1a ||
3763
+ c === 0x2e1b ||
3764
+ c === 0x2e1c ||
3765
+ c === 0x2e1d ||
3766
+ (c >= 0x2e1e && c <= 0x2e1f) ||
3767
+ c === 0x2e20 ||
3768
+ c === 0x2e21 ||
3769
+ c === 0x2e22 ||
3770
+ c === 0x2e23 ||
3771
+ c === 0x2e24 ||
3772
+ c === 0x2e25 ||
3773
+ c === 0x2e26 ||
3774
+ c === 0x2e27 ||
3775
+ c === 0x2e28 ||
3776
+ c === 0x2e29 ||
3777
+ (c >= 0x2e2a && c <= 0x2e2e) ||
3778
+ c === 0x2e2f ||
3779
+ (c >= 0x2e30 && c <= 0x2e39) ||
3780
+ (c >= 0x2e3a && c <= 0x2e3b) ||
3781
+ (c >= 0x2e3c && c <= 0x2e3f) ||
3782
+ c === 0x2e40 ||
3783
+ c === 0x2e41 ||
3784
+ c === 0x2e42 ||
3785
+ (c >= 0x2e43 && c <= 0x2e4f) ||
3786
+ (c >= 0x2e50 && c <= 0x2e51) ||
3787
+ c === 0x2e52 ||
3788
+ (c >= 0x2e53 && c <= 0x2e7f) ||
3789
+ (c >= 0x3001 && c <= 0x3003) ||
3790
+ c === 0x3008 ||
3791
+ c === 0x3009 ||
3792
+ c === 0x300a ||
3793
+ c === 0x300b ||
3794
+ c === 0x300c ||
3795
+ c === 0x300d ||
3796
+ c === 0x300e ||
3797
+ c === 0x300f ||
3798
+ c === 0x3010 ||
3799
+ c === 0x3011 ||
3800
+ (c >= 0x3012 && c <= 0x3013) ||
3801
+ c === 0x3014 ||
3802
+ c === 0x3015 ||
3803
+ c === 0x3016 ||
3804
+ c === 0x3017 ||
3805
+ c === 0x3018 ||
3806
+ c === 0x3019 ||
3807
+ c === 0x301a ||
3808
+ c === 0x301b ||
3809
+ c === 0x301c ||
3810
+ c === 0x301d ||
3811
+ (c >= 0x301e && c <= 0x301f) ||
3812
+ c === 0x3020 ||
3813
+ c === 0x3030 ||
3814
+ c === 0xfd3e ||
3815
+ c === 0xfd3f ||
3816
+ (c >= 0xfe45 && c <= 0xfe46));
3817
+ }
3818
+
3819
+ function pruneLocation(els) {
3820
+ els.forEach(function (el) {
3821
+ delete el.location;
3822
+ if (isSelectElement(el) || isPluralElement(el)) {
3823
+ for (var k in el.options) {
3824
+ delete el.options[k].location;
3825
+ pruneLocation(el.options[k].value);
3826
+ }
3827
+ }
3828
+ else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
3829
+ delete el.style.location;
3830
+ }
3831
+ else if ((isDateElement(el) || isTimeElement(el)) &&
3832
+ isDateTimeSkeleton(el.style)) {
3833
+ delete el.style.location;
3834
+ }
3835
+ else if (isTagElement(el)) {
3836
+ pruneLocation(el.children);
3837
+ }
3838
+ });
3839
+ }
3840
+ function parse(message, opts) {
3841
+ if (opts === void 0) { opts = {}; }
3842
+ opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
3843
+ var result = new Parser(message, opts).parse();
3844
+ if (result.err) {
3845
+ var error = SyntaxError(ErrorKind[result.err.kind]);
3846
+ // @ts-expect-error Assign to error object
3847
+ error.location = result.err.location;
3848
+ // @ts-expect-error Assign to error object
3849
+ error.originalMessage = result.err.message;
3850
+ throw error;
3851
+ }
3852
+ if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
3853
+ pruneLocation(result.val);
3854
+ }
3855
+ return result.val;
3856
+ }
3857
+
3858
+ //
3859
+ // Main
3860
+ //
3861
+ function memoize(fn, options) {
3862
+ var cache = options && options.cache ? options.cache : cacheDefault;
3863
+ var serializer = options && options.serializer ? options.serializer : serializerDefault;
3864
+ var strategy = options && options.strategy ? options.strategy : strategyDefault;
3865
+ return strategy(fn, {
3866
+ cache: cache,
3867
+ serializer: serializer,
3868
+ });
3869
+ }
3870
+ //
3871
+ // Strategy
3872
+ //
3873
+ function isPrimitive(value) {
3874
+ return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === "string" 'unsafe' primitive for our needs
3875
+ }
3876
+ function monadic(fn, cache, serializer, arg) {
3877
+ var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
3878
+ var computedValue = cache.get(cacheKey);
3879
+ if (typeof computedValue === 'undefined') {
3880
+ computedValue = fn.call(this, arg);
3881
+ cache.set(cacheKey, computedValue);
3882
+ }
3883
+ return computedValue;
3884
+ }
3885
+ function variadic(fn, cache, serializer) {
3886
+ var args = Array.prototype.slice.call(arguments, 3);
3887
+ var cacheKey = serializer(args);
3888
+ var computedValue = cache.get(cacheKey);
3889
+ if (typeof computedValue === 'undefined') {
3890
+ computedValue = fn.apply(this, args);
3891
+ cache.set(cacheKey, computedValue);
3892
+ }
3893
+ return computedValue;
3894
+ }
3895
+ function assemble(fn, context, strategy, cache, serialize) {
3896
+ return strategy.bind(context, fn, cache, serialize);
3897
+ }
3898
+ function strategyDefault(fn, options) {
3899
+ var strategy = fn.length === 1 ? monadic : variadic;
3900
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
3901
+ }
3902
+ function strategyVariadic(fn, options) {
3903
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
3904
+ }
3905
+ function strategyMonadic(fn, options) {
3906
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
3907
+ }
3908
+ //
3909
+ // Serializer
3910
+ //
3911
+ var serializerDefault = function () {
3912
+ return JSON.stringify(arguments);
3913
+ };
3914
+ //
3915
+ // Cache
3916
+ //
3917
+ function ObjectWithoutPrototypeCache() {
3918
+ this.cache = Object.create(null);
3919
+ }
3920
+ ObjectWithoutPrototypeCache.prototype.has = function (key) {
3921
+ return key in this.cache;
3922
+ };
3923
+ ObjectWithoutPrototypeCache.prototype.get = function (key) {
3924
+ return this.cache[key];
3925
+ };
3926
+ ObjectWithoutPrototypeCache.prototype.set = function (key, value) {
3927
+ this.cache[key] = value;
3928
+ };
3929
+ var cacheDefault = {
3930
+ create: function create() {
3931
+ // @ts-ignore
3932
+ return new ObjectWithoutPrototypeCache();
3933
+ },
3934
+ };
3935
+ var strategies = {
3936
+ variadic: strategyVariadic,
3937
+ monadic: strategyMonadic,
3938
+ };
3939
+
3940
+ var ErrorCode;
3941
+ (function (ErrorCode) {
3942
+ // When we have a placeholder but no value to format
3943
+ ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
3944
+ // When value supplied is invalid
3945
+ ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
3946
+ // When we need specific Intl API but it's not available
3947
+ ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
3948
+ })(ErrorCode || (ErrorCode = {}));
3949
+ var FormatError = /** @class */ (function (_super) {
3950
+ __extends(FormatError, _super);
3951
+ function FormatError(msg, code, originalMessage) {
3952
+ var _this = _super.call(this, msg) || this;
3953
+ _this.code = code;
3954
+ _this.originalMessage = originalMessage;
3955
+ return _this;
3956
+ }
3957
+ FormatError.prototype.toString = function () {
3958
+ return "[formatjs Error: " + this.code + "] " + this.message;
3959
+ };
3960
+ return FormatError;
3961
+ }(Error));
3962
+ var InvalidValueError = /** @class */ (function (_super) {
3963
+ __extends(InvalidValueError, _super);
3964
+ function InvalidValueError(variableId, value, options, originalMessage) {
3965
+ return _super.call(this, "Invalid values for \"" + variableId + "\": \"" + value + "\". Options are \"" + Object.keys(options).join('", "') + "\"", ErrorCode.INVALID_VALUE, originalMessage) || this;
3966
+ }
3967
+ return InvalidValueError;
3968
+ }(FormatError));
3969
+ var InvalidValueTypeError = /** @class */ (function (_super) {
3970
+ __extends(InvalidValueTypeError, _super);
3971
+ function InvalidValueTypeError(value, type, originalMessage) {
3972
+ return _super.call(this, "Value for \"" + value + "\" must be of type " + type, ErrorCode.INVALID_VALUE, originalMessage) || this;
3973
+ }
3974
+ return InvalidValueTypeError;
3975
+ }(FormatError));
3976
+ var MissingValueError = /** @class */ (function (_super) {
3977
+ __extends(MissingValueError, _super);
3978
+ function MissingValueError(variableId, originalMessage) {
3979
+ return _super.call(this, "The intl string context variable \"" + variableId + "\" was not provided to the string \"" + originalMessage + "\"", ErrorCode.MISSING_VALUE, originalMessage) || this;
3980
+ }
3981
+ return MissingValueError;
3982
+ }(FormatError));
3983
+
3984
+ var PART_TYPE;
3985
+ (function (PART_TYPE) {
3986
+ PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
3987
+ PART_TYPE[PART_TYPE["object"] = 1] = "object";
3988
+ })(PART_TYPE || (PART_TYPE = {}));
3989
+ function mergeLiteral(parts) {
3990
+ if (parts.length < 2) {
3991
+ return parts;
3992
+ }
3993
+ return parts.reduce(function (all, part) {
3994
+ var lastPart = all[all.length - 1];
3995
+ if (!lastPart ||
3996
+ lastPart.type !== PART_TYPE.literal ||
3997
+ part.type !== PART_TYPE.literal) {
3998
+ all.push(part);
3999
+ }
4000
+ else {
4001
+ lastPart.value += part.value;
4002
+ }
4003
+ return all;
4004
+ }, []);
4005
+ }
4006
+ function isFormatXMLElementFn(el) {
4007
+ return typeof el === 'function';
4008
+ }
4009
+ // TODO(skeleton): add skeleton support
4010
+ function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
4011
+ // For debugging
4012
+ originalMessage) {
4013
+ // Hot path for straight simple msg translations
4014
+ if (els.length === 1 && isLiteralElement(els[0])) {
4015
+ return [
4016
+ {
4017
+ type: PART_TYPE.literal,
4018
+ value: els[0].value,
4019
+ },
4020
+ ];
4021
+ }
4022
+ var result = [];
4023
+ for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
4024
+ var el = els_1[_i];
4025
+ // Exit early for string parts.
4026
+ if (isLiteralElement(el)) {
4027
+ result.push({
4028
+ type: PART_TYPE.literal,
4029
+ value: el.value,
4030
+ });
4031
+ continue;
4032
+ }
4033
+ // TODO: should this part be literal type?
4034
+ // Replace `#` in plural rules with the actual numeric value.
4035
+ if (isPoundElement(el)) {
4036
+ if (typeof currentPluralValue === 'number') {
4037
+ result.push({
4038
+ type: PART_TYPE.literal,
4039
+ value: formatters.getNumberFormat(locales).format(currentPluralValue),
4040
+ });
4041
+ }
4042
+ continue;
4043
+ }
4044
+ var varName = el.value;
4045
+ // Enforce that all required values are provided by the caller.
4046
+ if (!(values && varName in values)) {
4047
+ throw new MissingValueError(varName, originalMessage);
4048
+ }
4049
+ var value = values[varName];
4050
+ if (isArgumentElement(el)) {
4051
+ if (!value || typeof value === 'string' || typeof value === 'number') {
4052
+ value =
4053
+ typeof value === 'string' || typeof value === 'number'
4054
+ ? String(value)
4055
+ : '';
4056
+ }
4057
+ result.push({
4058
+ type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
4059
+ value: value,
4060
+ });
4061
+ continue;
4062
+ }
4063
+ // Recursively format plural and select parts' option — which can be a
4064
+ // nested pattern structure. The choosing of the option to use is
4065
+ // abstracted-by and delegated-to the part helper object.
4066
+ if (isDateElement(el)) {
4067
+ var style = typeof el.style === 'string'
4068
+ ? formats.date[el.style]
4069
+ : isDateTimeSkeleton(el.style)
4070
+ ? el.style.parsedOptions
4071
+ : undefined;
4072
+ result.push({
4073
+ type: PART_TYPE.literal,
4074
+ value: formatters
4075
+ .getDateTimeFormat(locales, style)
4076
+ .format(value),
4077
+ });
4078
+ continue;
4079
+ }
4080
+ if (isTimeElement(el)) {
4081
+ var style = typeof el.style === 'string'
4082
+ ? formats.time[el.style]
4083
+ : isDateTimeSkeleton(el.style)
4084
+ ? el.style.parsedOptions
4085
+ : undefined;
4086
+ result.push({
4087
+ type: PART_TYPE.literal,
4088
+ value: formatters
4089
+ .getDateTimeFormat(locales, style)
4090
+ .format(value),
4091
+ });
4092
+ continue;
4093
+ }
4094
+ if (isNumberElement(el)) {
4095
+ var style = typeof el.style === 'string'
4096
+ ? formats.number[el.style]
4097
+ : isNumberSkeleton(el.style)
4098
+ ? el.style.parsedOptions
4099
+ : undefined;
4100
+ if (style && style.scale) {
4101
+ value =
4102
+ value *
4103
+ (style.scale || 1);
4104
+ }
4105
+ result.push({
4106
+ type: PART_TYPE.literal,
4107
+ value: formatters
4108
+ .getNumberFormat(locales, style)
4109
+ .format(value),
4110
+ });
4111
+ continue;
4112
+ }
4113
+ if (isTagElement(el)) {
4114
+ var children = el.children, value_1 = el.value;
4115
+ var formatFn = values[value_1];
4116
+ if (!isFormatXMLElementFn(formatFn)) {
4117
+ throw new InvalidValueTypeError(value_1, 'function', originalMessage);
4118
+ }
4119
+ var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
4120
+ var chunks = formatFn(parts.map(function (p) { return p.value; }));
4121
+ if (!Array.isArray(chunks)) {
4122
+ chunks = [chunks];
4123
+ }
4124
+ result.push.apply(result, chunks.map(function (c) {
4125
+ return {
4126
+ type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
4127
+ value: c,
4128
+ };
4129
+ }));
4130
+ }
4131
+ if (isSelectElement(el)) {
4132
+ var opt = el.options[value] || el.options.other;
4133
+ if (!opt) {
4134
+ throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
4135
+ }
4136
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
4137
+ continue;
4138
+ }
4139
+ if (isPluralElement(el)) {
4140
+ var opt = el.options["=" + value];
4141
+ if (!opt) {
4142
+ if (!Intl.PluralRules) {
4143
+ throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
4144
+ }
4145
+ var rule = formatters
4146
+ .getPluralRules(locales, { type: el.pluralType })
4147
+ .select(value - (el.offset || 0));
4148
+ opt = el.options[rule] || el.options.other;
4149
+ }
4150
+ if (!opt) {
4151
+ throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
4152
+ }
4153
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
4154
+ continue;
4155
+ }
4156
+ }
4157
+ return mergeLiteral(result);
4158
+ }
4159
+
4160
+ /*
4161
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
4162
+ Copyrights licensed under the New BSD License.
4163
+ See the accompanying LICENSE file for terms.
4164
+ */
4165
+ // -- MessageFormat --------------------------------------------------------
4166
+ function mergeConfig(c1, c2) {
4167
+ if (!c2) {
4168
+ return c1;
4169
+ }
4170
+ return __assign(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
4171
+ all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));
4172
+ return all;
4173
+ }, {}));
4174
+ }
4175
+ function mergeConfigs(defaultConfig, configs) {
4176
+ if (!configs) {
4177
+ return defaultConfig;
4178
+ }
4179
+ return Object.keys(defaultConfig).reduce(function (all, k) {
4180
+ all[k] = mergeConfig(defaultConfig[k], configs[k]);
4181
+ return all;
4182
+ }, __assign({}, defaultConfig));
4183
+ }
4184
+ function createFastMemoizeCache(store) {
4185
+ return {
4186
+ create: function () {
4187
+ return {
4188
+ has: function (key) {
4189
+ return key in store;
4190
+ },
4191
+ get: function (key) {
4192
+ return store[key];
4193
+ },
4194
+ set: function (key, value) {
4195
+ store[key] = value;
4196
+ },
4197
+ };
4198
+ },
4199
+ };
4200
+ }
4201
+ function createDefaultFormatters(cache) {
4202
+ if (cache === void 0) { cache = {
4203
+ number: {},
4204
+ dateTime: {},
4205
+ pluralRules: {},
4206
+ }; }
4207
+ return {
4208
+ getNumberFormat: memoize(function () {
4209
+ var _a;
4210
+ var args = [];
4211
+ for (var _i = 0; _i < arguments.length; _i++) {
4212
+ args[_i] = arguments[_i];
4213
+ }
4214
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args)))();
4215
+ }, {
4216
+ cache: createFastMemoizeCache(cache.number),
4217
+ strategy: strategies.variadic,
4218
+ }),
4219
+ getDateTimeFormat: memoize(function () {
4220
+ var _a;
4221
+ var args = [];
4222
+ for (var _i = 0; _i < arguments.length; _i++) {
4223
+ args[_i] = arguments[_i];
4224
+ }
4225
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args)))();
4226
+ }, {
4227
+ cache: createFastMemoizeCache(cache.dateTime),
4228
+ strategy: strategies.variadic,
4229
+ }),
4230
+ getPluralRules: memoize(function () {
4231
+ var _a;
4232
+ var args = [];
4233
+ for (var _i = 0; _i < arguments.length; _i++) {
4234
+ args[_i] = arguments[_i];
4235
+ }
4236
+ return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args)))();
4237
+ }, {
4238
+ cache: createFastMemoizeCache(cache.pluralRules),
4239
+ strategy: strategies.variadic,
4240
+ }),
4241
+ };
4242
+ }
4243
+ var IntlMessageFormat = /** @class */ (function () {
4244
+ function IntlMessageFormat(message, locales, overrideFormats, opts) {
4245
+ var _this = this;
4246
+ if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
4247
+ this.formatterCache = {
4248
+ number: {},
4249
+ dateTime: {},
4250
+ pluralRules: {},
4251
+ };
4252
+ this.format = function (values) {
4253
+ var parts = _this.formatToParts(values);
4254
+ // Hot path for straight simple msg translations
4255
+ if (parts.length === 1) {
4256
+ return parts[0].value;
4257
+ }
4258
+ var result = parts.reduce(function (all, part) {
4259
+ if (!all.length ||
4260
+ part.type !== PART_TYPE.literal ||
4261
+ typeof all[all.length - 1] !== 'string') {
4262
+ all.push(part.value);
4263
+ }
4264
+ else {
4265
+ all[all.length - 1] += part.value;
4266
+ }
4267
+ return all;
4268
+ }, []);
4269
+ if (result.length <= 1) {
4270
+ return result[0] || '';
4271
+ }
4272
+ return result;
4273
+ };
4274
+ this.formatToParts = function (values) {
4275
+ return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
4276
+ };
4277
+ this.resolvedOptions = function () { return ({
4278
+ locale: Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
4279
+ }); };
4280
+ this.getAst = function () { return _this.ast; };
4281
+ if (typeof message === 'string') {
4282
+ this.message = message;
4283
+ if (!IntlMessageFormat.__parse) {
4284
+ throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
4285
+ }
4286
+ // Parse string messages into an AST.
4287
+ this.ast = IntlMessageFormat.__parse(message, {
4288
+ ignoreTag: opts === null || opts === void 0 ? void 0 : opts.ignoreTag,
4289
+ });
4290
+ }
4291
+ else {
4292
+ this.ast = message;
4293
+ }
4294
+ if (!Array.isArray(this.ast)) {
4295
+ throw new TypeError('A message must be provided as a String or AST.');
4296
+ }
4297
+ // Creates a new object with the specified `formats` merged with the default
4298
+ // formats.
4299
+ this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
4300
+ // Defined first because it's used to build the format pattern.
4301
+ this.locales = locales;
4302
+ this.formatters =
4303
+ (opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
4304
+ }
4305
+ Object.defineProperty(IntlMessageFormat, "defaultLocale", {
4306
+ get: function () {
4307
+ if (!IntlMessageFormat.memoizedDefaultLocale) {
4308
+ IntlMessageFormat.memoizedDefaultLocale =
4309
+ new Intl.NumberFormat().resolvedOptions().locale;
4310
+ }
4311
+ return IntlMessageFormat.memoizedDefaultLocale;
4312
+ },
4313
+ enumerable: false,
4314
+ configurable: true
4315
+ });
4316
+ IntlMessageFormat.memoizedDefaultLocale = null;
4317
+ IntlMessageFormat.__parse = parse;
4318
+ // Default format options used as the prototype of the `formats` provided to the
4319
+ // constructor. These are used when constructing the internal Intl.NumberFormat
4320
+ // and Intl.DateTimeFormat instances.
4321
+ IntlMessageFormat.formats = {
4322
+ number: {
4323
+ integer: {
4324
+ maximumFractionDigits: 0,
4325
+ },
4326
+ currency: {
4327
+ style: 'currency',
4328
+ },
4329
+ percent: {
4330
+ style: 'percent',
4331
+ },
4332
+ },
4333
+ date: {
4334
+ short: {
4335
+ month: 'numeric',
4336
+ day: 'numeric',
4337
+ year: '2-digit',
4338
+ },
4339
+ medium: {
4340
+ month: 'short',
4341
+ day: 'numeric',
4342
+ year: 'numeric',
4343
+ },
4344
+ long: {
4345
+ month: 'long',
4346
+ day: 'numeric',
4347
+ year: 'numeric',
4348
+ },
4349
+ full: {
4350
+ weekday: 'long',
4351
+ month: 'long',
4352
+ day: 'numeric',
4353
+ year: 'numeric',
4354
+ },
4355
+ },
4356
+ time: {
4357
+ short: {
4358
+ hour: 'numeric',
4359
+ minute: 'numeric',
4360
+ },
4361
+ medium: {
4362
+ hour: 'numeric',
4363
+ minute: 'numeric',
4364
+ second: 'numeric',
4365
+ },
4366
+ long: {
4367
+ hour: 'numeric',
4368
+ minute: 'numeric',
4369
+ second: 'numeric',
4370
+ timeZoneName: 'short',
4371
+ },
4372
+ full: {
4373
+ hour: 'numeric',
4374
+ minute: 'numeric',
4375
+ second: 'numeric',
4376
+ timeZoneName: 'short',
4377
+ },
4378
+ },
4379
+ };
4380
+ return IntlMessageFormat;
4381
+ }());
4382
+
4383
+ const r={},i=(e,n,t)=>t?(n in r||(r[n]={}),e in r[n]||(r[n][e]=t),t):t,a=(e,n)=>{if(null==n)return;if(n in r&&e in r[n])return r[n][e];const t=E(n);for(let o=0;o<t.length;o++){const r=c(t[o],e);if(r)return i(e,n,r)}};let l;const s=writable({});function u(e){return e in l}function c(e,n){if(!u(e))return null;return function(e,n){if(n in e)return e[n];const t=n.split(".");let o=e;for(let e=0;e<t.length;e++)if("object"==typeof o){if(e>0){const n=t.slice(e,t.length).join(".");if(n in o){o=o[n];break}}o=o[t[e]];}else o=void 0;return o}(function(e){return l[e]||null}(e),n)}function m(e,...n){delete r[e],s.update((o=>(o[e]=cjs.all([o[e]||{},...n]),o)));}derived([s],(([e])=>Object.keys(e)));s.subscribe((e=>l=e));const d={};function g(e){return d[e]}function w(e){return E(e).some((e=>{var n;return null===(n=g(e))||void 0===n?void 0:n.size}))}function h(e,n){return Promise.all(n.map((n=>(function(e,n){d[e].delete(n),0===d[e].size&&delete d[e];}(e,n),n().then((e=>e.default||e)))))).then((n=>m(e,...n)))}const p={};function b(e){if(!w(e))return e in p?p[e]:void 0;const n=function(e){return E(e).map((e=>{const n=g(e);return [e,n?[...n]:[]]})).filter((([,e])=>e.length>0))}(e);return p[e]=Promise.all(n.map((([e,n])=>h(e,n)))).then((()=>{if(w(e))return b(e);delete p[e];})),p[e]}/*! *****************************************************************************
4384
+ Copyright (c) Microsoft Corporation.
4385
+
4386
+ Permission to use, copy, modify, and/or distribute this software for any
4387
+ purpose with or without fee is hereby granted.
4388
+
4389
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
4390
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4391
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
4392
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4393
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
4394
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4395
+ PERFORMANCE OF THIS SOFTWARE.
4396
+ ***************************************************************************** */function v(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]]);}return t}const O={fallbackLocale:null,initialLocale:null,loadingDelay:200,formats:{number:{scientific:{notation:"scientific"},engineering:{notation:"engineering"},compactLong:{notation:"compact",compactDisplay:"long"},compactShort:{notation:"compact",compactDisplay:"short"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},warnOnMissingMessages:!0,ignoreTag:!0};function j(){return O}const k=writable(!1);let L;const T=writable(null);function x(e){return e.split("-").map(((e,n,t)=>t.slice(0,n+1).join("-"))).reverse()}function E(e,n=j().fallbackLocale){const t=x(e);return n?[...new Set([...t,...x(n)])]:t}function D(){return L}T.subscribe((e=>{L=e,"undefined"!=typeof window&&null!==e&&document.documentElement.setAttribute("lang",e);}));const M=T.set;T.set=e=>{if(function(e){if(null==e)return;const n=E(e);for(let e=0;e<n.length;e++){const t=n[e];if(u(t))return t}}(e)&&w(e)){const{loadingDelay:n}=j();let t;return "undefined"!=typeof window&&null!=D()&&n?t=window.setTimeout((()=>k.set(!0)),n):k.set(!0),b(e).then((()=>{M(e);})).finally((()=>{clearTimeout(t),k.set(!1);}))}return M(e)},T.update=e=>M(e(L));const Z=e=>{const n=Object.create(null);return t=>{const o=JSON.stringify(t);return o in n?n[o]:n[o]=e(t)}},C=(e,n)=>{const{formats:t}=j();if(e in t&&n in t[e])return t[e][n];throw new Error(`[svelte-i18n] Unknown "${n}" ${e} format.`)},G=Z((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return t&&(o=C("number",t)),new Intl.NumberFormat(n,o)})),J=Z((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return t?o=C("date",t):0===Object.keys(o).length&&(o=C("date","short")),new Intl.DateTimeFormat(n,o)})),U=Z((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return t?o=C("time",t):0===Object.keys(o).length&&(o=C("time","short")),new Intl.DateTimeFormat(n,o)})),_=(e={})=>{var{locale:n=D()}=e,t=v(e,["locale"]);return G(Object.assign({locale:n},t))},q=(e={})=>{var{locale:n=D()}=e,t=v(e,["locale"]);return J(Object.assign({locale:n},t))},B=(e={})=>{var{locale:n=D()}=e,t=v(e,["locale"]);return U(Object.assign({locale:n},t))},H=Z(((e,n=D())=>new IntlMessageFormat(e,n,j().formats,{ignoreTag:j().ignoreTag}))),K=(e,n={})=>{"object"==typeof e&&(e=(n=e).id);const{values:t,locale:o=D(),default:r}=n;if(null==o)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let i=a(e,o);if(i){if("string"!=typeof i)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof i}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),i}else j().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${E(o).join('", "')}".${w(D())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),i=r||e;if(!t)return i;let l=i;try{l=H(i,o).format(t);}catch(n){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,n.message);}return l},Q=(e,n)=>B(n).format(e),R=(e,n)=>q(n).format(e),V=(e,n)=>_(n).format(e),W=(e,n=D())=>a(e,n);derived([T,s],(()=>K));derived([T],(()=>Q));derived([T],(()=>R));derived([T],(()=>V));derived([T,s],(()=>W));
4397
+
4398
+ window.emWidgets = { topic };
4399
+
4400
+ /**
4401
+ * @name getDevice
4402
+ * @description A method that returns the type of the device
4403
+ * @param {String} userAgent window.navigator.userAgent
4404
+ * @returns {String} Android/iPhone/iPad/PC
4405
+ */
4406
+ const getDevice = (userAgent) => {
4407
+ if (userAgent.toLowerCase().match(/android/i)) {
4408
+ return 'Android';
4409
+ }
4410
+
4411
+ if (userAgent.toLowerCase().match(/iphone/i)) {
4412
+ return 'iPhone';
4413
+ }
4414
+
4415
+ if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
4416
+ return 'iPad';
4417
+ }
4418
+
4419
+ return 'PC';
4420
+ };
4421
+
4422
+ /* src/PlayerWithdrawal.svelte generated by Svelte v3.37.0 */
4423
+
4424
+ const { console: console_1 } = globals;
4425
+ const file = "src/PlayerWithdrawal.svelte";
4426
+
4427
+ // (81:2) {#if isMobile}
4428
+ function create_if_block_1(ctx) {
4429
+ let div;
4430
+ let svg;
4431
+ let defs;
4432
+ let style;
4433
+ let t0;
4434
+ let g1;
4435
+ let g0;
4436
+ let path;
4437
+ let t1;
4438
+ let h2;
4439
+ let mounted;
4440
+ let dispose;
4441
+
4442
+ const block = {
4443
+ c: function create() {
4444
+ div = element("div");
4445
+ svg = svg_element("svg");
4446
+ defs = svg_element("defs");
4447
+ style = svg_element("style");
4448
+ t0 = text(".aaa{fill:#d0046c;}");
4449
+ g1 = svg_element("g");
4450
+ g0 = svg_element("g");
4451
+ path = svg_element("path");
4452
+ t1 = space();
4453
+ h2 = element("h2");
4454
+ h2.textContent = "Withdrawal";
4455
+ add_location(style, file, 82, 95, 2791);
4456
+ add_location(defs, file, 82, 89, 2785);
4457
+ attr_dev(path, "class", "aaa");
4458
+ attr_dev(path, "d", "M7.5,0,6.136,1.364,11.3,6.526H0V8.474H11.3L6.136,13.636,7.5,15,15,7.5Z");
4459
+ attr_dev(path, "transform", "translate(15 15) rotate(180)");
4460
+ add_location(path, file, 84, 10, 2920);
4461
+ attr_dev(g0, "transform", "translate(20 158)");
4462
+ add_location(g0, file, 83, 8, 2876);
4463
+ attr_dev(g1, "transform", "translate(-20 -158)");
4464
+ add_location(g1, file, 82, 136, 2832);
4465
+ attr_dev(svg, "xmlns", "http://www.w3.org/2000/svg");
4466
+ attr_dev(svg, "width", "15");
4467
+ attr_dev(svg, "height", "15");
4468
+ attr_dev(svg, "viewBox", "0 0 15 15");
4469
+ add_location(svg, file, 82, 6, 2702);
4470
+ attr_dev(h2, "class", "WithdrawalTitleMobile");
4471
+ add_location(h2, file, 87, 6, 3092);
4472
+ attr_dev(div, "class", "MenuReturnButton");
4473
+ add_location(div, file, 81, 4, 2633);
4474
+ },
4475
+ m: function mount(target, anchor) {
4476
+ insert_dev(target, div, anchor);
4477
+ append_dev(div, svg);
4478
+ append_dev(svg, defs);
4479
+ append_dev(defs, style);
4480
+ append_dev(style, t0);
4481
+ append_dev(svg, g1);
4482
+ append_dev(g1, g0);
4483
+ append_dev(g0, path);
4484
+ append_dev(div, t1);
4485
+ append_dev(div, h2);
4486
+
4487
+ if (!mounted) {
4488
+ dispose = listen_dev(div, "click", /*click_handler*/ ctx[7], false, false, false);
4489
+ mounted = true;
4490
+ }
4491
+ },
4492
+ p: noop$1,
4493
+ d: function destroy(detaching) {
4494
+ if (detaching) detach_dev(div);
4495
+ mounted = false;
4496
+ dispose();
4497
+ }
4498
+ };
4499
+
4500
+ dispatch_dev("SvelteRegisterBlock", {
4501
+ block,
4502
+ id: create_if_block_1.name,
4503
+ type: "if",
4504
+ source: "(81:2) {#if isMobile}",
4505
+ ctx
4506
+ });
4507
+
4508
+ return block;
4509
+ }
4510
+
4511
+ // (94:2) {:else}
4512
+ function create_else_block(ctx) {
4513
+ let div;
4514
+ let iframe;
4515
+ let iframe_src_value;
4516
+
4517
+ const block = {
4518
+ c: function create() {
4519
+ div = element("div");
4520
+ iframe = element("iframe");
4521
+ if (iframe.src !== (iframe_src_value = /*iframeUrl*/ ctx[1])) attr_dev(iframe, "src", iframe_src_value);
4522
+ attr_dev(iframe, "title", "Withdrawal Iframe");
4523
+ add_location(iframe, file, 95, 6, 3359);
4524
+ attr_dev(div, "class", "WithdrawalIframeWrapper");
4525
+ add_location(div, file, 94, 4, 3315);
4526
+ },
4527
+ m: function mount(target, anchor) {
4528
+ insert_dev(target, div, anchor);
4529
+ append_dev(div, iframe);
4530
+ },
4531
+ p: function update(ctx, dirty) {
4532
+ if (dirty & /*iframeUrl*/ 2 && iframe.src !== (iframe_src_value = /*iframeUrl*/ ctx[1])) {
4533
+ attr_dev(iframe, "src", iframe_src_value);
4534
+ }
4535
+ },
4536
+ d: function destroy(detaching) {
4537
+ if (detaching) detach_dev(div);
4538
+ }
4539
+ };
4540
+
4541
+ dispatch_dev("SvelteRegisterBlock", {
4542
+ block,
4543
+ id: create_else_block.name,
4544
+ type: "else",
4545
+ source: "(94:2) {:else}",
4546
+ ctx
4547
+ });
4548
+
4549
+ return block;
4550
+ }
4551
+
4552
+ // (92:2) {#if isLoading}
4553
+ function create_if_block(ctx) {
4554
+ let p;
4555
+
4556
+ const block = {
4557
+ c: function create() {
4558
+ p = element("p");
4559
+ p.textContent = "Loading, please wait ...";
4560
+ add_location(p, file, 92, 4, 3269);
4561
+ },
4562
+ m: function mount(target, anchor) {
4563
+ insert_dev(target, p, anchor);
4564
+ },
4565
+ p: noop$1,
4566
+ d: function destroy(detaching) {
4567
+ if (detaching) detach_dev(p);
4568
+ }
4569
+ };
4570
+
4571
+ dispatch_dev("SvelteRegisterBlock", {
4572
+ block,
4573
+ id: create_if_block.name,
4574
+ type: "if",
4575
+ source: "(92:2) {#if isLoading}",
4576
+ ctx
4577
+ });
4578
+
4579
+ return block;
4580
+ }
4581
+
4582
+ function create_fragment(ctx) {
4583
+ let div;
4584
+ let t0;
4585
+ let h2;
4586
+ let t1;
4587
+ let t2;
4588
+ let if_block0 = /*isMobile*/ ctx[2] && create_if_block_1(ctx);
4589
+
4590
+ function select_block_type(ctx, dirty) {
4591
+ if (/*isLoading*/ ctx[0]) return create_if_block;
4592
+ return create_else_block;
4593
+ }
4594
+
4595
+ let current_block_type = select_block_type(ctx);
4596
+ let if_block1 = current_block_type(ctx);
4597
+
4598
+ const block = {
4599
+ c: function create() {
4600
+ div = element("div");
4601
+ if (if_block0) if_block0.c();
4602
+ t0 = space();
4603
+ h2 = element("h2");
4604
+ t1 = text("Withdrawal");
4605
+ t2 = space();
4606
+ if_block1.c();
4607
+ this.c = noop$1;
4608
+ attr_dev(h2, "class", "WithdrawalTitle " + (/*isMobile*/ ctx[2] ? "WithdrawalTitleNone" : ""));
4609
+ add_location(h2, file, 90, 2, 3163);
4610
+ attr_dev(div, "class", "WithdrawalWrapper " + (/*isMobile*/ ctx[2] ? "WithdrawalWrapperMobile" : ""));
4611
+ add_location(div, file, 79, 0, 2536);
4612
+ },
4613
+ l: function claim(nodes) {
4614
+ throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
4615
+ },
4616
+ m: function mount(target, anchor) {
4617
+ insert_dev(target, div, anchor);
4618
+ if (if_block0) if_block0.m(div, null);
4619
+ append_dev(div, t0);
4620
+ append_dev(div, h2);
4621
+ append_dev(h2, t1);
4622
+ append_dev(div, t2);
4623
+ if_block1.m(div, null);
4624
+ },
4625
+ p: function update(ctx, [dirty]) {
4626
+ if (/*isMobile*/ ctx[2]) if_block0.p(ctx, dirty);
4627
+
4628
+ if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block1) {
4629
+ if_block1.p(ctx, dirty);
4630
+ } else {
4631
+ if_block1.d(1);
4632
+ if_block1 = current_block_type(ctx);
4633
+
4634
+ if (if_block1) {
4635
+ if_block1.c();
4636
+ if_block1.m(div, null);
4637
+ }
4638
+ }
4639
+ },
4640
+ i: noop$1,
4641
+ o: noop$1,
4642
+ d: function destroy(detaching) {
4643
+ if (detaching) detach_dev(div);
4644
+ if (if_block0) if_block0.d();
4645
+ if_block1.d();
4646
+ }
4647
+ };
4648
+
4649
+ dispatch_dev("SvelteRegisterBlock", {
4650
+ block,
4651
+ id: create_fragment.name,
4652
+ type: "component",
4653
+ source: "",
4654
+ ctx
4655
+ });
4656
+
4657
+ return block;
4658
+ }
4659
+
4660
+ function instance($$self, $$props, $$invalidate) {
4661
+ let { $$slots: slots = {}, $$scope } = $$props;
4662
+ validate_slots("undefined", slots, []);
4663
+ let { endpoint = "" } = $$props;
4664
+ let { session = "" } = $$props;
4665
+ let { playerid = "" } = $$props;
4666
+ let userAgent = window.navigator.userAgent;
4667
+ let isMobile = getDevice(userAgent) === "PC" ? false : true;
4668
+ let isLoading = true;
4669
+ let currency = "";
4670
+ let amount = 0;
4671
+ let iframeUrl = "";
4672
+
4673
+ const toggleScreen = () => {
4674
+ window.postMessage({ type: "ReturnToMenu" }, window.location.href);
4675
+ };
4676
+
4677
+ const messageHandler = e => {
4678
+ if (e.data) {
4679
+ switch (e.data.type) {
4680
+ case "ProfileDetailsData":
4681
+ currency = e.data.profileDetails.currency;
4682
+ break;
4683
+ }
4684
+
4685
+ switch (e.data.redirect) {
4686
+ case "mm-hc-casino":
4687
+ window.postMessage({ type: "GoToCasino" }, window.location.href);
4688
+ break;
4689
+ case "mm-hc-sports":
4690
+ window.postMessage({ type: "GoToSports" }, window.location.href);
4691
+ break;
4692
+ case "mm-hc-contact":
4693
+ window.postMessage({ type: "GoToCustomerSupport" }, window.location.href);
4694
+ break;
4695
+ case "mm-hc-back-to-merchant":
4696
+ window.postMessage({ type: "GoToHomepage" }, window.location.href);
4697
+ break;
4698
+ case "mm-wm-hc-init-deposit":
4699
+ window.postMessage({ type: "GoToDeposit" }, window.location.href);
4700
+ break;
4701
+ }
4702
+ }
4703
+ };
4704
+
4705
+ const getWithdrawalIframe = () => {
4706
+ let url = new URL(`${endpoint}/player/${playerid}/hostedcashier/initializewithdraw`);
4707
+
4708
+ let options = {
4709
+ method: "POST",
4710
+ headers: {
4711
+ "playerId": playerid,
4712
+ "X-SessionId": session,
4713
+ currency,
4714
+ amount,
4715
+ "cashierMode": "Default",
4716
+ "IsShortCashier": false,
4717
+ "accept": "application/json"
4718
+ }
4719
+ };
4720
+
4721
+ fetch(url, options).then(res => res.json()).then(
4722
+ data => {
4723
+ $$invalidate(0, isLoading = false);
4724
+ $$invalidate(1, iframeUrl = data.CashierUrl);
4725
+ },
4726
+ err => {
4727
+ console.error(err);
4728
+ }
4729
+ );
4730
+ };
4731
+
4732
+ onMount(() => {
4733
+ window.addEventListener("message", messageHandler, false);
4734
+
4735
+ return () => {
4736
+ window.removeEventListener("message", messageHandler);
4737
+ };
4738
+ });
4739
+
4740
+ const writable_props = ["endpoint", "session", "playerid"];
4741
+
4742
+ Object.keys($$props).forEach(key => {
4743
+ if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console_1.warn(`<undefined> was created with unknown prop '${key}'`);
4744
+ });
4745
+
4746
+ const click_handler = () => toggleScreen();
4747
+
4748
+ $$self.$$set = $$props => {
4749
+ if ("endpoint" in $$props) $$invalidate(4, endpoint = $$props.endpoint);
4750
+ if ("session" in $$props) $$invalidate(5, session = $$props.session);
4751
+ if ("playerid" in $$props) $$invalidate(6, playerid = $$props.playerid);
4752
+ };
4753
+
4754
+ $$self.$capture_state = () => ({
4755
+ onMount,
4756
+ getDevice,
4757
+ endpoint,
4758
+ session,
4759
+ playerid,
4760
+ userAgent,
4761
+ isMobile,
4762
+ isLoading,
4763
+ currency,
4764
+ amount,
4765
+ iframeUrl,
4766
+ toggleScreen,
4767
+ messageHandler,
4768
+ getWithdrawalIframe
4769
+ });
4770
+
4771
+ $$self.$inject_state = $$props => {
4772
+ if ("endpoint" in $$props) $$invalidate(4, endpoint = $$props.endpoint);
4773
+ if ("session" in $$props) $$invalidate(5, session = $$props.session);
4774
+ if ("playerid" in $$props) $$invalidate(6, playerid = $$props.playerid);
4775
+ if ("userAgent" in $$props) userAgent = $$props.userAgent;
4776
+ if ("isMobile" in $$props) $$invalidate(2, isMobile = $$props.isMobile);
4777
+ if ("isLoading" in $$props) $$invalidate(0, isLoading = $$props.isLoading);
4778
+ if ("currency" in $$props) currency = $$props.currency;
4779
+ if ("amount" in $$props) amount = $$props.amount;
4780
+ if ("iframeUrl" in $$props) $$invalidate(1, iframeUrl = $$props.iframeUrl);
4781
+ };
4782
+
4783
+ if ($$props && "$$inject" in $$props) {
4784
+ $$self.$inject_state($$props.$$inject);
4785
+ }
4786
+
4787
+ $$self.$$.update = () => {
4788
+ if ($$self.$$.dirty & /*session, playerid, endpoint*/ 112) {
4789
+ session && playerid && endpoint && getWithdrawalIframe();
4790
+ }
4791
+ };
4792
+
4793
+ return [
4794
+ isLoading,
4795
+ iframeUrl,
4796
+ isMobile,
4797
+ toggleScreen,
4798
+ endpoint,
4799
+ session,
4800
+ playerid,
4801
+ click_handler
4802
+ ];
4803
+ }
4804
+
4805
+ class PlayerWithdrawal extends SvelteElement {
4806
+ constructor(options) {
4807
+ super();
4808
+ this.shadowRoot.innerHTML = `<style>.WithdrawalWrapper{color:#07072A;padding:50px 50px 30px 50px;max-width:100%}.WithdrawalWrapper.WithdrawalWrapperMobile{padding:20px 15px;max-width:unset}.MenuReturnButton{color:#D0046C;display:inline-flex;align-items:center;column-gap:10px;margin-bottom:30px}.MenuReturnButton svg{fill:#D0046C}.WithdrawalTitle{font-size:26px;color:#D0046C;font-weight:400}.WithdrawalTitleMobile{font-size:16px}.WithdrawalTitleNone{display:none}.WithdrawalIframeWrapper iframe{border:none;width:100%;height:85vh}</style>`;
4809
+
4810
+ init(
4811
+ this,
4812
+ {
4813
+ target: this.shadowRoot,
4814
+ props: attribute_to_object(this.attributes),
4815
+ customElement: true
4816
+ },
4817
+ instance,
4818
+ create_fragment,
4819
+ safe_not_equal,
4820
+ { endpoint: 4, session: 5, playerid: 6 }
4821
+ );
4822
+
4823
+ if (options) {
4824
+ if (options.target) {
4825
+ insert_dev(options.target, this, options.anchor);
4826
+ }
4827
+
4828
+ if (options.props) {
4829
+ this.$set(options.props);
4830
+ flush();
4831
+ }
4832
+ }
4833
+ }
4834
+
4835
+ static get observedAttributes() {
4836
+ return ["endpoint", "session", "playerid"];
4837
+ }
4838
+
4839
+ get endpoint() {
4840
+ return this.$$.ctx[4];
4841
+ }
4842
+
4843
+ set endpoint(endpoint) {
4844
+ this.$set({ endpoint });
4845
+ flush();
4846
+ }
4847
+
4848
+ get session() {
4849
+ return this.$$.ctx[5];
4850
+ }
4851
+
4852
+ set session(session) {
4853
+ this.$set({ session });
4854
+ flush();
4855
+ }
4856
+
4857
+ get playerid() {
4858
+ return this.$$.ctx[6];
4859
+ }
4860
+
4861
+ set playerid(playerid) {
4862
+ this.$set({ playerid });
4863
+ flush();
4864
+ }
4865
+ }
4866
+
4867
+ !customElements.get('player-withdrawal') && customElements.define('player-withdrawal', PlayerWithdrawal);
4868
+
4869
+ return PlayerWithdrawal;
4870
+
4871
+ })));
4872
+ //# sourceMappingURL=player-withdrawal.js.map