@opexa/portal-components 0.0.927 → 0.0.928

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 (183) hide show
  1. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/QRPHDepositContext.d.ts +2 -2
  2. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/useQRPHDeposit.d.ts +1 -1
  3. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.d.ts +1 -0
  4. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.js +11 -0
  5. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.d.ts +1 -0
  6. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.js +11 -0
  7. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.d.ts +1 -0
  8. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.js +126 -0
  9. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.d.ts +1 -0
  10. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.js +10 -0
  11. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.d.ts +1 -0
  12. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.js +12 -0
  13. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.d.ts +17 -0
  14. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.js +2 -0
  15. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.d.ts +1 -0
  16. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.js +41 -0
  17. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.d.ts +13 -0
  18. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.js +91 -0
  19. package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
  20. package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
  21. package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
  22. package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
  23. package/dist/components/DigitainLauncher/Loading.js +1 -1
  24. package/dist/components/Disclaimer/DisclaimerV2.js +1 -1
  25. package/dist/components/Disclaimer/ResponsibleGaming.d.ts +10 -0
  26. package/dist/components/Disclaimer/ResponsibleGaming.js +13 -0
  27. package/dist/components/Disclaimer/TermsOfUse.d.ts +11 -0
  28. package/dist/components/Disclaimer/TermsOfUse.js +13 -0
  29. package/dist/components/FeatureFlag/FeatureFlag.d.ts +1 -0
  30. package/dist/components/FeatureFlag/FeatureFlag.js +29 -0
  31. package/dist/components/FeatureFlag/index.d.ts +1 -0
  32. package/dist/components/FeatureFlag/index.js +1 -0
  33. package/dist/components/ForgotPassword/Crazywin/ForgotPassword.module.css +42 -42
  34. package/dist/components/Jackpots/Jackpots.module.css +288 -288
  35. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
  36. package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
  37. package/dist/components/KYC/AutoOpen.d.ts +1 -0
  38. package/dist/components/KYC/AutoOpen.js +40 -0
  39. package/dist/components/KYC/BasicInformation.js +1 -1
  40. package/dist/components/KYC/CaptureIdDocument.d.ts +1 -0
  41. package/dist/components/KYC/CaptureIdDocument.js +219 -0
  42. package/dist/components/KYC/CaptureSelfie.d.ts +1 -0
  43. package/dist/components/KYC/CaptureSelfie.js +285 -0
  44. package/dist/components/KYC/DisplayImage.d.ts +5 -0
  45. package/dist/components/KYC/DisplayImage.js +8 -0
  46. package/dist/components/KYC/FileUpload.d.ts +10 -0
  47. package/dist/components/KYC/FileUpload.js +72 -0
  48. package/dist/components/KYC/IdentityVerification.js +1 -1
  49. package/dist/components/KYC/KYC.lazy.js +1 -1
  50. package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +2 -2
  51. package/dist/components/KYC/KYCNonPagCor/KYCVerificationStatus.lazy.js +2 -2
  52. package/dist/components/KYC/KYCVerificationStatus.lazy.js +8 -5
  53. package/dist/components/KYC/NoCameraError.d.ts +7 -0
  54. package/dist/components/KYC/NoCameraError.js +6 -0
  55. package/dist/components/KYC/PersonOverlayDesktop.d.ts +7 -0
  56. package/dist/components/KYC/PersonOverlayDesktop.js +9 -0
  57. package/dist/components/KYC/PersonalInformation.js +1 -1
  58. package/dist/components/KYC/backup/Header.d.ts +1 -0
  59. package/dist/components/KYC/backup/Header.js +8 -0
  60. package/dist/components/KYC/backup/Indicator.d.ts +1 -0
  61. package/dist/components/KYC/backup/Indicator.js +9 -0
  62. package/dist/components/KYC/backup/KYC.d.ts +1 -0
  63. package/dist/components/KYC/backup/KYC.js +14 -0
  64. package/dist/components/KYC/backup/KYC.lazy.d.ts +1 -0
  65. package/dist/components/KYC/backup/KYC.lazy.js +26 -0
  66. package/dist/components/KYC/backup/KYCContext.d.ts +6 -0
  67. package/dist/components/KYC/backup/KYCContext.js +2 -0
  68. package/dist/components/KYC/backup/Step1.d.ts +1 -0
  69. package/dist/components/KYC/backup/Step1.js +13 -0
  70. package/dist/components/KYC/backup/Step2.d.ts +1 -0
  71. package/dist/components/KYC/backup/Step2.js +13 -0
  72. package/dist/components/KYC/backup/Step3.d.ts +1 -0
  73. package/dist/components/KYC/backup/Step3.js +13 -0
  74. package/dist/components/KYC/backup/Step4.d.ts +1 -0
  75. package/dist/components/KYC/backup/Step4.js +7 -0
  76. package/dist/components/KYC/backup/useKYC.d.ts +10 -0
  77. package/dist/components/KYC/backup/useKYC.js +8 -0
  78. package/dist/components/KYC/loadModels.d.ts +1 -0
  79. package/dist/components/KYC/loadModels.js +9 -0
  80. package/dist/components/KYC/utils.d.ts +9 -0
  81. package/dist/components/KYC/utils.js +79 -0
  82. package/dist/components/Messages/Message.d.ts +1 -0
  83. package/dist/components/Messages/Message.js +35 -0
  84. package/dist/components/Messages/MessageContext.d.ts +6 -0
  85. package/dist/components/Messages/MessageContext.js +2 -0
  86. package/dist/components/Messages/MessagePopup.d.ts +1 -0
  87. package/dist/components/Messages/MessagePopup.js +20 -0
  88. package/dist/components/Messages/MessageTrigger.d.ts +8 -0
  89. package/dist/components/Messages/MessageTrigger.js +19 -0
  90. package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
  91. package/dist/components/Quests/CountdownTimer.d.ts +15 -0
  92. package/dist/components/Quests/CountdownTimer.js +33 -0
  93. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +4 -0
  94. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +78 -0
  95. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +8 -0
  96. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +9 -0
  97. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +4 -0
  98. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +4 -0
  99. package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +4 -0
  100. package/dist/components/Quests/WageringQuest/WageringQuest.js +20 -0
  101. package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +9 -0
  102. package/dist/components/Quests/WageringQuest/WageringQuestModal.js +9 -0
  103. package/dist/components/SignUp/SignUp.lazy.d.ts +12 -0
  104. package/dist/components/SignUp/SignUp.lazy.js +18 -0
  105. package/dist/components/SignUp/SignUpContext.d.ts +6 -0
  106. package/dist/components/SignUp/SignUpContext.js +2 -0
  107. package/dist/components/SignUp/SignUpDefault/SignUp.lazy.d.ts +17 -0
  108. package/dist/components/SignUp/SignUpDefault/SignUp.lazy.js +18 -0
  109. package/dist/components/SignUp/SignUpDefault/SignUpContext.d.ts +6 -0
  110. package/dist/components/SignUp/SignUpDefault/SignUpContext.js +2 -0
  111. package/dist/components/SignUp/SignUpDefault/SignUpForm.d.ts +1 -0
  112. package/dist/components/SignUp/SignUpDefault/SignUpForm.js +310 -0
  113. package/dist/components/SignUp/SignUpForm.d.ts +1 -0
  114. package/dist/components/SignUp/SignUpForm.js +284 -0
  115. package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.d.ts +1 -0
  116. package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.js +198 -0
  117. package/dist/components/SignUp/SignUpKYC/CaptureSelfie.d.ts +1 -0
  118. package/dist/components/SignUp/SignUpKYC/CaptureSelfie.js +251 -0
  119. package/dist/components/SignUp/SignUpKYC/ImageUploader.d.ts +10 -0
  120. package/dist/components/SignUp/SignUpKYC/ImageUploader.js +42 -0
  121. package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.d.ts +7 -0
  122. package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.js +9 -0
  123. package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.d.ts +1 -0
  124. package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +464 -0
  125. package/dist/components/SignUp/SignUpKYC/useImageUploader.d.ts +11 -0
  126. package/dist/components/SignUp/SignUpKYC/useImageUploader.js +20 -0
  127. package/dist/components/SignUp/SignUpKYC/utils.d.ts +9 -0
  128. package/dist/components/SignUp/SignUpKYC/utils.js +79 -0
  129. package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +1 -0
  130. package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +198 -0
  131. package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +1 -0
  132. package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +251 -0
  133. package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +10 -0
  134. package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +41 -0
  135. package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +1 -0
  136. package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +429 -0
  137. package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +13 -0
  138. package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +26 -0
  139. package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +7 -0
  140. package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +2 -0
  141. package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +11 -0
  142. package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +20 -0
  143. package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
  144. package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
  145. package/dist/components/shared/IdDocumentField.client.d.ts +25 -0
  146. package/dist/components/shared/IdDocumentField.client.js +204 -0
  147. package/dist/components/shared/IdDocumentField.d.ts +2 -0
  148. package/dist/components/shared/IdDocumentField.js +11 -0
  149. package/dist/components/shared/SelfieField.client.d.ts +20 -0
  150. package/dist/components/shared/SelfieField.client.js +327 -0
  151. package/dist/components/shared/SelfieField.d.ts +2 -0
  152. package/dist/components/shared/SelfieField.js +11 -0
  153. package/dist/constants/BranchCode.d.ts +4 -0
  154. package/dist/constants/BranchCode.js +42 -0
  155. package/dist/handlers/postTransformIdFrontImage.d.ts +3 -0
  156. package/dist/handlers/postTransformIdFrontImage.js +67 -0
  157. package/dist/handlers/postTransformSelfieImage.d.ts +3 -0
  158. package/dist/handlers/postTransformSelfieImage.js +71 -0
  159. package/dist/handlers.d.ts +43 -0
  160. package/dist/handlers.js +297 -0
  161. package/dist/icons/BellRingIcon.d.ts +2 -0
  162. package/dist/icons/BellRingIcon.js +4 -0
  163. package/dist/images/phone-icon.svg +10 -10
  164. package/dist/services/queries.js +3369 -3369
  165. package/dist/styles/theme.css +776 -776
  166. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  167. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  168. package/dist/ui/Checkbox/checkbox.recipe.js +1 -1
  169. package/dist/utils/dataUrlToBlob.d.ts +1 -0
  170. package/dist/utils/dataUrlToBlob.js +11 -0
  171. package/dist/utils/gamesAvailable3pmTo3am.d.ts +1 -0
  172. package/dist/utils/gamesAvailable3pmTo3am.js +1 -0
  173. package/dist/utils/getGameName.d.ts +1 -0
  174. package/dist/utils/getGameName.js +6 -0
  175. package/dist/utils/isBetween3amAnd3pm.d.ts +1 -0
  176. package/dist/utils/isBetween3amAnd3pm.js +5 -0
  177. package/dist/utils/resizeImageSize.d.ts +2 -0
  178. package/dist/utils/resizeImageSize.js +11 -0
  179. package/package.json +179 -179
  180. package/dist/components/Banner/Banner.client.d.ts +0 -12
  181. package/dist/components/Banner/Banner.client.js +0 -49
  182. package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +0 -1
  183. package/dist/components/PortalProvider/AndroidOnlyComponents.js +0 -12
