@cuemath/leap 3.3.24-link.2 → 3.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/features/auth/account-selector/account-selector-styled.js +5 -6
  2. package/dist/features/auth/account-selector/account-selector-styled.js.map +1 -1
  3. package/dist/features/auth/account-selector/account-selector.js +57 -51
  4. package/dist/features/auth/account-selector/account-selector.js.map +1 -1
  5. package/dist/features/auth/comps/user-list/user-list-styled.js +2 -3
  6. package/dist/features/auth/comps/user-list/user-list-styled.js.map +1 -1
  7. package/dist/features/auth/pla-signup/pla-analytics-events.js +3 -9
  8. package/dist/features/auth/pla-signup/pla-analytics-events.js.map +1 -1
  9. package/dist/features/auth/signup/circular-step-wrapper/circular-step-wrapper.js.map +1 -1
  10. package/dist/features/auth/signup/custom-input-field/custom-input-field.js +8 -8
  11. package/dist/features/auth/signup/custom-input-field/custom-input-field.js.map +1 -1
  12. package/dist/features/journey/use-journey/use-journey.js +6 -18
  13. package/dist/features/journey/use-journey/use-journey.js.map +1 -1
  14. package/dist/features/milestone/create/milestone-create-helpers.js +7 -13
  15. package/dist/features/milestone/create/milestone-create-helpers.js.map +1 -1
  16. package/dist/features/parent-dashboard/hooks/use-parent-home-data.js +34 -40
  17. package/dist/features/parent-dashboard/hooks/use-parent-home-data.js.map +1 -1
  18. package/dist/features/parent-dashboard/modals/tutor-change/tutor-change-styled.js +3 -3
  19. package/dist/features/parent-dashboard/modals/tutor-change/tutor-change-styled.js.map +1 -1
  20. package/dist/features/parent-dashboard/parent-dashboard-types.js.map +1 -1
  21. package/dist/features/parent-dashboard/parent-dashboard-view.js +138 -161
  22. package/dist/features/parent-dashboard/parent-dashboard-view.js.map +1 -1
  23. package/dist/features/stickers/constants.js +235 -0
  24. package/dist/features/stickers/constants.js.map +1 -0
  25. package/dist/features/{ui/sticker-grid/sticker-grid-styles.js → stickers/sticker-selector/comps/sticker/sticker-styled.js} +15 -45
  26. package/dist/features/stickers/sticker-selector/comps/sticker/sticker-styled.js.map +1 -0
  27. package/dist/features/stickers/sticker-selector/comps/sticker/sticker.js +49 -0
  28. package/dist/features/stickers/sticker-selector/comps/sticker/sticker.js.map +1 -0
  29. package/dist/features/stickers/sticker-selector/comps/stiker-selector-grid/sticker-selector-grid-styled.js +28 -0
  30. package/dist/features/stickers/sticker-selector/comps/stiker-selector-grid/sticker-selector-grid-styled.js.map +1 -0
  31. package/dist/features/stickers/sticker-selector/comps/stiker-selector-grid/sticker-selector-grid.js +26 -0
  32. package/dist/features/stickers/sticker-selector/comps/stiker-selector-grid/sticker-selector-grid.js.map +1 -0
  33. package/dist/features/stickers/sticker-selector/sticker-selector-styled.js +13 -0
  34. package/dist/features/stickers/sticker-selector/sticker-selector-styled.js.map +1 -0
  35. package/dist/features/stickers/sticker-selector/sticker-selector.js +86 -0
  36. package/dist/features/stickers/sticker-selector/sticker-selector.js.map +1 -0
  37. package/dist/features/stickers/stickers-effects/stickers-effects-animations.js +82 -0
  38. package/dist/features/stickers/stickers-effects/stickers-effects-animations.js.map +1 -0
  39. package/dist/features/stickers/stickers-effects/stickers-effects-cache.js +19 -0
  40. package/dist/features/stickers/stickers-effects/stickers-effects-cache.js.map +1 -0
  41. package/dist/features/stickers/stickers-effects/stickers-effects-helper.js +105 -0
  42. package/dist/features/stickers/stickers-effects/stickers-effects-helper.js.map +1 -0
  43. package/dist/features/stickers/stickers-effects/stickers-effects-styled.js +37 -0
  44. package/dist/features/stickers/stickers-effects/stickers-effects-styled.js.map +1 -0
  45. package/dist/features/stickers/stickers-effects/stickers-effects.js +67 -0
  46. package/dist/features/stickers/stickers-effects/stickers-effects.js.map +1 -0
  47. package/dist/features/trial-session/comps/class-preference/class-preference.js +49 -61
  48. package/dist/features/trial-session/comps/class-preference/class-preference.js.map +1 -1
  49. package/dist/features/trial-session/comps/session-report/session-report.js +15 -15
  50. package/dist/features/trial-session/comps/session-report/session-report.js.map +1 -1
  51. package/dist/features/trial-session/comps/student-feedback/student-feedback-constants.js +0 -5
  52. package/dist/features/trial-session/comps/student-feedback/student-feedback-constants.js.map +1 -1
  53. package/dist/features/trial-session/comps/student-feedback/student-feedback.js +51 -96
  54. package/dist/features/trial-session/comps/student-feedback/student-feedback.js.map +1 -1
  55. package/dist/features/trial-session/comps/student-profile/student-profile.js +63 -70
  56. package/dist/features/trial-session/comps/student-profile/student-profile.js.map +1 -1
  57. package/dist/features/trial-session/helper.js +54 -71
  58. package/dist/features/trial-session/helper.js.map +1 -1
  59. package/dist/features/trial-session/hooks/use-trial-session-navigation.js +130 -149
  60. package/dist/features/trial-session/hooks/use-trial-session-navigation.js.map +1 -1
  61. package/dist/features/trial-session/trial-session-types.js.map +1 -1
  62. package/dist/features/trial-session/trial-session-view.js +98 -107
  63. package/dist/features/trial-session/trial-session-view.js.map +1 -1
  64. package/dist/features/ui/dot-lottie-animations/dot-lottie-animation.js +88 -75
  65. package/dist/features/ui/dot-lottie-animations/dot-lottie-animation.js.map +1 -1
  66. package/dist/features/ui/lottie-animation/lottie-animation.js +55 -46
  67. package/dist/features/ui/lottie-animation/lottie-animation.js.map +1 -1
  68. package/dist/features/ui/modals/modal-styled.js +48 -15
  69. package/dist/features/ui/modals/modal-styled.js.map +1 -1
  70. package/dist/features/ui/modals/modal.js +46 -38
  71. package/dist/features/ui/modals/modal.js.map +1 -1
  72. package/dist/index.d.ts +71 -66
  73. package/dist/index.js +391 -401
  74. package/dist/index.js.map +1 -1
  75. package/package.json +3 -2
  76. package/dist/features/auth/account-selector/comps/compact-header/account-selector-header.js +0 -31
  77. package/dist/features/auth/account-selector/comps/compact-header/account-selector-header.js.map +0 -1
  78. package/dist/features/parent-dashboard/api/cancel-subscription.js +0 -9
  79. package/dist/features/parent-dashboard/api/cancel-subscription.js.map +0 -1
  80. package/dist/features/parent-dashboard/comps/billing-information/billing-information-styled.js +0 -20
  81. package/dist/features/parent-dashboard/comps/billing-information/billing-information-styled.js.map +0 -1
  82. package/dist/features/parent-dashboard/comps/billing-information/billing-information.js +0 -96
  83. package/dist/features/parent-dashboard/comps/billing-information/billing-information.js.map +0 -1
  84. package/dist/features/parent-dashboard/modals/cancel-subscription/cancel-subscription-constants.js +0 -21
  85. package/dist/features/parent-dashboard/modals/cancel-subscription/cancel-subscription-constants.js.map +0 -1
  86. package/dist/features/parent-dashboard/modals/cancel-subscription/cancel-subscription.js +0 -80
  87. package/dist/features/parent-dashboard/modals/cancel-subscription/cancel-subscription.js.map +0 -1
  88. package/dist/features/parent-dashboard/modals/cancellation-confirmation/cancellation-confirmation.js +0 -23
  89. package/dist/features/parent-dashboard/modals/cancellation-confirmation/cancellation-confirmation.js.map +0 -1
  90. package/dist/features/parent-dashboard/modals/cancellation-reason/cancellation-reason-constant.js +0 -55
  91. package/dist/features/parent-dashboard/modals/cancellation-reason/cancellation-reason-constant.js.map +0 -1
  92. package/dist/features/parent-dashboard/modals/cancellation-reason/cancellation-reason-styled.js +0 -59
  93. package/dist/features/parent-dashboard/modals/cancellation-reason/cancellation-reason-styled.js.map +0 -1
  94. package/dist/features/parent-dashboard/modals/cancellation-reason/cancellation-reason.js +0 -93
  95. package/dist/features/parent-dashboard/modals/cancellation-reason/cancellation-reason.js.map +0 -1
  96. package/dist/features/parent-dashboard/modals/hooks/use-pla-model-handlers.js +0 -63
  97. package/dist/features/parent-dashboard/modals/hooks/use-pla-model-handlers.js.map +0 -1
  98. package/dist/features/parent-dashboard/modals/view-payment-method/view-payment-method.js +0 -65
  99. package/dist/features/parent-dashboard/modals/view-payment-method/view-payment-method.js.map +0 -1
  100. package/dist/features/student-username/add/add-student-username-constants.js +0 -6
  101. package/dist/features/student-username/add/add-student-username-constants.js.map +0 -1
  102. package/dist/features/student-username/add/add-student-username-helpers.js +0 -6
  103. package/dist/features/student-username/add/add-student-username-helpers.js.map +0 -1
  104. package/dist/features/student-username/add/add-student-username-styled.js +0 -10
  105. package/dist/features/student-username/add/add-student-username-styled.js.map +0 -1
  106. package/dist/features/student-username/add/add-student-username.js +0 -78
  107. package/dist/features/student-username/add/add-student-username.js.map +0 -1
  108. package/dist/features/student-username/add/api/update-username.js +0 -9
  109. package/dist/features/student-username/add/api/update-username.js.map +0 -1
  110. package/dist/features/student-username/add/api/username-availability.js +0 -10
  111. package/dist/features/student-username/add/api/username-availability.js.map +0 -1
  112. package/dist/features/student-username/add/hooks/use-check-username-availability.js +0 -41
  113. package/dist/features/student-username/add/hooks/use-check-username-availability.js.map +0 -1
  114. package/dist/features/trial-session/api/teacher-availability.js +0 -9
  115. package/dist/features/trial-session/api/teacher-availability.js.map +0 -1
  116. package/dist/features/trial-session/comps/class-preference/helpers.js +0 -28
  117. package/dist/features/trial-session/comps/class-preference/helpers.js.map +0 -1
  118. package/dist/features/ui/sticker-grid/sticker-grid-styles.js.map +0 -1
  119. package/dist/features/ui/sticker-grid/sticker-grid.js +0 -24
  120. package/dist/features/ui/sticker-grid/sticker-grid.js.map +0 -1
  121. package/dist/features/ui/sticker-grid/sticker.js +0 -57
  122. package/dist/features/ui/sticker-grid/sticker.js.map +0 -1
  123. package/dist/features/ui/stickers/constants.js +0 -6
  124. package/dist/features/ui/stickers/constants.js.map +0 -1
  125. package/dist/features/ui/stickers/stickers-effects.js +0 -64
  126. package/dist/features/ui/stickers/stickers-effects.js.map +0 -1
  127. package/dist/features/ui/stickers/stickers-styled.js +0 -29
  128. package/dist/features/ui/stickers/stickers-styled.js.map +0 -1
  129. package/dist/features/ui/stickers/stickers-utils.js +0 -91
  130. package/dist/features/ui/stickers/stickers-utils.js.map +0 -1
  131. package/dist/features/ui/stickers/stickers.js +0 -40
  132. package/dist/features/ui/stickers/stickers.js.map +0 -1
