@maestro_io/maestro-web-sdk 2.1.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/MaestroEventDelegate.d.ts +1 -0
  2. package/dist/components/atoms/Rive/index.d.ts +1 -0
  3. package/dist/components/atoms/SvgIcon/Icon.d.ts +0 -2
  4. package/dist/components/core/ScrollableContainer/ScrollableContainer.d.ts +3 -1
  5. package/dist/components/molecules/ActionButton/ActionButton.d.ts +1 -0
  6. package/dist/components/molecules/PanelNavButton/PanelNavButton.d.ts +1 -0
  7. package/dist/components/organisms/SegmentController/SegmentController.d.ts +2 -2
  8. package/dist/external/spatial-navigation/index.d.ts +2 -3
  9. package/dist/external/spatial-navigation/spatialNavigation.d.ts +3 -5
  10. package/dist/external/spatial-navigation/withFocusable.d.ts +1 -0
  11. package/dist/interfaces/IMaestroEvent.d.ts +14 -0
  12. package/dist/interfaces/IMaestroEventDelegate.d.ts +19 -6
  13. package/dist/maestro-web-sdk.umd.js +3 -3
  14. package/dist/maestro-web-sdk.umd.js.map +1 -1
  15. package/dist/models/IPanel.d.ts +1 -2
  16. package/dist/modules/bets/view/HotProps/HotPropsView.d.ts +7 -6
  17. package/dist/modules/bets/view/SixPack/SixPackView.d.ts +2 -2
  18. package/dist/modules/bets/view/TabLoadFailureView.d.ts +1 -0
  19. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.d.ts +7 -6
  20. package/dist/modules/bets/view/components/Bet/Bet.d.ts +1 -0
  21. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.d.ts +2 -2
  22. package/dist/modules/key-plays/view/KeyPlayCardView.d.ts +0 -4
  23. package/dist/modules/stats/interfaces/IStats.d.ts +44 -15
  24. package/dist/modules/stats/utils/driveSummaryUtils.d.ts +18 -0
  25. package/dist/modules/stats/utils/renderTeamStatistic.d.ts +21 -0
  26. package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.d.ts +21 -0
  27. package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.d.ts +5 -0
  28. package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.d.ts +10 -0
  29. package/dist/modules/stats/view/ActiveAthletes/index.d.ts +2 -0
  30. package/dist/modules/stats/view/DriveSummary/DrivePlayCard.d.ts +26 -0
  31. package/dist/modules/stats/view/DriveSummary/DriveSummary.d.ts +24 -0
  32. package/dist/modules/stats/view/DriveSummary/index.d.ts +2 -0
  33. package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +15 -25
  34. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +13 -47
  35. package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +11 -21
  36. package/dist/modules/stats/view/StatsItemView.d.ts +19 -0
  37. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +1 -0
  38. package/dist/modules/stats/view/StatsView.d.ts +3 -3
  39. package/dist/modules/stats/view/TeamStats/TeamStatsView.d.ts +52 -0
  40. package/dist/modules/stats/view/TeamStats/index.d.ts +2 -0
  41. package/dist/modules/stats/view/Teams/Teams.d.ts +11 -26
  42. package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +11 -21
  43. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.d.ts +19 -3
  44. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +2 -8
  45. package/dist/modules/stats/view/index.d.ts +1 -0
  46. package/dist/modules/stats/view-model/StatsViewModel.d.ts +149 -5
  47. package/dist/services/StatsService.d.ts +36 -0
  48. package/dist/view-models/MaestroEventViewModel.d.ts +7 -0
  49. package/package.json +1 -1
  50. package/dist/MaestroEventDelegate.js +0 -60
  51. package/dist/components/atoms/BaseButton/BaseButton.js +0 -11
  52. package/dist/components/atoms/BaseButton/index.js +0 -2
  53. package/dist/components/atoms/Image/index.js +0 -30
  54. package/dist/components/atoms/Rive/index.js +0 -52
  55. package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +0 -9
  56. package/dist/components/atoms/SvgIcon/BetsIcon.js +0 -11
  57. package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +0 -11
  58. package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +0 -6
  59. package/dist/components/atoms/SvgIcon/CollapseIcon.js +0 -6
  60. package/dist/components/atoms/SvgIcon/ExpandIcon.js +0 -6
  61. package/dist/components/atoms/SvgIcon/FantasyIcon.d.ts +0 -6
  62. package/dist/components/atoms/SvgIcon/FantasyIcon.js +0 -8
  63. package/dist/components/atoms/SvgIcon/FlameIcon.js +0 -11
  64. package/dist/components/atoms/SvgIcon/Icon.js +0 -42
  65. package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +0 -10
  66. package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +0 -11
  67. package/dist/components/atoms/SvgIcon/PlayIcon.js +0 -8
  68. package/dist/components/atoms/SvgIcon/StatsIcon.js +0 -12
  69. package/dist/components/atoms/SvgIcon/TimesIcon.js +0 -6
  70. package/dist/components/atoms/SvgIcon/WarningIcon.js +0 -8
  71. package/dist/components/atoms/SvgIcon/index.js +0 -2
  72. package/dist/components/core/App/App.js +0 -41
  73. package/dist/components/core/App/index.js +0 -2
  74. package/dist/components/core/OverlayContainer.js +0 -58
  75. package/dist/components/core/PanelManager/PanelManager.js +0 -80
  76. package/dist/components/core/PanelManager/index.js +0 -2
  77. package/dist/components/core/ScrollableContainer/FocusableItem.js +0 -38
  78. package/dist/components/core/ScrollableContainer/ScrollableContainer.js +0 -166
  79. package/dist/components/core/ScrollableContainer/index.js +0 -2
  80. package/dist/components/molecules/ActionButton/ActionButton.js +0 -10
  81. package/dist/components/molecules/ActionButton/index.js +0 -2
  82. package/dist/components/molecules/Overlay/Overlay.js +0 -139
  83. package/dist/components/molecules/Overlay/index.js +0 -2
  84. package/dist/components/molecules/PanelNavButton/PanelNavButton.js +0 -40
  85. package/dist/components/molecules/PanelNavButton/index.js +0 -2
  86. package/dist/components/molecules/SegmentButton/SegmentButton.js +0 -10
  87. package/dist/components/molecules/SegmentButton/index.js +0 -2
  88. package/dist/components/molecules/WatchButton/WatchButton.js +0 -15
  89. package/dist/components/molecules/WatchButton/index.js +0 -2
  90. package/dist/components/organisms/PanelNavigation/PanelNavigation.js +0 -72
  91. package/dist/components/organisms/PanelNavigation/index.js +0 -2
  92. package/dist/components/organisms/SegmentController/SegmentController.js +0 -69
  93. package/dist/components/organisms/SegmentController/index.js +0 -2
  94. package/dist/external/AxiosNetworkClient.js +0 -83
  95. package/dist/external/LocalStorageCacheManager.js +0 -213
  96. package/dist/external/ReactRenderer.js +0 -86
  97. package/dist/external/mocks/MockExternalNetworkClient.js +0 -161
  98. package/dist/external/ports/cacheManager.js +0 -1
  99. package/dist/external/ports/networkClient.js +0 -1
  100. package/dist/external/ports/renderer.js +0 -1
  101. package/dist/external/spatial-navigation/index.js +0 -4
  102. package/dist/external/spatial-navigation/measureLayout.js +0 -30
  103. package/dist/external/spatial-navigation/spatialNavigation.js +0 -875
  104. package/dist/external/spatial-navigation/utils.js +0 -6
  105. package/dist/external/spatial-navigation/visualDebugger.js +0 -76
  106. package/dist/external/spatial-navigation/withFocusable.js +0 -238
  107. package/dist/helpers/Observable.js +0 -37
  108. package/dist/helpers/deliver-focus.d.ts +0 -5
  109. package/dist/helpers/deliver-focus.js +0 -12
  110. package/dist/index.js +0 -192
  111. package/dist/interfaces/IMaestroEvent.js +0 -6
  112. package/dist/interfaces/IMaestroEventDelegate.js +0 -1
  113. package/dist/interfaces/IMaestroManager.js +0 -1
  114. package/dist/models/IModel.js +0 -1
  115. package/dist/models/IPanel.js +0 -53
  116. package/dist/models/ITheme.js +0 -20
  117. package/dist/models/IWinningBet.js +0 -1
  118. package/dist/modules/bets/interfaces/IBets.js +0 -1
  119. package/dist/modules/bets/mocks.js +0 -572
  120. package/dist/modules/bets/view/BetsView.js +0 -116
  121. package/dist/modules/bets/view/HotProps/HotPropsView.js +0 -139
  122. package/dist/modules/bets/view/SixPack/SixPackView.js +0 -103
  123. package/dist/modules/bets/view/TabLoadFailureView.js +0 -12
  124. package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +0 -6
  125. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +0 -122
  126. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +0 -34
  127. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +0 -22
  128. package/dist/modules/bets/view/UserBets/Boost/Boost.js +0 -6
  129. package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +0 -9
  130. package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +0 -13
  131. package/dist/modules/bets/view/UserBets/Straight/Straight.js +0 -6
  132. package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +0 -13
  133. package/dist/modules/bets/view/UserBets/UserBetsView.js +0 -114
  134. package/dist/modules/bets/view/components/Bet/Bet.js +0 -32
  135. package/dist/modules/bets/view/components/BetPill/BetPill.js +0 -6
  136. package/dist/modules/bets/view/components/BetsCard/BetsCard.js +0 -15
  137. package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +0 -20
  138. package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +0 -14
  139. package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +0 -16
  140. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +0 -63
  141. package/dist/modules/bets/view/components/PromoCodeBanner/index.js +0 -1
  142. package/dist/modules/bets/view-model/BetsViewModel.js +0 -767
  143. package/dist/modules/key-plays/constants.js +0 -292
  144. package/dist/modules/key-plays/interfaces/IKeyPlays.js +0 -14
  145. package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +0 -1
  146. package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +0 -13
  147. package/dist/modules/key-plays/view/KeyPlayCardView.js +0 -142
  148. package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +0 -58
  149. package/dist/modules/key-plays/view/KeyPlaysView.js +0 -167
  150. package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +0 -182
  151. package/dist/modules/stats/interfaces/IStats.js +0 -1
  152. package/dist/modules/stats/mocks.js +0 -546
  153. package/dist/modules/stats/utils.js +0 -62
  154. package/dist/modules/stats/view/GameLeaders/GameLeaders.js +0 -9
  155. package/dist/modules/stats/view/GameLeaders/index.js +0 -2
  156. package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +0 -55
  157. package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +0 -1
  158. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +0 -66
  159. package/dist/modules/stats/view/MatchPredictor/index.js +0 -2
  160. package/dist/modules/stats/view/RecentGames/RecentGames.js +0 -22
  161. package/dist/modules/stats/view/RecentGames/index.js +0 -2
  162. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +0 -38
  163. package/dist/modules/stats/view/StatsQRCode/index.js +0 -1
  164. package/dist/modules/stats/view/StatsView.js +0 -87
  165. package/dist/modules/stats/view/Teams/StatsCarousel.js +0 -14
  166. package/dist/modules/stats/view/Teams/StatsProgressBar.js +0 -14
  167. package/dist/modules/stats/view/Teams/Teams.js +0 -35
  168. package/dist/modules/stats/view/Teams/index.js +0 -2
  169. package/dist/modules/stats/view/WinProbability/WinProbability.js +0 -27
  170. package/dist/modules/stats/view/WinProbability/index.js +0 -2
  171. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +0 -28
  172. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +0 -11
  173. package/dist/modules/stats/view/components/AthletesStatistics/index.js +0 -2
  174. package/dist/modules/stats/view/index.js +0 -1
  175. package/dist/modules/stats/view-model/StatsViewModel.js +0 -90
  176. package/dist/services/BetsService.js +0 -102
  177. package/dist/services/NetworkManager/NetworkManager.js +0 -410
  178. package/dist/services/NetworkManager/errors.js +0 -45
  179. package/dist/services/ThemeManager/constants.js +0 -47
  180. package/dist/test-polyfills.js +0 -15
  181. package/dist/types/OverlayTypes.js +0 -4
  182. package/dist/view-models/MaestroEventViewModel.js +0 -156
  183. package/dist/view-models/OverlayViewModel.js +0 -222
  184. package/dist/view-models/PanelManagerViewModel.js +0 -80
  185. package/dist/view-models/ViewModel.js +0 -32
  186. package/dist/view-models/index.js +0 -59
