@cuemath/leap 2.8.62-aa0 → 2.8.62-rj-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.
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.js +18 -18
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.js.map +1 -1
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js +10 -10
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel.js +51 -49
- package/dist/features/circle-games/game-launcher/comps/carousel/carousel.js.map +1 -1
- package/dist/features/circle-games/game-launcher/game-launcher.js +87 -90
- package/dist/features/circle-games/game-launcher/game-launcher.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js +83 -82
- package/dist/features/circle-games/game-launcher/hooks/use-game-launcher-journey/use-game-launcher-journey.js.map +1 -1
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js +59 -57
- package/dist/features/circle-games/game-launcher/hooks/use-table-launcher-journey/use-table-launcher-journey.js.map +1 -1
- package/dist/features/circle-games/games/web-view/web-view-types.js.map +1 -1
- package/dist/features/circle-games/games/web-view/web-view.js +53 -47
- package/dist/features/circle-games/games/web-view/web-view.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-provider.js +8 -9
- package/dist/features/cue-canvas/cue-canvas-provider.js.map +1 -1
- package/dist/features/journey/hooks/use-get-eligible-journeys-via-route.js +7 -4
- package/dist/features/journey/hooks/use-get-eligible-journeys-via-route.js.map +1 -1
- package/dist/features/journey/use-journey/journey-context-provider.js +71 -67
- package/dist/features/journey/use-journey/journey-context-provider.js.map +1 -1
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js +41 -41
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js.map +1 -1
- package/dist/features/sheets/resources-list/resource-item/resource-item.js +20 -20
- package/dist/features/sheets/resources-list/resource-item/resource-item.js.map +1 -1
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/student-actions/student-actions.js +33 -33
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/student-actions/student-actions.js.map +1 -1
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/teacher-actions/teacher-actions.js +30 -30
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/sheets/utils/is-v3-worksheet.js +14 -9
- package/dist/features/sheets/utils/is-v3-worksheet.js.map +1 -1
- package/dist/features/ui/section-list/section-list.js +12 -12
- package/dist/features/ui/section-list/section-list.js.map +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +43 -44
- package/package.json +2 -4
- package/dist/library/polypad.js +0 -24965
- package/dist/library/polypad.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-view.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view.tsx"],"sourcesContent":["
|
1
|
+
{"version":3,"file":"web-view.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view.tsx"],"sourcesContent":["import type {\n IInfoMessage,\n ILessonWebGameProps,\n IMessageProps,\n IMultiplayerWebGameProps,\n IPlayerStats,\n IPuzzleWebGameProps,\n ITableWebGameProps,\n IVibrationPattern,\n IWebViewProps,\n} from './web-view-types';\nimport type { ForwardedRef } from 'react';\n\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport { useUIContext } from '../../../ui/context/context';\nimport { ALLOWED_ORIGIN } from './constants';\nimport { ProjectType, WebViewEvent } from './enums';\n\nexport const WebView = forwardRef((props: IWebViewProps, ref: ForwardedRef<HTMLIFrameElement>) => {\n const {\n baseUrl,\n projectDetails,\n playerDetails,\n onGameLoad,\n onGamePlayFinish,\n handleInfoMessage,\n onBack,\n parentDomain,\n ...rest\n } = props;\n const webViewRef = useRef<HTMLIFrameElement>(null);\n const memoizedPlayerDetails = useMemo(() => playerDetails, [playerDetails]);\n const memoizedProjectDetails = useMemo(() => projectDetails, [projectDetails]);\n\n let miniGameIdentifier = '';\n const { onEvent: trackEvent } = useUIContext();\n\n if (memoizedProjectDetails.projectType === ProjectType.LESSON) {\n miniGameIdentifier = (memoizedProjectDetails as ILessonWebGameProps).miniGameIdentifier;\n }\n\n const getProjectDetails = useCallback(() => {\n const { enableCloseButton = true } = memoizedProjectDetails;\n\n let payload = {\n enableCloseButton,\n } as IMultiplayerWebGameProps | IPuzzleWebGameProps | ILessonWebGameProps;\n\n if (memoizedProjectDetails.projectType === ProjectType.GAME) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as IMultiplayerWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.PUZZLE) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as IPuzzleWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.LESSON) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as ILessonWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.TABLE) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as ITableWebGameProps;\n }\n\n return payload;\n }, [memoizedProjectDetails]);\n\n const sendGamesData = useCallback(() => {\n const payload = getProjectDetails();\n\n webViewRef.current?.contentWindow?.postMessage(\n JSON.stringify({\n event: WebViewEvent.GAME_DATA,\n payload,\n }),\n ALLOWED_ORIGIN,\n );\n }, [getProjectDetails]);\n\n const setConfig = useCallback(() => {\n const projectConfig = getProjectDetails();\n\n webViewRef.current?.contentWindow?.postMessage(\n JSON.stringify({\n event: WebViewEvent.SET_CONFIG,\n payload: {\n user: memoizedPlayerDetails,\n projectConfig,\n parentDomain,\n },\n }),\n ALLOWED_ORIGIN,\n );\n }, [memoizedPlayerDetails, getProjectDetails, parentDomain]);\n\n useImperativeHandle(ref, () => webViewRef.current as HTMLIFrameElement, []);\n\n useEffect(() => {\n const handleMessage = (e: MessageEvent) => {\n const data: string = e.data;\n const parsedData = typeof data === 'string' ? JSON.parse(data) : (data as IMessageProps);\n\n const { event, payload = null } = parsedData;\n\n if (event === WebViewEvent.VIBRATE) {\n const { pattern } = payload as IVibrationPattern;\n\n window.navigator.vibrate?.(pattern);\n }\n\n if (event === WebViewEvent.GAME_BACK) {\n onBack?.();\n }\n\n if (event === WebViewEvent.HIDE_LOADER) {\n onGameLoad?.();\n }\n\n if (event === WebViewEvent.LOAD_DATA_FROM_APP) {\n sendGamesData?.();\n }\n\n if (event === WebViewEvent.GET_CONFIG) {\n setConfig();\n }\n\n if (event === WebViewEvent.UPDATE_STATS) {\n onGamePlayFinish?.(payload as IPlayerStats);\n }\n\n if (event === WebViewEvent.SHOW_SNACKBAR) {\n handleInfoMessage?.(payload as IInfoMessage);\n }\n\n if (event === WebViewEvent.TRACK_EVENT) {\n const { eventName, properties } = payload;\n\n trackEvent(eventName, properties);\n }\n };\n\n window.addEventListener('message', handleMessage);\n\n return () => {\n window.removeEventListener('message', handleMessage);\n };\n }, [\n handleInfoMessage,\n onBack,\n onGamePlayFinish,\n onGameLoad,\n setConfig,\n sendGamesData,\n trackEvent,\n ]);\n\n return (\n <iframe\n {...rest}\n ref={webViewRef}\n src={`${baseUrl}/play-game/${memoizedProjectDetails.projectId}/${\n memoizedProjectDetails.variant\n }${miniGameIdentifier ? `/${miniGameIdentifier}` : ''}?version=2`}\n allow=\"autoplay\"\n />\n );\n});\n"],"names":["WebView","forwardRef","props","ref","baseUrl","projectDetails","playerDetails","onGameLoad","onGamePlayFinish","handleInfoMessage","onBack","parentDomain","rest","webViewRef","useRef","memoizedPlayerDetails","useMemo","memoizedProjectDetails","miniGameIdentifier","trackEvent","useUIContext","ProjectType","getProjectDetails","useCallback","enableCloseButton","payload","sendGamesData","_b","_a","WebViewEvent","ALLOWED_ORIGIN","setConfig","projectConfig","useImperativeHandle","useEffect","handleMessage","data","parsedData","event","pattern","eventName","properties","jsx"],"mappings":";;;;;;AAmBO,MAAMA,IAAUC,EAAW,CAACC,GAAsBC,MAAyC;AAC1F,QAAA;AAAA,IACJ,SAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,YAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,GAAGC;AAAA,EACD,IAAAV,GACEW,IAAaC,EAA0B,IAAI,GAC3CC,IAAwBC,EAAQ,MAAMV,GAAe,CAACA,CAAa,CAAC,GACpEW,IAAyBD,EAAQ,MAAMX,GAAgB,CAACA,CAAc,CAAC;AAE7E,MAAIa,IAAqB;AACzB,QAAM,EAAE,SAASC,EAAW,IAAIC,EAAa;AAEzC,EAAAH,EAAuB,gBAAgBI,EAAY,WACrDH,IAAsBD,EAA+C;AAGjE,QAAAK,IAAoBC,EAAY,MAAM;AACpC,UAAA,EAAE,mBAAAC,IAAoB,GAAS,IAAAP;AAErC,QAAIQ,IAAU;AAAA,MACZ,mBAAAD;AAAA,IAAA;AAGE,WAAAP,EAAuB,gBAAgBI,EAAY,SAC3CI,IAAA;AAAA,MACR,GAAGA;AAAA,MACH,GAAGR;AAAA,IAAA,IAIHA,EAAuB,gBAAgBI,EAAY,WAC3CI,IAAA;AAAA,MACR,GAAGA;AAAA,MACH,GAAGR;AAAA,IAAA,IAIHA,EAAuB,gBAAgBI,EAAY,WAC3CI,IAAA;AAAA,MACR,GAAGA;AAAA,MACH,GAAGR;AAAA,IAAA,IAIHA,EAAuB,gBAAgBI,EAAY,UAC3CI,IAAA;AAAA,MACR,GAAGA;AAAA,MACH,GAAGR;AAAA,IAAA,IAIAQ;AAAA,EAAA,GACN,CAACR,CAAsB,CAAC,GAErBS,IAAgBH,EAAY,MAAM;;AACtC,UAAME,IAAUH;AAEhB,KAAAK,KA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,KAGlBa,MAAUT,EAAa,aAAa;AAChC,cAAA,EAAE,WAAAW,GAAW,YAAAC,EAAe,IAAAhB;AAElC,QAAAN,EAAWqB,GAAWC,CAAU;AAAA,MAClC;AAAA,IAAA;AAGK,kBAAA,iBAAiB,WAAWN,CAAa,GAEzC,MAAM;AACJ,aAAA,oBAAoB,WAAWA,CAAa;AAAA,IAAA;AAAA,EACrD,GACC;AAAA,IACD1B;AAAA,IACAC;AAAA,IACAF;AAAA,IACAD;AAAA,IACAwB;AAAA,IACAL;AAAA,IACAP;AAAA,EAAA,CACD,GAGC,gBAAAuB;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG9B;AAAA,MACJ,KAAKC;AAAA,MACL,KAAK,GAAGT,CAAO,cAAca,EAAuB,SAAS,IAC3DA,EAAuB,OACzB,GAAGC,IAAqB,IAAIA,CAAkB,KAAK,EAAE;AAAA,MACrD,OAAM;AAAA,IAAA;AAAA,EAAA;AAGZ,CAAC;"}
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
2
|
-
import "
|
3
|
-
import
|
4
|
-
import f from "./cue-canvas-context.js";
|
2
|
+
import { memo as f, useMemo as n, useState as o } from "react";
|
3
|
+
import p from "./cue-canvas-context.js";
|
5
4
|
import { getColorsForUser as x } from "./cue-canvas-helpers.js";
|
6
|
-
const A =
|
7
|
-
({ children:
|
8
|
-
const
|
5
|
+
const A = f(
|
6
|
+
({ children: a, userType: t }) => {
|
7
|
+
const i = n(() => x(t), [t]), [e, v] = o(), [r, m] = o("pen"), [s, l] = o(), [c, C] = o(i[0]), u = n(
|
9
8
|
() => ({
|
10
9
|
activeInstance: e,
|
11
10
|
setActiveInstance: v,
|
@@ -18,10 +17,10 @@ const A = p(
|
|
18
17
|
}),
|
19
18
|
[c, e, s, r]
|
20
19
|
);
|
21
|
-
return /* @__PURE__ */ d(
|
20
|
+
return /* @__PURE__ */ d(p.Provider, { value: u, children: a });
|
22
21
|
}
|
23
|
-
),
|
22
|
+
), g = A;
|
24
23
|
export {
|
25
|
-
|
24
|
+
g as default
|
26
25
|
};
|
27
26
|
//# sourceMappingURL=cue-canvas-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cue-canvas-provider.js","sources":["../../../src/features/cue-canvas/cue-canvas-provider.tsx"],"sourcesContent":["import type { TUserTypes } from '../ui/types';\nimport type { CueCanvasCore } from './cue-canvas-core';\nimport type { TCueCanvasColors, TCueCanvasSidebar, TCueCanvasTool } from './types/cue-canvas';\nimport '../../library/polypad';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { useState, memo, useMemo } from 'react';\n\nimport CueCanvasContext from './cue-canvas-context';\nimport { getColorsForUser } from './cue-canvas-helpers';\n\nconst CueCanvasProvider: FC<PropsWithChildren<{ userType: TUserTypes }>> = memo(\n ({ children, userType }) => {\n const colors = useMemo(() => getColorsForUser(userType), [userType]);\n\n const [activeInstance, setActiveInstance] = useState<CueCanvasCore>();\n const [activeTool, setActiveTool] = useState<TCueCanvasTool>('pen');\n const [activeSidebar, setActiveSidebar] = useState<TCueCanvasSidebar>();\n const [activeColor, setActiveColor] = useState<TCueCanvasColors>(colors[0] as TCueCanvasColors);\n const contextValue = useMemo(\n () => ({\n activeInstance: activeInstance,\n setActiveInstance: setActiveInstance,\n activeTool: activeTool,\n setActiveTool: setActiveTool,\n activeColor,\n setActiveColor,\n activeSidebar,\n setActiveSidebar,\n }),\n [activeColor, activeInstance, activeSidebar, activeTool],\n );\n\n return <CueCanvasContext.Provider value={contextValue}>{children}</CueCanvasContext.Provider>;\n },\n);\n\nexport default CueCanvasProvider;\n"],"names":["CueCanvasProvider","memo","children","userType","colors","useMemo","getColorsForUser","activeInstance","setActiveInstance","useState","activeTool","setActiveTool","activeSidebar","setActiveSidebar","activeColor","setActiveColor","contextValue","CueCanvasContext","CueCanvasProvider$1"],"mappings":"
|
1
|
+
{"version":3,"file":"cue-canvas-provider.js","sources":["../../../src/features/cue-canvas/cue-canvas-provider.tsx"],"sourcesContent":["import type { TUserTypes } from '../ui/types';\nimport type { CueCanvasCore } from './cue-canvas-core';\nimport type { TCueCanvasColors, TCueCanvasSidebar, TCueCanvasTool } from './types/cue-canvas';\nimport '../../library/polypad';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { useState, memo, useMemo } from 'react';\n\nimport CueCanvasContext from './cue-canvas-context';\nimport { getColorsForUser } from './cue-canvas-helpers';\n\nconst CueCanvasProvider: FC<PropsWithChildren<{ userType: TUserTypes }>> = memo(\n ({ children, userType }) => {\n const colors = useMemo(() => getColorsForUser(userType), [userType]);\n\n const [activeInstance, setActiveInstance] = useState<CueCanvasCore>();\n const [activeTool, setActiveTool] = useState<TCueCanvasTool>('pen');\n const [activeSidebar, setActiveSidebar] = useState<TCueCanvasSidebar>();\n const [activeColor, setActiveColor] = useState<TCueCanvasColors>(colors[0] as TCueCanvasColors);\n const contextValue = useMemo(\n () => ({\n activeInstance: activeInstance,\n setActiveInstance: setActiveInstance,\n activeTool: activeTool,\n setActiveTool: setActiveTool,\n activeColor,\n setActiveColor,\n activeSidebar,\n setActiveSidebar,\n }),\n [activeColor, activeInstance, activeSidebar, activeTool],\n );\n\n return <CueCanvasContext.Provider value={contextValue}>{children}</CueCanvasContext.Provider>;\n },\n);\n\nexport default CueCanvasProvider;\n"],"names":["CueCanvasProvider","memo","children","userType","colors","useMemo","getColorsForUser","activeInstance","setActiveInstance","useState","activeTool","setActiveTool","activeSidebar","setActiveSidebar","activeColor","setActiveColor","contextValue","CueCanvasContext","CueCanvasProvider$1"],"mappings":";;;;AAWA,MAAMA,IAAqEC;AAAA,EACzE,CAAC,EAAE,UAAAC,GAAU,UAAAC,QAAe;AACpB,UAAAC,IAASC,EAAQ,MAAMC,EAAiBH,CAAQ,GAAG,CAACA,CAAQ,CAAC,GAE7D,CAACI,GAAgBC,CAAiB,IAAIC,EAAwB,GAC9D,CAACC,GAAYC,CAAa,IAAIF,EAAyB,KAAK,GAC5D,CAACG,GAAeC,CAAgB,IAAIJ,EAA4B,GAChE,CAACK,GAAaC,CAAc,IAAIN,EAA2BL,EAAO,CAAC,CAAqB,GACxFY,IAAeX;AAAA,MACnB,OAAO;AAAA,QACL,gBAAAE;AAAA,QACA,mBAAAC;AAAA,QACA,YAAAE;AAAA,QACA,eAAAC;AAAA,QACA,aAAAG;AAAA,QACA,gBAAAC;AAAA,QACA,eAAAH;AAAA,QACA,kBAAAC;AAAA,MAAA;AAAA,MAEF,CAACC,GAAaP,GAAgBK,GAAeF,CAAU;AAAA,IAAA;AAGzD,6BAAQO,EAAiB,UAAjB,EAA0B,OAAOD,GAAe,UAAAd,EAAS,CAAA;AAAA,EACnE;AACF,GAEAgB,IAAelB;"}
|
@@ -1,10 +1,13 @@
|
|
1
1
|
import { useMemo as i } from "react";
|
2
2
|
import { useJourney as s } from "../use-journey/use-journey.js";
|
3
|
-
const
|
4
|
-
const { userCompletedJourneyIds:
|
5
|
-
return i(
|
3
|
+
const n = (e) => {
|
4
|
+
const { userCompletedJourneyIds: o } = s();
|
5
|
+
return i(
|
6
|
+
() => e.filter((r) => !o.includes(r)),
|
7
|
+
[e, o]
|
8
|
+
);
|
6
9
|
};
|
7
10
|
export {
|
8
|
-
|
11
|
+
n as useGetEligibleJourneysViaRoute
|
9
12
|
};
|
10
13
|
//# sourceMappingURL=use-get-eligible-journeys-via-route.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-get-eligible-journeys-via-route.js","sources":["../../../../src/features/journey/hooks/use-get-eligible-journeys-via-route.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\n\nimport { useMemo } from 'react';\n\nimport { useJourney } from '../use-journey/use-journey';\n\nexport const useGetEligibleJourneysViaRoute = (routeJourneyIds: TJourneyId[]) => {\n const { userCompletedJourneyIds } = useJourney();\n\n const eligibleJourneys = useMemo(
|
1
|
+
{"version":3,"file":"use-get-eligible-journeys-via-route.js","sources":["../../../../src/features/journey/hooks/use-get-eligible-journeys-via-route.tsx"],"sourcesContent":["import type { TJourneyId } from '../journey-id/journey-id-types';\n\nimport { useMemo } from 'react';\n\nimport { useJourney } from '../use-journey/use-journey';\n\nexport const useGetEligibleJourneysViaRoute = (routeJourneyIds: TJourneyId[]) => {\n const { userCompletedJourneyIds } = useJourney();\n\n const eligibleJourneys = useMemo(\n () => routeJourneyIds.filter(journeyId => !userCompletedJourneyIds.includes(journeyId)),\n [routeJourneyIds, userCompletedJourneyIds],\n );\n\n return eligibleJourneys;\n};\n"],"names":["useGetEligibleJourneysViaRoute","routeJourneyIds","userCompletedJourneyIds","useJourney","useMemo","journeyId"],"mappings":";;AAMa,MAAAA,IAAiC,CAACC,MAAkC;AACzE,QAAA,EAAE,yBAAAC,MAA4BC;AAO7B,SALkBC;AAAA,IACvB,MAAMH,EAAgB,OAAO,CAAAI,MAAa,CAACH,EAAwB,SAASG,CAAS,CAAC;AAAA,IACtF,CAACJ,GAAiBC,CAAuB;AAAA,EAAA;AAI7C;"}
|
@@ -1,105 +1,109 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { createContext as
|
3
|
-
import { Coachmark as
|
4
|
-
import { usePostUserJourney as
|
5
|
-
import { Overlay as
|
6
|
-
const
|
7
|
-
const [
|
8
|
-
|
9
|
-
|
1
|
+
import { jsxs as b, jsx as j } from "react/jsx-runtime";
|
2
|
+
import { createContext as q, useState as h, useRef as C, useCallback as l, useMemo as L, useEffect as R } from "react";
|
3
|
+
import { Coachmark as N } from "../comps/coachmark/coachmark.js";
|
4
|
+
import { usePostUserJourney as M, useGetUserJourney as z } from "../user-journey-api/user-journey-api.js";
|
5
|
+
import { Overlay as G } from "./journey-styled.js";
|
6
|
+
const S = q(null), Q = ({ children: T, appId: u, userId: s }) => {
|
7
|
+
const [k, v] = h([]), [o, c] = h([]), [g, p] = h(!1), a = C(-1), r = C(), f = C([]), { post: x } = M(), {
|
8
|
+
data: m = null,
|
9
|
+
get: _,
|
10
|
+
isProcessing: D
|
11
|
+
} = z(), O = (u === "" || m && !D) && o.length > 0, $ = l(
|
12
|
+
(e, t) => {
|
13
|
+
if (o.length > 0) {
|
10
14
|
console.error(
|
11
|
-
`setJourney: Other Journey is already active, Current Journey: ${
|
15
|
+
`setJourney: Other Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
12
16
|
);
|
13
17
|
return;
|
14
18
|
}
|
15
|
-
|
19
|
+
console.log(`setJourney: Journey ID: ${e}`), p(!0), r.current = e, a.current = -1, c([...t]);
|
16
20
|
},
|
17
|
-
[
|
18
|
-
),
|
19
|
-
|
21
|
+
[o.length]
|
22
|
+
), y = l(() => {
|
23
|
+
f.current.forEach((e) => {
|
20
24
|
clearTimeout(e);
|
21
|
-
}),
|
22
|
-
}, []),
|
25
|
+
}), f.current = [], r.current = void 0, a.current = -1, c([]), p(!1);
|
26
|
+
}, []), A = l(
|
23
27
|
(e) => {
|
24
|
-
|
25
|
-
app_id:
|
26
|
-
user_id:
|
28
|
+
v((t) => [...t, e]), x({
|
29
|
+
app_id: u,
|
30
|
+
user_id: s,
|
27
31
|
journey_id: e,
|
28
32
|
journey_status: "COMPLETED"
|
29
|
-
});
|
33
|
+
}), y();
|
30
34
|
},
|
31
|
-
[
|
32
|
-
),
|
33
|
-
if (!
|
35
|
+
[u, y, x, s]
|
36
|
+
), P = l((e, t) => {
|
37
|
+
if (!r.current || e !== r.current) {
|
34
38
|
console.error(
|
35
|
-
|
39
|
+
r.current ? `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}` : "addCoachmark was called before setJourney and Journey ID is undefined"
|
36
40
|
);
|
37
41
|
return;
|
38
42
|
}
|
39
|
-
|
40
|
-
}, []),
|
41
|
-
(e,
|
42
|
-
if (!
|
43
|
+
c((J) => [...J, t]);
|
44
|
+
}, []), w = l(
|
45
|
+
(e, t = !1, J = 0) => {
|
46
|
+
if (!r.current || e !== r.current) {
|
43
47
|
console.error(
|
44
|
-
|
48
|
+
r.current ? "nextCoachmark was called before setJourney" : `A Journey is already active, Current Journey: ${r.current}, New Journey Request: ${e}`
|
45
49
|
);
|
46
50
|
return;
|
47
51
|
}
|
48
|
-
|
49
|
-
const
|
50
|
-
clearTimeout(
|
51
|
-
const n =
|
52
|
-
|
52
|
+
J !== 0 && c((n) => n.map((i) => ({ ...i, isActive: !1 })));
|
53
|
+
const E = setTimeout(() => {
|
54
|
+
clearTimeout(E);
|
55
|
+
const n = a.current + 1;
|
56
|
+
c((i) => {
|
53
57
|
if (n >= i.length || i.length === 0)
|
54
|
-
return
|
55
|
-
|
56
|
-
const
|
57
|
-
return
|
58
|
+
return r.current = void 0, a.current = -1, [];
|
59
|
+
a.current = n;
|
60
|
+
const d = [...i];
|
61
|
+
return d[n].isActive = !0, n > 0 && (d[n - 1].isActive = t), d;
|
58
62
|
});
|
59
|
-
},
|
60
|
-
|
63
|
+
}, J);
|
64
|
+
f.current.push(E);
|
61
65
|
},
|
62
|
-
[
|
63
|
-
),
|
66
|
+
[]
|
67
|
+
), U = L(
|
64
68
|
() => ({
|
65
|
-
nextCoachmark:
|
66
|
-
setJourney:
|
67
|
-
addCoachmark:
|
68
|
-
clearJourney:
|
69
|
-
endJourney:
|
70
|
-
coachmarks:
|
71
|
-
userCompletedJourneyIds:
|
72
|
-
isJourneyActive:
|
69
|
+
nextCoachmark: w,
|
70
|
+
setJourney: $,
|
71
|
+
addCoachmark: P,
|
72
|
+
clearJourney: y,
|
73
|
+
endJourney: A,
|
74
|
+
coachmarks: o,
|
75
|
+
userCompletedJourneyIds: k,
|
76
|
+
isJourneyActive: g
|
73
77
|
}),
|
74
78
|
[
|
79
|
+
w,
|
80
|
+
$,
|
75
81
|
P,
|
82
|
+
y,
|
76
83
|
A,
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
c,
|
81
|
-
x,
|
82
|
-
J
|
84
|
+
o,
|
85
|
+
k,
|
86
|
+
g
|
83
87
|
]
|
84
88
|
);
|
85
89
|
return R(() => {
|
86
|
-
|
87
|
-
app_id:
|
88
|
-
user_id:
|
90
|
+
u && s && _(s, {
|
91
|
+
app_id: u,
|
92
|
+
user_id: s,
|
89
93
|
journey_status: "COMPLETED"
|
90
94
|
});
|
91
|
-
}, [
|
92
|
-
if (
|
93
|
-
const e =
|
94
|
-
|
95
|
+
}, [u, _, s]), R(() => {
|
96
|
+
if (m) {
|
97
|
+
const e = m.map((t) => t.journey_id);
|
98
|
+
v(e);
|
95
99
|
}
|
96
|
-
}, [
|
97
|
-
|
100
|
+
}, [m]), /* @__PURE__ */ b(S.Provider, { value: U, children: [
|
101
|
+
O && /* @__PURE__ */ j(G, { children: o.map((e, t) => /* @__PURE__ */ j(N, { coachmark: e }, `coachmark-${t}`)) }),
|
98
102
|
T
|
99
103
|
] });
|
100
104
|
};
|
101
105
|
export {
|
102
|
-
|
103
|
-
|
106
|
+
S as JourneyContext,
|
107
|
+
Q as JourneyProvider
|
104
108
|
};
|
105
109
|
//# 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":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[] | null>(null);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const { data: userCompletedJourneys = null, get: getJourneyProgress } = useGetUserJourney();\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n clearJourney();\n setUserCompletedJourneyIds(prev => {\n if (prev && !prev.includes(journeyId)) {\n return [...prev, journeyId];\n }\n\n return prev;\n });\n // fire the API (doesn’t block the UI)\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\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 clearJourney();\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 timerRefs.current.push(timer);\n },\n [clearJourney],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {isJourneyActive && (\n <S.Overlay about=\"journey-overlay\" data-testid={currentJourneyId.current}>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","useGetUserJourney","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","jsx","S.Overlay","index","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAyBC,CAA0B,IAAIC,EAA8B,IAAI,GAC1F,CAACC,GAAeC,CAAgB,IAAIF,EAA4B,CAAE,CAAA,GAClE,CAACG,GAAiBC,CAAkB,IAAIJ,EAAS,EAAK,GACtDK,IAAeC,EAAO,EAAE,GACxBC,IAAmBD,KACnBE,IAAYF,EAAwC,CAAA,CAAE,GAEtD,EAAE,MAAMG,EAAsB,IAAIC,EAAmB,GACrD,EAAE,MAAMC,IAAwB,MAAM,KAAKC,EAAA,IAAuBC,KAElEC,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAhB,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEM,EAAiB,OAAO,0BAA0BS,CAAE;AAAA,QAAA;AAGvH;AAAA,MACF;AACA,MAAAZ,EAAmB,EAAI,GACvBG,EAAiB,UAAUS,GAC3BX,EAAa,UAAU,IACNH,EAAA,CAAC,GAAGe,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAAChB,EAAc,MAAM;AAAA,EAAA,G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,gBAAA0B,EAAA7C,EAAe,UAAf,EAAwB,OAAOwC,GAC7B,UAAA;AAAA,IACC7B,KAAA,gBAAAmC,EAACC,GAAA,EAAU,OAAM,mBAAkB,eAAahC,EAAiB,SAC9D,UAAAN,EAAc,IAAI,CAACuB,GAAWgB,MAC5B,gBAAAF,EAAAG,GAAA,EAAqC,WAAAjB,KAAtB,aAAagB,CAAK,EAA0B,CAC7D,EACH,CAAA;AAAA,IAED7C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
1
|
+
{"version":3,"file":"journey-context-provider.js","sources":["../../../../src/features/journey/use-journey/journey-context-provider.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { TJourneyId } from '../journey-id/journey-id-types';\nimport type {\n ICoachmarkProps,\n IJourneyContext,\n IJourneyProviderProps,\n} from './journey-context-types';\nimport type { FC } from 'react';\n\nimport { createContext, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { Coachmark } from '../comps/coachmark/coachmark';\nimport { useGetUserJourney, usePostUserJourney } from '../user-journey-api/user-journey-api';\nimport * as S from './journey-styled';\n\nexport const JourneyContext = createContext<IJourneyContext | null>(null);\n\nexport const JourneyProvider: FC<IJourneyProviderProps> = ({ children, appId, userId }) => {\n const [userCompletedJourneyIds, setUserCompletedJourneyIds] = useState<TJourneyId[]>([]);\n const [coachmarkList, setCoachmarkList] = useState<ICoachmarkProps[]>([]);\n const [isJourneyActive, setIsJourneyActive] = useState(false);\n const currentIndex = useRef(-1);\n const currentJourneyId = useRef<TJourneyId | undefined>();\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { post: postJourneyCompletion } = usePostUserJourney();\n const {\n data: userCompletedJourneys = null,\n get: getJourneyProgress,\n isProcessing,\n } = useGetUserJourney();\n\n const showCoachmarks =\n appId === '' // Otherwise coachmark stories wont work\n ? coachmarkList.length > 0\n : userCompletedJourneys && !isProcessing && coachmarkList.length > 0;\n\n const setJourney = useCallback(\n (id: TJourneyId, coachmarks: ICoachmarkProps[]) => {\n if (coachmarkList.length > 0) {\n console.error(\n `setJourney: Other Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\n }\n console.log(`setJourney: Journey ID: ${id}`);\n\n setIsJourneyActive(true);\n currentJourneyId.current = id;\n currentIndex.current = -1;\n setCoachmarkList([...coachmarks]);\n },\n [coachmarkList.length],\n );\n\n const clearJourney = useCallback(() => {\n // Clear all timers\n timerRefs.current.forEach(timer => {\n clearTimeout(timer);\n });\n timerRefs.current = [];\n currentJourneyId.current = undefined;\n currentIndex.current = -1;\n setCoachmarkList([]);\n setIsJourneyActive(false);\n }, []);\n\n const endJourney = useCallback(\n (journeyId: TJourneyId) => {\n setUserCompletedJourneyIds(prev => [...prev, journeyId]);\n postJourneyCompletion({\n app_id: appId,\n user_id: userId,\n journey_id: journeyId,\n journey_status: 'COMPLETED',\n });\n clearJourney();\n },\n [appId, clearJourney, postJourneyCompletion, userId],\n );\n\n const addCoachmark = useCallback((id: TJourneyId, coachmark: ICoachmarkProps) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`\n : `addCoachmark was called before setJourney and Journey ID is undefined`,\n );\n\n return;\n }\n\n setCoachmarkList(prev => [...prev, coachmark]);\n }, []);\n\n const nextCoachmark = useCallback(\n (id: TJourneyId, keepPrevActive: boolean = false, delayInMs: number = 0) => {\n if (!currentJourneyId.current || id !== currentJourneyId.current) {\n console.error(\n currentJourneyId.current\n ? `nextCoachmark was called before setJourney`\n : `A Journey is already active, Current Journey: ${currentJourneyId.current}, New Journey Request: ${id}`,\n );\n\n return;\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 currentJourneyId.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 timerRefs.current.push(timer);\n },\n [],\n );\n\n const memoizedContextValue: IJourneyContext = useMemo(\n () => ({\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarks: coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n }),\n [\n nextCoachmark,\n setJourney,\n addCoachmark,\n clearJourney,\n endJourney,\n coachmarkList,\n userCompletedJourneyIds,\n isJourneyActive,\n ],\n );\n\n // Get the initial state of incompleteJourneys\n useEffect(() => {\n if (appId && userId) {\n getJourneyProgress(userId, {\n app_id: appId,\n user_id: userId,\n journey_status: 'COMPLETED',\n });\n }\n }, [appId, getJourneyProgress, userId]);\n\n // Set the data to context state initially\n useEffect(() => {\n if (userCompletedJourneys) {\n const completedUserJourneysIds = userCompletedJourneys.map(journey => journey.journey_id);\n\n setUserCompletedJourneyIds(completedUserJourneysIds);\n }\n }, [userCompletedJourneys]);\n\n return (\n <JourneyContext.Provider value={memoizedContextValue}>\n {showCoachmarks && (\n <S.Overlay>\n {coachmarkList.map((coachmark, index) => (\n <Coachmark key={`coachmark-${index}`} coachmark={coachmark} />\n ))}\n </S.Overlay>\n )}\n {children}\n </JourneyContext.Provider>\n );\n};\n"],"names":["JourneyContext","createContext","JourneyProvider","children","appId","userId","userCompletedJourneyIds","setUserCompletedJourneyIds","useState","coachmarkList","setCoachmarkList","isJourneyActive","setIsJourneyActive","currentIndex","useRef","currentJourneyId","timerRefs","postJourneyCompletion","usePostUserJourney","userCompletedJourneys","getJourneyProgress","isProcessing","useGetUserJourney","showCoachmarks","setJourney","useCallback","id","coachmarks","clearJourney","timer","endJourney","journeyId","prev","addCoachmark","coachmark","nextCoachmark","keepPrevActive","delayInMs","prevList","item","currIndex","updatedCoachmarkList","memoizedContextValue","useMemo","useEffect","completedUserJourneysIds","journey","jsxs","S.Overlay","index","jsx","Coachmark"],"mappings":";;;;;AAea,MAAAA,IAAiBC,EAAsC,IAAI,GAE3DC,IAA6C,CAAC,EAAE,UAAAC,GAAU,OAAAC,GAAO,QAAAC,QAAa;AACzF,QAAM,CAACC,GAAyBC,CAA0B,IAAIC,EAAuB,CAAE,CAAA,GACjF,CAACC,GAAeC,CAAgB,IAAIF,EAA4B,CAAE,CAAA,GAClE,CAACG,GAAiBC,CAAkB,IAAIJ,EAAS,EAAK,GACtDK,IAAeC,EAAO,EAAE,GACxBC,IAAmBD,KACnBE,IAAYF,EAAwC,CAAA,CAAE,GAEtD,EAAE,MAAMG,EAAsB,IAAIC,EAAmB,GACrD;AAAA,IACJ,MAAMC,IAAwB;AAAA,IAC9B,KAAKC;AAAA,IACL,cAAAC;AAAA,MACEC,EAAkB,GAEhBC,KACJnB,MAAU,MAENe,KAAyB,CAACE,MAAgBZ,EAAc,SAAS,GAEjEe,IAAaC;AAAA,IACjB,CAACC,GAAgBC,MAAkC;AAC7C,UAAAlB,EAAc,SAAS,GAAG;AACpB,gBAAA;AAAA,UACN,iEAAiEM,EAAiB,OAAO,0BAA0BW,CAAE;AAAA,QAAA;AAGvH;AAAA,MACF;AACQ,cAAA,IAAI,2BAA2BA,CAAE,EAAE,GAE3Cd,EAAmB,EAAI,GACvBG,EAAiB,UAAUW,GAC3Bb,EAAa,UAAU,IACNH,EAAA,CAAC,GAAGiB,CAAU,CAAC;AAAA,IAClC;AAAA,IACA,CAAClB,EAAc,MAAM;AAAA,EAAA,GAGjBmB,IAAeH,EAAY,MAAM;AAE3B,IAAAT,EAAA,QAAQ,QAA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,GAAA,EACE,UAAAvC,EAAc,IAAI,CAACyB,GAAWe,MAC7B,gBAAAC,EAACC,KAAqC,WAAAjB,KAAtB,aAAae,CAAK,EAA0B,CAC7D,GACH;AAAA,IAED9C;AAAA,EACH,EAAA,CAAA;AAEJ;"}
|
@@ -1,20 +1,20 @@
|
|
1
|
-
import { jsx as
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
2
2
|
import { memo as O, useMemo as $, useCallback as M, Fragment as V } from "react";
|
3
3
|
import B from "../../../../assets/line-icons/icons/bulb2.js";
|
4
4
|
import F from "../../../../assets/line-icons/icons/practice.js";
|
5
|
-
import { IS_CHAPTER_COMPLETED_STATES as
|
5
|
+
import { IS_CHAPTER_COMPLETED_STATES as b } from "../../../milestone/create/milestone-create-constants.js";
|
6
6
|
import H from "../../../ui/arrow-tooltip/arrow-tooltip.js";
|
7
7
|
import j from "../../../ui/layout/flex-view.js";
|
8
8
|
import K from "../../comps/sheet-button/index.js";
|
9
9
|
import { NODE_TYPE as U, SHEET_STATE as W } from "../../constants/sheet.js";
|
10
10
|
import { isV3Worksheet as i } from "../../utils/is-v3-worksheet.js";
|
11
|
-
const { TARGET_PRACTICE:
|
12
|
-
if (n ===
|
11
|
+
const { TARGET_PRACTICE: v, PRACTICE: y, LEARNING: X } = U, { COMPLETED: P, IN_PROGRESS: Y } = W, q = (n, o, a) => {
|
12
|
+
if (n === P || b.some((d) => d === n))
|
13
13
|
return {
|
14
14
|
state: "completed",
|
15
15
|
renderAs: "secondary_black"
|
16
16
|
};
|
17
|
-
if ((o === y || o ===
|
17
|
+
if ((o === y || o === v) && a === "PENDING_TARGET_PRACTICE")
|
18
18
|
return {
|
19
19
|
state: "overdue",
|
20
20
|
renderAs: "tertiary"
|
@@ -25,80 +25,80 @@ const { TARGET_PRACTICE: b, PRACTICE: y, LEARNING: X } = U, { COMPLETED: v, IN_P
|
|
25
25
|
renderAs: "primary"
|
26
26
|
};
|
27
27
|
}, me = O(
|
28
|
-
({ sheetsListData: n, userType: o, isLessonDisabled: a, ...
|
29
|
-
const { lessonTagType:
|
30
|
-
(
|
31
|
-
const { permissions:
|
28
|
+
({ sheetsListData: n, userType: o, isLessonDisabled: a, ...h }) => {
|
29
|
+
const { lessonTagType: d, onStart: u, onResume: f, onReattempt: l, onReview: _, onPreview: w } = h, s = $(() => o === "STUDENT", [o]), I = M(
|
30
|
+
(e) => {
|
31
|
+
const { permissions: E, node_id: r, user_node_id: t } = e, {
|
32
32
|
can_start: c,
|
33
33
|
can_resume: m,
|
34
|
-
can_reattempt:
|
35
|
-
can_review:
|
36
|
-
can_teacher_review:
|
37
|
-
} =
|
38
|
-
if (
|
34
|
+
can_reattempt: C,
|
35
|
+
can_review: R,
|
36
|
+
can_teacher_review: T
|
37
|
+
} = E, S = s ? R : T;
|
38
|
+
if (s) {
|
39
39
|
if (c || m) {
|
40
|
-
if (c && typeof
|
41
|
-
|
40
|
+
if (c && typeof u == "function") {
|
41
|
+
u(r, i(e), t);
|
42
42
|
return;
|
43
43
|
}
|
44
|
-
if (m && typeof
|
45
|
-
|
44
|
+
if (m && typeof f == "function") {
|
45
|
+
f(r, i(e), t);
|
46
46
|
return;
|
47
47
|
}
|
48
48
|
throw new Error("No callback is available");
|
49
|
-
} else if (
|
49
|
+
} else if (C) {
|
50
50
|
if (typeof l != "function")
|
51
51
|
throw new Error("canReattempt must be a function");
|
52
|
-
l(
|
52
|
+
l(r, i(e), t);
|
53
53
|
return;
|
54
54
|
}
|
55
55
|
}
|
56
|
-
if (
|
56
|
+
if (S) {
|
57
57
|
if (typeof _ != "function")
|
58
58
|
throw new Error("onReview must be a function");
|
59
|
-
if (!
|
59
|
+
if (!t)
|
60
60
|
throw new Error("user node id must be present to review the sheet");
|
61
|
-
_(
|
61
|
+
_(t, i(e, "review"));
|
62
62
|
return;
|
63
63
|
}
|
64
|
-
if (typeof
|
64
|
+
if (typeof w != "function")
|
65
65
|
throw new Error("onPreview must be a function");
|
66
|
-
|
66
|
+
w(e, i(e));
|
67
67
|
},
|
68
|
-
[
|
68
|
+
[s, _, u, w, l, f]
|
69
69
|
);
|
70
|
-
return /* @__PURE__ */
|
70
|
+
return /* @__PURE__ */ p(j, { $flexDirection: "row", $flexGapX: 1, $alignItems: "center", children: n.map((e, E) => {
|
71
71
|
const {
|
72
|
-
node_type:
|
73
|
-
state:
|
72
|
+
node_type: r,
|
73
|
+
state: t,
|
74
74
|
permissions: c,
|
75
75
|
sheet_statement: m
|
76
|
-
} =
|
77
|
-
can_start:
|
78
|
-
can_resume:
|
79
|
-
can_reattempt:
|
80
|
-
can_review:
|
81
|
-
} = c, A =
|
82
|
-
return /* @__PURE__ */
|
76
|
+
} = e, {
|
77
|
+
can_start: C,
|
78
|
+
can_resume: R,
|
79
|
+
can_reattempt: T,
|
80
|
+
can_review: S
|
81
|
+
} = c, A = r === v ? y : r, N = r === X, D = t === "LOCKED", g = q(t, r, d), { state: k, renderAs: L } = g || {}, x = !(t === P || b.some((G) => G === t)) && !(C || R || S || T);
|
82
|
+
return /* @__PURE__ */ p(V, { children: /* @__PURE__ */ p(
|
83
83
|
H,
|
84
84
|
{
|
85
85
|
renderAs: "secondary",
|
86
86
|
position: "bottom",
|
87
87
|
tooltipItem: m,
|
88
88
|
textVariant: "ab3",
|
89
|
-
children: /* @__PURE__ */
|
89
|
+
children: /* @__PURE__ */ p(
|
90
90
|
K,
|
91
91
|
{
|
92
|
-
renderAs: L ?? (a || !
|
92
|
+
renderAs: L ?? (a || !s && D ? "secondary_grey" : "primary"),
|
93
93
|
label: A,
|
94
94
|
Icon: N ? B : F,
|
95
|
-
onClick: () =>
|
96
|
-
disabled:
|
95
|
+
onClick: () => I(e),
|
96
|
+
disabled: s && (a || x),
|
97
97
|
state: k
|
98
98
|
}
|
99
99
|
)
|
100
100
|
}
|
101
|
-
) }, `${A}__lesson_button__${
|
101
|
+
) }, `${A}__lesson_button__${E}`);
|
102
102
|
}) });
|
103
103
|
}
|
104
104
|
);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lesson-item-cta-info.js","sources":["../../../../../src/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.tsx"],"sourcesContent":["import type { TSheetButtonVariant } from '../../comps/sheet-button/types';\nimport type { ISheetDataProps } from '../../sheets-list/sheet-item/sheet-item-types';\nimport type { IGetLessonCtaInfo, ILessonItemCtaInfoProps } from './lesson-item-types';\nimport type { FC } from 'react';\n\nimport { Fragment, memo, useCallback, useMemo } from 'react';\n\nimport Bulb2Icon from '../../../../assets/line-icons/icons/bulb2';\nimport PracticeIcon from '../../../../assets/line-icons/icons/practice';\nimport { IS_CHAPTER_COMPLETED_STATES } from '../../../milestone/create/milestone-create-constants';\nimport ArrowTooltip from '../../../ui/arrow-tooltip/arrow-tooltip';\nimport FlexView from '../../../ui/layout/flex-view';\nimport SheetButton from '../../comps/sheet-button';\nimport { NODE_TYPE, SHEET_STATE } from '../../constants/sheet';\nimport { isV3Worksheet } from '../../utils/is-v3-worksheet';\n\nconst { TARGET_PRACTICE, PRACTICE, LEARNING } = NODE_TYPE;\nconst { COMPLETED, IN_PROGRESS } = SHEET_STATE;\n\nconst getLessonCtaInfo: IGetLessonCtaInfo = (state, nodeType, lessonTagType) => {\n const isSheetCompleted =\n state === COMPLETED || IS_CHAPTER_COMPLETED_STATES.some(sheetState => sheetState === state);\n\n if (isSheetCompleted) {\n return {\n state: 'completed',\n renderAs: 'secondary_black',\n };\n }\n\n if (\n (nodeType === PRACTICE || nodeType === TARGET_PRACTICE) &&\n lessonTagType === 'PENDING_TARGET_PRACTICE'\n ) {\n return {\n state: 'overdue',\n renderAs: 'tertiary',\n };\n }\n\n if (state === IN_PROGRESS) {\n return {\n state: 'in_progress',\n renderAs: 'primary',\n };\n }\n\n return undefined;\n};\n\nconst LessonItemCtaInfo: FC<ILessonItemCtaInfoProps> = memo(\n ({ sheetsListData, userType, isLessonDisabled, ...restLessonItemCtaInfoProps }) => {\n const { lessonTagType, onStart, onResume, onReattempt, onReview, onPreview } =\n restLessonItemCtaInfoProps;\n\n const isStudent = useMemo(() => userType === 'STUDENT', [userType]);\n\n const handleOnClick = useCallback(\n (sheetInfo: ISheetDataProps) => {\n const { permissions, node_id: nodeId, user_node_id: userNodeId } = sheetInfo;\n const {\n can_start: canStart,\n can_resume: canResume,\n can_reattempt: canReattempt,\n can_review: canReview,\n can_teacher_review: canTeacherReview,\n } = permissions;\n const canReviewSheet = isStudent ? canReview : canTeacherReview;\n\n if (isStudent) {\n //* Student actions\n\n if (canStart || canResume) {\n if (canStart && typeof onStart === 'function') {\n onStart(nodeId, isV3Worksheet(sheetInfo), userNodeId);\n\n return;\n }\n\n if (canResume && typeof onResume === 'function') {\n onResume(nodeId, isV3Worksheet(sheetInfo), userNodeId);\n\n return;\n }\n\n throw new Error('No callback is available');\n } else if (canReattempt) {\n if (typeof onReattempt !== 'function') {\n throw new Error('canReattempt must be a function');\n }\n\n onReattempt(nodeId, isV3Worksheet(sheetInfo), userNodeId);\n\n return;\n }\n }\n\n if (canReviewSheet) {\n if (typeof onReview !== 'function') {\n throw new Error('onReview must be a function');\n }\n\n if (!userNodeId) {\n throw new Error('user node id must be present to review the sheet');\n }\n\n onReview(userNodeId, isV3Worksheet(sheetInfo, 'review'));\n\n return;\n }\n\n if (typeof onPreview !== 'function') {\n throw new Error('onPreview must be a function');\n }\n\n onPreview(sheetInfo, isV3Worksheet(sheetInfo));\n\n return;\n },\n [isStudent, onReview, onStart, onPreview, onReattempt, onResume],\n );\n\n return (\n <FlexView $flexDirection=\"row\" $flexGapX={1} $alignItems=\"center\">\n {sheetsListData.map((sheet, idx) => {\n const {\n node_type: nodeType,\n state,\n permissions,\n sheet_statement: sheetStatement,\n } = sheet;\n const {\n can_start: canStart,\n can_resume: canResume,\n can_reattempt: canReattempt,\n can_review: canReview,\n } = permissions;\n const sheetType = nodeType === TARGET_PRACTICE ? PRACTICE : nodeType;\n const isLearningNodeType = nodeType === LEARNING;\n const isSheetLocked = state === 'LOCKED';\n\n const lessonCtaInfo = getLessonCtaInfo(state, nodeType, lessonTagType);\n const { state: lessonCtaState, renderAs } = lessonCtaInfo || {};\n\n const isSheetCompleted =\n state === COMPLETED ||\n IS_CHAPTER_COMPLETED_STATES.some(sheetState => sheetState === state);\n const sheetPermissionDisability =\n !isSheetCompleted && !(canStart || canResume || canReview || canReattempt);\n const disableCta = isStudent && (isLessonDisabled || sheetPermissionDisability);\n const sheetCtaDefaultRenderAs: TSheetButtonVariant =\n isLessonDisabled || (!isStudent && isSheetLocked) ? 'secondary_grey' : 'primary';\n\n return (\n <Fragment key={`${sheetType}__lesson_button__${idx}`}>\n <ArrowTooltip\n renderAs=\"secondary\"\n position=\"bottom\"\n tooltipItem={sheetStatement}\n textVariant=\"ab3\"\n >\n <SheetButton\n renderAs={renderAs ?? sheetCtaDefaultRenderAs}\n label={sheetType}\n Icon={isLearningNodeType ? Bulb2Icon : PracticeIcon}\n onClick={() => handleOnClick(sheet)}\n disabled={disableCta}\n state={lessonCtaState}\n />\n </ArrowTooltip>\n </Fragment>\n );\n })}\n </FlexView>\n );\n },\n);\n\nexport default LessonItemCtaInfo;\n"],"names":["TARGET_PRACTICE","PRACTICE","LEARNING","NODE_TYPE","COMPLETED","IN_PROGRESS","SHEET_STATE","getLessonCtaInfo","state","nodeType","lessonTagType","IS_CHAPTER_COMPLETED_STATES","sheetState","LessonItemCtaInfo","memo","sheetsListData","userType","isLessonDisabled","restLessonItemCtaInfoProps","onStart","onResume","onReattempt","onReview","onPreview","isStudent","useMemo","handleOnClick","useCallback","sheetInfo","permissions","nodeId","userNodeId","canStart","canResume","canReattempt","canReview","canTeacherReview","canReviewSheet","isV3Worksheet","jsx","FlexView","sheet","idx","sheetStatement","sheetType","isLearningNodeType","isSheetLocked","lessonCtaInfo","lessonCtaState","renderAs","sheetPermissionDisability","Fragment","ArrowTooltip","SheetButton","Bulb2Icon","PracticeIcon"],"mappings":";;;;;;;;;;AAgBA,MAAM,EAAE,iBAAAA,GAAiB,UAAAC,GAAU,UAAAC,EAAA,IAAaC,GAC1C,EAAE,WAAAC,GAAW,aAAAC,EAAgB,IAAAC,GAE7BC,IAAsC,CAACC,GAAOC,GAAUC,MAAkB;AAI9E,MAFEF,MAAUJ,KAAaO,EAA4B,KAAK,CAAAC,MAAcA,MAAeJ,CAAK;AAGnF,WAAA;AAAA,MACL,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAId,OACGC,MAAaR,KAAYQ,MAAaT,MACvCU,MAAkB;AAEX,WAAA;AAAA,MACL,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAId,MAAIF,MAAUH;AACL,WAAA;AAAA,MACL,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAKhB,GAEMQ,KAAiDC;AAAA,EACrD,CAAC,EAAE,gBAAAC,GAAgB,UAAAC,GAAU,kBAAAC,GAAkB,GAAGC,QAAiC;AACjF,UAAM,EAAE,eAAAR,GAAe,SAAAS,GAAS,UAAAC,GAAU,aAAAC,GAAa,UAAAC,GAAU,WAAAC,EAC/D,IAAAL,GAEIM,IAAYC,EAAQ,MAAMT,MAAa,WAAW,CAACA,CAAQ,CAAC,GAE5DU,IAAgBC;AAAA,MACpB,CAACC,MAA+B;AAC9B,cAAM,EAAE,aAAAC,GAAa,SAASC,GAAQ,cAAcC,EAAe,IAAAH,GAC7D;AAAA,UACJ,WAAWI;AAAA,UACX,YAAYC;AAAA,UACZ,eAAeC;AAAA,UACf,YAAYC;AAAA,UACZ,oBAAoBC;AAAA,QAClB,IAAAP,GACEQ,IAAiBb,IAAYW,IAAYC;AAE/C,YAAIZ;AAGF,cAAIQ,KAAYC,GAAW;AACrB,gBAAAD,KAAY,OAAOb,KAAY,YAAY;AAC7C,cAAAA,EAAQW,GAAQQ,
|
1
|
+
{"version":3,"file":"lesson-item-cta-info.js","sources":["../../../../../src/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.tsx"],"sourcesContent":["import type { TSheetButtonVariant } from '../../comps/sheet-button/types';\nimport type { ISheetDataProps } from '../../sheets-list/sheet-item/sheet-item-types';\nimport type { IGetLessonCtaInfo, ILessonItemCtaInfoProps } from './lesson-item-types';\nimport type { FC } from 'react';\n\nimport { Fragment, memo, useCallback, useMemo } from 'react';\n\nimport Bulb2Icon from '../../../../assets/line-icons/icons/bulb2';\nimport PracticeIcon from '../../../../assets/line-icons/icons/practice';\nimport { IS_CHAPTER_COMPLETED_STATES } from '../../../milestone/create/milestone-create-constants';\nimport ArrowTooltip from '../../../ui/arrow-tooltip/arrow-tooltip';\nimport FlexView from '../../../ui/layout/flex-view';\nimport SheetButton from '../../comps/sheet-button';\nimport { NODE_TYPE, SHEET_STATE } from '../../constants/sheet';\nimport { isV3Worksheet } from '../../utils/is-v3-worksheet';\n\nconst { TARGET_PRACTICE, PRACTICE, LEARNING } = NODE_TYPE;\nconst { COMPLETED, IN_PROGRESS } = SHEET_STATE;\n\nconst getLessonCtaInfo: IGetLessonCtaInfo = (state, nodeType, lessonTagType) => {\n const isSheetCompleted =\n state === COMPLETED || IS_CHAPTER_COMPLETED_STATES.some(sheetState => sheetState === state);\n\n if (isSheetCompleted) {\n return {\n state: 'completed',\n renderAs: 'secondary_black',\n };\n }\n\n if (\n (nodeType === PRACTICE || nodeType === TARGET_PRACTICE) &&\n lessonTagType === 'PENDING_TARGET_PRACTICE'\n ) {\n return {\n state: 'overdue',\n renderAs: 'tertiary',\n };\n }\n\n if (state === IN_PROGRESS) {\n return {\n state: 'in_progress',\n renderAs: 'primary',\n };\n }\n\n return undefined;\n};\n\nconst LessonItemCtaInfo: FC<ILessonItemCtaInfoProps> = memo(\n ({ sheetsListData, userType, isLessonDisabled, ...restLessonItemCtaInfoProps }) => {\n const { lessonTagType, onStart, onResume, onReattempt, onReview, onPreview } =\n restLessonItemCtaInfoProps;\n\n const isStudent = useMemo(() => userType === 'STUDENT', [userType]);\n\n const handleOnClick = useCallback(\n (sheetInfo: ISheetDataProps) => {\n const { permissions, node_id: nodeId, user_node_id: userNodeId } = sheetInfo;\n const {\n can_start: canStart,\n can_resume: canResume,\n can_reattempt: canReattempt,\n can_review: canReview,\n can_teacher_review: canTeacherReview,\n } = permissions;\n const canReviewSheet = isStudent ? canReview : canTeacherReview;\n\n if (isStudent) {\n //* Student actions\n\n if (canStart || canResume) {\n if (canStart && typeof onStart === 'function') {\n onStart(nodeId, isV3Worksheet(sheetInfo), userNodeId);\n\n return;\n }\n\n if (canResume && typeof onResume === 'function') {\n onResume(nodeId, isV3Worksheet(sheetInfo), userNodeId);\n\n return;\n }\n\n throw new Error('No callback is available');\n } else if (canReattempt) {\n if (typeof onReattempt !== 'function') {\n throw new Error('canReattempt must be a function');\n }\n\n onReattempt(nodeId, isV3Worksheet(sheetInfo), userNodeId);\n\n return;\n }\n }\n\n if (canReviewSheet) {\n if (typeof onReview !== 'function') {\n throw new Error('onReview must be a function');\n }\n\n if (!userNodeId) {\n throw new Error('user node id must be present to review the sheet');\n }\n\n onReview(userNodeId, isV3Worksheet(sheetInfo, 'review'));\n\n return;\n }\n\n if (typeof onPreview !== 'function') {\n throw new Error('onPreview must be a function');\n }\n\n onPreview(sheetInfo, isV3Worksheet(sheetInfo));\n\n return;\n },\n [isStudent, onReview, onStart, onPreview, onReattempt, onResume],\n );\n\n return (\n <FlexView $flexDirection=\"row\" $flexGapX={1} $alignItems=\"center\">\n {sheetsListData.map((sheet, idx) => {\n const {\n node_type: nodeType,\n state,\n permissions,\n sheet_statement: sheetStatement,\n } = sheet;\n const {\n can_start: canStart,\n can_resume: canResume,\n can_reattempt: canReattempt,\n can_review: canReview,\n } = permissions;\n const sheetType = nodeType === TARGET_PRACTICE ? PRACTICE : nodeType;\n const isLearningNodeType = nodeType === LEARNING;\n const isSheetLocked = state === 'LOCKED';\n\n const lessonCtaInfo = getLessonCtaInfo(state, nodeType, lessonTagType);\n const { state: lessonCtaState, renderAs } = lessonCtaInfo || {};\n\n const isSheetCompleted =\n state === COMPLETED ||\n IS_CHAPTER_COMPLETED_STATES.some(sheetState => sheetState === state);\n const sheetPermissionDisability =\n !isSheetCompleted && !(canStart || canResume || canReview || canReattempt);\n const disableCta = isStudent && (isLessonDisabled || sheetPermissionDisability);\n const sheetCtaDefaultRenderAs: TSheetButtonVariant =\n isLessonDisabled || (!isStudent && isSheetLocked) ? 'secondary_grey' : 'primary';\n\n return (\n <Fragment key={`${sheetType}__lesson_button__${idx}`}>\n <ArrowTooltip\n renderAs=\"secondary\"\n position=\"bottom\"\n tooltipItem={sheetStatement}\n textVariant=\"ab3\"\n >\n <SheetButton\n renderAs={renderAs ?? sheetCtaDefaultRenderAs}\n label={sheetType}\n Icon={isLearningNodeType ? Bulb2Icon : PracticeIcon}\n onClick={() => handleOnClick(sheet)}\n disabled={disableCta}\n state={lessonCtaState}\n />\n </ArrowTooltip>\n </Fragment>\n );\n })}\n </FlexView>\n );\n },\n);\n\nexport default LessonItemCtaInfo;\n"],"names":["TARGET_PRACTICE","PRACTICE","LEARNING","NODE_TYPE","COMPLETED","IN_PROGRESS","SHEET_STATE","getLessonCtaInfo","state","nodeType","lessonTagType","IS_CHAPTER_COMPLETED_STATES","sheetState","LessonItemCtaInfo","memo","sheetsListData","userType","isLessonDisabled","restLessonItemCtaInfoProps","onStart","onResume","onReattempt","onReview","onPreview","isStudent","useMemo","handleOnClick","useCallback","sheetInfo","permissions","nodeId","userNodeId","canStart","canResume","canReattempt","canReview","canTeacherReview","canReviewSheet","isV3Worksheet","jsx","FlexView","sheet","idx","sheetStatement","sheetType","isLearningNodeType","isSheetLocked","lessonCtaInfo","lessonCtaState","renderAs","sheetPermissionDisability","Fragment","ArrowTooltip","SheetButton","Bulb2Icon","PracticeIcon"],"mappings":";;;;;;;;;;AAgBA,MAAM,EAAE,iBAAAA,GAAiB,UAAAC,GAAU,UAAAC,EAAA,IAAaC,GAC1C,EAAE,WAAAC,GAAW,aAAAC,EAAgB,IAAAC,GAE7BC,IAAsC,CAACC,GAAOC,GAAUC,MAAkB;AAI9E,MAFEF,MAAUJ,KAAaO,EAA4B,KAAK,CAAAC,MAAcA,MAAeJ,CAA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