@@ -0,0 +1,82 @@
1
+ import { keyframes as i, css as t } from "styled-components";
2
+ import { randomizeDuration as a } from "./stickers-effects-helper.js";
3
+ const r = i`
4
+ 0% {
5
+ opacity: 1;
6
+ visibility: visible;
7
+ }
8
+ 80% {
9
+ opacity: 0.5;
10
+ }
11
+ 100% {
12
+ opacity: 0;
13
+ visibility: visible;
14
+ }
15
+ `, e = i`
16
+ 0% {
17
+ transform: translateY(0vh);
18
+ visibility: visible;
19
+ }
20
+ 100% {
21
+ transform: translateY(-100vh);
22
+ visibility: visible;
23
+ }
24
+ `, n = i`
25
+ 0% {
26
+ transform: translateY(0vh);
27
+ visibility: visible;
28
+ }
29
+ 100% {
30
+ transform: translateY(100vh);
31
+ visibility: visible;
32
+ }
33
+ `, o = i`
34
+ 0% {
35
+ transform: translateX(var(--from-x)) translateY(var(--from-y)) scale(1);
36
+ visibility: visible;
37
+ }
38
+ 100% {
39
+ transform: translateX(0vw) translateY(0vh) scale(1.25);
40
+ visibility: visible;
41
+ }
42
+ `, l = i`
43
+ 0% {
44
+ transform: translateX(0) translateY(0vh);
45
+ visibility: visible;
46
+ }
47
+ 35% {
48
+ transform: translateX(0) translateY(-50vh) scale(1.25);
49
+ }
50
+ 60% {
51
+ transform: translateX(var(--from-x)) translateY(var(--from-y)) scale(1.25);
52
+ }
53
+ 100% {
54
+ transform: translateX(var(--from-x)) translateY(-110vh) scale(1.25);
55
+ visibility: visible;
56
+ }
57
+ `, v = {
58
+ "float-up": (s) => t`
59
+ animation:
60
+ ${e} ${a(s)}ms ease-out forwards,
61
+ ${r} ${a(s)}ms ease-in forwards;
62
+ `,
63
+ "fall-down": (s) => t`
64
+ animation:
65
+ ${n} ${a(s)}ms ease-out forwards,
66
+ ${r} ${a(s)}ms ease-in forwards;
67
+ `,
68
+ "burst-from-edges": (s) => t`
69
+ animation:
70
+ ${o} ${a(s)}ms linear forwards,
71
+ ${r} ${a(s)}ms ease-in forwards;
72
+ `,
73
+ "pop-expand": (s) => t`
74
+ animation:
75
+ ${l} ${s}ms cubic-bezier(0.5, 0.1, 0.7, 1) forwards,
76
+ ${r} ${s}ms ease-in forwards;
77
+ `
78
+ };
79
+ export {
80
+ v as effectAnimations
81
+ };
82
+ //# sourceMappingURL=stickers-effects-animations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stickers-effects-animations.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects-animations.ts"],"sourcesContent":["import type { IStickersProps } from './stickers-effects-types';\n\nimport { keyframes, css } from 'styled-components';\n\nimport { randomizeDuration } from './stickers-effects-helper';\n\nconst fadeOutEaseIn = keyframes`\n 0% {\n opacity: 1;\n visibility: visible;\n }\n 80% {\n opacity: 0.5;\n }\n 100% {\n opacity: 0;\n visibility: visible;\n }\n`;\n\nconst floatUp = keyframes`\n 0% {\n transform: translateY(0vh);\n visibility: visible;\n }\n 100% {\n transform: translateY(-100vh);\n visibility: visible;\n }\n`;\n\nconst fallDown = keyframes`\n 0% {\n transform: translateY(0vh);\n visibility: visible;\n }\n 100% {\n transform: translateY(100vh);\n visibility: visible;\n }\n`;\n\nconst burstFromEdges = keyframes`\n 0% {\n transform: translateX(var(--from-x)) translateY(var(--from-y)) scale(1);\n visibility: visible;\n }\n 100% {\n transform: translateX(0vw) translateY(0vh) scale(1.25);\n visibility: visible;\n }\n`;\n\nconst popExpand = keyframes`\n 0% {\n transform: translateX(0) translateY(0vh);\n visibility: visible;\n }\n 35% {\n transform: translateX(0) translateY(-50vh) scale(1.25);\n }\n 60% {\n transform: translateX(var(--from-x)) translateY(var(--from-y)) scale(1.25);\n }\n 100% {\n transform: translateX(var(--from-x)) translateY(-110vh) scale(1.25);\n visibility: visible;\n }\n`;\n\nexport const effectAnimations: Record<\n IStickersProps['effect'],\n (duration: number) => ReturnType<typeof css>\n> = {\n 'float-up': (duration: number) => css`\n animation:\n ${floatUp} ${randomizeDuration(duration)}ms ease-out forwards,\n ${fadeOutEaseIn} ${randomizeDuration(duration)}ms ease-in forwards;\n `,\n 'fall-down': (duration: number) => css`\n animation:\n ${fallDown} ${randomizeDuration(duration)}ms ease-out forwards,\n ${fadeOutEaseIn} ${randomizeDuration(duration)}ms ease-in forwards;\n `,\n 'burst-from-edges': (duration: number) => css`\n animation:\n ${burstFromEdges} ${randomizeDuration(duration)}ms linear forwards,\n ${fadeOutEaseIn} ${randomizeDuration(duration)}ms ease-in forwards;\n `,\n 'pop-expand': (duration: number) => css`\n animation:\n ${popExpand} ${duration}ms cubic-bezier(0.5, 0.1, 0.7, 1) forwards,\n ${fadeOutEaseIn} ${duration}ms ease-in forwards;\n `,\n};\n"],"names":["fadeOutEaseIn","keyframes","floatUp","fallDown","burstFromEdges","popExpand","effectAnimations","duration","css","randomizeDuration"],"mappings":";;AAMA,MAAMA,IAAgBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAchBC,IAAUD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWVE,IAAWF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWXG,IAAiBH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWjBI,IAAYJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAiBLK,IAGT;AAAA,EACF,YAAY,CAACC,MAAqBC;AAAA;AAAA,QAE5BN,CAAO,IAAIO,EAAkBF,CAAQ,CAAC;AAAA,QACtCP,CAAa,IAAIS,EAAkBF,CAAQ,CAAC;AAAA;AAAA,EAElD,aAAa,CAACA,MAAqBC;AAAA;AAAA,QAE7BL,CAAQ,IAAIM,EAAkBF,CAAQ,CAAC;AAAA,QACvCP,CAAa,IAAIS,EAAkBF,CAAQ,CAAC;AAAA;AAAA,EAElD,oBAAoB,CAACA,MAAqBC;AAAA;AAAA,QAEpCJ,CAAc,IAAIK,EAAkBF,CAAQ,CAAC;AAAA,QAC7CP,CAAa,IAAIS,EAAkBF,CAAQ,CAAC;AAAA;AAAA,EAElD,cAAc,CAACA,MAAqBC;AAAA;AAAA,QAE9BH,CAAS,IAAIE,CAAQ;AAAA,QACrBP,CAAa,IAAIO,CAAQ;AAAA;AAEjC;"}
@@ -0,0 +1,19 @@
1
+ const o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
2
+ async function r(t) {
3
+ if (o.has(t))
4
+ return o.get(t);
5
+ if (n.has(t))
6
+ return n.get(t);
7
+ const i = fetch(t).then(async (e) => {
8
+ if (!e.ok) return null;
9
+ const a = t.endsWith(".lottie") ? await e.arrayBuffer() : await e.json();
10
+ return o.set(t, a), a;
11
+ }).catch((e) => (console.error("Lottie preload error:", e), null)).finally(() => {
12
+ n.delete(t);
13
+ });
14
+ return n.set(t, i), i;
15
+ }
16
+ export {
17
+ r as preloadLottieFile
18
+ };
19
+ //# sourceMappingURL=stickers-effects-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stickers-effects-cache.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects-cache.ts"],"sourcesContent":["import type { Data } from '@lottiefiles/dotlottie-web';\n\nconst lottieCache = new Map<string, Data>();\nconst lottiePromises = new Map<string, Promise<Data | null>>();\n\nexport async function preloadLottieFile(url: string): Promise<Data | null> {\n if (lottieCache.has(url)) {\n return lottieCache.get(url)!;\n }\n\n if (lottiePromises.has(url)) {\n return lottiePromises.get(url)!;\n }\n\n const fetchPromise = fetch(url)\n .then(async res => {\n if (!res.ok) return null;\n\n const isLottieFile = url.endsWith('.lottie');\n const data = isLottieFile ? await res.arrayBuffer() : await res.json();\n\n lottieCache.set(url, data);\n\n return data;\n })\n .catch(err => {\n // eslint-disable-next-line no-console\n console.error('Lottie preload error:', err);\n\n return null;\n })\n .finally(() => {\n lottiePromises.delete(url);\n });\n\n lottiePromises.set(url, fetchPromise);\n\n return fetchPromise;\n}\n"],"names":["lottieCache","lottiePromises","preloadLottieFile","url","fetchPromise","res","data","err"],"mappings":"AAEA,MAAMA,wBAAkB,OAClBC,wBAAqB;AAE3B,eAAsBC,EAAkBC,GAAmC;AACrE,MAAAH,EAAY,IAAIG,CAAG;AACd,WAAAH,EAAY,IAAIG,CAAG;AAGxB,MAAAF,EAAe,IAAIE,CAAG;AACjB,WAAAF,EAAe,IAAIE,CAAG;AAG/B,QAAMC,IAAe,MAAMD,CAAG,EAC3B,KAAK,OAAME,MAAO;AACb,QAAA,CAACA,EAAI,GAAW,QAAA;AAGd,UAAAC,IADeH,EAAI,SAAS,SAAS,IACf,MAAME,EAAI,gBAAgB,MAAMA,EAAI;AAEpD,WAAAL,EAAA,IAAIG,GAAKG,CAAI,GAElBA;AAAA,EAAA,CACR,EACA,MAAM,CAAOC,OAEJ,QAAA,MAAM,yBAAyBA,CAAG,GAEnC,KACR,EACA,QAAQ,MAAM;AACb,IAAAN,EAAe,OAAOE,CAAG;AAAA,EAAA,CAC1B;AAEY,SAAAF,EAAA,IAAIE,GAAKC,CAAY,GAE7BA;AACT;"}
@@ -0,0 +1,105 @@
1
+ import { STICKERS_DATA as k } from "../constants.js";
2
+ const b = (o, e) => {
3
+ const t = Math.ceil(e / 4), a = Math.floor(o / t), m = o % t, p = ["top", "right", "bottom", "left"][a] ?? "left", c = (m + 0.5) / t * 100, i = (Math.random() - 0.5) * 25, r = Math.min(Math.max(c + i, 0), 100), l = 45 + Math.random() * 10, s = 45 + Math.random() * 10;
4
+ let n = 0, h = 0;
5
+ switch (p) {
6
+ case "top":
7
+ n = r - l, h = -s + i;
8
+ break;
9
+ case "right":
10
+ n = 100 - l + i, h = r - s;
11
+ break;
12
+ case "bottom":
13
+ n = r - l, h = 100 - s + i;
14
+ break;
15
+ case "left":
16
+ n = -l + i, h = r - s;
17
+ break;
18
+ }
19
+ return {
20
+ fromX: `${n}vw`,
21
+ fromY: `${h}vh`,
22
+ x: l,
23
+ y: s
24
+ };
25
+ }, w = (o, e = 10) => {
26
+ const t = [];
27
+ let a = 0;
28
+ const m = o;
29
+ for (; t.length < o && a < m; ) {
30
+ const d = Math.floor(Math.random() * (100 - 2 * e) + e);
31
+ t.every((p) => Math.abs(p - d) >= e) && t.push(d), a++;
32
+ }
33
+ for (; t.length < o; )
34
+ t.push(Math.floor(Math.random() * (100 - 2 * e) + e));
35
+ return t;
36
+ };
37
+ function y({
38
+ count: o,
39
+ effect: e,
40
+ stickerId: t,
41
+ minSize: a,
42
+ maxSize: m
43
+ }) {
44
+ const d = 100 / o * 2, p = () => Math.random() * (m - a) + a, c = [], i = ["float-up", "fall-down"].includes(e) ? w(o, d) : [];
45
+ for (let r = 0; r < o; r++) {
46
+ const { emoji: l = "", lottieUrl: s } = k.find(({ id: f }) => f === t) || {}, n = p(), h = i[r], M = { id: t, sticker: l, size: n };
47
+ switch (e) {
48
+ case "float-up":
49
+ c.push({
50
+ ...M,
51
+ x: h,
52
+ y: 110 + (Math.random() - 0.5) * n,
53
+ lottie: s
54
+ });
55
+ break;
56
+ case "fall-down":
57
+ c.push({
58
+ ...M,
59
+ x: h,
60
+ y: -10 + (Math.random() - 0.5) * n,
61
+ lottie: s
62
+ });
63
+ break;
64
+ case "burst-from-edges": {
65
+ const { x: f, y: u, fromX: x, fromY: g } = b(r, o);
66
+ c.push({
67
+ ...M,
68
+ x: f,
69
+ y: u,
70
+ fromX: x,
71
+ fromY: g,
72
+ size: n,
73
+ lottie: s
74
+ });
75
+ break;
76
+ }
77
+ case "pop-expand":
78
+ c.push({
79
+ ...M,
80
+ x: 50,
81
+ y: 100,
82
+ fromX: `${(Math.random() - 0.5) * 27.5}vw`,
83
+ fromY: `${-50 - Math.random() * 27.5}vh`,
84
+ lottie: s
85
+ });
86
+ break;
87
+ default:
88
+ c.push({
89
+ ...M,
90
+ x: Math.random() * 100,
91
+ y: Math.random() * 100
92
+ });
93
+ }
94
+ }
95
+ return c;
96
+ }
97
+ const P = (o, e = 0.2) => {
98
+ const t = o * e, a = o - t, m = o + t;
99
+ return Math.floor(Math.random() * (m - a + 1)) + a;
100
+ };
101
+ export {
102
+ y as generateStickerData,
103
+ P as randomizeDuration
104
+ };
105
+ //# sourceMappingURL=stickers-effects-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stickers-effects-helper.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects-helper.ts"],"sourcesContent":["import type { TStickerData, IGenerateStickersData } from './stickers-effects-types';\n\nimport { STICKERS_DATA } from '../constants';\n\nconst getBurstPosition = (\n index: number,\n total: number,\n): {\n fromX: string;\n fromY: string;\n x: number;\n y: number;\n} => {\n const countPerSide = Math.ceil(total / 4);\n const sideIndex = Math.floor(index / countPerSide);\n const pos = index % countPerSide;\n\n const sides = ['top', 'right', 'bottom', 'left'] as const;\n const side = sides[sideIndex] ?? 'left';\n\n const basePercent = ((pos + 0.5) / countPerSide) * 100;\n const jitter = (Math.random() - 0.5) * 25;\n const edgePercent = Math.min(Math.max(basePercent + jitter, 0), 100);\n\n const centerX = 45 + Math.random() * 10;\n const centerY = 45 + Math.random() * 10;\n\n let fromX = 0;\n let fromY = 0;\n\n switch (side) {\n case 'top':\n fromX = edgePercent - centerX;\n fromY = -centerY + jitter;\n break;\n case 'right':\n fromX = 100 - centerX + jitter;\n fromY = edgePercent - centerY;\n break;\n case 'bottom':\n fromX = edgePercent - centerX;\n fromY = 100 - centerY + jitter;\n break;\n case 'left':\n fromX = -centerX + jitter;\n fromY = edgePercent - centerY;\n break;\n }\n\n return {\n fromX: `${fromX}vw`,\n fromY: `${fromY}vh`,\n x: centerX,\n y: centerY,\n };\n};\n\nconst getRandomNonOverlappingPositions = (count: number, buffer = 10): number[] => {\n const used: number[] = [];\n let attempts = 0;\n const maxAttempts = count;\n\n while (used.length < count && attempts < maxAttempts) {\n const value = Math.floor(Math.random() * (100 - 2 * buffer) + buffer);\n\n if (used.every(v => Math.abs(v - value) >= buffer)) {\n used.push(value);\n }\n attempts++;\n }\n\n while (used.length < count) {\n used.push(Math.floor(Math.random() * (100 - 2 * buffer) + buffer));\n }\n\n return used;\n};\n\nexport function generateStickerData({\n count,\n effect,\n stickerId,\n minSize,\n maxSize,\n}: IGenerateStickersData): TStickerData[] {\n const buffer = (100 / count) * 2;\n const getSize = () => Math.random() * (maxSize - minSize) + minSize;\n const result: TStickerData[] = [];\n const xPositions = ['float-up', 'fall-down'].includes(effect)\n ? getRandomNonOverlappingPositions(count, buffer)\n : [];\n\n for (let i = 0; i < count; i++) {\n const { emoji: sticker = '', lottieUrl: lottie } =\n STICKERS_DATA.find(({ id }) => id === stickerId) || {};\n\n const size = getSize();\n const x = xPositions[i]!;\n const common = { id: stickerId, sticker, size };\n\n switch (effect) {\n case 'float-up':\n result.push({\n ...common,\n x,\n y: 110 + (Math.random() - 0.5) * size,\n lottie: lottie,\n });\n break;\n\n case 'fall-down':\n result.push({\n ...common,\n x,\n y: -10 + (Math.random() - 0.5) * size,\n lottie: lottie,\n });\n break;\n\n case 'burst-from-edges': {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { x, y, fromX, fromY } = getBurstPosition(i, count);\n\n result.push({\n ...common,\n x,\n y,\n fromX,\n fromY,\n size,\n lottie: lottie,\n });\n break;\n }\n\n case 'pop-expand':\n result.push({\n ...common,\n x: 50,\n y: 100,\n fromX: `${(Math.random() - 0.5) * 27.5}vw`,\n fromY: `${-50 - Math.random() * 27.5}vh`,\n lottie: lottie,\n });\n break;\n\n default:\n result.push({\n ...common,\n x: Math.random() * 100,\n y: Math.random() * 100,\n });\n }\n }\n\n return result;\n}\n\nexport const randomizeDuration = (base: number, variancePercent = 0.2): number => {\n const delta = base * variancePercent;\n const min = base - delta;\n const max = base + delta;\n\n return Math.floor(Math.random() * (max - min + 1)) + min;\n};\n"],"names":["getBurstPosition","index","total","countPerSide","sideIndex","pos","side","basePercent","jitter","edgePercent","centerX","centerY","fromX","fromY","getRandomNonOverlappingPositions","count","buffer","used","attempts","maxAttempts","value","v","generateStickerData","effect","stickerId","minSize","maxSize","getSize","result","xPositions","i","sticker","lottie","STICKERS_DATA","id","size","x","common","y","randomizeDuration","base","variancePercent","delta","min","max"],"mappings":";AAIA,MAAMA,IAAmB,CACvBC,GACAC,MAMG;AACH,QAAMC,IAAe,KAAK,KAAKD,IAAQ,CAAC,GAClCE,IAAY,KAAK,MAAMH,IAAQE,CAAY,GA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;AAAA,UACA,OAAAC;AAAA,UACA,MAAAsB;AAAA,UACA,QAAAH;AAAA,QAAA,CACD;AACD;AAAA,MACF;AAAA,MAEA,KAAK;AACH,QAAAJ,EAAO,KAAK;AAAA,UACV,GAAGS;AAAA,UACH,GAAG;AAAA,UACH,GAAG;AAAA,UACH,OAAO,IAAI,KAAK,OAAO,IAAI,OAAO,IAAI;AAAA,UACtC,OAAO,GAAG,MAAM,KAAK,WAAW,IAAI;AAAA,UACpC,QAAAL;AAAA,QAAA,CACD;AACD;AAAA,MAEF;AACE,QAAAJ,EAAO,KAAK;AAAA,UACV,GAAGS;AAAA,UACH,GAAG,KAAK,OAAA,IAAW;AAAA,UACnB,GAAG,KAAK,OAAA,IAAW;AAAA,QAAA,CACpB;AAAA,IACL;AAAA,EACF;AAEO,SAAAT;AACT;AAEO,MAAMW,IAAoB,CAACC,GAAcC,IAAkB,QAAgB;AAChF,QAAMC,IAAQF,IAAOC,GACfE,IAAMH,IAAOE,GACbE,IAAMJ,IAAOE;AAEZ,SAAA,KAAK,MAAM,KAAK,OAAA,KAAYE,IAAMD,IAAM,EAAE,IAAIA;AACvD;"}
@@ -0,0 +1,37 @@
1
+ import o, { css as n } from "styled-components";
2
+ import { effectAnimations as r } from "./stickers-effects-animations.js";
3
+ const d = o.div`
4
+ position: relative;
5
+ width: 100vw;
6
+ height: 100vh;
7
+ background: transparent;
8
+ pointer-events: none;
9
+ `, h = o.div`
10
+ position: absolute;
11
+ z-index: 10;
12
+
13
+ left: ${({ x: i }) => `${i}%`};
14
+ top: ${({ y: i }) => `${i}%`};
15
+ width: ${({ size: i }) => `${i}px`};
16
+ height: ${({ size: i }) => `${i}px`};
17
+ font-size: ${({ size: i }) => `${i}px`};
18
+
19
+ pointer-events: none;
20
+ visibility: hidden;
21
+ animation-fill-mode: both;
22
+
23
+ ${({ effect: i, duration: $, delay: s = 0, fromX: t, fromY: e }) => n`
24
+ ${r[i]($)}
25
+ animation-delay: ${s}ms;
26
+
27
+ ${t && e && n`
28
+ --from-x: ${t};
29
+ --from-y: ${e};
30
+ `}
31
+ `}
32
+ `;
33
+ export {
34
+ d as Container,
35
+ h as Sticker
36
+ };
37
+ //# sourceMappingURL=stickers-effects-styled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stickers-effects-styled.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects-styled.ts"],"sourcesContent":["import type { IStickersProps } from './stickers-effects-types';\n\nimport styled, { css } from 'styled-components';\n\nimport { effectAnimations } from './stickers-effects-animations';\n\nexport const Container = styled.div`\n position: relative;\n width: 100vw;\n height: 100vh;\n background: transparent;\n pointer-events: none;\n`;\n\nexport const Sticker = styled.div<{\n effect: IStickersProps['effect'];\n duration: number;\n delay?: number;\n fromX?: string;\n fromY?: string;\n x: number;\n y: number;\n size: number;\n}>`\n position: absolute;\n z-index: 10;\n\n left: ${({ x }) => `${x}%`};\n top: ${({ y }) => `${y}%`};\n width: ${({ size }) => `${size}px`};\n height: ${({ size }) => `${size}px`};\n font-size: ${({ size }) => `${size}px`};\n\n pointer-events: none;\n visibility: hidden;\n animation-fill-mode: both;\n\n ${({ effect, duration, delay = 0, fromX, fromY }) => css`\n ${effectAnimations[effect](duration)}\n animation-delay: ${delay}ms;\n\n ${fromX &&\n fromY &&\n css`\n --from-x: ${fromX};\n --from-y: ${fromY};\n `}\n `}\n`;\n"],"names":["Container","styled","Sticker","x","y","size","effect","duration","delay","fromX","fromY","css","effectAnimations"],"mappings":";;AAMO,MAAMA,IAAYC,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQnBC,IAAUD,EAAO;AAAA;AAAA;AAAA;AAAA,UAapB,CAAC,EAAE,GAAAE,EAAQ,MAAA,GAAGA,CAAC,GAAG;AAAA,SACnB,CAAC,EAAE,GAAAC,EAAQ,MAAA,GAAGA,CAAC,GAAG;AAAA,WAChB,CAAC,EAAE,MAAAC,EAAW,MAAA,GAAGA,CAAI,IAAI;AAAA,YACxB,CAAC,EAAE,MAAAA,EAAW,MAAA,GAAGA,CAAI,IAAI;AAAA,eACtB,CAAC,EAAE,MAAAA,EAAW,MAAA,GAAGA,CAAI,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMpC,CAAC,EAAE,QAAAC,GAAQ,UAAAC,GAAU,OAAAC,IAAQ,GAAG,OAAAC,GAAO,OAAAC,EAAY,MAAAC;AAAA,MACjDC,EAAiBN,CAAM,EAAEC,CAAQ,CAAC;AAAA,uBACjBC,CAAK;AAAA;AAAA,MAEtBC,KACFC,KACAC;AAAA,kBACcF,CAAK;AAAA,kBACLC,CAAK;AAAA,KAClB;AAAA,GACF;AAAA;"}
@@ -0,0 +1,67 @@
1
+ import { jsx as n, Fragment as x } from "react/jsx-runtime";
2
+ import { memo as p, useState as l, useEffect as d } from "react";
3
+ import E from "../../ui/dot-lottie-animations/dot-lottie-animation.js";
4
+ import { preloadLottieFile as F } from "./stickers-effects-cache.js";
5
+ import { generateStickerData as y } from "./stickers-effects-helper.js";
6
+ import { Container as z, Sticker as L } from "./stickers-effects-styled.js";
7
+ const T = p(({ url: t, sticker: i, size: o }) => {
8
+ const [r, f] = l(), [c, e] = l(!1), s = {
9
+ loop: !0,
10
+ autoplay: !0
11
+ };
12
+ return d(() => {
13
+ let a = !0;
14
+ if (t)
15
+ return F(t).then((m) => {
16
+ a && (m ? f(m) : e(!0));
17
+ }).catch(() => {
18
+ a && e(!0);
19
+ }), () => {
20
+ a = !1;
21
+ };
22
+ }, [t]), !t || c || !r ? /* @__PURE__ */ n(x, { children: i }) : /* @__PURE__ */ n(
23
+ E,
24
+ {
25
+ data: r,
26
+ width: o,
27
+ height: o,
28
+ settings: s,
29
+ onError: () => e(!0)
30
+ }
31
+ );
32
+ }), $ = ({ stickerId: t, effect: i, count: o, duration: r }) => {
33
+ const [f, c] = l([]);
34
+ return d(() => {
35
+ const e = y({
36
+ count: o,
37
+ effect: i,
38
+ stickerId: t,
39
+ minSize: 48,
40
+ maxSize: 72
41
+ });
42
+ c(e);
43
+ const s = setTimeout(() => c([]), r);
44
+ return () => clearTimeout(s);
45
+ }, [i, o, r, t]), /* @__PURE__ */ n(z, { children: f.map((e, s) => {
46
+ const { id: a, sticker: m, lottie: h, x: k, y: S, size: u, fromX: D, fromY: g } = e;
47
+ return /* @__PURE__ */ n(
48
+ L,
49
+ {
50
+ effect: i,
51
+ duration: r,
52
+ delay: 500,
53
+ fromX: D,
54
+ fromY: g,
55
+ x: k,
56
+ y: S,
57
+ size: u,
58
+ children: /* @__PURE__ */ n(T, { url: h, sticker: m, size: u })
59
+ },
60
+ `${a}-${s}`
61
+ );
62
+ }) });
63
+ }, W = p($);
64
+ export {
65
+ W as default
66
+ };
67
+ //# sourceMappingURL=stickers-effects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stickers-effects.js","sources":["../../../../src/features/stickers/stickers-effects/stickers-effects.tsx"],"sourcesContent":["import type { TStickerData, IStickersProps } from './stickers-effects-types';\nimport type { Data } from '@lottiefiles/dotlottie-web';\nimport type { FC } from 'react';\n\nimport React, { memo, useEffect, useState } from 'react';\n\nimport DotLottieAnimation from '../../ui/dot-lottie-animations/dot-lottie-animation';\nimport { preloadLottieFile } from './stickers-effects-cache';\nimport { generateStickerData } from './stickers-effects-helper';\nimport * as Styled from './stickers-effects-styled';\n\nconst StickerWithFallback: FC<{\n url?: string;\n sticker: string;\n size: number;\n}> = memo(({ url, sticker, size }) => {\n const [data, setData] = useState<Data>();\n const [failed, setFailed] = useState(false);\n const renderSettings = {\n loop: true,\n autoplay: true,\n };\n\n useEffect(() => {\n let isMounted = true;\n\n if (!url) return;\n\n preloadLottieFile(url)\n .then(result => {\n if (isMounted) {\n if (result) {\n setData(result);\n } else {\n setFailed(true);\n }\n }\n })\n .catch(() => {\n if (isMounted) setFailed(true);\n });\n\n return () => {\n isMounted = false;\n };\n }, [url]);\n\n if (!url || failed || !data) {\n return <>{sticker}</>;\n }\n\n return (\n <DotLottieAnimation\n data={data}\n width={size}\n height={size}\n settings={renderSettings}\n onError={() => setFailed(true)}\n />\n );\n});\n\nconst StickersEffects: React.FC<IStickersProps> = ({ stickerId, effect, count, duration }) => {\n const [stickersData, setStickersData] = useState<ReturnType<typeof generateStickerData>>([]);\n\n useEffect(() => {\n const stickerData = generateStickerData({\n count,\n effect,\n stickerId,\n minSize: 48,\n maxSize: 72,\n });\n\n setStickersData(stickerData);\n\n const timeout = setTimeout(() => setStickersData([]), duration);\n\n return () => clearTimeout(timeout);\n }, [effect, count, duration, stickerId]);\n\n return (\n <Styled.Container>\n {stickersData.map((data: TStickerData, i) => {\n const { id, sticker, lottie, x, y, size, fromX, fromY } = data;\n\n return (\n <Styled.Sticker\n key={`${id}-${i}`}\n effect={effect}\n duration={duration}\n delay={500}\n fromX={fromX}\n fromY={fromY}\n x={x}\n y={y}\n size={size}\n >\n <StickerWithFallback url={lottie} sticker={sticker} size={size} />\n </Styled.Sticker>\n );\n })}\n </Styled.Container>\n );\n};\n\nexport default memo(StickersEffects);\n"],"names":["StickerWithFallback","memo","url","sticker","size","data","setData","useState","failed","setFailed","renderSettings","useEffect","isMounted","preloadLottieFile","result","jsx","DotLottieAnimation","StickersEffects","stickerId","effect","count","duration","stickersData","setStickersData","stickerData","generateStickerData","timeout","Styled.Container","i","id","lottie","x","y","fromX","fromY","Styled.Sticker","stickersEffects"],"mappings":";;;;;;AAWA,MAAMA,IAIDC,EAAK,CAAC,EAAE,KAAAC,GAAK,SAAAC,GAAS,MAAAC,QAAW;AACpC,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAe,GACjC,CAACC,GAAQC,CAAS,IAAIF,EAAS,EAAK,GACpCG,IAAiB;AAAA,IACrB,MAAM;AAAA,IACN,UAAU;AAAA,EAAA;AA2BZ,SAxBAC,EAAU,MAAM;AACd,QAAIC,IAAY;AAEhB,QAAKV;AAEa,aAAAW,EAAAX,CAAG,EAClB,KAAK,CAAUY,MAAA;AACd,QAAIF,MACEE,IACFR,EAAQQ,CAAM,IAEdL,EAAU,EA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A,GAAAH;AAAA,QACA,GAAAC;AAAA,QACA,MAAA5B;AAAA,QAEA,UAAC,gBAAAW,EAAAf,GAAA,EAAoB,KAAK8B,GAAQ,SAAA3B,GAAkB,MAAAC,GAAY;AAAA,MAAA;AAAA,MAV3D,GAAGyB,CAAE,IAAID,CAAC;AAAA,IAAA;AAAA,EAapB,CAAA,EACH,CAAA;AAEJ,GAEeQ,IAAAnC,EAAKgB,CAAe;"}
@@ -1,61 +1,49 @@
1
- import { jsxs as d, jsx as i } from "react/jsx-runtime";
2
- import { memo as H, useMemo as j, useCallback as F, useEffect as P } from "react";
1
+ import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
+ import { memo as A, useCallback as O, useEffect as w } from "react";
3
3
  import { DAYS as f } from "../../../../constants/date-time.js";