@@ -0,0 +1,251 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as faceapi from 'face-api.js';
4
+ import { useEffect, useRef, useState } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { ArrowLeftIcon } from '../../../icons/ArrowLeftIcon.js';
7
+ import { Camera01Icon } from '../../../icons/Camera01Icon.js';
8
+ import { XIcon } from '../../../icons/XIcon.js';
9
+ import { Button } from '../../../ui/Button/index.js';
10
+ import { Dialog } from '../../../ui/Dialog/index.js';
11
+ import { Portal } from '../../../ui/Portal/index.js';
12
+ import { onMobileDevice } from '../../../utils/onMobileDevice.js';
13
+ import PersonOverlayDesktop from './PersonOverlayDesktop.js';
14
+ import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
15
+ import { dataURLtoBlob, loadFaceApiModels, resizeFile } from './utils.js';
16
+ export function CaptureSelfie() {
17
+ const props = useSignUpKYCPropsContext();
18
+ const mobileDevice = onMobileDevice();
19
+ const [modelsLoaded, setModelsLoaded] = useState(false);
20
+ const [videoStream, setVideoStream] = useState(null);
21
+ const [cameraError, setCameraError] = useState(null);
22
+ const [captureInProgress, setCaptureInProgress] = useState(false);
23
+ const [selectedImage, setSelectedImage] = useState(null);
24
+ const [isFaceCentered, setIsFaceCentered] = useState(false);
25
+ const [isCapturing, setIsCapturing] = useState(false);
26
+ const [countdown, setCountdown] = useState(3);
27
+ const videoRef = useRef(null);
28
+ const faceCanvasRef = useRef(null);
29
+ const detectionIntervalRef = useRef(null);
30
+ const countdownTimerRef = useRef(null);
31
+ useEffect(() => {
32
+ loadFaceApiModels()
33
+ .then(() => setModelsLoaded(true))
34
+ .catch(() => setModelsLoaded(false));
35
+ }, []);
36
+ useEffect(() => {
37
+ if (captureInProgress) {
38
+ startFaceDetection();
39
+ }
40
+ }, [captureInProgress]);
41
+ async function startCamera() {
42
+ setCaptureInProgress(true);
43
+ const stream = await navigator.mediaDevices.getUserMedia({
44
+ video: {
45
+ facingMode: mobileDevice ? 'user' : 'environment',
46
+ aspectRatio: mobileDevice ? 9 / 16 : 16 / 9,
47
+ width: { ideal: 1920 },
48
+ height: { ideal: 1080 },
49
+ },
50
+ audio: false,
51
+ });
52
+ setVideoStream(stream);
53
+ if (videoRef.current) {
54
+ videoRef.current.srcObject = stream;
55
+ videoRef.current.onloadedmetadata = () => {
56
+ videoRef.current
57
+ ?.play()
58
+ .then(() => {
59
+ if (modelsLoaded) {
60
+ startFaceDetection();
61
+ }
62
+ })
63
+ .catch((error) => {
64
+ console.error('Error playing video:', error);
65
+ setCameraError('Failed to play video stream. Please check your camera settings.');
66
+ });
67
+ };
68
+ }
69
+ }
70
+ function startFaceDetection() {
71
+ if (!modelsLoaded) {
72
+ console.error('Cannot start face detection: video element not ready or models not loaded');
73
+ return;
74
+ }
75
+ if (!faceCanvasRef.current) {
76
+ faceCanvasRef.current = faceapi.createCanvasFromMedia(videoRef.current);
77
+ const parentDiv = document.getElementById('parent');
78
+ faceCanvasRef.current.className = `absolute inset-0 m-auto h-${parentDiv?.clientHeight} w-${parentDiv?.clientWidth} md:aspect-video object-cover md:object-contain`;
79
+ faceCanvasRef.current.style.width = `${videoRef.current?.clientWidth}px`;
80
+ faceCanvasRef.current.style.height = `${videoRef.current?.clientHeight}px`;
81
+ }
82
+ const displaySize = {
83
+ width: videoRef.current?.clientWidth || 643,
84
+ height: videoRef.current?.clientHeight || 333,
85
+ };
86
+ // Clear any existing interval
87
+ if (detectionIntervalRef.current) {
88
+ clearInterval(detectionIntervalRef.current);
89
+ }
90
+ faceapi.matchDimensions(faceCanvasRef.current, displaySize);
91
+ let countdownInterval = null;
92
+ detectionIntervalRef.current = window.setInterval(async () => {
93
+ if (!videoRef.current || !faceCanvasRef.current) {
94
+ console.error('Video or canvas element is not ready');
95
+ return;
96
+ }
97
+ try {
98
+ const detection = await faceapi
99
+ .detectSingleFace(videoRef.current, new faceapi.TinyFaceDetectorOptions())
100
+ .withFaceLandmarks();
101
+ if (detection) {
102
+ const resizedDetection = faceapi.resizeResults(detection, displaySize);
103
+ const frame_height = resizedDetection.detection.box.height;
104
+ const frame_width = resizedDetection.detection.box.width;
105
+ const frame_x = resizedDetection.detection.box.x;
106
+ const frame_y = resizedDetection.detection.box.y;
107
+ const faceCenterX = frame_x + frame_width / 2;
108
+ const faceCenterY = frame_y + frame_height / 2;
109
+ const screenCenterX = displaySize.width / 2;
110
+ const screenCenterY = displaySize.height / 2;
111
+ const centerThresholdX = displaySize.width * 0.15;
112
+ const centerThresholdY = displaySize.height * 0.15;
113
+ const isFaceCentered = Math.abs(faceCenterX - screenCenterX) <= centerThresholdX &&
114
+ Math.abs(faceCenterY - screenCenterY) <= centerThresholdY;
115
+ setIsFaceCentered(isFaceCentered);
116
+ const faceDetectionConfidence = detection.detection.score * 100;
117
+ // const context = faceCanvasRef.current.getContext('2d');
118
+ // if (context) {
119
+ // context.clearRect(
120
+ // 0,
121
+ // 0,
122
+ // faceCanvasRef.current.width,
123
+ // faceCanvasRef.current.height,
124
+ // );
125
+ // faceapi.draw.drawDetections(
126
+ // faceCanvasRef.current,
127
+ // resizedDetection,
128
+ // );
129
+ // faceapi.draw.drawFaceLandmarks(
130
+ // faceCanvasRef.current,
131
+ // resizedDetection,
132
+ // );
133
+ // }
134
+ //adjust the faceDetectionConfidence if need
135
+ if (isFaceCentered && faceDetectionConfidence >= 65) {
136
+ if (!countdownInterval) {
137
+ setIsCapturing(true);
138
+ countdownInterval = setInterval(() => {
139
+ setCountdown((prev) => {
140
+ if (prev === 1) {
141
+ clearInterval(countdownInterval);
142
+ countdownInterval = null;
143
+ captureImage();
144
+ return 3;
145
+ }
146
+ return prev - 1;
147
+ });
148
+ }, 1000);
149
+ }
150
+ }
151
+ else {
152
+ if (countdownInterval) {
153
+ clearInterval(countdownInterval);
154
+ countdownInterval = null;
155
+ setCountdown(3);
156
+ setIsCapturing(false);
157
+ }
158
+ }
159
+ }
160
+ }
161
+ catch (error) {
162
+ console.error('Error during face detection:', error);
163
+ setCameraError('An error occurred while detecting your face. Please try again.');
164
+ }
165
+ }, 100);
166
+ }
167
+ function stopCamera() {
168
+ setCaptureInProgress(false);
169
+ if (detectionIntervalRef.current) {
170
+ clearInterval(detectionIntervalRef.current);
171
+ detectionIntervalRef.current = null;
172
+ }
173
+ if (countdownTimerRef.current) {
174
+ clearInterval(countdownTimerRef.current);
175
+ countdownTimerRef.current = null;
176
+ }
177
+ if (videoStream) {
178
+ videoStream.getTracks().forEach((track) => track.stop());
179
+ setVideoStream(null);
180
+ }
181
+ if (videoRef.current && videoRef.current.srcObject) {
182
+ const stream = videoRef.current.srcObject;
183
+ stream.getTracks().forEach((track) => {
184
+ track.stop();
185
+ });
186
+ videoRef.current.srcObject = null;
187
+ videoRef.current.pause();
188
+ videoRef.current.currentTime = 0;
189
+ videoRef.current.load();
190
+ }
191
+ setCountdown(3);
192
+ }
193
+ function captureImage() {
194
+ if (videoRef.current && faceCanvasRef.current) {
195
+ const canvas = document.createElement('canvas');
196
+ canvas.width = videoRef.current.videoWidth;
197
+ canvas.height = videoRef.current.videoHeight;
198
+ const context = canvas.getContext('2d');
199
+ if (context) {
200
+ context.drawImage(videoRef.current, 0, 0, canvas.width, canvas.height);
201
+ const imageData = canvas.toDataURL('image/png');
202
+ setSelectedImage(imageData);
203
+ stopCamera();
204
+ }
205
+ }
206
+ }
207
+ function retakePhoto() {
208
+ setSelectedImage(null);
209
+ setCaptureInProgress(true);
210
+ setCameraError(null);
211
+ if (faceCanvasRef.current) {
212
+ const canvas = faceCanvasRef.current.querySelector('canvas');
213
+ if (canvas) {
214
+ canvas.width = canvas.width;
215
+ }
216
+ faceCanvasRef.current.innerHTML = '';
217
+ }
218
+ if (videoRef.current) {
219
+ videoRef.current.play();
220
+ }
221
+ startCamera();
222
+ }
223
+ async function usePhoto() {
224
+ if (!selectedImage) {
225
+ console.error('No photo selected to use');
226
+ return;
227
+ }
228
+ const blob = dataURLtoBlob(selectedImage);
229
+ const img = new File([blob], 'image', { type: blob.type });
230
+ const resizedImage = (await resizeFile(img));
231
+ if (resizedImage) {
232
+ props.setSelfieImage(resizedImage);
233
+ props.setCapturing(null);
234
+ stopCamera();
235
+ }
236
+ }
237
+ useEffect(() => {
238
+ return () => {
239
+ if (detectionIntervalRef.current) {
240
+ clearInterval(detectionIntervalRef.current);
241
+ }
242
+ if (countdownTimerRef.current) {
243
+ clearInterval(countdownTimerRef.current);
244
+ }
245
+ };
246
+ }, []);
247
+ return (_jsx(Dialog.Root, { open: props.capturing === 'SELFIE', lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: twMerge('bg-bg-primary-alt mx-auto h-full w-full items-start overflow-y-auto p-3xl pb-4xl lg:h-auto lg:w-fit lg:rounded-xl', props.className), children: _jsxs("div", { className: "w-full p-4 lg:w-[640px] lg:px-12 lg:py-4xl", children: [_jsxs("button", { type: "button", className: "flex items-center gap-lg lg:absolute lg:right-5 lg:top-5 lg:p-md", onClick: () => {
248
+ stopCamera();
249
+ props.setCapturing(null);
250
+ }, children: [_jsx(XIcon, { className: "text-text-senary-300 hidden size-5 lg:block" }), _jsx(ArrowLeftIcon, { className: "text-text-senary-300 size-5 lg:hidden" }), _jsx("span", { className: "text-lg font-semibold lg:hidden", children: "Back" })] }), _jsx(Dialog.Title, { className: "mt-6 text-center text-lg font-semibold lg:mt-0", children: "Take a Selfie Holding Your ID" }), _jsx(Dialog.Description, { className: "text-text-tertiary-600 mx-auto mt-sm max-w-[19rem] text-center text-sm lg:max-w-full", children: "Make sure your face and ID are clearly visible, with no glare or blur." }), _jsx("div", { id: "parent", className: "border-border-disabled mt-6 aspect-video rounded-xl border bg-black lg:mt-8", children: captureInProgress ? (_jsxs("div", { className: "relative flex h-fit w-full flex-col items-center justify-center", children: [_jsx("video", { ref: videoRef, autoPlay: true, muted: true, className: "h-[60vh] w-full rounded-lg object-cover md:aspect-video md:h-[333px]", width: "100%", height: "100%" }), _jsx("canvas", { ref: faceCanvasRef, className: "absolute inset-0 h-[60vh] w-full object-cover md:aspect-video md:h-[333px] md:object-contain", width: "100%", height: "100%" }), isCapturing && (_jsx("span", { className: "absolute inset-x-0 bottom-8 flex items-center justify-center text-5xl font-bold text-[#713B12CC] md:bottom-4", children: countdown })), !isFaceCentered && (_jsx("span", { className: "absolute inset-x-0 bottom-12 mx-auto w-1/2 text-center text-xs text-white md:bottom-3", children: "Please center your face in the camera view. Make sure your ID is clearly visible next to your face." })), _jsx(PersonOverlayDesktop, { isFaceCentered: isFaceCentered, width: videoRef.current?.clientWidth || 543, height: videoRef.current?.clientHeight || 333 })] })) : (selectedImage && (_jsx("img", { src: selectedImage, alt: "Captured Photo", className: "h-full w-full rounded-lg object-cover md:aspect-video md:h-[333px]" }))) }), selectedImage && (_jsxs("div", { className: "flex flex-col items-center justify-center gap-2 md:flex-row", children: [_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-4 px-xl disabled:opacity-100", size: "sm", onClick: retakePhoto, type: "button", children: ["Retake Photo", _jsx(Camera01Icon, { className: "size-5" })] }), _jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-4 px-xl disabled:opacity-100", size: "sm", onClick: usePhoto, type: "button", children: ["Use Photo", _jsx(Camera01Icon, { className: "size-5" })] })] })), !captureInProgress && (_jsxs(Button, { className: twMerge('mx-auto mt-6 px-xl lg:mt-8', selectedImage && 'hidden'), onClick: startCamera, disabled: !modelsLoaded, type: "button", children: ["Start Camera", _jsx(Camera01Icon, { className: "size-5" })] }))] }) }) })] }) }));
251
+ }
@@ -0,0 +1,10 @@
1
+ import type { CaptureSubject } from '../../KYC/useKYC';
2
+ interface FileUploadProps {
3
+ name: string;
4
+ value: File | null;
5
+ hasDescription?: boolean;
6
+ onChange?: (id: File) => void;
7
+ captureObject: CaptureSubject;
8
+ }
9
+ declare function ImageUploader({ value, name, hasDescription, onChange, captureObject, }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
10
+ export default ImageUploader;
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import Image from 'next/image';
4
+ import { useEffect, useRef, useState } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { UploadCloud02Icon } from '../../../icons/UploadCloud02Icon.js';
7
+ import { Button } from '../../../ui/Button/index.js';
8
+ import { useSignUpKYCPropsContext } from './SignUpKYCContext.js';
9
+ import { validateFile } from './utils.js';
10
+ function ImageUploader({ value, name, hasDescription = true, onChange, captureObject, }) {
11
+ const props = useSignUpKYCPropsContext();
12
+ const [previewUrl, setPreviewUrl] = useState(null);
13
+ const [error, setError] = useState(null);
14
+ const fileInputRef = useRef(null);
15
+ const handleFileChange = (event) => {
16
+ const file = event.target.files?.[0];
17
+ if (!file) {
18
+ setError('No file selected');
19
+ return;
20
+ }
21
+ const validationError = validateFile(file);
22
+ if (validationError) {
23
+ setError(validationError);
24
+ return;
25
+ }
26
+ setError(null);
27
+ const url = URL.createObjectURL(file);
28
+ setPreviewUrl(url);
29
+ onChange?.(file);
30
+ return () => URL.revokeObjectURL(url);
31
+ };
32
+ const handleUploadClick = () => {
33
+ fileInputRef.current?.click();
34
+ };
35
+ useEffect(() => {
36
+ if (value) {
37
+ setPreviewUrl(URL.createObjectURL(value));
38
+ }
39
+ }, [value]);
40
+ return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col items-center justify-center gap-lg rounded-xl border px-3xl py-xl", children: [error && (_jsx("p", { className: "text-text-error-600 mb-2 text-center text-sm", children: error })), previewUrl ? (_jsxs("div", { className: "flex w-full flex-col items-center", children: [_jsx("div", { className: "relative h-[9.25rem] w-full overflow-hidden rounded-md", children: _jsx(Image, { src: previewUrl, alt: "Uploaded image preview", fill: true, className: "object-contain", draggable: false, priority: true }) }), _jsx(Button, { size: "xs", variant: "outline", className: twMerge('mx-auto mt-4 w-fit', value && 'hidden'), type: "button", onClick: handleUploadClick, children: "Reupload" })] })) : (hasDescription && (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-border-primary shadow-xs flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsxs("p", { className: "text-text-tertiary-600 text-center text-sm", children: [_jsx("span", { className: "text-button-secondary-fg cursor-pointer font-semibold hover:underline", onClick: handleUploadClick, children: "Click to upload" }), ' ', "or drag and drop", _jsx("br", {}), "PNG, JPG, or JPEG (max. 10MB)"] })] }))), _jsx("input", { type: "file", id: `file-upload-${name}`, name: name, ref: fileInputRef, onChange: handleFileChange, accept: "image/png,image/jpg,image/jpeg", className: "hidden", "aria-label": "Upload image file" }), _jsx(Button, { size: "xs", variant: "outline", className: "mt-4 w-fit", onClick: () => props.setCapturing(captureObject), type: "button", children: value ? 'Retake Photo' : 'Take a Photo' })] }));
41
+ }
42
+ export default ImageUploader;
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ isFaceCentered: boolean;
3
+ width: number;
4
+ height: number;
5
+ }
6
+ declare function PersonOverlayDesktop({ isFaceCentered, height, width }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export default PersonOverlayDesktop;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ function PersonOverlayDesktop({ isFaceCentered, height, width }) {
3
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "pointer-events-none absolute inset-0 hidden md:block", children: _jsxs("svg", { width: `${width}px`, height: `${height}px`, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "xMidYMid meet", className: "max-h-full w-full", children: [_jsxs("defs", { children: [_jsx("path", { id: "head-shoulder-path", d: "M 389.605 124.529 C 390.221 129.441 390.638 134.433 390.846 139.492 L 390.932 151.978 C 390.841 155.321 390.658 158.636 390.388 161.919 C 388.294 162.987 388.18 164.214 389 168 L 390.277 171.709 L 395 181 C 395.61 182.222 396.985 183.052 398.459 183.693 L 399.097 183.956 C 401.81 185.016 404.425 186.275 406.923 187.715 L 420.473 198.503 C 424.405 202.729 427.713 207.542 430.252 212.795 L 435.357 229.337 C 435.78 232.162 436 235.055 436 238 V 244.833 V 258.5 H 436 V 272.167 V 285.833 H 436 V 299.5 V 313.167 H 436 V 320 C 436 321.36 435.73 322.651 435.242 323.827 L 429.827 329.242 C 428.651 329.73 427.36 330 426 330 H 418.275 H 402.825 V 330 H 387.375 H 371.925 V 330 H 356.475 H 341.025 V 330 H 325.575 H 310.125 V 330 H 294.675 H 279.225 V 330 H 263.775 H 248.325 V 330 H 232.875 H 217.425 V 330 H 201.975 H 186.525 V 330 H 171.075 H 155.625 V 330 H 140.175 H 124.725 V 330 H 117 C 115.641 330 114.349 329.73 113.173 329.242 L 107.758 323.827 C 107.27 322.651 107 321.36 107 320 V 313.167 V 299.5 H 107 V 285.833 V 272.167 H 107 V 258.5 V 244.833 H 107 V 238 C 107 235.088 107.214 232.227 107.628 229.433 L 112.622 213.056 C 115.107 207.848 118.347 203.067 122.2 198.856 L 135.494 188.055 C 137.641 186.783 139.877 185.647 142.19 184.656 L 143.186 184.241 C 144.876 183.555 146.441 182.623 147.83 181.498 L 153.722 172.52 C 154.177 170.759 154.329 168.902 154.116 167.011 L 153.981 165.769 C 153.85 164.525 153.732 163.276 153.627 162.022 C 151.354 158.847 151.164 155.472 151.069 152.068 L 151.153 139.492 C 151.36 134.462 151.773 129.498 152.383 124.613 L 152.394 124.529 L 154.894 109.723 C 155.95 104.771 157.212 99.9212 158.668 95.1875 L 163.727 81.0498 C 165.649 76.3661 167.77 71.8259 170.076 67.4453 L 177.715 54.5254 C 180.508 50.3027 183.489 46.274 186.641 42.457 L 196.832 31.4316 C 200.471 27.9227 204.28 24.6674 208.24 21.6846 L 220.789 13.4502 C 225.168 10.9758 229.688 8.8149 234.332 6.9912 L 248.66 2.544 C 253.508 1.4258 258.458 0.6639 263.493 0.2832 L 278.506 0.2832 C 283.541 0.6638 288.491 1.4259 293.339 2.544 L 307.667 6.9912 C 312.311 8.8149 316.831 10.9758 321.21 13.4502 L 333.759 21.6846 C 337.719 24.6673 341.528 27.9227 345.167 31.4316 L 355.359 42.458 C 358.511 46.2749 361.491 50.3038 364.284 54.5264 L 371.923 67.4453 C 374.229 71.826 376.35 76.3661 378.272 81.0498 L 383.331 95.1875 C 384.787 99.9212 386.049 104.771 387.105 109.723 L 389.605 124.529 Z" }), _jsxs("mask", { id: "outline-mask", children: [_jsx("rect", { width: "100%", height: "100%", fill: "white" }), _jsx("use", { href: "#head-shoulder-path", fill: "black" })] })] }), _jsx("rect", { width: "100%", height: "100%", fill: !isFaceCentered
4
+ ? 'rgba(156, 156, 156, 0.40)'
5
+ : 'rgba(34, 139, 87, 0.75)', mask: "url(#outline-mask)" }), _jsx("use", { href: "#head-shoulder-path", fill: "none", stroke: !isFaceCentered ? '#B54708' : '#34D399', strokeWidth: "3", strokeDasharray: "10 5" })] }) }), _jsx("div", { className: "pointer-events-none absolute inset-0 block md:hidden", children: _jsxs("svg", { className: "block md:hidden", width: "100%", height: "100%", viewBox: "0 0 400 400", preserveAspectRatio: "xMidYMid slice", children: [_jsxs("defs", { children: [_jsx("path", { id: "fill-path", d: "M 300.85 220.1 C 301.15 223.9 302.705 227.284 305.171 230.096 V 230.097 L 311.15 234.9 L 316.351 238.504 C 320.778 242.037 324.741 246.126 328.135 250.665 L 336.459 265.409 C 338.554 270.577 340.015 276.069 340.746 281.79 V 320.036 V 359.74 V 369.667 L 340.28 374.731 C 338.938 377.967 336.351 380.555 333.115 381.896 H 300.872 H 264.633 H 228.396 H 192.158 H 155.921 H 119.682 H 83.4439 H 74.3844 L 69.319 381.896 C 66.0834 380.554 63.4953 377.967 62.1539 374.731 V 339.888 V 320.036 V 300.184 L 62.15 281.9 C 62.459 275.847 63.967 270.273 66.127 265.038 L 74.702 250.13 C 78.005 245.806 81.828 241.899 86.08 238.506 L 86.819 237.925 L 98.284 229.572 L 104.15 223.9 C 105.146 217.607 104.959 215.459 104.343 213.349 L 102.15 210.9 L 98.15 202.9 C 97.985 196.059 96.943 188.701 96.423 181.159 L 96.31 160.744 C 96.641 154.989 97.273 149.337 98.193 143.813 L 98.454 142.294 L 102.789 124.231 C 104.631 118.212 106.825 112.406 109.34 106.849 L 118.126 90.483 C 121.479 85.154 125.161 80.154 129.135 75.528 L 142.322 62.463 C 147.129 58.431 152.22 54.874 157.55 51.845 L 174.504 44.306 C 180.364 42.381 186.424 41.058 192.638 40.394 L 211.201 40.394 C 217.414 41.057 223.474 42.381 229.334 44.306 L 246.288 51.845 C 251.619 54.874 256.709 58.431 261.516 62.463 L 274.703 75.528 C 278.677 80.154 282.359 85.154 285.712 90.483 L 294.499 106.849 C 297.014 112.406 299.208 118.212 301.049 124.231 L 305.385 142.294 V 142.293 C 306.447 148.299 307.168 154.46 307.529 160.744 L 307.403 181.33 C 306.867 188.989 305.792 196.459 304.224 203.681 C 301.374 206.417 300.58 209.572 300.15 212.9 L 300.15 214.9 L 300.85 220.1 Z" }), _jsx("path", { id: "border-path", d: "M 300.85 220.1 C 301.15 223.9 302.705 227.284 305.171 230.096 V 230.097 L 311.15 234.9 L 316.351 238.504 C 320.778 242.037 324.741 246.126 328.135 250.665 L 336.459 265.409 C 338.554 270.577 340.015 276.069 340.746 281.79 V 320.036 V 359.74 V 369.667 L 340.28 374.731 C 338.938 377.967 336.351 380.555 333.115 381.896 H 300.872 H 264.633 H 228.396 H 192.158 H 155.921 H 119.682 H 83.4439 H 74.3844 L 69.319 381.896 C 66.0834 380.554 63.4953 377.967 62.1539 374.731 V 339.888 V 320.036 V 300.184 L 62.15 281.9 C 62.459 275.847 63.967 270.273 66.127 265.038 L 74.702 250.13 C 78.005 245.806 81.828 241.899 86.08 238.506 L 86.819 237.925 L 98.284 229.572 L 104.15 223.9 C 105.146 217.607 104.959 215.459 104.343 213.349 L 102.15 210.9 L 98.15 202.9 C 97.985 196.059 96.943 188.701 96.423 181.159 L 96.31 160.744 C 96.641 154.989 97.273 149.337 98.193 143.813 L 98.454 142.294 L 102.789 124.231 C 104.631 118.212 106.825 112.406 109.34 106.849 L 118.126 90.483 C 121.479 85.154 125.161 80.154 129.135 75.528 L 142.322 62.463 C 147.129 58.431 152.22 54.874 157.55 51.845 L 174.504 44.306 C 180.364 42.381 186.424 41.058 192.638 40.394 L 211.201 40.394 C 217.414 41.057 223.474 42.381 229.334 44.306 L 246.288 51.845 C 251.619 54.874 256.709 58.431 261.516 62.463 L 274.703 75.528 C 278.677 80.154 282.359 85.154 285.712 90.483 L 294.499 106.849 C 297.014 112.406 299.208 118.212 301.049 124.231 L 305.385 142.294 V 142.293 C 306.447 148.299 307.168 154.46 307.529 160.744 L 307.403 181.33 C 306.867 188.989 305.792 196.459 304.224 203.681 C 301.374 206.417 300.58 209.572 300.15 212.9 L 300.15 214.9 L 300.85 220.1 Z" }), _jsx("clipPath", { id: "face-cutout", children: _jsx("use", { href: "#fill-path" }) }), _jsxs("mask", { id: "face-mask", children: [_jsx("rect", { x: "0", y: "0", width: "400", height: "400", fill: "white" }), _jsx("use", { href: "#fill-path", fill: "black" })] })] }), _jsx("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: !isFaceCentered
6
+ ? 'rgba(156, 156, 156, 0.40)'
7
+ : 'rgba(34, 139, 87, 0.75)', mask: "url(#face-mask)" }), _jsx("use", { href: "#border-path", fill: "none", stroke: !isFaceCentered ? '#B54708' : '#34D399', strokeWidth: "3", strokeDasharray: "12 8", strokeLinecap: "round", id: "border-element" })] }) })] }));
8
+ }
9
+ export default PersonOverlayDesktop;
@@ -0,0 +1 @@
1
+ export declare function SignUpFormKYC(): import("react/jsx-runtime").JSX.Element;