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