@everymatrix/casino-tournaments-thumbnail-duration 1.31.1 → 1.31.2

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,3857 @@
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() { }
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 validate_store(store, name) {
32
+ if (store != null && typeof store.subscribe !== 'function') {
33
+ throw new Error(`'${name}' is not a store with a 'subscribe' method`);
34
+ }
35
+ }
36
+ function subscribe(store, ...callbacks) {
37
+ if (store == null) {
38
+ return noop;
39
+ }
40
+ const unsub = store.subscribe(...callbacks);
41
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
42
+ }
43
+ function component_subscribe(component, store, callback) {
44
+ component.$$.on_destroy.push(subscribe(store, callback));
45
+ }
46
+ function action_destroyer(action_result) {
47
+ return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;
48
+ }
49
+
50
+ function append(target, node) {
51
+ target.appendChild(node);
52
+ }
53
+ function insert(target, node, anchor) {
54
+ target.insertBefore(node, anchor || null);
55
+ }
56
+ function detach(node) {
57
+ node.parentNode.removeChild(node);
58
+ }
59
+ function element(name) {
60
+ return document.createElement(name);
61
+ }
62
+ function text(data) {
63
+ return document.createTextNode(data);
64
+ }
65
+ function space() {
66
+ return text(' ');
67
+ }
68
+ function empty() {
69
+ return text('');
70
+ }
71
+ function attr(node, attribute, value) {
72
+ if (value == null)
73
+ node.removeAttribute(attribute);
74
+ else if (node.getAttribute(attribute) !== value)
75
+ node.setAttribute(attribute, value);
76
+ }
77
+ function children(element) {
78
+ return Array.from(element.childNodes);
79
+ }
80
+ function set_style(node, key, value, important) {
81
+ node.style.setProperty(key, value, important ? 'important' : '');
82
+ }
83
+ function custom_event(type, detail) {
84
+ const e = document.createEvent('CustomEvent');
85
+ e.initCustomEvent(type, false, false, detail);
86
+ return e;
87
+ }
88
+ function attribute_to_object(attributes) {
89
+ const result = {};
90
+ for (const attribute of attributes) {
91
+ result[attribute.name] = attribute.value;
92
+ }
93
+ return result;
94
+ }
95
+
96
+ let current_component;
97
+ function set_current_component(component) {
98
+ current_component = component;
99
+ }
100
+
101
+ const dirty_components = [];
102
+ const binding_callbacks = [];
103
+ const render_callbacks = [];
104
+ const flush_callbacks = [];
105
+ const resolved_promise = Promise.resolve();
106
+ let update_scheduled = false;
107
+ function schedule_update() {
108
+ if (!update_scheduled) {
109
+ update_scheduled = true;
110
+ resolved_promise.then(flush);
111
+ }
112
+ }
113
+ function add_render_callback(fn) {
114
+ render_callbacks.push(fn);
115
+ }
116
+ let flushing = false;
117
+ const seen_callbacks = new Set();
118
+ function flush() {
119
+ if (flushing)
120
+ return;
121
+ flushing = true;
122
+ do {
123
+ // first, call beforeUpdate functions
124
+ // and update components
125
+ for (let i = 0; i < dirty_components.length; i += 1) {
126
+ const component = dirty_components[i];
127
+ set_current_component(component);
128
+ update(component.$$);
129
+ }
130
+ set_current_component(null);
131
+ dirty_components.length = 0;
132
+ while (binding_callbacks.length)
133
+ binding_callbacks.pop()();
134
+ // then, once components are updated, call
135
+ // afterUpdate functions. This may cause
136
+ // subsequent updates...
137
+ for (let i = 0; i < render_callbacks.length; i += 1) {
138
+ const callback = render_callbacks[i];
139
+ if (!seen_callbacks.has(callback)) {
140
+ // ...so guard against infinite loops
141
+ seen_callbacks.add(callback);
142
+ callback();
143
+ }
144
+ }
145
+ render_callbacks.length = 0;
146
+ } while (dirty_components.length);
147
+ while (flush_callbacks.length) {
148
+ flush_callbacks.pop()();
149
+ }
150
+ update_scheduled = false;
151
+ flushing = false;
152
+ seen_callbacks.clear();
153
+ }
154
+ function update($$) {
155
+ if ($$.fragment !== null) {
156
+ $$.update();
157
+ run_all($$.before_update);
158
+ const dirty = $$.dirty;
159
+ $$.dirty = [-1];
160
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
161
+ $$.after_update.forEach(add_render_callback);
162
+ }
163
+ }
164
+ const outroing = new Set();
165
+ function transition_in(block, local) {
166
+ if (block && block.i) {
167
+ outroing.delete(block);
168
+ block.i(local);
169
+ }
170
+ }
171
+
172
+ const globals = (typeof window !== 'undefined'
173
+ ? window
174
+ : typeof globalThis !== 'undefined'
175
+ ? globalThis
176
+ : global);
177
+ function mount_component(component, target, anchor, customElement) {
178
+ const { fragment, on_mount, on_destroy, after_update } = component.$$;
179
+ fragment && fragment.m(target, anchor);
180
+ if (!customElement) {
181
+ // onMount happens before the initial afterUpdate
182
+ add_render_callback(() => {
183
+ const new_on_destroy = on_mount.map(run).filter(is_function);
184
+ if (on_destroy) {
185
+ on_destroy.push(...new_on_destroy);
186
+ }
187
+ else {
188
+ // Edge case - component was destroyed immediately,
189
+ // most likely as a result of a binding initialising
190
+ run_all(new_on_destroy);
191
+ }
192
+ component.$$.on_mount = [];
193
+ });
194
+ }
195
+ after_update.forEach(add_render_callback);
196
+ }
197
+ function destroy_component(component, detaching) {
198
+ const $$ = component.$$;
199
+ if ($$.fragment !== null) {
200
+ run_all($$.on_destroy);
201
+ $$.fragment && $$.fragment.d(detaching);
202
+ // TODO null out other refs, including component.$$ (but need to
203
+ // preserve final state?)
204
+ $$.on_destroy = $$.fragment = null;
205
+ $$.ctx = [];
206
+ }
207
+ }
208
+ function make_dirty(component, i) {
209
+ if (component.$$.dirty[0] === -1) {
210
+ dirty_components.push(component);
211
+ schedule_update();
212
+ component.$$.dirty.fill(0);
213
+ }
214
+ component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
215
+ }
216
+ function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
217
+ const parent_component = current_component;
218
+ set_current_component(component);
219
+ const $$ = component.$$ = {
220
+ fragment: null,
221
+ ctx: null,
222
+ // state
223
+ props,
224
+ update: noop,
225
+ not_equal,
226
+ bound: blank_object(),
227
+ // lifecycle
228
+ on_mount: [],
229
+ on_destroy: [],
230
+ on_disconnect: [],
231
+ before_update: [],
232
+ after_update: [],
233
+ context: new Map(parent_component ? parent_component.$$.context : options.context || []),
234
+ // everything else
235
+ callbacks: blank_object(),
236
+ dirty,
237
+ skip_bound: false
238
+ };
239
+ let ready = false;
240
+ $$.ctx = instance
241
+ ? instance(component, options.props || {}, (i, ret, ...rest) => {
242
+ const value = rest.length ? rest[0] : ret;
243
+ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
244
+ if (!$$.skip_bound && $$.bound[i])
245
+ $$.bound[i](value);
246
+ if (ready)
247
+ make_dirty(component, i);
248
+ }
249
+ return ret;
250
+ })
251
+ : [];
252
+ $$.update();
253
+ ready = true;
254
+ run_all($$.before_update);
255
+ // `false` as a special case of no DOM component
256
+ $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
257
+ if (options.target) {
258
+ if (options.hydrate) {
259
+ const nodes = children(options.target);
260
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
261
+ $$.fragment && $$.fragment.l(nodes);
262
+ nodes.forEach(detach);
263
+ }
264
+ else {
265
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
266
+ $$.fragment && $$.fragment.c();
267
+ }
268
+ if (options.intro)
269
+ transition_in(component.$$.fragment);
270
+ mount_component(component, options.target, options.anchor, options.customElement);
271
+ flush();
272
+ }
273
+ set_current_component(parent_component);
274
+ }
275
+ let SvelteElement;
276
+ if (typeof HTMLElement === 'function') {
277
+ SvelteElement = class extends HTMLElement {
278
+ constructor() {
279
+ super();
280
+ this.attachShadow({ mode: 'open' });
281
+ }
282
+ connectedCallback() {
283
+ const { on_mount } = this.$$;
284
+ this.$$.on_disconnect = on_mount.map(run).filter(is_function);
285
+ // @ts-ignore todo: improve typings
286
+ for (const key in this.$$.slotted) {
287
+ // @ts-ignore todo: improve typings
288
+ this.appendChild(this.$$.slotted[key]);
289
+ }
290
+ }
291
+ attributeChangedCallback(attr, _oldValue, newValue) {
292
+ this[attr] = newValue;
293
+ }
294
+ disconnectedCallback() {
295
+ run_all(this.$$.on_disconnect);
296
+ }
297
+ $destroy() {
298
+ destroy_component(this, 1);
299
+ this.$destroy = noop;
300
+ }
301
+ $on(type, callback) {
302
+ // TODO should this delegate to addEventListener?
303
+ const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
304
+ callbacks.push(callback);
305
+ return () => {
306
+ const index = callbacks.indexOf(callback);
307
+ if (index !== -1)
308
+ callbacks.splice(index, 1);
309
+ };
310
+ }
311
+ $set($$props) {
312
+ if (this.$$set && !is_empty($$props)) {
313
+ this.$$.skip_bound = true;
314
+ this.$$set($$props);
315
+ this.$$.skip_bound = false;
316
+ }
317
+ }
318
+ };
319
+ }
320
+
321
+ function dispatch_dev(type, detail) {
322
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.37.0' }, detail)));
323
+ }
324
+ function append_dev(target, node) {
325
+ dispatch_dev('SvelteDOMInsert', { target, node });
326
+ append(target, node);
327
+ }
328
+ function insert_dev(target, node, anchor) {
329
+ dispatch_dev('SvelteDOMInsert', { target, node, anchor });
330
+ insert(target, node, anchor);
331
+ }
332
+ function detach_dev(node) {
333
+ dispatch_dev('SvelteDOMRemove', { node });
334
+ detach(node);
335
+ }
336
+ function attr_dev(node, attribute, value) {
337
+ attr(node, attribute, value);
338
+ if (value == null)
339
+ dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
340
+ else
341
+ dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
342
+ }
343
+ function set_data_dev(text, data) {
344
+ data = '' + data;
345
+ if (text.wholeText === data)
346
+ return;
347
+ dispatch_dev('SvelteDOMSetData', { node: text, data });
348
+ text.data = data;
349
+ }
350
+ function validate_slots(name, slot, keys) {
351
+ for (const slot_key of Object.keys(slot)) {
352
+ if (!~keys.indexOf(slot_key)) {
353
+ console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
354
+ }
355
+ }
356
+ }
357
+
358
+ const subscriber_queue = [];
359
+ /**
360
+ * Creates a `Readable` store that allows reading by subscription.
361
+ * @param value initial value
362
+ * @param {StartStopNotifier}start start and stop notifications for subscriptions
363
+ */
364
+ function readable(value, start) {
365
+ return {
366
+ subscribe: writable(value, start).subscribe
367
+ };
368
+ }
369
+ /**
370
+ * Create a `Writable` store that allows both updating and reading by subscription.
371
+ * @param {*=}value initial value
372
+ * @param {StartStopNotifier=}start start and stop notifications for subscriptions
373
+ */
374
+ function writable(value, start = noop) {
375
+ let stop;
376
+ const subscribers = [];
377
+ function set(new_value) {
378
+ if (safe_not_equal(value, new_value)) {
379
+ value = new_value;
380
+ if (stop) { // store is ready
381
+ const run_queue = !subscriber_queue.length;
382
+ for (let i = 0; i < subscribers.length; i += 1) {
383
+ const s = subscribers[i];
384
+ s[1]();
385
+ subscriber_queue.push(s, value);
386
+ }
387
+ if (run_queue) {
388
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
389
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
390
+ }
391
+ subscriber_queue.length = 0;
392
+ }
393
+ }
394
+ }
395
+ }
396
+ function update(fn) {
397
+ set(fn(value));
398
+ }
399
+ function subscribe(run, invalidate = noop) {
400
+ const subscriber = [run, invalidate];
401
+ subscribers.push(subscriber);
402
+ if (subscribers.length === 1) {
403
+ stop = start(set) || noop;
404
+ }
405
+ run(value);
406
+ return () => {
407
+ const index = subscribers.indexOf(subscriber);
408
+ if (index !== -1) {
409
+ subscribers.splice(index, 1);
410
+ }
411
+ if (subscribers.length === 0) {
412
+ stop();
413
+ stop = null;
414
+ }
415
+ };
416
+ }
417
+ return { set, update, subscribe };
418
+ }
419
+ function derived(stores, fn, initial_value) {
420
+ const single = !Array.isArray(stores);
421
+ const stores_array = single
422
+ ? [stores]
423
+ : stores;
424
+ const auto = fn.length < 2;
425
+ return readable(initial_value, (set) => {
426
+ let inited = false;
427
+ const values = [];
428
+ let pending = 0;
429
+ let cleanup = noop;
430
+ const sync = () => {
431
+ if (pending) {
432
+ return;
433
+ }
434
+ cleanup();
435
+ const result = fn(single ? values[0] : values, set);
436
+ if (auto) {
437
+ set(result);
438
+ }
439
+ else {
440
+ cleanup = is_function(result) ? result : noop;
441
+ }
442
+ };
443
+ const unsubscribers = stores_array.map((store, i) => subscribe(store, (value) => {
444
+ values[i] = value;
445
+ pending &= ~(1 << i);
446
+ if (inited) {
447
+ sync();
448
+ }
449
+ }, () => {
450
+ pending |= (1 << i);
451
+ }));
452
+ inited = true;
453
+ sync();
454
+ return function stop() {
455
+ run_all(unsubscribers);
456
+ cleanup();
457
+ };
458
+ });
459
+ }
460
+
461
+ var isMergeableObject = function isMergeableObject(value) {
462
+ return isNonNullObject(value)
463
+ && !isSpecial(value)
464
+ };
465
+
466
+ function isNonNullObject(value) {
467
+ return !!value && typeof value === 'object'
468
+ }
469
+
470
+ function isSpecial(value) {
471
+ var stringValue = Object.prototype.toString.call(value);
472
+
473
+ return stringValue === '[object RegExp]'
474
+ || stringValue === '[object Date]'
475
+ || isReactElement(value)
476
+ }
477
+
478
+ // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
479
+ var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
480
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
481
+
482
+ function isReactElement(value) {
483
+ return value.$$typeof === REACT_ELEMENT_TYPE
484
+ }
485
+
486
+ function emptyTarget(val) {
487
+ return Array.isArray(val) ? [] : {}
488
+ }
489
+
490
+ function cloneUnlessOtherwiseSpecified(value, options) {
491
+ return (options.clone !== false && options.isMergeableObject(value))
492
+ ? deepmerge(emptyTarget(value), value, options)
493
+ : value
494
+ }
495
+
496
+ function defaultArrayMerge(target, source, options) {
497
+ return target.concat(source).map(function(element) {
498
+ return cloneUnlessOtherwiseSpecified(element, options)
499
+ })
500
+ }
501
+
502
+ function getMergeFunction(key, options) {
503
+ if (!options.customMerge) {
504
+ return deepmerge
505
+ }
506
+ var customMerge = options.customMerge(key);
507
+ return typeof customMerge === 'function' ? customMerge : deepmerge
508
+ }
509
+
510
+ function getEnumerableOwnPropertySymbols(target) {
511
+ return Object.getOwnPropertySymbols
512
+ ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
513
+ return target.propertyIsEnumerable(symbol)
514
+ })
515
+ : []
516
+ }
517
+
518
+ function getKeys(target) {
519
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
520
+ }
521
+
522
+ function propertyIsOnObject(object, property) {
523
+ try {
524
+ return property in object
525
+ } catch(_) {
526
+ return false
527
+ }
528
+ }
529
+
530
+ // Protects from prototype poisoning and unexpected merging up the prototype chain.
531
+ function propertyIsUnsafe(target, key) {
532
+ return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
533
+ && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
534
+ && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
535
+ }
536
+
537
+ function mergeObject(target, source, options) {
538
+ var destination = {};
539
+ if (options.isMergeableObject(target)) {
540
+ getKeys(target).forEach(function(key) {
541
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
542
+ });
543
+ }
544
+ getKeys(source).forEach(function(key) {
545
+ if (propertyIsUnsafe(target, key)) {
546
+ return
547
+ }
548
+
549
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
550
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
551
+ } else {
552
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
553
+ }
554
+ });
555
+ return destination
556
+ }
557
+
558
+ function deepmerge(target, source, options) {
559
+ options = options || {};
560
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
561
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
562
+ // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
563
+ // implementations can use it. The caller may not replace it.
564
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
565
+
566
+ var sourceIsArray = Array.isArray(source);
567
+ var targetIsArray = Array.isArray(target);
568
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
569
+
570
+ if (!sourceAndTargetTypesMatch) {
571
+ return cloneUnlessOtherwiseSpecified(source, options)
572
+ } else if (sourceIsArray) {
573
+ return options.arrayMerge(target, source, options)
574
+ } else {
575
+ return mergeObject(target, source, options)
576
+ }
577
+ }
578
+
579
+ deepmerge.all = function deepmergeAll(array, options) {
580
+ if (!Array.isArray(array)) {
581
+ throw new Error('first argument should be an array')
582
+ }
583
+
584
+ return array.reduce(function(prev, next) {
585
+ return deepmerge(prev, next, options)
586
+ }, {})
587
+ };
588
+
589
+ var deepmerge_1 = deepmerge;
590
+
591
+ var cjs = deepmerge_1;
592
+
593
+ /*! *****************************************************************************
594
+ Copyright (c) Microsoft Corporation.
595
+
596
+ Permission to use, copy, modify, and/or distribute this software for any
597
+ purpose with or without fee is hereby granted.
598
+
599
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
600
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
601
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
602
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
603
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
604
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
605
+ PERFORMANCE OF THIS SOFTWARE.
606
+ ***************************************************************************** */
607
+ /* global Reflect, Promise */
608
+
609
+ var extendStatics = function(d, b) {
610
+ extendStatics = Object.setPrototypeOf ||
611
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
612
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
613
+ return extendStatics(d, b);
614
+ };
615
+
616
+ function __extends(d, b) {
617
+ if (typeof b !== "function" && b !== null)
618
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
619
+ extendStatics(d, b);
620
+ function __() { this.constructor = d; }
621
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
622
+ }
623
+
624
+ var __assign = function() {
625
+ __assign = Object.assign || function __assign(t) {
626
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
627
+ s = arguments[i];
628
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
629
+ }
630
+ return t;
631
+ };
632
+ return __assign.apply(this, arguments);
633
+ };
634
+
635
+ function __spreadArray(to, from) {
636
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
637
+ to[j] = from[i];
638
+ return to;
639
+ }
640
+
641
+ var ErrorKind;
642
+ (function (ErrorKind) {
643
+ /** Argument is unclosed (e.g. `{0`) */
644
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
645
+ /** Argument is empty (e.g. `{}`). */
646
+ ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
647
+ /** Argument is malformed (e.g. `{foo!}``) */
648
+ ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
649
+ /** Expect an argument type (e.g. `{foo,}`) */
650
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
651
+ /** Unsupported argument type (e.g. `{foo,foo}`) */
652
+ ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
653
+ /** Expect an argument style (e.g. `{foo, number, }`) */
654
+ ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
655
+ /** The number skeleton is invalid. */
656
+ ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
657
+ /** The date time skeleton is invalid. */
658
+ ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
659
+ /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */
660
+ ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
661
+ /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */
662
+ ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
663
+ /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */
664
+ ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
665
+ /** Missing select argument options (e.g. `{foo, select}`) */
666
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
667
+ /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */
668
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
669
+ /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */
670
+ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
671
+ /** Expecting a selector in `select` argument (e.g `{foo, select}`) */
672
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
673
+ /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */
674
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
675
+ /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */
676
+ ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
677
+ /**
678
+ * Expecting a message fragment after the `plural` or `selectordinal` selector
679
+ * (e.g. `{foo, plural, one}`)
680
+ */
681
+ ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
682
+ /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */
683
+ ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
684
+ /**
685
+ * Duplicate selectors in `plural` or `selectordinal` argument.
686
+ * (e.g. {foo, plural, one {#} one {#}})
687
+ */
688
+ ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
689
+ /** Duplicate selectors in `select` argument.
690
+ * (e.g. {foo, select, apple {apple} apple {apple}})
691
+ */
692
+ ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
693
+ /** Plural or select argument option must have `other` clause. */
694
+ ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
695
+ /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */
696
+ ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG";
697
+ /** The tag name is invalid. (e.g. `<123>foo</123>`) */
698
+ ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
699
+ /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */
700
+ ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
701
+ /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */
702
+ ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
703
+ })(ErrorKind || (ErrorKind = {}));
704
+
705
+ var TYPE;
706
+ (function (TYPE) {
707
+ /**
708
+ * Raw text
709
+ */
710
+ TYPE[TYPE["literal"] = 0] = "literal";
711
+ /**
712
+ * Variable w/o any format, e.g `var` in `this is a {var}`
713
+ */
714
+ TYPE[TYPE["argument"] = 1] = "argument";
715
+ /**
716
+ * Variable w/ number format
717
+ */
718
+ TYPE[TYPE["number"] = 2] = "number";
719
+ /**
720
+ * Variable w/ date format
721
+ */
722
+ TYPE[TYPE["date"] = 3] = "date";
723
+ /**
724
+ * Variable w/ time format
725
+ */
726
+ TYPE[TYPE["time"] = 4] = "time";
727
+ /**
728
+ * Variable w/ select format
729
+ */
730
+ TYPE[TYPE["select"] = 5] = "select";
731
+ /**
732
+ * Variable w/ plural format
733
+ */
734
+ TYPE[TYPE["plural"] = 6] = "plural";
735
+ /**
736
+ * Only possible within plural argument.
737
+ * This is the `#` symbol that will be substituted with the count.
738
+ */
739
+ TYPE[TYPE["pound"] = 7] = "pound";
740
+ /**
741
+ * XML-like tag
742
+ */
743
+ TYPE[TYPE["tag"] = 8] = "tag";
744
+ })(TYPE || (TYPE = {}));
745
+ var SKELETON_TYPE;
746
+ (function (SKELETON_TYPE) {
747
+ SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
748
+ SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
749
+ })(SKELETON_TYPE || (SKELETON_TYPE = {}));
750
+ /**
751
+ * Type Guards
752
+ */
753
+ function isLiteralElement(el) {
754
+ return el.type === TYPE.literal;
755
+ }
756
+ function isArgumentElement(el) {
757
+ return el.type === TYPE.argument;
758
+ }
759
+ function isNumberElement(el) {
760
+ return el.type === TYPE.number;
761
+ }
762
+ function isDateElement(el) {
763
+ return el.type === TYPE.date;
764
+ }
765
+ function isTimeElement(el) {
766
+ return el.type === TYPE.time;
767
+ }
768
+ function isSelectElement(el) {
769
+ return el.type === TYPE.select;
770
+ }
771
+ function isPluralElement(el) {
772
+ return el.type === TYPE.plural;
773
+ }
774
+ function isPoundElement(el) {
775
+ return el.type === TYPE.pound;
776
+ }
777
+ function isTagElement(el) {
778
+ return el.type === TYPE.tag;
779
+ }
780
+ function isNumberSkeleton(el) {
781
+ return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);
782
+ }
783
+ function isDateTimeSkeleton(el) {
784
+ return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
785
+ }
786
+
787
+ // @generated from regex-gen.ts
788
+ var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
789
+
790
+ /**
791
+ * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
792
+ * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
793
+ * with some tweaks
794
+ */
795
+ 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;
796
+ /**
797
+ * Parse Date time skeleton into Intl.DateTimeFormatOptions
798
+ * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
799
+ * @public
800
+ * @param skeleton skeleton string
801
+ */
802
+ function parseDateTimeSkeleton(skeleton) {
803
+ var result = {};
804
+ skeleton.replace(DATE_TIME_REGEX, function (match) {
805
+ var len = match.length;
806
+ switch (match[0]) {
807
+ // Era
808
+ case 'G':
809
+ result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
810
+ break;
811
+ // Year
812
+ case 'y':
813
+ result.year = len === 2 ? '2-digit' : 'numeric';
814
+ break;
815
+ case 'Y':
816
+ case 'u':
817
+ case 'U':
818
+ case 'r':
819
+ throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');
820
+ // Quarter
821
+ case 'q':
822
+ case 'Q':
823
+ throw new RangeError('`q/Q` (quarter) patterns are not supported');
824
+ // Month
825
+ case 'M':
826
+ case 'L':
827
+ result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
828
+ break;
829
+ // Week
830
+ case 'w':
831
+ case 'W':
832
+ throw new RangeError('`w/W` (week) patterns are not supported');
833
+ case 'd':
834
+ result.day = ['numeric', '2-digit'][len - 1];
835
+ break;
836
+ case 'D':
837
+ case 'F':
838
+ case 'g':
839
+ throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');
840
+ // Weekday
841
+ case 'E':
842
+ result.weekday = len === 4 ? 'short' : len === 5 ? 'narrow' : 'short';
843
+ break;
844
+ case 'e':
845
+ if (len < 4) {
846
+ throw new RangeError('`e..eee` (weekday) patterns are not supported');
847
+ }
848
+ result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
849
+ break;
850
+ case 'c':
851
+ if (len < 4) {
852
+ throw new RangeError('`c..ccc` (weekday) patterns are not supported');
853
+ }
854
+ result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
855
+ break;
856
+ // Period
857
+ case 'a': // AM, PM
858
+ result.hour12 = true;
859
+ break;
860
+ case 'b': // am, pm, noon, midnight
861
+ case 'B': // flexible day periods
862
+ throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');
863
+ // Hour
864
+ case 'h':
865
+ result.hourCycle = 'h12';
866
+ result.hour = ['numeric', '2-digit'][len - 1];
867
+ break;
868
+ case 'H':
869
+ result.hourCycle = 'h23';
870
+ result.hour = ['numeric', '2-digit'][len - 1];
871
+ break;
872
+ case 'K':
873
+ result.hourCycle = 'h11';
874
+ result.hour = ['numeric', '2-digit'][len - 1];
875
+ break;
876
+ case 'k':
877
+ result.hourCycle = 'h24';
878
+ result.hour = ['numeric', '2-digit'][len - 1];
879
+ break;
880
+ case 'j':
881
+ case 'J':
882
+ case 'C':
883
+ throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
884
+ // Minute
885
+ case 'm':
886
+ result.minute = ['numeric', '2-digit'][len - 1];
887
+ break;
888
+ // Second
889
+ case 's':
890
+ result.second = ['numeric', '2-digit'][len - 1];
891
+ break;
892
+ case 'S':
893
+ case 'A':
894
+ throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead');
895
+ // Zone
896
+ case 'z': // 1..3, 4: specific non-location format
897
+ result.timeZoneName = len < 4 ? 'short' : 'long';
898
+ break;
899
+ case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
900
+ case 'O': // 1, 4: miliseconds in day short, long
901
+ case 'v': // 1, 4: generic non-location format
902
+ case 'V': // 1, 2, 3, 4: time zone ID or city
903
+ case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
904
+ case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
905
+ throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead');
906
+ }
907
+ return '';
908
+ });
909
+ return result;
910
+ }
911
+
912
+ // @generated from regex-gen.ts
913
+ var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
914
+
915
+ function parseNumberSkeletonFromString(skeleton) {
916
+ if (skeleton.length === 0) {
917
+ throw new Error('Number skeleton cannot be empty');
918
+ }
919
+ // Parse the skeleton
920
+ var stringTokens = skeleton
921
+ .split(WHITE_SPACE_REGEX)
922
+ .filter(function (x) { return x.length > 0; });
923
+ var tokens = [];
924
+ for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
925
+ var stringToken = stringTokens_1[_i];
926
+ var stemAndOptions = stringToken.split('/');
927
+ if (stemAndOptions.length === 0) {
928
+ throw new Error('Invalid number skeleton');
929
+ }
930
+ var stem = stemAndOptions[0], options = stemAndOptions.slice(1);
931
+ for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
932
+ var option = options_1[_a];
933
+ if (option.length === 0) {
934
+ throw new Error('Invalid number skeleton');
935
+ }
936
+ }
937
+ tokens.push({ stem: stem, options: options });
938
+ }
939
+ return tokens;
940
+ }
941
+ function icuUnitToEcma(unit) {
942
+ return unit.replace(/^(.*?)-/, '');
943
+ }
944
+ var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
945
+ var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
946
+ var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
947
+ var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
948
+ function parseSignificantPrecision(str) {
949
+ var result = {};
950
+ str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
951
+ // @@@ case
952
+ if (typeof g2 !== 'string') {
953
+ result.minimumSignificantDigits = g1.length;
954
+ result.maximumSignificantDigits = g1.length;
955
+ }
956
+ // @@@+ case
957
+ else if (g2 === '+') {
958
+ result.minimumSignificantDigits = g1.length;
959
+ }
960
+ // .### case
961
+ else if (g1[0] === '#') {
962
+ result.maximumSignificantDigits = g1.length;
963
+ }
964
+ // .@@## or .@@@ case
965
+ else {
966
+ result.minimumSignificantDigits = g1.length;
967
+ result.maximumSignificantDigits =
968
+ g1.length + (typeof g2 === 'string' ? g2.length : 0);
969
+ }
970
+ return '';
971
+ });
972
+ return result;
973
+ }
974
+ function parseSign(str) {
975
+ switch (str) {
976
+ case 'sign-auto':
977
+ return {
978
+ signDisplay: 'auto',
979
+ };
980
+ case 'sign-accounting':
981
+ case '()':
982
+ return {
983
+ currencySign: 'accounting',
984
+ };
985
+ case 'sign-always':
986
+ case '+!':
987
+ return {
988
+ signDisplay: 'always',
989
+ };
990
+ case 'sign-accounting-always':
991
+ case '()!':
992
+ return {
993
+ signDisplay: 'always',
994
+ currencySign: 'accounting',
995
+ };
996
+ case 'sign-except-zero':
997
+ case '+?':
998
+ return {
999
+ signDisplay: 'exceptZero',
1000
+ };
1001
+ case 'sign-accounting-except-zero':
1002
+ case '()?':
1003
+ return {
1004
+ signDisplay: 'exceptZero',
1005
+ currencySign: 'accounting',
1006
+ };
1007
+ case 'sign-never':
1008
+ case '+_':
1009
+ return {
1010
+ signDisplay: 'never',
1011
+ };
1012
+ }
1013
+ }
1014
+ function parseConciseScientificAndEngineeringStem(stem) {
1015
+ // Engineering
1016
+ var result;
1017
+ if (stem[0] === 'E' && stem[1] === 'E') {
1018
+ result = {
1019
+ notation: 'engineering',
1020
+ };
1021
+ stem = stem.slice(2);
1022
+ }
1023
+ else if (stem[0] === 'E') {
1024
+ result = {
1025
+ notation: 'scientific',
1026
+ };
1027
+ stem = stem.slice(1);
1028
+ }
1029
+ if (result) {
1030
+ var signDisplay = stem.slice(0, 2);
1031
+ if (signDisplay === '+!') {
1032
+ result.signDisplay = 'always';
1033
+ stem = stem.slice(2);
1034
+ }
1035
+ else if (signDisplay === '+?') {
1036
+ result.signDisplay = 'exceptZero';
1037
+ stem = stem.slice(2);
1038
+ }
1039
+ if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
1040
+ throw new Error('Malformed concise eng/scientific notation');
1041
+ }
1042
+ result.minimumIntegerDigits = stem.length;
1043
+ }
1044
+ return result;
1045
+ }
1046
+ function parseNotationOptions(opt) {
1047
+ var result = {};
1048
+ var signOpts = parseSign(opt);
1049
+ if (signOpts) {
1050
+ return signOpts;
1051
+ }
1052
+ return result;
1053
+ }
1054
+ /**
1055
+ * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
1056
+ */
1057
+ function parseNumberSkeleton(tokens) {
1058
+ var result = {};
1059
+ for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
1060
+ var token = tokens_1[_i];
1061
+ switch (token.stem) {
1062
+ case 'percent':
1063
+ case '%':
1064
+ result.style = 'percent';
1065
+ continue;
1066
+ case '%x100':
1067
+ result.style = 'percent';
1068
+ result.scale = 100;
1069
+ continue;
1070
+ case 'currency':
1071
+ result.style = 'currency';
1072
+ result.currency = token.options[0];
1073
+ continue;
1074
+ case 'group-off':
1075
+ case ',_':
1076
+ result.useGrouping = false;
1077
+ continue;
1078
+ case 'precision-integer':
1079
+ case '.':
1080
+ result.maximumFractionDigits = 0;
1081
+ continue;
1082
+ case 'measure-unit':
1083
+ case 'unit':
1084
+ result.style = 'unit';
1085
+ result.unit = icuUnitToEcma(token.options[0]);
1086
+ continue;
1087
+ case 'compact-short':
1088
+ case 'K':
1089
+ result.notation = 'compact';
1090
+ result.compactDisplay = 'short';
1091
+ continue;
1092
+ case 'compact-long':
1093
+ case 'KK':
1094
+ result.notation = 'compact';
1095
+ result.compactDisplay = 'long';
1096
+ continue;
1097
+ case 'scientific':
1098
+ result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
1099
+ continue;
1100
+ case 'engineering':
1101
+ result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
1102
+ continue;
1103
+ case 'notation-simple':
1104
+ result.notation = 'standard';
1105
+ continue;
1106
+ // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
1107
+ case 'unit-width-narrow':
1108
+ result.currencyDisplay = 'narrowSymbol';
1109
+ result.unitDisplay = 'narrow';
1110
+ continue;
1111
+ case 'unit-width-short':
1112
+ result.currencyDisplay = 'code';
1113
+ result.unitDisplay = 'short';
1114
+ continue;
1115
+ case 'unit-width-full-name':
1116
+ result.currencyDisplay = 'name';
1117
+ result.unitDisplay = 'long';
1118
+ continue;
1119
+ case 'unit-width-iso-code':
1120
+ result.currencyDisplay = 'symbol';
1121
+ continue;
1122
+ case 'scale':
1123
+ result.scale = parseFloat(token.options[0]);
1124
+ continue;
1125
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
1126
+ case 'integer-width':
1127
+ if (token.options.length > 1) {
1128
+ throw new RangeError('integer-width stems only accept a single optional option');
1129
+ }
1130
+ token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) {
1131
+ if (g1) {
1132
+ result.minimumIntegerDigits = g2.length;
1133
+ }
1134
+ else if (g3 && g4) {
1135
+ throw new Error('We currently do not support maximum integer digits');
1136
+ }
1137
+ else if (g5) {
1138
+ throw new Error('We currently do not support exact integer digits');
1139
+ }
1140
+ return '';
1141
+ });
1142
+ continue;
1143
+ }
1144
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
1145
+ if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
1146
+ result.minimumIntegerDigits = token.stem.length;
1147
+ continue;
1148
+ }
1149
+ if (FRACTION_PRECISION_REGEX.test(token.stem)) {
1150
+ // Precision
1151
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision
1152
+ // precision-integer case
1153
+ if (token.options.length > 1) {
1154
+ throw new RangeError('Fraction-precision stems only accept a single optional option');
1155
+ }
1156
+ token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {
1157
+ // .000* case (before ICU67 it was .000+)
1158
+ if (g2 === '*') {
1159
+ result.minimumFractionDigits = g1.length;
1160
+ }
1161
+ // .### case
1162
+ else if (g3 && g3[0] === '#') {
1163
+ result.maximumFractionDigits = g3.length;
1164
+ }
1165
+ // .00## case
1166
+ else if (g4 && g5) {
1167
+ result.minimumFractionDigits = g4.length;
1168
+ result.maximumFractionDigits = g4.length + g5.length;
1169
+ }
1170
+ else {
1171
+ result.minimumFractionDigits = g1.length;
1172
+ result.maximumFractionDigits = g1.length;
1173
+ }
1174
+ return '';
1175
+ });
1176
+ if (token.options.length) {
1177
+ result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
1178
+ }
1179
+ continue;
1180
+ }
1181
+ // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision
1182
+ if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
1183
+ result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
1184
+ continue;
1185
+ }
1186
+ var signOpts = parseSign(token.stem);
1187
+ if (signOpts) {
1188
+ result = __assign(__assign({}, result), signOpts);
1189
+ }
1190
+ var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
1191
+ if (conciseScientificAndEngineeringOpts) {
1192
+ result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);
1193
+ }
1194
+ }
1195
+ return result;
1196
+ }
1197
+
1198
+ var _a;
1199
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
1200
+ var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
1201
+ function createLocation(start, end) {
1202
+ return { start: start, end: end };
1203
+ }
1204
+ // #region Ponyfills
1205
+ // Consolidate these variables up top for easier toggling during debugging
1206
+ var hasNativeStartsWith = !!String.prototype.startsWith;
1207
+ var hasNativeFromCodePoint = !!String.fromCodePoint;
1208
+ var hasNativeFromEntries = !!Object.fromEntries;
1209
+ var hasNativeCodePointAt = !!String.prototype.codePointAt;
1210
+ var hasTrimStart = !!String.prototype.trimStart;
1211
+ var hasTrimEnd = !!String.prototype.trimEnd;
1212
+ var hasNativeIsSafeInteger = !!Number.isSafeInteger;
1213
+ var isSafeInteger = hasNativeIsSafeInteger
1214
+ ? Number.isSafeInteger
1215
+ : function (n) {
1216
+ return (typeof n === 'number' &&
1217
+ isFinite(n) &&
1218
+ Math.floor(n) === n &&
1219
+ Math.abs(n) <= 0x1fffffffffffff);
1220
+ };
1221
+ // IE11 does not support y and u.
1222
+ var REGEX_SUPPORTS_U_AND_Y = true;
1223
+ try {
1224
+ var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
1225
+ /**
1226
+ * legacy Edge or Xbox One browser
1227
+ * Unicode flag support: supported
1228
+ * Pattern_Syntax support: not supported
1229
+ * See https://github.com/formatjs/formatjs/issues/2822
1230
+ */
1231
+ REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
1232
+ }
1233
+ catch (_) {
1234
+ REGEX_SUPPORTS_U_AND_Y = false;
1235
+ }
1236
+ var startsWith = hasNativeStartsWith
1237
+ ? // Native
1238
+ function startsWith(s, search, position) {
1239
+ return s.startsWith(search, position);
1240
+ }
1241
+ : // For IE11
1242
+ function startsWith(s, search, position) {
1243
+ return s.slice(position, position + search.length) === search;
1244
+ };
1245
+ var fromCodePoint = hasNativeFromCodePoint
1246
+ ? String.fromCodePoint
1247
+ : // IE11
1248
+ function fromCodePoint() {
1249
+ var codePoints = [];
1250
+ for (var _i = 0; _i < arguments.length; _i++) {
1251
+ codePoints[_i] = arguments[_i];
1252
+ }
1253
+ var elements = '';
1254
+ var length = codePoints.length;
1255
+ var i = 0;
1256
+ var code;
1257
+ while (length > i) {
1258
+ code = codePoints[i++];
1259
+ if (code > 0x10ffff)
1260
+ throw RangeError(code + ' is not a valid code point');
1261
+ elements +=
1262
+ code < 0x10000
1263
+ ? String.fromCharCode(code)
1264
+ : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
1265
+ }
1266
+ return elements;
1267
+ };
1268
+ var fromEntries =
1269
+ // native
1270
+ hasNativeFromEntries
1271
+ ? Object.fromEntries
1272
+ : // Ponyfill
1273
+ function fromEntries(entries) {
1274
+ var obj = {};
1275
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1276
+ var _a = entries_1[_i], k = _a[0], v = _a[1];
1277
+ obj[k] = v;
1278
+ }
1279
+ return obj;
1280
+ };
1281
+ var codePointAt = hasNativeCodePointAt
1282
+ ? // Native
1283
+ function codePointAt(s, index) {
1284
+ return s.codePointAt(index);
1285
+ }
1286
+ : // IE 11
1287
+ function codePointAt(s, index) {
1288
+ var size = s.length;
1289
+ if (index < 0 || index >= size) {
1290
+ return undefined;
1291
+ }
1292
+ var first = s.charCodeAt(index);
1293
+ var second;
1294
+ return first < 0xd800 ||
1295
+ first > 0xdbff ||
1296
+ index + 1 === size ||
1297
+ (second = s.charCodeAt(index + 1)) < 0xdc00 ||
1298
+ second > 0xdfff
1299
+ ? first
1300
+ : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
1301
+ };
1302
+ var trimStart = hasTrimStart
1303
+ ? // Native
1304
+ function trimStart(s) {
1305
+ return s.trimStart();
1306
+ }
1307
+ : // Ponyfill
1308
+ function trimStart(s) {
1309
+ return s.replace(SPACE_SEPARATOR_START_REGEX, '');
1310
+ };
1311
+ var trimEnd = hasTrimEnd
1312
+ ? // Native
1313
+ function trimEnd(s) {
1314
+ return s.trimEnd();
1315
+ }
1316
+ : // Ponyfill
1317
+ function trimEnd(s) {
1318
+ return s.replace(SPACE_SEPARATOR_END_REGEX, '');
1319
+ };
1320
+ // Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
1321
+ function RE(s, flag) {
1322
+ return new RegExp(s, flag);
1323
+ }
1324
+ // #endregion
1325
+ var matchIdentifierAtIndex;
1326
+ if (REGEX_SUPPORTS_U_AND_Y) {
1327
+ // Native
1328
+ var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
1329
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
1330
+ var _a;
1331
+ IDENTIFIER_PREFIX_RE_1.lastIndex = index;
1332
+ var match = IDENTIFIER_PREFIX_RE_1.exec(s);
1333
+ return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
1334
+ };
1335
+ }
1336
+ else {
1337
+ // IE11
1338
+ matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
1339
+ var match = [];
1340
+ while (true) {
1341
+ var c = codePointAt(s, index);
1342
+ if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
1343
+ break;
1344
+ }
1345
+ match.push(c);
1346
+ index += c >= 0x10000 ? 2 : 1;
1347
+ }
1348
+ return fromCodePoint.apply(void 0, match);
1349
+ };
1350
+ }
1351
+ var Parser = /** @class */ (function () {
1352
+ function Parser(message, options) {
1353
+ if (options === void 0) { options = {}; }
1354
+ this.message = message;
1355
+ this.position = { offset: 0, line: 1, column: 1 };
1356
+ this.ignoreTag = !!options.ignoreTag;
1357
+ this.requiresOtherClause = !!options.requiresOtherClause;
1358
+ this.shouldParseSkeletons = !!options.shouldParseSkeletons;
1359
+ }
1360
+ Parser.prototype.parse = function () {
1361
+ if (this.offset() !== 0) {
1362
+ throw Error('parser can only be used once');
1363
+ }
1364
+ return this.parseMessage(0, '', false);
1365
+ };
1366
+ Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
1367
+ var elements = [];
1368
+ while (!this.isEOF()) {
1369
+ var char = this.char();
1370
+ if (char === 123 /* `{` */) {
1371
+ var result = this.parseArgument(nestingLevel, expectingCloseTag);
1372
+ if (result.err) {
1373
+ return result;
1374
+ }
1375
+ elements.push(result.val);
1376
+ }
1377
+ else if (char === 125 /* `}` */ && nestingLevel > 0) {
1378
+ break;
1379
+ }
1380
+ else if (char === 35 /* `#` */ &&
1381
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) {
1382
+ var position = this.clonePosition();
1383
+ this.bump();
1384
+ elements.push({
1385
+ type: TYPE.pound,
1386
+ location: createLocation(position, this.clonePosition()),
1387
+ });
1388
+ }
1389
+ else if (char === 60 /* `<` */ &&
1390
+ !this.ignoreTag &&
1391
+ this.peek() === 47 // char code for '/'
1392
+ ) {
1393
+ if (expectingCloseTag) {
1394
+ break;
1395
+ }
1396
+ else {
1397
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
1398
+ }
1399
+ }
1400
+ else if (char === 60 /* `<` */ &&
1401
+ !this.ignoreTag &&
1402
+ _isAlpha(this.peek() || 0)) {
1403
+ var result = this.parseTag(nestingLevel, parentArgType);
1404
+ if (result.err) {
1405
+ return result;
1406
+ }
1407
+ elements.push(result.val);
1408
+ }
1409
+ else {
1410
+ var result = this.parseLiteral(nestingLevel, parentArgType);
1411
+ if (result.err) {
1412
+ return result;
1413
+ }
1414
+ elements.push(result.val);
1415
+ }
1416
+ }
1417
+ return { val: elements, err: null };
1418
+ };
1419
+ /**
1420
+ * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
1421
+ * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
1422
+ * are accepted:
1423
+ *
1424
+ * ```
1425
+ * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
1426
+ * tagName ::= [a-z] (PENChar)*
1427
+ * PENChar ::=
1428
+ * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
1429
+ * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
1430
+ * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
1431
+ * ```
1432
+ *
1433
+ * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
1434
+ * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
1435
+ * since other tag-based engines like React allow it
1436
+ */
1437
+ Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
1438
+ var startPosition = this.clonePosition();
1439
+ this.bump(); // `<`
1440
+ var tagName = this.parseTagName();
1441
+ this.bumpSpace();
1442
+ if (this.bumpIf('/>')) {
1443
+ // Self closing tag
1444
+ return {
1445
+ val: {
1446
+ type: TYPE.literal,
1447
+ value: "<" + tagName + "/>",
1448
+ location: createLocation(startPosition, this.clonePosition()),
1449
+ },
1450
+ err: null,
1451
+ };
1452
+ }
1453
+ else if (this.bumpIf('>')) {
1454
+ var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
1455
+ if (childrenResult.err) {
1456
+ return childrenResult;
1457
+ }
1458
+ var children = childrenResult.val;
1459
+ // Expecting a close tag
1460
+ var endTagStartPosition = this.clonePosition();
1461
+ if (this.bumpIf('</')) {
1462
+ if (this.isEOF() || !_isAlpha(this.char())) {
1463
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
1464
+ }
1465
+ var closingTagNameStartPosition = this.clonePosition();
1466
+ var closingTagName = this.parseTagName();
1467
+ if (tagName !== closingTagName) {
1468
+ return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
1469
+ }
1470
+ this.bumpSpace();
1471
+ if (!this.bumpIf('>')) {
1472
+ return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
1473
+ }
1474
+ return {
1475
+ val: {
1476
+ type: TYPE.tag,
1477
+ value: tagName,
1478
+ children: children,
1479
+ location: createLocation(startPosition, this.clonePosition()),
1480
+ },
1481
+ err: null,
1482
+ };
1483
+ }
1484
+ else {
1485
+ return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
1486
+ }
1487
+ }
1488
+ else {
1489
+ return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
1490
+ }
1491
+ };
1492
+ /**
1493
+ * This method assumes that the caller has peeked ahead for the first tag character.
1494
+ */
1495
+ Parser.prototype.parseTagName = function () {
1496
+ var startOffset = this.offset();
1497
+ this.bump(); // the first tag name character
1498
+ while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
1499
+ this.bump();
1500
+ }
1501
+ return this.message.slice(startOffset, this.offset());
1502
+ };
1503
+ Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
1504
+ var start = this.clonePosition();
1505
+ var value = '';
1506
+ while (true) {
1507
+ var parseQuoteResult = this.tryParseQuote(parentArgType);
1508
+ if (parseQuoteResult) {
1509
+ value += parseQuoteResult;
1510
+ continue;
1511
+ }
1512
+ var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
1513
+ if (parseUnquotedResult) {
1514
+ value += parseUnquotedResult;
1515
+ continue;
1516
+ }
1517
+ var parseLeftAngleResult = this.tryParseLeftAngleBracket();
1518
+ if (parseLeftAngleResult) {
1519
+ value += parseLeftAngleResult;
1520
+ continue;
1521
+ }
1522
+ break;
1523
+ }
1524
+ var location = createLocation(start, this.clonePosition());
1525
+ return {
1526
+ val: { type: TYPE.literal, value: value, location: location },
1527
+ err: null,
1528
+ };
1529
+ };
1530
+ Parser.prototype.tryParseLeftAngleBracket = function () {
1531
+ if (!this.isEOF() &&
1532
+ this.char() === 60 /* `<` */ &&
1533
+ (this.ignoreTag ||
1534
+ // If at the opening tag or closing tag position, bail.
1535
+ !_isAlphaOrSlash(this.peek() || 0))) {
1536
+ this.bump(); // `<`
1537
+ return '<';
1538
+ }
1539
+ return null;
1540
+ };
1541
+ /**
1542
+ * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
1543
+ * a character that requires quoting (that is, "only where needed"), and works the same in
1544
+ * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
1545
+ */
1546
+ Parser.prototype.tryParseQuote = function (parentArgType) {
1547
+ if (this.isEOF() || this.char() !== 39 /* `'` */) {
1548
+ return null;
1549
+ }
1550
+ // Parse escaped char following the apostrophe, or early return if there is no escaped char.
1551
+ // Check if is valid escaped character
1552
+ switch (this.peek()) {
1553
+ case 39 /* `'` */:
1554
+ // double quote, should return as a single quote.
1555
+ this.bump();
1556
+ this.bump();
1557
+ return "'";
1558
+ // '{', '<', '>', '}'
1559
+ case 123:
1560
+ case 60:
1561
+ case 62:
1562
+ case 125:
1563
+ break;
1564
+ case 35: // '#'
1565
+ if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
1566
+ break;
1567
+ }
1568
+ return null;
1569
+ default:
1570
+ return null;
1571
+ }
1572
+ this.bump(); // apostrophe
1573
+ var codePoints = [this.char()]; // escaped char
1574
+ this.bump();
1575
+ // read chars until the optional closing apostrophe is found
1576
+ while (!this.isEOF()) {
1577
+ var ch = this.char();
1578
+ if (ch === 39 /* `'` */) {
1579
+ if (this.peek() === 39 /* `'` */) {
1580
+ codePoints.push(39);
1581
+ // Bump one more time because we need to skip 2 characters.
1582
+ this.bump();
1583
+ }
1584
+ else {
1585
+ // Optional closing apostrophe.
1586
+ this.bump();
1587
+ break;
1588
+ }
1589
+ }
1590
+ else {
1591
+ codePoints.push(ch);
1592
+ }
1593
+ this.bump();
1594
+ }
1595
+ return fromCodePoint.apply(void 0, codePoints);
1596
+ };
1597
+ Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
1598
+ if (this.isEOF()) {
1599
+ return null;
1600
+ }
1601
+ var ch = this.char();
1602
+ if (ch === 60 /* `<` */ ||
1603
+ ch === 123 /* `{` */ ||
1604
+ (ch === 35 /* `#` */ &&
1605
+ (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
1606
+ (ch === 125 /* `}` */ && nestingLevel > 0)) {
1607
+ return null;
1608
+ }
1609
+ else {
1610
+ this.bump();
1611
+ return fromCodePoint(ch);
1612
+ }
1613
+ };
1614
+ Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
1615
+ var openingBracePosition = this.clonePosition();
1616
+ this.bump(); // `{`
1617
+ this.bumpSpace();
1618
+ if (this.isEOF()) {
1619
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
1620
+ }
1621
+ if (this.char() === 125 /* `}` */) {
1622
+ this.bump();
1623
+ return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
1624
+ }
1625
+ // argument name
1626
+ var value = this.parseIdentifierIfPossible().value;
1627
+ if (!value) {
1628
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
1629
+ }
1630
+ this.bumpSpace();
1631
+ if (this.isEOF()) {
1632
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
1633
+ }
1634
+ switch (this.char()) {
1635
+ // Simple argument: `{name}`
1636
+ case 125 /* `}` */: {
1637
+ this.bump(); // `}`
1638
+ return {
1639
+ val: {
1640
+ type: TYPE.argument,
1641
+ // value does not include the opening and closing braces.
1642
+ value: value,
1643
+ location: createLocation(openingBracePosition, this.clonePosition()),
1644
+ },
1645
+ err: null,
1646
+ };
1647
+ }
1648
+ // Argument with options: `{name, format, ...}`
1649
+ case 44 /* `,` */: {
1650
+ this.bump(); // `,`
1651
+ this.bumpSpace();
1652
+ if (this.isEOF()) {
1653
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
1654
+ }
1655
+ return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
1656
+ }
1657
+ default:
1658
+ return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
1659
+ }
1660
+ };
1661
+ /**
1662
+ * Advance the parser until the end of the identifier, if it is currently on
1663
+ * an identifier character. Return an empty string otherwise.
1664
+ */
1665
+ Parser.prototype.parseIdentifierIfPossible = function () {
1666
+ var startingPosition = this.clonePosition();
1667
+ var startOffset = this.offset();
1668
+ var value = matchIdentifierAtIndex(this.message, startOffset);
1669
+ var endOffset = startOffset + value.length;
1670
+ this.bumpTo(endOffset);
1671
+ var endPosition = this.clonePosition();
1672
+ var location = createLocation(startingPosition, endPosition);
1673
+ return { value: value, location: location };
1674
+ };
1675
+ Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
1676
+ var _a;
1677
+ // Parse this range:
1678
+ // {name, type, style}
1679
+ // ^---^
1680
+ var typeStartPosition = this.clonePosition();
1681
+ var argType = this.parseIdentifierIfPossible().value;
1682
+ var typeEndPosition = this.clonePosition();
1683
+ switch (argType) {
1684
+ case '':
1685
+ // Expecting a style string number, date, time, plural, selectordinal, or select.
1686
+ return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
1687
+ case 'number':
1688
+ case 'date':
1689
+ case 'time': {
1690
+ // Parse this range:
1691
+ // {name, number, style}
1692
+ // ^-------^
1693
+ this.bumpSpace();
1694
+ var styleAndLocation = null;
1695
+ if (this.bumpIf(',')) {
1696
+ this.bumpSpace();
1697
+ var styleStartPosition = this.clonePosition();
1698
+ var result = this.parseSimpleArgStyleIfPossible();
1699
+ if (result.err) {
1700
+ return result;
1701
+ }
1702
+ var style = trimEnd(result.val);
1703
+ if (style.length === 0) {
1704
+ return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
1705
+ }
1706
+ var styleLocation = createLocation(styleStartPosition, this.clonePosition());
1707
+ styleAndLocation = { style: style, styleLocation: styleLocation };
1708
+ }
1709
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
1710
+ if (argCloseResult.err) {
1711
+ return argCloseResult;
1712
+ }
1713
+ var location_1 = createLocation(openingBracePosition, this.clonePosition());
1714
+ // Extract style or skeleton
1715
+ if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
1716
+ // Skeleton starts with `::`.
1717
+ var skeleton = trimStart(styleAndLocation.style.slice(2));
1718
+ if (argType === 'number') {
1719
+ var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
1720
+ if (result.err) {
1721
+ return result;
1722
+ }
1723
+ return {
1724
+ val: { type: TYPE.number, value: value, location: location_1, style: result.val },
1725
+ err: null,
1726
+ };
1727
+ }
1728
+ else {
1729
+ if (skeleton.length === 0) {
1730
+ return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
1731
+ }
1732
+ var style = {
1733
+ type: SKELETON_TYPE.dateTime,
1734
+ pattern: skeleton,
1735
+ location: styleAndLocation.styleLocation,
1736
+ parsedOptions: this.shouldParseSkeletons
1737
+ ? parseDateTimeSkeleton(skeleton)
1738
+ : {},
1739
+ };
1740
+ var type = argType === 'date' ? TYPE.date : TYPE.time;
1741
+ return {
1742
+ val: { type: type, value: value, location: location_1, style: style },
1743
+ err: null,
1744
+ };
1745
+ }
1746
+ }
1747
+ // Regular style or no style.
1748
+ return {
1749
+ val: {
1750
+ type: argType === 'number'
1751
+ ? TYPE.number
1752
+ : argType === 'date'
1753
+ ? TYPE.date
1754
+ : TYPE.time,
1755
+ value: value,
1756
+ location: location_1,
1757
+ style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
1758
+ },
1759
+ err: null,
1760
+ };
1761
+ }
1762
+ case 'plural':
1763
+ case 'selectordinal':
1764
+ case 'select': {
1765
+ // Parse this range:
1766
+ // {name, plural, options}
1767
+ // ^---------^
1768
+ var typeEndPosition_1 = this.clonePosition();
1769
+ this.bumpSpace();
1770
+ if (!this.bumpIf(',')) {
1771
+ return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
1772
+ }
1773
+ this.bumpSpace();
1774
+ // Parse offset:
1775
+ // {name, plural, offset:1, options}
1776
+ // ^-----^
1777
+ //
1778
+ // or the first option:
1779
+ //
1780
+ // {name, plural, one {...} other {...}}
1781
+ // ^--^
1782
+ var identifierAndLocation = this.parseIdentifierIfPossible();
1783
+ var pluralOffset = 0;
1784
+ if (argType !== 'select' && identifierAndLocation.value === 'offset') {
1785
+ if (!this.bumpIf(':')) {
1786
+ return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
1787
+ }
1788
+ this.bumpSpace();
1789
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
1790
+ if (result.err) {
1791
+ return result;
1792
+ }
1793
+ // Parse another identifier for option parsing
1794
+ this.bumpSpace();
1795
+ identifierAndLocation = this.parseIdentifierIfPossible();
1796
+ pluralOffset = result.val;
1797
+ }
1798
+ var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
1799
+ if (optionsResult.err) {
1800
+ return optionsResult;
1801
+ }
1802
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
1803
+ if (argCloseResult.err) {
1804
+ return argCloseResult;
1805
+ }
1806
+ var location_2 = createLocation(openingBracePosition, this.clonePosition());
1807
+ if (argType === 'select') {
1808
+ return {
1809
+ val: {
1810
+ type: TYPE.select,
1811
+ value: value,
1812
+ options: fromEntries(optionsResult.val),
1813
+ location: location_2,
1814
+ },
1815
+ err: null,
1816
+ };
1817
+ }
1818
+ else {
1819
+ return {
1820
+ val: {
1821
+ type: TYPE.plural,
1822
+ value: value,
1823
+ options: fromEntries(optionsResult.val),
1824
+ offset: pluralOffset,
1825
+ pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
1826
+ location: location_2,
1827
+ },
1828
+ err: null,
1829
+ };
1830
+ }
1831
+ }
1832
+ default:
1833
+ return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
1834
+ }
1835
+ };
1836
+ Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
1837
+ // Parse: {value, number, ::currency/GBP }
1838
+ //
1839
+ if (this.isEOF() || this.char() !== 125 /* `}` */) {
1840
+ return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
1841
+ }
1842
+ this.bump(); // `}`
1843
+ return { val: true, err: null };
1844
+ };
1845
+ /**
1846
+ * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
1847
+ */
1848
+ Parser.prototype.parseSimpleArgStyleIfPossible = function () {
1849
+ var nestedBraces = 0;
1850
+ var startPosition = this.clonePosition();
1851
+ while (!this.isEOF()) {
1852
+ var ch = this.char();
1853
+ switch (ch) {
1854
+ case 39 /* `'` */: {
1855
+ // Treat apostrophe as quoting but include it in the style part.
1856
+ // Find the end of the quoted literal text.
1857
+ this.bump();
1858
+ var apostrophePosition = this.clonePosition();
1859
+ if (!this.bumpUntil("'")) {
1860
+ return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
1861
+ }
1862
+ this.bump();
1863
+ break;
1864
+ }
1865
+ case 123 /* `{` */: {
1866
+ nestedBraces += 1;
1867
+ this.bump();
1868
+ break;
1869
+ }
1870
+ case 125 /* `}` */: {
1871
+ if (nestedBraces > 0) {
1872
+ nestedBraces -= 1;
1873
+ }
1874
+ else {
1875
+ return {
1876
+ val: this.message.slice(startPosition.offset, this.offset()),
1877
+ err: null,
1878
+ };
1879
+ }
1880
+ break;
1881
+ }
1882
+ default:
1883
+ this.bump();
1884
+ break;
1885
+ }
1886
+ }
1887
+ return {
1888
+ val: this.message.slice(startPosition.offset, this.offset()),
1889
+ err: null,
1890
+ };
1891
+ };
1892
+ Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
1893
+ var tokens = [];
1894
+ try {
1895
+ tokens = parseNumberSkeletonFromString(skeleton);
1896
+ }
1897
+ catch (e) {
1898
+ return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
1899
+ }
1900
+ return {
1901
+ val: {
1902
+ type: SKELETON_TYPE.number,
1903
+ tokens: tokens,
1904
+ location: location,
1905
+ parsedOptions: this.shouldParseSkeletons
1906
+ ? parseNumberSkeleton(tokens)
1907
+ : {},
1908
+ },
1909
+ err: null,
1910
+ };
1911
+ };
1912
+ /**
1913
+ * @param nesting_level The current nesting level of messages.
1914
+ * This can be positive when parsing message fragment in select or plural argument options.
1915
+ * @param parent_arg_type The parent argument's type.
1916
+ * @param parsed_first_identifier If provided, this is the first identifier-like selector of
1917
+ * the argument. It is a by-product of a previous parsing attempt.
1918
+ * @param expecting_close_tag If true, this message is directly or indirectly nested inside
1919
+ * between a pair of opening and closing tags. The nested message will not parse beyond
1920
+ * the closing tag boundary.
1921
+ */
1922
+ Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
1923
+ var _a;
1924
+ var hasOtherClause = false;
1925
+ var options = [];
1926
+ var parsedSelectors = new Set();
1927
+ var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
1928
+ // Parse:
1929
+ // one {one apple}
1930
+ // ^--^
1931
+ while (true) {
1932
+ if (selector.length === 0) {
1933
+ var startPosition = this.clonePosition();
1934
+ if (parentArgType !== 'select' && this.bumpIf('=')) {
1935
+ // Try parse `={number}` selector
1936
+ var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
1937
+ if (result.err) {
1938
+ return result;
1939
+ }
1940
+ selectorLocation = createLocation(startPosition, this.clonePosition());
1941
+ selector = this.message.slice(startPosition.offset, this.offset());
1942
+ }
1943
+ else {
1944
+ break;
1945
+ }
1946
+ }
1947
+ // Duplicate selector clauses
1948
+ if (parsedSelectors.has(selector)) {
1949
+ return this.error(parentArgType === 'select'
1950
+ ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
1951
+ : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
1952
+ }
1953
+ if (selector === 'other') {
1954
+ hasOtherClause = true;
1955
+ }
1956
+ // Parse:
1957
+ // one {one apple}
1958
+ // ^----------^
1959
+ this.bumpSpace();
1960
+ var openingBracePosition = this.clonePosition();
1961
+ if (!this.bumpIf('{')) {
1962
+ return this.error(parentArgType === 'select'
1963
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
1964
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
1965
+ }
1966
+ var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
1967
+ if (fragmentResult.err) {
1968
+ return fragmentResult;
1969
+ }
1970
+ var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
1971
+ if (argCloseResult.err) {
1972
+ return argCloseResult;
1973
+ }
1974
+ options.push([
1975
+ selector,
1976
+ {
1977
+ value: fragmentResult.val,
1978
+ location: createLocation(openingBracePosition, this.clonePosition()),
1979
+ },
1980
+ ]);
1981
+ // Keep track of the existing selectors
1982
+ parsedSelectors.add(selector);
1983
+ // Prep next selector clause.
1984
+ this.bumpSpace();
1985
+ (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
1986
+ }
1987
+ if (options.length === 0) {
1988
+ return this.error(parentArgType === 'select'
1989
+ ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
1990
+ : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
1991
+ }
1992
+ if (this.requiresOtherClause && !hasOtherClause) {
1993
+ return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
1994
+ }
1995
+ return { val: options, err: null };
1996
+ };
1997
+ Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumberError) {
1998
+ var sign = 1;
1999
+ var startingPosition = this.clonePosition();
2000
+ if (this.bumpIf('+')) ;
2001
+ else if (this.bumpIf('-')) {
2002
+ sign = -1;
2003
+ }
2004
+ var hasDigits = false;
2005
+ var decimal = 0;
2006
+ while (!this.isEOF()) {
2007
+ var ch = this.char();
2008
+ if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
2009
+ hasDigits = true;
2010
+ decimal = decimal * 10 + (ch - 48);
2011
+ this.bump();
2012
+ }
2013
+ else {
2014
+ break;
2015
+ }
2016
+ }
2017
+ var location = createLocation(startingPosition, this.clonePosition());
2018
+ if (!hasDigits) {
2019
+ return this.error(expectNumberError, location);
2020
+ }
2021
+ decimal *= sign;
2022
+ if (!isSafeInteger(decimal)) {
2023
+ return this.error(invalidNumberError, location);
2024
+ }
2025
+ return { val: decimal, err: null };
2026
+ };
2027
+ Parser.prototype.offset = function () {
2028
+ return this.position.offset;
2029
+ };
2030
+ Parser.prototype.isEOF = function () {
2031
+ return this.offset() === this.message.length;
2032
+ };
2033
+ Parser.prototype.clonePosition = function () {
2034
+ // This is much faster than `Object.assign` or spread.
2035
+ return {
2036
+ offset: this.position.offset,
2037
+ line: this.position.line,
2038
+ column: this.position.column,
2039
+ };
2040
+ };
2041
+ /**
2042
+ * Return the code point at the current position of the parser.
2043
+ * Throws if the index is out of bound.
2044
+ */
2045
+ Parser.prototype.char = function () {
2046
+ var offset = this.position.offset;
2047
+ if (offset >= this.message.length) {
2048
+ throw Error('out of bound');
2049
+ }
2050
+ var code = codePointAt(this.message, offset);
2051
+ if (code === undefined) {
2052
+ throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
2053
+ }
2054
+ return code;
2055
+ };
2056
+ Parser.prototype.error = function (kind, location) {
2057
+ return {
2058
+ val: null,
2059
+ err: {
2060
+ kind: kind,
2061
+ message: this.message,
2062
+ location: location,
2063
+ },
2064
+ };
2065
+ };
2066
+ /** Bump the parser to the next UTF-16 code unit. */
2067
+ Parser.prototype.bump = function () {
2068
+ if (this.isEOF()) {
2069
+ return;
2070
+ }
2071
+ var code = this.char();
2072
+ if (code === 10 /* '\n' */) {
2073
+ this.position.line += 1;
2074
+ this.position.column = 1;
2075
+ this.position.offset += 1;
2076
+ }
2077
+ else {
2078
+ this.position.column += 1;
2079
+ // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
2080
+ this.position.offset += code < 0x10000 ? 1 : 2;
2081
+ }
2082
+ };
2083
+ /**
2084
+ * If the substring starting at the current position of the parser has
2085
+ * the given prefix, then bump the parser to the character immediately
2086
+ * following the prefix and return true. Otherwise, don't bump the parser
2087
+ * and return false.
2088
+ */
2089
+ Parser.prototype.bumpIf = function (prefix) {
2090
+ if (startsWith(this.message, prefix, this.offset())) {
2091
+ for (var i = 0; i < prefix.length; i++) {
2092
+ this.bump();
2093
+ }
2094
+ return true;
2095
+ }
2096
+ return false;
2097
+ };
2098
+ /**
2099
+ * Bump the parser until the pattern character is found and return `true`.
2100
+ * Otherwise bump to the end of the file and return `false`.
2101
+ */
2102
+ Parser.prototype.bumpUntil = function (pattern) {
2103
+ var currentOffset = this.offset();
2104
+ var index = this.message.indexOf(pattern, currentOffset);
2105
+ if (index >= 0) {
2106
+ this.bumpTo(index);
2107
+ return true;
2108
+ }
2109
+ else {
2110
+ this.bumpTo(this.message.length);
2111
+ return false;
2112
+ }
2113
+ };
2114
+ /**
2115
+ * Bump the parser to the target offset.
2116
+ * If target offset is beyond the end of the input, bump the parser to the end of the input.
2117
+ */
2118
+ Parser.prototype.bumpTo = function (targetOffset) {
2119
+ if (this.offset() > targetOffset) {
2120
+ throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
2121
+ }
2122
+ targetOffset = Math.min(targetOffset, this.message.length);
2123
+ while (true) {
2124
+ var offset = this.offset();
2125
+ if (offset === targetOffset) {
2126
+ break;
2127
+ }
2128
+ if (offset > targetOffset) {
2129
+ throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
2130
+ }
2131
+ this.bump();
2132
+ if (this.isEOF()) {
2133
+ break;
2134
+ }
2135
+ }
2136
+ };
2137
+ /** advance the parser through all whitespace to the next non-whitespace code unit. */
2138
+ Parser.prototype.bumpSpace = function () {
2139
+ while (!this.isEOF() && _isWhiteSpace(this.char())) {
2140
+ this.bump();
2141
+ }
2142
+ };
2143
+ /**
2144
+ * Peek at the *next* Unicode codepoint in the input without advancing the parser.
2145
+ * If the input has been exhausted, then this returns null.
2146
+ */
2147
+ Parser.prototype.peek = function () {
2148
+ if (this.isEOF()) {
2149
+ return null;
2150
+ }
2151
+ var code = this.char();
2152
+ var offset = this.offset();
2153
+ var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
2154
+ return nextCode !== null && nextCode !== void 0 ? nextCode : null;
2155
+ };
2156
+ return Parser;
2157
+ }());
2158
+ /**
2159
+ * This check if codepoint is alphabet (lower & uppercase)
2160
+ * @param codepoint
2161
+ * @returns
2162
+ */
2163
+ function _isAlpha(codepoint) {
2164
+ return ((codepoint >= 97 && codepoint <= 122) ||
2165
+ (codepoint >= 65 && codepoint <= 90));
2166
+ }
2167
+ function _isAlphaOrSlash(codepoint) {
2168
+ return _isAlpha(codepoint) || codepoint === 47; /* '/' */
2169
+ }
2170
+ /** See `parseTag` function docs. */
2171
+ function _isPotentialElementNameChar(c) {
2172
+ return (c === 45 /* '-' */ ||
2173
+ c === 46 /* '.' */ ||
2174
+ (c >= 48 && c <= 57) /* 0..9 */ ||
2175
+ c === 95 /* '_' */ ||
2176
+ (c >= 97 && c <= 122) /** a..z */ ||
2177
+ (c >= 65 && c <= 90) /* A..Z */ ||
2178
+ c == 0xb7 ||
2179
+ (c >= 0xc0 && c <= 0xd6) ||
2180
+ (c >= 0xd8 && c <= 0xf6) ||
2181
+ (c >= 0xf8 && c <= 0x37d) ||
2182
+ (c >= 0x37f && c <= 0x1fff) ||
2183
+ (c >= 0x200c && c <= 0x200d) ||
2184
+ (c >= 0x203f && c <= 0x2040) ||
2185
+ (c >= 0x2070 && c <= 0x218f) ||
2186
+ (c >= 0x2c00 && c <= 0x2fef) ||
2187
+ (c >= 0x3001 && c <= 0xd7ff) ||
2188
+ (c >= 0xf900 && c <= 0xfdcf) ||
2189
+ (c >= 0xfdf0 && c <= 0xfffd) ||
2190
+ (c >= 0x10000 && c <= 0xeffff));
2191
+ }
2192
+ /**
2193
+ * Code point equivalent of regex `\p{White_Space}`.
2194
+ * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
2195
+ */
2196
+ function _isWhiteSpace(c) {
2197
+ return ((c >= 0x0009 && c <= 0x000d) ||
2198
+ c === 0x0020 ||
2199
+ c === 0x0085 ||
2200
+ (c >= 0x200e && c <= 0x200f) ||
2201
+ c === 0x2028 ||
2202
+ c === 0x2029);
2203
+ }
2204
+ /**
2205
+ * Code point equivalent of regex `\p{Pattern_Syntax}`.
2206
+ * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
2207
+ */
2208
+ function _isPatternSyntax(c) {
2209
+ return ((c >= 0x0021 && c <= 0x0023) ||
2210
+ c === 0x0024 ||
2211
+ (c >= 0x0025 && c <= 0x0027) ||
2212
+ c === 0x0028 ||
2213
+ c === 0x0029 ||
2214
+ c === 0x002a ||
2215
+ c === 0x002b ||
2216
+ c === 0x002c ||
2217
+ c === 0x002d ||
2218
+ (c >= 0x002e && c <= 0x002f) ||
2219
+ (c >= 0x003a && c <= 0x003b) ||
2220
+ (c >= 0x003c && c <= 0x003e) ||
2221
+ (c >= 0x003f && c <= 0x0040) ||
2222
+ c === 0x005b ||
2223
+ c === 0x005c ||
2224
+ c === 0x005d ||
2225
+ c === 0x005e ||
2226
+ c === 0x0060 ||
2227
+ c === 0x007b ||
2228
+ c === 0x007c ||
2229
+ c === 0x007d ||
2230
+ c === 0x007e ||
2231
+ c === 0x00a1 ||
2232
+ (c >= 0x00a2 && c <= 0x00a5) ||
2233
+ c === 0x00a6 ||
2234
+ c === 0x00a7 ||
2235
+ c === 0x00a9 ||
2236
+ c === 0x00ab ||
2237
+ c === 0x00ac ||
2238
+ c === 0x00ae ||
2239
+ c === 0x00b0 ||
2240
+ c === 0x00b1 ||
2241
+ c === 0x00b6 ||
2242
+ c === 0x00bb ||
2243
+ c === 0x00bf ||
2244
+ c === 0x00d7 ||
2245
+ c === 0x00f7 ||
2246
+ (c >= 0x2010 && c <= 0x2015) ||
2247
+ (c >= 0x2016 && c <= 0x2017) ||
2248
+ c === 0x2018 ||
2249
+ c === 0x2019 ||
2250
+ c === 0x201a ||
2251
+ (c >= 0x201b && c <= 0x201c) ||
2252
+ c === 0x201d ||
2253
+ c === 0x201e ||
2254
+ c === 0x201f ||
2255
+ (c >= 0x2020 && c <= 0x2027) ||
2256
+ (c >= 0x2030 && c <= 0x2038) ||
2257
+ c === 0x2039 ||
2258
+ c === 0x203a ||
2259
+ (c >= 0x203b && c <= 0x203e) ||
2260
+ (c >= 0x2041 && c <= 0x2043) ||
2261
+ c === 0x2044 ||
2262
+ c === 0x2045 ||
2263
+ c === 0x2046 ||
2264
+ (c >= 0x2047 && c <= 0x2051) ||
2265
+ c === 0x2052 ||
2266
+ c === 0x2053 ||
2267
+ (c >= 0x2055 && c <= 0x205e) ||
2268
+ (c >= 0x2190 && c <= 0x2194) ||
2269
+ (c >= 0x2195 && c <= 0x2199) ||
2270
+ (c >= 0x219a && c <= 0x219b) ||
2271
+ (c >= 0x219c && c <= 0x219f) ||
2272
+ c === 0x21a0 ||
2273
+ (c >= 0x21a1 && c <= 0x21a2) ||
2274
+ c === 0x21a3 ||
2275
+ (c >= 0x21a4 && c <= 0x21a5) ||
2276
+ c === 0x21a6 ||
2277
+ (c >= 0x21a7 && c <= 0x21ad) ||
2278
+ c === 0x21ae ||
2279
+ (c >= 0x21af && c <= 0x21cd) ||
2280
+ (c >= 0x21ce && c <= 0x21cf) ||
2281
+ (c >= 0x21d0 && c <= 0x21d1) ||
2282
+ c === 0x21d2 ||
2283
+ c === 0x21d3 ||
2284
+ c === 0x21d4 ||
2285
+ (c >= 0x21d5 && c <= 0x21f3) ||
2286
+ (c >= 0x21f4 && c <= 0x22ff) ||
2287
+ (c >= 0x2300 && c <= 0x2307) ||
2288
+ c === 0x2308 ||
2289
+ c === 0x2309 ||
2290
+ c === 0x230a ||
2291
+ c === 0x230b ||
2292
+ (c >= 0x230c && c <= 0x231f) ||
2293
+ (c >= 0x2320 && c <= 0x2321) ||
2294
+ (c >= 0x2322 && c <= 0x2328) ||
2295
+ c === 0x2329 ||
2296
+ c === 0x232a ||
2297
+ (c >= 0x232b && c <= 0x237b) ||
2298
+ c === 0x237c ||
2299
+ (c >= 0x237d && c <= 0x239a) ||
2300
+ (c >= 0x239b && c <= 0x23b3) ||
2301
+ (c >= 0x23b4 && c <= 0x23db) ||
2302
+ (c >= 0x23dc && c <= 0x23e1) ||
2303
+ (c >= 0x23e2 && c <= 0x2426) ||
2304
+ (c >= 0x2427 && c <= 0x243f) ||
2305
+ (c >= 0x2440 && c <= 0x244a) ||
2306
+ (c >= 0x244b && c <= 0x245f) ||
2307
+ (c >= 0x2500 && c <= 0x25b6) ||
2308
+ c === 0x25b7 ||
2309
+ (c >= 0x25b8 && c <= 0x25c0) ||
2310
+ c === 0x25c1 ||
2311
+ (c >= 0x25c2 && c <= 0x25f7) ||
2312
+ (c >= 0x25f8 && c <= 0x25ff) ||
2313
+ (c >= 0x2600 && c <= 0x266e) ||
2314
+ c === 0x266f ||
2315
+ (c >= 0x2670 && c <= 0x2767) ||
2316
+ c === 0x2768 ||
2317
+ c === 0x2769 ||
2318
+ c === 0x276a ||
2319
+ c === 0x276b ||
2320
+ c === 0x276c ||
2321
+ c === 0x276d ||
2322
+ c === 0x276e ||
2323
+ c === 0x276f ||
2324
+ c === 0x2770 ||
2325
+ c === 0x2771 ||
2326
+ c === 0x2772 ||
2327
+ c === 0x2773 ||
2328
+ c === 0x2774 ||
2329
+ c === 0x2775 ||
2330
+ (c >= 0x2794 && c <= 0x27bf) ||
2331
+ (c >= 0x27c0 && c <= 0x27c4) ||
2332
+ c === 0x27c5 ||
2333
+ c === 0x27c6 ||
2334
+ (c >= 0x27c7 && c <= 0x27e5) ||
2335
+ c === 0x27e6 ||
2336
+ c === 0x27e7 ||
2337
+ c === 0x27e8 ||
2338
+ c === 0x27e9 ||
2339
+ c === 0x27ea ||
2340
+ c === 0x27eb ||
2341
+ c === 0x27ec ||
2342
+ c === 0x27ed ||
2343
+ c === 0x27ee ||
2344
+ c === 0x27ef ||
2345
+ (c >= 0x27f0 && c <= 0x27ff) ||
2346
+ (c >= 0x2800 && c <= 0x28ff) ||
2347
+ (c >= 0x2900 && c <= 0x2982) ||
2348
+ c === 0x2983 ||
2349
+ c === 0x2984 ||
2350
+ c === 0x2985 ||
2351
+ c === 0x2986 ||
2352
+ c === 0x2987 ||
2353
+ c === 0x2988 ||
2354
+ c === 0x2989 ||
2355
+ c === 0x298a ||
2356
+ c === 0x298b ||
2357
+ c === 0x298c ||
2358
+ c === 0x298d ||
2359
+ c === 0x298e ||
2360
+ c === 0x298f ||
2361
+ c === 0x2990 ||
2362
+ c === 0x2991 ||
2363
+ c === 0x2992 ||
2364
+ c === 0x2993 ||
2365
+ c === 0x2994 ||
2366
+ c === 0x2995 ||
2367
+ c === 0x2996 ||
2368
+ c === 0x2997 ||
2369
+ c === 0x2998 ||
2370
+ (c >= 0x2999 && c <= 0x29d7) ||
2371
+ c === 0x29d8 ||
2372
+ c === 0x29d9 ||
2373
+ c === 0x29da ||
2374
+ c === 0x29db ||
2375
+ (c >= 0x29dc && c <= 0x29fb) ||
2376
+ c === 0x29fc ||
2377
+ c === 0x29fd ||
2378
+ (c >= 0x29fe && c <= 0x2aff) ||
2379
+ (c >= 0x2b00 && c <= 0x2b2f) ||
2380
+ (c >= 0x2b30 && c <= 0x2b44) ||
2381
+ (c >= 0x2b45 && c <= 0x2b46) ||
2382
+ (c >= 0x2b47 && c <= 0x2b4c) ||
2383
+ (c >= 0x2b4d && c <= 0x2b73) ||
2384
+ (c >= 0x2b74 && c <= 0x2b75) ||
2385
+ (c >= 0x2b76 && c <= 0x2b95) ||
2386
+ c === 0x2b96 ||
2387
+ (c >= 0x2b97 && c <= 0x2bff) ||
2388
+ (c >= 0x2e00 && c <= 0x2e01) ||
2389
+ c === 0x2e02 ||
2390
+ c === 0x2e03 ||
2391
+ c === 0x2e04 ||
2392
+ c === 0x2e05 ||
2393
+ (c >= 0x2e06 && c <= 0x2e08) ||
2394
+ c === 0x2e09 ||
2395
+ c === 0x2e0a ||
2396
+ c === 0x2e0b ||
2397
+ c === 0x2e0c ||
2398
+ c === 0x2e0d ||
2399
+ (c >= 0x2e0e && c <= 0x2e16) ||
2400
+ c === 0x2e17 ||
2401
+ (c >= 0x2e18 && c <= 0x2e19) ||
2402
+ c === 0x2e1a ||
2403
+ c === 0x2e1b ||
2404
+ c === 0x2e1c ||
2405
+ c === 0x2e1d ||
2406
+ (c >= 0x2e1e && c <= 0x2e1f) ||
2407
+ c === 0x2e20 ||
2408
+ c === 0x2e21 ||
2409
+ c === 0x2e22 ||
2410
+ c === 0x2e23 ||
2411
+ c === 0x2e24 ||
2412
+ c === 0x2e25 ||
2413
+ c === 0x2e26 ||
2414
+ c === 0x2e27 ||
2415
+ c === 0x2e28 ||
2416
+ c === 0x2e29 ||
2417
+ (c >= 0x2e2a && c <= 0x2e2e) ||
2418
+ c === 0x2e2f ||
2419
+ (c >= 0x2e30 && c <= 0x2e39) ||
2420
+ (c >= 0x2e3a && c <= 0x2e3b) ||
2421
+ (c >= 0x2e3c && c <= 0x2e3f) ||
2422
+ c === 0x2e40 ||
2423
+ c === 0x2e41 ||
2424
+ c === 0x2e42 ||
2425
+ (c >= 0x2e43 && c <= 0x2e4f) ||
2426
+ (c >= 0x2e50 && c <= 0x2e51) ||
2427
+ c === 0x2e52 ||
2428
+ (c >= 0x2e53 && c <= 0x2e7f) ||
2429
+ (c >= 0x3001 && c <= 0x3003) ||
2430
+ c === 0x3008 ||
2431
+ c === 0x3009 ||
2432
+ c === 0x300a ||
2433
+ c === 0x300b ||
2434
+ c === 0x300c ||
2435
+ c === 0x300d ||
2436
+ c === 0x300e ||
2437
+ c === 0x300f ||
2438
+ c === 0x3010 ||
2439
+ c === 0x3011 ||
2440
+ (c >= 0x3012 && c <= 0x3013) ||
2441
+ c === 0x3014 ||
2442
+ c === 0x3015 ||
2443
+ c === 0x3016 ||
2444
+ c === 0x3017 ||
2445
+ c === 0x3018 ||
2446
+ c === 0x3019 ||
2447
+ c === 0x301a ||
2448
+ c === 0x301b ||
2449
+ c === 0x301c ||
2450
+ c === 0x301d ||
2451
+ (c >= 0x301e && c <= 0x301f) ||
2452
+ c === 0x3020 ||
2453
+ c === 0x3030 ||
2454
+ c === 0xfd3e ||
2455
+ c === 0xfd3f ||
2456
+ (c >= 0xfe45 && c <= 0xfe46));
2457
+ }
2458
+
2459
+ function pruneLocation(els) {
2460
+ els.forEach(function (el) {
2461
+ delete el.location;
2462
+ if (isSelectElement(el) || isPluralElement(el)) {
2463
+ for (var k in el.options) {
2464
+ delete el.options[k].location;
2465
+ pruneLocation(el.options[k].value);
2466
+ }
2467
+ }
2468
+ else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
2469
+ delete el.style.location;
2470
+ }
2471
+ else if ((isDateElement(el) || isTimeElement(el)) &&
2472
+ isDateTimeSkeleton(el.style)) {
2473
+ delete el.style.location;
2474
+ }
2475
+ else if (isTagElement(el)) {
2476
+ pruneLocation(el.children);
2477
+ }
2478
+ });
2479
+ }
2480
+ function parse(message, opts) {
2481
+ if (opts === void 0) { opts = {}; }
2482
+ opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
2483
+ var result = new Parser(message, opts).parse();
2484
+ if (result.err) {
2485
+ var error = SyntaxError(ErrorKind[result.err.kind]);
2486
+ // @ts-expect-error Assign to error object
2487
+ error.location = result.err.location;
2488
+ // @ts-expect-error Assign to error object
2489
+ error.originalMessage = result.err.message;
2490
+ throw error;
2491
+ }
2492
+ if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
2493
+ pruneLocation(result.val);
2494
+ }
2495
+ return result.val;
2496
+ }
2497
+
2498
+ //
2499
+ // Main
2500
+ //
2501
+ function memoize(fn, options) {
2502
+ var cache = options && options.cache ? options.cache : cacheDefault;
2503
+ var serializer = options && options.serializer ? options.serializer : serializerDefault;
2504
+ var strategy = options && options.strategy ? options.strategy : strategyDefault;
2505
+ return strategy(fn, {
2506
+ cache: cache,
2507
+ serializer: serializer,
2508
+ });
2509
+ }
2510
+ //
2511
+ // Strategy
2512
+ //
2513
+ function isPrimitive(value) {
2514
+ return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === "string" 'unsafe' primitive for our needs
2515
+ }
2516
+ function monadic(fn, cache, serializer, arg) {
2517
+ var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
2518
+ var computedValue = cache.get(cacheKey);
2519
+ if (typeof computedValue === 'undefined') {
2520
+ computedValue = fn.call(this, arg);
2521
+ cache.set(cacheKey, computedValue);
2522
+ }
2523
+ return computedValue;
2524
+ }
2525
+ function variadic(fn, cache, serializer) {
2526
+ var args = Array.prototype.slice.call(arguments, 3);
2527
+ var cacheKey = serializer(args);
2528
+ var computedValue = cache.get(cacheKey);
2529
+ if (typeof computedValue === 'undefined') {
2530
+ computedValue = fn.apply(this, args);
2531
+ cache.set(cacheKey, computedValue);
2532
+ }
2533
+ return computedValue;
2534
+ }
2535
+ function assemble(fn, context, strategy, cache, serialize) {
2536
+ return strategy.bind(context, fn, cache, serialize);
2537
+ }
2538
+ function strategyDefault(fn, options) {
2539
+ var strategy = fn.length === 1 ? monadic : variadic;
2540
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
2541
+ }
2542
+ function strategyVariadic(fn, options) {
2543
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
2544
+ }
2545
+ function strategyMonadic(fn, options) {
2546
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
2547
+ }
2548
+ //
2549
+ // Serializer
2550
+ //
2551
+ var serializerDefault = function () {
2552
+ return JSON.stringify(arguments);
2553
+ };
2554
+ //
2555
+ // Cache
2556
+ //
2557
+ function ObjectWithoutPrototypeCache() {
2558
+ this.cache = Object.create(null);
2559
+ }
2560
+ ObjectWithoutPrototypeCache.prototype.has = function (key) {
2561
+ return key in this.cache;
2562
+ };
2563
+ ObjectWithoutPrototypeCache.prototype.get = function (key) {
2564
+ return this.cache[key];
2565
+ };
2566
+ ObjectWithoutPrototypeCache.prototype.set = function (key, value) {
2567
+ this.cache[key] = value;
2568
+ };
2569
+ var cacheDefault = {
2570
+ create: function create() {
2571
+ // @ts-ignore
2572
+ return new ObjectWithoutPrototypeCache();
2573
+ },
2574
+ };
2575
+ var strategies = {
2576
+ variadic: strategyVariadic,
2577
+ monadic: strategyMonadic,
2578
+ };
2579
+
2580
+ var ErrorCode;
2581
+ (function (ErrorCode) {
2582
+ // When we have a placeholder but no value to format
2583
+ ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
2584
+ // When value supplied is invalid
2585
+ ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
2586
+ // When we need specific Intl API but it's not available
2587
+ ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
2588
+ })(ErrorCode || (ErrorCode = {}));
2589
+ var FormatError = /** @class */ (function (_super) {
2590
+ __extends(FormatError, _super);
2591
+ function FormatError(msg, code, originalMessage) {
2592
+ var _this = _super.call(this, msg) || this;
2593
+ _this.code = code;
2594
+ _this.originalMessage = originalMessage;
2595
+ return _this;
2596
+ }
2597
+ FormatError.prototype.toString = function () {
2598
+ return "[formatjs Error: " + this.code + "] " + this.message;
2599
+ };
2600
+ return FormatError;
2601
+ }(Error));
2602
+ var InvalidValueError = /** @class */ (function (_super) {
2603
+ __extends(InvalidValueError, _super);
2604
+ function InvalidValueError(variableId, value, options, originalMessage) {
2605
+ return _super.call(this, "Invalid values for \"" + variableId + "\": \"" + value + "\". Options are \"" + Object.keys(options).join('", "') + "\"", ErrorCode.INVALID_VALUE, originalMessage) || this;
2606
+ }
2607
+ return InvalidValueError;
2608
+ }(FormatError));
2609
+ var InvalidValueTypeError = /** @class */ (function (_super) {
2610
+ __extends(InvalidValueTypeError, _super);
2611
+ function InvalidValueTypeError(value, type, originalMessage) {
2612
+ return _super.call(this, "Value for \"" + value + "\" must be of type " + type, ErrorCode.INVALID_VALUE, originalMessage) || this;
2613
+ }
2614
+ return InvalidValueTypeError;
2615
+ }(FormatError));
2616
+ var MissingValueError = /** @class */ (function (_super) {
2617
+ __extends(MissingValueError, _super);
2618
+ function MissingValueError(variableId, originalMessage) {
2619
+ return _super.call(this, "The intl string context variable \"" + variableId + "\" was not provided to the string \"" + originalMessage + "\"", ErrorCode.MISSING_VALUE, originalMessage) || this;
2620
+ }
2621
+ return MissingValueError;
2622
+ }(FormatError));
2623
+
2624
+ var PART_TYPE;
2625
+ (function (PART_TYPE) {
2626
+ PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
2627
+ PART_TYPE[PART_TYPE["object"] = 1] = "object";
2628
+ })(PART_TYPE || (PART_TYPE = {}));
2629
+ function mergeLiteral(parts) {
2630
+ if (parts.length < 2) {
2631
+ return parts;
2632
+ }
2633
+ return parts.reduce(function (all, part) {
2634
+ var lastPart = all[all.length - 1];
2635
+ if (!lastPart ||
2636
+ lastPart.type !== PART_TYPE.literal ||
2637
+ part.type !== PART_TYPE.literal) {
2638
+ all.push(part);
2639
+ }
2640
+ else {
2641
+ lastPart.value += part.value;
2642
+ }
2643
+ return all;
2644
+ }, []);
2645
+ }
2646
+ function isFormatXMLElementFn(el) {
2647
+ return typeof el === 'function';
2648
+ }
2649
+ // TODO(skeleton): add skeleton support
2650
+ function formatToParts(els, locales, formatters, formats, values, currentPluralValue,
2651
+ // For debugging
2652
+ originalMessage) {
2653
+ // Hot path for straight simple msg translations
2654
+ if (els.length === 1 && isLiteralElement(els[0])) {
2655
+ return [
2656
+ {
2657
+ type: PART_TYPE.literal,
2658
+ value: els[0].value,
2659
+ },
2660
+ ];
2661
+ }
2662
+ var result = [];
2663
+ for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
2664
+ var el = els_1[_i];
2665
+ // Exit early for string parts.
2666
+ if (isLiteralElement(el)) {
2667
+ result.push({
2668
+ type: PART_TYPE.literal,
2669
+ value: el.value,
2670
+ });
2671
+ continue;
2672
+ }
2673
+ // TODO: should this part be literal type?
2674
+ // Replace `#` in plural rules with the actual numeric value.
2675
+ if (isPoundElement(el)) {
2676
+ if (typeof currentPluralValue === 'number') {
2677
+ result.push({
2678
+ type: PART_TYPE.literal,
2679
+ value: formatters.getNumberFormat(locales).format(currentPluralValue),
2680
+ });
2681
+ }
2682
+ continue;
2683
+ }
2684
+ var varName = el.value;
2685
+ // Enforce that all required values are provided by the caller.
2686
+ if (!(values && varName in values)) {
2687
+ throw new MissingValueError(varName, originalMessage);
2688
+ }
2689
+ var value = values[varName];
2690
+ if (isArgumentElement(el)) {
2691
+ if (!value || typeof value === 'string' || typeof value === 'number') {
2692
+ value =
2693
+ typeof value === 'string' || typeof value === 'number'
2694
+ ? String(value)
2695
+ : '';
2696
+ }
2697
+ result.push({
2698
+ type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
2699
+ value: value,
2700
+ });
2701
+ continue;
2702
+ }
2703
+ // Recursively format plural and select parts' option — which can be a
2704
+ // nested pattern structure. The choosing of the option to use is
2705
+ // abstracted-by and delegated-to the part helper object.
2706
+ if (isDateElement(el)) {
2707
+ var style = typeof el.style === 'string'
2708
+ ? formats.date[el.style]
2709
+ : isDateTimeSkeleton(el.style)
2710
+ ? el.style.parsedOptions
2711
+ : undefined;
2712
+ result.push({
2713
+ type: PART_TYPE.literal,
2714
+ value: formatters
2715
+ .getDateTimeFormat(locales, style)
2716
+ .format(value),
2717
+ });
2718
+ continue;
2719
+ }
2720
+ if (isTimeElement(el)) {
2721
+ var style = typeof el.style === 'string'
2722
+ ? formats.time[el.style]
2723
+ : isDateTimeSkeleton(el.style)
2724
+ ? el.style.parsedOptions
2725
+ : undefined;
2726
+ result.push({
2727
+ type: PART_TYPE.literal,
2728
+ value: formatters
2729
+ .getDateTimeFormat(locales, style)
2730
+ .format(value),
2731
+ });
2732
+ continue;
2733
+ }
2734
+ if (isNumberElement(el)) {
2735
+ var style = typeof el.style === 'string'
2736
+ ? formats.number[el.style]
2737
+ : isNumberSkeleton(el.style)
2738
+ ? el.style.parsedOptions
2739
+ : undefined;
2740
+ if (style && style.scale) {
2741
+ value =
2742
+ value *
2743
+ (style.scale || 1);
2744
+ }
2745
+ result.push({
2746
+ type: PART_TYPE.literal,
2747
+ value: formatters
2748
+ .getNumberFormat(locales, style)
2749
+ .format(value),
2750
+ });
2751
+ continue;
2752
+ }
2753
+ if (isTagElement(el)) {
2754
+ var children = el.children, value_1 = el.value;
2755
+ var formatFn = values[value_1];
2756
+ if (!isFormatXMLElementFn(formatFn)) {
2757
+ throw new InvalidValueTypeError(value_1, 'function', originalMessage);
2758
+ }
2759
+ var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
2760
+ var chunks = formatFn(parts.map(function (p) { return p.value; }));
2761
+ if (!Array.isArray(chunks)) {
2762
+ chunks = [chunks];
2763
+ }
2764
+ result.push.apply(result, chunks.map(function (c) {
2765
+ return {
2766
+ type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
2767
+ value: c,
2768
+ };
2769
+ }));
2770
+ }
2771
+ if (isSelectElement(el)) {
2772
+ var opt = el.options[value] || el.options.other;
2773
+ if (!opt) {
2774
+ throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
2775
+ }
2776
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
2777
+ continue;
2778
+ }
2779
+ if (isPluralElement(el)) {
2780
+ var opt = el.options["=" + value];
2781
+ if (!opt) {
2782
+ if (!Intl.PluralRules) {
2783
+ throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
2784
+ }
2785
+ var rule = formatters
2786
+ .getPluralRules(locales, { type: el.pluralType })
2787
+ .select(value - (el.offset || 0));
2788
+ opt = el.options[rule] || el.options.other;
2789
+ }
2790
+ if (!opt) {
2791
+ throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
2792
+ }
2793
+ result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
2794
+ continue;
2795
+ }
2796
+ }
2797
+ return mergeLiteral(result);
2798
+ }
2799
+
2800
+ /*
2801
+ Copyright (c) 2014, Yahoo! Inc. All rights reserved.
2802
+ Copyrights licensed under the New BSD License.
2803
+ See the accompanying LICENSE file for terms.
2804
+ */
2805
+ // -- MessageFormat --------------------------------------------------------
2806
+ function mergeConfig(c1, c2) {
2807
+ if (!c2) {
2808
+ return c1;
2809
+ }
2810
+ return __assign(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
2811
+ all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));
2812
+ return all;
2813
+ }, {}));
2814
+ }
2815
+ function mergeConfigs(defaultConfig, configs) {
2816
+ if (!configs) {
2817
+ return defaultConfig;
2818
+ }
2819
+ return Object.keys(defaultConfig).reduce(function (all, k) {
2820
+ all[k] = mergeConfig(defaultConfig[k], configs[k]);
2821
+ return all;
2822
+ }, __assign({}, defaultConfig));
2823
+ }
2824
+ function createFastMemoizeCache(store) {
2825
+ return {
2826
+ create: function () {
2827
+ return {
2828
+ has: function (key) {
2829
+ return key in store;
2830
+ },
2831
+ get: function (key) {
2832
+ return store[key];
2833
+ },
2834
+ set: function (key, value) {
2835
+ store[key] = value;
2836
+ },
2837
+ };
2838
+ },
2839
+ };
2840
+ }
2841
+ function createDefaultFormatters(cache) {
2842
+ if (cache === void 0) { cache = {
2843
+ number: {},
2844
+ dateTime: {},
2845
+ pluralRules: {},
2846
+ }; }
2847
+ return {
2848
+ getNumberFormat: memoize(function () {
2849
+ var _a;
2850
+ var args = [];
2851
+ for (var _i = 0; _i < arguments.length; _i++) {
2852
+ args[_i] = arguments[_i];
2853
+ }
2854
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args)))();
2855
+ }, {
2856
+ cache: createFastMemoizeCache(cache.number),
2857
+ strategy: strategies.variadic,
2858
+ }),
2859
+ getDateTimeFormat: memoize(function () {
2860
+ var _a;
2861
+ var args = [];
2862
+ for (var _i = 0; _i < arguments.length; _i++) {
2863
+ args[_i] = arguments[_i];
2864
+ }
2865
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args)))();
2866
+ }, {
2867
+ cache: createFastMemoizeCache(cache.dateTime),
2868
+ strategy: strategies.variadic,
2869
+ }),
2870
+ getPluralRules: memoize(function () {
2871
+ var _a;
2872
+ var args = [];
2873
+ for (var _i = 0; _i < arguments.length; _i++) {
2874
+ args[_i] = arguments[_i];
2875
+ }
2876
+ return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args)))();
2877
+ }, {
2878
+ cache: createFastMemoizeCache(cache.pluralRules),
2879
+ strategy: strategies.variadic,
2880
+ }),
2881
+ };
2882
+ }
2883
+ var IntlMessageFormat = /** @class */ (function () {
2884
+ function IntlMessageFormat(message, locales, overrideFormats, opts) {
2885
+ var _this = this;
2886
+ if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
2887
+ this.formatterCache = {
2888
+ number: {},
2889
+ dateTime: {},
2890
+ pluralRules: {},
2891
+ };
2892
+ this.format = function (values) {
2893
+ var parts = _this.formatToParts(values);
2894
+ // Hot path for straight simple msg translations
2895
+ if (parts.length === 1) {
2896
+ return parts[0].value;
2897
+ }
2898
+ var result = parts.reduce(function (all, part) {
2899
+ if (!all.length ||
2900
+ part.type !== PART_TYPE.literal ||
2901
+ typeof all[all.length - 1] !== 'string') {
2902
+ all.push(part.value);
2903
+ }
2904
+ else {
2905
+ all[all.length - 1] += part.value;
2906
+ }
2907
+ return all;
2908
+ }, []);
2909
+ if (result.length <= 1) {
2910
+ return result[0] || '';
2911
+ }
2912
+ return result;
2913
+ };
2914
+ this.formatToParts = function (values) {
2915
+ return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
2916
+ };
2917
+ this.resolvedOptions = function () { return ({
2918
+ locale: Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
2919
+ }); };
2920
+ this.getAst = function () { return _this.ast; };
2921
+ if (typeof message === 'string') {
2922
+ this.message = message;
2923
+ if (!IntlMessageFormat.__parse) {
2924
+ throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
2925
+ }
2926
+ // Parse string messages into an AST.
2927
+ this.ast = IntlMessageFormat.__parse(message, {
2928
+ ignoreTag: opts === null || opts === void 0 ? void 0 : opts.ignoreTag,
2929
+ });
2930
+ }
2931
+ else {
2932
+ this.ast = message;
2933
+ }
2934
+ if (!Array.isArray(this.ast)) {
2935
+ throw new TypeError('A message must be provided as a String or AST.');
2936
+ }
2937
+ // Creates a new object with the specified `formats` merged with the default
2938
+ // formats.
2939
+ this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
2940
+ // Defined first because it's used to build the format pattern.
2941
+ this.locales = locales;
2942
+ this.formatters =
2943
+ (opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
2944
+ }
2945
+ Object.defineProperty(IntlMessageFormat, "defaultLocale", {
2946
+ get: function () {
2947
+ if (!IntlMessageFormat.memoizedDefaultLocale) {
2948
+ IntlMessageFormat.memoizedDefaultLocale =
2949
+ new Intl.NumberFormat().resolvedOptions().locale;
2950
+ }
2951
+ return IntlMessageFormat.memoizedDefaultLocale;
2952
+ },
2953
+ enumerable: false,
2954
+ configurable: true
2955
+ });
2956
+ IntlMessageFormat.memoizedDefaultLocale = null;
2957
+ IntlMessageFormat.__parse = parse;
2958
+ // Default format options used as the prototype of the `formats` provided to the
2959
+ // constructor. These are used when constructing the internal Intl.NumberFormat
2960
+ // and Intl.DateTimeFormat instances.
2961
+ IntlMessageFormat.formats = {
2962
+ number: {
2963
+ integer: {
2964
+ maximumFractionDigits: 0,
2965
+ },
2966
+ currency: {
2967
+ style: 'currency',
2968
+ },
2969
+ percent: {
2970
+ style: 'percent',
2971
+ },
2972
+ },
2973
+ date: {
2974
+ short: {
2975
+ month: 'numeric',
2976
+ day: 'numeric',
2977
+ year: '2-digit',
2978
+ },
2979
+ medium: {
2980
+ month: 'short',
2981
+ day: 'numeric',
2982
+ year: 'numeric',
2983
+ },
2984
+ long: {
2985
+ month: 'long',
2986
+ day: 'numeric',
2987
+ year: 'numeric',
2988
+ },
2989
+ full: {
2990
+ weekday: 'long',
2991
+ month: 'long',
2992
+ day: 'numeric',
2993
+ year: 'numeric',
2994
+ },
2995
+ },
2996
+ time: {
2997
+ short: {
2998
+ hour: 'numeric',
2999
+ minute: 'numeric',
3000
+ },
3001
+ medium: {
3002
+ hour: 'numeric',
3003
+ minute: 'numeric',
3004
+ second: 'numeric',
3005
+ },
3006
+ long: {
3007
+ hour: 'numeric',
3008
+ minute: 'numeric',
3009
+ second: 'numeric',
3010
+ timeZoneName: 'short',
3011
+ },
3012
+ full: {
3013
+ hour: 'numeric',
3014
+ minute: 'numeric',
3015
+ second: 'numeric',
3016
+ timeZoneName: 'short',
3017
+ },
3018
+ },
3019
+ };
3020
+ return IntlMessageFormat;
3021
+ }());
3022
+
3023
+ 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]}/*! *****************************************************************************
3024
+ Copyright (c) Microsoft Corporation.
3025
+
3026
+ Permission to use, copy, modify, and/or distribute this software for any
3027
+ purpose with or without fee is hereby granted.
3028
+
3029
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3030
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3031
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3032
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3033
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3034
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3035
+ PERFORMANCE OF THIS SOFTWARE.
3036
+ ***************************************************************************** */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),X=derived([T,s],(()=>K));derived([T],(()=>Q));derived([T],(()=>R));derived([T],(()=>V));derived([T,s],(()=>W));
3037
+
3038
+ function addNewMessages(lang, dict) {
3039
+ m(lang, dict);
3040
+ }
3041
+
3042
+ function setLocale(_locale) {
3043
+ T.set(_locale);
3044
+ }
3045
+
3046
+ const TournamentsDurationTranslations = {
3047
+ en: {
3048
+ tournamentsDuration: {
3049
+ finished: 'Finished',
3050
+ starting: 'Starting in ',
3051
+ days: 'days',
3052
+ minutesleft: 'minutes left',
3053
+ hoursleft: 'hours left',
3054
+ daysleft: 'days left'
3055
+ }
3056
+ },
3057
+ tr: {
3058
+ tournamentsDuration: {
3059
+ finished: 'Sona ermiş',
3060
+ starting: 'Başlamasına ',
3061
+ days: 'gün',
3062
+ minutesleft: 'dakika kaldı',
3063
+ hoursleft: 'saat kaldı',
3064
+ daysleft: 'gün kaldı'
3065
+ }
3066
+ },
3067
+ el: {
3068
+ tournamentsDuration: {
3069
+ finished: 'Ολοκληρωμένα',
3070
+ starting: 'Αρχίζει σε ',
3071
+ days: 'ημέρες',
3072
+ minutesleft: 'λεπτά απομένουν',
3073
+ hoursleft: 'ώρες απομένουν',
3074
+ daysleft: 'ημέρες απομένουν'
3075
+ }
3076
+ },
3077
+ };
3078
+
3079
+ /* src/CasinoTournmanetsThumbnailDuration.svelte generated by Svelte v3.37.0 */
3080
+
3081
+ const { Object: Object_1 } = globals;
3082
+ const file = "src/CasinoTournmanetsThumbnailDuration.svelte";
3083
+
3084
+ // (72:2) {#if startdate && enddate}
3085
+ function create_if_block(ctx) {
3086
+ let div2;
3087
+ let div0;
3088
+ let t0;
3089
+ let t1;
3090
+ let div1;
3091
+ let t2;
3092
+ let t3;
3093
+ let div3;
3094
+ let mounted;
3095
+ let dispose;
3096
+
3097
+ function select_block_type(ctx, dirty) {
3098
+ if (/*status*/ ctx[2] == "Finished" || /*status*/ ctx[2] == "Closing" || /*status*/ ctx[2] == "Closed") return create_if_block_1;
3099
+ if (/*tournamentUntilStartDays*/ ctx[6] > 0) return create_if_block_2;
3100
+ return create_else_block;
3101
+ }
3102
+
3103
+ let current_block_type = select_block_type(ctx);
3104
+ let if_block = current_block_type(ctx);
3105
+
3106
+ const block = {
3107
+ c: function create() {
3108
+ div2 = element("div");
3109
+ div0 = element("div");
3110
+ t0 = text(/*startDate*/ ctx[3]);
3111
+ t1 = space();
3112
+ div1 = element("div");
3113
+ t2 = text(/*endDate*/ ctx[4]);
3114
+ t3 = space();
3115
+ div3 = element("div");
3116
+ if_block.c();
3117
+ attr_dev(div0, "class", "StartDate");
3118
+ add_location(div0, file, 73, 6, 2460);
3119
+ attr_dev(div1, "class", "EndDate");
3120
+ add_location(div1, file, 74, 6, 2527);
3121
+ attr_dev(div2, "class", "TournamentDates");
3122
+ add_location(div2, file, 72, 4, 2424);
3123
+ attr_dev(div3, "class", "ProgressBar");
3124
+ add_location(div3, file, 76, 4, 2597);
3125
+ },
3126
+ m: function mount(target, anchor) {
3127
+ insert_dev(target, div2, anchor);
3128
+ append_dev(div2, div0);
3129
+ append_dev(div0, t0);
3130
+ append_dev(div2, t1);
3131
+ append_dev(div2, div1);
3132
+ append_dev(div1, t2);
3133
+ insert_dev(target, t3, anchor);
3134
+ insert_dev(target, div3, anchor);
3135
+ if_block.m(div3, null);
3136
+
3137
+ if (!mounted) {
3138
+ dispose = [
3139
+ action_destroyer(/*formatStartDate*/ ctx[12].call(null, div0)),
3140
+ action_destroyer(/*formatEndDate*/ ctx[13].call(null, div1)),
3141
+ action_destroyer(/*getDuration*/ ctx[14].call(null, div3))
3142
+ ];
3143
+
3144
+ mounted = true;
3145
+ }
3146
+ },
3147
+ p: function update(ctx, dirty) {
3148
+ if (dirty & /*startDate*/ 8) set_data_dev(t0, /*startDate*/ ctx[3]);
3149
+ if (dirty & /*endDate*/ 16) set_data_dev(t2, /*endDate*/ ctx[4]);
3150
+
3151
+ if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
3152
+ if_block.p(ctx, dirty);
3153
+ } else {
3154
+ if_block.d(1);
3155
+ if_block = current_block_type(ctx);
3156
+
3157
+ if (if_block) {
3158
+ if_block.c();
3159
+ if_block.m(div3, null);
3160
+ }
3161
+ }
3162
+ },
3163
+ d: function destroy(detaching) {
3164
+ if (detaching) detach_dev(div2);
3165
+ if (detaching) detach_dev(t3);
3166
+ if (detaching) detach_dev(div3);
3167
+ if_block.d();
3168
+ mounted = false;
3169
+ run_all(dispose);
3170
+ }
3171
+ };
3172
+
3173
+ dispatch_dev("SvelteRegisterBlock", {
3174
+ block,
3175
+ id: create_if_block.name,
3176
+ type: "if",
3177
+ source: "(72:2) {#if startdate && enddate}",
3178
+ ctx
3179
+ });
3180
+
3181
+ return block;
3182
+ }
3183
+
3184
+ // (85:8) {:else}
3185
+ function create_else_block(ctx) {
3186
+ let div;
3187
+ let t;
3188
+ let if_block_anchor;
3189
+ let if_block = /*tournamentLeftDays*/ ctx[5] > 0 && create_if_block_3(ctx);
3190
+
3191
+ const block = {
3192
+ c: function create() {
3193
+ div = element("div");
3194
+ t = space();
3195
+ if (if_block) if_block.c();
3196
+ if_block_anchor = empty();
3197
+ attr_dev(div, "class", "ProgressBarFill");
3198
+ set_style(div, "width", /*progress*/ ctx[7] + "%");
3199
+ add_location(div, file, 85, 10, 3110);
3200
+ },
3201
+ m: function mount(target, anchor) {
3202
+ insert_dev(target, div, anchor);
3203
+ insert_dev(target, t, anchor);
3204
+ if (if_block) if_block.m(target, anchor);
3205
+ insert_dev(target, if_block_anchor, anchor);
3206
+ },
3207
+ p: function update(ctx, dirty) {
3208
+ if (dirty & /*progress*/ 128) {
3209
+ set_style(div, "width", /*progress*/ ctx[7] + "%");
3210
+ }
3211
+
3212
+ if (/*tournamentLeftDays*/ ctx[5] > 0) {
3213
+ if (if_block) {
3214
+ if_block.p(ctx, dirty);
3215
+ } else {
3216
+ if_block = create_if_block_3(ctx);
3217
+ if_block.c();
3218
+ if_block.m(if_block_anchor.parentNode, if_block_anchor);
3219
+ }
3220
+ } else if (if_block) {
3221
+ if_block.d(1);
3222
+ if_block = null;
3223
+ }
3224
+ },
3225
+ d: function destroy(detaching) {
3226
+ if (detaching) detach_dev(div);
3227
+ if (detaching) detach_dev(t);
3228
+ if (if_block) if_block.d(detaching);
3229
+ if (detaching) detach_dev(if_block_anchor);
3230
+ }
3231
+ };
3232
+
3233
+ dispatch_dev("SvelteRegisterBlock", {
3234
+ block,
3235
+ id: create_else_block.name,
3236
+ type: "else",
3237
+ source: "(85:8) {:else}",
3238
+ ctx
3239
+ });
3240
+
3241
+ return block;
3242
+ }
3243
+
3244
+ // (82:8) {#if tournamentUntilStartDays > 0}
3245
+ function create_if_block_2(ctx) {
3246
+ let div0;
3247
+ let t0;
3248
+ let div1;
3249
+ let t1_value = /*$_*/ ctx[11]("tournamentsDuration.starting") + "";
3250
+ let t1;
3251
+ let t2;
3252
+ let t3;
3253
+ let t4;
3254
+ let t5_value = /*$_*/ ctx[11]("tournamentsDuration.days") + "";
3255
+ let t5;
3256
+
3257
+ const block = {
3258
+ c: function create() {
3259
+ div0 = element("div");
3260
+ t0 = space();
3261
+ div1 = element("div");
3262
+ t1 = text(t1_value);
3263
+ t2 = space();
3264
+ t3 = text(/*tournamentUntilStartDays*/ ctx[6]);
3265
+ t4 = space();
3266
+ t5 = text(t5_value);
3267
+ attr_dev(div0, "class", "ProgressBarFillStarting");
3268
+ add_location(div0, file, 82, 10, 2904);
3269
+ attr_dev(div1, "class", "Remaining");
3270
+ add_location(div1, file, 83, 10, 2958);
3271
+ },
3272
+ m: function mount(target, anchor) {
3273
+ insert_dev(target, div0, anchor);
3274
+ insert_dev(target, t0, anchor);
3275
+ insert_dev(target, div1, anchor);
3276
+ append_dev(div1, t1);
3277
+ append_dev(div1, t2);
3278
+ append_dev(div1, t3);
3279
+ append_dev(div1, t4);
3280
+ append_dev(div1, t5);
3281
+ },
3282
+ p: function update(ctx, dirty) {
3283
+ if (dirty & /*$_*/ 2048 && t1_value !== (t1_value = /*$_*/ ctx[11]("tournamentsDuration.starting") + "")) set_data_dev(t1, t1_value);
3284
+ if (dirty & /*tournamentUntilStartDays*/ 64) set_data_dev(t3, /*tournamentUntilStartDays*/ ctx[6]);
3285
+ if (dirty & /*$_*/ 2048 && t5_value !== (t5_value = /*$_*/ ctx[11]("tournamentsDuration.days") + "")) set_data_dev(t5, t5_value);
3286
+ },
3287
+ d: function destroy(detaching) {
3288
+ if (detaching) detach_dev(div0);
3289
+ if (detaching) detach_dev(t0);
3290
+ if (detaching) detach_dev(div1);
3291
+ }
3292
+ };
3293
+
3294
+ dispatch_dev("SvelteRegisterBlock", {
3295
+ block,
3296
+ id: create_if_block_2.name,
3297
+ type: "if",
3298
+ source: "(82:8) {#if tournamentUntilStartDays > 0}",
3299
+ ctx
3300
+ });
3301
+
3302
+ return block;
3303
+ }
3304
+
3305
+ // (78:6) {#if status == 'Finished' || status == 'Closing' || status == 'Closed'}
3306
+ function create_if_block_1(ctx) {
3307
+ let div0;
3308
+ let t0;
3309
+ let div1;
3310
+ let t1_value = /*$_*/ ctx[11]("tournamentsDuration.finished") + "";
3311
+ let t1;
3312
+
3313
+ const block = {
3314
+ c: function create() {
3315
+ div0 = element("div");
3316
+ t0 = space();
3317
+ div1 = element("div");
3318
+ t1 = text(t1_value);
3319
+ attr_dev(div0, "class", "ProgressBarFillEnd");
3320
+ add_location(div0, file, 78, 8, 2725);
3321
+ attr_dev(div1, "class", "Finished");
3322
+ add_location(div1, file, 79, 8, 2772);
3323
+ },
3324
+ m: function mount(target, anchor) {
3325
+ insert_dev(target, div0, anchor);
3326
+ insert_dev(target, t0, anchor);
3327
+ insert_dev(target, div1, anchor);
3328
+ append_dev(div1, t1);
3329
+ },
3330
+ p: function update(ctx, dirty) {
3331
+ if (dirty & /*$_*/ 2048 && t1_value !== (t1_value = /*$_*/ ctx[11]("tournamentsDuration.finished") + "")) set_data_dev(t1, t1_value);
3332
+ },
3333
+ d: function destroy(detaching) {
3334
+ if (detaching) detach_dev(div0);
3335
+ if (detaching) detach_dev(t0);
3336
+ if (detaching) detach_dev(div1);
3337
+ }
3338
+ };
3339
+
3340
+ dispatch_dev("SvelteRegisterBlock", {
3341
+ block,
3342
+ id: create_if_block_1.name,
3343
+ type: "if",
3344
+ source: "(78:6) {#if status == 'Finished' || status == 'Closing' || status == 'Closed'}",
3345
+ ctx
3346
+ });
3347
+
3348
+ return block;
3349
+ }
3350
+
3351
+ // (87:10) {#if tournamentLeftDays > 0}
3352
+ function create_if_block_3(ctx) {
3353
+ let t0;
3354
+ let t1;
3355
+ let if_block2_anchor;
3356
+ let if_block0 = /*diffMinutes*/ ctx[8] && create_if_block_6(ctx);
3357
+ let if_block1 = /*diffHours*/ ctx[9] && create_if_block_5(ctx);
3358
+ let if_block2 = /*diffDays*/ ctx[10] && create_if_block_4(ctx);
3359
+
3360
+ const block = {
3361
+ c: function create() {
3362
+ if (if_block0) if_block0.c();
3363
+ t0 = space();
3364
+ if (if_block1) if_block1.c();
3365
+ t1 = space();
3366
+ if (if_block2) if_block2.c();
3367
+ if_block2_anchor = empty();
3368
+ },
3369
+ m: function mount(target, anchor) {
3370
+ if (if_block0) if_block0.m(target, anchor);
3371
+ insert_dev(target, t0, anchor);
3372
+ if (if_block1) if_block1.m(target, anchor);
3373
+ insert_dev(target, t1, anchor);
3374
+ if (if_block2) if_block2.m(target, anchor);
3375
+ insert_dev(target, if_block2_anchor, anchor);
3376
+ },
3377
+ p: function update(ctx, dirty) {
3378
+ if (/*diffMinutes*/ ctx[8]) {
3379
+ if (if_block0) {
3380
+ if_block0.p(ctx, dirty);
3381
+ } else {
3382
+ if_block0 = create_if_block_6(ctx);
3383
+ if_block0.c();
3384
+ if_block0.m(t0.parentNode, t0);
3385
+ }
3386
+ } else if (if_block0) {
3387
+ if_block0.d(1);
3388
+ if_block0 = null;
3389
+ }
3390
+
3391
+ if (/*diffHours*/ ctx[9]) {
3392
+ if (if_block1) {
3393
+ if_block1.p(ctx, dirty);
3394
+ } else {
3395
+ if_block1 = create_if_block_5(ctx);
3396
+ if_block1.c();
3397
+ if_block1.m(t1.parentNode, t1);
3398
+ }
3399
+ } else if (if_block1) {
3400
+ if_block1.d(1);
3401
+ if_block1 = null;
3402
+ }
3403
+
3404
+ if (/*diffDays*/ ctx[10]) {
3405
+ if (if_block2) {
3406
+ if_block2.p(ctx, dirty);
3407
+ } else {
3408
+ if_block2 = create_if_block_4(ctx);
3409
+ if_block2.c();
3410
+ if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
3411
+ }
3412
+ } else if (if_block2) {
3413
+ if_block2.d(1);
3414
+ if_block2 = null;
3415
+ }
3416
+ },
3417
+ d: function destroy(detaching) {
3418
+ if (if_block0) if_block0.d(detaching);
3419
+ if (detaching) detach_dev(t0);
3420
+ if (if_block1) if_block1.d(detaching);
3421
+ if (detaching) detach_dev(t1);
3422
+ if (if_block2) if_block2.d(detaching);
3423
+ if (detaching) detach_dev(if_block2_anchor);
3424
+ }
3425
+ };
3426
+
3427
+ dispatch_dev("SvelteRegisterBlock", {
3428
+ block,
3429
+ id: create_if_block_3.name,
3430
+ type: "if",
3431
+ source: "(87:10) {#if tournamentLeftDays > 0}",
3432
+ ctx
3433
+ });
3434
+
3435
+ return block;
3436
+ }
3437
+
3438
+ // (88:12) {#if diffMinutes}
3439
+ function create_if_block_6(ctx) {
3440
+ let div;
3441
+ let t0;
3442
+ let t1;
3443
+ let t2_value = /*$_*/ ctx[11]("tournamentsDuration.minutesleft") + "";
3444
+ let t2;
3445
+
3446
+ const block = {
3447
+ c: function create() {
3448
+ div = element("div");
3449
+ t0 = text(/*tournamentLeftDays*/ ctx[5]);
3450
+ t1 = space();
3451
+ t2 = text(t2_value);
3452
+ attr_dev(div, "class", "Remaining");
3453
+ add_location(div, file, 88, 14, 3255);
3454
+ },
3455
+ m: function mount(target, anchor) {
3456
+ insert_dev(target, div, anchor);
3457
+ append_dev(div, t0);
3458
+ append_dev(div, t1);
3459
+ append_dev(div, t2);
3460
+ },
3461
+ p: function update(ctx, dirty) {
3462
+ if (dirty & /*tournamentLeftDays*/ 32) set_data_dev(t0, /*tournamentLeftDays*/ ctx[5]);
3463
+ if (dirty & /*$_*/ 2048 && t2_value !== (t2_value = /*$_*/ ctx[11]("tournamentsDuration.minutesleft") + "")) set_data_dev(t2, t2_value);
3464
+ },
3465
+ d: function destroy(detaching) {
3466
+ if (detaching) detach_dev(div);
3467
+ }
3468
+ };
3469
+
3470
+ dispatch_dev("SvelteRegisterBlock", {
3471
+ block,
3472
+ id: create_if_block_6.name,
3473
+ type: "if",
3474
+ source: "(88:12) {#if diffMinutes}",
3475
+ ctx
3476
+ });
3477
+
3478
+ return block;
3479
+ }
3480
+
3481
+ // (91:12) {#if diffHours}
3482
+ function create_if_block_5(ctx) {
3483
+ let div;
3484
+ let t0;
3485
+ let t1;
3486
+ let t2_value = /*$_*/ ctx[11]("tournamentsDuration.hoursleft") + "";
3487
+ let t2;
3488
+
3489
+ const block = {
3490
+ c: function create() {
3491
+ div = element("div");
3492
+ t0 = text(/*tournamentLeftDays*/ ctx[5]);
3493
+ t1 = space();
3494
+ t2 = text(t2_value);
3495
+ attr_dev(div, "class", "Remaining");
3496
+ add_location(div, file, 91, 14, 3405);
3497
+ },
3498
+ m: function mount(target, anchor) {
3499
+ insert_dev(target, div, anchor);
3500
+ append_dev(div, t0);
3501
+ append_dev(div, t1);
3502
+ append_dev(div, t2);
3503
+ },
3504
+ p: function update(ctx, dirty) {
3505
+ if (dirty & /*tournamentLeftDays*/ 32) set_data_dev(t0, /*tournamentLeftDays*/ ctx[5]);
3506
+ if (dirty & /*$_*/ 2048 && t2_value !== (t2_value = /*$_*/ ctx[11]("tournamentsDuration.hoursleft") + "")) set_data_dev(t2, t2_value);
3507
+ },
3508
+ d: function destroy(detaching) {
3509
+ if (detaching) detach_dev(div);
3510
+ }
3511
+ };
3512
+
3513
+ dispatch_dev("SvelteRegisterBlock", {
3514
+ block,
3515
+ id: create_if_block_5.name,
3516
+ type: "if",
3517
+ source: "(91:12) {#if diffHours}",
3518
+ ctx
3519
+ });
3520
+
3521
+ return block;
3522
+ }
3523
+
3524
+ // (94:12) {#if diffDays}
3525
+ function create_if_block_4(ctx) {
3526
+ let div;
3527
+ let t0;
3528
+ let t1;
3529
+ let t2_value = /*$_*/ ctx[11]("tournamentsDuration.daysleft") + "";
3530
+ let t2;
3531
+
3532
+ const block = {
3533
+ c: function create() {
3534
+ div = element("div");
3535
+ t0 = text(/*tournamentLeftDays*/ ctx[5]);
3536
+ t1 = space();
3537
+ t2 = text(t2_value);
3538
+ attr_dev(div, "class", "Remaining");
3539
+ add_location(div, file, 94, 14, 3552);
3540
+ },
3541
+ m: function mount(target, anchor) {
3542
+ insert_dev(target, div, anchor);
3543
+ append_dev(div, t0);
3544
+ append_dev(div, t1);
3545
+ append_dev(div, t2);
3546
+ },
3547
+ p: function update(ctx, dirty) {
3548
+ if (dirty & /*tournamentLeftDays*/ 32) set_data_dev(t0, /*tournamentLeftDays*/ ctx[5]);
3549
+ if (dirty & /*$_*/ 2048 && t2_value !== (t2_value = /*$_*/ ctx[11]("tournamentsDuration.daysleft") + "")) set_data_dev(t2, t2_value);
3550
+ },
3551
+ d: function destroy(detaching) {
3552
+ if (detaching) detach_dev(div);
3553
+ }
3554
+ };
3555
+
3556
+ dispatch_dev("SvelteRegisterBlock", {
3557
+ block,
3558
+ id: create_if_block_4.name,
3559
+ type: "if",
3560
+ source: "(94:12) {#if diffDays}",
3561
+ ctx
3562
+ });
3563
+
3564
+ return block;
3565
+ }
3566
+
3567
+ function create_fragment(ctx) {
3568
+ let div;
3569
+ let if_block = /*startdate*/ ctx[0] && /*enddate*/ ctx[1] && create_if_block(ctx);
3570
+
3571
+ const block = {
3572
+ c: function create() {
3573
+ div = element("div");
3574
+ if (if_block) if_block.c();
3575
+ this.c = noop;
3576
+ attr_dev(div, "class", "TournamentDuration");
3577
+ add_location(div, file, 70, 0, 2358);
3578
+ },
3579
+ l: function claim(nodes) {
3580
+ throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
3581
+ },
3582
+ m: function mount(target, anchor) {
3583
+ insert_dev(target, div, anchor);
3584
+ if (if_block) if_block.m(div, null);
3585
+ },
3586
+ p: function update(ctx, [dirty]) {
3587
+ if (/*startdate*/ ctx[0] && /*enddate*/ ctx[1]) {
3588
+ if (if_block) {
3589
+ if_block.p(ctx, dirty);
3590
+ } else {
3591
+ if_block = create_if_block(ctx);
3592
+ if_block.c();
3593
+ if_block.m(div, null);
3594
+ }
3595
+ } else if (if_block) {
3596
+ if_block.d(1);
3597
+ if_block = null;
3598
+ }
3599
+ },
3600
+ i: noop,
3601
+ o: noop,
3602
+ d: function destroy(detaching) {
3603
+ if (detaching) detach_dev(div);
3604
+ if (if_block) if_block.d();
3605
+ }
3606
+ };
3607
+
3608
+ dispatch_dev("SvelteRegisterBlock", {
3609
+ block,
3610
+ id: create_fragment.name,
3611
+ type: "component",
3612
+ source: "",
3613
+ ctx
3614
+ });
3615
+
3616
+ return block;
3617
+ }
3618
+
3619
+ function instance($$self, $$props, $$invalidate) {
3620
+ let $_;
3621
+ validate_store(X, "_");
3622
+ component_subscribe($$self, X, $$value => $$invalidate(11, $_ = $$value));
3623
+ let { $$slots: slots = {}, $$scope } = $$props;
3624
+ validate_slots("undefined", slots, []);
3625
+ let { startdate = "" } = $$props;
3626
+ let { enddate = "" } = $$props;
3627
+ let { status = "" } = $$props;
3628
+ let { lang = "en" } = $$props;
3629
+ let startDate = "";
3630
+ let endDate = "";
3631
+ let tournamentDuration = "";
3632
+ let tournamentLeftDays = "";
3633
+ let tournamentUntilStartDays = "";
3634
+ let step = "";
3635
+ let progress = "";
3636
+ let diffMinutes = false;
3637
+ let diffHours = false;
3638
+ let diffDays = false;
3639
+
3640
+ Object.keys(TournamentsDurationTranslations).forEach(item => {
3641
+ addNewMessages(item, TournamentsDurationTranslations[item]);
3642
+ });
3643
+
3644
+ const formatDate = date => {
3645
+ const dateOptions = { month: "long" };
3646
+ let currentDate = new Date(date);
3647
+ let currentMonth = new Intl.DateTimeFormat(lang, dateOptions).format(currentDate);
3648
+ let currentDay = currentDate.getDate();
3649
+ return `${currentDay} ${currentMonth}, ${currentDate.toLocaleString("en-GB", { hour: "numeric", minute: "numeric" })}, ${currentDate.getUTCFullYear()}`;
3650
+ };
3651
+
3652
+ const formatStartDate = () => {
3653
+ $$invalidate(3, startDate = formatDate(new Date(startdate)));
3654
+ };
3655
+
3656
+ const formatEndDate = () => {
3657
+ $$invalidate(4, endDate = formatDate(new Date(enddate)));
3658
+ };
3659
+
3660
+ const diffTwoDates = (start, end, duration) => {
3661
+ let startDate = new Date(start);
3662
+ let endDate = new Date(end);
3663
+ let diff = (endDate - startDate) / (1000 * 60);
3664
+
3665
+ if (duration == true) {
3666
+ if (diff < 60) {
3667
+ $$invalidate(8, diffMinutes = true);
3668
+ return Math.ceil(diff);
3669
+ } else {
3670
+ if (diff < 1440) {
3671
+ $$invalidate(9, diffHours = true);
3672
+ return Math.ceil(diff / 60);
3673
+ } else {
3674
+ $$invalidate(10, diffDays = true);
3675
+ return Math.ceil(diff / (60 * 24));
3676
+ }
3677
+ }
3678
+ }
3679
+
3680
+ return Math.ceil(diff / (60 * 24));
3681
+ };
3682
+
3683
+ const getDuration = () => {
3684
+ tournamentDuration = diffTwoDates(startdate, enddate, false);
3685
+ $$invalidate(5, tournamentLeftDays = diffTwoDates(new Date(), enddate, true));
3686
+ $$invalidate(6, tournamentUntilStartDays = diffTwoDates(new Date(), startdate, false));
3687
+
3688
+ // This if should not be needed - tournamentLeftDays should be positive
3689
+ if (tournamentLeftDays > 0) {
3690
+ step = 100 / tournamentDuration;
3691
+ $$invalidate(7, progress = Math.floor((tournamentDuration - tournamentLeftDays) * step));
3692
+ }
3693
+ };
3694
+
3695
+ const writable_props = ["startdate", "enddate", "status", "lang"];
3696
+
3697
+ Object_1.keys($$props).forEach(key => {
3698
+ if (!~writable_props.indexOf(key) && key.slice(0, 2) !== "$$") console.warn(`<undefined> was created with unknown prop '${key}'`);
3699
+ });
3700
+
3701
+ $$self.$$set = $$props => {
3702
+ if ("startdate" in $$props) $$invalidate(0, startdate = $$props.startdate);
3703
+ if ("enddate" in $$props) $$invalidate(1, enddate = $$props.enddate);
3704
+ if ("status" in $$props) $$invalidate(2, status = $$props.status);
3705
+ if ("lang" in $$props) $$invalidate(15, lang = $$props.lang);
3706
+ };
3707
+
3708
+ $$self.$capture_state = () => ({
3709
+ _: X,
3710
+ addNewMessages,
3711
+ setLocale,
3712
+ TournamentsDurationTranslations,
3713
+ startdate,
3714
+ enddate,
3715
+ status,
3716
+ lang,
3717
+ startDate,
3718
+ endDate,
3719
+ tournamentDuration,
3720
+ tournamentLeftDays,
3721
+ tournamentUntilStartDays,
3722
+ step,
3723
+ progress,
3724
+ diffMinutes,
3725
+ diffHours,
3726
+ diffDays,
3727
+ formatDate,
3728
+ formatStartDate,
3729
+ formatEndDate,
3730
+ diffTwoDates,
3731
+ getDuration,
3732
+ $_
3733
+ });
3734
+
3735
+ $$self.$inject_state = $$props => {
3736
+ if ("startdate" in $$props) $$invalidate(0, startdate = $$props.startdate);
3737
+ if ("enddate" in $$props) $$invalidate(1, enddate = $$props.enddate);
3738
+ if ("status" in $$props) $$invalidate(2, status = $$props.status);
3739
+ if ("lang" in $$props) $$invalidate(15, lang = $$props.lang);
3740
+ if ("startDate" in $$props) $$invalidate(3, startDate = $$props.startDate);
3741
+ if ("endDate" in $$props) $$invalidate(4, endDate = $$props.endDate);
3742
+ if ("tournamentDuration" in $$props) tournamentDuration = $$props.tournamentDuration;
3743
+ if ("tournamentLeftDays" in $$props) $$invalidate(5, tournamentLeftDays = $$props.tournamentLeftDays);
3744
+ if ("tournamentUntilStartDays" in $$props) $$invalidate(6, tournamentUntilStartDays = $$props.tournamentUntilStartDays);
3745
+ if ("step" in $$props) step = $$props.step;
3746
+ if ("progress" in $$props) $$invalidate(7, progress = $$props.progress);
3747
+ if ("diffMinutes" in $$props) $$invalidate(8, diffMinutes = $$props.diffMinutes);
3748
+ if ("diffHours" in $$props) $$invalidate(9, diffHours = $$props.diffHours);
3749
+ if ("diffDays" in $$props) $$invalidate(10, diffDays = $$props.diffDays);
3750
+ };
3751
+
3752
+ if ($$props && "$$inject" in $$props) {
3753
+ $$self.$inject_state($$props.$$inject);
3754
+ }
3755
+
3756
+ return [
3757
+ startdate,
3758
+ enddate,
3759
+ status,
3760
+ startDate,
3761
+ endDate,
3762
+ tournamentLeftDays,
3763
+ tournamentUntilStartDays,
3764
+ progress,
3765
+ diffMinutes,
3766
+ diffHours,
3767
+ diffDays,
3768
+ $_,
3769
+ formatStartDate,
3770
+ formatEndDate,
3771
+ getDuration,
3772
+ lang
3773
+ ];
3774
+ }
3775
+
3776
+ class CasinoTournmanetsThumbnailDuration extends SvelteElement {
3777
+ constructor(options) {
3778
+ super();
3779
+ this.shadowRoot.innerHTML = `<style>*,*::before,*::after{margin:0;padding:0;list-style:none;text-decoration:none;outline:none;box-sizing:border-box;font-family:"Helvetica Neue", "Helvetica", sans-serif}.TournamentDates{margin-left:20px;margin-right:20px;display:flex;justify-content:space-between}.StartDate{font-size:11px;color:#58586B}.EndDate{font-size:11px;align-content:flex-end;color:#58586B}.ProgressBar{margin:5px 20px;height:8px;background:#fff}.ProgressBarFill{background-color:#48952a;height:8px}.ProgressBarFillEnd{background-color:#48952a;height:8px}.ProgressBarFillStarting{background-color:#58586B;height:8px}.Remaining,.Finished{font-size:10px;padding-top:5px;text-align:right;text-transform:uppercase}.Finished{color:#1B9800}</style>`;
3780
+
3781
+ init(
3782
+ this,
3783
+ {
3784
+ target: this.shadowRoot,
3785
+ props: attribute_to_object(this.attributes),
3786
+ customElement: true
3787
+ },
3788
+ instance,
3789
+ create_fragment,
3790
+ safe_not_equal,
3791
+ {
3792
+ startdate: 0,
3793
+ enddate: 1,
3794
+ status: 2,
3795
+ lang: 15
3796
+ }
3797
+ );
3798
+
3799
+ if (options) {
3800
+ if (options.target) {
3801
+ insert_dev(options.target, this, options.anchor);
3802
+ }
3803
+
3804
+ if (options.props) {
3805
+ this.$set(options.props);
3806
+ flush();
3807
+ }
3808
+ }
3809
+ }
3810
+
3811
+ static get observedAttributes() {
3812
+ return ["startdate", "enddate", "status", "lang"];
3813
+ }
3814
+
3815
+ get startdate() {
3816
+ return this.$$.ctx[0];
3817
+ }
3818
+
3819
+ set startdate(startdate) {
3820
+ this.$set({ startdate });
3821
+ flush();
3822
+ }
3823
+
3824
+ get enddate() {
3825
+ return this.$$.ctx[1];
3826
+ }
3827
+
3828
+ set enddate(enddate) {
3829
+ this.$set({ enddate });
3830
+ flush();
3831
+ }
3832
+
3833
+ get status() {
3834
+ return this.$$.ctx[2];
3835
+ }
3836
+
3837
+ set status(status) {
3838
+ this.$set({ status });
3839
+ flush();
3840
+ }
3841
+
3842
+ get lang() {
3843
+ return this.$$.ctx[15];
3844
+ }
3845
+
3846
+ set lang(lang) {
3847
+ this.$set({ lang });
3848
+ flush();
3849
+ }
3850
+ }
3851
+
3852
+ !customElements.get('casino-tournaments-thumbnail-duration') && customElements.define('casino-tournaments-thumbnail-duration', CasinoTournmanetsThumbnailDuration);
3853
+
3854
+ return CasinoTournmanetsThumbnailDuration;
3855
+
3856
+ })));
3857
+ //# sourceMappingURL=casino-tournmanets-thumbnail-duration.js.map