@everymatrix/casino-engagement-suite-luckywheel-list 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.esm.js +1 -0
  2. package/dist/casino-engagement-suite-luckywheel-list/index.esm.js +1 -0
  3. package/dist/casino-engagement-suite-luckywheel-list/p-c227cdc7.js +2 -0
  4. package/dist/casino-engagement-suite-luckywheel-list/p-d1ea0bae.entry.js +1 -0
  5. package/dist/casino-engagement-suite-luckywheel-list/p-e1255160.js +1 -0
  6. package/dist/casino-engagement-suite-luckywheel-list/p-f007d81f.js +1 -0
  7. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  8. package/dist/cjs/casino-engagement-suite-luckywheel-list-726f2e8f.js +2574 -0
  9. package/dist/cjs/casino-engagement-suite-luckywheel-list.cjs.js +25 -0
  10. package/dist/cjs/casino-engagement-suite-luckywheel-list_2.cjs.entry.js +73 -0
  11. package/dist/cjs/index-3815b8e0.js +1333 -0
  12. package/dist/cjs/index.cjs.js +10 -0
  13. package/dist/cjs/loader.cjs.js +15 -0
  14. package/dist/collection/collection-manifest.json +19 -0
  15. package/dist/collection/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.css +454 -0
  16. package/dist/collection/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.js +467 -0
  17. package/dist/collection/components/casino-engagement-suite-luckywheel-list/index.js +1 -0
  18. package/dist/collection/index.js +1 -0
  19. package/dist/collection/models/luckywheel.js +14 -0
  20. package/dist/collection/renders/LuckyWheelsHistory.js +52 -0
  21. package/dist/collection/utils/locale.utils.js +46 -0
  22. package/dist/collection/utils/utils.js +3 -0
  23. package/dist/esm/app-globals-0f993ce5.js +3 -0
  24. package/dist/esm/casino-engagement-suite-luckywheel-list-864bcb68.js +2572 -0
  25. package/dist/esm/casino-engagement-suite-luckywheel-list.js +20 -0
  26. package/dist/esm/casino-engagement-suite-luckywheel-list_2.entry.js +68 -0
  27. package/dist/esm/index-68de30f0.js +1305 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/esm/loader.js +11 -0
  30. package/dist/index.cjs.js +1 -0
  31. package/dist/index.js +1 -0
  32. package/dist/stencil.config.dev.js +14 -0
  33. package/dist/stencil.config.js +17 -0
  34. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/casino-engagement-suite-luckywheel-list/.stencil/packages/stencil/casino-engagement-suite-luckywheel-list/stencil.config.d.ts +2 -0
  35. package/dist/types/Users/maria.bumbar/Desktop/widgets-monorepo/packages/stencil/casino-engagement-suite-luckywheel-list/.stencil/packages/stencil/casino-engagement-suite-luckywheel-list/stencil.config.dev.d.ts +2 -0
  36. package/dist/types/components/casino-engagement-suite-luckywheel-list/casino-engagement-suite-luckywheel-list.d.ts +84 -0
  37. package/dist/types/components/casino-engagement-suite-luckywheel-list/index.d.ts +1 -0
  38. package/dist/types/components.d.ts +119 -0
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/models/luckywheel.d.ts +41 -0
  41. package/dist/types/renders/LuckyWheelsHistory.d.ts +6 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1680 -0
  43. package/dist/types/utils/locale.utils.d.ts +2 -0
  44. package/dist/types/utils/utils.d.ts +1 -0
  45. package/loader/cdn.js +1 -0
  46. package/loader/index.cjs.js +1 -0
  47. package/loader/index.d.ts +24 -0
  48. package/loader/index.es2017.js +1 -0
  49. package/loader/index.js +2 -0
  50. package/loader/package.json +11 -0
  51. package/package.json +26 -0
