@opexa/portal-components 0.0.192 → 0.0.194

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 (201) hide show
  1. package/dist/components/Bonus/Bonus.client.js +1 -1
  2. package/dist/components/Cashback/Cashback.client.js +1 -1
  3. package/dist/components/CustomPromo/CustomPromo.js +1 -1
  4. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
  5. package/dist/components/DepositWithdrawal/Deposit/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
  6. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
  7. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
  8. package/dist/components/Disclaimer/DisclaimerV2.js +7 -5
  9. package/dist/components/GameLaunch/GameLaunch.lazy.js +1 -1
  10. package/dist/components/GamesSearch/GamesSearch.js +1 -1
  11. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.js +17 -9
  12. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
  13. package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
  14. package/dist/components/Jackpots/JackpotsList/JackpotsListItemDesktop.js +15 -3
  15. package/dist/components/Jackpots/JackpotsList/JackpotsListItemMobile.js +17 -5
  16. package/dist/components/Jackpots/JackpotsList/useJackpotsListItemData.js +0 -4
  17. package/dist/components/KYC/backup/KYCContext.d.ts +5 -1
  18. package/dist/components/KYC/loadModels.d.ts +1 -0
  19. package/dist/components/KYC/loadModels.js +9 -0
  20. package/dist/components/KYC/utils.js +18 -18
  21. package/dist/components/Messages/MessageContext.d.ts +5 -1
  22. package/dist/components/News/News.js +1 -1
  23. package/dist/components/Promo/Promo.client.js +1 -1
  24. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +1 -1
  25. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +10 -5
  26. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +4 -3
  27. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +1 -1
  28. package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +1 -1
  29. package/dist/components/Quests/WageringQuest/WageringQuest.js +3 -2
  30. package/dist/components/Quests/WageringQuest/WageringQuestModal.js +4 -3
  31. package/dist/components/Search/Search.lazy.js +1 -1
  32. package/dist/components/SignUp/SignUpDefault/SignUpForm.js +2 -1
  33. package/dist/components/SignUp/SignUpForm.js +2 -1
  34. package/dist/components/SignUp/SignUpKYC/ImageUploader.js +2 -1
  35. package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +3 -2
  36. package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +1 -0
  37. package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +198 -0
  38. package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +1 -0
  39. package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +251 -0
  40. package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +10 -0
  41. package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +41 -0
  42. package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +1 -0
  43. package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +429 -0
  44. package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +13 -0
  45. package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +26 -0
  46. package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +7 -0
  47. package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +2 -0
  48. package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +11 -0
  49. package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +20 -0
  50. package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
  51. package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
  52. package/dist/constants/BranchCode.d.ts +4 -0
  53. package/dist/constants/BranchCode.js +42 -0
  54. package/dist/constants/GameProvider.d.ts +1 -1
  55. package/dist/constants/GameProvider.js +8 -0
  56. package/dist/images/game-providers/BNG.png +0 -0
  57. package/dist/services/queries.js +2436 -2436
  58. package/dist/styles/theme.css +693 -693
  59. package/dist/types/index.d.ts +6 -1
  60. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  61. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  62. package/dist/ui/Carousel/Carousel.d.ts +45 -45
  63. package/dist/ui/Carousel/carousel.recipe.d.ts +8 -8
  64. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  65. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  66. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  67. package/dist/ui/Collapsible/collapsible.recipe.d.ts +8 -8
  68. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  69. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  70. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  71. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  72. package/dist/ui/Menu/Menu.d.ts +90 -90
  73. package/dist/ui/Menu/menu.recipe.d.ts +8 -8
  74. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  75. package/dist/ui/Popover/popover.recipe.d.ts +5 -5
  76. package/dist/ui/Progress/Progress.d.ts +27 -27
  77. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  78. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  79. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  80. package/dist/ui/Select/Select.d.ts +45 -45
  81. package/dist/ui/Select/select.recipe.d.ts +3 -3
  82. package/dist/ui/Table/Table.d.ts +21 -21
  83. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  84. package/dist/ui/Table/table.recipe.d.ts +3 -3
  85. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  86. package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
  87. package/dist/utils/resizeImageSize.d.ts +1 -0
  88. package/dist/utils/resizeImageSize.js +5 -0
  89. package/package.json +164 -164
  90. package/dist/client/hooks/index.d.ts +0 -65
  91. package/dist/client/hooks/index.js +0 -65
  92. package/dist/client/services/index.d.ts +0 -4
  93. package/dist/client/services/index.js +0 -4
  94. package/dist/client/utils/index.d.ts +0 -3
  95. package/dist/client/utils/index.js +0 -3
  96. package/dist/components/Empty.d.ts +0 -10
  97. package/dist/components/Empty.js +0 -7
  98. package/dist/components/Games/GameContext.d.ts +0 -2
  99. package/dist/components/Games/GameContext.js +0 -2
  100. package/dist/components/InfiniteScroll.d.ts +0 -10
  101. package/dist/components/InfiniteScroll.js +0 -25
  102. package/dist/components/JackpotCounter/JackpotCounter.client.d.ts +0 -2
  103. package/dist/components/JackpotCounter/JackpotCounter.client.js +0 -66
  104. package/dist/components/JackpotCounter/JackpotCounter.d.ts +0 -17
  105. package/dist/components/JackpotCounter/JackpotCounter.js +0 -21
  106. package/dist/components/JackpotCounter/JackpotCounterItem.d.ts +0 -18
  107. package/dist/components/JackpotCounter/JackpotCounterItem.js +0 -109
  108. package/dist/components/JackpotCounter/JackpotCounterItem.module.css +0 -184
  109. package/dist/components/JackpotCounter/index.d.ts +0 -1
  110. package/dist/components/JackpotCounter/index.js +0 -1
  111. package/dist/components/Jackpots/JackpotDesktop.d.ts +0 -1
  112. package/dist/components/Jackpots/JackpotDesktop.js +0 -45
  113. package/dist/components/Jackpots/JackpotGameProviders.d.ts +0 -5
  114. package/dist/components/Jackpots/JackpotGameProviders.js +0 -41
  115. package/dist/components/Jackpots/JackpotItemDesktop.d.ts +0 -9
  116. package/dist/components/Jackpots/JackpotItemDesktop.js +0 -43
  117. package/dist/components/Jackpots/JackpotItemMobile.d.ts +0 -9
  118. package/dist/components/Jackpots/JackpotItemMobile.js +0 -44
  119. package/dist/components/Jackpots/JackpotMobile.d.ts +0 -1
  120. package/dist/components/Jackpots/JackpotMobile.js +0 -46
  121. package/dist/components/Jackpots/JackpotRules.d.ts +0 -5
  122. package/dist/components/Jackpots/JackpotRules.js +0 -11
  123. package/dist/components/Jackpots/Jackpots.client.d.ts +0 -2
  124. package/dist/components/Jackpots/Jackpots.client.js +0 -29
  125. package/dist/components/Jackpots/JackpotsContext.d.ts +0 -4
  126. package/dist/components/Jackpots/JackpotsContext.js +0 -3
  127. package/dist/components/Jackpots/useJackpotData.d.ts +0 -14
  128. package/dist/components/Jackpots/useJackpotData.js +0 -93
  129. package/dist/components/Jackpots/useJackpotItemData.d.ts +0 -20
  130. package/dist/components/Jackpots/useJackpotItemData.js +0 -87
  131. package/dist/components/KYC/Header.d.ts +0 -1
  132. package/dist/components/KYC/Header.js +0 -6
  133. package/dist/components/KYC/Step1.d.ts +0 -1
  134. package/dist/components/KYC/Step1.js +0 -12
  135. package/dist/components/KYC/Step2.d.ts +0 -1
  136. package/dist/components/KYC/Step2.js +0 -12
  137. package/dist/components/KYC/Step3.d.ts +0 -1
  138. package/dist/components/KYC/Step3.js +0 -11
  139. package/dist/components/KYC/Step4.d.ts +0 -1
  140. package/dist/components/KYC/Step4.js +0 -6
  141. package/dist/components/Messages/MessageItem.d.ts +0 -4
  142. package/dist/components/Messages/MessageItem.js +0 -34
  143. package/dist/components/TournamentCounter/TournamentCounter.client.d.ts +0 -2
  144. package/dist/components/TournamentCounter/TournamentCounter.client.js +0 -50
  145. package/dist/components/TournamentCounter/TournamentCounter.d.ts +0 -8
  146. package/dist/components/TournamentCounter/TournamentCounter.js +0 -21
  147. package/dist/components/TournamentCounter/TournamentCounterItem.d.ts +0 -8
  148. package/dist/components/TournamentCounter/TournamentCounterItem.js +0 -106
  149. package/dist/components/TournamentCounter/index.d.ts +0 -1
  150. package/dist/components/TournamentCounter/index.js +0 -1
  151. package/dist/components/Tournaments/TournamentDesktop.d.ts +0 -1
  152. package/dist/components/Tournaments/TournamentDesktop.js +0 -57
  153. package/dist/components/Tournaments/TournamentGameProviders.d.ts +0 -5
  154. package/dist/components/Tournaments/TournamentGameProviders.js +0 -38
  155. package/dist/components/Tournaments/TournamentItemDesktop.d.ts +0 -7
  156. package/dist/components/Tournaments/TournamentItemDesktop.js +0 -56
  157. package/dist/components/Tournaments/TournamentItemMobile.d.ts +0 -7
  158. package/dist/components/Tournaments/TournamentItemMobile.js +0 -54
  159. package/dist/components/Tournaments/TournamentMobile.d.ts +0 -1
  160. package/dist/components/Tournaments/TournamentMobile.js +0 -55
  161. package/dist/components/Tournaments/TournamentRules.d.ts +0 -5
  162. package/dist/components/Tournaments/TournamentRules.js +0 -11
  163. package/dist/components/Tournaments/Tournaments.client.d.ts +0 -2
  164. package/dist/components/Tournaments/Tournaments.client.js +0 -20
  165. package/dist/components/Tournaments/TournamentsContext.d.ts +0 -4
  166. package/dist/components/Tournaments/TournamentsContext.js +0 -3
  167. package/dist/components/Tournaments/useTournamentData.d.ts +0 -10
  168. package/dist/components/Tournaments/useTournamentData.js +0 -72
  169. package/dist/components/Tournaments/useTournamentItemData.d.ts +0 -16
  170. package/dist/components/Tournaments/useTournamentItemData.js +0 -64
  171. package/dist/components/index.d.ts +0 -33
  172. package/dist/components/index.js +0 -33
  173. package/dist/constants/envVars.d.ts +0 -5
  174. package/dist/constants/envVars.js +0 -28
  175. package/dist/constants/gameProviders.d.ts +0 -5
  176. package/dist/constants/gameProviders.js +0 -362
  177. package/dist/constants/gameTypes.d.ts +0 -4
  178. package/dist/constants/gameTypes.js +0 -64
  179. package/dist/constants/headerKeys.d.ts +0 -1
  180. package/dist/constants/headerKeys.js +0 -1
  181. package/dist/constants/secretQuestions.d.ts +0 -3
  182. package/dist/constants/secretQuestions.js +0 -24
  183. package/dist/constants/storageKeys.d.ts +0 -2
  184. package/dist/constants/storageKeys.js +0 -2
  185. package/dist/icons/index.d.ts +0 -65
  186. package/dist/icons/index.js +0 -65
  187. package/dist/images/hacksaw-gaming.png +0 -0
  188. package/dist/server/services/index.d.ts +0 -4
  189. package/dist/server/services/index.js +0 -4
  190. package/dist/server/utils/index.d.ts +0 -29
  191. package/dist/server/utils/index.js +0 -29
  192. package/dist/ui/Presence.d.ts +0 -2
  193. package/dist/ui/Presence.js +0 -7
  194. package/dist/ui/Prose.d.ts +0 -2
  195. package/dist/ui/Prose.js +0 -5
  196. package/dist/ui/index.d.ts +0 -26
  197. package/dist/ui/index.js +0 -26
  198. package/dist/utils/index.d.ts +0 -17
  199. package/dist/utils/index.js +0 -17
  200. package/dist/utils/isMobile.d.ts +0 -5
  201. package/dist/utils/isMobile.js +0 -9
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Portal } from '@ark-ui/react';
4
- import { XIcon } from '../../../icons/index.js';
5
- import { Button, Dialog } from '../../../ui/index.js';
3
+ import { XIcon } from '../../../icons/XIcon.js';
4
+ import { Button } from '../../../ui/Button/index.js';
5
+ import { Dialog } from '../../../ui/Dialog/index.js';
6
+ import { Portal } from '../../../ui/Portal/index.js';
6
7
  export function DailyCheckInQuestModal(props) {
7
8
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: props.modalState.isOpen, onOpenChange: ({ open }) => props.modalState.setIsOpen(open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("p", { className: "text-text-primary-900 text-lg font-semibold", children: "Daily Check-In Rules" }), _jsxs("ul", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn rewards just for checking in each day!" }), _jsx("li", { children: "Stay consistent to unlock special rewards on the 3rd, 5th, and 7th day." }), _jsx("li", { children: "Missing a day will reset your streak, starting again from Day 1." }), _jsx("li", { children: "Each check-in unlocks the next one on the following day." }), _jsx("li", { children: "Successfully check in for 7 consecutive days to complete the quest and reset the cycle." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => props.modalState.setIsOpen(false), children: "Ok" }) })] }) })] }) }));
8
9
  }
@@ -1,4 +1,4 @@
1
- import type { Quest } from '@opexa/portal-sdk-core';
1
+ import type { Quest } from '../../../types';
2
2
  export declare function OnboardingQuest(props: {
3
3
  quest: Quest;
4
4
  }): null;
@@ -1,4 +1,4 @@
1
- import type { Quest } from '@opexa/portal-sdk-core';
1
+ import type { Quest } from '../../../types';
2
2
  export declare function WageringQuest({ quest }: {
3
3
  quest: Quest;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,9 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
4
  import { twMerge } from 'tailwind-merge';
5
- import { ClockStopWatchIcon, InfoCircleIcon } from '../../../icons/index.js';
6
- import { Badge } from '../../../ui/index.js';
5
+ import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
6
+ import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
7
+ import { Badge } from '../../../ui/Badge/index.js';
7
8
  import CountdownTimer from '../CountdownTimer.js';
8
9
  import { WageringQuestModal } from './WageringQuestModal.js';
9
10
  export function WageringQuest({ quest }) {
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Portal } from '@ark-ui/react';
4
- import { XIcon } from '../../../icons/index.js';
5
- import { Button, Dialog } from '../../../ui/index.js';
3
+ import { XIcon } from '../../../icons/XIcon.js';
4
+ import { Button } from '../../../ui/Button/index.js';
5
+ import { Dialog } from '../../../ui/Dialog/index.js';
6
+ import { Portal } from '../../../ui/Portal/index.js';
6
7
  export function WageringQuestModal(props) {
7
8
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: props.modalState.isOpen, onOpenChange: ({ open }) => props.modalState.setIsOpen(open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("p", { className: "text-text-primary-900 text-lg font-semibold", children: props.questName }), _jsxs("ul", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn extra rewards just by playing Slots, every bet counts, win or lose!" }), _jsx("li", { children: "Reach the wagering requirement in bets to complete the quest and claim your reward." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => props.modalState.setIsOpen(false), children: "Ok" }) })] }) })] }) }));
8
9
  }
@@ -18,7 +18,7 @@ import { Dialog } from '../../ui/Dialog/index.js';
18
18
  import { Field } from '../../ui/Field/index.js';
19
19
  import { IconButton } from '../../ui/IconButton/index.js';
20
20
  import { Portal } from '../../ui/Portal/index.js';
21
- import { Presence } from '../../ui/Presence.js';
21
+ import { Presence } from '../../ui/Presence/index.js';
22
22
  import { callIfFn } from '../../utils/callIfFn.js';
23
23
  import { getGameImageUrl } from '../../utils/getGameImageUrl.js';
24
24
  import { GameLaunchTrigger } from '../GameLaunch/index.js';
@@ -9,6 +9,7 @@ import Link from 'next/link';
9
9
  import { useSearchParams } from 'next/navigation';
10
10
  import { useRef, useState } from 'react';
11
11
  import { Controller, useForm } from 'react-hook-form';
12
+ import { twMerge } from 'tailwind-merge';
12
13
  import { z } from 'zod';
13
14
  import { useShallow } from 'zustand/shallow';
14
15
  import { useControllableState } from '../../../client/hooks/useControllableState.js';
@@ -174,7 +175,7 @@ export function SignUpForm() {
174
175
  placement: 'top',
175
176
  }, children: [_jsx(Tooltip.Trigger, { children: _jsx(HelpCircleIcon, { className: "text-text-nav-item-button-icon size-4" }) }), _jsx(Tooltip.Positioner, { children: _jsxs(Tooltip.Content, { children: [_jsx(Tooltip.Arrow, { children: _jsx(Tooltip.ArrowTip, {}) }), "Choose branch closest to your residence."] }) })] })] }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: branchCollection.items.map((item) => {
176
177
  const label = branchCollection.stringifyItem(item) ?? '';
177
- return (_jsx(Select.Item, { item: item, children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
178
+ return (_jsx(Select.Item, { item: item, "aria-disabled": item.disabled, className: twMerge(item.disabled && 'text-border-disabled'), children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
178
179
  }) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] }), _jsx(Controller, { control: step1Form.control, name: "termsAccepted", render: (o) => (_jsxs(Field.Root, { className: "mt-2xl", invalid: o.fieldState.invalid, children: [_jsxs(Checkbox.Root, { checked: o.field.value, onCheckedChange: (details) => {
179
180
  o.field.onChange(details.checked);
180
181
  }, children: [_jsx(Checkbox.Control, { children: _jsx(Checkbox.Indicator, { asChild: true, children: _jsx(CheckIcon, {}) }) }), _jsxs(Checkbox.Label, { children: ["I am at least 21 years of age and I accept the", ' ', _jsx(Link, { href: signUpProps.termsAndConditionsUrl ??
@@ -192,6 +192,7 @@ export function SignUpForm() {
192
192
  mobileNumber: mobileNumberParser.format(mobileNumber),
193
193
  verificationCode: verificationCode.join(''),
194
194
  referralCode: search.get('referralCode') ?? undefined,
195
+ domain: search.get('domain') ?? undefined,
195
196
  btag: search.get('btag') ?? undefined,
196
197
  });
197
198
  const name = mobileNumberParser.format(mobileNumber);
@@ -251,7 +252,7 @@ export function SignUpForm() {
251
252
  o.field.onChange(details.value);
252
253
  }, onValueComplete: () => {
253
254
  form2Ref.current?.requestSubmit();
254
- }, blurOnComplete: true, readOnly: step2Form.formState.isSubmitting, type: "numeric", children: [_jsxs(PinInput.Control, { className: "grid-cols-[1fr_1fr_1fr_auto_1fr_1fr_1fr] items-center gap-md", children: [_jsx(PinInput.Input, { index: 0 }), _jsx(PinInput.Input, { index: 1 }), _jsx(PinInput.Input, { index: 2 }), _jsx("span", { className: "text-text-placeholder-subtle text-2xl font-medium", children: "\u2013" }), _jsx(PinInput.Input, { index: 3 }), _jsx(PinInput.Input, { index: 4 }), _jsx(PinInput.Input, { index: 5 })] }), _jsx(PinInput.HiddenInput, {})] }), _jsx(Field.ErrorText, { children: o.formState.errors.verificationCode?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: step2Form.formState.isSubmitting, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold disabled:cursor-not-allowed disabled:opacity-75", disabled: cooldown.cooling, onClick: async () => {
255
+ }, children: [_jsxs(PinInput.Control, { className: "grid-cols-[1fr_1fr_1fr_auto_1fr_1fr_1fr] items-center gap-md", children: [_jsx(PinInput.Input, { index: 0 }), _jsx(PinInput.Input, { index: 1 }), _jsx(PinInput.Input, { index: 2 }), _jsx("span", { className: "text-text-placeholder-subtle text-2xl font-medium", children: "\u2013" }), _jsx(PinInput.Input, { index: 3 }), _jsx(PinInput.Input, { index: 4 }), _jsx(PinInput.Input, { index: 5 })] }), _jsx(PinInput.HiddenInput, {})] }), _jsx(Field.ErrorText, { children: o.formState.errors.verificationCode?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-4xl", disabled: step2Form.formState.isSubmitting, children: "Verify" }), _jsxs("div", { className: "mt-3 flex w-full items-center justify-center gap-xs text-sm", children: [_jsx("span", { className: "text-text-secondary-700", children: "Didn't recieve the code?" }), _jsx("button", { type: "button", className: "text-button-secondary-fg font-semibold disabled:cursor-not-allowed disabled:opacity-75", disabled: cooldown.cooling, onClick: async () => {
255
256
  await sendVerificationCodeMutation.mutateAsync({
256
257
  channel: 'SMS',
257
258
  recipient: mobileNumberParser.format(step1Form.getValues('mobileNumber')),
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import Image from 'next/image';
4
4
  import { useEffect, useRef, useState } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
5
6
  import { UploadCloud02Icon } from '../../../icons/UploadCloud02Icon.js';
6
7
  import { Button } from '../../../ui/Button/index.js';
7
8
  import { validateFile } from '../../KYC/utils.js';
@@ -36,6 +37,6 @@ function ImageUploader({ value, name, hasDescription = true, onChange, captureOb
36
37
  setPreviewUrl(URL.createObjectURL(value));
37
38
  }
38
39
  }, [value]);
39
- 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: "mt-4 w-fit", 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' })] }));
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' })] }));
40
41
  }
41
42
  export default ImageUploader;
@@ -10,6 +10,7 @@ import Link from 'next/link';
10
10
  import { useSearchParams } from 'next/navigation';
11
11
  import { useEffect, useRef, useState } from 'react';
12
12
  import { Controller, useForm } from 'react-hook-form';
13
+ import { twMerge } from 'tailwind-merge';
13
14
  import { z } from 'zod';
14
15
  import { useShallow } from 'zustand/shallow';
15
16
  import { useControllableState } from '../../../client/hooks/useControllableState.js';
@@ -254,11 +255,11 @@ export function SignUpFormKYC() {
254
255
  placement: 'bottom',
255
256
  }, lazyMount: true, unmountOnExit: true, children: [_jsx(Select.Label, { className: "flex items-center gap-1", children: "Select Nearest Branch Around You" }), _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })] }), _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: branchCollection.items.map((item) => {
256
257
  const label = branchCollection.stringifyItem(item) ?? '';
257
- return (_jsx(Select.Item, { item: item, children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
258
+ return (_jsx(Select.Item, { item: item, "aria-disabled": item.disabled, className: twMerge(item.disabled && 'text-border-disabled'), children: _jsx("div", { title: label, className: "line-clamp-1", children: label }) }, item.code));
258
259
  }) }) })] }), _jsx(Field.ErrorText, { children: step1Form.formState.errors.branchCode?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.frontImage, className: "mt-xl", children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(ImageUploader, { value: props.frontImage || null, hasDescription: true, name: "idFrontImage", captureObject: "ID_DOCUMENT", onChange: (file) => {
259
260
  step1Form.setValue('frontImage', file);
260
261
  props.setFrontImage(file);
261
- } }, "id-front-image-upload"), _jsx(Field.ErrorText, { children: step1Form.formState.errors.frontImage?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.selfieImage, className: "mt-xl", children: [_jsx(Field.Label, { children: "Selfie holding your ID" }), _jsx(ImageUploader, { value: props.selfieImage || null, name: "selfieImage", captureObject: "SELFIE", onChange: (file) => {
262
+ } }, "id-front-image-upload"), _jsx(Field.ErrorText, { children: step1Form.formState.errors.frontImage?.message })] }), _jsxs(Field.Root, { invalid: !!step1Form.formState.errors.selfieImage, className: "mt-xl", children: [_jsx(Field.Label, { children: "Selfie holding your ID" }), _jsx(ImageUploader, { value: props.selfieImage || null, name: "selfieImage", captureObject: "SELFIE", hasDescription: false, onChange: (file) => {
262
263
  step1Form.setValue('selfieImage', file);
263
264
  props.setSelfieImage(file);
264
265
  } }, "selfie-image-upload"), _jsx(Field.ErrorText, { children: step1Form.formState.errors.selfieImage?.message })] }), _jsxs("div", { className: "mt-xl text-center text-sm", children: ["Prohibition to play in open and public places", _jsxs("div", { className: "mt-5 flex items-center justify-center gap-3xl", children: [_jsx("div", { className: "flex size-5xl items-center justify-center overflow-hidden rounded-full bg-white", children: _jsx(Image, { src: pagcorLogo, alt: "", draggable: false, className: "h-9.5 w-auto" }) }), _jsx(Image, { src: responsibleGamingLogo, alt: "", height: 62, width: 186, className: "h-10 w-auto", draggable: false })] })] }), _jsx(Controller, { control: step1Form.control, name: "termsAccepted", render: (o) => (_jsxs(Field.Root, { className: "mt-2xl", invalid: o.fieldState.invalid, children: [_jsxs(Checkbox.Root, { checked: o.field.value, onCheckedChange: (details) => {
@@ -0,0 +1 @@
1
+ export declare function CaptureIdDocument(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,198 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { ArrowLeftIcon } from '../../../icons/ArrowLeftIcon.js';
6
+ import { Camera01Icon } from '../../../icons/Camera01Icon.js';
7
+ import { CheckCircleIcon } from '../../../icons/CheckCircleIcon.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 { dataURLtoBlob, resizeFile } from '../../KYC/utils.js';
13
+ import { useSignUpPagcorPropsContext } from './SignUpPagcorContext.js';
14
+ export function CaptureIdDocument() {
15
+ const props = useSignUpPagcorPropsContext();
16
+ const [videoStream, setVideoStream] = useState(null);
17
+ const [cameraError, setCameraError] = useState(null);
18
+ const [isLoading, setIsLoading] = useState(false);
19
+ const [selectedImage, setSelectedImage] = useState(null);
20
+ const [captureInProgress, setCaptureInProgress] = useState(false);
21
+ const [proccessImageCanvas, setProccessImageCanvas] = useState(null);
22
+ const videoElement = useRef(null);
23
+ const containerRef = useRef(null);
24
+ function stopCamera() {
25
+ if (videoStream) {
26
+ videoStream.getTracks().forEach((track) => track.stop());
27
+ setVideoStream(null);
28
+ }
29
+ }
30
+ useEffect(() => {
31
+ return () => {
32
+ stopCamera();
33
+ };
34
+ }, [videoStream]);
35
+ async function startCamera() {
36
+ try {
37
+ setIsLoading(true);
38
+ setCameraError(null);
39
+ setCaptureInProgress(true);
40
+ console.log('Starting camera...');
41
+ const stream = await navigator.mediaDevices.getUserMedia({
42
+ video: {
43
+ facingMode: 'environment',
44
+ aspectRatio: 16 / 9,
45
+ width: { ideal: 1920, max: 1920 },
46
+ height: { ideal: 1080, max: 1080 },
47
+ frameRate: {
48
+ ideal: 30,
49
+ max: 60,
50
+ },
51
+ },
52
+ audio: false,
53
+ });
54
+ // Set the stream directly to the video element
55
+ if (videoElement.current) {
56
+ videoElement.current.srcObject = stream;
57
+ videoElement.current.onloadedmetadata = () => {
58
+ console.log('Video metadata loaded, starting playback...');
59
+ videoElement.current
60
+ ?.play()
61
+ .then(() => {
62
+ setVideoStream(stream);
63
+ setIsLoading(false);
64
+ })
65
+ .catch(() => {
66
+ setCameraError('Failed to start camera stream. Please try again.');
67
+ setIsLoading(false);
68
+ // Stop the stream if playback fails
69
+ stream.getTracks().forEach((track) => track.stop());
70
+ });
71
+ };
72
+ videoElement.current.onerror = (err) => {
73
+ console.error('Video element error:', err);
74
+ setCameraError('Video playback error. Please try again.');
75
+ setIsLoading(false);
76
+ stream.getTracks().forEach((track) => track.stop());
77
+ };
78
+ }
79
+ else {
80
+ console.error('Video element not available');
81
+ setCameraError('Camera initialization failed. Please try again.');
82
+ setCaptureInProgress(false);
83
+ setIsLoading(false);
84
+ stream.getTracks().forEach((track) => track.stop());
85
+ }
86
+ }
87
+ catch (error) {
88
+ setIsLoading(false);
89
+ if (error instanceof DOMException) {
90
+ console.error('Error accessing camera:', error.message);
91
+ setCameraError(error.message);
92
+ }
93
+ else {
94
+ console.error('Unknown error accessing camera:', error);
95
+ setCameraError('An unknown error occurred. Please check permissions and try again.');
96
+ }
97
+ setCaptureInProgress(false);
98
+ }
99
+ }
100
+ function captureAndProcessImage() {
101
+ if (!videoElement.current || !videoStream) {
102
+ console.error('Video element or stream not available for capture');
103
+ return;
104
+ }
105
+ try {
106
+ const canvas = document.createElement('canvas');
107
+ const parentDiv = document.getElementById('parent');
108
+ canvas.width = parentDiv?.clientWidth || videoElement.current.width;
109
+ canvas.height = parentDiv?.clientHeight || videoElement.current.height;
110
+ const ctx = canvas.getContext('2d');
111
+ if (!ctx) {
112
+ console.error('Could not get 2D context for canvas');
113
+ setCameraError('Failed to process image. Please try again.');
114
+ setCaptureInProgress(false);
115
+ return;
116
+ }
117
+ ctx.drawImage(videoElement.current, 0, 0, canvas.width, canvas.height);
118
+ const imageSrc = canvas.toDataURL('image/png', 1.0);
119
+ setSelectedImage({ src: imageSrc });
120
+ setCaptureInProgress(false);
121
+ stopCamera();
122
+ const newImg = document.createElement('img');
123
+ newImg.src = imageSrc;
124
+ //@ts-expect-error jscanify is not typed
125
+ const scanner = new jscanify();
126
+ newImg.onload = () => {
127
+ try {
128
+ if (containerRef.current) {
129
+ // containerRef.current.innerHTML = '';
130
+ const paperWidth = parentDiv?.clientWidth || videoElement.current?.videoWidth;
131
+ const paperHeight = parentDiv?.clientHeight || videoElement.current?.videoHeight;
132
+ //@ts-expect-error jscanify is not typed
133
+ const contour = scanner.findPaperContour(cv.imread(newImg));
134
+ const cornerPoints = scanner.getCornerPoints(contour);
135
+ const resultCanvas = scanner.extractPaper(newImg, paperWidth, paperHeight, cornerPoints);
136
+ newImg.className =
137
+ 'absolute inset-0 m-auto w-full h-auto md:max-h-[333px] md:max-w-[643px] aspect-video rounded-lg object-contain';
138
+ setProccessImageCanvas(resultCanvas);
139
+ containerRef.current.appendChild(resultCanvas);
140
+ setCaptureInProgress(false);
141
+ setSelectedImage({ src: resultCanvas.toDataURL('image/png') });
142
+ }
143
+ }
144
+ catch (error) {
145
+ console.error('Error processing image:', error);
146
+ setCameraError('Failed to process image. Please try again.');
147
+ }
148
+ };
149
+ newImg.onerror = () => {
150
+ console.error('Error loading image');
151
+ setCameraError('Failed to load image. Please try again.');
152
+ };
153
+ }
154
+ catch (error) {
155
+ console.error('Error capturing image:', error);
156
+ setCameraError('Failed to capture image. Please try again.');
157
+ setCaptureInProgress(false);
158
+ }
159
+ }
160
+ async function uploadPhoto() {
161
+ if (!proccessImageCanvas) {
162
+ console.error('Failed to process the image. Please try again.');
163
+ return;
164
+ }
165
+ const blob = proccessImageCanvas.toDataURL('image/png', 1.0);
166
+ const processedBlob = dataURLtoBlob(blob);
167
+ const img = new File([processedBlob], 'frontImage', { type: 'image/jpeg' });
168
+ const resizedImage = (await resizeFile(img));
169
+ if (resizedImage) {
170
+ props.setFrontImage(resizedImage);
171
+ props.setCapturing(null);
172
+ stopCamera();
173
+ }
174
+ }
175
+ function retakePhoto() {
176
+ setSelectedImage(null);
177
+ setCaptureInProgress(true);
178
+ setCameraError(null);
179
+ if (containerRef.current) {
180
+ const canvas = containerRef.current.querySelector('canvas');
181
+ if (canvas) {
182
+ canvas.width = canvas.width;
183
+ }
184
+ containerRef.current.innerHTML = '';
185
+ }
186
+ if (videoElement.current) {
187
+ videoElement.current.play();
188
+ }
189
+ startCamera();
190
+ }
191
+ return (_jsx(Dialog.Root, { open: props.capturing === 'ID_DOCUMENT', 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 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: () => {
192
+ stopCamera();
193
+ props.setCapturing(null);
194
+ }, 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 Picture of Your Front ID" }), _jsxs(Dialog.Description, { className: "lg:max-w-auto text-text-tertiary-600 mx-auto mt-sm max-w-[19rem] text-center text-sm lg:max-w-full", children: ["Make sure your ID is clearly visible, well-lit, and not blurry.", _jsx("br", { className: "hidden lg:block" }), " Avoid glare or reflections, and ensure all corners are within the frame."] }), _jsx("div", { id: "parent", className: "border-border-disabled mt-6 aspect-video rounded-xl border bg-black lg:mt-8", children: cameraError ? (_jsx("div", { className: "flex h-full items-center justify-center p-4", children: _jsxs("div", { className: "text-center", children: [_jsx("p", { className: "text-red-500 mb-2 text-sm", children: "Camera Error" }), _jsx("p", { className: "text-gray-400 text-xs", children: cameraError })] }) })) : captureInProgress ? (_jsxs("div", { className: "relative flex h-fit w-full flex-col items-center justify-center", children: [_jsx("video", { ref: videoElement, autoPlay: true, muted: true, playsInline: true, className: "relative h-[60vh] w-full rounded-lg object-cover md:aspect-video md:max-h-[333px]", width: "100%", height: "100%" }), _jsxs("div", { className: "pointer-events-none absolute inset-0 z-50", children: [_jsx("div", { className: twMerge('absolute inset-0 w-full bg-black/60 backdrop-blur-sm [clip-path:polygon(0%_0%,0%_100%,calc(50%-158px)_100%,calc(50%-158px)_calc(50%-100px),calc(50%+158px)_calc(50%-100px),calc(50%+158px)_calc(50%+100px),calc(50%-158px)_calc(50%+100px),calc(50%-158px)_100%,100%_100%,100%_0%)] md:[clip-path:polygon(0%_0%,0%_100%,calc(50%-225px)_100%,calc(50%-225px)_calc(50%-142px),calc(50%+225px)_calc(50%-142px),calc(50%+225px)_calc(50%+142px),calc(50%-225px)_calc(50%+142px),calc(50%-225px)_100%,100%_100%,100%_0%)]') }), _jsx("div", { className: "absolute inset-0 z-[60] mx-auto flex items-center justify-center", children: _jsx("div", { className: "relative aspect-[1011/638] h-[200px] md:h-[295px] md:w-[450px]", children: _jsx("div", { className: "h-full w-full rounded-lg border-4 border-dashed border-[#B54708]" }) }) })] })] })) : (_jsx("div", { ref: containerRef, className: "relative grid h-full w-full place-items-center rounded-lg object-contain md:max-h-[333px]" })) }), cameraError ? (_jsx("div", { className: "mt-4 text-center", children: _jsx(Button, { className: "mx-auto px-xl lg:w-fit", onClick: () => {
195
+ setCameraError(null);
196
+ startCamera();
197
+ }, children: "Try Again" }) })) : captureInProgress ? (_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-6 px-xl disabled:opacity-100 lg:mt-8 lg:w-fit", onClick: captureAndProcessImage, children: ["Capture Image", _jsx(Camera01Icon, { className: "size-5" })] })) : selectedImage && selectedImage.src ? (_jsxs("div", { className: "mt-4 flex flex-col items-center justify-center gap-2 md:flex-row", children: [_jsxs(Button, { className: "lg:w-fit", type: "button", onClick: retakePhoto, children: ["Retake Photo ", _jsx(Camera01Icon, { className: "ml-1" })] }), _jsxs(Button, { className: "lg:w-fit", type: "button", onClick: uploadPhoto, children: ["Use Photo ", _jsx(CheckCircleIcon, { className: "ml-1" })] })] })) : (_jsxs(Button, { className: "disabled:bg-bg-disabled disabled:text-text-disabled mx-auto mt-6 px-xl disabled:opacity-100 lg:mt-8 lg:w-fit", onClick: startCamera, disabled: isLoading || !!videoStream, children: [isLoading ? 'Starting Camera...' : 'Start Camera', _jsx(Camera01Icon, { className: "size-5" })] }))] }) }) })] }) }));
198
+ }
@@ -0,0 +1 @@
1
+ export declare function CaptureSelfie(): import("react/jsx-runtime").JSX.Element;
@@ -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 '../../KYC/PersonOverlayDesktop.js';
14
+ import { dataURLtoBlob, loadFaceApiModels, resizeFile } from '../../KYC/utils.js';
15
+ import { useSignUpPagcorPropsContext } from './SignUpPagcorContext.js';
16
+ export function CaptureSelfie() {
17
+ const props = useSignUpPagcorPropsContext();
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 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
+ }