@@ -1,167 +0,0 @@
1
- import React, { Component } from 'react';
2
- import KeyPlayCardView from './KeyPlayCardView';
3
- import './KeyPlaysView.styles.css';
4
- import KeyPlayErrorStateView from './KeyPlayErrorStateView';
5
- import SDK from '@/index';
6
- import { setFocus } from '@/external/spatial-navigation';
7
- import ScrollableContainer from '@/components/core/ScrollableContainer';
8
- const STICKY_HEADER_HEIGHT = 32;
9
- export class KeyPlays extends Component {
10
- constructor(props) {
11
- super(props);
12
- Object.defineProperty(this, "container", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: null
17
- });
18
- Object.defineProperty(this, "playbackProgressUnsub", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: null
23
- });
24
- Object.defineProperty(this, "playbackIndexUnsub", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: null
29
- });
30
- Object.defineProperty(this, "itemsUnsub", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: null
35
- });
36
- Object.defineProperty(this, "vm", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- Object.defineProperty(this, "handlePlayClip", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: (index) => async () => {
47
- await this.vm.playKeyPlay(index);
48
- }
49
- });
50
- this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
51
- const rawSections = this.vm.items.value;
52
- this.state = {
53
- scrollableContainer: null,
54
- playbackProgress: this.vm.currentClipPlaybackProgress.value ?? null,
55
- playbackIndex: this.vm.currentlyPlayingClipIndex.value ?? null,
56
- items: rawSections.map((section) => ({
57
- title: section.title,
58
- items: section.items.map((item) => ({
59
- id: item.id,
60
- clipID: item.clipID,
61
- awayTeamScore: item.awayTeamScore,
62
- homeTeamScore: item.homeTeamScore,
63
- awayTeamName: item.awayTeamName,
64
- homeTeamName: item.homeTeamName,
65
- description: item.description,
66
- playerImageUrl: item.playerImageUrl || '',
67
- teamImageUrl: item.teamImageUrl || '',
68
- thumbnailImageUrl: item.thumbnailImageUrl || '',
69
- })),
70
- })),
71
- };
72
- }
73
- componentDidMount() {
74
- this.playbackProgressUnsub = this.vm.currentClipPlaybackProgress.subscribe((value) => {
75
- this.setState({ playbackProgress: value ?? null });
76
- });
77
- this.playbackIndexUnsub = this.vm.currentlyPlayingClipIndex.subscribe((value) => {
78
- this.setState({ playbackIndex: value ?? null });
79
- });
80
- this.itemsUnsub = this.vm.items.subscribe((rawSections) => {
81
- this.setState({
82
- items: rawSections.map((section) => ({
83
- title: section.title,
84
- items: section.items.map((item) => ({
85
- id: item.id,
86
- clipID: item.clipID,
87
- awayTeamScore: item.awayTeamScore,
88
- homeTeamScore: item.homeTeamScore,
89
- awayTeamName: item.awayTeamName,
90
- homeTeamName: item.homeTeamName,
91
- description: item.description,
92
- playerImageUrl: item.playerImageUrl || '',
93
- teamImageUrl: item.teamImageUrl || '',
94
- thumbnailImageUrl: item.thumbnailImageUrl || '',
95
- })),
96
- })),
97
- });
98
- });
99
- this.setState({
100
- scrollableContainer: this.container,
101
- });
102
- }
103
- componentWillUnmount() {
104
- this.playbackProgressUnsub && this.playbackProgressUnsub();
105
- this.playbackIndexUnsub && this.playbackIndexUnsub();
106
- this.itemsUnsub && this.itemsUnsub();
107
- }
108
- render() {
109
- const { playbackProgress, playbackIndex, items, scrollableContainer, } = this.state;
110
- return (React.createElement(ScrollableContainer, { scrollableContainerRef: scrollableContainer, containerTopOffset: STICKY_HEADER_HEIGHT },
111
- React.createElement("div", { ref: (el) => {
112
- this.container = el;
113
- }, className: "key-plays-view" },
114
- items.map((section, sectionIndex) => (React.createElement("div", { key: `section-${sectionIndex}`, className: "key-plays-section" },
115
- React.createElement("h3", { className: "key-plays-section-title T10" }, section.title),
116
- React.createElement("div", { className: "key-plays-section-items" }, section.items.map((item) => {
117
- const absoluteIndex = this.vm.allItems.findIndex((vmItem) => vmItem.id === item.id);
118
- return (React.createElement(KeyPlayCardView, { key: item.id, id: item.id, clipID: item.clipID, description: item.description, awayTeamName: item.awayTeamName, homeTeamName: item.homeTeamName, awayTeamScore: item.awayTeamScore, homeTeamScore: item.homeTeamScore, playerImageUrl: item.playerImageUrl, teamImageUrl: item.teamImageUrl, thumbnailImageUrl: item.thumbnailImageUrl, isPlaying: this.vm.isCurrentlyPlaying(absoluteIndex), isScoring: Boolean(item.awayTeamScore && item.homeTeamScore), playbackProgress: absoluteIndex === playbackIndex
119
- ? playbackProgress
120
- : null, onEnterPress: this.handlePlayClip(absoluteIndex) }));
121
- }))))),
122
- React.createElement("div", { className: "key-plays-bottom-padding" }))));
123
- }
124
- }
125
- export default class KeyPlaysWithErrorState extends Component {
126
- constructor(props) {
127
- super(props);
128
- Object.defineProperty(this, "errorStateUnsub", {
129
- enumerable: true,
130
- configurable: true,
131
- writable: true,
132
- value: null
133
- });
134
- Object.defineProperty(this, "vm", {
135
- enumerable: true,
136
- configurable: true,
137
- writable: true,
138
- value: void 0
139
- });
140
- Object.defineProperty(this, "handleRetry", {
141
- enumerable: true,
142
- configurable: true,
143
- writable: true,
144
- value: async () => {
145
- await this.vm.userRequestedNewKeyPlaysData();
146
- setFocus('PANEL_NAV_BUTTON_0');
147
- }
148
- });
149
- this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
150
- this.state = { errorState: this.vm.errorState.value };
151
- }
152
- componentDidMount() {
153
- this.errorStateUnsub = this.vm.errorState.subscribe((value) => {
154
- this.setState({ errorState: value });
155
- });
156
- }
157
- componentWillUnmount() {
158
- this.errorStateUnsub && this.errorStateUnsub();
159
- }
160
- render() {
161
- const { errorState } = this.state;
162
- if (errorState) {
163
- return (React.createElement(KeyPlayErrorStateView, { errorState: errorState, onRetry: this.handleRetry }));
164
- }
165
- return React.createElement(KeyPlays, null);
166
- }
167
- }
@@ -1,182 +0,0 @@
1
- import SDK from '@/index';
2
- import { Observable } from '@/helpers/Observable';
3
- class KeyPlaysViewModel {
4
- constructor() {
5
- Object.defineProperty(this, "currentlyPlayingClipIndex", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: new Observable(null)
10
- });
11
- Object.defineProperty(this, "lastPlayedClipIndex", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: new Observable(null)
16
- });
17
- Object.defineProperty(this, "currentClipPlaybackProgress", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: new Observable(null)
22
- });
23
- Object.defineProperty(this, "errorState", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: new Observable('unpopulatedEvent')
28
- });
29
- Object.defineProperty(this, "failedClips", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: new Observable({})
34
- });
35
- Object.defineProperty(this, "items", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: new Observable([])
40
- });
41
- }
42
- isCurrentlyPlaying(index) {
43
- return index === this.currentlyPlayingClipIndex.value;
44
- }
45
- async setKeyPlays(items) {
46
- if (items === null) {
47
- this.errorState.value = 'tabLoadFailure';
48
- return;
49
- }
50
- this.items.value = this.parseNetworkResponse(items);
51
- this.cleanErrors();
52
- }
53
- cleanErrors() {
54
- if (this.errorState.value === 'tabLoadFailure') {
55
- this.errorState.value = null;
56
- }
57
- if (this.errorState.value === 'unpopulatedEvent' && this.allItems.length) {
58
- this.errorState.value = null;
59
- }
60
- if (!this.allItems.length) {
61
- this.errorState.value = 'unpopulatedEvent';
62
- }
63
- }
64
- async playKeyPlay(atIndex) {
65
- const mevm = SDK.getMaestroEventViewModel();
66
- mevm.delegate.playClip(atIndex);
67
- }
68
- parseNetworkResponse(response) {
69
- const teams = Object.values(response.entities.team);
70
- const athletes = Object.values(response.entities.athlete);
71
- const homeTeam = teams.find((team) => team.homeAway === 'home');
72
- const awayTeam = teams.find((team) => team.homeAway === 'away');
73
- if (!homeTeam || !awayTeam) {
74
- console.warn('Could not find home or away team');
75
- return [];
76
- }
77
- const items = [];
78
- const result = [];
79
- for (const section of response.sections) {
80
- for (const keyPlay of section.items) {
81
- const playTeam = keyPlay.team
82
- ? teams.find((team) => team.id === keyPlay.team)
83
- : undefined;
84
- const athlete = keyPlay.athlete
85
- ? athletes.find((a) => a.id === keyPlay.athlete)
86
- : undefined;
87
- const teamImageUrl = playTeam ? playTeam.logoRef : undefined;
88
- const playerImageUrl = athlete ? athlete.headshot : undefined;
89
- const thumbnailImageUrl = keyPlay.thumbnailType !== 'headshot' ? keyPlay.thumbnail : undefined;
90
- const homeScore = keyPlay.homeScore ? keyPlay.homeScore : '0';
91
- const awayScore = keyPlay.awayScore ? keyPlay.awayScore : '0';
92
- const homeTeamScore = keyPlay.scoringPlay
93
- ? parseInt(homeScore)
94
- : undefined;
95
- const awayTeamScore = keyPlay.scoringPlay
96
- ? parseInt(awayScore)
97
- : undefined;
98
- const randomId = Math.random().toString(36).substring(2, 15);
99
- const keyPlayData = {
100
- id: randomId,
101
- description: keyPlay.description ? keyPlay.description : '',
102
- homeTeamName: homeTeam ? homeTeam.shortName : '',
103
- awayTeamName: awayTeam ? awayTeam.shortName : '',
104
- homeTeamScore,
105
- awayTeamScore,
106
- clipID: keyPlay.clipID,
107
- teamImageUrl,
108
- playerImageUrl,
109
- thumbnailImageUrl,
110
- section: section.title,
111
- };
112
- items.push(keyPlayData);
113
- }
114
- // Only add the section if it has items
115
- if (items.length) {
116
- const sectionTitle = section.title;
117
- const existingSection = result.find((item) => item.title === sectionTitle);
118
- if (existingSection) {
119
- existingSection.items.push(...items);
120
- }
121
- else {
122
- result.push({
123
- title: sectionTitle,
124
- items: [...items],
125
- });
126
- }
127
- // Reset items for the next section
128
- items.length = 0;
129
- }
130
- }
131
- return result;
132
- }
133
- get allItems() {
134
- return this.items.value.reduce((acc, section) => {
135
- return acc.concat(section.items);
136
- }, []);
137
- }
138
- clipID(forKeyPlayAtIndex) {
139
- const item = this.allItems[forKeyPlayAtIndex];
140
- if (!item) {
141
- return undefined;
142
- }
143
- return this.allItems[forKeyPlayAtIndex].clipID;
144
- }
145
- handleKeyPlayLoadFailure(forKeyPlayAtIndex) {
146
- const clipID = this.clipID(forKeyPlayAtIndex);
147
- if (clipID) {
148
- const newFailedClips = this.failedClips.value;
149
- newFailedClips[clipID] = 'recentFailure';
150
- this.failedClips.value = newFailedClips;
151
- setTimeout(() => {
152
- if (this.loadFailureStatus(forKeyPlayAtIndex) === 'recentFailure') {
153
- const newFailedClips = this.failedClips.value;
154
- newFailedClips[clipID] = 'nonRecentFailure';
155
- this.failedClips.value = newFailedClips;
156
- }
157
- }, 5000);
158
- }
159
- }
160
- loadFailureStatus(forKeyPlayAtIndex) {
161
- const clipID = this.clipID(forKeyPlayAtIndex);
162
- const newFailedClips = this.failedClips.value;
163
- if (!newFailedClips) {
164
- return 'noFailure';
165
- }
166
- return clipID ? this.failedClips.value[clipID] : 'noFailure';
167
- }
168
- clearLoadFailureStatus(forKeyPlayAtIndex) {
169
- const clipID = this.clipID(forKeyPlayAtIndex);
170
- if (clipID && this.failedClips) {
171
- this.failedClips.value = {
172
- ...this.failedClips.value,
173
- [clipID]: 'noFailure',
174
- };
175
- }
176
- }
177
- async userRequestedNewKeyPlaysData() {
178
- const mevm = SDK.getMaestroEventViewModel();
179
- await mevm.delegate.userRequestedNewKeyPlaysData();
180
- }
181
- }
182
- export default KeyPlaysViewModel;
@@ -1 +0,0 @@
1
- export {};