@everymatrix/player-elevate-card 1.32.4 → 1.33.1

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 (116) hide show
  1. package/dist/cjs/general-styling-wrapper_5.cjs.entry.js +3162 -0
  2. package/dist/cjs/index-234565f1.js +1645 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/player-elevate-card.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +22 -0
  7. package/dist/collection/components/player-elevate-card/player-elevate-card-items.js +43 -0
  8. package/dist/collection/components/player-elevate-card/player-elevate-card.css +65 -0
  9. package/dist/collection/components/player-elevate-card/player-elevate-card.js +282 -0
  10. package/dist/collection/components/player-elevate-card-data/player-elevate-card-data.css +189 -0
  11. package/dist/collection/components/player-elevate-card-data/player-elevate-card-data.js +208 -0
  12. package/dist/collection/components/player-elevate-loyaltycard/player-elevate-loyaltycard.css +68 -0
  13. package/dist/collection/components/player-elevate-loyaltycard/player-elevate-loyaltycard.js +287 -0
  14. package/dist/collection/components/player-elevate-pointcard/player-elevate-pointcard.css +70 -0
  15. package/dist/collection/components/player-elevate-pointcard/player-elevate-pointcard.js +323 -0
  16. package/dist/collection/components/static/button-default.svg +42 -0
  17. package/dist/collection/components/static/button-disabled.svg +4 -0
  18. package/dist/collection/components/static/button-hover.svg +4 -0
  19. package/dist/collection/components/static/button-level.svg +27 -0
  20. package/dist/collection/components/static/button-pressed.svg +18 -0
  21. package/dist/collection/components/static/button-redeem.svg +36 -0
  22. package/dist/collection/components/static/card-ground-over.png +0 -0
  23. package/dist/collection/components/static/card-ground-over.svg +903 -0
  24. package/dist/collection/components/static/card-ground.png +0 -0
  25. package/dist/collection/components/static/card-ground.svg +34 -0
  26. package/dist/collection/components/static/info.svg +4 -0
  27. package/dist/collection/components/static/level-badge.png +0 -0
  28. package/dist/collection/components/static/level-percent.svg +80 -0
  29. package/dist/collection/components/static/tips-info.svg +21 -0
  30. package/dist/collection/components/static/user.svg +3 -0
  31. package/dist/collection/index.js +1 -0
  32. package/dist/collection/models/player-elevate.js +1 -0
  33. package/dist/collection/utils/locale.utils.js +144 -0
  34. package/dist/collection/utils/utils.js +47 -0
  35. package/dist/components/general-styling-wrapper.js +6 -0
  36. package/dist/components/general-styling-wrapper2.js +103 -0
  37. package/dist/components/index.d.ts +26 -0
  38. package/dist/components/index.js +1 -0
  39. package/dist/components/player-elevate-card-data.d.ts +11 -0
  40. package/dist/components/player-elevate-card-data.js +6 -0
  41. package/dist/components/player-elevate-card-data2.js +624 -0
  42. package/dist/components/player-elevate-card-items.js +2250 -0
  43. package/dist/components/player-elevate-card.d.ts +11 -0
  44. package/dist/components/player-elevate-card.js +118 -0
  45. package/dist/components/player-elevate-loyaltycard.d.ts +11 -0
  46. package/dist/components/player-elevate-loyaltycard.js +124 -0
  47. package/dist/components/player-elevate-pointcard.d.ts +11 -0
  48. package/dist/components/player-elevate-pointcard.js +127 -0
  49. package/dist/components/static/button-default.svg +42 -0
  50. package/dist/components/static/button-disabled.svg +4 -0
  51. package/dist/components/static/button-hover.svg +4 -0
  52. package/dist/components/static/button-level.svg +27 -0
  53. package/dist/components/static/button-pressed.svg +18 -0
  54. package/dist/components/static/button-redeem.svg +36 -0
  55. package/dist/components/static/card-ground-over.png +0 -0
  56. package/dist/components/static/card-ground-over.svg +903 -0
  57. package/dist/components/static/card-ground.png +0 -0
  58. package/dist/components/static/card-ground.svg +34 -0
  59. package/dist/components/static/info.svg +4 -0
  60. package/dist/components/static/level-badge.png +0 -0
  61. package/dist/components/static/level-percent.svg +80 -0
  62. package/dist/components/static/tips-info.svg +21 -0
  63. package/dist/components/static/user.svg +3 -0
  64. package/dist/esm/general-styling-wrapper_5.entry.js +3154 -0
  65. package/dist/esm/index-747197fd.js +1616 -0
  66. package/dist/esm/index.js +1 -0
  67. package/dist/esm/loader.js +17 -0
  68. package/dist/esm/player-elevate-card.js +17 -0
  69. package/dist/esm/polyfills/core-js.js +11 -0
  70. package/dist/esm/polyfills/css-shim.js +1 -0
  71. package/dist/esm/polyfills/dom.js +79 -0
  72. package/dist/esm/polyfills/es5-html-element.js +1 -0
  73. package/dist/esm/polyfills/index.js +34 -0
  74. package/dist/esm/polyfills/system.js +6 -0
  75. package/dist/index.cjs.js +1 -0
  76. package/dist/index.js +1 -0
  77. package/dist/player-elevate-card/index.esm.js +0 -0
  78. package/dist/player-elevate-card/p-56620f7c.entry.js +1 -0
  79. package/dist/player-elevate-card/p-afe7b72e.js +1 -0
  80. package/dist/player-elevate-card/player-elevate-card.esm.js +1 -0
  81. package/dist/static/button-default.svg +42 -0
  82. package/dist/static/button-disabled.svg +4 -0
  83. package/dist/static/button-hover.svg +4 -0
  84. package/dist/static/button-level.svg +27 -0
  85. package/dist/static/button-pressed.svg +18 -0
  86. package/dist/static/button-redeem.svg +36 -0
  87. package/dist/static/card-ground-over.png +0 -0
  88. package/dist/static/card-ground-over.svg +903 -0
  89. package/dist/static/card-ground.png +0 -0
  90. package/dist/static/card-ground.svg +34 -0
  91. package/dist/static/info.svg +4 -0
  92. package/dist/static/level-badge.png +0 -0
  93. package/dist/static/level-percent.svg +80 -0
  94. package/dist/static/tips-info.svg +21 -0
  95. package/dist/static/user.svg +3 -0
  96. package/dist/stencil.config.js +32 -0
  97. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/player-elevate-card/.stencil/packages/player-elevate-card/stencil.config.d.ts +2 -0
  98. package/dist/types/components/player-elevate-card/player-elevate-card-items.d.ts +19 -0
  99. package/dist/types/components/player-elevate-card/player-elevate-card.d.ts +53 -0
  100. package/dist/types/components/player-elevate-card-data/player-elevate-card-data.d.ts +22 -0
  101. package/dist/types/components/player-elevate-loyaltycard/player-elevate-loyaltycard.d.ts +53 -0
  102. package/dist/types/components/player-elevate-pointcard/player-elevate-pointcard.d.ts +66 -0
  103. package/dist/types/components.d.ts +335 -0
  104. package/dist/types/index.d.ts +1 -0
  105. package/dist/types/models/player-elevate.d.ts +40 -0
  106. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  107. package/dist/types/utils/locale.utils.d.ts +15 -0
  108. package/dist/types/utils/utils.d.ts +1 -0
  109. package/loader/cdn.js +3 -0
  110. package/loader/index.cjs.js +3 -0
  111. package/loader/index.d.ts +12 -0
  112. package/loader/index.es2017.js +3 -0
  113. package/loader/index.js +4 -0
  114. package/loader/package.json +10 -0
  115. package/package.json +2 -3
  116. package/LICENSE +0 -21
