@cuemath/leap 2.8.21-rj-9 → 2.8.21-rj-10

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.
@@ -1,5 +1,6 @@
1
- const _ = 500, E = 1500, S = 3e3;
1
+ const _ = 500, E = 1500, S = 3e3, T = 200;
2
2
  export {
3
+ T as FIRST_COACHMARK_AFTER_MS,
3
4
  _ as GO_TO_NEXT_SLIDE_AFTER_MS,
4
5
  E as SHOW_LABEL_HIGHLIGHT_AFTER_MS,
5
6
  S as SHOW_NUDGE_AFTER_MS
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../src/features/circle-games/game-launcher/use-game-launcher-journey/constants.ts"],"sourcesContent":["export const GO_TO_NEXT_SLIDE_AFTER_MS = 500;\nexport const SHOW_LABEL_HIGHLIGHT_AFTER_MS = 1500;\nexport const SHOW_NUDGE_AFTER_MS = 3000;\n"],"names":["GO_TO_NEXT_SLIDE_AFTER_MS","SHOW_LABEL_HIGHLIGHT_AFTER_MS","SHOW_NUDGE_AFTER_MS"],"mappings":"AAAO,MAAMA,IAA4B,KAC5BC,IAAgC,MAChCC,IAAsB;"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../src/features/circle-games/game-launcher/use-game-launcher-journey/constants.ts"],"sourcesContent":["export const GO_TO_NEXT_SLIDE_AFTER_MS = 500;\nexport const SHOW_LABEL_HIGHLIGHT_AFTER_MS = 1500;\nexport const SHOW_NUDGE_AFTER_MS = 3000;\nexport const FIRST_COACHMARK_AFTER_MS = 200;\n"],"names":["GO_TO_NEXT_SLIDE_AFTER_MS","SHOW_LABEL_HIGHLIGHT_AFTER_MS","SHOW_NUDGE_AFTER_MS","FIRST_COACHMARK_AFTER_MS"],"mappings":"AAAO,MAAMA,IAA4B,KAC5BC,IAAgC,MAChCC,IAAsB,KACtBC,IAA2B;"}
@@ -1,51 +1,50 @@
1
1
  import { jsx as e, Fragment as R } from "react/jsx-runtime";
2
- import { useRef as u, useCallback as b, useMemo as Q } from "react";
2
+ import { useRef as u, useCallback as E, useMemo as Q } from "react";
3
3
  import V from "../../../../assets/line-icons/icons/next.js";
4
4
  import { IndicatorType as s } from "../../../journey/use-journey/constants.js";
5
5
  import { useJourney as j } from "../../../journey/use-journey/use-journey.js";
6
6
  import Z from "../../../ui/buttons/icon-button/icon-button.js";
7
- import C from "../../../ui/layout/flex-view.js";
7
+ import b from "../../../ui/layout/flex-view.js";
8
8
  import d from "../../../ui/text/text.js";
9
9
  import { useCircleSounds as z } from "../../hooks/use-circle-sounds/use-circle-sounds.js";
10
10
  import { SegmentedGameCard as ee } from "../comps/segmented-game-card/segmented-game-card.js";