4
- import { getTimeUnits as W, getOffsetBetweenTimezone as z, convertEpochToDateTime as $, convertToMilliseconds as B } from "../../../../helpers/date-time.js";
5
- import C from "../../../ui/inputs/select-input/select-input.js";
4
+ import { getTimeUnits as j, getOffsetBetweenTimezone as v, convertEpochToDateTime as g, convertToMilliseconds as H } from "../../../../helpers/date-time.js";
5
+ import $ from "../../../ui/inputs/select-input/select-input.js";
6
6
  import u from "../../../ui/layout/flex-view.js";
7
- import M from "../../../ui/separator/separator.js";
8
- import Y from "../../../ui/text/text.js";
9
- import { useTrialSessionContext as K } from "../../context/use-trial-session-context.js";
10
- import { TEACHER_TIMEZONE as x } from "../../trial-session-constants.js";
11
- import G from "../slide-header/index.js";
12
- import { timeSlots as N } from "./class-preference-constants.js";
13
- import { Container as R, PreferenceWrapper as U, FixedLineSeparator as Z } from "./class-preference-styled.js";
14
- import { extractDayAndTimeFromEpoch as q } from "./helpers.js";
15
- const h = [
7
+ import P from "../../../ui/separator/separator.js";
8
+ import W from "../../../ui/text/text.js";
9
+ import { useTrialSessionContext as z } from "../../context/use-trial-session-context.js";
10
+ import { TEACHER_TIMEZONE as y } from "../../trial-session-constants.js";
11
+ import B from "../slide-header/index.js";
12
+ import { timeSlots as Y } from "./class-preference-constants.js";
13
+ import { Container as F, PreferenceWrapper as K, FixedLineSeparator as M } from "./class-preference-styled.js";
14
+ const C = [
16
15
  { id: 1, selectedDay: "", selectedTime: "" },
17
16
  { id: 2, selectedDay: "", selectedTime: "" }
18
- ], pe = H(({ miniScreenDevice: _ }) => {
19
- const { isTeacher: o, formData: b, trialHomeData: S, updateSlideConfig: T } = K(), { preferences: m, studentTimezone: n = "Asia/Calcutta" } = b || {}, { demo_info: E } = S || {}, { scheduled_start_time: y } = E || {}, A = f.map((e) => ({ id: e, label: e })), g = o ? x : n, l = j(
20
- () => o ? q(y, n) : void 0,
21
- [o, y, n]
22
- ), D = (e, t, s) => {
23
- T({
24
- preferences: (m ?? h).map(
17
+ ], se = A(({ miniScreenDevice: D }) => {
18
+ const { isTeacher: n, formData: x, updateSlideConfig: p } = z(), { preferences: o, studentTimezone: c } = x || {}, b = f.map((e) => ({ id: e, label: e })), h = n ? y : c, T = (e, t, s) => {
19
+ p({
20
+ preferences: (o ?? C).map(
25
21
  (r) => r.id === e ? { ...r, [t]: s } : r
26
22
  )
27
23
  });
28
- }, I = (e, t) => {
29
- D(e, "selectedDay", t);
30
- }, L = (e, t) => {
31
- D(e, "selectedTime", t);
32
- }, X = F(
24
+ }, _ = (e, t) => {
25
+ T(e, "selectedDay", t);
26
+ }, S = (e, t) => {
27
+ T(e, "selectedTime", t);
28
+ }, E = O(
33
29
  (e, t) => {
34
- if (e && t && n) {
35
- const { hours: s, minutes: r } = W(t), c = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0), p = z(x, n), a = o ? c + p : c, { day: k = "" } = $(a, n), O = f.indexOf(k), w = (f.indexOf(e) - O + 7) % 7, v = a + B({ days: w, hours: s, minutes: r });
36
- return $(v, g);
30
+ if (e && t && c) {
31
+ const { hours: s, minutes: r } = j(t), m = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0), l = v(y, c), i = n ? m + l : m, { day: L = "" } = g(i, c), I = f.indexOf(L), X = (f.indexOf(e) - I + 7) % 7, k = i + H({ days: X, hours: s, minutes: r });
32
+ return g(k, h);
37
33
  }
38
34
  return {};
39
35
  },
40
- [o, n, g]
36
+ [n, c, h]
41
37
  );
42
- return P(() => {
43
- o && !m && T({
44
- preferences: l ? h.map(
45
- (e) => e.id === 1 ? {
46
- ...e,
47
- selectedDay: l.day,
48
- selectedTime: l.time
49
- } : e
50
- ) : h
51
- });
52
- }, [l]), /* @__PURE__ */ d(R, { children: [
53
- /* @__PURE__ */ i(M, { height: 60 }),
54
- /* @__PURE__ */ i(G, {}),
38
+ return w(() => {
39
+ n && !o && p({ preferences: C });
40
+ }, [n, o, p]), /* @__PURE__ */ d(F, { children: [
41
+ /* @__PURE__ */ a(P, { height: 60 }),
42
+ /* @__PURE__ */ a(B, {}),
55
43
  /* @__PURE__ */ d(
56
- U,
44
+ K,
57
45
  {
58
- $gapX: _ ? 2.2 : 3.75,
46
+ $gapX: D ? 2.2 : 3.75,
59
47
  $gutterX: 4.6875,
60
48
  $background: "YELLOW_4",
61
49
  $borderColor: "BLACK_1",
@@ -63,51 +51,51 @@ const h = [
63
51
  $justifyContent: "space-between",
64
52
  $alignItems: "center",
65
53
  children: [
66
- /* @__PURE__ */ i(Z, {}),
67
- m == null ? void 0 : m.map((e) => {
68
- const { id: t, selectedDay: s, selectedTime: r } = e, { day: c, time: p } = X(s, r);
54
+ /* @__PURE__ */ a(M, {}),
55
+ o == null ? void 0 : o.map((e) => {
56
+ const { id: t, selectedDay: s, selectedTime: r } = e, { day: m, time: l } = E(s, r);
69
57
  return /* @__PURE__ */ d(u, { $widthX: 15, $background: "YELLOW_1", $borderColor: "BLACK_1", children: [
70
58
  /* @__PURE__ */ d(u, { $gapX: 1.65, $gutterX: 2, $flexGapX: 0.25, children: [
71
- /* @__PURE__ */ i(
72
- C,
59
+ /* @__PURE__ */ a(
60
+ $,
73
61
  {
74
62
  renderAs: "primary",
75
63
  label: `Day ${t}`,
76
64
  value: s,
77
- options: A,
65
+ options: b,
78
66
  theme: "dark",
79
67
  shape: "borderLess",
80
68
  isTransparent: !0,
81
- onChange: (a) => I(t, a)
69
+ onChange: (i) => _(t, i)
82
70
  }
83
71
  ),
84
- /* @__PURE__ */ i(
85
- C,
72
+ /* @__PURE__ */ a(
73
+ $,
86
74
  {
87
75
  renderAs: "primary",
88
76
  label: "Time",
89
77
  value: r,
90
- options: N,
78
+ options: Y,
91
79
  shape: "borderLess",
92
80
  isTransparent: !0,
93
81
  theme: "dark",
94
- onChange: (a) => L(t, a)
82
+ onChange: (i) => S(t, i)
95
83
  }
96
84
  )
97
85
  ] }),
98
- /* @__PURE__ */ i(
86
+ /* @__PURE__ */ a(
99
87
  u,
100
88
  {
101
89
  $heightX: 3.125,
102
90
  $gutterX: 2,
103
91
  $justifyContent: "center",
104
92
  $background: "WHITE_T_60",
105
- children: o ? /* @__PURE__ */ d(Y, { $renderAs: "ac4-black", $align: "center", children: [
106
- c ? c.slice(0, 3) : "__",
93
+ children: n ? /* @__PURE__ */ d(W, { $renderAs: "ac4-black", $align: "center", children: [
94
+ m ? m.slice(0, 3) : "__",
107
95
  ", ",
108
- p || "__",
96
+ l || "__",
109
97
  " ",
110
- o ? "(IST)" : ""
98
+ n ? "(IST)" : ""
111
99
  ] }) : null
112
100
  }
113
101
  )
@@ -119,6 +107,6 @@ const h = [
119
107
  ] });
120
108
  });
121
109
  export {
122
- pe as default
110
+ se as default
123
111
  };
124
112
  //# sourceMappingURL=class-preference.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"class-preference.js","sources":["../../../../../src/features/trial-session/comps/class-preference/class-preference.tsx"],"sourcesContent":["import type { IClassPreference, TPreference } from './class-preference-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect, useMemo } from 'react';\n\nimport { DAYS } from '../../../../constants/date-time';\nimport {\n convertEpochToDateTime,\n convertToMilliseconds,\n getOffsetBetweenTimezone,\n getTimeUnits,\n} from '../../../../helpers/date-time';\nimport SelectInput from '../../../ui/inputs/select-input/select-input';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Separator from '../../../ui/separator/separator';\nimport Text from '../../../ui/text/text';\nimport { useTrialSessionContext } from '../../context/use-trial-session-context';\nimport { TEACHER_TIMEZONE as teacherTimezone } from '../../trial-session-constants';\nimport SlideHeader from '../slide-header';\nimport { timeSlots } from './class-preference-constants';\nimport * as Styled from './class-preference-styled';\nimport { extractDayAndTimeFromEpoch } from './helpers';\n\nconst defaultPreferences = [\n { id: 1, selectedDay: '', selectedTime: '' },\n { id: 2, selectedDay: '', selectedTime: '' },\n];\n\nconst ClassPreference: FC<IClassPreference> = memo(({ miniScreenDevice }) => {\n const { isTeacher, formData, trialHomeData, updateSlideConfig } = useTrialSessionContext();\n const { preferences, studentTimezone = 'Asia/Calcutta' } = formData || {};\n const { demo_info: demoInfo } = trialHomeData || {};\n const { scheduled_start_time: scheduledStartTime } = demoInfo || {};\n\n const daySlots = DAYS.map(day => ({ id: day, label: day }));\n const timezone = isTeacher ? teacherTimezone : studentTimezone;\n\n const preSelectedDateTimeFromEpoch = useMemo(\n () => (isTeacher ? extractDayAndTimeFromEpoch(scheduledStartTime, studentTimezone) : undefined),\n [isTeacher, scheduledStartTime, studentTimezone],\n );\n\n const handlePreferenceChange = (\n id: number,\n field: 'selectedDay' | 'selectedTime',\n value: string,\n ) => {\n updateSlideConfig({\n preferences: (preferences ?? defaultPreferences).map((preference: TPreference) =>\n preference.id === id ? { ...preference, [field]: value } : preference,\n ),\n });\n };\n\n const handleDayChange = (id: number, value: string) => {\n handlePreferenceChange(id, 'selectedDay', value);\n };\n\n const handleTimeChange = (id: number, value: string) => {\n handlePreferenceChange(id, 'selectedTime', value);\n };\n\n const getDisplayDateTimeValue = useCallback(\n (dayValue: string, timeValue: string) => {\n if (dayValue && timeValue && studentTimezone) {\n // Extracting hours, minutes, and period from the selected time.\n const { hours, minutes } = getTimeUnits(timeValue);\n const todayTimestamp = new Date().setHours(0, 0, 0, 0); // Setting current date to midnight\n\n // Calculating offset between the teacher's and student's timezone.\n const timestampOffset = getOffsetBetweenTimezone(teacherTimezone, studentTimezone);\n const studentTimestamp = isTeacher ? todayTimestamp + timestampOffset : todayTimestamp; // Current timestamp at student's timezone\n const { day: today = '' } = convertEpochToDateTime(studentTimestamp, studentTimezone); // Current day at student's timezone.\n\n // Calculating current and selected day index to get day difference.\n const currentDayIndex = DAYS.indexOf(today);\n const selectedDayIndex = DAYS.indexOf(dayValue);\n const dayDifference = (selectedDayIndex - currentDayIndex + 7) % 7;\n\n // Calculate the epoch timestamp for the selected day and time in the student's timezone.\n const epochTimestamp =\n studentTimestamp + convertToMilliseconds({ days: dayDifference, hours, minutes });\n\n // Returning date, time value with respect to both teacher and student timezone.\n return convertEpochToDateTime(epochTimestamp, timezone);\n }\n\n return {};\n },\n [isTeacher, studentTimezone, timezone],\n );\n\n useEffect(() => {\n if (isTeacher && !preferences) {\n updateSlideConfig({\n preferences: preSelectedDateTimeFromEpoch\n ? defaultPreferences.map((preference: TPreference) =>\n preference.id === 1\n ? {\n ...preference,\n selectedDay: preSelectedDateTimeFromEpoch.day,\n selectedTime: preSelectedDateTimeFromEpoch.time,\n }\n : preference,\n )\n : defaultPreferences,\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [preSelectedDateTimeFromEpoch]);\n\n return (\n <Styled.Container>\n <Separator height={60} />\n <SlideHeader />\n <Styled.PreferenceWrapper\n $gapX={miniScreenDevice ? 2.2 : 3.75}\n $gutterX={4.6875}\n $background=\"YELLOW_4\"\n $borderColor=\"BLACK_1\"\n $flexDirection=\"row\"\n $justifyContent=\"space-between\"\n $alignItems=\"center\"\n >\n <Styled.FixedLineSeparator />\n {preferences?.map(preference => {\n const { id, selectedDay, selectedTime } = preference;\n const { day, time } = getDisplayDateTimeValue(selectedDay, selectedTime);\n\n return (\n <FlexView key={`slot-${id}`} $widthX={15} $background=\"YELLOW_1\" $borderColor=\"BLACK_1\">\n <FlexView $gapX={1.65} $gutterX={2} $flexGapX={0.25}>\n <SelectInput\n renderAs=\"primary\"\n label={`Day ${id}`}\n value={selectedDay}\n options={daySlots}\n theme=\"dark\"\n shape=\"borderLess\"\n isTransparent\n onChange={value => handleDayChange(id, value)}\n />\n <SelectInput\n renderAs=\"primary\"\n label=\"Time\"\n value={selectedTime}\n options={timeSlots}\n shape=\"borderLess\"\n isTransparent\n theme=\"dark\"\n onChange={value => handleTimeChange(id, value)}\n />\n </FlexView>\n <FlexView\n $heightX={3.125}\n $gutterX={2}\n $justifyContent=\"center\"\n $background=\"WHITE_T_60\"\n >\n {isTeacher ? (\n <Text $renderAs=\"ac4-black\" $align=\"center\">\n {day ? day.slice(0, 3) : '__'}, {time ? time : '__'} {isTeacher ? '(IST)' : ''}\n </Text>\n ) : null}\n </FlexView>\n </FlexView>\n );\n })}\n </Styled.PreferenceWrapper>\n </Styled.Container>\n );\n});\n\nexport default ClassPreference;\n"],"names":["defaultPreferences","ClassPreference","memo","miniScreenDevice","isTeacher","formData","trialHomeData","updateSlideConfig","useTrialSessionContext","preferences","studentTimezone","demoInfo","scheduledStartTime","daySlots","DAYS","day","timezone","teacherTimezone","preSelectedDateTimeFromEpoch","useMemo","extractDayAndTimeFromEpoch","handlePreferenceChange","id","field","value","preference","handleDayChange","handleTimeChange","getDisplayDateTimeValue","useCallback","dayValue","timeValue","hours","minutes","getTimeUnits","todayTimestamp","timestampOffset","getOffsetBetweenTimezone","studentTimestamp","today","convertEpochToDateTime","currentDayIndex","dayDifference","epochTimestamp","convertToMilliseconds","useEffect","jsxs","Styled.Container","jsx","Separator","SlideHeader","Styled.PreferenceWrapper","Styled.FixedLineSeparator","selectedDay","selectedTime","time","FlexView","SelectInput","timeSlots","Text"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMA,IAAqB;AAAA,EACzB,EAAE,IAAI,GAAG,aAAa,IAAI,cAAc,GAAG;AAAA,EAC3C,EAAE,IAAI,GAAG,aAAa,IAAI,cAAc,GAAG;AAC7C,GAEMC,KAAwCC,EAAK,C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/features/trial-session/comps/class-preference/class-preference.tsx"],"sourcesContent":["import type { IClassPreference, TPreference } from './class-preference-types';\nimport type { FC } from 'react';\n\nimport { memo, useCallback, useEffect } from 'react';\n\nimport { DAYS } from '../../../../constants/date-time';\nimport {\n convertEpochToDateTime,\n convertToMilliseconds,\n getOffsetBetweenTimezone,\n getTimeUnits,\n} from '../../../../helpers/date-time';\nimport SelectInput from '../../../ui/inputs/select-input/select-input';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Separator from '../../../ui/separator/separator';\nimport Text from '../../../ui/text/text';\nimport { useTrialSessionContext } from '../../context/use-trial-session-context';\nimport { TEACHER_TIMEZONE as teacherTimezone } from '../../trial-session-constants';\nimport SlideHeader from '../slide-header';\nimport { timeSlots } from './class-preference-constants';\nimport * as Styled from './class-preference-styled';\n\nconst defaultPreferences = [\n { id: 1, selectedDay: '', selectedTime: '' },\n { id: 2, selectedDay: '', selectedTime: '' },\n];\n\nconst ClassPreference: FC<IClassPreference> = memo(({ miniScreenDevice }) => {\n const { isTeacher, formData, updateSlideConfig } = useTrialSessionContext();\n const { preferences, studentTimezone } = formData || {};\n\n const daySlots = DAYS.map(day => ({ id: day, label: day }));\n const timezone = isTeacher ? teacherTimezone : studentTimezone;\n\n const handlePreferenceChange = (\n id: number,\n field: 'selectedDay' | 'selectedTime',\n value: string,\n ) => {\n updateSlideConfig({\n preferences: (preferences ?? defaultPreferences).map((preference: TPreference) =>\n preference.id === id ? { ...preference, [field]: value } : preference,\n ),\n });\n };\n\n const handleDayChange = (id: number, value: string) => {\n handlePreferenceChange(id, 'selectedDay', value);\n };\n\n const handleTimeChange = (id: number, value: string) => {\n handlePreferenceChange(id, 'selectedTime', value);\n };\n\n const getDisplayDateTimeValue = useCallback(\n (dayValue: string, timeValue: string) => {\n if (dayValue && timeValue && studentTimezone) {\n // Extracting hours, minutes, and period from the selected time.\n const { hours, minutes } = getTimeUnits(timeValue);\n const todayTimestamp = new Date().setHours(0, 0, 0, 0); // Setting current date to midnight\n\n // Calculating offset between the teacher's and student's timezone.\n const timestampOffset = getOffsetBetweenTimezone(teacherTimezone, studentTimezone);\n const studentTimestamp = isTeacher ? todayTimestamp + timestampOffset : todayTimestamp; // Current timestamp at student's timezone\n const { day: today = '' } = convertEpochToDateTime(studentTimestamp, studentTimezone); // Current day at student's timezone.\n\n // Calculating current and selected day index to get day difference.\n const currentDayIndex = DAYS.indexOf(today);\n const selectedDayIndex = DAYS.indexOf(dayValue);\n const dayDifference = (selectedDayIndex - currentDayIndex + 7) % 7;\n\n // Calculate the epoch timestamp for the selected day and time in the student's timezone.\n const epochTimestamp =\n studentTimestamp + convertToMilliseconds({ days: dayDifference, hours, minutes });\n\n // Returning date, time value with respect to both teacher and student timezone.\n return convertEpochToDateTime(epochTimestamp, timezone);\n }\n\n return {};\n },\n [isTeacher, studentTimezone, timezone],\n );\n\n useEffect(() => {\n if (isTeacher && !preferences) {\n updateSlideConfig({ preferences: defaultPreferences });\n }\n }, [isTeacher, preferences, updateSlideConfig]);\n\n return (\n <Styled.Container>\n <Separator height={60} />\n <SlideHeader />\n <Styled.PreferenceWrapper\n $gapX={miniScreenDevice ? 2.2 : 3.75}\n $gutterX={4.6875}\n $background=\"YELLOW_4\"\n $borderColor=\"BLACK_1\"\n $flexDirection=\"row\"\n $justifyContent=\"space-between\"\n $alignItems=\"center\"\n >\n <Styled.FixedLineSeparator />\n {preferences?.map(preference => {\n const { id, selectedDay, selectedTime } = preference;\n const { day, time } = getDisplayDateTimeValue(selectedDay, selectedTime);\n\n return (\n <FlexView key={`slot-${id}`} $widthX={15} $background=\"YELLOW_1\" $borderColor=\"BLACK_1\">\n <FlexView $gapX={1.65} $gutterX={2} $flexGapX={0.25}>\n <SelectInput\n renderAs=\"primary\"\n label={`Day ${id}`}\n value={selectedDay}\n options={daySlots}\n theme=\"dark\"\n shape=\"borderLess\"\n isTransparent\n onChange={value => handleDayChange(id, value)}\n />\n <SelectInput\n renderAs=\"primary\"\n label=\"Time\"\n value={selectedTime}\n options={timeSlots}\n shape=\"borderLess\"\n isTransparent\n theme=\"dark\"\n onChange={value => handleTimeChange(id, value)}\n />\n </FlexView>\n <FlexView\n $heightX={3.125}\n $gutterX={2}\n $justifyContent=\"center\"\n $background=\"WHITE_T_60\"\n >\n {isTeacher ? (\n <Text $renderAs=\"ac4-black\" $align=\"center\">\n {day ? day.slice(0, 3) : '__'}, {time ? time : '__'} {isTeacher ? '(IST)' : ''}\n </Text>\n ) : null}\n </FlexView>\n </FlexView>\n );\n })}\n </Styled.PreferenceWrapper>\n </Styled.Container>\n );\n});\n\nexport default ClassPreference;\n"],"names":["defaultPreferences","ClassPreference","memo","miniScreenDevice","isTeacher","formData","updateSlideConfig","useTrialSessionContext","preferences","studentTimezone","daySlots","DAYS","day","timezone","teacherTimezone","handlePreferenceChange","id","field","value","preference","handleDayChange","handleTimeChange","getDisplayDateTimeValue","useCallback","dayValue","timeValue","hours","minutes","getTimeUnits","todayTimestamp","timestampOffset","getOffsetBetweenTimezone","studentTimestamp","today","convertEpochToDateTime","currentDayIndex","dayDifference","epochTimestamp","convertToMilliseconds","useEffect","jsxs","Styled.Container","jsx","Separator","SlideHeader","Styled.PreferenceWrapper","Styled.FixedLineSeparator","selectedDay","selectedTime","time","FlexView","SelectInput","timeSlots","Text"],"mappings":";;;;;;;;;;;;;AAsBA,MAAMA,IAAqB;AAAA,EACzB,EAAE,IAAI,GAAG,aAAa,IAAI,cAAc,GAAG;AAAA,EAC3C,EAAE,IAAI,GAAG,aAAa,IAAI,cAAc,GAAG;AAC7C,GAEMC,KAAwCC,EAAK,CAAC,EAAE,kBAAAC,QAAuB;AAC3E,QAAM,EAAE,WAAAC,GAAW,UAAAC,GAAU,mBAAAC,MAAsBC,EAAuB,GACpE,EAAE,aAAAC,GAAa,iBAAAC,MAAoBJ,KAAY,CAAA,GAE/CK,IAAWC,EAAK,IAAI,CAAAC,OAAQ,EAAE,IAAIA,GAAK,OAAOA,EAAA,EAAM,GACpDC,IAAWT,IAAYU,I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