@@ -0,0 +1,3162 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-234565f1.js');
6
+
7
+ const mergeTranslations = (url, target) => {
8
+ return new Promise((resolve) => {
9
+ fetch(url)
10
+ .then((res) => res.json())
11
+ .then((data) => {
12
+ Object.keys(data).forEach((item) => {
13
+ target[item] = target[item] ? target[item] : {};
14
+ for (let key in data[item]) {
15
+ target[item][key] = data[item][key];
16
+ }
17
+ });
18
+ resolve(true);
19
+ });
20
+ });
21
+ };
22
+
23
+ const generalStylingWrapperCss = ":host{display:block}";
24
+
25
+ const GeneralStylingWrapper = class {
26
+ constructor(hostRef) {
27
+ index.registerInstance(this, hostRef);
28
+ /**
29
+ * Client custom styling via inline styles
30
+ */
31
+ this.clientStyling = '';
32
+ /**
33
+ * Client custom styling via url
34
+ */
35
+ this.clientStylingUrl = '';
36
+ /**
37
+ * Translation via url
38
+ */
39
+ this.translationUrl = '';
40
+ this.stylingAppends = false;
41
+ this.setClientStyling = () => {
42
+ let sheet = document.createElement('style');
43
+ sheet.innerHTML = this.clientStyling;
44
+ this.el.prepend(sheet);
45
+ };
46
+ this.setClientStylingURL = () => {
47
+ let url = new URL(this.clientStylingUrl);
48
+ let cssFile = document.createElement('style');
49
+ fetch(url.href)
50
+ .then((res) => res.text())
51
+ .then((data) => {
52
+ cssFile.innerHTML = data;
53
+ setTimeout(() => {
54
+ this.el.prepend(cssFile);
55
+ }, 1);
56
+ })
57
+ .catch((err) => {
58
+ console.log('error ', err);
59
+ });
60
+ };
61
+ }
62
+ componentDidRender() {
63
+ // start custom styling area
64
+ if (!this.stylingAppends) {
65
+ if (this.clientStyling)
66
+ this.setClientStyling();
67
+ if (this.clientStylingUrl)
68
+ this.setClientStylingURL();
69
+ this.stylingAppends = true;
70
+ }
71
+ // end custom styling area
72
+ }
73
+ async componentWillLoad() {
74
+ const promises = [];
75
+ if (this.translationUrl) {
76
+ const translationPromise = mergeTranslations(this.translationUrl, this.targetTranslations);
77
+ promises.push(translationPromise);
78
+ }
79
+ return await Promise.all(promises);
80
+ }
81
+ render() {
82
+ return (index.h("div", { class: "StyleShell" }, index.h("slot", { name: "mainContent" })));
83
+ }
84
+ get el() { return index.getElement(this); }
85
+ };
86
+ GeneralStylingWrapper.style = generalStylingWrapperCss;
87
+
88
+ const LoyaltyProgress = `<svg width="100%" height="28" fill="none" xmlns="http://www.w3.org/2000/svg">
89
+ <rect y="12" width="100%" id="total_level" height="5" rx="2.5" fill="white" fill-opacity="0.5"/>
90
+ <rect y="12" id="current_level" width="64" height="5" rx="2.5" fill="white"/>
91
+ <g filter="url(#filter_current_level)">
92
+ <circle id="circle_current_level" cx="74.5" cy="14.5" r="6.5" fill="white"/>
93
+ </g>
94
+ <g filter="url(#filter_heart_ball)">
95
+ <g filter="url(#filter_ball)">
96
+ <circle cx="169" cy="14" r="10" id="lock" fill="url(#paint0_linear_ball)"/>
97
+ </g>
98
+ <g filter="url(#filter_heart)">
99
+ <svg x="0" y="4" id="lock_box">
100
+ <path d="M10.217 6.42442c-0.713,-0.574,-1.304,-1.083,-1.928,-1.622c-0.348,-0.299,-0.707,-0.611,-1.101,-0.943l-0.013,-0.01c0,0,-0.023,-0.017,-0.04,-0.027l-0.167,-0.095l-0.15,0.12c0,0,-0.015,0.012,-0.024,0.02c-0.391,0.33,-0.749,0.64,-1.094,0.939c-0.622,0.539,-1.211,1.048,-1.924,1.624c-1.816,1.463,-3.598,3.263,-3.033,5.506c0.404,1.601,2.104,2.905,3.789,2.905c0.211,0,0.423,-0.02,0.626,-0.061c0.286,-0.058,0.572,-0.145,0.864,-0.265c-0.079,0.962,-0.413,1.864,-0.881,2.369l-0.423,0.459h0.633c0.633,0,1.018,-0.007,1.356,-0.013c0.248,-0.004,0.462,-0.008,0.72,-0.008c0.335,0,0.709,0.006,1.215,0.021l0.686,0.02l-0.474,-0.483c-0.504,-0.514,-0.847,-1.403,-0.923,-2.385c0.311,0.132,0.616,0.227,0.916,0.287c0.204,0.039,0.411,0.059,0.623,0.059c1.687,0,3.386,-1.304,3.789,-2.909c0.56,-2.243,-1.224,-4.041,-3.042,-5.504v-0.004z" fill="#933CBF"/>
101
+ <path d="M9.727,6.98459c-1.004,-0.83,-1.741,-1.515,-2.723,-2.365c-0.002,0,-0.004,-0.004,-0.007,-0.006c-0.002,0,-0.004,0.004,-0.006,0.006c-0.98,0.85,-1.715,1.537,-2.721,2.367c-1.455,1.202,-3.126,2.821,-2.638,4.81c0.37,1.511,2.091,2.751,3.665,2.43c0.389,-0.08,0.75,-0.224,1.094,-0.402c0,0.116,-0.004,0.233,-0.012,0.353c-0.064,0.991,-0.398,1.892,-0.86,2.401c1.481,0,1.481,-0.043,2.961,0c-0.481,-0.503,-0.834,-1.382,-0.9,-2.401c-0.008,-0.127,-0.012,-0.253,-0.012,-0.378c0.357,0.19,0.733,0.342,1.14,0.425c1.574,0.319,3.292,-0.922,3.661,-2.433c0.486,-1.992,-1.189,-3.609,-2.644,
102
+ -4.809l0.002,0.002z" fill="url(#paint1_linear_lock)"/>
103
+ <path d="M9.255,7.551c-0.844,-0.716,-1.462,-1.309,-2.286,-2.045c-0.002,0,-0.004,-0.004,-0.006,-0.006c0,0,-0.004,0.004,-0.006,0.006c-0.824,0.736,-1.44,1.329,-2.284,2.047c-0.919,0.782,-1.94,1.769,-2.214,2.943c-0.115,0.021,-0.914,0.044,-0.914,0.044l0.887,0.083c-0.039,0.206,-0.055,0.418,-0.041,0.638c0.087,-1.371,1.25,-2.507,2.282,-3.384c0.844,-0.718,1.462,-1.313,2.284,-2.047c0.002,-0.002,0.004,-0.004,0.006,-0.006c0.002,0,0.004,0.004,0.006,0.004c0.824,0.734,1.442,1.329,2.286,2.045c1.034,0.879,2.198,2.013,2.286,3.386c0.093,-1.517,-1.173,-2.761,-2.286,-3.708z" fill="#9040C9"/>
104
+ </svg>
105
+ </g>
106
+ </g>
107
+ <g filter="url(#filter_lock)">
108
+ <svg x="100%" y="9" id="heart_box">
109
+ <path d="M7,6c-0.19,-0.002,-0.377,0.052,-0.534,0.154c-0.158,0.103,-0.278,0.25,-0.346,0.42c-0.069,0.171,-0.081,0.357,-0.035,0.535c0.046,0.177,0.147,0.337,0.29,0.457v0.834c0,0.159,0.066,0.312,0.183,0.424c0.117,0.113,0.276,0.176,0.442,0.176c0.166,0,0.325,-0.063,0.442,-0.176c0.117,-0.112,0.183,-0.265,0.183,-0.424v-0.834c0.143,-0.12,0.244,-0.28,0.29,-0.457c0.046,-0.178,0.034,-0.364,-0.035,-0.535c-0.068,-0.17,-0.188,-0.317,-0.346,-0.42c-0.157,-0.102,-0.344,-0.156,-0.534,-0.154zm3.125,-2.4v-1.2c0,-0.796,-0.329,-1.559,-0.915,-2.121c-0.586,-0.563,-1.381,-0.879,-2.21,-0.879c-0.829,0,-1.624,0.316,-2.21,0.879c-0.586,0.562,-0.915,1.325,-0.915,2.121v1.2c-0.497,0,-0.974,0.19,-1.326,0.527c-0.351,0.338,-0.549,0.796,-0.549,1.273v4.2c0,0.477,0.198,0.935,0.549,1.273c0.352,0.337,0.829,0.527,1.326,0.527h6.25c0.497,0,0.974,-0.19,1.326,-0.527c0.351,-0.338,0.549,-0.796,0.549,-1.273v-4.2c0,-0.477,-0.198,-0.935,-0.549,-1.273c-0.352,-0.337,-0.829,-0.527,-1.326,-0.527zm-5,-1.2c0,-0.477,0.198,-0.935,0.549,-1.273c0.352,-0.337,0.829,-0.527,1.326,-0.527c0.497,0,0.974,0.19,1.326,0.527c0.351,0.338,0.549,0.796,0.549,1.273v1.2h-3.75v-1.2zm5.625,7.2c0,0.159,-0.066,0.312,-0.183,0.424c-0.117,0.113,-0.276,0.176,-0.442,0.176h-6.25c-0.166,0,-0.325,-0.063,-0.442,-0.176c-0.117,-0.112,-0.183,-0.265,-0.183,-0.424v-4.2c0,-0.159,0.066,-0.312,0.183,-0.424c0.117,-0.113,0.276,-0.176,0.442,-0.176h6.25c0.166,0,0.325,0.063,0.442,0.176c0.117,0.112,0.183,0.265,0.183,0.424v4.2z" fill="white"/>
110
+ </svg>
111
+ </g>
112
+ <defs>
113
+ <filter id="filter_current_level" x="64" y="4" width="21" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
114
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
115
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
116
+ <feGaussianBlur stdDeviation="2" result="effect1_foregroundBlur_305_23"/>
117
+ </filter>
118
+ <filter id="filter_heart_ball" x="155" y="0" width="28" height="28" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
119
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
120
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
121
+ <feOffset/>
122
+ <feGaussianBlur stdDeviation="2"/>
123
+ <feComposite in2="hardAlpha" operator="out"/>
124
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
125
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
126
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
127
+ </filter>
128
+ <filter id="filter_ball" x="159" y="4" width="20" height="21" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
129
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
130
+ <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
131
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
132
+ <feOffset dy="1"/>
133
+ <feGaussianBlur stdDeviation="1"/>
134
+ <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
135
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0"/>
136
+ <feBlend mode="normal" in2="shape" result="effect1_innerShadow_305_23"/>
137
+ </filter>
138
+ <filter id="filter_heart" x="161.636" y="5.72727" width="14.7271" height="15.6364" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
139
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
140
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
141
+ <feOffset/>
142
+ <feGaussianBlur stdDeviation="0.5"/>
143
+ <feComposite in2="hardAlpha" operator="out"/>
144
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
145
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
146
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
147
+ </filter>
148
+ <filter id="filter_lock" x="50" y="7" width="12" height="14" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
149
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
150
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
151
+ <feOffset/>
152
+ <feGaussianBlur stdDeviation="0.5"/>
153
+ <feComposite in2="hardAlpha" operator="out"/>
154
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
155
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_305_23"/>
156
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_305_23" result="shape"/>
157
+ </filter>
158
+ <linearGradient id="paint0_linear_ball" x1="163" y1="6" x2="174.2" y2="22.6" gradientUnits="userSpaceOnUse">
159
+ <stop stop-color="#946AD7"/>
160
+ <stop offset="1" stop-color="#EFABEB"/>
161
+ </linearGradient>
162
+ <linearGradient id="paint1_linear_lock" x1="100%" y1="18.4056" x2="169.002" y2="10.2845" gradientUnits="userSpaceOnUse">
163
+ <stop stop-color="#814FD6"/>
164
+ <stop offset="1" stop-color="#D679D8"/>
165
+ </linearGradient>
166
+ </defs>
167
+ </svg>
168
+ `;
169
+
170
+ const DEFAULT_LANGUAGE = 'en';
171
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
172
+ const TRANSLATIONS = {
173
+ en: {
174
+ redeem: 'Redeem',
175
+ expireOn: 'Expire on ',
176
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
177
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
178
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
179
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
180
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
181
+ spendablePoints: 'Spendable Points:',
182
+ details: 'Details',
183
+ earningRules: 'Earning Rules',
184
+ xp: 'XP',
185
+ sp: 'Coins',
186
+ termAndConditions: 'Term & Conditions',
187
+ },
188
+ 'zh-hk': {
189
+ redeem: '兑奖',
190
+ expireOn: 'Expire on ',
191
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
192
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
193
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
194
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
195
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
196
+ spendablePoints: 'Spendable Points:',
197
+ details: '明细',
198
+ earningRules: 'Earning Rules',
199
+ xp: 'XP',
200
+ sp: 'Coins',
201
+ termAndConditions: 'Term & Conditions',
202
+ },
203
+ de: {
204
+ redeem: 'Redeem',
205
+ expireOn: 'Expire on ',
206
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
207
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
208
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
209
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
210
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
211
+ spendablePoints: 'Spendable Points:',
212
+ details: 'Details',
213
+ earningRules: 'Earning Rules',
214
+ xp: 'XP',
215
+ sp: 'Coins',
216
+ termAndConditions: 'Term & Conditions',
217
+ },
218
+ it: {
219
+ redeem: 'Redeem',
220
+ expireOn: 'Expire on ',
221
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
222
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
223
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
224
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
225
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
226
+ spendablePoints: 'Spendable Points:',
227
+ details: 'Details',
228
+ earningRules: 'Earning Rules',
229
+ xp: 'XP',
230
+ sp: 'Coins',
231
+ termAndConditions: 'Term & Conditions',
232
+ },
233
+ fr: {
234
+ redeem: 'Redeem',
235
+ expireOn: 'Expire on ',
236
+ pointsToBeExpired: '${expirationPoints} points to expire in ${expireDay} days',
237
+ pointsToBeExpiredDay: '${expirationPoints} points to expire in ${expireDay} day',
238
+ pointsToBeExpiredHours: '${expirationPoints} points to expire in ${expireDay} hours',
239
+ pointsToBeExpiredHour: '${expirationPoints} points to expire in ${expireDay} hour',
240
+ tipsForNextLevel: 'Need ${pointsToReach} to reach ${levelName}',
241
+ spendablePoints: 'Spendable Points:',
242
+ details: 'Details',
243
+ earningRules: 'Earning Rules',
244
+ xp: 'XP',
245
+ sp: 'Coins',
246
+ termAndConditions: 'Term & Conditions',
247
+ },
248
+ es: {
249
+ redeem: 'Redeem'
250
+ },
251
+ tr: {
252
+ redeem: 'Redeem'
253
+ },
254
+ ru: {
255
+ redeem: 'Redeem'
256
+ },
257
+ ro: {
258
+ redeem: 'Redeem'
259
+ },
260
+ hr: {
261
+ redeem: 'Otkupiti',
262
+ expireOn: 'Istječe',
263
+ pointsToBeExpired: '${expirationPoints} bodova ističe za ${expireDay} dana',
264
+ tipsForNextLevel: 'Trebate ${pointsToReach} da dosegnete razinu ${levelName}',
265
+ spendablePoints: 'Bodovi za potrošit:',
266
+ details: 'Detalji',
267
+ xp: 'XP',
268
+ },
269
+ hu: {
270
+ redeem: 'Redeem'
271
+ },
272
+ pl: {
273
+ redeem: 'Redeem'
274
+ },
275
+ pt: {
276
+ redeem: 'Redeem'
277
+ },
278
+ sl: {
279
+ redeem: 'Redeem'
280
+ },
281
+ sr: {
282
+ redeem: 'Redeem'
283
+ }
284
+ };
285
+ const translate = (key, customLang) => {
286
+ const lang = customLang;
287
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
288
+ };
289
+ const translateWithParams = (key, params) => {
290
+ const lang = params['lang'];
291
+ let templateString = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
292
+ if (!params) {
293
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
294
+ }
295
+ Object.keys(params).forEach((paramName) => {
296
+ templateString = templateString.replace(new RegExp('\\$\{' + paramName + '\}', 'gm'), params[paramName]);
297
+ });
298
+ return templateString;
299
+ };
300
+
301
+ function _typeof(o) {
302
+ "@babel/helpers - typeof";
303
+
304
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
305
+ return typeof o;
306
+ } : function (o) {
307
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
308
+ }, _typeof(o);
309
+ }
310
+
311
+ function requiredArgs(required, args) {
312
+ if (args.length < required) {
313
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
314
+ }
315
+ }
316
+
317
+ /**
318
+ * @name isDate
319
+ * @category Common Helpers
320
+ * @summary Is the given value a date?
321
+ *
322
+ * @description
323
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
324
+ *
325
+ * @param {*} value - the value to check
326
+ * @returns {boolean} true if the given value is a date
327
+ * @throws {TypeError} 1 arguments required
328
+ *
329
+ * @example
330
+ * // For a valid date:
331
+ * const result = isDate(new Date())
332
+ * //=> true
333
+ *
334
+ * @example
335
+ * // For an invalid date:
336
+ * const result = isDate(new Date(NaN))
337
+ * //=> true
338
+ *
339
+ * @example
340
+ * // For some value:
341
+ * const result = isDate('2014-02-31')
342
+ * //=> false
343
+ *
344
+ * @example
345
+ * // For an object:
346
+ * const result = isDate({})
347
+ * //=> false
348
+ */
349
+ function isDate(value) {
350
+ requiredArgs(1, arguments);
351
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
352
+ }
353
+
354
+ /**
355
+ * @name toDate
356
+ * @category Common Helpers
357
+ * @summary Convert the given argument to an instance of Date.
358
+ *
359
+ * @description
360
+ * Convert the given argument to an instance of Date.
361
+ *
362
+ * If the argument is an instance of Date, the function returns its clone.
363
+ *
364
+ * If the argument is a number, it is treated as a timestamp.
365
+ *
366
+ * If the argument is none of the above, the function returns Invalid Date.
367
+ *
368
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
369
+ *
370
+ * @param {Date|Number} argument - the value to convert
371
+ * @returns {Date} the parsed date in the local time zone
372
+ * @throws {TypeError} 1 argument required
373
+ *
374
+ * @example
375
+ * // Clone the date:
376
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
377
+ * //=> Tue Feb 11 2014 11:30:30
378
+ *
379
+ * @example
380
+ * // Convert the timestamp to date:
381
+ * const result = toDate(1392098430000)
382
+ * //=> Tue Feb 11 2014 11:30:30
383
+ */
384
+ function toDate(argument) {
385
+ requiredArgs(1, arguments);
386
+ var argStr = Object.prototype.toString.call(argument);
387
+
388
+ // Clone the date
389
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
390
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
391
+ return new Date(argument.getTime());
392
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
393
+ return new Date(argument);
394
+ } else {
395
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
396
+ // eslint-disable-next-line no-console
397
+ 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");
398
+ // eslint-disable-next-line no-console
399
+ console.warn(new Error().stack);
400
+ }
401
+ return new Date(NaN);
402
+ }
403
+ }
404
+
405
+ /**
406
+ * @name isValid
407
+ * @category Common Helpers
408
+ * @summary Is the given date valid?
409
+ *
410
+ * @description
411
+ * Returns false if argument is Invalid Date and true otherwise.
412
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
413
+ * Invalid Date is a Date, whose time value is NaN.
414
+ *
415
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
416
+ *
417
+ * @param {*} date - the date to check
418
+ * @returns {Boolean} the date is valid
419
+ * @throws {TypeError} 1 argument required
420
+ *
421
+ * @example
422
+ * // For the valid date:
423
+ * const result = isValid(new Date(2014, 1, 31))
424
+ * //=> true
425
+ *
426
+ * @example
427
+ * // For the value, convertable into a date:
428
+ * const result = isValid(1393804800000)
429
+ * //=> true
430
+ *
431
+ * @example
432
+ * // For the invalid date:
433
+ * const result = isValid(new Date(''))
434
+ * //=> false
435
+ */
436
+ function isValid(dirtyDate) {
437
+ requiredArgs(1, arguments);
438
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
439
+ return false;
440
+ }
441
+ var date = toDate(dirtyDate);
442
+ return !isNaN(Number(date));
443
+ }
444
+
445
+ function toInteger(dirtyNumber) {
446
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
447
+ return NaN;
448
+ }
449
+ var number = Number(dirtyNumber);
450
+ if (isNaN(number)) {
451
+ return number;
452
+ }
453
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
454
+ }
455
+
456
+ /**
457
+ * @name addMilliseconds
458
+ * @category Millisecond Helpers
459
+ * @summary Add the specified number of milliseconds to the given date.
460
+ *
461
+ * @description
462
+ * Add the specified number of milliseconds to the given date.
463
+ *
464
+ * @param {Date|Number} date - the date to be changed
465
+ * @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`.
466
+ * @returns {Date} the new date with the milliseconds added
467
+ * @throws {TypeError} 2 arguments required
468
+ *
469
+ * @example
470
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
471
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
472
+ * //=> Thu Jul 10 2014 12:45:30.750
473
+ */
474
+ function addMilliseconds(dirtyDate, dirtyAmount) {
475
+ requiredArgs(2, arguments);
476
+ var timestamp = toDate(dirtyDate).getTime();
477
+ var amount = toInteger(dirtyAmount);
478
+ return new Date(timestamp + amount);
479
+ }
480
+
481
+ /**
482
+ * @name subMilliseconds
483
+ * @category Millisecond Helpers
484
+ * @summary Subtract the specified number of milliseconds from the given date.
485
+ *
486
+ * @description
487
+ * Subtract the specified number of milliseconds from the given date.
488
+ *
489
+ * @param {Date|Number} date - the date to be changed
490
+ * @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`.
491
+ * @returns {Date} the new date with the milliseconds subtracted
492
+ * @throws {TypeError} 2 arguments required
493
+ *
494
+ * @example
495
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
496
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
497
+ * //=> Thu Jul 10 2014 12:45:29.250
498
+ */
499
+ function subMilliseconds(dirtyDate, dirtyAmount) {
500
+ requiredArgs(2, arguments);
501
+ var amount = toInteger(dirtyAmount);
502
+ return addMilliseconds(dirtyDate, -amount);
503
+ }
504
+
505
+ var MILLISECONDS_IN_DAY$1 = 86400000;
506
+ function getUTCDayOfYear(dirtyDate) {
507
+ requiredArgs(1, arguments);
508
+ var date = toDate(dirtyDate);
509
+ var timestamp = date.getTime();
510
+ date.setUTCMonth(0, 1);
511
+ date.setUTCHours(0, 0, 0, 0);
512
+ var startOfYearTimestamp = date.getTime();
513
+ var difference = timestamp - startOfYearTimestamp;
514
+ return Math.floor(difference / MILLISECONDS_IN_DAY$1) + 1;
515
+ }
516
+
517
+ function startOfUTCISOWeek(dirtyDate) {
518
+ requiredArgs(1, arguments);
519
+ var weekStartsOn = 1;
520
+ var date = toDate(dirtyDate);
521
+ var day = date.getUTCDay();
522
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
523
+ date.setUTCDate(date.getUTCDate() - diff);
524
+ date.setUTCHours(0, 0, 0, 0);
525
+ return date;
526
+ }
527
+
528
+ function getUTCISOWeekYear(dirtyDate) {
529
+ requiredArgs(1, arguments);
530
+ var date = toDate(dirtyDate);
531
+ var year = date.getUTCFullYear();
532
+ var fourthOfJanuaryOfNextYear = new Date(0);
533
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
534
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
535
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
536
+ var fourthOfJanuaryOfThisYear = new Date(0);
537
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
538
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
539
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
540
+ if (date.getTime() >= startOfNextYear.getTime()) {
541
+ return year + 1;
542
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
543
+ return year;
544
+ } else {
545
+ return year - 1;
546
+ }
547
+ }
548
+
549
+ function startOfUTCISOWeekYear(dirtyDate) {
550
+ requiredArgs(1, arguments);
551
+ var year = getUTCISOWeekYear(dirtyDate);
552
+ var fourthOfJanuary = new Date(0);
553
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
554
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
555
+ var date = startOfUTCISOWeek(fourthOfJanuary);
556
+ return date;
557
+ }
558
+
559
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
560
+ function getUTCISOWeek(dirtyDate) {
561
+ requiredArgs(1, arguments);
562
+ var date = toDate(dirtyDate);
563
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
564
+
565
+ // Round the number of days to the nearest integer
566
+ // because the number of milliseconds in a week is not constant
567
+ // (e.g. it's different in the week of the daylight saving time clock shift)
568
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
569
+ }
570
+
571
+ var defaultOptions = {};
572
+ function getDefaultOptions() {
573
+ return defaultOptions;
574
+ }
575
+
576
+ function startOfUTCWeek(dirtyDate, options) {
577
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
578
+ requiredArgs(1, arguments);
579
+ var defaultOptions = getDefaultOptions();
580
+ 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);
581
+
582
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
583
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
584
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
585
+ }
586
+ var date = toDate(dirtyDate);
587
+ var day = date.getUTCDay();
588
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
589
+ date.setUTCDate(date.getUTCDate() - diff);
590
+ date.setUTCHours(0, 0, 0, 0);
591
+ return date;
592
+ }
593
+
594
+ function getUTCWeekYear(dirtyDate, options) {
595
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
596
+ requiredArgs(1, arguments);
597
+ var date = toDate(dirtyDate);
598
+ var year = date.getUTCFullYear();
599
+ var defaultOptions = getDefaultOptions();
600
+ 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);
601
+
602
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
603
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
604
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
605
+ }
606
+ var firstWeekOfNextYear = new Date(0);
607
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
608
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
609
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
610
+ var firstWeekOfThisYear = new Date(0);
611
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
612
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
613
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
614
+ if (date.getTime() >= startOfNextYear.getTime()) {
615
+ return year + 1;
616
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
617
+ return year;
618
+ } else {
619
+ return year - 1;
620
+ }
621
+ }
622
+
623
+ function startOfUTCWeekYear(dirtyDate, options) {
624
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
625
+ requiredArgs(1, arguments);
626
+ var defaultOptions = getDefaultOptions();
627
+ 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);
628
+ var year = getUTCWeekYear(dirtyDate, options);
629
+ var firstWeek = new Date(0);
630
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
631
+ firstWeek.setUTCHours(0, 0, 0, 0);
632
+ var date = startOfUTCWeek(firstWeek, options);
633
+ return date;
634
+ }
635
+
636
+ var MILLISECONDS_IN_WEEK = 604800000;
637
+ function getUTCWeek(dirtyDate, options) {
638
+ requiredArgs(1, arguments);
639
+ var date = toDate(dirtyDate);
640
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
641
+
642
+ // Round the number of days to the nearest integer
643
+ // because the number of milliseconds in a week is not constant
644
+ // (e.g. it's different in the week of the daylight saving time clock shift)
645
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
646
+ }
647
+
648
+ function addLeadingZeros(number, targetLength) {
649
+ var sign = number < 0 ? '-' : '';
650
+ var output = Math.abs(number).toString();
651
+ while (output.length < targetLength) {
652
+ output = '0' + output;
653
+ }
654
+ return sign + output;
655
+ }
656
+
657
+ /*
658
+ * | | Unit | | Unit |
659
+ * |-----|--------------------------------|-----|--------------------------------|
660
+ * | a | AM, PM | A* | |
661
+ * | d | Day of month | D | |
662
+ * | h | Hour [1-12] | H | Hour [0-23] |
663
+ * | m | Minute | M | Month |
664
+ * | s | Second | S | Fraction of second |
665
+ * | y | Year (abs) | Y | |
666
+ *
667
+ * Letters marked by * are not implemented but reserved by Unicode standard.
668
+ */
669
+ var formatters$1 = {
670
+ // Year
671
+ y: function y(date, token) {
672
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
673
+ // | Year | y | yy | yyy | yyyy | yyyyy |
674
+ // |----------|-------|----|-------|-------|-------|
675
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
676
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
677
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
678
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
679
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
680
+
681
+ var signedYear = date.getUTCFullYear();
682
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
683
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
684
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
685
+ },
686
+ // Month
687
+ M: function M(date, token) {
688
+ var month = date.getUTCMonth();
689
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
690
+ },
691
+ // Day of the month
692
+ d: function d(date, token) {
693
+ return addLeadingZeros(date.getUTCDate(), token.length);
694
+ },
695
+ // AM or PM
696
+ a: function a(date, token) {
697
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
698
+ switch (token) {
699
+ case 'a':
700
+ case 'aa':
701
+ return dayPeriodEnumValue.toUpperCase();
702
+ case 'aaa':
703
+ return dayPeriodEnumValue;
704
+ case 'aaaaa':
705
+ return dayPeriodEnumValue[0];
706
+ case 'aaaa':
707
+ default:
708
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
709
+ }
710
+ },
711
+ // Hour [1-12]
712
+ h: function h(date, token) {
713
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
714
+ },
715
+ // Hour [0-23]
716
+ H: function H(date, token) {
717
+ return addLeadingZeros(date.getUTCHours(), token.length);
718
+ },
719
+ // Minute
720
+ m: function m(date, token) {
721
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
722
+ },
723
+ // Second
724
+ s: function s(date, token) {
725
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
726
+ },
727
+ // Fraction of second
728
+ S: function S(date, token) {
729
+ var numberOfDigits = token.length;
730
+ var milliseconds = date.getUTCMilliseconds();
731
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
732
+ return addLeadingZeros(fractionalSeconds, token.length);
733
+ }
734
+ };
735
+
736
+ var dayPeriodEnum = {
737
+ am: 'am',
738
+ pm: 'pm',
739
+ midnight: 'midnight',
740
+ noon: 'noon',
741
+ morning: 'morning',
742
+ afternoon: 'afternoon',
743
+ evening: 'evening',
744
+ night: 'night'
745
+ };
746
+ /*
747
+ * | | Unit | | Unit |
748
+ * |-----|--------------------------------|-----|--------------------------------|
749
+ * | a | AM, PM | A* | Milliseconds in day |
750
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
751
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
752
+ * | d | Day of month | D | Day of year |
753
+ * | e | Local day of week | E | Day of week |
754
+ * | f | | F* | Day of week in month |
755
+ * | g* | Modified Julian day | G | Era |
756
+ * | h | Hour [1-12] | H | Hour [0-23] |
757
+ * | i! | ISO day of week | I! | ISO week of year |
758
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
759
+ * | k | Hour [1-24] | K | Hour [0-11] |
760
+ * | l* | (deprecated) | L | Stand-alone month |
761
+ * | m | Minute | M | Month |
762
+ * | n | | N | |
763
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
764
+ * | p! | Long localized time | P! | Long localized date |
765
+ * | q | Stand-alone quarter | Q | Quarter |
766
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
767
+ * | s | Second | S | Fraction of second |
768
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
769
+ * | u | Extended year | U* | Cyclic year |
770
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
771
+ * | w | Local week of year | W* | Week of month |
772
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
773
+ * | y | Year (abs) | Y | Local week-numbering year |
774
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
775
+ *
776
+ * Letters marked by * are not implemented but reserved by Unicode standard.
777
+ *
778
+ * Letters marked by ! are non-standard, but implemented by date-fns:
779
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
780
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
781
+ * i.e. 7 for Sunday, 1 for Monday, etc.
782
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
783
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
784
+ * `R` is supposed to be used in conjunction with `I` and `i`
785
+ * for universal ISO week-numbering date, whereas
786
+ * `Y` is supposed to be used in conjunction with `w` and `e`
787
+ * for week-numbering date specific to the locale.
788
+ * - `P` is long localized date format
789
+ * - `p` is long localized time format
790
+ */
791
+
792
+ var formatters = {
793
+ // Era
794
+ G: function G(date, token, localize) {
795
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
796
+ switch (token) {
797
+ // AD, BC
798
+ case 'G':
799
+ case 'GG':
800
+ case 'GGG':
801
+ return localize.era(era, {
802
+ width: 'abbreviated'
803
+ });
804
+ // A, B
805
+ case 'GGGGG':
806
+ return localize.era(era, {
807
+ width: 'narrow'
808
+ });
809
+ // Anno Domini, Before Christ
810
+ case 'GGGG':
811
+ default:
812
+ return localize.era(era, {
813
+ width: 'wide'
814
+ });
815
+ }
816
+ },
817
+ // Year
818
+ y: function y(date, token, localize) {
819
+ // Ordinal number
820
+ if (token === 'yo') {
821
+ var signedYear = date.getUTCFullYear();
822
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
823
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
824
+ return localize.ordinalNumber(year, {
825
+ unit: 'year'
826
+ });
827
+ }
828
+ return formatters$1.y(date, token);
829
+ },
830
+ // Local week-numbering year
831
+ Y: function Y(date, token, localize, options) {
832
+ var signedWeekYear = getUTCWeekYear(date, options);
833
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
834
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
835
+
836
+ // Two digit year
837
+ if (token === 'YY') {
838
+ var twoDigitYear = weekYear % 100;
839
+ return addLeadingZeros(twoDigitYear, 2);
840
+ }
841
+
842
+ // Ordinal number
843
+ if (token === 'Yo') {
844
+ return localize.ordinalNumber(weekYear, {
845
+ unit: 'year'
846
+ });
847
+ }
848
+
849
+ // Padding
850
+ return addLeadingZeros(weekYear, token.length);
851
+ },
852
+ // ISO week-numbering year
853
+ R: function R(date, token) {
854
+ var isoWeekYear = getUTCISOWeekYear(date);
855
+
856
+ // Padding
857
+ return addLeadingZeros(isoWeekYear, token.length);
858
+ },
859
+ // Extended year. This is a single number designating the year of this calendar system.
860
+ // The main difference between `y` and `u` localizers are B.C. years:
861
+ // | Year | `y` | `u` |
862
+ // |------|-----|-----|
863
+ // | AC 1 | 1 | 1 |
864
+ // | BC 1 | 1 | 0 |
865
+ // | BC 2 | 2 | -1 |
866
+ // Also `yy` always returns the last two digits of a year,
867
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
868
+ u: function u(date, token) {
869
+ var year = date.getUTCFullYear();
870
+ return addLeadingZeros(year, token.length);
871
+ },
872
+ // Quarter
873
+ Q: function Q(date, token, localize) {
874
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
875
+ switch (token) {
876
+ // 1, 2, 3, 4
877
+ case 'Q':
878
+ return String(quarter);
879
+ // 01, 02, 03, 04
880
+ case 'QQ':
881
+ return addLeadingZeros(quarter, 2);
882
+ // 1st, 2nd, 3rd, 4th
883
+ case 'Qo':
884
+ return localize.ordinalNumber(quarter, {
885
+ unit: 'quarter'
886
+ });
887
+ // Q1, Q2, Q3, Q4
888
+ case 'QQQ':
889
+ return localize.quarter(quarter, {
890
+ width: 'abbreviated',
891
+ context: 'formatting'
892
+ });
893
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
894
+ case 'QQQQQ':
895
+ return localize.quarter(quarter, {
896
+ width: 'narrow',
897
+ context: 'formatting'
898
+ });
899
+ // 1st quarter, 2nd quarter, ...
900
+ case 'QQQQ':
901
+ default:
902
+ return localize.quarter(quarter, {
903
+ width: 'wide',
904
+ context: 'formatting'
905
+ });
906
+ }
907
+ },
908
+ // Stand-alone quarter
909
+ q: function q(date, token, localize) {
910
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
911
+ switch (token) {
912
+ // 1, 2, 3, 4
913
+ case 'q':
914
+ return String(quarter);
915
+ // 01, 02, 03, 04
916
+ case 'qq':
917
+ return addLeadingZeros(quarter, 2);
918
+ // 1st, 2nd, 3rd, 4th
919
+ case 'qo':
920
+ return localize.ordinalNumber(quarter, {
921
+ unit: 'quarter'
922
+ });
923
+ // Q1, Q2, Q3, Q4
924
+ case 'qqq':
925
+ return localize.quarter(quarter, {
926
+ width: 'abbreviated',
927
+ context: 'standalone'
928
+ });
929
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
930
+ case 'qqqqq':
931
+ return localize.quarter(quarter, {
932
+ width: 'narrow',
933
+ context: 'standalone'
934
+ });
935
+ // 1st quarter, 2nd quarter, ...
936
+ case 'qqqq':
937
+ default:
938
+ return localize.quarter(quarter, {
939
+ width: 'wide',
940
+ context: 'standalone'
941
+ });
942
+ }
943
+ },
944
+ // Month
945
+ M: function M(date, token, localize) {
946
+ var month = date.getUTCMonth();
947
+ switch (token) {
948
+ case 'M':
949
+ case 'MM':
950
+ return formatters$1.M(date, token);
951
+ // 1st, 2nd, ..., 12th
952
+ case 'Mo':
953
+ return localize.ordinalNumber(month + 1, {
954
+ unit: 'month'
955
+ });
956
+ // Jan, Feb, ..., Dec
957
+ case 'MMM':
958
+ return localize.month(month, {
959
+ width: 'abbreviated',
960
+ context: 'formatting'
961
+ });
962
+ // J, F, ..., D
963
+ case 'MMMMM':
964
+ return localize.month(month, {
965
+ width: 'narrow',
966
+ context: 'formatting'
967
+ });
968
+ // January, February, ..., December
969
+ case 'MMMM':
970
+ default:
971
+ return localize.month(month, {
972
+ width: 'wide',
973
+ context: 'formatting'
974
+ });
975
+ }
976
+ },
977
+ // Stand-alone month
978
+ L: function L(date, token, localize) {
979
+ var month = date.getUTCMonth();
980
+ switch (token) {
981
+ // 1, 2, ..., 12
982
+ case 'L':
983
+ return String(month + 1);
984
+ // 01, 02, ..., 12
985
+ case 'LL':
986
+ return addLeadingZeros(month + 1, 2);
987
+ // 1st, 2nd, ..., 12th
988
+ case 'Lo':
989
+ return localize.ordinalNumber(month + 1, {
990
+ unit: 'month'
991
+ });
992
+ // Jan, Feb, ..., Dec
993
+ case 'LLL':
994
+ return localize.month(month, {
995
+ width: 'abbreviated',
996
+ context: 'standalone'
997
+ });
998
+ // J, F, ..., D
999
+ case 'LLLLL':
1000
+ return localize.month(month, {
1001
+ width: 'narrow',
1002
+ context: 'standalone'
1003
+ });
1004
+ // January, February, ..., December
1005
+ case 'LLLL':
1006
+ default:
1007
+ return localize.month(month, {
1008
+ width: 'wide',
1009
+ context: 'standalone'
1010
+ });
1011
+ }
1012
+ },
1013
+ // Local week of year
1014
+ w: function w(date, token, localize, options) {
1015
+ var week = getUTCWeek(date, options);
1016
+ if (token === 'wo') {
1017
+ return localize.ordinalNumber(week, {
1018
+ unit: 'week'
1019
+ });
1020
+ }
1021
+ return addLeadingZeros(week, token.length);
1022
+ },
1023
+ // ISO week of year
1024
+ I: function I(date, token, localize) {
1025
+ var isoWeek = getUTCISOWeek(date);
1026
+ if (token === 'Io') {
1027
+ return localize.ordinalNumber(isoWeek, {
1028
+ unit: 'week'
1029
+ });
1030
+ }
1031
+ return addLeadingZeros(isoWeek, token.length);
1032
+ },
1033
+ // Day of the month
1034
+ d: function d(date, token, localize) {
1035
+ if (token === 'do') {
1036
+ return localize.ordinalNumber(date.getUTCDate(), {
1037
+ unit: 'date'
1038
+ });
1039
+ }
1040
+ return formatters$1.d(date, token);
1041
+ },
1042
+ // Day of year
1043
+ D: function D(date, token, localize) {
1044
+ var dayOfYear = getUTCDayOfYear(date);
1045
+ if (token === 'Do') {
1046
+ return localize.ordinalNumber(dayOfYear, {
1047
+ unit: 'dayOfYear'
1048
+ });
1049
+ }
1050
+ return addLeadingZeros(dayOfYear, token.length);
1051
+ },
1052
+ // Day of week
1053
+ E: function E(date, token, localize) {
1054
+ var dayOfWeek = date.getUTCDay();
1055
+ switch (token) {
1056
+ // Tue
1057
+ case 'E':
1058
+ case 'EE':
1059
+ case 'EEE':
1060
+ return localize.day(dayOfWeek, {
1061
+ width: 'abbreviated',
1062
+ context: 'formatting'
1063
+ });
1064
+ // T
1065
+ case 'EEEEE':
1066
+ return localize.day(dayOfWeek, {
1067
+ width: 'narrow',
1068
+ context: 'formatting'
1069
+ });
1070
+ // Tu
1071
+ case 'EEEEEE':
1072
+ return localize.day(dayOfWeek, {
1073
+ width: 'short',
1074
+ context: 'formatting'
1075
+ });
1076
+ // Tuesday
1077
+ case 'EEEE':
1078
+ default:
1079
+ return localize.day(dayOfWeek, {
1080
+ width: 'wide',
1081
+ context: 'formatting'
1082
+ });
1083
+ }
1084
+ },
1085
+ // Local day of week
1086
+ e: function e(date, token, localize, options) {
1087
+ var dayOfWeek = date.getUTCDay();
1088
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1089
+ switch (token) {
1090
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
1091
+ case 'e':
1092
+ return String(localDayOfWeek);
1093
+ // Padded numerical value
1094
+ case 'ee':
1095
+ return addLeadingZeros(localDayOfWeek, 2);
1096
+ // 1st, 2nd, ..., 7th
1097
+ case 'eo':
1098
+ return localize.ordinalNumber(localDayOfWeek, {
1099
+ unit: 'day'
1100
+ });
1101
+ case 'eee':
1102
+ return localize.day(dayOfWeek, {
1103
+ width: 'abbreviated',
1104
+ context: 'formatting'
1105
+ });
1106
+ // T
1107
+ case 'eeeee':
1108
+ return localize.day(dayOfWeek, {
1109
+ width: 'narrow',
1110
+ context: 'formatting'
1111
+ });
1112
+ // Tu
1113
+ case 'eeeeee':
1114
+ return localize.day(dayOfWeek, {
1115
+ width: 'short',
1116
+ context: 'formatting'
1117
+ });
1118
+ // Tuesday
1119
+ case 'eeee':
1120
+ default:
1121
+ return localize.day(dayOfWeek, {
1122
+ width: 'wide',
1123
+ context: 'formatting'
1124
+ });
1125
+ }
1126
+ },
1127
+ // Stand-alone local day of week
1128
+ c: function c(date, token, localize, options) {
1129
+ var dayOfWeek = date.getUTCDay();
1130
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1131
+ switch (token) {
1132
+ // Numerical value (same as in `e`)
1133
+ case 'c':
1134
+ return String(localDayOfWeek);
1135
+ // Padded numerical value
1136
+ case 'cc':
1137
+ return addLeadingZeros(localDayOfWeek, token.length);
1138
+ // 1st, 2nd, ..., 7th
1139
+ case 'co':
1140
+ return localize.ordinalNumber(localDayOfWeek, {
1141
+ unit: 'day'
1142
+ });
1143
+ case 'ccc':
1144
+ return localize.day(dayOfWeek, {
1145
+ width: 'abbreviated',
1146
+ context: 'standalone'
1147
+ });
1148
+ // T
1149
+ case 'ccccc':
1150
+ return localize.day(dayOfWeek, {
1151
+ width: 'narrow',
1152
+ context: 'standalone'
1153
+ });
1154
+ // Tu
1155
+ case 'cccccc':
1156
+ return localize.day(dayOfWeek, {
1157
+ width: 'short',
1158
+ context: 'standalone'
1159
+ });
1160
+ // Tuesday
1161
+ case 'cccc':
1162
+ default:
1163
+ return localize.day(dayOfWeek, {
1164
+ width: 'wide',
1165
+ context: 'standalone'
1166
+ });
1167
+ }
1168
+ },
1169
+ // ISO day of week
1170
+ i: function i(date, token, localize) {
1171
+ var dayOfWeek = date.getUTCDay();
1172
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1173
+ switch (token) {
1174
+ // 2
1175
+ case 'i':
1176
+ return String(isoDayOfWeek);
1177
+ // 02
1178
+ case 'ii':
1179
+ return addLeadingZeros(isoDayOfWeek, token.length);
1180
+ // 2nd
1181
+ case 'io':
1182
+ return localize.ordinalNumber(isoDayOfWeek, {
1183
+ unit: 'day'
1184
+ });
1185
+ // Tue
1186
+ case 'iii':
1187
+ return localize.day(dayOfWeek, {
1188
+ width: 'abbreviated',
1189
+ context: 'formatting'
1190
+ });
1191
+ // T
1192
+ case 'iiiii':
1193
+ return localize.day(dayOfWeek, {
1194
+ width: 'narrow',
1195
+ context: 'formatting'
1196
+ });
1197
+ // Tu
1198
+ case 'iiiiii':
1199
+ return localize.day(dayOfWeek, {
1200
+ width: 'short',
1201
+ context: 'formatting'
1202
+ });
1203
+ // Tuesday
1204
+ case 'iiii':
1205
+ default:
1206
+ return localize.day(dayOfWeek, {
1207
+ width: 'wide',
1208
+ context: 'formatting'
1209
+ });
1210
+ }
1211
+ },
1212
+ // AM or PM
1213
+ a: function a(date, token, localize) {
1214
+ var hours = date.getUTCHours();
1215
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1216
+ switch (token) {
1217
+ case 'a':
1218
+ case 'aa':
1219
+ return localize.dayPeriod(dayPeriodEnumValue, {
1220
+ width: 'abbreviated',
1221
+ context: 'formatting'
1222
+ });
1223
+ case 'aaa':
1224
+ return localize.dayPeriod(dayPeriodEnumValue, {
1225
+ width: 'abbreviated',
1226
+ context: 'formatting'
1227
+ }).toLowerCase();
1228
+ case 'aaaaa':
1229
+ return localize.dayPeriod(dayPeriodEnumValue, {
1230
+ width: 'narrow',
1231
+ context: 'formatting'
1232
+ });
1233
+ case 'aaaa':
1234
+ default:
1235
+ return localize.dayPeriod(dayPeriodEnumValue, {
1236
+ width: 'wide',
1237
+ context: 'formatting'
1238
+ });
1239
+ }
1240
+ },
1241
+ // AM, PM, midnight, noon
1242
+ b: function b(date, token, localize) {
1243
+ var hours = date.getUTCHours();
1244
+ var dayPeriodEnumValue;
1245
+ if (hours === 12) {
1246
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1247
+ } else if (hours === 0) {
1248
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1249
+ } else {
1250
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1251
+ }
1252
+ switch (token) {
1253
+ case 'b':
1254
+ case 'bb':
1255
+ return localize.dayPeriod(dayPeriodEnumValue, {
1256
+ width: 'abbreviated',
1257
+ context: 'formatting'
1258
+ });
1259
+ case 'bbb':
1260
+ return localize.dayPeriod(dayPeriodEnumValue, {
1261
+ width: 'abbreviated',
1262
+ context: 'formatting'
1263
+ }).toLowerCase();
1264
+ case 'bbbbb':
1265
+ return localize.dayPeriod(dayPeriodEnumValue, {
1266
+ width: 'narrow',
1267
+ context: 'formatting'
1268
+ });
1269
+ case 'bbbb':
1270
+ default:
1271
+ return localize.dayPeriod(dayPeriodEnumValue, {
1272
+ width: 'wide',
1273
+ context: 'formatting'
1274
+ });
1275
+ }
1276
+ },
1277
+ // in the morning, in the afternoon, in the evening, at night
1278
+ B: function B(date, token, localize) {
1279
+ var hours = date.getUTCHours();
1280
+ var dayPeriodEnumValue;
1281
+ if (hours >= 17) {
1282
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1283
+ } else if (hours >= 12) {
1284
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1285
+ } else if (hours >= 4) {
1286
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1287
+ } else {
1288
+ dayPeriodEnumValue = dayPeriodEnum.night;
1289
+ }
1290
+ switch (token) {
1291
+ case 'B':
1292
+ case 'BB':
1293
+ case 'BBB':
1294
+ return localize.dayPeriod(dayPeriodEnumValue, {
1295
+ width: 'abbreviated',
1296
+ context: 'formatting'
1297
+ });
1298
+ case 'BBBBB':
1299
+ return localize.dayPeriod(dayPeriodEnumValue, {
1300
+ width: 'narrow',
1301
+ context: 'formatting'
1302
+ });
1303
+ case 'BBBB':
1304
+ default:
1305
+ return localize.dayPeriod(dayPeriodEnumValue, {
1306
+ width: 'wide',
1307
+ context: 'formatting'
1308
+ });
1309
+ }
1310
+ },
1311
+ // Hour [1-12]
1312
+ h: function h(date, token, localize) {
1313
+ if (token === 'ho') {
1314
+ var hours = date.getUTCHours() % 12;
1315
+ if (hours === 0) hours = 12;
1316
+ return localize.ordinalNumber(hours, {
1317
+ unit: 'hour'
1318
+ });
1319
+ }
1320
+ return formatters$1.h(date, token);
1321
+ },
1322
+ // Hour [0-23]
1323
+ H: function H(date, token, localize) {
1324
+ if (token === 'Ho') {
1325
+ return localize.ordinalNumber(date.getUTCHours(), {
1326
+ unit: 'hour'
1327
+ });
1328
+ }
1329
+ return formatters$1.H(date, token);
1330
+ },
1331
+ // Hour [0-11]
1332
+ K: function K(date, token, localize) {
1333
+ var hours = date.getUTCHours() % 12;
1334
+ if (token === 'Ko') {
1335
+ return localize.ordinalNumber(hours, {
1336
+ unit: 'hour'
1337
+ });
1338
+ }
1339
+ return addLeadingZeros(hours, token.length);
1340
+ },
1341
+ // Hour [1-24]
1342
+ k: function k(date, token, localize) {
1343
+ var hours = date.getUTCHours();
1344
+ if (hours === 0) hours = 24;
1345
+ if (token === 'ko') {
1346
+ return localize.ordinalNumber(hours, {
1347
+ unit: 'hour'
1348
+ });
1349
+ }
1350
+ return addLeadingZeros(hours, token.length);
1351
+ },
1352
+ // Minute
1353
+ m: function m(date, token, localize) {
1354
+ if (token === 'mo') {
1355
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1356
+ unit: 'minute'
1357
+ });
1358
+ }
1359
+ return formatters$1.m(date, token);
1360
+ },
1361
+ // Second
1362
+ s: function s(date, token, localize) {
1363
+ if (token === 'so') {
1364
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1365
+ unit: 'second'
1366
+ });
1367
+ }
1368
+ return formatters$1.s(date, token);
1369
+ },
1370
+ // Fraction of second
1371
+ S: function S(date, token) {
1372
+ return formatters$1.S(date, token);
1373
+ },
1374
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1375
+ X: function X(date, token, _localize, options) {
1376
+ var originalDate = options._originalDate || date;
1377
+ var timezoneOffset = originalDate.getTimezoneOffset();
1378
+ if (timezoneOffset === 0) {
1379
+ return 'Z';
1380
+ }
1381
+ switch (token) {
1382
+ // Hours and optional minutes
1383
+ case 'X':
1384
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1385
+
1386
+ // Hours, minutes and optional seconds without `:` delimiter
1387
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1388
+ // so this token always has the same output as `XX`
1389
+ case 'XXXX':
1390
+ case 'XX':
1391
+ // Hours and minutes without `:` delimiter
1392
+ return formatTimezone(timezoneOffset);
1393
+
1394
+ // Hours, minutes and optional seconds with `:` delimiter
1395
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1396
+ // so this token always has the same output as `XXX`
1397
+ case 'XXXXX':
1398
+ case 'XXX': // Hours and minutes with `:` delimiter
1399
+ default:
1400
+ return formatTimezone(timezoneOffset, ':');
1401
+ }
1402
+ },
1403
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1404
+ x: function x(date, token, _localize, options) {
1405
+ var originalDate = options._originalDate || date;
1406
+ var timezoneOffset = originalDate.getTimezoneOffset();
1407
+ switch (token) {
1408
+ // Hours and optional minutes
1409
+ case 'x':
1410
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1411
+
1412
+ // Hours, minutes and optional seconds without `:` delimiter
1413
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1414
+ // so this token always has the same output as `xx`
1415
+ case 'xxxx':
1416
+ case 'xx':
1417
+ // Hours and minutes without `:` delimiter
1418
+ return formatTimezone(timezoneOffset);
1419
+
1420
+ // Hours, minutes and optional seconds with `:` delimiter
1421
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1422
+ // so this token always has the same output as `xxx`
1423
+ case 'xxxxx':
1424
+ case 'xxx': // Hours and minutes with `:` delimiter
1425
+ default:
1426
+ return formatTimezone(timezoneOffset, ':');
1427
+ }
1428
+ },
1429
+ // Timezone (GMT)
1430
+ O: function O(date, token, _localize, options) {
1431
+ var originalDate = options._originalDate || date;
1432
+ var timezoneOffset = originalDate.getTimezoneOffset();
1433
+ switch (token) {
1434
+ // Short
1435
+ case 'O':
1436
+ case 'OO':
1437
+ case 'OOO':
1438
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1439
+ // Long
1440
+ case 'OOOO':
1441
+ default:
1442
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1443
+ }
1444
+ },
1445
+ // Timezone (specific non-location)
1446
+ z: function z(date, token, _localize, options) {
1447
+ var originalDate = options._originalDate || date;
1448
+ var timezoneOffset = originalDate.getTimezoneOffset();
1449
+ switch (token) {
1450
+ // Short
1451
+ case 'z':
1452
+ case 'zz':
1453
+ case 'zzz':
1454
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1455
+ // Long
1456
+ case 'zzzz':
1457
+ default:
1458
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1459
+ }
1460
+ },
1461
+ // Seconds timestamp
1462
+ t: function t(date, token, _localize, options) {
1463
+ var originalDate = options._originalDate || date;
1464
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1465
+ return addLeadingZeros(timestamp, token.length);
1466
+ },
1467
+ // Milliseconds timestamp
1468
+ T: function T(date, token, _localize, options) {
1469
+ var originalDate = options._originalDate || date;
1470
+ var timestamp = originalDate.getTime();
1471
+ return addLeadingZeros(timestamp, token.length);
1472
+ }
1473
+ };
1474
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1475
+ var sign = offset > 0 ? '-' : '+';
1476
+ var absOffset = Math.abs(offset);
1477
+ var hours = Math.floor(absOffset / 60);
1478
+ var minutes = absOffset % 60;
1479
+ if (minutes === 0) {
1480
+ return sign + String(hours);
1481
+ }
1482
+ var delimiter = dirtyDelimiter || '';
1483
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1484
+ }
1485
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1486
+ if (offset % 60 === 0) {
1487
+ var sign = offset > 0 ? '-' : '+';
1488
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1489
+ }
1490
+ return formatTimezone(offset, dirtyDelimiter);
1491
+ }
1492
+ function formatTimezone(offset, dirtyDelimiter) {
1493
+ var delimiter = dirtyDelimiter || '';
1494
+ var sign = offset > 0 ? '-' : '+';
1495
+ var absOffset = Math.abs(offset);
1496
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1497
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1498
+ return sign + hours + delimiter + minutes;
1499
+ }
1500
+
1501
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1502
+ switch (pattern) {
1503
+ case 'P':
1504
+ return formatLong.date({
1505
+ width: 'short'
1506
+ });
1507
+ case 'PP':
1508
+ return formatLong.date({
1509
+ width: 'medium'
1510
+ });
1511
+ case 'PPP':
1512
+ return formatLong.date({
1513
+ width: 'long'
1514
+ });
1515
+ case 'PPPP':
1516
+ default:
1517
+ return formatLong.date({
1518
+ width: 'full'
1519
+ });
1520
+ }
1521
+ };
1522
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1523
+ switch (pattern) {
1524
+ case 'p':
1525
+ return formatLong.time({
1526
+ width: 'short'
1527
+ });
1528
+ case 'pp':
1529
+ return formatLong.time({
1530
+ width: 'medium'
1531
+ });
1532
+ case 'ppp':
1533
+ return formatLong.time({
1534
+ width: 'long'
1535
+ });
1536
+ case 'pppp':
1537
+ default:
1538
+ return formatLong.time({
1539
+ width: 'full'
1540
+ });
1541
+ }
1542
+ };
1543
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1544
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1545
+ var datePattern = matchResult[1];
1546
+ var timePattern = matchResult[2];
1547
+ if (!timePattern) {
1548
+ return dateLongFormatter(pattern, formatLong);
1549
+ }
1550
+ var dateTimeFormat;
1551
+ switch (datePattern) {
1552
+ case 'P':
1553
+ dateTimeFormat = formatLong.dateTime({
1554
+ width: 'short'
1555
+ });
1556
+ break;
1557
+ case 'PP':
1558
+ dateTimeFormat = formatLong.dateTime({
1559
+ width: 'medium'
1560
+ });
1561
+ break;
1562
+ case 'PPP':
1563
+ dateTimeFormat = formatLong.dateTime({
1564
+ width: 'long'
1565
+ });
1566
+ break;
1567
+ case 'PPPP':
1568
+ default:
1569
+ dateTimeFormat = formatLong.dateTime({
1570
+ width: 'full'
1571
+ });
1572
+ break;
1573
+ }
1574
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1575
+ };
1576
+ var longFormatters = {
1577
+ p: timeLongFormatter,
1578
+ P: dateTimeLongFormatter
1579
+ };
1580
+
1581
+ /**
1582
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
1583
+ * They usually appear for dates that denote time before the timezones were introduced
1584
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
1585
+ * and GMT+01:00:00 after that date)
1586
+ *
1587
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
1588
+ * which would lead to incorrect calculations.
1589
+ *
1590
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
1591
+ */
1592
+ function getTimezoneOffsetInMilliseconds(date) {
1593
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
1594
+ utcDate.setUTCFullYear(date.getFullYear());
1595
+ return date.getTime() - utcDate.getTime();
1596
+ }
1597
+
1598
+ var protectedDayOfYearTokens = ['D', 'DD'];
1599
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1600
+ function isProtectedDayOfYearToken(token) {
1601
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1602
+ }
1603
+ function isProtectedWeekYearToken(token) {
1604
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1605
+ }
1606
+ function throwProtectedError(token, format, input) {
1607
+ if (token === 'YYYY') {
1608
+ 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"));
1609
+ } else if (token === 'YY') {
1610
+ 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"));
1611
+ } else if (token === 'D') {
1612
+ 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"));
1613
+ } else if (token === 'DD') {
1614
+ 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"));
1615
+ }
1616
+ }
1617
+
1618
+ var formatDistanceLocale = {
1619
+ lessThanXSeconds: {
1620
+ one: 'less than a second',
1621
+ other: 'less than {{count}} seconds'
1622
+ },
1623
+ xSeconds: {
1624
+ one: '1 second',
1625
+ other: '{{count}} seconds'
1626
+ },
1627
+ halfAMinute: 'half a minute',
1628
+ lessThanXMinutes: {
1629
+ one: 'less than a minute',
1630
+ other: 'less than {{count}} minutes'
1631
+ },
1632
+ xMinutes: {
1633
+ one: '1 minute',
1634
+ other: '{{count}} minutes'
1635
+ },
1636
+ aboutXHours: {
1637
+ one: 'about 1 hour',
1638
+ other: 'about {{count}} hours'
1639
+ },
1640
+ xHours: {
1641
+ one: '1 hour',
1642
+ other: '{{count}} hours'
1643
+ },
1644
+ xDays: {
1645
+ one: '1 day',
1646
+ other: '{{count}} days'
1647
+ },
1648
+ aboutXWeeks: {
1649
+ one: 'about 1 week',
1650
+ other: 'about {{count}} weeks'
1651
+ },
1652
+ xWeeks: {
1653
+ one: '1 week',
1654
+ other: '{{count}} weeks'
1655
+ },
1656
+ aboutXMonths: {
1657
+ one: 'about 1 month',
1658
+ other: 'about {{count}} months'
1659
+ },
1660
+ xMonths: {
1661
+ one: '1 month',
1662
+ other: '{{count}} months'
1663
+ },
1664
+ aboutXYears: {
1665
+ one: 'about 1 year',
1666
+ other: 'about {{count}} years'
1667
+ },
1668
+ xYears: {
1669
+ one: '1 year',
1670
+ other: '{{count}} years'
1671
+ },
1672
+ overXYears: {
1673
+ one: 'over 1 year',
1674
+ other: 'over {{count}} years'
1675
+ },
1676
+ almostXYears: {
1677
+ one: 'almost 1 year',
1678
+ other: 'almost {{count}} years'
1679
+ }
1680
+ };
1681
+ var formatDistance = function formatDistance(token, count, options) {
1682
+ var result;
1683
+ var tokenValue = formatDistanceLocale[token];
1684
+ if (typeof tokenValue === 'string') {
1685
+ result = tokenValue;
1686
+ } else if (count === 1) {
1687
+ result = tokenValue.one;
1688
+ } else {
1689
+ result = tokenValue.other.replace('{{count}}', count.toString());
1690
+ }
1691
+ if (options !== null && options !== void 0 && options.addSuffix) {
1692
+ if (options.comparison && options.comparison > 0) {
1693
+ return 'in ' + result;
1694
+ } else {
1695
+ return result + ' ago';
1696
+ }
1697
+ }
1698
+ return result;
1699
+ };
1700
+
1701
+ function buildFormatLongFn(args) {
1702
+ return function () {
1703
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1704
+ // TODO: Remove String()
1705
+ var width = options.width ? String(options.width) : args.defaultWidth;
1706
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1707
+ return format;
1708
+ };
1709
+ }
1710
+
1711
+ var dateFormats = {
1712
+ full: 'EEEE, MMMM do, y',
1713
+ long: 'MMMM do, y',
1714
+ medium: 'MMM d, y',
1715
+ short: 'MM/dd/yyyy'
1716
+ };
1717
+ var timeFormats = {
1718
+ full: 'h:mm:ss a zzzz',
1719
+ long: 'h:mm:ss a z',
1720
+ medium: 'h:mm:ss a',
1721
+ short: 'h:mm a'
1722
+ };
1723
+ var dateTimeFormats = {
1724
+ full: "{{date}} 'at' {{time}}",
1725
+ long: "{{date}} 'at' {{time}}",
1726
+ medium: '{{date}}, {{time}}',
1727
+ short: '{{date}}, {{time}}'
1728
+ };
1729
+ var formatLong = {
1730
+ date: buildFormatLongFn({
1731
+ formats: dateFormats,
1732
+ defaultWidth: 'full'
1733
+ }),
1734
+ time: buildFormatLongFn({
1735
+ formats: timeFormats,
1736
+ defaultWidth: 'full'
1737
+ }),
1738
+ dateTime: buildFormatLongFn({
1739
+ formats: dateTimeFormats,
1740
+ defaultWidth: 'full'
1741
+ })
1742
+ };
1743
+
1744
+ var formatRelativeLocale = {
1745
+ lastWeek: "'last' eeee 'at' p",
1746
+ yesterday: "'yesterday at' p",
1747
+ today: "'today at' p",
1748
+ tomorrow: "'tomorrow at' p",
1749
+ nextWeek: "eeee 'at' p",
1750
+ other: 'P'
1751
+ };
1752
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1753
+ return formatRelativeLocale[token];
1754
+ };
1755
+
1756
+ function buildLocalizeFn(args) {
1757
+ return function (dirtyIndex, options) {
1758
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1759
+ var valuesArray;
1760
+ if (context === 'formatting' && args.formattingValues) {
1761
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1762
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1763
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1764
+ } else {
1765
+ var _defaultWidth = args.defaultWidth;
1766
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1767
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1768
+ }
1769
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1770
+ // @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!
1771
+ return valuesArray[index];
1772
+ };
1773
+ }
1774
+
1775
+ var eraValues = {
1776
+ narrow: ['B', 'A'],
1777
+ abbreviated: ['BC', 'AD'],
1778
+ wide: ['Before Christ', 'Anno Domini']
1779
+ };
1780
+ var quarterValues = {
1781
+ narrow: ['1', '2', '3', '4'],
1782
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1783
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1784
+ };
1785
+
1786
+ // Note: in English, the names of days of the week and months are capitalized.
1787
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1788
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1789
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1790
+ var monthValues = {
1791
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1792
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1793
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1794
+ };
1795
+ var dayValues = {
1796
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1797
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1798
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1799
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1800
+ };
1801
+ var dayPeriodValues = {
1802
+ narrow: {
1803
+ am: 'a',
1804
+ pm: 'p',
1805
+ midnight: 'mi',
1806
+ noon: 'n',
1807
+ morning: 'morning',
1808
+ afternoon: 'afternoon',
1809
+ evening: 'evening',
1810
+ night: 'night'
1811
+ },
1812
+ abbreviated: {
1813
+ am: 'AM',
1814
+ pm: 'PM',
1815
+ midnight: 'midnight',
1816
+ noon: 'noon',
1817
+ morning: 'morning',
1818
+ afternoon: 'afternoon',
1819
+ evening: 'evening',
1820
+ night: 'night'
1821
+ },
1822
+ wide: {
1823
+ am: 'a.m.',
1824
+ pm: 'p.m.',
1825
+ midnight: 'midnight',
1826
+ noon: 'noon',
1827
+ morning: 'morning',
1828
+ afternoon: 'afternoon',
1829
+ evening: 'evening',
1830
+ night: 'night'
1831
+ }
1832
+ };
1833
+ var formattingDayPeriodValues = {
1834
+ narrow: {
1835
+ am: 'a',
1836
+ pm: 'p',
1837
+ midnight: 'mi',
1838
+ noon: 'n',
1839
+ morning: 'in the morning',
1840
+ afternoon: 'in the afternoon',
1841
+ evening: 'in the evening',
1842
+ night: 'at night'
1843
+ },
1844
+ abbreviated: {
1845
+ am: 'AM',
1846
+ pm: 'PM',
1847
+ midnight: 'midnight',
1848
+ noon: 'noon',
1849
+ morning: 'in the morning',
1850
+ afternoon: 'in the afternoon',
1851
+ evening: 'in the evening',
1852
+ night: 'at night'
1853
+ },
1854
+ wide: {
1855
+ am: 'a.m.',
1856
+ pm: 'p.m.',
1857
+ midnight: 'midnight',
1858
+ noon: 'noon',
1859
+ morning: 'in the morning',
1860
+ afternoon: 'in the afternoon',
1861
+ evening: 'in the evening',
1862
+ night: 'at night'
1863
+ }
1864
+ };
1865
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1866
+ var number = Number(dirtyNumber);
1867
+
1868
+ // If ordinal numbers depend on context, for example,
1869
+ // if they are different for different grammatical genders,
1870
+ // use `options.unit`.
1871
+ //
1872
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1873
+ // 'day', 'hour', 'minute', 'second'.
1874
+
1875
+ var rem100 = number % 100;
1876
+ if (rem100 > 20 || rem100 < 10) {
1877
+ switch (rem100 % 10) {
1878
+ case 1:
1879
+ return number + 'st';
1880
+ case 2:
1881
+ return number + 'nd';
1882
+ case 3:
1883
+ return number + 'rd';
1884
+ }
1885
+ }
1886
+ return number + 'th';
1887
+ };
1888
+ var localize = {
1889
+ ordinalNumber: ordinalNumber,
1890
+ era: buildLocalizeFn({
1891
+ values: eraValues,
1892
+ defaultWidth: 'wide'
1893
+ }),
1894
+ quarter: buildLocalizeFn({
1895
+ values: quarterValues,
1896
+ defaultWidth: 'wide',
1897
+ argumentCallback: function argumentCallback(quarter) {
1898
+ return quarter - 1;
1899
+ }
1900
+ }),
1901
+ month: buildLocalizeFn({
1902
+ values: monthValues,
1903
+ defaultWidth: 'wide'
1904
+ }),
1905
+ day: buildLocalizeFn({
1906
+ values: dayValues,
1907
+ defaultWidth: 'wide'
1908
+ }),
1909
+ dayPeriod: buildLocalizeFn({
1910
+ values: dayPeriodValues,
1911
+ defaultWidth: 'wide',
1912
+ formattingValues: formattingDayPeriodValues,
1913
+ defaultFormattingWidth: 'wide'
1914
+ })
1915
+ };
1916
+
1917
+ function buildMatchFn(args) {
1918
+ return function (string) {
1919
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1920
+ var width = options.width;
1921
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1922
+ var matchResult = string.match(matchPattern);
1923
+ if (!matchResult) {
1924
+ return null;
1925
+ }
1926
+ var matchedString = matchResult[0];
1927
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1928
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1929
+ return pattern.test(matchedString);
1930
+ }) : findKey(parsePatterns, function (pattern) {
1931
+ return pattern.test(matchedString);
1932
+ });
1933
+ var value;
1934
+ value = args.valueCallback ? args.valueCallback(key) : key;
1935
+ value = options.valueCallback ? options.valueCallback(value) : value;
1936
+ var rest = string.slice(matchedString.length);
1937
+ return {
1938
+ value: value,
1939
+ rest: rest
1940
+ };
1941
+ };
1942
+ }
1943
+ function findKey(object, predicate) {
1944
+ for (var key in object) {
1945
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1946
+ return key;
1947
+ }
1948
+ }
1949
+ return undefined;
1950
+ }
1951
+ function findIndex(array, predicate) {
1952
+ for (var key = 0; key < array.length; key++) {
1953
+ if (predicate(array[key])) {
1954
+ return key;
1955
+ }
1956
+ }
1957
+ return undefined;
1958
+ }
1959
+
1960
+ function buildMatchPatternFn(args) {
1961
+ return function (string) {
1962
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1963
+ var matchResult = string.match(args.matchPattern);
1964
+ if (!matchResult) return null;
1965
+ var matchedString = matchResult[0];
1966
+ var parseResult = string.match(args.parsePattern);
1967
+ if (!parseResult) return null;
1968
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1969
+ value = options.valueCallback ? options.valueCallback(value) : value;
1970
+ var rest = string.slice(matchedString.length);
1971
+ return {
1972
+ value: value,
1973
+ rest: rest
1974
+ };
1975
+ };
1976
+ }
1977
+
1978
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1979
+ var parseOrdinalNumberPattern = /\d+/i;
1980
+ var matchEraPatterns = {
1981
+ narrow: /^(b|a)/i,
1982
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1983
+ wide: /^(before christ|before common era|anno domini|common era)/i
1984
+ };
1985
+ var parseEraPatterns = {
1986
+ any: [/^b/i, /^(a|c)/i]
1987
+ };
1988
+ var matchQuarterPatterns = {
1989
+ narrow: /^[1234]/i,
1990
+ abbreviated: /^q[1234]/i,
1991
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1992
+ };
1993
+ var parseQuarterPatterns = {
1994
+ any: [/1/i, /2/i, /3/i, /4/i]
1995
+ };
1996
+ var matchMonthPatterns = {
1997
+ narrow: /^[jfmasond]/i,
1998
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1999
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
2000
+ };
2001
+ var parseMonthPatterns = {
2002
+ 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],
2003
+ 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]
2004
+ };
2005
+ var matchDayPatterns = {
2006
+ narrow: /^[smtwf]/i,
2007
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
2008
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2009
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2010
+ };
2011
+ var parseDayPatterns = {
2012
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2013
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2014
+ };
2015
+ var matchDayPeriodPatterns = {
2016
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2017
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
2018
+ };
2019
+ var parseDayPeriodPatterns = {
2020
+ any: {
2021
+ am: /^a/i,
2022
+ pm: /^p/i,
2023
+ midnight: /^mi/i,
2024
+ noon: /^no/i,
2025
+ morning: /morning/i,
2026
+ afternoon: /afternoon/i,
2027
+ evening: /evening/i,
2028
+ night: /night/i
2029
+ }
2030
+ };
2031
+ var match = {
2032
+ ordinalNumber: buildMatchPatternFn({
2033
+ matchPattern: matchOrdinalNumberPattern,
2034
+ parsePattern: parseOrdinalNumberPattern,
2035
+ valueCallback: function valueCallback(value) {
2036
+ return parseInt(value, 10);
2037
+ }
2038
+ }),
2039
+ era: buildMatchFn({
2040
+ matchPatterns: matchEraPatterns,
2041
+ defaultMatchWidth: 'wide',
2042
+ parsePatterns: parseEraPatterns,
2043
+ defaultParseWidth: 'any'
2044
+ }),
2045
+ quarter: buildMatchFn({
2046
+ matchPatterns: matchQuarterPatterns,
2047
+ defaultMatchWidth: 'wide',
2048
+ parsePatterns: parseQuarterPatterns,
2049
+ defaultParseWidth: 'any',
2050
+ valueCallback: function valueCallback(index) {
2051
+ return index + 1;
2052
+ }
2053
+ }),
2054
+ month: buildMatchFn({
2055
+ matchPatterns: matchMonthPatterns,
2056
+ defaultMatchWidth: 'wide',
2057
+ parsePatterns: parseMonthPatterns,
2058
+ defaultParseWidth: 'any'
2059
+ }),
2060
+ day: buildMatchFn({
2061
+ matchPatterns: matchDayPatterns,
2062
+ defaultMatchWidth: 'wide',
2063
+ parsePatterns: parseDayPatterns,
2064
+ defaultParseWidth: 'any'
2065
+ }),
2066
+ dayPeriod: buildMatchFn({
2067
+ matchPatterns: matchDayPeriodPatterns,
2068
+ defaultMatchWidth: 'any',
2069
+ parsePatterns: parseDayPeriodPatterns,
2070
+ defaultParseWidth: 'any'
2071
+ })
2072
+ };
2073
+
2074
+ /**
2075
+ * @type {Locale}
2076
+ * @category Locales
2077
+ * @summary English locale (United States).
2078
+ * @language English
2079
+ * @iso-639-2 eng
2080
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
2081
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
2082
+ */
2083
+ var locale = {
2084
+ code: 'en-US',
2085
+ formatDistance: formatDistance,
2086
+ formatLong: formatLong,
2087
+ formatRelative: formatRelative,
2088
+ localize: localize,
2089
+ match: match,
2090
+ options: {
2091
+ weekStartsOn: 0 /* Sunday */,
2092
+ firstWeekContainsDate: 1
2093
+ }
2094
+ };
2095
+
2096
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2097
+ // (one of the certain letters followed by `o`)
2098
+ // - (\w)\1* matches any sequences of the same letter
2099
+ // - '' matches two quote characters in a row
2100
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2101
+ // except a single quote symbol, which ends the sequence.
2102
+ // Two quote characters do not end the sequence.
2103
+ // If there is no matching single quote
2104
+ // then the sequence will continue until the end of the string.
2105
+ // - . matches any single character unmatched by previous parts of the RegExps
2106
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2107
+
2108
+ // This RegExp catches symbols escaped by quotes, and also
2109
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2110
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2111
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2112
+ var doubleQuoteRegExp = /''/g;
2113
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2114
+
2115
+ /**
2116
+ * @name format
2117
+ * @category Common Helpers
2118
+ * @summary Format the date.
2119
+ *
2120
+ * @description
2121
+ * Return the formatted date string in the given format. The result may vary by locale.
2122
+ *
2123
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2124
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2125
+ *
2126
+ * The characters wrapped between two single quotes characters (') are escaped.
2127
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2128
+ * (see the last example)
2129
+ *
2130
+ * Format of the string is based on Unicode Technical Standard #35:
2131
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2132
+ * with a few additions (see note 7 below the table).
2133
+ *
2134
+ * Accepted patterns:
2135
+ * | Unit | Pattern | Result examples | Notes |
2136
+ * |---------------------------------|---------|-----------------------------------|-------|
2137
+ * | Era | G..GGG | AD, BC | |
2138
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2139
+ * | | GGGGG | A, B | |
2140
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2141
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2142
+ * | | yy | 44, 01, 00, 17 | 5 |
2143
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2144
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2145
+ * | | yyyyy | ... | 3,5 |
2146
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2147
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2148
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2149
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2150
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2151
+ * | | YYYYY | ... | 3,5 |
2152
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2153
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2154
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2155
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2156
+ * | | RRRRR | ... | 3,5,7 |
2157
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2158
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2159
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2160
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2161
+ * | | uuuuu | ... | 3,5 |
2162
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2163
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2164
+ * | | QQ | 01, 02, 03, 04 | |
2165
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2166
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2167
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2168
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2169
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2170
+ * | | qq | 01, 02, 03, 04 | |
2171
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2172
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2173
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2174
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2175
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2176
+ * | | MM | 01, 02, ..., 12 | |
2177
+ * | | MMM | Jan, Feb, ..., Dec | |
2178
+ * | | MMMM | January, February, ..., December | 2 |
2179
+ * | | MMMMM | J, F, ..., D | |
2180
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2181
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2182
+ * | | LL | 01, 02, ..., 12 | |
2183
+ * | | LLL | Jan, Feb, ..., Dec | |
2184
+ * | | LLLL | January, February, ..., December | 2 |
2185
+ * | | LLLLL | J, F, ..., D | |
2186
+ * | Local week of year | w | 1, 2, ..., 53 | |
2187
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2188
+ * | | ww | 01, 02, ..., 53 | |
2189
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2190
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2191
+ * | | II | 01, 02, ..., 53 | 7 |
2192
+ * | Day of month | d | 1, 2, ..., 31 | |
2193
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2194
+ * | | dd | 01, 02, ..., 31 | |
2195
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2196
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2197
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2198
+ * | | DDD | 001, 002, ..., 365, 366 | |
2199
+ * | | DDDD | ... | 3 |
2200
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2201
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2202
+ * | | EEEEE | M, T, W, T, F, S, S | |
2203
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2204
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2205
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2206
+ * | | ii | 01, 02, ..., 07 | 7 |
2207
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2208
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2209
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2210
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2211
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2212
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2213
+ * | | ee | 02, 03, ..., 01 | |
2214
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2215
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2216
+ * | | eeeee | M, T, W, T, F, S, S | |
2217
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2218
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2219
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2220
+ * | | cc | 02, 03, ..., 01 | |
2221
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2222
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2223
+ * | | ccccc | M, T, W, T, F, S, S | |
2224
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2225
+ * | AM, PM | a..aa | AM, PM | |
2226
+ * | | aaa | am, pm | |
2227
+ * | | aaaa | a.m., p.m. | 2 |
2228
+ * | | aaaaa | a, p | |
2229
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2230
+ * | | bbb | am, pm, noon, midnight | |
2231
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2232
+ * | | bbbbb | a, p, n, mi | |
2233
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2234
+ * | | BBBB | at night, in the morning, ... | 2 |
2235
+ * | | BBBBB | at night, in the morning, ... | |
2236
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2237
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2238
+ * | | hh | 01, 02, ..., 11, 12 | |
2239
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2240
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2241
+ * | | HH | 00, 01, 02, ..., 23 | |
2242
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2243
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2244
+ * | | KK | 01, 02, ..., 11, 00 | |
2245
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2246
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2247
+ * | | kk | 24, 01, 02, ..., 23 | |
2248
+ * | Minute | m | 0, 1, ..., 59 | |
2249
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2250
+ * | | mm | 00, 01, ..., 59 | |
2251
+ * | Second | s | 0, 1, ..., 59 | |
2252
+ * | | so | 0th, 1st, ..., 59th | 7 |
2253
+ * | | ss | 00, 01, ..., 59 | |
2254
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2255
+ * | | SS | 00, 01, ..., 99 | |
2256
+ * | | SSS | 000, 001, ..., 999 | |
2257
+ * | | SSSS | ... | 3 |
2258
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2259
+ * | | XX | -0800, +0530, Z | |
2260
+ * | | XXX | -08:00, +05:30, Z | |
2261
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2262
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2263
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2264
+ * | | xx | -0800, +0530, +0000 | |
2265
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2266
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2267
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2268
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2269
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2270
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2271
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2272
+ * | Seconds timestamp | t | 512969520 | 7 |
2273
+ * | | tt | ... | 3,7 |
2274
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2275
+ * | | TT | ... | 3,7 |
2276
+ * | Long localized date | P | 04/29/1453 | 7 |
2277
+ * | | PP | Apr 29, 1453 | 7 |
2278
+ * | | PPP | April 29th, 1453 | 7 |
2279
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2280
+ * | Long localized time | p | 12:00 AM | 7 |
2281
+ * | | pp | 12:00:00 AM | 7 |
2282
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2283
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2284
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2285
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2286
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2287
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2288
+ * Notes:
2289
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2290
+ * are the same as "stand-alone" units, but are different in some languages.
2291
+ * "Formatting" units are declined according to the rules of the language
2292
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2293
+ *
2294
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2295
+ *
2296
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2297
+ *
2298
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2299
+ * the single quote characters (see below).
2300
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2301
+ * the output will be the same as default pattern for this unit, usually
2302
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2303
+ * are marked with "2" in the last column of the table.
2304
+ *
2305
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2306
+ *
2307
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2308
+ *
2309
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2310
+ *
2311
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2312
+ *
2313
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2314
+ *
2315
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2316
+ * The output will be padded with zeros to match the length of the pattern.
2317
+ *
2318
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2319
+ *
2320
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2321
+ * These tokens represent the shortest form of the quarter.
2322
+ *
2323
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2324
+ *
2325
+ * | Year | `y` | `u` |
2326
+ * |------|-----|-----|
2327
+ * | AC 1 | 1 | 1 |
2328
+ * | BC 1 | 1 | 0 |
2329
+ * | BC 2 | 2 | -1 |
2330
+ *
2331
+ * Also `yy` always returns the last two digits of a year,
2332
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2333
+ *
2334
+ * | Year | `yy` | `uu` |
2335
+ * |------|------|------|
2336
+ * | 1 | 01 | 01 |
2337
+ * | 14 | 14 | 14 |
2338
+ * | 376 | 76 | 376 |
2339
+ * | 1453 | 53 | 1453 |
2340
+ *
2341
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2342
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2343
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2344
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2345
+ *
2346
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2347
+ * so right now these tokens fall back to GMT timezones.
2348
+ *
2349
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2350
+ * - `i`: ISO day of week
2351
+ * - `I`: ISO week of year
2352
+ * - `R`: ISO week-numbering year
2353
+ * - `t`: seconds timestamp
2354
+ * - `T`: milliseconds timestamp
2355
+ * - `o`: ordinal number modifier
2356
+ * - `P`: long localized date
2357
+ * - `p`: long localized time
2358
+ *
2359
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2360
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2361
+ *
2362
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2363
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2364
+ *
2365
+ * @param {Date|Number} date - the original date
2366
+ * @param {String} format - the string of tokens
2367
+ * @param {Object} [options] - an object with options.
2368
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2369
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2370
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2371
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2372
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2373
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2374
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2375
+ * @returns {String} the formatted date string
2376
+ * @throws {TypeError} 2 arguments required
2377
+ * @throws {RangeError} `date` must not be Invalid Date
2378
+ * @throws {RangeError} `options.locale` must contain `localize` property
2379
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2380
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2381
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2382
+ * @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
2383
+ * @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
2384
+ * @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
2385
+ * @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
2386
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2387
+ *
2388
+ * @example
2389
+ * // Represent 11 February 2014 in middle-endian format:
2390
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2391
+ * //=> '02/11/2014'
2392
+ *
2393
+ * @example
2394
+ * // Represent 2 July 2014 in Esperanto:
2395
+ * import { eoLocale } from 'date-fns/locale/eo'
2396
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2397
+ * locale: eoLocale
2398
+ * })
2399
+ * //=> '2-a de julio 2014'
2400
+ *
2401
+ * @example
2402
+ * // Escape string by single quote characters:
2403
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2404
+ * //=> "3 o'clock"
2405
+ */
2406
+
2407
+ function format(dirtyDate, dirtyFormatStr, options) {
2408
+ 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;
2409
+ requiredArgs(2, arguments);
2410
+ var formatStr = String(dirtyFormatStr);
2411
+ var defaultOptions = getDefaultOptions();
2412
+ var locale$1 = (_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 : locale;
2413
+ 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);
2414
+
2415
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2416
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2417
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2418
+ }
2419
+ 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);
2420
+
2421
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2422
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2423
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2424
+ }
2425
+ if (!locale$1.localize) {
2426
+ throw new RangeError('locale must contain localize property');
2427
+ }
2428
+ if (!locale$1.formatLong) {
2429
+ throw new RangeError('locale must contain formatLong property');
2430
+ }
2431
+ var originalDate = toDate(dirtyDate);
2432
+ if (!isValid(originalDate)) {
2433
+ throw new RangeError('Invalid time value');
2434
+ }
2435
+
2436
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2437
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2438
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2439
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2440
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2441
+ var formatterOptions = {
2442
+ firstWeekContainsDate: firstWeekContainsDate,
2443
+ weekStartsOn: weekStartsOn,
2444
+ locale: locale$1,
2445
+ _originalDate: originalDate
2446
+ };
2447
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2448
+ var firstCharacter = substring[0];
2449
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2450
+ var longFormatter = longFormatters[firstCharacter];
2451
+ return longFormatter(substring, locale$1.formatLong);
2452
+ }
2453
+ return substring;
2454
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2455
+ // Replace two single quote characters with one single quote character
2456
+ if (substring === "''") {
2457
+ return "'";
2458
+ }
2459
+ var firstCharacter = substring[0];
2460
+ if (firstCharacter === "'") {
2461
+ return cleanEscapedString(substring);
2462
+ }
2463
+ var formatter = formatters[firstCharacter];
2464
+ if (formatter) {
2465
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2466
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2467
+ }
2468
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2469
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2470
+ }
2471
+ return formatter(utcDate, substring, locale$1.localize, formatterOptions);
2472
+ }
2473
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2474
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2475
+ }
2476
+ return substring;
2477
+ }).join('');
2478
+ return result;
2479
+ }
2480
+ function cleanEscapedString(input) {
2481
+ var matched = input.match(escapedStringRegExp);
2482
+ if (!matched) {
2483
+ return input;
2484
+ }
2485
+ return matched[1].replace(doubleQuoteRegExp, "'");
2486
+ }
2487
+
2488
+ const TipsInfo = `<svg width="126" height="92" viewBox="0 0 126 92" fill="none" xmlns="http://www.w3.org/2000/svg">
2489
+ <g filter="url(#filter0_d_242_4231)">
2490
+ <rect x="24" y="20" width="78" height="36" rx="4" fill="white"/>
2491
+ <path d="M24 24C24 21.7909 25.7909 20 28 20H64V56H28C25.7909 56 24 54.2091 24 52V24Z" fill="#464646"/>
2492
+ <path d="M51 56H37L43.2474 63.1399C43.6458 63.5952 44.3542 63.5952 44.7526 63.1399L51 56Z" fill="#464646"/>
2493
+ <circle cx="44" cy="38" r="7" fill="white"/>
2494
+ <path d="M43.9405 34C44.5456 34 45.0362 34.4906 45.0362 35.0957C45.0362 35.7009 44.5456 36.1915 43.9405 36.1915C43.3353 36.1915 42.8447 35.7009 42.8447 35.0957C42.8447 34.4906 43.3353 34 43.9405 34Z" fill="#464646"/>
2495
+ <path d="M45.8801 41.3737C45.8801 41.7617 45.5626 42.0791 45.1746 42.0791H44.3233H43.551H42.7055C42.3175 42.0791 42 41.7617 42 41.3737V41.3575C42 40.9695 42.3175 40.6521 42.7055 40.6521H42.8455V37.8714H42.3528C42.1588 37.8714 42 37.7127 42 37.5187V37.4936C42 37.2996 42.1588 37.1409 42.3528 37.1409H43.551H44.031H44.3233C44.7113 37.1409 45.0287 37.4583 45.0287 37.8463V40.6521H45.1746C45.5626 40.6521 45.8801 40.9696 45.8801 41.3576V41.3737Z" fill="#464646"/>
2496
+ </g>
2497
+ <defs>
2498
+ <filter id="filter0_d_242_4231" x="0" y="0" width="126" height="91.4814" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
2499
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
2500
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
2501
+ <feOffset dy="4"/>
2502
+ <feGaussianBlur stdDeviation="12"/>
2503
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
2504
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_242_4231"/>
2505
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_242_4231" result="shape"/>
2506
+ </filter>
2507
+ </defs>
2508
+ </svg>
2509
+ `;
2510
+
2511
+ const PlayerLoyaltyProcess = () => (index.h("span", { class: "LevelProgress", id: 'LevelProgress', innerHTML: LoyaltyProgress }));
2512
+ const PlayerPoints = ({ loyaltyPoints, spendablePoints, pointExpireString, language, }) => (index.h("div", { class: "PointsInfo" },
2513
+ loyaltyPoints &&
2514
+ index.h("div", { class: 'Points' },
2515
+ loyaltyPoints,
2516
+ " ",
2517
+ index.h("sub", { class: "XP" }, translate('xp', language))),
2518
+ spendablePoints &&
2519
+ index.h("div", { class: 'Points' },
2520
+ spendablePoints,
2521
+ " ",
2522
+ index.h("sub", { class: "XP" }, translate('sp', language))),
2523
+ pointExpireString && (index.h("div", { class: 'ExpirationPoints' },
2524
+ pointExpireString,
2525
+ " "))));
2526
+ const PlayerElevateCardRedeem = ({ language, onRedeemClick }) => (index.h("div", { class: "CardCell Redeem" },
2527
+ index.h("div", { class: "RedeemButton", onClick: () => {
2528
+ onRedeemClick();
2529
+ } },
2530
+ index.h("span", null, translate('redeem', language)))));
2531
+ const PlayerNameDiv = (props) => (index.h("div", { class: 'CardCell PlayerName Txt' }, props.playerName));
2532
+ const PlayerElevateLoyaltyLevel = (props) => (index.h("div", { class: 'CardCell ElevateLevel' },
2533
+ index.h("span", { class: "LevelName", title: props.level }, props.level),
2534
+ props.expireTime && (index.h("div", { class: "CardCell ExpirationDate Txt" },
2535
+ translate('expireOn', props.language),
2536
+ index.h("span", { class: "ExpireTime" }, format(new Date(props.expireTime), props.dateFormat || 'yyyy-MM-dd')),
2537
+ !props.hideInfo && (index.h("span", { class: "fa Info", style: { 'background': `url(${index.getAssetPath('../static/info.svg')})` } },
2538
+ index.h("span", { class: "InfoTips", innerHTML: TipsInfo })))))));
2539
+ const PlayerAvatar = (props) => {
2540
+ const badge = props.loyaltyIconUrl
2541
+ ? index.h("img", { class: "Badge", src: props.loyaltyIconUrl })
2542
+ : props.hideIfNull ? '' : index.h("div", { class: "Badge" });
2543
+ const avatarSrc = props.playerAvatarUrl || index.getAssetPath('../static/user.svg');
2544
+ return index.h("div", { class: "PlayerAvatar", style: { 'position': `${props.onlyBadge ? '' : 'relative'}` } },
2545
+ !props.onlyBadge && index.h("img", { class: "Avatar", src: avatarSrc }),
2546
+ badge);
2547
+ };
2548
+
2549
+ const playerElevateCardCss = "@container (max-width: 270px) {\n .Card .Inner {\n flex-direction: column;\n }\n .Card .Inner .Content {\n padding: 9px;\n }\n\n .Inner .Row .ExpirationPoints {\n order: 1;\n }\n}\n.Card .PlayerImg {\n order: 0;\n}\n.Card .ExpirationPoints {\n order: 3;\n}\n.Card .LevelInfo {\n order: 2;\n}\n.Card .Inner .Row .PlayerImg {\n flex-direction: column;\n}\n.Card .Inner .Row .PointsInfo {\n width: 100%;\n text-align: center;\n display: flex;\n flex-direction: column;\n max-height: 50%;\n}\n.Card .Inner .PlayerAvatar .Badge {\n background-size: contain;\n background-repeat: no-repeat;\n position: absolute;\n right: 5px;\n bottom: -5px;\n width: 40%;\n height: 40%;\n overflow: visible;\n}\n.Card .Inner .Row .ExpirationPoints {\n text-align: left;\n color: var(--emfe-w-color-red, red);\n}\n.Card .Inner .Row .Points {\n text-wrap: nowrap;\n}\n.Card .Inner .LevelInfo .ElevateLevel {\n flex-direction: column;\n}\n.Card .Inner .LevelInfo .ElevateLevel .LevelName {\n width: calc(100% - 20px);\n text-align: left;\n font-size: 13px;\n padding-left: 20px;\n margin: 10px 0;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpirationDate {\n text-align: center;\n font-size: smaller;\n}\n.Card .Inner .LevelInfo .ElevateLevel .ExpireTime {\n margin-left: 5px;\n}";
2550
+
2551
+ const PlayerElevateCard = class {
2552
+ constructor(hostRef) {
2553
+ index.registerInstance(this, hostRef);
2554
+ /**
2555
+ * The style that widget shows,available value: Dark, Light
2556
+ * Default: Dark
2557
+ */
2558
+ this.theme = 'Dark';
2559
+ /**
2560
+ * Widget Language to show
2561
+ */
2562
+ this.language = 'en';
2563
+ /**
2564
+ * datePattern
2565
+ */
2566
+ this.dateFormat = 'yyyy-MM-dd';
2567
+ /**
2568
+ * Client custom styling via inline styles
2569
+ */
2570
+ this.clientStyling = '';
2571
+ /**
2572
+ * Client custom styling via url
2573
+ */
2574
+ this.clientStylingUrl = '';
2575
+ /**
2576
+ * Translation via url
2577
+ */
2578
+ this.translationUrl = '';
2579
+ this.playerLevelFlag = 0;
2580
+ }
2581
+ playerElevateLeveLoadedHandler(event) {
2582
+ if (!event.detail) {
2583
+ return;
2584
+ }
2585
+ if (event.detail['elevateLevelWalletTotal']) {
2586
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
2587
+ }
2588
+ if (event.detail['elevateLevel']) {
2589
+ this.playerElevateLevel = event.detail['elevateLevel'];
2590
+ }
2591
+ if (event.detail['pointExpireString']) {
2592
+ this.pointExpireString = event.detail.xpExpireString;
2593
+ }
2594
+ if (event.detail.calculatedLevelFlag) {
2595
+ this.playerLevelFlag = event.detail.calculatedLevelFlag;
2596
+ }
2597
+ }
2598
+ onRedeemClick() {
2599
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
2600
+ }
2601
+ componentWillLoad() {
2602
+ this.paramProxy = {
2603
+ endpoint: this.endpoint,
2604
+ session: this.session,
2605
+ language: this.language,
2606
+ calculateLevelFlag: true,
2607
+ };
2608
+ }
2609
+ render() {
2610
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
2611
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
2612
+ return (index.h("div", { class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { class: "Card Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { params: this.paramProxy }), index.h("div", { class: "OuterCover Inner", style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, this.playerElevateLevel && (index.h(index.Fragment, null, index.h("div", { class: 'Content Row' }, index.h("div", { class: "PlayerImg" }, index.h(PlayerAvatar, { playerAvatarUrl: this.playerAvatarUrl, loyaltyIconUrl: this.playerElevateLevel.presentation.asset }), index.h(PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language })), this.pointExpireString && (index.h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), index.h("div", { class: `LevelInfo Level${this.playerLevelFlag} ${this.playerElevateLevel.presentation.displayName}` }, index.h(PlayerNameDiv, { playerName: this.playerName }), index.h(PlayerElevateLoyaltyLevel, { hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), index.h(PlayerLoyaltyProcess, null), index.h(PlayerElevateCardRedeem, { onRedeemClick: this.onRedeemClick, language: this.language })))))))));
2613
+ }
2614
+ static get assetsDirs() { return ["../static"]; }
2615
+ };
2616
+ PlayerElevateCard.style = playerElevateCardCss;
2617
+
2618
+ /**
2619
+ * @name startOfDay
2620
+ * @category Day Helpers
2621
+ * @summary Return the start of a day for the given date.
2622
+ *
2623
+ * @description
2624
+ * Return the start of a day for the given date.
2625
+ * The result will be in the local timezone.
2626
+ *
2627
+ * @param {Date|Number} date - the original date
2628
+ * @returns {Date} the start of a day
2629
+ * @throws {TypeError} 1 argument required
2630
+ *
2631
+ * @example
2632
+ * // The start of a day for 2 September 2014 11:55:00:
2633
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
2634
+ * //=> Tue Sep 02 2014 00:00:00
2635
+ */
2636
+ function startOfDay(dirtyDate) {
2637
+ requiredArgs(1, arguments);
2638
+ var date = toDate(dirtyDate);
2639
+ date.setHours(0, 0, 0, 0);
2640
+ return date;
2641
+ }
2642
+
2643
+ var MILLISECONDS_IN_DAY = 86400000;
2644
+
2645
+ /**
2646
+ * @name differenceInCalendarDays
2647
+ * @category Day Helpers
2648
+ * @summary Get the number of calendar days between the given dates.
2649
+ *
2650
+ * @description
2651
+ * Get the number of calendar days between the given dates. This means that the times are removed
2652
+ * from the dates and then the difference in days is calculated.
2653
+ *
2654
+ * @param {Date|Number} dateLeft - the later date
2655
+ * @param {Date|Number} dateRight - the earlier date
2656
+ * @returns {Number} the number of calendar days
2657
+ * @throws {TypeError} 2 arguments required
2658
+ *
2659
+ * @example
2660
+ * // How many calendar days are between
2661
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
2662
+ * const result = differenceInCalendarDays(
2663
+ * new Date(2012, 6, 2, 0, 0),
2664
+ * new Date(2011, 6, 2, 23, 0)
2665
+ * )
2666
+ * //=> 366
2667
+ * // How many calendar days are between
2668
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
2669
+ * const result = differenceInCalendarDays(
2670
+ * new Date(2011, 6, 3, 0, 1),
2671
+ * new Date(2011, 6, 2, 23, 59)
2672
+ * )
2673
+ * //=> 1
2674
+ */
2675
+ function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
2676
+ requiredArgs(2, arguments);
2677
+ var startOfDayLeft = startOfDay(dirtyDateLeft);
2678
+ var startOfDayRight = startOfDay(dirtyDateRight);
2679
+ var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
2680
+ var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);
2681
+
2682
+ // Round the number of days to the nearest integer
2683
+ // because the number of milliseconds in a day is not constant
2684
+ // (e.g. it's different in the day of the daylight saving time clock shift)
2685
+ return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
2686
+ }
2687
+
2688
+ /**
2689
+ * Days in 1 week.
2690
+ *
2691
+ * @name daysInWeek
2692
+ * @constant
2693
+ * @type {number}
2694
+ * @default
2695
+ */
2696
+
2697
+ /**
2698
+ * Milliseconds in 1 hour
2699
+ *
2700
+ * @name millisecondsInHour
2701
+ * @constant
2702
+ * @type {number}
2703
+ * @default
2704
+ */
2705
+ var millisecondsInHour = 3600000;
2706
+
2707
+ /**
2708
+ * @name differenceInMilliseconds
2709
+ * @category Millisecond Helpers
2710
+ * @summary Get the number of milliseconds between the given dates.
2711
+ *
2712
+ * @description
2713
+ * Get the number of milliseconds between the given dates.
2714
+ *
2715
+ * @param {Date|Number} dateLeft - the later date
2716
+ * @param {Date|Number} dateRight - the earlier date
2717
+ * @returns {Number} the number of milliseconds
2718
+ * @throws {TypeError} 2 arguments required
2719
+ *
2720
+ * @example
2721
+ * // How many milliseconds are between
2722
+ * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
2723
+ * const result = differenceInMilliseconds(
2724
+ * new Date(2014, 6, 2, 12, 30, 21, 700),
2725
+ * new Date(2014, 6, 2, 12, 30, 20, 600)
2726
+ * )
2727
+ * //=> 1100
2728
+ */
2729
+ function differenceInMilliseconds(dateLeft, dateRight) {
2730
+ requiredArgs(2, arguments);
2731
+ return toDate(dateLeft).getTime() - toDate(dateRight).getTime();
2732
+ }
2733
+
2734
+ var roundingMap = {
2735
+ ceil: Math.ceil,
2736
+ round: Math.round,
2737
+ floor: Math.floor,
2738
+ trunc: function trunc(value) {
2739
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
2740
+ } // Math.trunc is not supported by IE
2741
+ };
2742
+
2743
+ var defaultRoundingMethod = 'trunc';
2744
+ function getRoundingMethod(method) {
2745
+ return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
2746
+ }
2747
+
2748
+ /**
2749
+ * @name differenceInHours
2750
+ * @category Hour Helpers
2751
+ * @summary Get the number of hours between the given dates.
2752
+ *
2753
+ * @description
2754
+ * Get the number of hours between the given dates.
2755
+ *
2756
+ * @param {Date|Number} dateLeft - the later date
2757
+ * @param {Date|Number} dateRight - the earlier date
2758
+ * @param {Object} [options] - an object with options.
2759
+ * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)
2760
+ * @returns {Number} the number of hours
2761
+ * @throws {TypeError} 2 arguments required
2762
+ *
2763
+ * @example
2764
+ * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?
2765
+ * const result = differenceInHours(
2766
+ * new Date(2014, 6, 2, 19, 0),
2767
+ * new Date(2014, 6, 2, 6, 50)
2768
+ * )
2769
+ * //=> 12
2770
+ */
2771
+ function differenceInHours(dateLeft, dateRight, options) {
2772
+ requiredArgs(2, arguments);
2773
+ var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
2774
+ return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);
2775
+ }
2776
+
2777
+ /**
2778
+ * @name isBefore
2779
+ * @category Common Helpers
2780
+ * @summary Is the first date before the second one?
2781
+ *
2782
+ * @description
2783
+ * Is the first date before the second one?
2784
+ *
2785
+ * @param {Date|Number} date - the date that should be before the other one to return true
2786
+ * @param {Date|Number} dateToCompare - the date to compare with
2787
+ * @returns {Boolean} the first date is before the second date
2788
+ * @throws {TypeError} 2 arguments required
2789
+ *
2790
+ * @example
2791
+ * // Is 10 July 1989 before 11 February 1987?
2792
+ * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
2793
+ * //=> false
2794
+ */
2795
+ function isBefore(dirtyDate, dirtyDateToCompare) {
2796
+ requiredArgs(2, arguments);
2797
+ var date = toDate(dirtyDate);
2798
+ var dateToCompare = toDate(dirtyDateToCompare);
2799
+ return date.getTime() < dateToCompare.getTime();
2800
+ }
2801
+
2802
+ function updateProgressSvg(progressElementRef, percent) {
2803
+ const svgElement = progressElementRef.querySelector('#total_level');
2804
+ const endLockWidth = 15;
2805
+ const barWidth = svgElement.getBBox().width;
2806
+ const widthOnBar = percent * barWidth - endLockWidth < 0 ? 0 : percent * barWidth - endLockWidth;
2807
+ //update bar's width, widthOnBar
2808
+ const levelBar = progressElementRef.querySelector('#current_level');
2809
+ //update filters, x = widthOnBar
2810
+ const levelFilter = progressElementRef.querySelector('#filter_current_level');
2811
+ //update circle, widthOnBar+10
2812
+ const levelCircle = progressElementRef.querySelector('#circle_current_level');
2813
+ svgElement.setAttribute('viewbox', `0 0 ${widthOnBar} 28`);
2814
+ levelBar.setAttribute('width', `${widthOnBar}`);
2815
+ levelCircle.setAttribute('cx', `${widthOnBar + 3}`);
2816
+ levelFilter.setAttribute('x', `${widthOnBar - 4}`);
2817
+ //update lock location
2818
+ const endLockElement = progressElementRef.querySelector('#lock');
2819
+ // wrapper of endLock, include ball and heatfilter1_d_305_23
2820
+ const filter1 = progressElementRef.querySelector('#filter_heart_ball');
2821
+ // ball in endlockfilter2_i_305_23
2822
+ const filter2 = progressElementRef.querySelector('#filter_ball');
2823
+ // heart in endlockfilter3_d_305_23
2824
+ const filter3 = progressElementRef.querySelector('#filter_heart');
2825
+ //wrapper of lockfilter4_d_305_23
2826
+ const filterLock = progressElementRef.querySelector('#filter_lock');
2827
+ // shadow of ball paint0_linear_305_23
2828
+ const paint0 = progressElementRef.querySelector('#paint0_linear_ball');
2829
+ //paint in lockpaint1_linear_305_23
2830
+ const paint1 = progressElementRef.querySelector('#paint1_linear_lock');
2831
+ // box of lock and heart, for move position dynamically
2832
+ const lockBox = progressElementRef.querySelector('#lock_box');
2833
+ const heartBox = progressElementRef.querySelector('#heart_box');
2834
+ const rightPaddingOfLockWidth = 10, cxOfEndLockEle = barWidth - rightPaddingOfLockWidth;
2835
+ //set cx of lockElement
2836
+ endLockElement.setAttribute('cx', `${cxOfEndLockEle}`);
2837
+ //set cx of sub Elements
2838
+ paint1.setAttribute('x1', `${cxOfEndLockEle}`);
2839
+ paint1.setAttribute('x2', `${cxOfEndLockEle}`);
2840
+ paint0.setAttribute('x1', `${cxOfEndLockEle - 6}`);
2841
+ paint0.setAttribute('x2', `${cxOfEndLockEle - 6 + 11.2}`);
2842
+ filterLock.setAttribute('x', `${cxOfEndLockEle - 6}`);
2843
+ filter3.setAttribute('x', `${cxOfEndLockEle - 6 - 2}`);
2844
+ filter2.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2}`);
2845
+ filter1.setAttribute('x', `${cxOfEndLockEle - 6 - 2 - 2 - 4}`);
2846
+ lockBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
2847
+ heartBox.setAttribute('x', `${cxOfEndLockEle - 6}`);
2848
+ }
2849
+
2850
+ const playerElevateCardDataCss = ":host {\n display: block;\n width: 360px;\n height: 230px;\n}\n\n.ElevateCardWrapper {\n contain: layout inline-size;\n width: 100%;\n height: fit-content;\n min-height: 218px;\n}\n\n.Outer {\n container-type: inline-size;\n font-size: 12px;\n background-size: cover;\n background-repeat: no-repeat;\n line-height: initial;\n width: 100%;\n height: 100%;\n}\n\n.Dark {\n color: var(--emfe-w-color-gray150, #efefef);\n}\n\n.Light {\n color: var(--emfe-w-color-black, #0e0e0e);\n}\n\n@container (min-width: 381px) {\n .Outer {\n background-size: cover;\n }\n .Outer .OuterCover {\n min-height: 190px;\n }\n}\n@container (min-width: 260px) {\n .Outer {\n background-size: contain;\n }\n}\n.OuterCover {\n width: 100%;\n height: 100%;\n content: \"\";\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 15px;\n}\n\n.Inner {\n display: flex;\n flex-direction: column;\n min-height: 158px;\n}\n.Inner .Content {\n padding: 15px;\n flex-wrap: wrap;\n gap: 8px;\n}\n.Inner .Row {\n display: flex;\n flex-direction: row;\n}\n.Inner .CardCell {\n display: flex;\n}\n.Inner .LevelInfo {\n display: flex;\n flex-direction: column;\n}\n.Inner .LevelInfo .ElevateLevel .LevelName {\n height: 28px;\n border-radius: 5px;\n line-height: 28px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.Inner .LevelInfo.Level0 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level0button-shadow, rgba(191, 84, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level0-bg0, #E2792C) 0%, var(--emfe-w-elevate-color-level0-bg1, rgba(242, 151, 99, 0)) 100%);\n}\n.Inner .LevelInfo.Level1 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level1button-shadow, rgba(151, 151, 151, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level1-bg0, #BEBFED) 0%, var(--emfe-w-elevate-color-level1-bg1, rgba(216, 217, 233, 0)) 100%);\n}\n.Inner .LevelInfo.Level2 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level2button-shadow, rgba(191, 120, 6, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level2-bg0, #FCC410) 0%, var(--emfe-w-elevate-color-level2-bg1, rgba(255, 189, 43, 0)) 100%);\n}\n.Inner .LevelInfo.Level3 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level3button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level3-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level3-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo.Level4 .ElevateLevel .LevelName {\n box-shadow: -2px -2px 7px 0px var(--emfe-w-elevate-color-level4button-shadow, rgba(65, 6, 191, 0.75));\n background: linear-gradient(180deg, var(--emfe-w-elevate-color-level4-bg0, #B1A2DB) 0%, var(--emfe-w-elevate-color-level4-bg1, rgba(203, 202, 245, 0)) 100%);\n}\n.Inner .LevelInfo .ElevateLevel {\n display: flex;\n}\n.Inner .LevelInfo {\n flex: 1;\n flex-grow: 1;\n min-width: 150px;\n}\n.Inner .PlayerImg {\n width: 29%;\n margin: auto;\n max-width: 100px;\n min-width: 30px;\n order: 0;\n}\n.Inner .PlayerAvatar {\n max-width: 100px;\n flex-basis: 100px;\n height: auto;\n margin: auto;\n padding-top: 10px;\n}\n.Inner .PlayerAvatar .Avatar, .Inner .PlayerAvatar .Badge {\n width: 100%;\n height: 100%;\n}\n.Inner .PlayerAvatar .Avatar {\n border-radius: 50%;\n background-size: contain;\n background-repeat: no-repeat;\n}\n.Inner .ElevateLevel .ExpirationDate {\n max-width: 138px;\n min-width: 118px;\n}\n.Inner .PlayerName, .Inner .RedeemButton, .Inner .ElevateLevel {\n text-transform: capitalize;\n width: 100%;\n}\n.Inner .PlayerName {\n font-size: 16px;\n}\n.Inner .Row .PointsInfo {\n display: table;\n font-weight: 600;\n}\n.Inner .Row .Redeem {\n justify-content: flex-end;\n margin-left: auto;\n}\n.Inner .Row .Redeem:hover {\n color: var(--emfe-w-elevate-color-redeem-hover, #00ABA4);\n cursor: pointer;\n}\n.Inner .Row .RedeemButton:hover span {\n color: var(emfe-w-elevate-color-redeem-text-hover, #f1f1f1);\n font-weight: bold;\n}\n.Inner .Row .RedeemButton {\n width: 95px;\n height: 35px;\n display: flex;\n align-items: center;\n border-radius: 10px;\n background: var(--emfe-w-elevate-color-redeem-bg, linear-gradient(0deg, #26CC37, #26CC37)), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%);\n box-shadow: 0px 4px 4px 0px #00000040;\n}\n.Inner .Row .RedeemButton span {\n color: var(--emfe-w-color-white, #fff);\n line-height: 18px;\n font-size: 15px;\n text-align: center;\n width: 100%;\n}\n.Inner .Row .Points {\n font-size: large;\n vertical-align: middle;\n}\n.Inner .Row .Points .XP {\n font-size: x-small;\n}\n.Inner .Row .ExpirationPoints {\n font-size: small;\n text-align: right;\n font-weight: bold;\n color: var(--emfe-w-color-red, #9e595f);\n}";
2851
+
2852
+ const PlayerElevateCardData = class {
2853
+ constructor(hostRef) {
2854
+ index.registerInstance(this, hostRef);
2855
+ this.playerElevateLeveLoaded = index.createEvent(this, "playerElevateLeveLoaded", 7);
2856
+ }
2857
+ handleWindowResizs() {
2858
+ this.initLevelProgressbar();
2859
+ }
2860
+ onRedeemClick() {
2861
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
2862
+ }
2863
+ loadLevels() {
2864
+ let url = new URL(`${this.params.endpoint}/v1/elevate/levels?language=${this.params.language}`);
2865
+ return new Promise((resolve, reject) => {
2866
+ return fetch(url.href, {
2867
+ method: 'GET',
2868
+ })
2869
+ .then((res) => res.json())
2870
+ .then((res) => {
2871
+ this.levels = res.data;
2872
+ resolve(true);
2873
+ })
2874
+ .catch((err) => {
2875
+ reject(err);
2876
+ });
2877
+ });
2878
+ }
2879
+ calcuatePointsToBeExpired(walletTotalInfo) {
2880
+ let pointExpireInfoAsString = '';
2881
+ if (!walletTotalInfo || !walletTotalInfo.aboutToExpire ||
2882
+ walletTotalInfo.aboutToExpire.length == 0 ||
2883
+ walletTotalInfo.aboutToExpire[0].points <= 0) {
2884
+ return pointExpireInfoAsString;
2885
+ }
2886
+ walletTotalInfo.aboutToExpire.sort((expire1, expire2) => {
2887
+ return isBefore(new Date(expire1.expireTime), new Date(expire2.expireTime))
2888
+ ? -1
2889
+ : 1;
2890
+ });
2891
+ const aboutToExpire = walletTotalInfo.aboutToExpire[0];
2892
+ const daysToExpried = differenceInCalendarDays(new Date(aboutToExpire.expireTime), new Date());
2893
+ let hoursToExpired = 0, expiredTranslationKey = daysToExpried === 0 ? 'pointsToBeExpiredDay' : 'pointsToBeExpired';
2894
+ if (daysToExpried == 0) {
2895
+ hoursToExpired = differenceInHours(new Date(aboutToExpire.expireTime), new Date());
2896
+ expiredTranslationKey = hoursToExpired > 1 ? 'pointsToBeExpiredHours' : 'pointsToBeExpiredHour';
2897
+ }
2898
+ pointExpireInfoAsString = translateWithParams(expiredTranslationKey, {
2899
+ expirationPoints: aboutToExpire.points,
2900
+ expireDay: daysToExpried,
2901
+ });
2902
+ return pointExpireInfoAsString;
2903
+ }
2904
+ loadPlayerLevelInfo() {
2905
+ let url = new URL(`${this.params.endpoint}/v1/elevate/playerInfo?language=${this.params.language}`);
2906
+ return new Promise((resolve, reject) => {
2907
+ return fetch(url.href, {
2908
+ method: 'GET',
2909
+ headers: {
2910
+ 'X-Sessionid': this.params.session,
2911
+ 'Content-Type': 'application/json',
2912
+ },
2913
+ })
2914
+ .then((res) => res.json())
2915
+ .then((res) => {
2916
+ var _a, _b, _c;
2917
+ if (!res.success) {
2918
+ console.error('Exception when fetch user elevateinfo, ', res.errorCode, res.errorMessage);
2919
+ reject(true);
2920
+ return;
2921
+ }
2922
+ let playerElevateInfo = res.data;
2923
+ this.playerElevateLevel = playerElevateInfo.level;
2924
+ this.playerElevateLevel.name = this.playerElevateLevel.presentation.displayName || this.playerElevateLevel.name;
2925
+ this.playerElevateLevel.spendablePoints = ((_a = playerElevateInfo.spendableWallet) === null || _a === void 0 ? void 0 : _a.total.points) || 0;
2926
+ this.playerElevateLeveLoaded.emit({ elevateLevel: this.playerElevateLevel });
2927
+ const spendableTotal = (_b = res.data.spendableWallet) === null || _b === void 0 ? void 0 : _b.total;
2928
+ const loyaltyWalletTotal = (_c = res.data.loyaltyWallet) === null || _c === void 0 ? void 0 : _c.total;
2929
+ this.playerElevateLeveLoaded.emit({
2930
+ elevateLevelWalletTotal: spendableTotal,
2931
+ loyaltyWalletTotal
2932
+ });
2933
+ let spExpireInfoAsString = this.calcuatePointsToBeExpired(spendableTotal);
2934
+ let xpExpireInfoAsString = this.calcuatePointsToBeExpired(loyaltyWalletTotal);
2935
+ if (spExpireInfoAsString || xpExpireInfoAsString) {
2936
+ this.playerElevateLeveLoaded.emit({
2937
+ pointExpireString: spExpireInfoAsString,
2938
+ xpExpireString: xpExpireInfoAsString
2939
+ });
2940
+ }
2941
+ resolve(this.playerElevateLevel);
2942
+ })
2943
+ .catch((err) => {
2944
+ console.log('error ', err);
2945
+ reject(true);
2946
+ });
2947
+ });
2948
+ }
2949
+ setLoyaltyProgress(percent) {
2950
+ updateProgressSvg(this.loyaltyProgressEle, percent);
2951
+ }
2952
+ initLevelProgressbar() {
2953
+ setTimeout(() => {
2954
+ this.loyaltyProgressEle =
2955
+ this.elevateCardRef.parentElement.querySelector('#LevelProgress');
2956
+ if (!this.loyaltyProgressEle) {
2957
+ return;
2958
+ }
2959
+ this.setLoyaltyProgress(!this.playerElevateLevel.nextLevel
2960
+ ? 1
2961
+ : (this.playerElevateLevel.loyaltyPoints -
2962
+ this.playerElevateLevel.entryPoints) /
2963
+ (this.playerElevateLevel.nextLevel.entryPoints -
2964
+ this.playerElevateLevel.loyaltyPoints));
2965
+ this.params['playerElevateLevel'] = this.playerElevateLevel;
2966
+ }, 80);
2967
+ }
2968
+ componentWillRender() { }
2969
+ componentDidRender() {
2970
+ this.initLevelProgressbar();
2971
+ }
2972
+ componentWillLoad() {
2973
+ if (!this.params.endpoint || !this.params.session) {
2974
+ return;
2975
+ }
2976
+ const promises = [];
2977
+ promises.push(this.loadPlayerLevelInfo());
2978
+ if (this.params.calculateLevelFlag) {
2979
+ promises.push(this.loadLevels());
2980
+ }
2981
+ Promise.all(promises).then((res) => {
2982
+ console.log('elevate-init', res);
2983
+ this.initLevelProgressbar();
2984
+ if (!this.levels) {
2985
+ return;
2986
+ }
2987
+ this.levels.sort((level1, level2) => {
2988
+ return level1.firstEntryPoints > level2.firstEntryPoints ? 1 : -1;
2989
+ });
2990
+ const playerPoints = this.playerElevateLevel.loyaltyPoints;
2991
+ let playerLevelNumber = 0;
2992
+ this.levels.forEach((elevateLevel, idx) => {
2993
+ if (playerPoints > elevateLevel.firstEntryPoints) {
2994
+ playerLevelNumber = idx;
2995
+ }
2996
+ });
2997
+ this.playerElevateLeveLoaded.emit({
2998
+ calculatedLevelFlag: playerLevelNumber,
2999
+ });
3000
+ });
3001
+ }
3002
+ get elevateCardRef() { return index.getElement(this); }
3003
+ };
3004
+ PlayerElevateCardData.style = playerElevateCardDataCss;
3005
+
3006
+ const playerElevateLoyaltycardCss = ":host{display:block}@media screen and (min-width: 501px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:nowrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:11px;margin-left:5px}}@media screen and (max-width: 500px){.LoyaltyCard .Inner .LevelInfo .ElevateLevel{flex-wrap:wrap}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{padding-top:0px;margin-left:0px}}.LoyaltyCard .Inner .LevelProgress{margin-left:0px}.LoyaltyCard .Inner .Row .PointsInfo{width:100%}.LoyaltyCard .Inner .Row .PointsInfo.ExpirationPoints{text-align:left;color:var(--emfe-w-color-red-50, red)}.LoyaltyCard .Inner .PlayerAvatar .Avatar{display:none}.LoyaltyCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%}.LoyaltyCard .Inner .LevelInfo .ElevateLevel{display:flex;flex:1;align-items:center}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate{position:relative;padding-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .ExpirationDate .ExpireTime{margin-left:5px}.LoyaltyCard .Inner .LevelInfo .ElevateLevel .LevelName{padding-left:0;font-size:var(--emfe-w-elevate-fontsize-2xlarge, 21px);position:relative;width:auto;color:var(--emfe-w-elevate-color-levelname, #FFBD2B);font-weight:bold}.LoyaltyCard .NextLevelTip{text-align:right;font-size:11px;color:var(--emfe-w-color-black, #000);opacity:0.8;font-weight:bold}";
3007
+
3008
+ const PlayerElevateLoyaltycard = class {
3009
+ constructor(hostRef) {
3010
+ index.registerInstance(this, hostRef);
3011
+ /**
3012
+ * The style that widget shows,available value: Dark, Light
3013
+ * Default: Dark
3014
+ */
3015
+ this.theme = 'Dark';
3016
+ /**
3017
+ * Widget Language to show
3018
+ */
3019
+ this.language = 'en';
3020
+ /**
3021
+ * datePattern
3022
+ */
3023
+ this.dateFormat = 'yyyy-MM-dd';
3024
+ /**
3025
+ * Client custom styling via inline styles
3026
+ */
3027
+ this.clientStyling = '';
3028
+ /**
3029
+ * Client custom styling via url
3030
+ */
3031
+ this.clientStylingUrl = '';
3032
+ /**
3033
+ * Translation via url
3034
+ */
3035
+ this.translationUrl = '';
3036
+ }
3037
+ playerElevateLeveLoadedHandler(event) {
3038
+ if (!event.detail) {
3039
+ return;
3040
+ }
3041
+ if (event.detail['elevateLevelWalletTotal']) {
3042
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3043
+ }
3044
+ if (event.detail['elevateLevel']) {
3045
+ this.playerElevateLevel = event.detail['elevateLevel'];
3046
+ }
3047
+ if (event.detail['pointExpireString']) {
3048
+ this.pointExpireString = event.detail.xpExpireString;
3049
+ }
3050
+ }
3051
+ onRedeemClick() {
3052
+ window.postMessage({ type: 'BEERedeemClicked' }, window.location.href);
3053
+ }
3054
+ componentWillLoad() {
3055
+ this.paramsProxy = {
3056
+ endpoint: this.endpoint,
3057
+ session: this.session,
3058
+ language: this.language,
3059
+ };
3060
+ }
3061
+ getNextLevelTips() {
3062
+ var _a;
3063
+ //need xx to reach Diamond
3064
+ let nextLevel = (_a = this.playerElevateLevel) === null || _a === void 0 ? void 0 : _a.nextLevel;
3065
+ if (this.playerElevateLevel && nextLevel) {
3066
+ const pointsToReach = (nextLevel.entryPoints - this.playerElevateLevel.loyaltyPoints).toFixed(2);
3067
+ return translateWithParams('tipsForNextLevel', {
3068
+ pointsToReach,
3069
+ levelName: nextLevel.name,
3070
+ });
3071
+ }
3072
+ return '';
3073
+ }
3074
+ render() {
3075
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
3076
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
3077
+ return (index.h("div", { class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { class: "LoyaltyCard Outer", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { params: this.paramsProxy }), index.h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, index.h("div", { class: 'Content Row' }, this.playerElevateLevel && (index.h(index.Fragment, null, index.h("div", { class: "PlayerImg" }, index.h(PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), index.h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, index.h(PlayerElevateLoyaltyLevel, { hideInfo: true, level: this.playerElevateLevel.name, expireTime: this.playerElevateLevel.expireTime, dateFormat: this.dateFormat }), index.h(PlayerPoints, { loyaltyPoints: this.playerElevateLevel.loyaltyPoints, language: this.language }), this.pointExpireString && (index.h("div", { class: 'PointsInfo ExpirationPoints' }, this.pointExpireString, " ")), index.h(PlayerLoyaltyProcess, null), index.h("div", { class: "NextLevelTip" }, this.getNextLevelTips())))))))));
3078
+ }
3079
+ };
3080
+ PlayerElevateLoyaltycard.style = playerElevateLoyaltycardCss;
3081
+
3082
+ const playerElevatePointcardCss = ":host{display:block}.PointsCard .Inner .Row .ExpirationPoints{text-align:left}.PointsCard .Inner .PlayerAvatar .Avatar{display:none}.PointsCard .Inner .PlayerAvatar .Badge{border-radius:50%;background-size:contain;width:100%;height:100%;position:inherit}.PointsCard .Inner .PointsTxt{display:flex;flex-direction:row;justify-content:space-between}.PointsCard .Inner .DetailButton{background:linear-gradient(283.85deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.47%), linear-gradient(117.99deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 33.89%), linear-gradient(268.18deg, rgba(255, 255, 255, 0.6) -17.36%, rgba(239, 239, 239, 0) 15.78%), linear-gradient(0deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6));border-radius:5px;box-shadow:0px 4px 4px 0px rgba(0, 0, 0, 0.25);border:2px solid;font-size:11px;width:108px;padding:4px;cursor:pointer;margin-top:5px;height:16px;min-width:45px;text-align:center}.PointsCard .Inner .DetailButton span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .DetailButton span{display:inline-block;vertical-align:middle}.PointsCard .Inner .DetailButton:hover span{color:var(--emfe-w-color-gray-150, #6D6D6D)}.PointsCard .Inner .LevelInfo{gap:15px;width:70%}.PointsCard .Inner .LevelInfo .PointsTxt{font-size:15px}.PointsCard .Inner .LevelInfo .PointsTxt.Label{display:none}.PointsCard .Inner .LevelInfo .PointsTxt.SPPoints{padding-top:15px}.PointsCard .Inner .LevelInfo .PointsTxt .TC{font-size:x-small;color:var(--emw--color-gray-300, #58586B);display:flex;align-content:center;height:100%;flex-wrap:wrap;text-decoration:underline;cursor:pointer;display:none}";
3083
+
3084
+ const PlayerElevatePointcard = class {
3085
+ constructor(hostRef) {
3086
+ index.registerInstance(this, hostRef);
3087
+ /**
3088
+ * The style that widget shows,available value: Dark, Light
3089
+ * Default: Dark
3090
+ */
3091
+ this.theme = 'Dark';
3092
+ /**
3093
+ * Widget Language to show
3094
+ */
3095
+ this.language = 'en';
3096
+ /**
3097
+ * Check if the card used in points details widget, default: 'earningRule'
3098
+ * value: 'details'/'earningRule'
3099
+ * It effected the button in card
3100
+ * 'earningRule': button text, 'earning rules', post 'BEEPointRulesClicked' when clicked
3101
+ * 'details': button text, 'details', post 'BEEDetailsClicked' when clicked
3102
+ */
3103
+ this.buttonType = 'earningRule';
3104
+ /**
3105
+ * datePattern
3106
+ */
3107
+ this.dateFormat = 'yyyy-MM-dd';
3108
+ /**
3109
+ * Client custom styling via inline styles
3110
+ */
3111
+ this.clientStyling = '';
3112
+ /**
3113
+ * Client custom styling via url
3114
+ */
3115
+ this.clientStylingUrl = '';
3116
+ /**
3117
+ * Translation via url
3118
+ */
3119
+ this.translationUrl = '';
3120
+ this.isPointDetailCard = this.buttonType === 'earningRule';
3121
+ }
3122
+ playerElevateLeveLoadedHandler(event) {
3123
+ if (!event.detail) {
3124
+ return;
3125
+ }
3126
+ if (event.detail['elevateLevelWalletTotal']) {
3127
+ this.elevateWalletTotal = event.detail['elevateLevelWalletTotal'];
3128
+ this.elevateSPTotal = event.detail['loyaltyWalletTotal'];
3129
+ }
3130
+ if (event.detail['elevateLevel']) {
3131
+ this.playerElevateLevel = event.detail['elevateLevel'];
3132
+ }
3133
+ if (event.detail['pointExpireString']) {
3134
+ this.pointExpireString = event.detail.pointExpireString;
3135
+ }
3136
+ }
3137
+ onDetailsClick() {
3138
+ window.postMessage({ type: this.isPointDetailCard ? 'BEEPointRulesClicked' : 'BEEDetailsClicked',
3139
+ path: this.isPointDetailCard ? 'player-elevate-level' : 'player-elevate-point-details' }, window.location.href);
3140
+ }
3141
+ componentWillLoad() {
3142
+ this.paramProxy = {
3143
+ endpoint: this.endpoint,
3144
+ session: this.session,
3145
+ language: this.language,
3146
+ };
3147
+ }
3148
+ render() {
3149
+ const backgroundOuterImagePath = index.getAssetPath('../static/card-ground.svg');
3150
+ const backgroundInnerImagePath = index.getAssetPath('../static/card-ground-over.svg');
3151
+ return (index.h("div", { class: `ElevateCardWrapper ${this.theme}` }, index.h("div", { class: "PointsCard Outer ", style: { 'backgroundImage': `url(${backgroundOuterImagePath}` } }, index.h("general-styling-wrapper", { clientStyling: this.clientStyling, clientStylingUrl: this.clientStylingUrl, targetTranslations: TRANSLATIONS, translationUrl: this.translationUrl }), index.h("player-elevate-card-data", { params: this.paramProxy }), index.h("div", { class: 'OuterCover Inner', style: { 'backgroundImage': `url(${backgroundInnerImagePath}` } }, index.h("div", { class: 'Content Row' }, this.playerElevateLevel && (index.h(index.Fragment, null, index.h("div", { class: "PlayerImg" }, index.h(PlayerAvatar, { onlyBadge: true, loyaltyIconUrl: this.playerElevateLevel.presentation.asset })), index.h("div", { class: `LevelInfo ${this.playerElevateLevel.name}` }, index.h("div", { class: "PointsTxt Label" }, this.cardTitle ? this.cardTitle : translate('spendablePoints')), index.h("div", { class: 'PointsTxt SPPoints' }, index.h(PlayerPoints, { spendablePoints: this.playerElevateLevel.spendablePoints, language: this.language }), index.h("a", { class: "TC", onClick: () => {
3152
+ this.onDetailsClick();
3153
+ } }, translate('termAndConditions', this.language))), this.pointExpireString && (index.h("div", { class: 'ExpirationPoints' }, this.pointExpireString, " "))))))))));
3154
+ }
3155
+ };
3156
+ PlayerElevatePointcard.style = playerElevatePointcardCss;
3157
+
3158
+ exports.general_styling_wrapper = GeneralStylingWrapper;
3159
+ exports.player_elevate_card = PlayerElevateCard;
3160
+ exports.player_elevate_card_data = PlayerElevateCardData;
3161
+ exports.player_elevate_loyaltycard = PlayerElevateLoyaltycard;
3162
+ exports.player_elevate_pointcard = PlayerElevatePointcard;