11
- import { GO_TO_NEXT_SLIDE_AFTER_MS as te, SHOW_LABEL_HIGHLIGHT_AFTER_MS as re, SHOW_NUDGE_AFTER_MS as ne } from "./constants.js";
12
- import { ProjectType as ie } from "../../games/web-view/enums/project-type-enum.js";
11
+ import { GO_TO_NEXT_SLIDE_AFTER_MS as te, SHOW_LABEL_HIGHLIGHT_AFTER_MS as re, SHOW_NUDGE_AFTER_MS as ne, FIRST_COACHMARK_AFTER_MS as ie } from "./constants.js";
12
+ import { ProjectType as oe } from "../../games/web-view/enums/project-type-enum.js";
13
13
  const Ee = ({
14
- onSegmentClick: L,
15
- setCarouselIndex: H,
16
- onJourneyComplete: A
14
+ onSegmentClick: C,
15
+ setCarouselIndex: A,
16
+ onJourneyComplete: L
17
17
  }) => {
18
- const c = u(null), i = u(null), t = u(null), a = u(null), E = u(!1), { playButtonSound: O } = z(), { nextCoachmark: o, setJourney: y } = j(), h = b(
18
+ const c = u(null), i = u(null), t = u(null), a = u(null), T = u(!1), { playButtonSound: H } = z(), { nextCoachmark: o, setJourney: O } = j(), h = E(
19
19
  (n, l, r, m = !1) => {
20
- m || (O(), H((T) => T + 1), o(r, !1, te));
20
+ m || (H(), A((p) => p + 1), o(r, !1, te));
21
21
  const f = setTimeout(() => {
22
22
  clearTimeout(f), n.startLabelAnimation(l);
23
- }, re), p = setTimeout(() => {
24
- clearTimeout(p), o(r, !0);
25
- }, ne);
23
+ }, re);
24
+ o(r, !0, ne);
26
25
  },
27
- [o, O, H]
28
- ), P = b(
26
+ [o, H, A]
27
+ ), _ = E(
29
28
  (n, l) => {
30
- L(n, ie.PUZZLE), o(l), A(l);
29
+ C(n, oe.PUZZLE), o(l), L(l);
31
30
  },
32
- [o, A, L]
33
- ), _ = b(
31
+ [o, L, C]
32
+ ), y = E(
34
33
  (n, l, r) => {
35
- var k, v, G, S, B, N, x, I, U, $, W, X, Y, D, F, J, M;
36
- if (E.current || !((k = c == null ? void 0 : c.current) != null && k.nextBtnRef.current) || !((v = t == null ? void 0 : t.current) != null && v.segmentedCardWrapperRef.current) || !((G = i == null ? void 0 : i.current) != null && G.labelRef.current) || !((S = t == null ? void 0 : t.current) != null && S.labelRef.current) || !n)
34
+ var k, S, v, G, B, I, x, N, U, $, W, F, X, M, Y, D, J;
35
+ if (T.current || !((k = c == null ? void 0 : c.current) != null && k.nextBtnRef.current) || !((S = t == null ? void 0 : t.current) != null && S.segmentedCardWrapperRef.current) || !((v = i == null ? void 0 : i.current) != null && v.labelRef.current) || !((G = t == null ? void 0 : t.current) != null && G.labelRef.current) || !n)
37
36
  return;
38
- E.current = !0;
39
- const m = ((x = (N = (B = a.current) == null ? void 0 : B.labelRef) == null ? void 0 : N.current) == null ? void 0 : x.getBoundingClientRect()) || {
37
+ T.current = !0;
38
+ const m = ((x = (I = (B = a.current) == null ? void 0 : B.labelRef) == null ? void 0 : I.current) == null ? void 0 : x.getBoundingClientRect()) || {
40
39
  height: 0,
41
40
  width: 0
42
- }, f = (($ = (U = (I = i.current) == null ? void 0 : I.labelRef) == null ? void 0 : U.current) == null ? void 0 : $.getBoundingClientRect()) || {
41
+ }, f = (($ = (U = (N = i.current) == null ? void 0 : N.labelRef) == null ? void 0 : U.current) == null ? void 0 : $.getBoundingClientRect()) || {
43
42
  height: 0,
44
43
  width: 0
45
- }, p = ((Y = (X = (W = t.current) == null ? void 0 : W.labelRef) == null ? void 0 : X.current) == null ? void 0 : Y.getBoundingClientRect()) || {
44
+ }, p = ((X = (F = (W = t.current) == null ? void 0 : W.labelRef) == null ? void 0 : F.current) == null ? void 0 : X.getBoundingClientRect()) || {
46
45
  height: 0,
47
46
  width: 0
48
- }, T = ((J = (F = (D = t.current) == null ? void 0 : D.segmentedCardWrapperRef) == null ? void 0 : F.current) == null ? void 0 : J.getBoundingClientRect()) || {
47
+ }, P = ((D = (Y = (M = t.current) == null ? void 0 : M.segmentedCardWrapperRef) == null ? void 0 : Y.current) == null ? void 0 : D.getBoundingClientRect()) || {
49
48
  height: 0,
50
49
  width: 0
51
50
  };
@@ -60,13 +59,13 @@ const Ee = ({
60
59
  position: "right",
61
60
  backgroundColor: "BLUE_4",
62
61
  width: 264,
63
- tooltipItem: /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Get faster & stay ahead in school. Practice 3 new skills everyday." }) }),
62
+ tooltipItem: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Get faster & stay ahead in school. Practice 3 new skills everyday." }) }),
64
63
  tooltipXCoOrdinates: m.width,
65
64
  tooltipYCoOrdinates: m.height / 2
66
65
  }
67
66
  },
68
67
  {
69
- originalElementToHighlightRef: (M = c.current) == null ? void 0 : M.nextBtnRef,
68
+ originalElementToHighlightRef: (J = c.current) == null ? void 0 : J.nextBtnRef,
70
69
  isActive: !1,
71
70
  type: s.NUDGE,
72
71
  elementToHighlight: /* @__PURE__ */ e(
@@ -86,7 +85,7 @@ const Ee = ({
86
85
  }
87
86
  }
88
87
  ]);
89
- const q = [
88
+ const K = [
90
89
  {
91
90
  originalElementToHighlightRef: i.current.labelRef,
92
91
  isActive: !1,
@@ -96,7 +95,7 @@ const Ee = ({
96
95
  position: "right",
97
96
  backgroundColor: "ORANGE_4",
98
97
  width: 264,
99
- tooltipItem: /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Train to think deeper & plan ahead. Play 3 new games everyday." }) }),
98
+ tooltipItem: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Train to think deeper & plan ahead. Play 3 new games everyday." }) }),
100
99
  tooltipXCoOrdinates: f.width,
101
100
  tooltipYCoOrdinates: f.height / 2
102
101
  }
@@ -121,7 +120,7 @@ const Ee = ({
121
120
  nudgePointerY: 0
122
121
  }
123
122
  }
124
- ], K = [
123
+ ], q = [
125
124
  {
126
125
  originalElementToHighlightRef: t.current.labelRef,
127
126
  isActive: !1,
@@ -131,7 +130,7 @@ const Ee = ({
131
130
  position: "right",
132
131
  backgroundColor: "PURPLE_4",
133
132
  width: 264,
134
- tooltipItem: /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Think in new ways & stay sharp. Solve 3 new puzzles everyday." }) }),
133
+ tooltipItem: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(d, { $renderAs: "ab2-bold", children: "Think in new ways & stay sharp. Solve 3 new puzzles everyday." }) }),
135
134
  tooltipXCoOrdinates: p.width,
136
135
  tooltipYCoOrdinates: p.height / 2
137
136
  }
@@ -152,21 +151,21 @@ const Ee = ({
152
151
  name: "",
153
152
  // We dont want to show the name of the puzzle in onboarding
154
153
  isCompleted: g.solved,
155
- onPress: () => P(g, r)
154
+ onPress: () => _(g, r)
156
155
  }))
157
156
  }
158
157
  ),
159
158
  indicator: {
160
159
  nudge: "click",
161
160
  content: /* @__PURE__ */ e(d, { $renderAs: "ab1", $color: "WHITE", children: "Click to solve a puzzle" }),
162
- nudgePointerX: T.width * 0.6,
163
- nudgePointerY: T.height * 0.4
161
+ nudgePointerX: P.width * 0.6,
162
+ nudgePointerY: P.height * 0.4
164
163
  }
165
164
  }
166
165
  ];
167
- y(r, [...w, ...q, ...K]), o(r, !0), l && a.current ? h(a.current, "BLUE_4", r, !0) : h(i.current, "ORANGE_4", r, !0);
166
+ O(r, [...w, ...K, ...q]), o(r, !1, ie), l && a.current ? h(a.current, "BLUE_4", r, !0) : h(i.current, "ORANGE_4", r, !0);
168
167
  },
169
- [P, h, o, y]
168
+ [_, h, o, O]
170
169
  );