@@ -0,0 +1,2572 @@
1
+ import { h, r as registerInstance, c as createEvent, g as getElement } from './index-68de30f0.js';
2
+
3
+ const DEFAULT_LANGUAGE = 'en';
4
+ const SUPPORTED_LANGUAGES = ['en'];
5
+ const TRANSLATIONS = {
6
+ en: {
7
+ luckywheels: 'LuckyWheels',
8
+ join: 'Join',
9
+ unjoin: 'Unjoin',
10
+ new: 'new',
11
+ noluckywheels: 'No Unlocked LuckyWheel',
12
+ tryOtherGames: 'Try winning LuckyWheel as rewards or launching other booster games',
13
+ tooltip: 'LuckyWheels where your real money bets contribute towards the level progress to achieve the level reward',
14
+ history: 'History',
15
+ rewards: 'Rewards',
16
+ issued: 'Issued',
17
+ time: 'Time',
18
+ loading: 'Loading...',
19
+ noHistory: 'No LuckyWheels’ history available (last 30 days)',
20
+ freeSpins: 'Free Spins',
21
+ luckyWheel: 'LuckyWheel',
22
+ leaderboard: 'Leaderboard',
23
+ mission: 'Mission',
24
+ canceled: 'The luckywheel has been canceled.',
25
+ support: 'Please, contact support.'
26
+ }
27
+ };
28
+ const translate = (key, customLang) => {
29
+ const lang = customLang;
30
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
31
+ };
32
+ const getTranslations = (url) => {
33
+ // fetch url, get the data, replace the TRANSLATIONS content
34
+ return new Promise((resolve, reject) => {
35
+ fetch(url)
36
+ .then((res) => res.json())
37
+ .then((data) => {
38
+ Object.keys(data).forEach((item) => {
39
+ for (let key in data[item]) {
40
+ TRANSLATIONS[item][key] = data[item][key];
41
+ }
42
+ });
43
+ resolve(TRANSLATIONS);
44
+ }).catch(err => {
45
+ reject(err);
46
+ });
47
+ });
48
+ };
49
+
50
+ var GeneralAnimationLoadingCczQRHih = {};
51
+
52
+ (function (exports) {
53
+ var V=Object.defineProperty,z=Object.defineProperties;var F=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var x=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))G.call(t,n)&&x(e,n,t[n]);if(N)for(var n of N(t))q.call(t,n)&&x(e,n,t[n]);return e},M=(e,t)=>z(e,F(t));var $=(e,t,n)=>x(e,typeof t!="symbol"?t+"":t,n);var T=(e,t,n)=>new Promise((s,l)=>{var i=o=>{try{u(n.next(o));}catch(r){l(r);}},c=o=>{try{u(n.throw(o));}catch(r){l(r);}},u=o=>o.done?s(o.value):Promise.resolve(o.value).then(i,c);u((n=n.apply(e,t)).next());});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function _(){}function H(e){return e()}function B(){return Object.create(null)}function b(e){e.forEach(H);}function I(e){return typeof e=="function"}function K(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Q(e){return Object.keys(e).length===0}function W(e,t){e.appendChild(t);}function X(e,t,n){const s=Y(e);if(!s.getElementById(t)){const l=L("style");l.id=t,l.textContent=n,Z(s,l);}}function Y(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function Z(e,t){return W(e.head||e,t),t.sheet}function U(e,t,n){e.insertBefore(t,n||null);}function C(e){e.parentNode&&e.parentNode.removeChild(e);}function L(e){return document.createElement(e)}function tt(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n);}function et(e){return Array.from(e.childNodes)}function nt(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0;}),t}let j;function g(e){j=e;}const h=[],k=[];let p=[];const R=[],it=Promise.resolve();let v=!1;function st(){v||(v=!0,it.then(y));}function E(e){p.push(e);}const w=new Set;let a=0;function y(){if(a!==0)return;const e=j;do{try{for(;a<h.length;){const t=h[a];a++,g(t),rt(t.$$);}}catch(t){throw h.length=0,a=0,t}for(g(null),h.length=0,a=0;k.length;)k.pop()();for(let t=0;t<p.length;t+=1){const n=p[t];w.has(n)||(w.add(n),n());}p.length=0;}while(h.length);for(;R.length;)R.pop()();v=!1,w.clear(),g(e);}function rt(e){if(e.fragment!==null){e.update(),b(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(E);}}function lt(e){const t=[],n=[];p.forEach(s=>e.indexOf(s)===-1?t.push(s):n.push(s)),n.forEach(s=>s()),p=t;}const ct=new Set;function ot(e,t){e&&e.i&&(ct.delete(e),e.i(t));}function ut(e,t,n){const{fragment:s,after_update:l}=e.$$;s&&s.m(t,n),E(()=>{const i=e.$$.on_mount.map(H).filter(I);e.$$.on_destroy?e.$$.on_destroy.push(...i):b(i),e.$$.on_mount=[];}),l.forEach(E);}function dt(e,t){const n=e.$$;n.fragment!==null&&(lt(n.after_update),b(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[]);}function $t(e,t){e.$$.dirty[0]===-1&&(h.push(e),st(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31;}function ft(e,t,n,s,l,i,c=null,u=[-1]){const o=j;g(e);const r=e.$$={fragment:null,ctx:[],props:i,update:_,not_equal:l,bound:B(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(o?o.$$.context:[])),callbacks:B(),dirty:u,skip_bound:!1,root:t.target||o.$$.root};c&&c(r.root);let f=!1;if(r.ctx=n?n(e,t.props||{},(d,O,...S)=>{const A=S.length?S[0]:O;return r.ctx&&l(r.ctx[d],r.ctx[d]=A)&&(!r.skip_bound&&r.bound[d]&&r.bound[d](A),f&&$t(e,d)),O}):[],r.update(),f=!0,b(r.before_update),r.fragment=s?s(r.ctx):!1,t.target){if(t.hydrate){const d=et(t.target);r.fragment&&r.fragment.l(d),d.forEach(C);}else r.fragment&&r.fragment.c();t.intro&&ot(e.$$.fragment),ut(e,t.target,t.anchor),y();}g(o);}let D;typeof HTMLElement=="function"&&(D=class extends HTMLElement{constructor(t,n,s){super();$(this,"$$ctor");$(this,"$$s");$(this,"$$c");$(this,"$$cn",!1);$(this,"$$d",{});$(this,"$$r",!1);$(this,"$$p_d",{});$(this,"$$l",{});$(this,"$$l_u",new Map);this.$$ctor=t,this.$$s=n,s&&this.attachShadow({mode:"open"});}addEventListener(t,n,s){if(this.$$l[t]=this.$$l[t]||[],this.$$l[t].push(n),this.$$c){const l=this.$$c.$on(t,n);this.$$l_u.set(n,l);}super.addEventListener(t,n,s);}removeEventListener(t,n,s){if(super.removeEventListener(t,n,s),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n));}}connectedCallback(){return T(this,null,function*(){if(this.$$cn=!0,!this.$$c){let t=function(i){return ()=>{let c;return {c:function(){c=L("slot"),i!=="default"&&tt(c,"name",i);},m:function(r,f){U(r,c,f);},d:function(r){r&&C(c);}}}};if(yield Promise.resolve(),!this.$$cn||this.$$c)return;const n={},s=nt(this);for(const i of this.$$s)i in s&&(n[i]=[t(i)]);for(const i of this.attributes){const c=this.$$g_p(i.name);c in this.$$d||(this.$$d[c]=m(c,i.value,this.$$p_d,"toProp"));}for(const i in this.$$p_d)!(i in this.$$d)&&this[i]!==void 0&&(this.$$d[i]=this[i],delete this[i]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:M(P({},this.$$d),{$$slots:n,$$scope:{ctx:[]}})});const l=()=>{this.$$r=!0;for(const i in this.$$p_d)if(this.$$d[i]=this.$$c.$$.ctx[this.$$c.$$.props[i]],this.$$p_d[i].reflect){const c=m(i,this.$$d[i],this.$$p_d,"toAttribute");c==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,c);}this.$$r=!1;};this.$$c.$$.after_update.push(l),l();for(const i in this.$$l)for(const c of this.$$l[i]){const u=this.$$c.$on(i,c);this.$$l_u.set(c,u);}this.$$l={};}})}attributeChangedCallback(t,n,s){var l;this.$$r||(t=this.$$g_p(t),this.$$d[t]=m(t,s,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[t]:this.$$d[t]}));}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0);});}$$g_p(t){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===t||!this.$$p_d[n].attribute&&n.toLowerCase()===t)||t}});function m(e,t,n,s){var i;const l=(i=n[e])==null?void 0:i.type;if(t=l==="Boolean"&&typeof t!="boolean"?t!=null:t,!s||!n[e])return t;if(s==="toAttribute")switch(l){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t==null?null:t;default:return t}else switch(l){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function at(e,t,n,s,l,i){let c=class extends D{constructor(){super(e,n,l),this.$$p_d=t;}static get observedAttributes(){return Object.keys(t).map(u=>(t[u].attribute||u).toLowerCase())}};return Object.keys(t).forEach(u=>{Object.defineProperty(c.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(o){var r;o=m(u,o,t),this.$$d[u]=o,(r=this.$$c)==null||r.$set({[u]:o});}});}),s.forEach(u=>{Object.defineProperty(c.prototype,u,{get(){var o;return (o=this.$$c)==null?void 0:o[u]}});}),e.element=c,c}class ht{constructor(){$(this,"$$");$(this,"$$set");}$destroy(){dt(this,1),this.$destroy=_;}$on(t,n){if(!I(n))return _;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(n),()=>{const l=s.indexOf(n);l!==-1&&s.splice(l,1);}}$set(t){this.$$set&&!Q(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1);}}const _t="4";typeof window!="undefined"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(_t);function pt(e){X(e,"svelte-gnt082",".LoaderContainer{display:flex;justify-content:center}.lds-ellipsis{display:inline-block;position:relative;width:80px;height:80px}.lds-ellipsis div{position:absolute;top:33px;width:13px;height:13px;border-radius:50%;background:#d1d1d1;animation-timing-function:cubic-bezier(0, 1, 1, 0)}.lds-ellipsis div:nth-child(1){left:8px;animation:lds-ellipsis1 0.6s infinite}.lds-ellipsis div:nth-child(2){left:8px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(3){left:32px;animation:lds-ellipsis2 0.6s infinite}.lds-ellipsis div:nth-child(4){left:56px;animation:lds-ellipsis3 0.6s infinite}@keyframes lds-ellipsis1{0%{transform:scale(0)}100%{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}100%{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0, 0)}100%{transform:translate(24px, 0)}}");}function gt(e){let t;return {c(){t=L("div"),t.innerHTML='<section class="LoaderContainer" part="LoaderContainer"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></section>';},m(n,s){U(n,t,s),e[3](t);},p:_,i:_,o:_,d(n){n&&C(t),e[3](null);}}}function mt(e,t,n){let{clientstyling:s=""}=t,{clientstylingurl:l=""}=t,i;const c=()=>{let r=document.createElement("style");r.innerHTML=s,i.appendChild(r);},u=()=>{let r=new URL(l),f=document.createElement("style");fetch(r.href).then(d=>d.text()).then(d=>{f.innerHTML=d,setTimeout(()=>{i.appendChild(f);},1),setTimeout(()=>{},500);});};function o(r){k[r?"unshift":"push"](()=>{i=r,n(0,i);});}return e.$$set=r=>{"clientstyling"in r&&n(1,s=r.clientstyling),"clientstylingurl"in r&&n(2,l=r.clientstylingurl);},e.$$.update=()=>{e.$$.dirty&3&&s&&i&&c(),e.$$.dirty&5&&l&&i&&u();},[i,s,l,o]}class J extends ht{constructor(t){super(),ft(this,t,mt,gt,K,{clientstyling:1,clientstylingurl:2},pt);}get clientstyling(){return this.$$.ctx[1]}set clientstyling(t){this.$$set({clientstyling:t}),y();}get clientstylingurl(){return this.$$.ctx[2]}set clientstylingurl(t){this.$$set({clientstylingurl:t}),y();}}at(J,{clientstyling:{},clientstylingurl:{}},[],[],!0);exports.default=J;
54
+ }(GeneralAnimationLoadingCczQRHih));
55
+
56
+ if(typeof window!="undefined"){let n=function(t){return function(...i){try{return t.apply(this,i)}catch(e){if(e instanceof DOMException&&e.message.includes("has already been used with this registry")||e.message.includes("Cannot define multiple custom elements with the same tag name"))return !1;throw e}}};customElements.define=n(customElements.define),Promise.resolve().then(()=>GeneralAnimationLoadingCczQRHih).then(({default:t})=>{!customElements.get("general-animation-loading")&&customElements.define("general-animation-loading",t.element);});}
57
+
58
+ var LuckyWheelRewardType;
59
+ (function (LuckyWheelRewardType) {
60
+ LuckyWheelRewardType[LuckyWheelRewardType["FreeSpins"] = 0] = "FreeSpins";
61
+ LuckyWheelRewardType[LuckyWheelRewardType["LuckyWheel"] = 1] = "LuckyWheel";
62
+ LuckyWheelRewardType[LuckyWheelRewardType["Leaderboard"] = 2] = "Leaderboard";
63
+ LuckyWheelRewardType[LuckyWheelRewardType["Challenge"] = 3] = "Challenge";
64
+ LuckyWheelRewardType[LuckyWheelRewardType["Custom"] = 4] = "Custom";
65
+ })(LuckyWheelRewardType || (LuckyWheelRewardType = {}));
66
+ var LuckyWheelHistoryLevelStatus;
67
+ (function (LuckyWheelHistoryLevelStatus) {
68
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Completed"] = 0] = "Completed";
69
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Expired"] = 1] = "Expired";
70
+ LuckyWheelHistoryLevelStatus[LuckyWheelHistoryLevelStatus["Forfeited"] = 2] = "Forfeited";
71
+ })(LuckyWheelHistoryLevelStatus || (LuckyWheelHistoryLevelStatus = {}));
72
+
73
+ function _typeof(o) {
74
+ "@babel/helpers - typeof";
75
+
76
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
77
+ return typeof o;
78
+ } : function (o) {
79
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
80
+ }, _typeof(o);
81
+ }
82
+
83
+ function toInteger(dirtyNumber) {
84
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
85
+ return NaN;
86
+ }
87
+ var number = Number(dirtyNumber);
88
+ if (isNaN(number)) {
89
+ return number;
90
+ }
91
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
92
+ }
93
+
94
+ function requiredArgs(required, args) {
95
+ if (args.length < required) {
96
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @name toDate
102
+ * @category Common Helpers
103
+ * @summary Convert the given argument to an instance of Date.
104
+ *
105
+ * @description
106
+ * Convert the given argument to an instance of Date.
107
+ *
108
+ * If the argument is an instance of Date, the function returns its clone.
109
+ *
110
+ * If the argument is a number, it is treated as a timestamp.
111
+ *
112
+ * If the argument is none of the above, the function returns Invalid Date.
113
+ *
114
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
115
+ *
116
+ * @param {Date|Number} argument - the value to convert
117
+ * @returns {Date} the parsed date in the local time zone
118
+ * @throws {TypeError} 1 argument required
119
+ *
120
+ * @example
121
+ * // Clone the date:
122
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
123
+ * //=> Tue Feb 11 2014 11:30:30
124
+ *
125
+ * @example
126
+ * // Convert the timestamp to date:
127
+ * const result = toDate(1392098430000)
128
+ * //=> Tue Feb 11 2014 11:30:30
129
+ */
130
+ function toDate(argument) {
131
+ requiredArgs(1, arguments);
132
+ var argStr = Object.prototype.toString.call(argument);
133
+
134
+ // Clone the date
135
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
136
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
137
+ return new Date(argument.getTime());
138
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
139
+ return new Date(argument);
140
+ } else {
141
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
142
+ // eslint-disable-next-line no-console
143
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
144
+ // eslint-disable-next-line no-console
145
+ console.warn(new Error().stack);
146
+ }
147
+ return new Date(NaN);
148
+ }
149
+ }
150
+
151
+ /**
152
+ * @name addMilliseconds
153
+ * @category Millisecond Helpers
154
+ * @summary Add the specified number of milliseconds to the given date.
155
+ *
156
+ * @description
157
+ * Add the specified number of milliseconds to the given date.
158
+ *
159
+ * @param {Date|Number} date - the date to be changed
160
+ * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
161
+ * @returns {Date} the new date with the milliseconds added
162
+ * @throws {TypeError} 2 arguments required
163
+ *
164
+ * @example
165
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
166
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
167
+ * //=> Thu Jul 10 2014 12:45:30.750
168
+ */
169
+ function addMilliseconds(dirtyDate, dirtyAmount) {
170
+ requiredArgs(2, arguments);
171
+ var timestamp = toDate(dirtyDate).getTime();
172
+ var amount = toInteger(dirtyAmount);
173
+ return new Date(timestamp + amount);
174
+ }
175
+
176
+ var defaultOptions = {};
177
+ function getDefaultOptions() {
178
+ return defaultOptions;
179
+ }
180
+
181
+ /**
182
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
183
+ * They usually appear for dates that denote time before the timezones were introduced
184
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
185
+ * and GMT+01:00:00 after that date)
186
+ *
187
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
188
+ * which would lead to incorrect calculations.
189
+ *
190
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
191
+ */
192
+ function getTimezoneOffsetInMilliseconds(date) {
193
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
194
+ utcDate.setUTCFullYear(date.getFullYear());
195
+ return date.getTime() - utcDate.getTime();
196
+ }
197
+
198
+ /**
199
+ * @name isDate
200
+ * @category Common Helpers
201
+ * @summary Is the given value a date?
202
+ *
203
+ * @description
204
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
205
+ *
206
+ * @param {*} value - the value to check
207
+ * @returns {boolean} true if the given value is a date
208
+ * @throws {TypeError} 1 arguments required
209
+ *
210
+ * @example
211
+ * // For a valid date:
212
+ * const result = isDate(new Date())
213
+ * //=> true
214
+ *
215
+ * @example
216
+ * // For an invalid date:
217
+ * const result = isDate(new Date(NaN))
218
+ * //=> true
219
+ *
220
+ * @example
221
+ * // For some value:
222
+ * const result = isDate('2014-02-31')
223
+ * //=> false
224
+ *
225
+ * @example
226
+ * // For an object:
227
+ * const result = isDate({})
228
+ * //=> false
229
+ */
230
+ function isDate(value) {
231
+ requiredArgs(1, arguments);
232
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
233
+ }
234
+
235
+ /**
236
+ * @name isValid
237
+ * @category Common Helpers
238
+ * @summary Is the given date valid?
239
+ *
240
+ * @description
241
+ * Returns false if argument is Invalid Date and true otherwise.
242
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
243
+ * Invalid Date is a Date, whose time value is NaN.
244
+ *
245
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
246
+ *
247
+ * @param {*} date - the date to check
248
+ * @returns {Boolean} the date is valid
249
+ * @throws {TypeError} 1 argument required
250
+ *
251
+ * @example
252
+ * // For the valid date:
253
+ * const result = isValid(new Date(2014, 1, 31))
254
+ * //=> true
255
+ *
256
+ * @example
257
+ * // For the value, convertable into a date:
258
+ * const result = isValid(1393804800000)
259
+ * //=> true
260
+ *
261
+ * @example
262
+ * // For the invalid date:
263
+ * const result = isValid(new Date(''))
264
+ * //=> false
265
+ */
266
+ function isValid(dirtyDate) {
267
+ requiredArgs(1, arguments);
268
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
269
+ return false;
270
+ }
271
+ var date = toDate(dirtyDate);
272
+ return !isNaN(Number(date));
273
+ }
274
+
275
+ /**
276
+ * @name subMilliseconds
277
+ * @category Millisecond Helpers
278
+ * @summary Subtract the specified number of milliseconds from the given date.
279
+ *
280
+ * @description
281
+ * Subtract the specified number of milliseconds from the given date.
282
+ *
283
+ * @param {Date|Number} date - the date to be changed
284
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
285
+ * @returns {Date} the new date with the milliseconds subtracted
286
+ * @throws {TypeError} 2 arguments required
287
+ *
288
+ * @example
289
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
290
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
291
+ * //=> Thu Jul 10 2014 12:45:29.250
292
+ */
293
+ function subMilliseconds(dirtyDate, dirtyAmount) {
294
+ requiredArgs(2, arguments);
295
+ var amount = toInteger(dirtyAmount);
296
+ return addMilliseconds(dirtyDate, -amount);
297
+ }
298
+
299
+ var MILLISECONDS_IN_DAY = 86400000;
300
+ function getUTCDayOfYear(dirtyDate) {
301
+ requiredArgs(1, arguments);
302
+ var date = toDate(dirtyDate);
303
+ var timestamp = date.getTime();
304
+ date.setUTCMonth(0, 1);
305
+ date.setUTCHours(0, 0, 0, 0);
306
+ var startOfYearTimestamp = date.getTime();
307
+ var difference = timestamp - startOfYearTimestamp;
308
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
309
+ }
310
+
311
+ function startOfUTCISOWeek(dirtyDate) {
312
+ requiredArgs(1, arguments);
313
+ var weekStartsOn = 1;
314
+ var date = toDate(dirtyDate);
315
+ var day = date.getUTCDay();
316
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
317
+ date.setUTCDate(date.getUTCDate() - diff);
318
+ date.setUTCHours(0, 0, 0, 0);
319
+ return date;
320
+ }
321
+
322
+ function getUTCISOWeekYear(dirtyDate) {
323
+ requiredArgs(1, arguments);
324
+ var date = toDate(dirtyDate);
325
+ var year = date.getUTCFullYear();
326
+ var fourthOfJanuaryOfNextYear = new Date(0);
327
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
328
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
329
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
330
+ var fourthOfJanuaryOfThisYear = new Date(0);
331
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
332
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
333
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
334
+ if (date.getTime() >= startOfNextYear.getTime()) {
335
+ return year + 1;
336
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
337
+ return year;
338
+ } else {
339
+ return year - 1;
340
+ }
341
+ }
342
+
343
+ function startOfUTCISOWeekYear(dirtyDate) {
344
+ requiredArgs(1, arguments);
345
+ var year = getUTCISOWeekYear(dirtyDate);
346
+ var fourthOfJanuary = new Date(0);
347
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
348
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
349
+ var date = startOfUTCISOWeek(fourthOfJanuary);
350
+ return date;
351
+ }
352
+
353
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
354
+ function getUTCISOWeek(dirtyDate) {
355
+ requiredArgs(1, arguments);
356
+ var date = toDate(dirtyDate);
357
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
358
+
359
+ // Round the number of days to the nearest integer
360
+ // because the number of milliseconds in a week is not constant
361
+ // (e.g. it's different in the week of the daylight saving time clock shift)
362
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
363
+ }
364
+
365
+ function startOfUTCWeek(dirtyDate, options) {
366
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
367
+ requiredArgs(1, arguments);
368
+ var defaultOptions = getDefaultOptions();
369
+ var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
370
+
371
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
372
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
373
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
374
+ }
375
+ var date = toDate(dirtyDate);
376
+ var day = date.getUTCDay();
377
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
378
+ date.setUTCDate(date.getUTCDate() - diff);
379
+ date.setUTCHours(0, 0, 0, 0);
380
+ return date;
381
+ }
382
+
383
+ function getUTCWeekYear(dirtyDate, options) {
384
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
385
+ requiredArgs(1, arguments);
386
+ var date = toDate(dirtyDate);
387
+ var year = date.getUTCFullYear();
388
+ var defaultOptions = getDefaultOptions();
389
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
390
+
391
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
392
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
393
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
394
+ }
395
+ var firstWeekOfNextYear = new Date(0);
396
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
397
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
398
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
399
+ var firstWeekOfThisYear = new Date(0);
400
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
401
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
402
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
403
+ if (date.getTime() >= startOfNextYear.getTime()) {
404
+ return year + 1;
405
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
406
+ return year;
407
+ } else {
408
+ return year - 1;
409
+ }
410
+ }
411
+
412
+ function startOfUTCWeekYear(dirtyDate, options) {
413
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
414
+ requiredArgs(1, arguments);
415
+ var defaultOptions = getDefaultOptions();
416
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
417
+ var year = getUTCWeekYear(dirtyDate, options);
418
+ var firstWeek = new Date(0);
419
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
420
+ firstWeek.setUTCHours(0, 0, 0, 0);
421
+ var date = startOfUTCWeek(firstWeek, options);
422
+ return date;
423
+ }
424
+
425
+ var MILLISECONDS_IN_WEEK = 604800000;
426
+ function getUTCWeek(dirtyDate, options) {
427
+ requiredArgs(1, arguments);
428
+ var date = toDate(dirtyDate);
429
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
430
+
431
+ // Round the number of days to the nearest integer
432
+ // because the number of milliseconds in a week is not constant
433
+ // (e.g. it's different in the week of the daylight saving time clock shift)
434
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
435
+ }
436
+
437
+ function addLeadingZeros(number, targetLength) {
438
+ var sign = number < 0 ? '-' : '';
439
+ var output = Math.abs(number).toString();
440
+ while (output.length < targetLength) {
441
+ output = '0' + output;
442
+ }
443
+ return sign + output;
444
+ }
445
+
446
+ /*
447
+ * | | Unit | | Unit |
448
+ * |-----|--------------------------------|-----|--------------------------------|
449
+ * | a | AM, PM | A* | |
450
+ * | d | Day of month | D | |
451
+ * | h | Hour [1-12] | H | Hour [0-23] |
452
+ * | m | Minute | M | Month |
453
+ * | s | Second | S | Fraction of second |
454
+ * | y | Year (abs) | Y | |
455
+ *
456
+ * Letters marked by * are not implemented but reserved by Unicode standard.
457
+ */
458
+ var formatters$2 = {
459
+ // Year
460
+ y: function y(date, token) {
461
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
462
+ // | Year | y | yy | yyy | yyyy | yyyyy |
463
+ // |----------|-------|----|-------|-------|-------|
464
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
465
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
466
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
467
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
468
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
469
+
470
+ var signedYear = date.getUTCFullYear();
471
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
472
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
473
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
474
+ },
475
+ // Month
476
+ M: function M(date, token) {
477
+ var month = date.getUTCMonth();
478
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
479
+ },
480
+ // Day of the month
481
+ d: function d(date, token) {
482
+ return addLeadingZeros(date.getUTCDate(), token.length);
483
+ },
484
+ // AM or PM
485
+ a: function a(date, token) {
486
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
487
+ switch (token) {
488
+ case 'a':
489
+ case 'aa':
490
+ return dayPeriodEnumValue.toUpperCase();
491
+ case 'aaa':
492
+ return dayPeriodEnumValue;
493
+ case 'aaaaa':
494
+ return dayPeriodEnumValue[0];
495
+ case 'aaaa':
496
+ default:
497
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
498
+ }
499
+ },
500
+ // Hour [1-12]
501
+ h: function h(date, token) {
502
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
503
+ },
504
+ // Hour [0-23]
505
+ H: function H(date, token) {
506
+ return addLeadingZeros(date.getUTCHours(), token.length);
507
+ },
508
+ // Minute
509
+ m: function m(date, token) {
510
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
511
+ },
512
+ // Second
513
+ s: function s(date, token) {
514
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
515
+ },
516
+ // Fraction of second
517
+ S: function S(date, token) {
518
+ var numberOfDigits = token.length;
519
+ var milliseconds = date.getUTCMilliseconds();
520
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
521
+ return addLeadingZeros(fractionalSeconds, token.length);
522
+ }
523
+ };
524
+ const formatters$3 = formatters$2;
525
+
526
+ var dayPeriodEnum = {
527
+ am: 'am',
528
+ pm: 'pm',
529
+ midnight: 'midnight',
530
+ noon: 'noon',
531
+ morning: 'morning',
532
+ afternoon: 'afternoon',
533
+ evening: 'evening',
534
+ night: 'night'
535
+ };
536
+ /*
537
+ * | | Unit | | Unit |
538
+ * |-----|--------------------------------|-----|--------------------------------|
539
+ * | a | AM, PM | A* | Milliseconds in day |
540
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
541
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
542
+ * | d | Day of month | D | Day of year |
543
+ * | e | Local day of week | E | Day of week |
544
+ * | f | | F* | Day of week in month |
545
+ * | g* | Modified Julian day | G | Era |
546
+ * | h | Hour [1-12] | H | Hour [0-23] |
547
+ * | i! | ISO day of week | I! | ISO week of year |
548
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
549
+ * | k | Hour [1-24] | K | Hour [0-11] |
550
+ * | l* | (deprecated) | L | Stand-alone month |
551
+ * | m | Minute | M | Month |
552
+ * | n | | N | |
553
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
554
+ * | p! | Long localized time | P! | Long localized date |
555
+ * | q | Stand-alone quarter | Q | Quarter |
556
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
557
+ * | s | Second | S | Fraction of second |
558
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
559
+ * | u | Extended year | U* | Cyclic year |
560
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
561
+ * | w | Local week of year | W* | Week of month |
562
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
563
+ * | y | Year (abs) | Y | Local week-numbering year |
564
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
565
+ *
566
+ * Letters marked by * are not implemented but reserved by Unicode standard.
567
+ *
568
+ * Letters marked by ! are non-standard, but implemented by date-fns:
569
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
570
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
571
+ * i.e. 7 for Sunday, 1 for Monday, etc.
572
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
573
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
574
+ * `R` is supposed to be used in conjunction with `I` and `i`
575
+ * for universal ISO week-numbering date, whereas
576
+ * `Y` is supposed to be used in conjunction with `w` and `e`
577
+ * for week-numbering date specific to the locale.
578
+ * - `P` is long localized date format
579
+ * - `p` is long localized time format
580
+ */
581
+
582
+ var formatters = {
583
+ // Era
584
+ G: function G(date, token, localize) {
585
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
586
+ switch (token) {
587
+ // AD, BC
588
+ case 'G':
589
+ case 'GG':
590
+ case 'GGG':
591
+ return localize.era(era, {
592
+ width: 'abbreviated'
593
+ });
594
+ // A, B
595
+ case 'GGGGG':
596
+ return localize.era(era, {
597
+ width: 'narrow'
598
+ });
599
+ // Anno Domini, Before Christ
600
+ case 'GGGG':
601
+ default:
602
+ return localize.era(era, {
603
+ width: 'wide'
604
+ });
605
+ }
606
+ },
607
+ // Year
608
+ y: function y(date, token, localize) {
609
+ // Ordinal number
610
+ if (token === 'yo') {
611
+ var signedYear = date.getUTCFullYear();
612
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
613
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
614
+ return localize.ordinalNumber(year, {
615
+ unit: 'year'
616
+ });
617
+ }
618
+ return formatters$3.y(date, token);
619
+ },
620
+ // Local week-numbering year
621
+ Y: function Y(date, token, localize, options) {
622
+ var signedWeekYear = getUTCWeekYear(date, options);
623
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
624
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
625
+
626
+ // Two digit year
627
+ if (token === 'YY') {
628
+ var twoDigitYear = weekYear % 100;
629
+ return addLeadingZeros(twoDigitYear, 2);
630
+ }
631
+
632
+ // Ordinal number
633
+ if (token === 'Yo') {
634
+ return localize.ordinalNumber(weekYear, {
635
+ unit: 'year'
636
+ });
637
+ }
638
+
639
+ // Padding
640
+ return addLeadingZeros(weekYear, token.length);
641
+ },
642
+ // ISO week-numbering year
643
+ R: function R(date, token) {
644
+ var isoWeekYear = getUTCISOWeekYear(date);
645
+
646
+ // Padding
647
+ return addLeadingZeros(isoWeekYear, token.length);
648
+ },
649
+ // Extended year. This is a single number designating the year of this calendar system.
650
+ // The main difference between `y` and `u` localizers are B.C. years:
651
+ // | Year | `y` | `u` |
652
+ // |------|-----|-----|
653
+ // | AC 1 | 1 | 1 |
654
+ // | BC 1 | 1 | 0 |
655
+ // | BC 2 | 2 | -1 |
656
+ // Also `yy` always returns the last two digits of a year,
657
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
658
+ u: function u(date, token) {
659
+ var year = date.getUTCFullYear();
660
+ return addLeadingZeros(year, token.length);
661
+ },
662
+ // Quarter
663
+ Q: function Q(date, token, localize) {
664
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
665
+ switch (token) {
666
+ // 1, 2, 3, 4
667
+ case 'Q':
668
+ return String(quarter);
669
+ // 01, 02, 03, 04
670
+ case 'QQ':
671
+ return addLeadingZeros(quarter, 2);
672
+ // 1st, 2nd, 3rd, 4th
673
+ case 'Qo':
674
+ return localize.ordinalNumber(quarter, {
675
+ unit: 'quarter'
676
+ });
677
+ // Q1, Q2, Q3, Q4
678
+ case 'QQQ':
679
+ return localize.quarter(quarter, {
680
+ width: 'abbreviated',
681
+ context: 'formatting'
682
+ });
683
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
684
+ case 'QQQQQ':
685
+ return localize.quarter(quarter, {
686
+ width: 'narrow',
687
+ context: 'formatting'
688
+ });
689
+ // 1st quarter, 2nd quarter, ...
690
+ case 'QQQQ':
691
+ default:
692
+ return localize.quarter(quarter, {
693
+ width: 'wide',
694
+ context: 'formatting'
695
+ });
696
+ }
697
+ },
698
+ // Stand-alone quarter
699
+ q: function q(date, token, localize) {
700
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
701
+ switch (token) {
702
+ // 1, 2, 3, 4
703
+ case 'q':
704
+ return String(quarter);
705
+ // 01, 02, 03, 04
706
+ case 'qq':
707
+ return addLeadingZeros(quarter, 2);
708
+ // 1st, 2nd, 3rd, 4th
709
+ case 'qo':
710
+ return localize.ordinalNumber(quarter, {
711
+ unit: 'quarter'
712
+ });
713
+ // Q1, Q2, Q3, Q4
714
+ case 'qqq':
715
+ return localize.quarter(quarter, {
716
+ width: 'abbreviated',
717
+ context: 'standalone'
718
+ });
719
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
720
+ case 'qqqqq':
721
+ return localize.quarter(quarter, {
722
+ width: 'narrow',
723
+ context: 'standalone'
724
+ });
725
+ // 1st quarter, 2nd quarter, ...
726
+ case 'qqqq':
727
+ default:
728
+ return localize.quarter(quarter, {
729
+ width: 'wide',
730
+ context: 'standalone'
731
+ });
732
+ }
733
+ },
734
+ // Month
735
+ M: function M(date, token, localize) {
736
+ var month = date.getUTCMonth();
737
+ switch (token) {
738
+ case 'M':
739
+ case 'MM':
740
+ return formatters$3.M(date, token);
741
+ // 1st, 2nd, ..., 12th
742
+ case 'Mo':
743
+ return localize.ordinalNumber(month + 1, {
744
+ unit: 'month'
745
+ });
746
+ // Jan, Feb, ..., Dec
747
+ case 'MMM':
748
+ return localize.month(month, {
749
+ width: 'abbreviated',
750
+ context: 'formatting'
751
+ });
752
+ // J, F, ..., D
753
+ case 'MMMMM':
754
+ return localize.month(month, {
755
+ width: 'narrow',
756
+ context: 'formatting'
757
+ });
758
+ // January, February, ..., December
759
+ case 'MMMM':
760
+ default:
761
+ return localize.month(month, {
762
+ width: 'wide',
763
+ context: 'formatting'
764
+ });
765
+ }
766
+ },
767
+ // Stand-alone month
768
+ L: function L(date, token, localize) {
769
+ var month = date.getUTCMonth();
770
+ switch (token) {
771
+ // 1, 2, ..., 12
772
+ case 'L':
773
+ return String(month + 1);
774
+ // 01, 02, ..., 12
775
+ case 'LL':
776
+ return addLeadingZeros(month + 1, 2);
777
+ // 1st, 2nd, ..., 12th
778
+ case 'Lo':
779
+ return localize.ordinalNumber(month + 1, {
780
+ unit: 'month'
781
+ });
782
+ // Jan, Feb, ..., Dec
783
+ case 'LLL':
784
+ return localize.month(month, {
785
+ width: 'abbreviated',
786
+ context: 'standalone'
787
+ });
788
+ // J, F, ..., D
789
+ case 'LLLLL':
790
+ return localize.month(month, {
791
+ width: 'narrow',
792
+ context: 'standalone'
793
+ });
794
+ // January, February, ..., December
795
+ case 'LLLL':
796
+ default:
797
+ return localize.month(month, {
798
+ width: 'wide',
799
+ context: 'standalone'
800
+ });
801
+ }
802
+ },
803
+ // Local week of year
804
+ w: function w(date, token, localize, options) {
805
+ var week = getUTCWeek(date, options);
806
+ if (token === 'wo') {
807
+ return localize.ordinalNumber(week, {
808
+ unit: 'week'
809
+ });
810
+ }
811
+ return addLeadingZeros(week, token.length);
812
+ },
813
+ // ISO week of year
814
+ I: function I(date, token, localize) {
815
+ var isoWeek = getUTCISOWeek(date);
816
+ if (token === 'Io') {
817
+ return localize.ordinalNumber(isoWeek, {
818
+ unit: 'week'
819
+ });
820
+ }
821
+ return addLeadingZeros(isoWeek, token.length);
822
+ },
823
+ // Day of the month
824
+ d: function d(date, token, localize) {
825
+ if (token === 'do') {
826
+ return localize.ordinalNumber(date.getUTCDate(), {
827
+ unit: 'date'
828
+ });
829
+ }
830
+ return formatters$3.d(date, token);
831
+ },
832
+ // Day of year
833
+ D: function D(date, token, localize) {
834
+ var dayOfYear = getUTCDayOfYear(date);
835
+ if (token === 'Do') {
836
+ return localize.ordinalNumber(dayOfYear, {
837
+ unit: 'dayOfYear'
838
+ });
839
+ }
840
+ return addLeadingZeros(dayOfYear, token.length);
841
+ },
842
+ // Day of week
843
+ E: function E(date, token, localize) {
844
+ var dayOfWeek = date.getUTCDay();
845
+ switch (token) {
846
+ // Tue
847
+ case 'E':
848
+ case 'EE':
849
+ case 'EEE':
850
+ return localize.day(dayOfWeek, {
851
+ width: 'abbreviated',
852
+ context: 'formatting'
853
+ });
854
+ // T
855
+ case 'EEEEE':
856
+ return localize.day(dayOfWeek, {
857
+ width: 'narrow',
858
+ context: 'formatting'
859
+ });
860
+ // Tu
861
+ case 'EEEEEE':
862
+ return localize.day(dayOfWeek, {
863
+ width: 'short',
864
+ context: 'formatting'
865
+ });
866
+ // Tuesday
867
+ case 'EEEE':
868
+ default:
869
+ return localize.day(dayOfWeek, {
870
+ width: 'wide',
871
+ context: 'formatting'
872
+ });
873
+ }
874
+ },
875
+ // Local day of week
876
+ e: function e(date, token, localize, options) {
877
+ var dayOfWeek = date.getUTCDay();
878
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
879
+ switch (token) {
880
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
881
+ case 'e':
882
+ return String(localDayOfWeek);
883
+ // Padded numerical value
884
+ case 'ee':
885
+ return addLeadingZeros(localDayOfWeek, 2);
886
+ // 1st, 2nd, ..., 7th
887
+ case 'eo':
888
+ return localize.ordinalNumber(localDayOfWeek, {
889
+ unit: 'day'
890
+ });
891
+ case 'eee':
892
+ return localize.day(dayOfWeek, {
893
+ width: 'abbreviated',
894
+ context: 'formatting'
895
+ });
896
+ // T
897
+ case 'eeeee':
898
+ return localize.day(dayOfWeek, {
899
+ width: 'narrow',
900
+ context: 'formatting'
901
+ });
902
+ // Tu
903
+ case 'eeeeee':
904
+ return localize.day(dayOfWeek, {
905
+ width: 'short',
906
+ context: 'formatting'
907
+ });
908
+ // Tuesday
909
+ case 'eeee':
910
+ default:
911
+ return localize.day(dayOfWeek, {
912
+ width: 'wide',
913
+ context: 'formatting'
914
+ });
915
+ }
916
+ },
917
+ // Stand-alone local day of week
918
+ c: function c(date, token, localize, options) {
919
+ var dayOfWeek = date.getUTCDay();
920
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
921
+ switch (token) {
922
+ // Numerical value (same as in `e`)
923
+ case 'c':
924
+ return String(localDayOfWeek);
925
+ // Padded numerical value
926
+ case 'cc':
927
+ return addLeadingZeros(localDayOfWeek, token.length);
928
+ // 1st, 2nd, ..., 7th
929
+ case 'co':
930
+ return localize.ordinalNumber(localDayOfWeek, {
931
+ unit: 'day'
932
+ });
933
+ case 'ccc':
934
+ return localize.day(dayOfWeek, {
935
+ width: 'abbreviated',
936
+ context: 'standalone'
937
+ });
938
+ // T
939
+ case 'ccccc':
940
+ return localize.day(dayOfWeek, {
941
+ width: 'narrow',
942
+ context: 'standalone'
943
+ });
944
+ // Tu
945
+ case 'cccccc':
946
+ return localize.day(dayOfWeek, {
947
+ width: 'short',
948
+ context: 'standalone'
949
+ });
950
+ // Tuesday
951
+ case 'cccc':
952
+ default:
953
+ return localize.day(dayOfWeek, {
954
+ width: 'wide',
955
+ context: 'standalone'
956
+ });
957
+ }
958
+ },
959
+ // ISO day of week
960
+ i: function i(date, token, localize) {
961
+ var dayOfWeek = date.getUTCDay();
962
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
963
+ switch (token) {
964
+ // 2
965
+ case 'i':
966
+ return String(isoDayOfWeek);
967
+ // 02
968
+ case 'ii':
969
+ return addLeadingZeros(isoDayOfWeek, token.length);
970
+ // 2nd
971
+ case 'io':
972
+ return localize.ordinalNumber(isoDayOfWeek, {
973
+ unit: 'day'
974
+ });
975
+ // Tue
976
+ case 'iii':
977
+ return localize.day(dayOfWeek, {
978
+ width: 'abbreviated',
979
+ context: 'formatting'
980
+ });
981
+ // T
982
+ case 'iiiii':
983
+ return localize.day(dayOfWeek, {
984
+ width: 'narrow',
985
+ context: 'formatting'
986
+ });
987
+ // Tu
988
+ case 'iiiiii':
989
+ return localize.day(dayOfWeek, {
990
+ width: 'short',
991
+ context: 'formatting'
992
+ });
993
+ // Tuesday
994
+ case 'iiii':
995
+ default:
996
+ return localize.day(dayOfWeek, {
997
+ width: 'wide',
998
+ context: 'formatting'
999
+ });
1000
+ }
1001
+ },
1002
+ // AM or PM
1003
+ a: function a(date, token, localize) {
1004
+ var hours = date.getUTCHours();
1005
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1006
+ switch (token) {
1007
+ case 'a':
1008
+ case 'aa':
1009
+ return localize.dayPeriod(dayPeriodEnumValue, {
1010
+ width: 'abbreviated',
1011
+ context: 'formatting'
1012
+ });
1013
+ case 'aaa':
1014
+ return localize.dayPeriod(dayPeriodEnumValue, {
1015
+ width: 'abbreviated',
1016
+ context: 'formatting'
1017
+ }).toLowerCase();
1018
+ case 'aaaaa':
1019
+ return localize.dayPeriod(dayPeriodEnumValue, {
1020
+ width: 'narrow',
1021
+ context: 'formatting'
1022
+ });
1023
+ case 'aaaa':
1024
+ default:
1025
+ return localize.dayPeriod(dayPeriodEnumValue, {
1026
+ width: 'wide',
1027
+ context: 'formatting'
1028
+ });
1029
+ }
1030
+ },
1031
+ // AM, PM, midnight, noon
1032
+ b: function b(date, token, localize) {
1033
+ var hours = date.getUTCHours();
1034
+ var dayPeriodEnumValue;
1035
+ if (hours === 12) {
1036
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1037
+ } else if (hours === 0) {
1038
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1039
+ } else {
1040
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1041
+ }
1042
+ switch (token) {
1043
+ case 'b':
1044
+ case 'bb':
1045
+ return localize.dayPeriod(dayPeriodEnumValue, {
1046
+ width: 'abbreviated',
1047
+ context: 'formatting'
1048
+ });
1049
+ case 'bbb':
1050
+ return localize.dayPeriod(dayPeriodEnumValue, {
1051
+ width: 'abbreviated',
1052
+ context: 'formatting'
1053
+ }).toLowerCase();
1054
+ case 'bbbbb':
1055
+ return localize.dayPeriod(dayPeriodEnumValue, {
1056
+ width: 'narrow',
1057
+ context: 'formatting'
1058
+ });
1059
+ case 'bbbb':
1060
+ default:
1061
+ return localize.dayPeriod(dayPeriodEnumValue, {
1062
+ width: 'wide',
1063
+ context: 'formatting'
1064
+ });
1065
+ }
1066
+ },
1067
+ // in the morning, in the afternoon, in the evening, at night
1068
+ B: function B(date, token, localize) {
1069
+ var hours = date.getUTCHours();
1070
+ var dayPeriodEnumValue;
1071
+ if (hours >= 17) {
1072
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1073
+ } else if (hours >= 12) {
1074
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1075
+ } else if (hours >= 4) {
1076
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1077
+ } else {
1078
+ dayPeriodEnumValue = dayPeriodEnum.night;
1079
+ }
1080
+ switch (token) {
1081
+ case 'B':
1082
+ case 'BB':
1083
+ case 'BBB':
1084
+ return localize.dayPeriod(dayPeriodEnumValue, {
1085
+ width: 'abbreviated',
1086
+ context: 'formatting'
1087
+ });
1088
+ case 'BBBBB':
1089
+ return localize.dayPeriod(dayPeriodEnumValue, {
1090
+ width: 'narrow',
1091
+ context: 'formatting'
1092
+ });
1093
+ case 'BBBB':
1094
+ default:
1095
+ return localize.dayPeriod(dayPeriodEnumValue, {
1096
+ width: 'wide',
1097
+ context: 'formatting'
1098
+ });
1099
+ }
1100
+ },
1101
+ // Hour [1-12]
1102
+ h: function h(date, token, localize) {
1103
+ if (token === 'ho') {
1104
+ var hours = date.getUTCHours() % 12;
1105
+ if (hours === 0) hours = 12;
1106
+ return localize.ordinalNumber(hours, {
1107
+ unit: 'hour'
1108
+ });
1109
+ }
1110
+ return formatters$3.h(date, token);
1111
+ },
1112
+ // Hour [0-23]
1113
+ H: function H(date, token, localize) {
1114
+ if (token === 'Ho') {
1115
+ return localize.ordinalNumber(date.getUTCHours(), {
1116
+ unit: 'hour'
1117
+ });
1118
+ }
1119
+ return formatters$3.H(date, token);
1120
+ },
1121
+ // Hour [0-11]
1122
+ K: function K(date, token, localize) {
1123
+ var hours = date.getUTCHours() % 12;
1124
+ if (token === 'Ko') {
1125
+ return localize.ordinalNumber(hours, {
1126
+ unit: 'hour'
1127
+ });
1128
+ }
1129
+ return addLeadingZeros(hours, token.length);
1130
+ },
1131
+ // Hour [1-24]
1132
+ k: function k(date, token, localize) {
1133
+ var hours = date.getUTCHours();
1134
+ if (hours === 0) hours = 24;
1135
+ if (token === 'ko') {
1136
+ return localize.ordinalNumber(hours, {
1137
+ unit: 'hour'
1138
+ });
1139
+ }
1140
+ return addLeadingZeros(hours, token.length);
1141
+ },
1142
+ // Minute
1143
+ m: function m(date, token, localize) {
1144
+ if (token === 'mo') {
1145
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1146
+ unit: 'minute'
1147
+ });
1148
+ }
1149
+ return formatters$3.m(date, token);
1150
+ },
1151
+ // Second
1152
+ s: function s(date, token, localize) {
1153
+ if (token === 'so') {
1154
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1155
+ unit: 'second'
1156
+ });
1157
+ }
1158
+ return formatters$3.s(date, token);
1159
+ },
1160
+ // Fraction of second
1161
+ S: function S(date, token) {
1162
+ return formatters$3.S(date, token);
1163
+ },
1164
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1165
+ X: function X(date, token, _localize, options) {
1166
+ var originalDate = options._originalDate || date;
1167
+ var timezoneOffset = originalDate.getTimezoneOffset();
1168
+ if (timezoneOffset === 0) {
1169
+ return 'Z';
1170
+ }
1171
+ switch (token) {
1172
+ // Hours and optional minutes
1173
+ case 'X':
1174
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1175
+
1176
+ // Hours, minutes and optional seconds without `:` delimiter
1177
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1178
+ // so this token always has the same output as `XX`
1179
+ case 'XXXX':
1180
+ case 'XX':
1181
+ // Hours and minutes without `:` delimiter
1182
+ return formatTimezone(timezoneOffset);
1183
+
1184
+ // Hours, minutes and optional seconds with `:` delimiter
1185
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1186
+ // so this token always has the same output as `XXX`
1187
+ case 'XXXXX':
1188
+ case 'XXX': // Hours and minutes with `:` delimiter
1189
+ default:
1190
+ return formatTimezone(timezoneOffset, ':');
1191
+ }
1192
+ },
1193
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1194
+ x: function x(date, token, _localize, options) {
1195
+ var originalDate = options._originalDate || date;
1196
+ var timezoneOffset = originalDate.getTimezoneOffset();
1197
+ switch (token) {
1198
+ // Hours and optional minutes
1199
+ case 'x':
1200
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1201
+
1202
+ // Hours, minutes and optional seconds without `:` delimiter
1203
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1204
+ // so this token always has the same output as `xx`
1205
+ case 'xxxx':
1206
+ case 'xx':
1207
+ // Hours and minutes without `:` delimiter
1208
+ return formatTimezone(timezoneOffset);
1209
+
1210
+ // Hours, minutes and optional seconds with `:` delimiter
1211
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1212
+ // so this token always has the same output as `xxx`
1213
+ case 'xxxxx':
1214
+ case 'xxx': // Hours and minutes with `:` delimiter
1215
+ default:
1216
+ return formatTimezone(timezoneOffset, ':');
1217
+ }
1218
+ },
1219
+ // Timezone (GMT)
1220
+ O: function O(date, token, _localize, options) {
1221
+ var originalDate = options._originalDate || date;
1222
+ var timezoneOffset = originalDate.getTimezoneOffset();
1223
+ switch (token) {
1224
+ // Short
1225
+ case 'O':
1226
+ case 'OO':
1227
+ case 'OOO':
1228
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1229
+ // Long
1230
+ case 'OOOO':
1231
+ default:
1232
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1233
+ }
1234
+ },
1235
+ // Timezone (specific non-location)
1236
+ z: function z(date, token, _localize, options) {
1237
+ var originalDate = options._originalDate || date;
1238
+ var timezoneOffset = originalDate.getTimezoneOffset();
1239
+ switch (token) {
1240
+ // Short
1241
+ case 'z':
1242
+ case 'zz':
1243
+ case 'zzz':
1244
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1245
+ // Long
1246
+ case 'zzzz':
1247
+ default:
1248
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1249
+ }
1250
+ },
1251
+ // Seconds timestamp
1252
+ t: function t(date, token, _localize, options) {
1253
+ var originalDate = options._originalDate || date;
1254
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1255
+ return addLeadingZeros(timestamp, token.length);
1256
+ },
1257
+ // Milliseconds timestamp
1258
+ T: function T(date, token, _localize, options) {
1259
+ var originalDate = options._originalDate || date;
1260
+ var timestamp = originalDate.getTime();
1261
+ return addLeadingZeros(timestamp, token.length);
1262
+ }
1263
+ };
1264
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1265
+ var sign = offset > 0 ? '-' : '+';
1266
+ var absOffset = Math.abs(offset);
1267
+ var hours = Math.floor(absOffset / 60);
1268
+ var minutes = absOffset % 60;
1269
+ if (minutes === 0) {
1270
+ return sign + String(hours);
1271
+ }
1272
+ var delimiter = dirtyDelimiter || '';
1273
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1274
+ }
1275
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1276
+ if (offset % 60 === 0) {
1277
+ var sign = offset > 0 ? '-' : '+';
1278
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1279
+ }
1280
+ return formatTimezone(offset, dirtyDelimiter);
1281
+ }
1282
+ function formatTimezone(offset, dirtyDelimiter) {
1283
+ var delimiter = dirtyDelimiter || '';
1284
+ var sign = offset > 0 ? '-' : '+';
1285
+ var absOffset = Math.abs(offset);
1286
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1287
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1288
+ return sign + hours + delimiter + minutes;
1289
+ }
1290
+ const formatters$1 = formatters;
1291
+
1292
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1293
+ switch (pattern) {
1294
+ case 'P':
1295
+ return formatLong.date({
1296
+ width: 'short'
1297
+ });
1298
+ case 'PP':
1299
+ return formatLong.date({
1300
+ width: 'medium'
1301
+ });
1302
+ case 'PPP':
1303
+ return formatLong.date({
1304
+ width: 'long'
1305
+ });
1306
+ case 'PPPP':
1307
+ default:
1308
+ return formatLong.date({
1309
+ width: 'full'
1310
+ });
1311
+ }
1312
+ };
1313
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1314
+ switch (pattern) {
1315
+ case 'p':
1316
+ return formatLong.time({
1317
+ width: 'short'
1318
+ });
1319
+ case 'pp':
1320
+ return formatLong.time({
1321
+ width: 'medium'
1322
+ });
1323
+ case 'ppp':
1324
+ return formatLong.time({
1325
+ width: 'long'
1326
+ });
1327
+ case 'pppp':
1328
+ default:
1329
+ return formatLong.time({
1330
+ width: 'full'
1331
+ });
1332
+ }
1333
+ };
1334
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1335
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1336
+ var datePattern = matchResult[1];
1337
+ var timePattern = matchResult[2];
1338
+ if (!timePattern) {
1339
+ return dateLongFormatter(pattern, formatLong);
1340
+ }
1341
+ var dateTimeFormat;
1342
+ switch (datePattern) {
1343
+ case 'P':
1344
+ dateTimeFormat = formatLong.dateTime({
1345
+ width: 'short'
1346
+ });
1347
+ break;
1348
+ case 'PP':
1349
+ dateTimeFormat = formatLong.dateTime({
1350
+ width: 'medium'
1351
+ });
1352
+ break;
1353
+ case 'PPP':
1354
+ dateTimeFormat = formatLong.dateTime({
1355
+ width: 'long'
1356
+ });
1357
+ break;
1358
+ case 'PPPP':
1359
+ default:
1360
+ dateTimeFormat = formatLong.dateTime({
1361
+ width: 'full'
1362
+ });
1363
+ break;
1364
+ }
1365
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1366
+ };
1367
+ var longFormatters = {
1368
+ p: timeLongFormatter,
1369
+ P: dateTimeLongFormatter
1370
+ };
1371
+ const longFormatters$1 = longFormatters;
1372
+
1373
+ var protectedDayOfYearTokens = ['D', 'DD'];
1374
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1375
+ function isProtectedDayOfYearToken(token) {
1376
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1377
+ }
1378
+ function isProtectedWeekYearToken(token) {
1379
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1380
+ }
1381
+ function throwProtectedError(token, format, input) {
1382
+ if (token === 'YYYY') {
1383
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1384
+ } else if (token === 'YY') {
1385
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1386
+ } else if (token === 'D') {
1387
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1388
+ } else if (token === 'DD') {
1389
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1390
+ }
1391
+ }
1392
+
1393
+ var formatDistanceLocale = {
1394
+ lessThanXSeconds: {
1395
+ one: 'less than a second',
1396
+ other: 'less than {{count}} seconds'
1397
+ },
1398
+ xSeconds: {
1399
+ one: '1 second',
1400
+ other: '{{count}} seconds'
1401
+ },
1402
+ halfAMinute: 'half a minute',
1403
+ lessThanXMinutes: {
1404
+ one: 'less than a minute',
1405
+ other: 'less than {{count}} minutes'
1406
+ },
1407
+ xMinutes: {
1408
+ one: '1 minute',
1409
+ other: '{{count}} minutes'
1410
+ },
1411
+ aboutXHours: {
1412
+ one: 'about 1 hour',
1413
+ other: 'about {{count}} hours'
1414
+ },
1415
+ xHours: {
1416
+ one: '1 hour',
1417
+ other: '{{count}} hours'
1418
+ },
1419
+ xDays: {
1420
+ one: '1 day',
1421
+ other: '{{count}} days'
1422
+ },
1423
+ aboutXWeeks: {
1424
+ one: 'about 1 week',
1425
+ other: 'about {{count}} weeks'
1426
+ },
1427
+ xWeeks: {
1428
+ one: '1 week',
1429
+ other: '{{count}} weeks'
1430
+ },
1431
+ aboutXMonths: {
1432
+ one: 'about 1 month',
1433
+ other: 'about {{count}} months'
1434
+ },
1435
+ xMonths: {
1436
+ one: '1 month',
1437
+ other: '{{count}} months'
1438
+ },
1439
+ aboutXYears: {
1440
+ one: 'about 1 year',
1441
+ other: 'about {{count}} years'
1442
+ },
1443
+ xYears: {
1444
+ one: '1 year',
1445
+ other: '{{count}} years'
1446
+ },
1447
+ overXYears: {
1448
+ one: 'over 1 year',
1449
+ other: 'over {{count}} years'
1450
+ },
1451
+ almostXYears: {
1452
+ one: 'almost 1 year',
1453
+ other: 'almost {{count}} years'
1454
+ }
1455
+ };
1456
+ var formatDistance = function formatDistance(token, count, options) {
1457
+ var result;
1458
+ var tokenValue = formatDistanceLocale[token];
1459
+ if (typeof tokenValue === 'string') {
1460
+ result = tokenValue;
1461
+ } else if (count === 1) {
1462
+ result = tokenValue.one;
1463
+ } else {
1464
+ result = tokenValue.other.replace('{{count}}', count.toString());
1465
+ }
1466
+ if (options !== null && options !== void 0 && options.addSuffix) {
1467
+ if (options.comparison && options.comparison > 0) {
1468
+ return 'in ' + result;
1469
+ } else {
1470
+ return result + ' ago';
1471
+ }
1472
+ }
1473
+ return result;
1474
+ };
1475
+ const formatDistance$1 = formatDistance;
1476
+
1477
+ function buildFormatLongFn(args) {
1478
+ return function () {
1479
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1480
+ // TODO: Remove String()
1481
+ var width = options.width ? String(options.width) : args.defaultWidth;
1482
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1483
+ return format;
1484
+ };
1485
+ }
1486
+
1487
+ var dateFormats = {
1488
+ full: 'EEEE, MMMM do, y',
1489
+ long: 'MMMM do, y',
1490
+ medium: 'MMM d, y',
1491
+ short: 'MM/dd/yyyy'
1492
+ };
1493
+ var timeFormats = {
1494
+ full: 'h:mm:ss a zzzz',
1495
+ long: 'h:mm:ss a z',
1496
+ medium: 'h:mm:ss a',
1497
+ short: 'h:mm a'
1498
+ };
1499
+ var dateTimeFormats = {
1500
+ full: "{{date}} 'at' {{time}}",
1501
+ long: "{{date}} 'at' {{time}}",
1502
+ medium: '{{date}}, {{time}}',
1503
+ short: '{{date}}, {{time}}'
1504
+ };
1505
+ var formatLong = {
1506
+ date: buildFormatLongFn({
1507
+ formats: dateFormats,
1508
+ defaultWidth: 'full'
1509
+ }),
1510
+ time: buildFormatLongFn({
1511
+ formats: timeFormats,
1512
+ defaultWidth: 'full'
1513
+ }),
1514
+ dateTime: buildFormatLongFn({
1515
+ formats: dateTimeFormats,
1516
+ defaultWidth: 'full'
1517
+ })
1518
+ };
1519
+ const formatLong$1 = formatLong;
1520
+
1521
+ var formatRelativeLocale = {
1522
+ lastWeek: "'last' eeee 'at' p",
1523
+ yesterday: "'yesterday at' p",
1524
+ today: "'today at' p",
1525
+ tomorrow: "'tomorrow at' p",
1526
+ nextWeek: "eeee 'at' p",
1527
+ other: 'P'
1528
+ };
1529
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1530
+ return formatRelativeLocale[token];
1531
+ };
1532
+ const formatRelative$1 = formatRelative;
1533
+
1534
+ function buildLocalizeFn(args) {
1535
+ return function (dirtyIndex, options) {
1536
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1537
+ var valuesArray;
1538
+ if (context === 'formatting' && args.formattingValues) {
1539
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1540
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1541
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1542
+ } else {
1543
+ var _defaultWidth = args.defaultWidth;
1544
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1545
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1546
+ }
1547
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1548
+ // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1549
+ return valuesArray[index];
1550
+ };
1551
+ }
1552
+
1553
+ var eraValues = {
1554
+ narrow: ['B', 'A'],
1555
+ abbreviated: ['BC', 'AD'],
1556
+ wide: ['Before Christ', 'Anno Domini']
1557
+ };
1558
+ var quarterValues = {
1559
+ narrow: ['1', '2', '3', '4'],
1560
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1561
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1562
+ };
1563
+
1564
+ // Note: in English, the names of days of the week and months are capitalized.
1565
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1566
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1567
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1568
+ var monthValues = {
1569
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1570
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1571
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1572
+ };
1573
+ var dayValues = {
1574
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1575
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1576
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1577
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1578
+ };
1579
+ var dayPeriodValues = {
1580
+ narrow: {
1581
+ am: 'a',
1582
+ pm: 'p',
1583
+ midnight: 'mi',
1584
+ noon: 'n',
1585
+ morning: 'morning',
1586
+ afternoon: 'afternoon',
1587
+ evening: 'evening',
1588
+ night: 'night'
1589
+ },
1590
+ abbreviated: {
1591
+ am: 'AM',
1592
+ pm: 'PM',
1593
+ midnight: 'midnight',
1594
+ noon: 'noon',
1595
+ morning: 'morning',
1596
+ afternoon: 'afternoon',
1597
+ evening: 'evening',
1598
+ night: 'night'
1599
+ },
1600
+ wide: {
1601
+ am: 'a.m.',
1602
+ pm: 'p.m.',
1603
+ midnight: 'midnight',
1604
+ noon: 'noon',
1605
+ morning: 'morning',
1606
+ afternoon: 'afternoon',
1607
+ evening: 'evening',
1608
+ night: 'night'
1609
+ }
1610
+ };
1611
+ var formattingDayPeriodValues = {
1612
+ narrow: {
1613
+ am: 'a',
1614
+ pm: 'p',
1615
+ midnight: 'mi',
1616
+ noon: 'n',
1617
+ morning: 'in the morning',
1618
+ afternoon: 'in the afternoon',
1619
+ evening: 'in the evening',
1620
+ night: 'at night'
1621
+ },
1622
+ abbreviated: {
1623
+ am: 'AM',
1624
+ pm: 'PM',
1625
+ midnight: 'midnight',
1626
+ noon: 'noon',
1627
+ morning: 'in the morning',
1628
+ afternoon: 'in the afternoon',
1629
+ evening: 'in the evening',
1630
+ night: 'at night'
1631
+ },
1632
+ wide: {
1633
+ am: 'a.m.',
1634
+ pm: 'p.m.',
1635
+ midnight: 'midnight',
1636
+ noon: 'noon',
1637
+ morning: 'in the morning',
1638
+ afternoon: 'in the afternoon',
1639
+ evening: 'in the evening',
1640
+ night: 'at night'
1641
+ }
1642
+ };
1643
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1644
+ var number = Number(dirtyNumber);
1645
+
1646
+ // If ordinal numbers depend on context, for example,
1647
+ // if they are different for different grammatical genders,
1648
+ // use `options.unit`.
1649
+ //
1650
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1651
+ // 'day', 'hour', 'minute', 'second'.
1652
+
1653
+ var rem100 = number % 100;
1654
+ if (rem100 > 20 || rem100 < 10) {
1655
+ switch (rem100 % 10) {
1656
+ case 1:
1657
+ return number + 'st';
1658
+ case 2:
1659
+ return number + 'nd';
1660
+ case 3:
1661
+ return number + 'rd';
1662
+ }
1663
+ }
1664
+ return number + 'th';
1665
+ };
1666
+ var localize = {
1667
+ ordinalNumber: ordinalNumber,
1668
+ era: buildLocalizeFn({
1669
+ values: eraValues,
1670
+ defaultWidth: 'wide'
1671
+ }),
1672
+ quarter: buildLocalizeFn({
1673
+ values: quarterValues,
1674
+ defaultWidth: 'wide',
1675
+ argumentCallback: function argumentCallback(quarter) {
1676
+ return quarter - 1;
1677
+ }
1678
+ }),
1679
+ month: buildLocalizeFn({
1680
+ values: monthValues,
1681
+ defaultWidth: 'wide'
1682
+ }),
1683
+ day: buildLocalizeFn({
1684
+ values: dayValues,
1685
+ defaultWidth: 'wide'
1686
+ }),
1687
+ dayPeriod: buildLocalizeFn({
1688
+ values: dayPeriodValues,
1689
+ defaultWidth: 'wide',
1690
+ formattingValues: formattingDayPeriodValues,
1691
+ defaultFormattingWidth: 'wide'
1692
+ })
1693
+ };
1694
+ const localize$1 = localize;
1695
+
1696
+ function buildMatchFn(args) {
1697
+ return function (string) {
1698
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1699
+ var width = options.width;
1700
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1701
+ var matchResult = string.match(matchPattern);
1702
+ if (!matchResult) {
1703
+ return null;
1704
+ }
1705
+ var matchedString = matchResult[0];
1706
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1707
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1708
+ return pattern.test(matchedString);
1709
+ }) : findKey(parsePatterns, function (pattern) {
1710
+ return pattern.test(matchedString);
1711
+ });
1712
+ var value;
1713
+ value = args.valueCallback ? args.valueCallback(key) : key;
1714
+ value = options.valueCallback ? options.valueCallback(value) : value;
1715
+ var rest = string.slice(matchedString.length);
1716
+ return {
1717
+ value: value,
1718
+ rest: rest
1719
+ };
1720
+ };
1721
+ }
1722
+ function findKey(object, predicate) {
1723
+ for (var key in object) {
1724
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1725
+ return key;
1726
+ }
1727
+ }
1728
+ return undefined;
1729
+ }
1730
+ function findIndex(array, predicate) {
1731
+ for (var key = 0; key < array.length; key++) {
1732
+ if (predicate(array[key])) {
1733
+ return key;
1734
+ }
1735
+ }
1736
+ return undefined;
1737
+ }
1738
+
1739
+ function buildMatchPatternFn(args) {
1740
+ return function (string) {
1741
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1742
+ var matchResult = string.match(args.matchPattern);
1743
+ if (!matchResult) return null;
1744
+ var matchedString = matchResult[0];
1745
+ var parseResult = string.match(args.parsePattern);
1746
+ if (!parseResult) return null;
1747
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1748
+ value = options.valueCallback ? options.valueCallback(value) : value;
1749
+ var rest = string.slice(matchedString.length);
1750
+ return {
1751
+ value: value,
1752
+ rest: rest
1753
+ };
1754
+ };
1755
+ }
1756
+
1757
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1758
+ var parseOrdinalNumberPattern = /\d+/i;
1759
+ var matchEraPatterns = {
1760
+ narrow: /^(b|a)/i,
1761
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1762
+ wide: /^(before christ|before common era|anno domini|common era)/i
1763
+ };
1764
+ var parseEraPatterns = {
1765
+ any: [/^b/i, /^(a|c)/i]
1766
+ };
1767
+ var matchQuarterPatterns = {
1768
+ narrow: /^[1234]/i,
1769
+ abbreviated: /^q[1234]/i,
1770
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1771
+ };
1772
+ var parseQuarterPatterns = {
1773
+ any: [/1/i, /2/i, /3/i, /4/i]
1774
+ };
1775
+ var matchMonthPatterns = {
1776
+ narrow: /^[jfmasond]/i,
1777
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1778
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1779
+ };
1780
+ var parseMonthPatterns = {
1781
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1782
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
1783
+ };
1784
+ var matchDayPatterns = {
1785
+ narrow: /^[smtwf]/i,
1786
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1787
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1788
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1789
+ };
1790
+ var parseDayPatterns = {
1791
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1792
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1793
+ };
1794
+ var matchDayPeriodPatterns = {
1795
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1796
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1797
+ };
1798
+ var parseDayPeriodPatterns = {
1799
+ any: {
1800
+ am: /^a/i,
1801
+ pm: /^p/i,
1802
+ midnight: /^mi/i,
1803
+ noon: /^no/i,
1804
+ morning: /morning/i,
1805
+ afternoon: /afternoon/i,
1806
+ evening: /evening/i,
1807
+ night: /night/i
1808
+ }
1809
+ };
1810
+ var match = {
1811
+ ordinalNumber: buildMatchPatternFn({
1812
+ matchPattern: matchOrdinalNumberPattern,
1813
+ parsePattern: parseOrdinalNumberPattern,
1814
+ valueCallback: function valueCallback(value) {
1815
+ return parseInt(value, 10);
1816
+ }
1817
+ }),
1818
+ era: buildMatchFn({
1819
+ matchPatterns: matchEraPatterns,
1820
+ defaultMatchWidth: 'wide',
1821
+ parsePatterns: parseEraPatterns,
1822
+ defaultParseWidth: 'any'
1823
+ }),
1824
+ quarter: buildMatchFn({
1825
+ matchPatterns: matchQuarterPatterns,
1826
+ defaultMatchWidth: 'wide',
1827
+ parsePatterns: parseQuarterPatterns,
1828
+ defaultParseWidth: 'any',
1829
+ valueCallback: function valueCallback(index) {
1830
+ return index + 1;
1831
+ }
1832
+ }),
1833
+ month: buildMatchFn({
1834
+ matchPatterns: matchMonthPatterns,
1835
+ defaultMatchWidth: 'wide',
1836
+ parsePatterns: parseMonthPatterns,
1837
+ defaultParseWidth: 'any'
1838
+ }),
1839
+ day: buildMatchFn({
1840
+ matchPatterns: matchDayPatterns,
1841
+ defaultMatchWidth: 'wide',
1842
+ parsePatterns: parseDayPatterns,
1843
+ defaultParseWidth: 'any'
1844
+ }),
1845
+ dayPeriod: buildMatchFn({
1846
+ matchPatterns: matchDayPeriodPatterns,
1847
+ defaultMatchWidth: 'any',
1848
+ parsePatterns: parseDayPeriodPatterns,
1849
+ defaultParseWidth: 'any'
1850
+ })
1851
+ };
1852
+ const match$1 = match;
1853
+
1854
+ /**
1855
+ * @type {Locale}
1856
+ * @category Locales
1857
+ * @summary English locale (United States).
1858
+ * @language English
1859
+ * @iso-639-2 eng
1860
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1861
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1862
+ */
1863
+ var locale = {
1864
+ code: 'en-US',
1865
+ formatDistance: formatDistance$1,
1866
+ formatLong: formatLong$1,
1867
+ formatRelative: formatRelative$1,
1868
+ localize: localize$1,
1869
+ match: match$1,
1870
+ options: {
1871
+ weekStartsOn: 0 /* Sunday */,
1872
+ firstWeekContainsDate: 1
1873
+ }
1874
+ };
1875
+ const defaultLocale = locale;
1876
+
1877
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1878
+ // (one of the certain letters followed by `o`)
1879
+ // - (\w)\1* matches any sequences of the same letter
1880
+ // - '' matches two quote characters in a row
1881
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1882
+ // except a single quote symbol, which ends the sequence.
1883
+ // Two quote characters do not end the sequence.
1884
+ // If there is no matching single quote
1885
+ // then the sequence will continue until the end of the string.
1886
+ // - . matches any single character unmatched by previous parts of the RegExps
1887
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1888
+
1889
+ // This RegExp catches symbols escaped by quotes, and also
1890
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1891
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1892
+ var escapedStringRegExp = /^'([^]*?)'?$/;
1893
+ var doubleQuoteRegExp = /''/g;
1894
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1895
+
1896
+ /**
1897
+ * @name format
1898
+ * @category Common Helpers
1899
+ * @summary Format the date.
1900
+ *
1901
+ * @description
1902
+ * Return the formatted date string in the given format. The result may vary by locale.
1903
+ *
1904
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1905
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1906
+ *
1907
+ * The characters wrapped between two single quotes characters (') are escaped.
1908
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1909
+ * (see the last example)
1910
+ *
1911
+ * Format of the string is based on Unicode Technical Standard #35:
1912
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1913
+ * with a few additions (see note 7 below the table).
1914
+ *
1915
+ * Accepted patterns:
1916
+ * | Unit | Pattern | Result examples | Notes |
1917
+ * |---------------------------------|---------|-----------------------------------|-------|
1918
+ * | Era | G..GGG | AD, BC | |
1919
+ * | | GGGG | Anno Domini, Before Christ | 2 |
1920
+ * | | GGGGG | A, B | |
1921
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1922
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1923
+ * | | yy | 44, 01, 00, 17 | 5 |
1924
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
1925
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1926
+ * | | yyyyy | ... | 3,5 |
1927
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1928
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1929
+ * | | YY | 44, 01, 00, 17 | 5,8 |
1930
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
1931
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1932
+ * | | YYYYY | ... | 3,5 |
1933
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1934
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1935
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1936
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1937
+ * | | RRRRR | ... | 3,5,7 |
1938
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1939
+ * | | uu | -43, 01, 1900, 2017 | 5 |
1940
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
1941
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1942
+ * | | uuuuu | ... | 3,5 |
1943
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1944
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1945
+ * | | QQ | 01, 02, 03, 04 | |
1946
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
1947
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1948
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
1949
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1950
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1951
+ * | | qq | 01, 02, 03, 04 | |
1952
+ * | | qqq | Q1, Q2, Q3, Q4 | |
1953
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1954
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
1955
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
1956
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
1957
+ * | | MM | 01, 02, ..., 12 | |
1958
+ * | | MMM | Jan, Feb, ..., Dec | |
1959
+ * | | MMMM | January, February, ..., December | 2 |
1960
+ * | | MMMMM | J, F, ..., D | |
1961
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1962
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
1963
+ * | | LL | 01, 02, ..., 12 | |
1964
+ * | | LLL | Jan, Feb, ..., Dec | |
1965
+ * | | LLLL | January, February, ..., December | 2 |
1966
+ * | | LLLLL | J, F, ..., D | |
1967
+ * | Local week of year | w | 1, 2, ..., 53 | |
1968
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
1969
+ * | | ww | 01, 02, ..., 53 | |
1970
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1971
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
1972
+ * | | II | 01, 02, ..., 53 | 7 |
1973
+ * | Day of month | d | 1, 2, ..., 31 | |
1974
+ * | | do | 1st, 2nd, ..., 31st | 7 |
1975
+ * | | dd | 01, 02, ..., 31 | |
1976
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1977
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1978
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
1979
+ * | | DDD | 001, 002, ..., 365, 366 | |
1980
+ * | | DDDD | ... | 3 |
1981
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
1982
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
1983
+ * | | EEEEE | M, T, W, T, F, S, S | |
1984
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
1985
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
1986
+ * | | io | 1st, 2nd, ..., 7th | 7 |
1987
+ * | | ii | 01, 02, ..., 07 | 7 |
1988
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
1989
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
1990
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
1991
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
1992
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
1993
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
1994
+ * | | ee | 02, 03, ..., 01 | |
1995
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
1996
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
1997
+ * | | eeeee | M, T, W, T, F, S, S | |
1998
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
1999
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2000
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2001
+ * | | cc | 02, 03, ..., 01 | |
2002
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2003
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2004
+ * | | ccccc | M, T, W, T, F, S, S | |
2005
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2006
+ * | AM, PM | a..aa | AM, PM | |
2007
+ * | | aaa | am, pm | |
2008
+ * | | aaaa | a.m., p.m. | 2 |
2009
+ * | | aaaaa | a, p | |
2010
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2011
+ * | | bbb | am, pm, noon, midnight | |
2012
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2013
+ * | | bbbbb | a, p, n, mi | |
2014
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2015
+ * | | BBBB | at night, in the morning, ... | 2 |
2016
+ * | | BBBBB | at night, in the morning, ... | |
2017
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2018
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2019
+ * | | hh | 01, 02, ..., 11, 12 | |
2020
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2021
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2022
+ * | | HH | 00, 01, 02, ..., 23 | |
2023
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2024
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2025
+ * | | KK | 01, 02, ..., 11, 00 | |
2026
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2027
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2028
+ * | | kk | 24, 01, 02, ..., 23 | |
2029
+ * | Minute | m | 0, 1, ..., 59 | |
2030
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2031
+ * | | mm | 00, 01, ..., 59 | |
2032
+ * | Second | s | 0, 1, ..., 59 | |
2033
+ * | | so | 0th, 1st, ..., 59th | 7 |
2034
+ * | | ss | 00, 01, ..., 59 | |
2035
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2036
+ * | | SS | 00, 01, ..., 99 | |
2037
+ * | | SSS | 000, 001, ..., 999 | |
2038
+ * | | SSSS | ... | 3 |
2039
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2040
+ * | | XX | -0800, +0530, Z | |
2041
+ * | | XXX | -08:00, +05:30, Z | |
2042
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2043
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2044
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2045
+ * | | xx | -0800, +0530, +0000 | |
2046
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2047
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2048
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2049
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2050
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2051
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2052
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2053
+ * | Seconds timestamp | t | 512969520 | 7 |
2054
+ * | | tt | ... | 3,7 |
2055
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2056
+ * | | TT | ... | 3,7 |
2057
+ * | Long localized date | P | 04/29/1453 | 7 |
2058
+ * | | PP | Apr 29, 1453 | 7 |
2059
+ * | | PPP | April 29th, 1453 | 7 |
2060
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2061
+ * | Long localized time | p | 12:00 AM | 7 |
2062
+ * | | pp | 12:00:00 AM | 7 |
2063
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2064
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2065
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2066
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2067
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2068
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2069
+ * Notes:
2070
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2071
+ * are the same as "stand-alone" units, but are different in some languages.
2072
+ * "Formatting" units are declined according to the rules of the language
2073
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2074
+ *
2075
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2076
+ *
2077
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2078
+ *
2079
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2080
+ * the single quote characters (see below).
2081
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2082
+ * the output will be the same as default pattern for this unit, usually
2083
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2084
+ * are marked with "2" in the last column of the table.
2085
+ *
2086
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2087
+ *
2088
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2089
+ *
2090
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2091
+ *
2092
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2093
+ *
2094
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2095
+ *
2096
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2097
+ * The output will be padded with zeros to match the length of the pattern.
2098
+ *
2099
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2100
+ *
2101
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2102
+ * These tokens represent the shortest form of the quarter.
2103
+ *
2104
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2105
+ *
2106
+ * | Year | `y` | `u` |
2107
+ * |------|-----|-----|
2108
+ * | AC 1 | 1 | 1 |
2109
+ * | BC 1 | 1 | 0 |
2110
+ * | BC 2 | 2 | -1 |
2111
+ *
2112
+ * Also `yy` always returns the last two digits of a year,
2113
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2114
+ *
2115
+ * | Year | `yy` | `uu` |
2116
+ * |------|------|------|
2117
+ * | 1 | 01 | 01 |
2118
+ * | 14 | 14 | 14 |
2119
+ * | 376 | 76 | 376 |
2120
+ * | 1453 | 53 | 1453 |
2121
+ *
2122
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2123
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2124
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2125
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2126
+ *
2127
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2128
+ * so right now these tokens fall back to GMT timezones.
2129
+ *
2130
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2131
+ * - `i`: ISO day of week
2132
+ * - `I`: ISO week of year
2133
+ * - `R`: ISO week-numbering year
2134
+ * - `t`: seconds timestamp
2135
+ * - `T`: milliseconds timestamp
2136
+ * - `o`: ordinal number modifier
2137
+ * - `P`: long localized date
2138
+ * - `p`: long localized time
2139
+ *
2140
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2141
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2142
+ *
2143
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2144
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2145
+ *
2146
+ * @param {Date|Number} date - the original date
2147
+ * @param {String} format - the string of tokens
2148
+ * @param {Object} [options] - an object with options.
2149
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2150
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2151
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2152
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2153
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2154
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2155
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2156
+ * @returns {String} the formatted date string
2157
+ * @throws {TypeError} 2 arguments required
2158
+ * @throws {RangeError} `date` must not be Invalid Date
2159
+ * @throws {RangeError} `options.locale` must contain `localize` property
2160
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2161
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2162
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2163
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2164
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2165
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2166
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2167
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2168
+ *
2169
+ * @example
2170
+ * // Represent 11 February 2014 in middle-endian format:
2171
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2172
+ * //=> '02/11/2014'
2173
+ *
2174
+ * @example
2175
+ * // Represent 2 July 2014 in Esperanto:
2176
+ * import { eoLocale } from 'date-fns/locale/eo'
2177
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2178
+ * locale: eoLocale
2179
+ * })
2180
+ * //=> '2-a de julio 2014'
2181
+ *
2182
+ * @example
2183
+ * // Escape string by single quote characters:
2184
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2185
+ * //=> "3 o'clock"
2186
+ */
2187
+
2188
+ function format(dirtyDate, dirtyFormatStr, options) {
2189
+ var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2190
+ requiredArgs(2, arguments);
2191
+ var formatStr = String(dirtyFormatStr);
2192
+ var defaultOptions = getDefaultOptions();
2193
+ var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
2194
+ var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2195
+
2196
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2197
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2198
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2199
+ }
2200
+ var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2201
+
2202
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2203
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2204
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2205
+ }
2206
+ if (!locale.localize) {
2207
+ throw new RangeError('locale must contain localize property');
2208
+ }
2209
+ if (!locale.formatLong) {
2210
+ throw new RangeError('locale must contain formatLong property');
2211
+ }
2212
+ var originalDate = toDate(dirtyDate);
2213
+ if (!isValid(originalDate)) {
2214
+ throw new RangeError('Invalid time value');
2215
+ }
2216
+
2217
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2218
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2219
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2220
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2221
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2222
+ var formatterOptions = {
2223
+ firstWeekContainsDate: firstWeekContainsDate,
2224
+ weekStartsOn: weekStartsOn,
2225
+ locale: locale,
2226
+ _originalDate: originalDate
2227
+ };
2228
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2229
+ var firstCharacter = substring[0];
2230
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2231
+ var longFormatter = longFormatters$1[firstCharacter];
2232
+ return longFormatter(substring, locale.formatLong);
2233
+ }
2234
+ return substring;
2235
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2236
+ // Replace two single quote characters with one single quote character
2237
+ if (substring === "''") {
2238
+ return "'";
2239
+ }
2240
+ var firstCharacter = substring[0];
2241
+ if (firstCharacter === "'") {
2242
+ return cleanEscapedString(substring);
2243
+ }
2244
+ var formatter = formatters$1[firstCharacter];
2245
+ if (formatter) {
2246
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2247
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2248
+ }
2249
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2250
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2251
+ }
2252
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2253
+ }
2254
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2255
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2256
+ }
2257
+ return substring;
2258
+ }).join('');
2259
+ return result;
2260
+ }
2261
+ function cleanEscapedString(input) {
2262
+ var matched = input.match(escapedStringRegExp);
2263
+ if (!matched) {
2264
+ return input;
2265
+ }
2266
+ return matched[1].replace(doubleQuoteRegExp, "'");
2267
+ }
2268
+
2269
+ const getHistoryLoaderTemplate = (lang) => {
2270
+ return h("div", { class: "HistoryLoader" },
2271
+ h("casino-engagement-suite-progress-bar", { indeterminate: true }),
2272
+ h("span", null, translate('loading', lang)));
2273
+ };
2274
+ const getRewards = (luckywheel, result) => {
2275
+ var _a, _b, _c, _d;
2276
+ const index = result.wheelOfFortunePartitionIndex || 0;
2277
+ const name = (_b = (_a = luckywheel.program.wheelOfFortune) === null || _a === void 0 ? void 0 : _a.partitions[index]) === null || _b === void 0 ? void 0 : _b.name;
2278
+ const displayName = name['en'] || name['*'];
2279
+ const assets = (_d = (_c = luckywheel.program.wheelOfFortune) === null || _c === void 0 ? void 0 : _c.partitions[index]) === null || _d === void 0 ? void 0 : _d.image1;
2280
+ const displayAssets = assets['en'] || assets['*'];
2281
+ const programName = luckywheel.program.name['en'] || luckywheel.program.name['*'];
2282
+ return h("div", { class: "HistoryRewards" }, displayName ? displayName : displayAssets ? (h("img", { src: displayAssets })) : programName);
2283
+ };
2284
+ const getStatus = (state) => {
2285
+ return state === 'fulfilled' ? 'Success' : 'Failed';
2286
+ };
2287
+ const getLuckyWheelsHistoryTemplate = (luckywheels, historyGroups, openedHistoryIds, toggleLuckyWheelHistory, lang) => {
2288
+ if (luckywheels.length === 0) {
2289
+ return h("p", { class: "HistoryEmptyMessage" }, translate('noHistory', lang));
2290
+ }
2291
+ return h("div", { class: "HistoryList" }, luckywheels.map((luckywheel) => {
2292
+ return h("div", { key: luckywheel.program.id, class: `HistoryListItem ${openedHistoryIds.includes(luckywheel.program.id) ? 'Opened' : 'Closed'}` },
2293
+ h("header", { class: "HistoryListItemHeader", "data-id": luckywheel.program.id, onClick: toggleLuckyWheelHistory },
2294
+ luckywheel.program.name['en'] || luckywheel.program.name['*'],
2295
+ h("button", { class: "EngagementSuiteIconButton ArrowDown" })),
2296
+ h("div", { class: "HistoryListItemBody" },
2297
+ h("div", { class: "HistoryInfoRow" }, Object.entries(historyGroups).map((histories) => {
2298
+ return histories[0] === luckywheel.program.id && histories[1].map((history) => {
2299
+ return h("div", { class: "HistoryInfo" },
2300
+ h("div", { class: "HistoryCol Rewards" }, getRewards(luckywheel, history.draw.result)),
2301
+ h("div", { class: "HistoryCol Issued" }, getStatus(history.draw.state)),
2302
+ h("div", { class: "HistoryCol Time" }, format(new Date(history.draw.time), 'LLL d, yyyy HH:mm:ss')));
2303
+ });
2304
+ }))));
2305
+ }));
2306
+ };
2307
+
2308
+ const casinoEngagementSuiteLuckywheelListCss = ":host{display:block;font-family:inherit}*{box-sizing:border-box;margin:0;padding:0}button{border:none;background:none;cursor:pointer}button:focus{outline:none}.EngagementSuiteIconButton{width:16px;height:16px}.EngagementSuiteIconButton.Help{background:center/100% url(https://static.everymatrix.com/gic/img/engagement-suite/help.svg) no-repeat}.EngagementSuiteIconButton.Close{background:center/100% url(https://static.everymatrix.com/gic/img/engagement-suite/close.svg) no-repeat}.EngagementSuiteIconButton.ArrowDown{background:center/100% url(https://static.everymatrix.com/gic/img/engagement-suite/arrow-down.svg) no-repeat}.LuckyWheelsListPopup{display:flex;height:100%;background-color:var(--emw--color-background, #1e1638);border-radius:var(--emw--border-radius-large, 8px);overflow:hidden;flex-direction:column;position:relative;padding-bottom:20px}.LuckyWheelsListPopupHeader{display:flex;justify-content:space-between;align-items:center;padding:12px 8px 8px}.LuckyWheelsListPopupHeaderName{color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-small, 14px);font-weight:var(--emw--font-weight-medium, 500);line-height:14px}.LuckyWheelsListWrapper{overflow-y:auto;-ms-overflow-style:none;scrollbar-width:none}.LuckyWheelsListWrapper::-webkit-scrollbar{display:none}.LuckyWheelsList{display:flex;flex-direction:column;row-gap:12px;padding:8px 19px 0}.LuckyWheelsRowWrapper{display:flex;justify-content:space-between;min-width:0}.LuckyWheelsCard{padding:15px 15px 19px;border:1px solid var(--emw--button-border-color, #403956);border-radius:var(--emw--border-radius-medium, 6px);position:relative;cursor:pointer}.LuckyWheelsCard.Forfeited{cursor:auto;pointer-events:none}.LuckyWheelsCardHeader{display:flex;justify-content:space-between;gap:24px;margin-bottom:12px;flex:1;min-width:0;align-items:flex-end}.LuckyWheelsName{color:var(--emw--color-typography, #ffffff);font-family:var(--emw--font-family-secondary, \"Montserrat\", sans-serif);line-height:22px;font-weight:var(--emw--font-weight-bold, 700);font-size:var(--emw--font-size-medium-plus, 18px);word-break:break-word;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.LuckyWheelsCounter{display:flex;color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-medium-plus, 18px);align-items:flex-end}.LuckyWheelsHighlightedCounter,.LuckyWheelsEmptyCounter{font-size:var(--emw--font-size-medium-plus, 18px);font-weight:var(--emw--font-weight-extra-bold, 800);margin-right:4px}.LuckyWheelsHighlightedCounter{background:var(--emw--engagement-suite-gradient-golden, linear-gradient(180deg, #ffb801 15.86%, #fef746 31.36%, #fbffe0 36.86%, #fffa60 47.86%, #ff9400 87.36%));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent}.LuckyWheelsEmptyCounter{color:var(--emw--color-gray-150, #8f8b9c)}.LuckyWheelsListEmpty{padding:20px 32px}.LuckyWheelsListEmpty h2{margin:0 0 16px 0;text-align:center;font-weight:var(--emw--font-weight-semibold, 600);font-size:var(--emw--font-size-large, 20px);line-height:24px;font-family:var(--emw--font-family-secondary, \"Montserrat\", sans-serif);color:var(--emw--color-typography, #ffffff)}.LuckyWheelsListEmpty p{font-size:var(--emw--font-size-small, 14px);line-height:17px;color:var(--emw--color-secondary, #bbb9c3)}.LuckyWheelsCountdownWrapper{display:flex;justify-content:space-between;align-items:flex-start}.LuckyWheelsCountdown,.ForfeitedMessage{color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-x-small, 12px);line-height:12px}.ForfeitedMessage{line-height:1.2}.LuckyWheelsBalCounter{display:flex;align-items:flex-end;color:var(--emw--color-secondary, #bbb9c3);font-size:var(--emw--font-size-x-small, 12px)}.LuckyWheelsRemainCounter{color:var(--emw--color-typography, #ffffff);font-weight:var(--emw--font-weight-bold, 700);margin-right:4px}.LuckyWheelLabel{min-width:35px;height:18px;background:var(--emw--engagement-suite-gradient-golden, linear-gradient(180deg, #ffb801 15.86%, #fef746 31.36%, #fbffe0 36.86%, #fffa60 47.86%, #ff9400 87.36%));border-radius:var(--emw--border-radius-x-small, 2px);display:none;position:absolute;top:-11px;right:11px;padding:0 2px;align-items:center;justify-content:center}.LuckyWheelLabel span{display:inline-block;text-transform:uppercase;font-size:var(--emw--font-size-2x-small, 10px);line-height:10px;font-weight:var(--emw--font-weight-bold, 700);font-family:var(--emw--font-family-secondary, \"Montserrat\", sans-serif);color:var(--emw--color-background, #1e1638)}.ShowLuckyWheelLabel{display:inline-flex}.EngagementSuiteTooltipBackdrop{padding:48px 30px 0;position:absolute;width:100%;height:100%;inset:0;background-color:rgba(0, 0, 0, 0.5)}.EngagementSuiteTooltipBackdrop .EngagementSuiteTooltip{border:1px solid var(--emw--button-border-color, #403956);background-color:var(--emw--color-background, #1e1638);border-radius:var(--emw--border-radius-large, 8px);padding:32px;font-size:var(--emw--font-size-small, 14px);line-height:17px;color:var(--emw--color-secondary, #bbb9c3);position:relative}.EngagementSuiteTooltipBackdrop .EngagementSuiteTooltip .EngagementSuiteIconButton{top:12px;right:12px;position:absolute}.LuckyWheelsEmptyNumber .LuckyWheelsName,.LuckyWheelsEmptyNumber .LuckyWheelsCountdown,.LuckyWheelsEmptyNumber .LuckyWheelsRemainCounter{color:var(--emw--color-gray-150, #8f8b9c)}.LuckyWheelsListPopup.Tablet .LuckyWheelsListPopupHeader,.LuckyWheelsListPopup.Desktop .LuckyWheelsListPopupHeader{padding-top:16px}.LuckyWheelsListPopup.Tablet .LuckyWheelsListPopupHeaderName,.LuckyWheelsListPopup.Desktop .LuckyWheelsListPopupHeaderName{font-size:var(--emw--font-size-medium, 16px);line-height:16px}.LuckyWheelsListPopup.Tablet .EngagementSuiteIconButton,.LuckyWheelsListPopup.Desktop .EngagementSuiteIconButton{width:24px;height:24px}.LuckyWheelsListPopup.Tablet .LuckyWheelsList,.LuckyWheelsListPopup.Desktop .LuckyWheelsList{padding:20px 24px 0;row-gap:20px}.LuckyWheelsListPopup.Tablet .LuckyWheelCardHeader,.LuckyWheelsListPopup.Desktop .LuckyWheelCardHeader{margin-bottom:16px}.LuckyWheelsListPopup.Tablet .LuckyWheelsName,.LuckyWheelsListPopup.Desktop .LuckyWheelsName{line-height:27px;font-size:var(--emw--font-size-large, 22px)}.LuckyWheelsListPopup.Tablet .LuckyWheelsCountdown,.LuckyWheelsListPopup.Desktop .LuckyWheelsCountdown{font-size:var(--emw--font-size-small, 14px);line-height:14px}.LuckyWheelsListPopup.Tablet .EngagementSuiteTooltipBackdrop,.LuckyWheelsListPopup.Desktop .EngagementSuiteTooltipBackdrop{padding:90px 75px 0}.LuckyWheelsListPopup.Tablet .EngagementSuiteTooltip,.LuckyWheelsListPopup.Desktop .EngagementSuiteTooltip{padding:60px 65px;font-size:var(--emw--font-size-medium, 16px);line-height:20px}.LuckyWheelsListPopup.Tablet .EngagementSuiteTooltip .EngagementSuiteIconButton,.LuckyWheelsListPopup.Desktop .EngagementSuiteTooltip .EngagementSuiteIconButton{top:24px;right:24px}.LuckyWheelsListPopup.Tablet .EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab,.LuckyWheelsListPopup.Desktop .EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab{font-size:var(--emw--font-size-medium, 16px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryCols,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryCols{font-size:var(--emw--font-size-medium, 16px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryCols .Rewards,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryCols .Rewards{flex-basis:140px}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryCols .Issued,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryCols .Issued{flex-basis:100px}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryListItemHeader,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryListItemHeader{font-size:var(--emw--font-size-large, 22px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryInfo,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryInfo{font-size:var(--emw--font-size-medium, 16px)}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryInfo .Rewards,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryInfo .Rewards{flex-basis:140px}.LuckyWheelsListPopup.Tablet .HistoryWrapper .HistoryListItem .HistoryInfo .Issued,.LuckyWheelsListPopup.Desktop .HistoryWrapper .HistoryListItem .HistoryInfo .Issued{flex-basis:100px}.EngagementSuiteTabsWrapper{padding:0 24px;margin:8px 0}.EngagementSuiteTabsWrapper .EngagementSuiteTabs{display:flex;position:relative;border-bottom:2px solid var(--emw--color-secondary, #666178)}.EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab{padding:9px 16px 7px;font-weight:var(--emw--font-weight-medium, 500);font-size:var(--emw--font-size-x-small, 12px);line-height:15px;color:var(--emw--color-gray-300, #666178);cursor:pointer}.EngagementSuiteTabsWrapper .EngagementSuiteTabs .EngagementSuiteTab.Active{color:var(--emw--color-typography, #fff);border-bottom:2px solid var(--emw--color-typography, #fff);margin-bottom:-2px}.HistoryWrapper{padding:0 24px;display:flex;flex-direction:column;height:100%;overflow:hidden}.HistoryWrapper .HistoryEmptyMessage{margin-top:8px;font-size:var(--emw--font-size-small, 14px);color:var(--emw--color-secondary, #bbb9c3);line-height:30px}.HistoryWrapper .HistoryCols{padding:12px 10px;position:relative;display:flex;border-bottom:1px solid var(--emw--color-secondary, #666178);font-size:var(--emw--font-size-x-small, 12px)}.HistoryWrapper .HistoryCols .HistoryColName{color:var(--emw--color-secondary, #bbb9c3)}.HistoryWrapper .HistoryCols .Rewards{flex-basis:80px}.HistoryWrapper .HistoryCols .Issued{flex-basis:80px}.HistoryWrapper .HistoryLoader{display:flex;flex-direction:column;justify-content:center;align-items:center;height:inherit;font-size:var(--emw--font-size-medium, 16px);color:var(--emw--color-gray-150, #8f8b9c)}.HistoryWrapper .HistoryLoader casino-engagement-suite-progress-bar{margin-bottom:8px;width:100px}.HistoryWrapper .HistoryListItem{margin-top:8px}.HistoryWrapper .HistoryListItem.Opened .EngagementSuiteIconButton.ArrowDown{transform:rotate(180deg)}.HistoryWrapper .HistoryListItem.Opened .HistoryListItemBody{padding-bottom:8px;grid-template-rows:1fr;border-bottom:1px solid var(--emw--color-secondary, #666178)}.HistoryWrapper .HistoryListItem .HistoryListItemHeader{padding:16px 0;display:flex;justify-content:space-between;align-items:center;color:var(--emw--color-typography, #ffffff);font-size:var(--emw--font-size-medium, 14px)}.HistoryWrapper .HistoryListItem .EngagementSuiteIconButton.ArrowDown{transition:transform 0.3s ease-out;width:24px;height:24px}.HistoryWrapper .HistoryListItem .HistoryListItemBody{position:relative;display:grid;grid-template-rows:0fr;transition:grid-template-rows 0.3s ease-out}.HistoryWrapper .HistoryListItem .HistoryListItemBody>div{overflow:hidden}.HistoryWrapper .HistoryListItem .HistoryListItemCard{padding:12px 5px}.HistoryWrapper .HistoryListItem .HistoryInfoRow{display:flex;gap:10px;flex-direction:column}.HistoryWrapper .HistoryListItem .HistoryInfo{display:flex;padding:10px;font-size:var(--emw--font-size-x-small, 12px);color:var(--emw--color-secondary, #bbb9c3)}.HistoryWrapper .HistoryListItem .HistoryInfo .HistoryCol{text-overflow:ellipsis;overflow:hidden}.HistoryWrapper .HistoryListItem .HistoryInfo .Rewards{color:var(--emw--color-typography, #ffffff);flex-basis:80px;font-weight:600}.HistoryWrapper .HistoryListItem .HistoryInfo .Issued{flex-basis:80px}";
2309
+ const CasinoEngagementSuiteLuckywheelListStyle0 = casinoEngagementSuiteLuckywheelListCss;
2310
+
2311
+ const CasinoEngagementSuiteLuckyWheelList = class {
2312
+ constructor(hostRef) {
2313
+ registerInstance(this, hostRef);
2314
+ this.close = createEvent(this, "close", 7);
2315
+ this.setClientStyling = () => {
2316
+ let sheet = document.createElement('style');
2317
+ sheet.innerHTML = this.clientStyling;
2318
+ this.host.prepend(sheet);
2319
+ };
2320
+ this.setClientStylingURL = () => {
2321
+ let url = new URL(this.clientStylingUrl);
2322
+ let cssFile = document.createElement('style');
2323
+ fetch(url.href)
2324
+ .then((res) => res.text())
2325
+ .then((data) => {
2326
+ cssFile.innerHTML = data;
2327
+ setTimeout(() => { this.host.prepend(cssFile); }, 1);
2328
+ })
2329
+ .catch((err) => {
2330
+ console.log('Error ', err);
2331
+ });
2332
+ };
2333
+ this.handleCloseClick = () => {
2334
+ this.close.emit();
2335
+ this.tooltip = false;
2336
+ };
2337
+ this.handleLuckyWheelClick = (ev) => {
2338
+ const id = ev.currentTarget.getAttribute('data-id');
2339
+ const index = ev.currentTarget.getAttribute('data-index');
2340
+ window.postMessage({ type: 'LuckyWheelClick', id, index });
2341
+ };
2342
+ this.showTooltip = () => {
2343
+ this.tooltip = true;
2344
+ };
2345
+ this.hideTooltip = () => {
2346
+ this.tooltip = false;
2347
+ };
2348
+ this.handleTabChange = (e) => {
2349
+ this.activeTab = +(e.target.getAttribute('data-index'));
2350
+ if (this.activeTab === 2) {
2351
+ if (!this.historyLoaded) {
2352
+ this.sendHistoryRequest();
2353
+ }
2354
+ }
2355
+ };
2356
+ this.toggleLuckyWheelHistory = (ev) => {
2357
+ const id = ev.currentTarget.getAttribute('data-id');
2358
+ const index = this.openedHistoryIds.findIndex(historyId => historyId === id);
2359
+ if (index > -1) {
2360
+ this.openedHistoryIds = this.openedHistoryIds.filter((historyId) => historyId !== id);
2361
+ }
2362
+ else {
2363
+ this.openedHistoryIds.push(id);
2364
+ }
2365
+ this.openedHistoryIds = [...this.openedHistoryIds];
2366
+ };
2367
+ this.clientStyling = '';
2368
+ this.clientStylingUrl = '';
2369
+ this.language = 'en';
2370
+ this.device = 'Mobile';
2371
+ this.luckywheels = [];
2372
+ this.endpoint = undefined;
2373
+ this.session = undefined;
2374
+ this.translationUrl = '';
2375
+ this.tooltip = false;
2376
+ this.timers = {};
2377
+ this.limitStylingAppends = false;
2378
+ this.activeTab = 1;
2379
+ this.historyLoading = false;
2380
+ this.luckywheelHistory = {};
2381
+ this.openedHistoryIds = [];
2382
+ this.historyLoaded = false;
2383
+ this.isLoading = false;
2384
+ }
2385
+ handleEvent(e) {
2386
+ const { type } = e === null || e === void 0 ? void 0 : e.data;
2387
+ if (type === 'BarLuckyWheelsClick') {
2388
+ this.activeTab = 1;
2389
+ this.openedHistoryIds = [];
2390
+ }
2391
+ }
2392
+ luckywheelsPropHandler(value) {
2393
+ if (!this.interval && value.length) {
2394
+ this.updateTimers();
2395
+ this.startCountdown();
2396
+ }
2397
+ if (this.interval && !value.length) {
2398
+ clearInterval(this.interval);
2399
+ }
2400
+ }
2401
+ componentWillLoad() {
2402
+ const promises = [];
2403
+ this.luckywheels = [];
2404
+ if (this.endpoint) {
2405
+ const consentsPromise = this.getLuckyWheels();
2406
+ promises.push(consentsPromise);
2407
+ }
2408
+ if (this.translationUrl) {
2409
+ const translationPromise = getTranslations(this.translationUrl);
2410
+ promises.push(translationPromise);
2411
+ }
2412
+ return Promise.all(promises);
2413
+ }
2414
+ getLuckyWheels() {
2415
+ let url = new URL(this.endpoint + `/v1/wof/lotteries`);
2416
+ let reqHeaders = new Headers();
2417
+ url.searchParams.append('language', this.language);
2418
+ if (this.session) {
2419
+ reqHeaders.append('X-SessionId', this.session);
2420
+ }
2421
+ let requestOptions = {
2422
+ method: 'GET',
2423
+ headers: reqHeaders,
2424
+ };
2425
+ this.isLoading = true;
2426
+ fetch(url.href, requestOptions).then((res) => res.json()).then((res) => {
2427
+ this.luckywheels = res.items;
2428
+ }).catch((err) => {
2429
+ throw new Error(err);
2430
+ }).finally(() => {
2431
+ this.isLoading = false;
2432
+ });
2433
+ }
2434
+ getLuckyWheelsHistory(luckywheelId) {
2435
+ let url = new URL(this.endpoint + `/v1/wof/outcome/${luckywheelId}`);
2436
+ let reqHeaders = new Headers();
2437
+ url.searchParams.append('language', this.language);
2438
+ if (this.session) {
2439
+ reqHeaders.append('X-SessionId', this.session);
2440
+ }
2441
+ let requestOptions = {
2442
+ method: 'GET',
2443
+ headers: reqHeaders,
2444
+ };
2445
+ return fetch(url.href, requestOptions).then((res) => res.json());
2446
+ }
2447
+ componentDidRender() {
2448
+ if (!this.limitStylingAppends && this.host) {
2449
+ if (this.clientStyling)
2450
+ this.setClientStyling();
2451
+ if (this.clientStylingUrl)
2452
+ this.setClientStylingURL();
2453
+ this.limitStylingAppends = true;
2454
+ }
2455
+ }
2456
+ disconnectedCallback() {
2457
+ this.interval && clearInterval(this.interval);
2458
+ }
2459
+ startCountdown() {
2460
+ this.interval = setInterval(() => {
2461
+ this.updateTimers();
2462
+ }, 1000);
2463
+ }
2464
+ updateTimers() {
2465
+ const now = new Date().getTime();
2466
+ this.timers = this.luckywheels.reduce((acc, luckywheel) => {
2467
+ var _a;
2468
+ const expirationDate = new Date((_a = luckywheel.current) === null || _a === void 0 ? void 0 : _a.endTime).getTime();
2469
+ const diff = expirationDate - now;
2470
+ let countdown = '00h:00m:00s';
2471
+ if (diff < 1) {
2472
+ this.removeLuckyWheel(luckywheel.program.id);
2473
+ }
2474
+ else {
2475
+ const { days, hours, minutes, seconds } = {
2476
+ days: String(Math.floor(diff / (1000 * 60 * 60 * 24))).padStart(2, '0'),
2477
+ hours: String(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'),
2478
+ minutes: String(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'),
2479
+ seconds: String(Math.floor((diff % (1000 * 60)) / 1000)).padStart(2, '0')
2480
+ };
2481
+ countdown = days === '00'
2482
+ ? `${hours}h:${minutes}m:${seconds}s`
2483
+ : `${days}d:${hours}h:${minutes}m`;
2484
+ }
2485
+ return Object.assign(Object.assign({}, acc), { [luckywheel.program.id]: countdown });
2486
+ }, {});
2487
+ }
2488
+ removeLuckyWheel(id) {
2489
+ this.luckywheels = this.luckywheels.filter((luckywheel) => luckywheel.program.id !== id);
2490
+ window.postMessage({ type: 'LuckyWheelHasExpired', id });
2491
+ }
2492
+ async sendHistoryRequest() {
2493
+ this.historyLoading = true;
2494
+ if (!this.luckywheels.length) {
2495
+ return;
2496
+ }
2497
+ const promises = [];
2498
+ this.luckywheels.forEach(async (luckywheel) => {
2499
+ promises.push(this.getLuckyWheelsHistory(luckywheel.program.id).then(res => {
2500
+ this.luckywheelHistory[luckywheel.program.id] = res.items;
2501
+ }));
2502
+ });
2503
+ await Promise.all(promises);
2504
+ this.historyLoading = false;
2505
+ this.historyLoaded = true;
2506
+ }
2507
+ getLuckyWheelClasses(luckyWheel) {
2508
+ return {
2509
+ LuckyWheelsCard: true,
2510
+ LuckyWheelsEmptyNumber: luckyWheel.current.remainingTimes === 0
2511
+ };
2512
+ }
2513
+ getLuckyWheelName(luckywheel) {
2514
+ var _a, _b;
2515
+ return ((_a = luckywheel.program) === null || _a === void 0 ? void 0 : _a.name['en']) || ((_b = luckywheel.program) === null || _b === void 0 ? void 0 : _b.name['*']);
2516
+ }
2517
+ getLuckyWheelHeaderTemplate(luckywheel) {
2518
+ var _a, _b;
2519
+ return (h("div", { class: "LuckyWheelsCardHeader" }, h("div", { class: `LuckyWheelsName` }, this.getLuckyWheelName(luckywheel)), (h("div", { class: "LuckyWheelsCounter" }, h("div", { class: `${((_a = luckywheel.current) === null || _a === void 0 ? void 0 : _a.remainingTimes) ? 'LuckyWheelsHighlightedCounter' : 'LuckyWheelsEmptyCounter'}` }, (_b = luckywheel.current) === null || _b === void 0 ? void 0 : _b.remainingTimes)))));
2520
+ }
2521
+ getLuckyWheelTemplate(luckywheel, index) {
2522
+ const countdown = this.timers[luckywheel.program.id];
2523
+ //TODO: canceled status
2524
+ const isCanceled = luckywheel.current.remainingTimes === 0;
2525
+ return (h("div", { class: this.getLuckyWheelClasses(luckywheel), onClick: this.handleLuckyWheelClick, key: luckywheel.program.id, "data-id": luckywheel.program.id, "data-index": index }, this.getLuckyWheelHeaderTemplate(luckywheel), isCanceled ? (h("div", { class: "ForfeitedMessage" }, h("div", null, translate('canceled', this.language)), h("div", null, translate('support', this.language)))) : (h("div", { class: "LuckyWheelsCountdownWrapper" }, h("span", { class: "LuckyWheelsCountdown" }, countdown)))));
2526
+ }
2527
+ getHeaderTemplate() {
2528
+ return h("header", { class: "LuckyWheelsListPopupHeader" }, h("button", { onClick: this.showTooltip, class: "EngagementSuiteIconButton Help" }), h("div", { class: "LuckyWheelsListPopupHeaderName" }, translate('luckyWheel', this.language)), h("button", { class: "EngagementSuiteIconButton Close", onClick: this.handleCloseClick }));
2529
+ }
2530
+ getListTemplate() {
2531
+ if (this.isLoading) {
2532
+ return h("general-animation-loading", null);
2533
+ }
2534
+ if (this.luckywheels.length) {
2535
+ return h("div", { class: "LuckyWheelsListWrapper" }, h("div", { class: "LuckyWheelsList" }, this.luckywheels.map((luckywheel, index) => this.getLuckyWheelTemplate(luckywheel, index))));
2536
+ }
2537
+ else {
2538
+ return h("div", { class: "LuckyWheelsListEmpty" }, h("h2", null, translate('noluckywheels', this.language)), h("p", null, translate('tryOtherGames', this.language)));
2539
+ }
2540
+ }
2541
+ getTooltipTemplate() {
2542
+ if (this.tooltip) {
2543
+ return h("div", { class: "EngagementSuiteTooltipBackdrop" }, h("div", { class: "EngagementSuiteTooltip" }, h("button", { class: "EngagementSuiteIconButton Close", onClick: this.hideTooltip }), translate('tooltip', this.language)));
2544
+ }
2545
+ else {
2546
+ return '';
2547
+ }
2548
+ }
2549
+ getTabsTemplate() {
2550
+ return h("div", { class: "EngagementSuiteTabsWrapper" }, h("div", { class: "EngagementSuiteTabs" }, h("div", { "data-index": "1", onClick: this.handleTabChange, class: `EngagementSuiteTab ${this.activeTab === 1 ? 'Active' : ''}` }, translate('luckywheels', this.language)), h("div", { "data-index": "2", onClick: this.handleTabChange, class: `EngagementSuiteTab ${this.activeTab === 2 ? 'Active' : ''}` }, translate('history', this.language))));
2551
+ }
2552
+ getHistoryTabTemplate() {
2553
+ return h("div", { class: "HistoryWrapper" }, h("div", { class: "HistoryCols" }, h("div", { class: "HistoryColName Rewards" }, translate('rewards', this.language)), h("div", { class: "HistoryColName Issued" }, translate('issued', this.language)), h("div", { class: "HistoryColName Time" }, translate('time', this.language))), this.historyLoading
2554
+ ? getHistoryLoaderTemplate(this.language)
2555
+ : getLuckyWheelsHistoryTemplate(this.luckywheels, this.luckywheelHistory, this.openedHistoryIds, this.toggleLuckyWheelHistory, this.language));
2556
+ }
2557
+ getTabsContentTemplate() {
2558
+ return this.activeTab === 1
2559
+ ? this.getListTemplate()
2560
+ : this.getHistoryTabTemplate();
2561
+ }
2562
+ render() {
2563
+ return h("div", { key: 'bec9d35e1b9362a5098ab53c9fddb620b407b17e', class: `LuckyWheelsListPopup ${this.device}` }, this.getHeaderTemplate(), this.getTabsTemplate(), this.getTabsContentTemplate(), this.getTooltipTemplate());
2564
+ }
2565
+ get host() { return getElement(this); }
2566
+ static get watchers() { return {
2567
+ "luckywheels": ["luckywheelsPropHandler"]
2568
+ }; }
2569
+ };
2570
+ CasinoEngagementSuiteLuckyWheelList.style = CasinoEngagementSuiteLuckywheelListStyle0;
2571
+
2572
+ export { CasinoEngagementSuiteLuckyWheelList as C };