171
170
  return Q(
172
171
  () => ({
@@ -174,10 +173,10 @@ const Ee = ({
174
173
  puzzleRefs: t,
175
174
  lessonRefs: a,
176
175
  carouselNextBtnRef: c,
177
- isJourneyInProgress: E,
178
- startJourney: _
176
+ isJourneyInProgress: T,
177
+ startJourney: y
179
178
  }),
180
- [_]
179
+ [y]
181
180
  );
182
181
  };
183
182
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"use-game-launcher-journey.js","sources":["../../../../../src/features/circle-games/game-launcher/use-game-launcher-journey/use-game-launcher-journey.tsx"],"sourcesContent":["import type { TJourneyId } from '../../../journey/journey-id/journey-id-types';\nimport type { ICoachmarkProps } from '../../../journey/use-journey/journey-context-types';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport type { INudgeProps } from '../../../ui/nudge/nudge-types';\nimport type { TColorNames } from '../../../ui/types';\nimport type { ICarouselRefs } from '../comps/carousel/carousel-types';\nimport type { ISegmentedGameCardRefs } from '../comps/segmented-game-card/segmented-game-card-types';\nimport type {\n IProject,\n Puzzle,\n} from '../dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IUseGameLauncherJourneyProps } from './use-game-launcher-journey-types';\n\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport NextIcon from '../../../../assets/line-icons/icons/next';\nimport { IndicatorType } from '../../../journey/use-journey/constants';\nimport { useJourney } from '../../../journey/use-journey/use-journey';\nimport IconButton from '../../../ui/buttons/icon-button/icon-button';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Text from '../../../ui/text/text';\nimport { ProjectType } from '../../games/web-view/enums';\nimport { useCircleSounds } from '../../hooks/use-circle-sounds/use-circle-sounds';\nimport { SegmentedGameCard } from '../comps/segmented-game-card/segmented-game-card';\nimport {\n GO_TO_NEXT_SLIDE_AFTER_MS,\n SHOW_LABEL_HIGHLIGHT_AFTER_MS,\n SHOW_NUDGE_AFTER_MS,\n} from './constants';\n\nexport const useGameLauncherJourney = ({\n onSegmentClick,\n setCarouselIndex,\n onJourneyComplete,\n}: IUseGameLauncherJourneyProps) => {\n const carouselNextBtnRef = useRef<ICarouselRefs>(null);\n const gameRefs = useRef<ISegmentedGameCardRefs>(null);\n const puzzleRefs = useRef<ISegmentedGameCardRefs>(null);\n const lessonRefs = useRef<ISegmentedGameCardRefs>(null);\n\n const isJourneyInProgress = useRef(false);\n\n const { playButtonSound } = useCircleSounds();\n const { nextCoachmark, setJourney } = useJourney();\n\n const goToNextCard = useCallback(\n (\n refOfNextSlide: ISegmentedGameCardRefs,\n color: TColorNames,\n journeyId: TJourneyId,\n isFirstSlide: boolean = false,\n ) => {\n if (!isFirstSlide) {\n playButtonSound();\n setCarouselIndex((prev: number) => prev + 1);\n nextCoachmark(journeyId, false, GO_TO_NEXT_SLIDE_AFTER_MS);\n }\n\n const animateLabelTimer = setTimeout(() => {\n clearTimeout(animateLabelTimer);\n refOfNextSlide.startLabelAnimation(color);\n }, SHOW_LABEL_HIGHLIGHT_AFTER_MS);\n\n const showNudgeTimer = setTimeout(() => {\n clearTimeout(showNudgeTimer);\n nextCoachmark(journeyId, true);\n }, SHOW_NUDGE_AFTER_MS);\n },\n [nextCoachmark, playButtonSound, setCarouselIndex],\n );\n\n const endJourney = useCallback(\n (puzzlesData: Puzzle, journeyId: TJourneyId) => {\n onSegmentClick(puzzlesData, ProjectType.PUZZLE);\n nextCoachmark(journeyId);\n onJourneyComplete(journeyId);\n },\n [nextCoachmark, onJourneyComplete, onSegmentClick],\n );\n\n const startJourney = useCallback(\n (puzzlesData: IProject<Puzzle>, isLessonAvailable: boolean, journeyId: TJourneyId) => {\n if (isJourneyInProgress.current) {\n return;\n }\n\n // If element refs are not available return, this is just for type safety\n if (\n !carouselNextBtnRef?.current?.nextBtnRef.current ||\n !puzzleRefs?.current?.segmentedCardWrapperRef.current ||\n !gameRefs?.current?.labelRef.current ||\n !puzzleRefs?.current?.labelRef.current ||\n !puzzlesData\n ) {\n return;\n }\n\n isJourneyInProgress.current = true;\n const lessonLabelDims = lessonRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const gameLabelDims = gameRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const puzzleLabelDims = puzzleRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n const launcherDims =\n puzzleRefs.current?.segmentedCardWrapperRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n let lessonSteps: ICoachmarkProps[] = [];\n\n if (isLessonAvailable && lessonRefs.current) {\n lessonSteps = [\n {\n originalElementToHighlightRef: lessonRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'BLUE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Get faster & stay ahead in school. Practice 3 new skills everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: lessonLabelDims.width,\n tooltipYCoOrdinates: lessonLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current?.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(gameRefs.current as ISegmentedGameCardRefs, 'ORANGE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to proceed\n </Text>\n ),\n nudgePointerX: 0,\n nudgePointerY: 0,\n } as INudgeProps,\n },\n ];\n }\n\n const gameSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: gameRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'ORANGE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Train to think deeper & plan ahead. Play 3 new games everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: gameLabelDims.width,\n tooltipYCoOrdinates: gameLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(puzzleRefs.current as ISegmentedGameCardRefs, 'PURPLE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to proceed\n </Text>\n ),\n nudgePointerX: 0,\n nudgePointerY: 0,\n } as INudgeProps,\n },\n ];\n\n const puzzleSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: puzzleRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'PURPLE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Think in new ways & stay sharp. Solve 3 new puzzles everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: puzzleLabelDims.width,\n tooltipYCoOrdinates: puzzleLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: puzzleRefs.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <SegmentedGameCard\n label={''} // This is intentionally left blank to avoid showing the label\n value={puzzlesData.data.filter(puzzle => puzzle.solved).length}\n maxValue={puzzlesData.data.length}\n initialValue={puzzlesData.initialProgressValue}\n data={puzzlesData.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: '', // We dont want to show the name of the puzzle in onboarding\n isCompleted: puzzle.solved,\n onPress: () => endJourney(puzzle, journeyId),\n }))}\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to solve a puzzle\n </Text>\n ),\n nudgePointerX: launcherDims.width * 0.6,\n nudgePointerY: launcherDims.height * 0.4,\n } as INudgeProps,\n },\n ];\n\n setJourney(journeyId, [...lessonSteps, ...gameSteps, ...puzzleSteps]);\n\n nextCoachmark(journeyId, true);\n if (isLessonAvailable && lessonRefs.current) {\n goToNextCard(lessonRefs.current, 'BLUE_4', journeyId, true);\n } else {\n goToNextCard(gameRefs.current, 'ORANGE_4', journeyId, true);\n }\n },\n [endJourney, goToNextCard, nextCoachmark, setJourney],\n );\n\n const data = useMemo(\n () => ({\n gameRefs,\n puzzleRefs,\n lessonRefs,\n carouselNextBtnRef,\n isJourneyInProgress,\n startJourney,\n }),\n [startJourney],\n );\n\n return data;\n};\n"],"names":["useGameLauncherJourney","onSegmentClick","setCarouselIndex","onJourneyComplete","carouselNextBtnRef","useRef","gameRefs","puzzleRefs","lessonRefs","isJourneyInProgress","playButtonSound","useCircleSounds","nextCoachmark","setJourney","useJourney","goToNextCard","useCallback","refOfNextSlide","color","journeyId","isFirstSlide","prev","GO_TO_NEXT_SLIDE_AFTER_MS","animateLabelTimer","SHOW_LABEL_HIGHLIGHT_AFTER_MS","showNudgeTimer","SHOW_NUDGE_AFTER_MS","endJourney","puzzlesData","ProjectType","startJourney","isLessonAvailable","_a","_b","_c","_d","lessonLabelDims","_g","_f","_e","gameLabelDims","_j","_i","_h","puzzleLabelDims","_m","_l","_k","launcherDims","_p","_o","_n","lessonSteps","IndicatorType","jsx","Fragment","FlexView","Text","_q","IconButton","NextIcon","gameSteps","puz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AO,SAAQ,UAErC,2BAAA;AAAA,YAEF,eAAeT,EAAa,QAAQ;AAAA,YACpC,eAAeA,EAAa,SAAS;AAAA,UACvC;AAAA,QACF;AAAA,MAAA;AAGS,MAAAnC,EAAAM,GAAW,CAAC,GAAGiC,GAAa,GAAGS,GAAW,GAAGC,CAAW,CAAC,GAEpElD,EAAcO,GAAW,EAAI,GACzBY,KAAqBvB,EAAW,UAClCO,EAAaP,EAAW,SAAS,UAAUW,GAAW,EAAI,IAE1DJ,EAAaT,EAAS,SAAS,YAAYa,GAAW,EAAI;AAAA,IAE9D;AAAA,IACA,CAACQ,GAAYZ,GAAcH,GAAeC,CAAU;AAAA,EAAA;AAe/C,SAZMoD;AAAA,IACX,OAAO;AAAA,MACL,UAAA3D;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,oBAAAJ;AAAA,MACA,qBAAAK;AAAA,MACA,cAAAqB;AAAA,IAAA;AAAA,IAEF,CAACA,CAAY;AAAA,EAAA;AAIjB;"}
1
+ {"version":3,"file":"use-game-launcher-journey.js","sources":["../../../../../src/features/circle-games/game-launcher/use-game-launcher-journey/use-game-launcher-journey.tsx"],"sourcesContent":["import type { TJourneyId } from '../../../journey/journey-id/journey-id-types';\nimport type { ICoachmarkProps } from '../../../journey/use-journey/journey-context-types';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport type { INudgeProps } from '../../../ui/nudge/nudge-types';\nimport type { TColorNames } from '../../../ui/types';\nimport type { ICarouselRefs } from '../comps/carousel/carousel-types';\nimport type { ISegmentedGameCardRefs } from '../comps/segmented-game-card/segmented-game-card-types';\nimport type {\n IProject,\n Puzzle,\n} from '../dal/use-get-circle-home-details-dal/use-get-circle-home-dal-types';\nimport type { IUseGameLauncherJourneyProps } from './use-game-launcher-journey-types';\n\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport NextIcon from '../../../../assets/line-icons/icons/next';\nimport { IndicatorType } from '../../../journey/use-journey/constants';\nimport { useJourney } from '../../../journey/use-journey/use-journey';\nimport IconButton from '../../../ui/buttons/icon-button/icon-button';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Text from '../../../ui/text/text';\nimport { ProjectType } from '../../games/web-view/enums';\nimport { useCircleSounds } from '../../hooks/use-circle-sounds/use-circle-sounds';\nimport { SegmentedGameCard } from '../comps/segmented-game-card/segmented-game-card';\nimport {\n FIRST_COACHMARK_AFTER_MS,\n GO_TO_NEXT_SLIDE_AFTER_MS,\n SHOW_LABEL_HIGHLIGHT_AFTER_MS,\n SHOW_NUDGE_AFTER_MS,\n} from './constants';\n\nexport const useGameLauncherJourney = ({\n onSegmentClick,\n setCarouselIndex,\n onJourneyComplete,\n}: IUseGameLauncherJourneyProps) => {\n const carouselNextBtnRef = useRef<ICarouselRefs>(null);\n const gameRefs = useRef<ISegmentedGameCardRefs>(null);\n const puzzleRefs = useRef<ISegmentedGameCardRefs>(null);\n const lessonRefs = useRef<ISegmentedGameCardRefs>(null);\n\n const isJourneyInProgress = useRef(false);\n\n const { playButtonSound } = useCircleSounds();\n const { nextCoachmark, setJourney } = useJourney();\n\n const goToNextCard = useCallback(\n (\n refOfNextSlide: ISegmentedGameCardRefs,\n color: TColorNames,\n journeyId: TJourneyId,\n isFirstSlide: boolean = false,\n ) => {\n if (!isFirstSlide) {\n playButtonSound();\n setCarouselIndex((prev: number) => prev + 1);\n nextCoachmark(journeyId, false, GO_TO_NEXT_SLIDE_AFTER_MS);\n }\n\n const animateLabelTimer = setTimeout(() => {\n clearTimeout(animateLabelTimer);\n refOfNextSlide.startLabelAnimation(color);\n }, SHOW_LABEL_HIGHLIGHT_AFTER_MS);\n\n nextCoachmark(journeyId, true, SHOW_NUDGE_AFTER_MS);\n },\n [nextCoachmark, playButtonSound, setCarouselIndex],\n );\n\n const endJourney = useCallback(\n (puzzlesData: Puzzle, journeyId: TJourneyId) => {\n onSegmentClick(puzzlesData, ProjectType.PUZZLE);\n nextCoachmark(journeyId);\n onJourneyComplete(journeyId);\n },\n [nextCoachmark, onJourneyComplete, onSegmentClick],\n );\n\n const startJourney = useCallback(\n (puzzlesData: IProject<Puzzle>, isLessonAvailable: boolean, journeyId: TJourneyId) => {\n if (isJourneyInProgress.current) {\n return;\n }\n\n // If element refs are not available return, this is just for type safety\n if (\n !carouselNextBtnRef?.current?.nextBtnRef.current ||\n !puzzleRefs?.current?.segmentedCardWrapperRef.current ||\n !gameRefs?.current?.labelRef.current ||\n !puzzleRefs?.current?.labelRef.current ||\n !puzzlesData\n ) {\n return;\n }\n\n isJourneyInProgress.current = true;\n const lessonLabelDims = lessonRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const gameLabelDims = gameRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n const puzzleLabelDims = puzzleRefs.current?.labelRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n const launcherDims =\n puzzleRefs.current?.segmentedCardWrapperRef?.current?.getBoundingClientRect() || {\n height: 0,\n width: 0,\n };\n\n let lessonSteps: ICoachmarkProps[] = [];\n\n if (isLessonAvailable && lessonRefs.current) {\n lessonSteps = [\n {\n originalElementToHighlightRef: lessonRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'BLUE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Get faster & stay ahead in school. Practice 3 new skills everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: lessonLabelDims.width,\n tooltipYCoOrdinates: lessonLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current?.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(gameRefs.current as ISegmentedGameCardRefs, 'ORANGE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to proceed\n </Text>\n ),\n nudgePointerX: 0,\n nudgePointerY: 0,\n } as INudgeProps,\n },\n ];\n }\n\n const gameSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: gameRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'ORANGE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Train to think deeper & plan ahead. Play 3 new games everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: gameLabelDims.width,\n tooltipYCoOrdinates: gameLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: carouselNextBtnRef.current.nextBtnRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <IconButton\n renderAs=\"secondary\"\n Icon={NextIcon}\n onClick={() =>\n goToNextCard(puzzleRefs.current as ISegmentedGameCardRefs, 'PURPLE_4', journeyId)\n }\n analyticsLabel=\"HELLO \"\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to proceed\n </Text>\n ),\n nudgePointerX: 0,\n nudgePointerY: 0,\n } as INudgeProps,\n },\n ];\n\n const puzzleSteps: ICoachmarkProps[] = [\n {\n originalElementToHighlightRef: puzzleRefs.current.labelRef,\n isActive: false,\n type: IndicatorType.TOOLTIP,\n elementToHighlight: <></>,\n indicator: {\n position: 'right',\n backgroundColor: 'PURPLE_4',\n width: 264,\n tooltipItem: (\n <FlexView>\n <Text $renderAs=\"ab2-bold\">\n Think in new ways & stay sharp. Solve 3 new puzzles everyday.\n </Text>\n </FlexView>\n ),\n tooltipXCoOrdinates: puzzleLabelDims.width,\n tooltipYCoOrdinates: puzzleLabelDims.height / 2,\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: puzzleRefs.current.segmentedCardWrapperRef,\n isActive: false,\n type: IndicatorType.NUDGE,\n elementToHighlight: (\n <SegmentedGameCard\n label={''} // This is intentionally left blank to avoid showing the label\n value={puzzlesData.data.filter(puzzle => puzzle.solved).length}\n maxValue={puzzlesData.data.length}\n initialValue={puzzlesData.initialProgressValue}\n data={puzzlesData.data.map(puzzle => ({\n card: puzzle.cardLottie,\n name: '', // We dont want to show the name of the puzzle in onboarding\n isCompleted: puzzle.solved,\n onPress: () => endJourney(puzzle, journeyId),\n }))}\n />\n ),\n indicator: {\n nudge: 'click',\n content: (\n <Text $renderAs=\"ab1\" $color=\"WHITE\">\n Click to solve a puzzle\n </Text>\n ),\n nudgePointerX: launcherDims.width * 0.6,\n nudgePointerY: launcherDims.height * 0.4,\n } as INudgeProps,\n },\n ];\n\n setJourney(journeyId, [...lessonSteps, ...gameSteps, ...puzzleSteps]);\n\n nextCoachmark(journeyId, false, FIRST_COACHMARK_AFTER_MS);\n if (isLessonAvailable && lessonRefs.current) {\n goToNextCard(lessonRefs.current, 'BLUE_4', journeyId, true);\n } else {\n goToNextCard(gameRefs.current, 'ORANGE_4', journeyId, true);\n }\n },\n [endJourney, goToNextCard, nextCoachmark, setJourney],\n );\n\n const data = useMemo(\n () => ({\n gameRefs,\n puzzleRefs,\n lessonRefs,\n carouselNextBtnRef,\n isJourneyInProgress,\n startJourney,\n }),\n [startJourney],\n );\n\n return data;\n};\n"],"names":["useGameLauncherJourney","onSegmentClick","setCarouselIndex","onJourneyComplete","carouselNextBtnRef","useRef","gameRefs","puzzleRefs","lessonRefs","isJourneyInProgress","playButtonSound","useCircleSounds","nextCoachmark","setJourney","useJourney","goToNextCard","useCallback","refOfNextSlide","color","journeyId","isFirstSlide","prev","GO_TO_NEXT_SLIDE_AFTER_MS","animateLabelTimer","SHOW_LABEL_HIGHLIGHT_AFTER_MS","SHOW_NUDGE_AFTER_MS","endJourney","puzzlesData","ProjectType","startJourney","isLessonAvailable","_a","_b","_c","_d","lessonLabelDims","_g","_f","_e","gameLabelDims","_j","_i","_h","puzzleLabelDims","_m","_l","_k","launcherDims","_p","_o","_n","lessonSteps","IndicatorType","jsx","Fragment","FlexView","Text","_q","IconButton","NextIcon","gameSteps","puzzleSteps","SegmentedGameCard","puzzle","FIRST_COACHMARK_AFTER_MS","useMemo"],"mappings":";;;;;;;;;;;;AA+BO,MAAMA,KAAyB,CAAC;AAAA,EACrC,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AACF,MAAoC;AAC5B,QAAAC,IAAqBC,EAAsB,IAAI,GAC/CC,IAAWD,EAA+B,IAAI,GAC9CE,IAAaF,EAA+B,IAAI,GAChDG,IAAaH,EAA+B,IAAI,GAEhDI,IAAsBJ,EAAO,EAAK,GAElC,EAAE,iBAAAK,MAAoBC,KACtB,EAAE,eAAAC,GAAe,YAAAC,EAAW,IAAIC,EAAW,GAE3CC,IAAeC;AAAA,IACnB,CACEC,GACAC,GACAC,GACAC,IAAwB,OACrB;AACH,MAAKA,MACaV,KACCR,EAAA,CAACmB,MAAiBA,IAAO,CAAC,GAC7BT,EAAAO,GAAW,IAAOG,EAAyB;AAGrD,YAAAC,IAAoB,WAAW,MAAM;AACzC,qBAAaA,CAAiB,GAC9BN,EAAe,oBAAoBC,CAAK;AAAA,SACvCM,EAA6B;AAElB,MAAAZ,EAAAO,GAAW,IAAMM,EAAmB;AAAA,IACpD;AAAA,IACA,CAACb,GAAeF,GAAiBR,CAAgB;AAAA,EAAA,GAG7CwB,IAAaV;AAAA,IACjB,CAACW,GAAqBR,MAA0B;AAC/B,MAAAlB,EAAA0B,GAAaC,GAAY,MAAM,GAC9ChB,EAAcO,CAAS,GACvBhB,EAAkBgB,CAAS;AAAA,IAC7B;AAAA,IACA,CAACP,GAAeT,GAAmBF,CAAc;AAAA,EAAA,GAG7C4B,IAAeb;AAAA,IACnB,CAACW,GAA+BG,GA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MAAMrC,EAAWqC,GAAQ5C,CAAS;AAAA,cAAA,EAC3C;AAAA,YAAA;AAAA,UACJ;AAAA,UAEF,WAAW;AAAA,YACT,OAAO;AAAA,YACP,SACG,gBAAAkC,EAAAG,GAAA,EAAK,WAAU,OAAM,QAAO,SAAQ,UAErC,2BAAA;AAAA,YAEF,eAAeT,EAAa,QAAQ;AAAA,YACpC,eAAeA,EAAa,SAAS;AAAA,UACvC;AAAA,QACF;AAAA,MAAA;AAGS,MAAAlC,EAAAM,GAAW,CAAC,GAAGgC,GAAa,GAAGS,GAAW,GAAGC,CAAW,CAAC,GAEtDjD,EAAAO,GAAW,IAAO6C,EAAwB,GACpDlC,KAAqBtB,EAAW,UAClCO,EAAaP,EAAW,SAAS,UAAUW,GAAW,EAAI,IAE1DJ,EAAaT,EAAS,SAAS,YAAYa,GAAW,EAAI;AAAA,IAE9D;AAAA,IACA,CAACO,GAAYX,GAAcH,GAAeC,CAAU;AAAA,EAAA;AAe/C,SAZMoD;AAAA,IACX,OAAO;AAAA,MACL,UAAA3D;AAAA,MACA,YAAAC;AAAA,MACA,YAAAC;AAAA,MACA,oBAAAJ;AAAA,MACA,qBAAAK;AAAA,MACA,cAAAoB;AAAA,IAAA;AAAA,IAEF,CAACA,CAAY;AAAA,EAAA;AAIjB;"}
@@ -1,65 +1,62 @@
1
- import { jsxs as v, jsx as k } from "react/jsx-runtime";
2
- import { createContext as $, useState as g, useRef as h, useCallback as s, useMemo as p, useEffect as R } from "react";
3
- import { Coachmark as A } from "../comps/coachmark/coachmark.js";
4
- import { BlurOverlay as E } from "./journey-styled.js";
5
- const N = $(null), O = ({ children: w }) => {
6
- const [n, u] = g([]), o = h(-1), r = h(), i = h(null), y = s(
1
+ import { jsxs as v, jsx as J } from "react/jsx-runtime";
2
+ import { createContext as x, useState as $, useRef as f, useCallback as i, useMemo as p } from "react";
3
+ import { Coachmark as g } from "../comps/coachmark/coachmark.js";
4
+ import { BlurOverlay as A } from "./journey-styled.js";
5
+ const R = x(null), j = ({ children: C }) => {
6
+ const [o, u] = $([]), c = f(-1), r = f(), l = i(
7
7
  (e, t) => {
8
- if (n.length > 0)
8
+ if (o.length > 0)
9
9
  throw new Error(
10
10
  `setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
11
11
  );
12
- r.current = e, o.current = -1, u([...t]);
12
+ r.current = e, c.current = -1, u([...t]);
13
13
  },
14
- [n.length]
15
- ), d = s(() => {
16
- r.current = void 0, o.current = -1, u([]);
17
- }, []), f = s((e, t) => {
14
+ [o.length]
15
+ ), h = i(() => {
16
+ r.current = void 0, c.current = -1, u([]);
17
+ }, []), y = i((e, t) => {
18
18
  if (!r.current || e !== r.current)
19
19
  throw new Error(
20
20
  r.current ? "addCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
21
21
  );
22
- u((a) => [...a, t]);
23
- }, []), J = s(
24
- (e, t = !1, a = 0) => {
22
+ u((s) => [...s, t]);
23
+ }, []), d = i(
24
+ (e, t = !1, s = 0) => {
25
25
  if (!r.current || e !== r.current)
26
26
  throw new Error(
27
27
  r.current ? "nextCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
28
28
  );
29
- const C = () => {
30
- const c = o.current + 1;
31
- u((l) => {
32
- if (c >= l.length || l.length === 0)
33
- return r.current = void 0, o.current = -1, [];
34
- o.current = c;
35
- const m = [...l];
36
- return m[c].isActive = !0, c > 0 && (m[c - 1].isActive = t), m;
29
+ s !== 0 && u((n) => n.map((a) => ({ ...a, isActive: !1 })));
30
+ const w = setTimeout(() => {
31
+ clearTimeout(w);
32
+ const n = c.current + 1;
33
+ u((a) => {
34
+ if (n >= a.length || a.length === 0)
35
+ return r.current = void 0, c.current = -1, [];
36
+ c.current = n;
37
+ const m = [...a];
38
+ return m[n].isActive = !0, n > 0 && (m[n - 1].isActive = t), m;
37
39
  });
38
- };
39
- a === 0 ? C() : i.current = setTimeout(() => {
40
- C();
41
- }, a);
40
+ }, s);
42
41
  },
43
42
  []
44
- ), x = p(
43
+ ), k = p(
45
44
  () => ({
46
- nextCoachmark: J,
47
- setJourney: y,
48
- addCoachmark: f,
49
- clearJourney: d,
50
- coachmarks: n
45
+ nextCoachmark: d,
46
+ setJourney: l,
47
+ addCoachmark: y,
48
+ clearJourney: h,
49
+ coachmarks: o
51
50
  }),
52
- [J, y, f, d, n]
51
+ [d, l, y, h, o]
53
52
  );
54
- return R(() => () => {
55
- i.current && clearTimeout(i.current);
56
- }, []), /* @__PURE__ */ v(N.Provider, { value: x, children: [
57
- n.length > 0 && /* @__PURE__ */ k(E, { children: n.map((e, t) => /* @__PURE__ */ k(A, { coachmark: e }, `coachmark-${t}`)) }),
58
- w
53
+ return /* @__PURE__ */ v(R.Provider, { value: k, children: [
54
+ o.length > 0 && /* @__PURE__ */ J(A, { children: o.map((e, t) => /* @__PURE__ */ J(g, { coachmark: e }, `coachmark-${t}`)) }),
55
+ C
59
56
  ] });
60
57
  };
61
58
  export {
62
- N as JourneyContext,
63
- O as JourneyProvider
59
+ R as JourneyContext,
60
+ j as JourneyProvider
64
61
  };
65
62
  //# sourceMappingURL=journey-context-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\nimport type { ICoachmarkProps, IJourneyContext } from './journey-context-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<{ children: ReactNode }> = ({ children }) => {\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const currentIndex = useRef(-1);\n const currentJourneyIdStudent = useRef<TJourneyId | undefined>();\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n throw new Error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n currentJourneyIdStudent.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n }, []);\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `addCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n\n const handleNextCoachmark = () => {\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n };\n\n if (delayInMs === 0) {\n handleNextCoachmark();\n } else {\n timerRef.current = setTimeout(() => {\n handleNextCoachmark();\n }, delayInMs);\n }\n },\n [],\n );\n\n const memoizedContextValue = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n coachmarks: coachmarkList,\n }),\n [nextCoachmark, setJourney, addCoachmark, clearJourney, coachmarkList],\n );\n\n // Cleanup timer refs\n useEffect(() => {\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {coachmarkList.length > 0 && (\n <S.BlurOverlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.BlurOverlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","coachmarkList","setCoachmarkList","useState","currentIndex","useRef","currentJourneyIdStudent","timerRef","setJourney","useCallback","id","coachmarks","clearJourney","addCoachmark","coachmark","prev","nextCoachmark","keepPrevActive","delayInMs","handleNextCoachmark","currIndex","prevList","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","jsxs","jsx","S.BlurOverlay","index","Coachmark"],"mappings":";;;;AASa,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA+C,CAAC,EAAE,UAAAC,QAAe;AAC5E,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA4B,CAAE,CAAA,GAClEC,IAAeC,EAAO,EAAE,GACxBC,IAA0BD,KAC1BE,IAAWF,EAA6C,IAAI,GAE5DG,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAV,EAAc,SAAS;AACzB,cAAM,IAAI;AAAA,UACR,iEAAiEK,EAAwB,OAAO,0BAA0BI,CAAE;AAAA,QAAA;AAGhI,MAAAJ,EAAwB,UAAUI,GAClCN,EAAa,UAAU,IACNF,EAAA,CAAC,GAAGS,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAACV,EAAc,MAAM;AAAA,EAAA,GA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AAR;AAAA,MACA,cAAAK;AAAA,MACA,cAAAD;AAAA,MACA,YAAYX;AAAA,IAAA;AAAA,IAEd,CAACe,GAAeR,GAAYK,GAAcD,GAAcX,CAAa;AAAA,EAAA;AAIvE,SAAAwB,EAAU,MACD,MAAM;AACX,IAAIlB,EAAS,WACX,aAAaA,EAAS,OAAO;AAAA,EAC/B,GAED,CAAE,CAAA,GAGF,gBAAAmB,EAAA7B,EAAe,UAAf,EAAwB,OAAO0B,GAC7B,UAAA;AAAA,IAAAtB,EAAc,SAAS,KACtB,gBAAA0B,EAACC,GAAA,EACE,YAAc,IAAI,CAACd,GAAWe,wBAC5BC,GAAqC,EAAA,WAAAhB,EAAA,GAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED7B;AAAA,EACH,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\nimport type { ICoachmarkProps, IJourneyContext } from './journey-context-types';\nimport type { FC, ReactNode } from 'react';\n\nimport { createContext, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<{ children: ReactNode }> = ({ children }) => {\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const currentIndex = useRef(-1);\n const currentJourneyIdStudent = useRef<TJourneyId | undefined>();\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n throw new Error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n currentJourneyIdStudent.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n }, []);\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `addCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyIdStudent.current || id !== currentJourneyIdStudent.current) {\n throw new Error(\n currentJourneyIdStudent.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyIdStudent.current}, New Journey Request: ${id}`,\n );\n }\n\n if (delayInMs !== 0) {\n // If delay is not 0, we will hide all them coachmarks and reveal only after the delay\n setCoachmarkList(prevList => {\n return prevList.map((item: ICoachmarkProps) => {\n return { ...item, isActive: false };\n });\n });\n }\n\n const timer = setTimeout(() => {\n clearTimeout(timer);\n const currIndex = currentIndex.current + 1;\n\n setCoachmarkList(prevList => {\n // Finish onboarding\n if (currIndex >= prevList.length || prevList.length === 0) {\n currentJourneyIdStudent.current = undefined;\n currentIndex.current = -1;\n\n return [];\n }\n\n currentIndex.current = currIndex;\n const updatedCoachmarkList = [...prevList];\n\n (updatedCoachmarkList[currIndex] as ICoachmarkProps).isActive = true;\n\n if (currIndex > 0) {\n (updatedCoachmarkList[currIndex - 1] as ICoachmarkProps).isActive = keepPrevActive;\n }\n\n return updatedCoachmarkList;\n });\n }, delayInMs);\n },\n [],\n );\n\n const memoizedContextValue = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n coachmarks: coachmarkList,\n }),\n [nextCoachmark, setJourney, addCoachmark, clearJourney, coachmarkList],\n );\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {coachmarkList.length > 0 && (\n <S.BlurOverlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.BlurOverlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","coachmarkList","setCoachmarkList","useState","currentIndex","useRef","currentJourneyIdStudent","setJourney","useCallback","id","coachmarks","clearJourney","addCoachmark","coachmark","prev","nextCoachmark","keepPrevActive","delayInMs","prevList","item","timer","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","jsxs","jsx","S.BlurOverlay","index","Coachmark"],"mappings":";;;;AASa,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA+C,CAAC,EAAE,UAAAC,QAAe;AAC5E,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA4B,CAAE,CAAA,GAClEC,IAAeC,EAAO,EAAE,GACxBC,IAA0BD,KAE1BE,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAT,EAAc,SAAS;AACzB,cAAM,IAAI;AAAA,UACR,iEAAiEK,EAAwB,OAAO,0BAA0BG,CAAE;AAAA,QAAA;AAGhI,MAAAH,EAAwB,UAAUG,GAClCL,EAAa,UAAU,IACNF,EAAA,CAAC,GAAGQ,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAACT,EAAc,MAAM;AAAA,EAAA,GAGjBU,IAAeH,EAAY,MAAM;AACrC,IAAAF,EAAwB,UAAU,QAClCF,EAAa,UAAU,IACvBF,EAAiB,CAAE,CAAA;AAAA,EACrB,GAAG,CAAE,CAAA,GAECU,IAAeJ,EAAY,CAACC,GAAgBI,MAA+B;AAC/E,QAAI,CAACP,EAAwB,WAAWG,MAAOH,EAAwB;AACrE,YAAM,IAAI;AAAA,QACRA,EAAwB,UACpB,8CACA,iDAAiDA,EAAwB,OAAO,0BAA0BG,CAAE;AAAA,MAAA;AAIpH,IAAAP,EAAiB,CAAQY,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