@swan-admin/swan-web-component 1.0.118 → 1.0.119

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 (64) hide show
  1. package/dist/BodyScan--QQkmBvw.js +2 -0
  2. package/dist/BodyScan--QQkmBvw.js.map +1 -0
  3. package/dist/BodyScan-1GnGflqx.js +2 -0
  4. package/dist/BodyScan-1GnGflqx.js.map +1 -0
  5. package/dist/BodyScan-B0MKE1vY.js +2 -0
  6. package/dist/BodyScan-B0MKE1vY.js.map +1 -0
  7. package/dist/BodyScan-B85rcTFy.js +2 -0
  8. package/dist/BodyScan-B85rcTFy.js.map +1 -0
  9. package/dist/BodyScan-B90ht9_5.js +2 -0
  10. package/dist/BodyScan-B90ht9_5.js.map +1 -0
  11. package/dist/BodyScan-BVAqja5k.js +2 -0
  12. package/dist/BodyScan-BVAqja5k.js.map +1 -0
  13. package/dist/BodyScan-BVrc-R6j.js +2 -0
  14. package/dist/BodyScan-BVrc-R6j.js.map +1 -0
  15. package/dist/BodyScan-Be0NcDVq.js +2 -0
  16. package/dist/BodyScan-Be0NcDVq.js.map +1 -0
  17. package/dist/BodyScan-BlT-y35F.js +2 -0
  18. package/dist/BodyScan-BlT-y35F.js.map +1 -0
  19. package/dist/BodyScan-C7dkFVxY.js +2 -0
  20. package/dist/BodyScan-C7dkFVxY.js.map +1 -0
  21. package/dist/BodyScan-CAIYPUJI.js +2 -0
  22. package/dist/BodyScan-CAIYPUJI.js.map +1 -0
  23. package/dist/BodyScan-CRfmNpg7.js +2 -0
  24. package/dist/BodyScan-CRfmNpg7.js.map +1 -0
  25. package/dist/BodyScan-Cgut5BZ2.js +2 -0
  26. package/dist/BodyScan-Cgut5BZ2.js.map +1 -0
  27. package/dist/BodyScan-CrmHVOBq.js +2 -0
  28. package/dist/BodyScan-CrmHVOBq.js.map +1 -0
  29. package/dist/BodyScan-CvT6nbKG.js +2 -0
  30. package/dist/BodyScan-CvT6nbKG.js.map +1 -0
  31. package/dist/BodyScan-DChxaIeM.js +2 -0
  32. package/dist/BodyScan-DChxaIeM.js.map +1 -0
  33. package/dist/BodyScan-DogOXXY0.js +2 -0
  34. package/dist/BodyScan-DogOXXY0.js.map +1 -0
  35. package/dist/BodyScan-b7bRBOYK.js +2 -0
  36. package/dist/BodyScan-b7bRBOYK.js.map +1 -0
  37. package/dist/BodyScan-kpbgefyc.js +2 -0
  38. package/dist/BodyScan-kpbgefyc.js.map +1 -0
  39. package/dist/BodyScan-lCqgPd6z.js +2 -0
  40. package/dist/BodyScan-lCqgPd6z.js.map +1 -0
  41. package/dist/BodyScan-lc189qhY.js +2 -0
  42. package/dist/BodyScan-lc189qhY.js.map +1 -0
  43. package/dist/BodyScan-liyrkU6l.js +2 -0
  44. package/dist/BodyScan-liyrkU6l.js.map +1 -0
  45. package/dist/BodyScan-xFn2tlOj.js +2 -0
  46. package/dist/BodyScan-xFn2tlOj.js.map +1 -0
  47. package/dist/BodyScan-ym1Rn7E9.js +2 -0
  48. package/dist/BodyScan-ym1Rn7E9.js.map +1 -0
  49. package/dist/FaceScan-1Fwy5JDo.js +2 -0
  50. package/dist/FaceScan-1Fwy5JDo.js.map +1 -0
  51. package/dist/FaceScan-D1B_6J78.js +2 -0
  52. package/dist/FaceScan-D1B_6J78.js.map +1 -0
  53. package/dist/LoadingScreen-C_pA2xaB.js +2 -0
  54. package/dist/LoadingScreen-C_pA2xaB.js.map +1 -0
  55. package/dist/LoadingScreen-HQLN5ZOg.js +2 -0
  56. package/dist/LoadingScreen-HQLN5ZOg.js.map +1 -0
  57. package/dist/bodyScan.js +1 -1
  58. package/dist/bodyScan.mjs +1 -1
  59. package/dist/faceScan.js +1 -1
  60. package/dist/faceScan.mjs +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist/index.mjs +1 -1
  63. package/dist/index.mjs.map +1 -1
  64. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BodyScan-BlT-y35F.js","sources":["../src/utils/context/mediaContext.tsx","../src/components/bodyScan/CameraScanChild.tsx","../src/customHooks/useTensorFlow.ts","../src/components/bodyScan/ScanningComponent.tsx","../src/components/bodyScan/AngleDetector.tsx","../src/components/Modal.tsx","../src/components/bodyScan/CameraPermission.tsx","../src/components/bodyScan/VideoPlayer.tsx","../src/components/bodyScan/ScanErrorMessage.tsx","../src/components/Signup.tsx","../src/components/bodyScan/BodyScanSteps.tsx","../src/components/bodyScan/BodyScan.tsx","../src/customHooks/useGyroSensor.ts"],"sourcesContent":["\"use client\"\nimport React, {\n createContext,\n Dispatch,\n ReactNode,\n SetStateAction,\n useEffect,\n useLayoutEffect,\n useMemo,\n useState,\n} from \"react\";\n\nexport const MEDIA_TYPES = {\n DESKTOP: \"DESKTOP\",\n TAB: \"TAB\",\n MOBILE: \"MOBILE\",\n};\n\ninterface MediaContextType {\n size: number[];\n setSize: Dispatch<SetStateAction<number[]>>;\n clearInputs: boolean;\n setClearInputs: Dispatch<SetStateAction<boolean>>;\n media: string;\n}\n\nexport const MediaContext = createContext<MediaContextType | undefined>(\n undefined\n);\n\nfunction MediaContextProvider({ children }: { children: ReactNode }) {\n const [size, setSize] = useState([window?.innerWidth, window?.innerHeight]);\n const [clearInputs, setClearInputs] = useState(false);\n\n const updateSize = () => {\n setSize([window?.innerWidth, window?.innerHeight]);\n };\n useEffect(() => {\n updateSize();\n }, []);\n useLayoutEffect(() => {\n window.addEventListener(\"resize\", updateSize);\n return () => window.removeEventListener(\"resize\", updateSize);\n }, [updateSize]);\n let media = MEDIA_TYPES.DESKTOP;\n if (size[0] > 768 && size[0] < 1024) {\n media = MEDIA_TYPES.TAB;\n }\n if (size[0] < 768) {\n media = MEDIA_TYPES.MOBILE;\n }\n\n const mediaDetails = useMemo(\n () => ({\n size,\n setSize,\n clearInputs,\n setClearInputs,\n media,\n }),\n [size, clearInputs, media]\n );\n\n return (\n <MediaContext.Provider value={mediaDetails}>\n {children}\n </MediaContext.Provider>\n );\n}\n\nexport default MediaContextProvider;\n","import { useContext } from \"react\";\nimport Webcam from \"react-webcam\";\nimport { CameraScanChildProps } from \"../../types/interfaces\";\nimport { MEDIA_TYPES, MediaContext } from \"../../utils/context/mediaContext\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { pauseIcon, voiceOverAssetsPath } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { X } from \"lucide-react\";\n\n\n\nfunction CameraScanChild({\n resetScan,\n loadingCam,\n onUserMedia,\n onPause,\n pause,\n recordingStarted,\n startSendingVideoFrames,\n showPause,\n webcamRef,\n onUserMediaError,\n resetDetector,\n videoConstraints,\n webcamKey,\n}: Omit<CameraScanChildProps, \"config\">) {\n const { media } = useContext(MediaContext) || {};\n const { translate } = useContext(LanguageContext) || {};\n\n return (\n <div className=\"App w-screen h-[100vh] relative common-ui-main\">\n <span\n onClick={() => {\n resetScan();\n resetDetector();\n }}\n className=\"fixed right-[20px] top-[20px] z-[999]\"\n >\n <X className=\"text-[#fff]\" />\n </span>\n\n <div className=\"w-full h-full overflow-hidden \">\n {media === MEDIA_TYPES.MOBILE && (\n <Webcam\n key={webcamKey}\n audio={false}\n ref={webcamRef}\n screenshotQuality={1}\n videoConstraints={videoConstraints}\n mirrored\n screenshotFormat=\"image/jpeg\"\n onUserMedia={onUserMedia}\n onUserMediaError={onUserMediaError}\n style={{\n position: \"fixed\",\n top: 0,\n bottom: 0,\n zIndex: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n }}\n />\n )}\n </div>\n\n <div className=\"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center\">\n {showPause && (\n <SpecificButton\n className=\"!w-[180px] !h-[40px] !py-[0] mx-auto \"\n prefix={pauseIcon}\n buttonText={translate?.(LanguageKeys.pause)}\n buttonFunc={onPause}\n btnSecondary\n />\n )}\n\n {pause ? (\n <div>\n <SpecificButton\n className=\"!w-[180px] !h-[40px] !py-[0] mx-auto\"\n buttonText={translate?.(LanguageKeys.restart)}\n buttonFunc={resetScan}\n btnSecondary\n />\n </div>\n ) : !recordingStarted ? (\n <SpecificButton\n className={`!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] ${\n loadingCam ? \"!opacity-50\" : \"\"\n }`}\n buttonText={translate?.(LanguageKeys.startScan)}\n buttonFunc={startSendingVideoFrames}\n disabled={loadingCam}\n />\n ) : null}\n </div>\n\n <audio\n id=\"audioElement\"\n crossOrigin=\"anonymous\"\n preload=\"auto\"\n style={{\n position: \"absolute\",\n zIndex: -99999,\n }}\n src={`${voiceOverAssetsPath}scanAudioInstructions/silence.mp3`}\n />\n </div>\n );\n}\n\nexport default CameraScanChild;\n","import { useState, useRef, useEffect } from \"react\";\n// We keep this, but we will make it optional in the logic below\n\ntype KeypointTuple = [number, number, number];\n\n// GLOBAL SINGLETONS (Persist across component re-mounts)\n// This prevents reloading the heavy model if the user navigates away and back.\nlet globalLoadingPromise: Promise<boolean> | null = null;\nlet globalDetector: any = null;\nlet globalPoseLib: any = null;\n\nexport default function useTensorFlow() {\n const [consecutiveFronts, setConsecutiveFronts] = useState(0);\n const [spinPhase, setSpinPhase] = useState(0);\n const [isLoaded, setIsLoaded] = useState(false);\n\n const spinPhaseRef = useRef(0);\n const consecutiveFrontsRef = useRef(0);\n const mounted = useRef(true);\n\n useEffect(() => {\n mounted.current = true; // Reset on mount\n\n // 1. If already loaded globally, just use it.\n if (globalDetector) {\n setIsLoaded(true);\n return;\n }\n\n // 2. If not loading, start the process.\n if (!globalLoadingPromise) {\n globalLoadingPromise = loadDependenciesGlobal();\n }\n\n // 3. Wait for the global promise to resolve.\n globalLoadingPromise.then((success) => {\n if (success && mounted.current) {\n setIsLoaded(true);\n }\n });\n\n return () => {\n mounted.current = false;\n };\n }, []);\n\n /**\n * Loads TensorFlow/MediaPipe dynamically.\n * This logic is ISOLATED from the server.\n */\n async function loadDependenciesGlobal(): Promise<boolean> {\n // GUARDRAIL 1: Strict Environment Check\n // Ensure we are in a browser environment with media capabilities\n if (\n typeof window === 'undefined' || \n typeof navigator === 'undefined'\n ) {\n return false;\n }\n \n try {\n console.log(\"Starting TensorFlow preload...\");\n \n // GUARDRAIL 2: Dynamic Imports\n // These heavy modules are only fetched by the browser, never the server.\n const [poseLib, tfjsCore, tfjsBackend] = await Promise.all([\n import(\"@tensorflow-models/pose-detection\"),\n import(\"@tensorflow/tfjs-core\"),\n import(\"@tensorflow/tfjs-backend-webgl\") // Triggers backend registration side-effect\n ]);\n \n globalPoseLib = poseLib;\n \n // Explicitly set the backend to WebGL for performance\n await tfjsCore.setBackend('webgl');\n await tfjsCore.ready();\n console.log(\"TensorFlow backend ready (WebGL)\");\n\n // GUARDRAIL 3: Zero-Config Asset Loading\n // If TENSORFLOW_SOLUTION_PATH fails or is missing, we must fallback \n // to a CDN so the user doesn't have to copy files manually.\n const modelConfig = {\n runtime: \"mediapipe\",\n modelType: \"full\",\n solutionPath:\"https://cdn.jsdelivr.net/npm/@mediapipe/pose\", // Fallback for Zero Config\n } as const;\n\n try {\n globalDetector = await globalPoseLib.createDetector(\n globalPoseLib.SupportedModels.BlazePose,\n modelConfig\n );\n console.log(\"MediaPipe detector created successfully\");\n } catch (mediapipeError) {\n console.warn(\"MediaPipe failed, falling back to TFJS runtime:\", mediapipeError);\n \n // Fallback to TFJS runtime (slower but works without external assets)\n globalDetector = await globalPoseLib.createDetector(\n globalPoseLib.SupportedModels.BlazePose,\n {\n runtime: \"tfjs\",\n modelType: \"full\",\n }\n );\n console.log(\"TFJS detector created successfully\");\n }\n \n return true;\n } catch (error) {\n console.error(\"Failed to load TensorFlow dependencies:\", error);\n globalLoadingPromise = null; // Reset so retry is possible\n return false;\n }\n }\n\n function isFrontFrame(body: KeypointTuple[]) {\n // Guardrail: Ensure points exist before filtering\n if (!body || body.length === 0) return false;\n return body.filter((p) => p[2] > 0.7).length === 22;\n }\n\n const poseDetector = async (callback: () => void, webcamRef: any) => {\n // GUARDRAIL 4: Runtime Safety\n // Check if everything is truly ready before calculating\n if (!globalDetector || !mounted.current || !webcamRef?.current?.video) {\n return;\n }\n \n // Check if video is actually playing and has data\n const video = webcamRef.current.video;\n if (video.readyState < 2) return; \n\n try {\n const poses = await globalDetector.estimatePoses(\n video,\n { flipHorizontal: false }\n );\n\n if (!poses || !poses.length) return;\n\n const keypoints = poses[0].keypoints;\n \n // Standardize keypoints\n const body: KeypointTuple[] = keypoints\n .slice(11) // Ignore face keypoints (0-10)\n .map((kp: any) => [\n kp.x > 0 && kp.x < 720 ? kp.x : -1,\n kp.y > 0 && kp.y < 1280 ? kp.y : -1,\n kp.score ?? 0,\n ]);\n\n if (spinPhaseRef.current === 0 && !isFrontFrame(body)) {\n setConsecutiveFronts((prev) => prev + 1);\n }\n\n if (spinPhaseRef.current === 1 && isFrontFrame(body)) {\n setConsecutiveFronts((prev) => prev + 1);\n }\n\n if (spinPhaseRef.current === 2) callback();\n } catch (err) {\n console.error(\"Pose detection error:\", err);\n }\n };\n\n useEffect(() => {\n consecutiveFrontsRef.current = consecutiveFronts;\n if (consecutiveFronts > 6 && spinPhaseRef.current < 2) {\n setSpinPhase((s) => s + 1);\n setConsecutiveFronts(0);\n }\n }, [consecutiveFronts]);\n\n useEffect(() => {\n spinPhaseRef.current = spinPhase;\n }, [spinPhase]);\n\n const resetDetector = () => {\n spinPhaseRef.current = 0;\n consecutiveFrontsRef.current = 0;\n setConsecutiveFronts(0);\n setSpinPhase(0);\n };\n\n const retryLoading = async () => {\n if (!globalDetector && !globalLoadingPromise) {\n globalLoadingPromise = loadDependenciesGlobal();\n const success = await globalLoadingPromise;\n if (success && mounted.current) {\n setIsLoaded(true);\n }\n }\n };\n\n return { \n poseDetector, \n isLoaded,\n spinPhase,\n resetDetector,\n retryLoading\n };\n}","/* eslint-disable no-use-before-define */\nimport React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport CameraScanChild from \"./CameraScanChild\";\nimport posthog from \"../../utils/posthog\";\nimport Webcam from \"react-webcam\";\nimport { ScanningComponentProps } from \"../../types/interfaces\";\nimport useTensorFlow from \"../../customHooks/useTensorFlow\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport {\n\tgenerateUuid,\n\tgetCurrentTimeInSeconds,\n\tgetPreferredMediaRecorderTypes,\n\tgetRecordingExtension,\n\tgetRecordingMimeType,\n\tgetSupportedMediaRecorderTypes,\n\thandleScanTimeCapture,\n\trescanSupportCaptureEvent,\n} from \"../../utils/utils\";\nimport speechService from \"../../utils/service/speechService\";\nimport { videoConstraintsExact, videoConstraintsFallback, videoTypes, voiceOverAssetsPath } from \"../../utils/constants\";\n\nlet id: string | null = null;\nlet audioTimeoutId: ReturnType<typeof setTimeout> | undefined;\nlet lastVideoPlayed: {\n\tskipCount: number;\n\tno_of_times_skipped: number;\n\taudioName: string;\n} | null = null;\n\nfunction ScanningComponent({ setIsScanLocked, resetDetector, scanID, setIsVideoUploaded, setScanFailsError, setScanStartTime, setScanUniqueKey, userDetails }: Omit<ScanningComponentProps, \"config\">) {\n\tconst { gender, heightInCm, email, shopDomain } = userDetails;\n\tconst webcamRef = useRef<Webcam | null>(null);\n\tconst mediaRecorderRef = useRef<MediaRecorder | null>(null);\n\tconst recordedFpsRef = useRef<number | null>(null);\n\tconst [recordedChunks, setRecordedChunks] = useState<Blob[]>([]);\n\tconst [loadingCam, setLoadingCam] = useState(true);\n\tconst [recordingStarted, setRecordingStarted] = useState(false);\n\tconst [faceDone, setFaceDone] = useState(false);\n\tconst [mediaRecorderStopped, setMediaRecorderStopped] = useState(true);\n\tconst [isScanning, setIsScanning] = useState(false);\n\tconst captureVideoTimeOutHandle = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst [audioSource, setAudioSource] = useState(\"\");\n\tconst [audioSourceList, setAudioSourceList] = useState<string[]>([]);\n\tconst [emptyAudioSource, setEmptyAudioSource] = useState(\"\");\n\tconst [startAgain, setStartAgain] = useState(false);\n\tconst [showRestart, setRestart] = useState(false);\n\tconst [pause, setPause] = useState(false);\n\tconst [events, setEvents] = useState<any>([]);\n\tconst [showPause, setShowPause] = useState(false);\n\tconst allowAudioToPlay = useRef(true);\n\tconst { poseDetector } = useTensorFlow();\n\tconst firstScan = useRef(true);\n\tconst poseStoppedRef = useRef(false);\n\tconst counterRef = useRef(0);\n\tconst consecutiveFalseRef = useRef(0);\n\tconst poseListenerRegistered = useRef(false);\n\tconst brilliantPlayedRef = useRef(false);\n\tconst postPoseProcessRef = useRef<() => void>(() => {});\n\tconst [supportedTypes, setSupportedTypes] = useState<string[]>([]);\n\tconst [webcamKey, setWebcamKey] = useState(0);\n\tconst [currentVideoConstraints, setCurrentVideoConstraints] = useState<MediaTrackConstraints>(videoConstraintsExact);\n\n\tconst { setStartGyro, uploadScanFile, setUploadLoading, swan, onScanStart, onCaptureComplete } = useContext(ParamsContext);\n\n\t// Refs to avoid stale closures in callbacks after pause/restart\n\tconst scanIDRef = useRef(scanID);\n\tuseEffect(() => { scanIDRef.current = scanID; }, [scanID]);\n\n\tconst eventsRef = useRef(events);\n\tuseEffect(() => { eventsRef.current = events; }, [events]);\n\n\tconst startSendingVideoFramesRef = useRef<() => void>(() => {});\n\n\tconst resetScan = () => {\n\t\tposeStoppedRef.current = false;\n\t\tclearTimeout(audioTimeoutId);\n\t\tif (captureVideoTimeOutHandle.current) clearTimeout(captureVideoTimeOutHandle.current);\n\t\tsetScanUniqueKey(generateUuid());\n\t\tsetScanFailsError(\"\");\n\t\tsetUploadLoading?.(false);\n\t\tsetRecordedChunks([]);\n\t\trecordedFpsRef.current = null;\n\t\tsetLoadingCam(true);\n\t\tsetRecordingStarted(false);\n\t\tsetFaceDone(false);\n\t\tsetMediaRecorderStopped(true);\n\t\tsetIsScanning(false);\n\t\tcaptureVideoTimeOutHandle.current = null;\n\t\tsetAudioSource(\"\");\n\t\tsetAudioSourceList([]);\n\t\tsetEmptyAudioSource(\"\");\n\t\tsetStartAgain(!startAgain);\n\t\tsetStartGyro(false);\n\t\tspeechService.stopAudio();\n\t\tsetRestart(false);\n\t\tsetPause(false);\n\t\tcounterRef.current = 0;\n\t\tconsecutiveFalseRef.current = 0;\n\t\tposeListenerRegistered.current = false;\n\t\tbrilliantPlayedRef.current = false;\n\t\tif (mediaRecorderRef.current !== null) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\n\t\tevents.forEach((el: any) => {\n\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.removeEventListener(\"dataavailable\", el);\n\t\t});\n\n\t\tsetEvents([]);\n\t\tallowAudioToPlay.current = true;\n\t\tsetShowPause(false);\n\t\tsetIsVideoUploaded(false);\n\t\tif (webcamRef.current?.stream) {\n\t\t\tsetLoadingCam(false);\n\t\t}\n\t};\n\n\tconst handleUserMedia = useCallback(() => {\n\t\tsetTimeout(() => {\n\t\t\tsetLoadingCam(false);\n\t\t}, 1000);\n\t}, []);\n\n\tconst handleUserMediaError = useCallback(\n\t\t(error: string | DOMException) => {\n\t\t\tconsole.log(\"camera error\", error);\n\t\t\t// Retry once with relaxed constraints for broader device compatibility.\n\t\t\tif (currentVideoConstraints === videoConstraintsExact) {\n\t\t\t\tsetCurrentVideoConstraints(videoConstraintsFallback);\n\t\t\t\tsetWebcamKey((prev) => prev + 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetLoadingCam(false);\n\t\t},\n\t\t[currentVideoConstraints],\n\t);\n\n\tconst handlePause = useCallback(() => {\n\t\tallowAudioToPlay.current = false;\n\t\tsetPause(true);\n\t\tsetShowPause(false);\n\t\tif (captureVideoTimeOutHandle.current) clearTimeout(captureVideoTimeOutHandle.current);\n\t\tif (mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.pause();\n\t\t}\n\t\tspeechService.stopAudio();\n\t\tswan.poseDetection.disconnect();\n\t\tcounterRef.current = 0;\n\t\tconsecutiveFalseRef.current = 0;\n\t\tposeListenerRegistered.current = false;\n\t\tbrilliantPlayedRef.current = false;\n\t\tif (mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\t\tevents.forEach((el: any) => {\n\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.removeEventListener(\"dataavailable\", el);\n\t\t});\n\t\tsetEvents([]);\n\t\tclearTimeout(audioTimeoutId);\n\t}, [mediaRecorderRef, events, speechService, allowAudioToPlay]);\n\n\t// const supportedTypes = videoTypes.filter((type) => MediaRecorder.isTypeSupported(type));\n\tconst preferredVideoTypes = useMemo(() => getPreferredMediaRecorderTypes(), []);\n\tconst recordingMimeType = getRecordingMimeType(supportedTypes);\n\tconst recordingExtension = getRecordingExtension(recordingMimeType);\n\n\tconst stopRecording = useCallback(async () => {\n\t\tallowAudioToPlay.current = true;\n\t\tawait speechService.playAudio(`${voiceOverAssetsPath}SpotOn.mp3`);\n\t\tsetPause(false);\n\t\tsetShowPause(false);\n\t\tif (captureVideoTimeOutHandle.current) clearTimeout(captureVideoTimeOutHandle.current);\n\t\tsetRecordingStarted(false);\n\t}, [captureVideoTimeOutHandle, speechService]);\n\n\tconst handleSocket = useCallback(async () => {\n\t\ttry {\n\t\t\tid = await swan.poseDetection.connect();\n console.log(id, \"websocket connected\");\n\n\t\t\tposthog.capture(`${shopDomain}/pose_detection_connected`, {\n\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\temail,\n\t\t\t\tid,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.log(error, \"while connecting websocket\");\n\t\t}\n\t}, [shopDomain, email, swan]);\n\n\tconst handleReScan = useCallback(async () => {\n\t\trescanSupportCaptureEvent({\n\t\t\teventName: `${shopDomain}/rescan`,\n\t\t\temail,\n\t\t\tscanID: scanIDRef.current,\n\t\t\theight: heightInCm,\n\t\t\tgender,\n\t\t\tstatus: false,\n\t\t});\n\t\tallowAudioToPlay.current = false;\n\t\tswan.poseDetection.disconnect();\n\t\tresetScan();\n\t\tawait handleSocket();\n\t\tstartSendingVideoFramesRef.current();\n\t}, [handleSocket, email, shopDomain, heightInCm, gender]);\n\n\tconst handleSpinDataAvailable = useCallback(\n\t\t({ data }: BlobEvent) => {\n\t\t\tif (data && data.size > 0 && allowAudioToPlay.current) {\n\t\t\t\tsetRecordedChunks((prev) => prev.concat(data));\n\t\t\t\tif (!poseStoppedRef.current && webcamRef.current) {\n\t\t\t\t\tposeStoppedRef.current = true;\n\t\t\t\t\tposeDetector(() => {\n\t\t\t\t\t\tstopRecording();\n\t\t\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\t\t\teventName: `${shopDomain}/tensorFlow`,\n\t\t\t\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\tmessage: \"recording stopped by tensorflow \",\n\t\t\t\t\t\t});\n\t\t\t\t\t}, webcamRef);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[stopRecording, handleScanTimeCapture, shopDomain, email, webcamRef],\n\t);\n\n\tconst playAudio = useCallback(async () => {\n\t\tif (audioSourceList.length > 0 && allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(voiceOverAssetsPath + audioSourceList[audioSourceList.length - 1]);\n\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\taudioTimeoutId = setTimeout(playAudio, 2000);\n\t\t\t}\n\t\t}\n\t}, [audioSourceList, allowAudioToPlay]);\n\n\t\tconst handleStartCaptureClick = useCallback(() => {\n\t\tif (mediaRecorderRef && mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\t\tsetRecordingStarted(true);\n\t\ttry {\n\t\t\tif (webcamRef && webcamRef.current && webcamRef.current.stream) {\n\t\t\t\t// Capture FPS from stream settings\n\t\t\t\tconst videoTrack = webcamRef.current.stream.getVideoTracks()[0];\n\t\t\t\tif (videoTrack) {\n\t\t\t\t\tconst settings = videoTrack.getSettings();\n\t\t\t\t\trecordedFpsRef.current = settings.frameRate || null;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst mediaRecorderOptions: MediaRecorderOptions = {\n\t\t\t\t\tvideoBitsPerSecond: 1_500_000,\n\t\t\t\t};\n\t\t\t\tif (supportedTypes[0]) {\n\t\t\t\t\tmediaRecorderOptions.mimeType = supportedTypes[0];\n\t\t\t\t}\n\t\t\t\tmediaRecorderRef.current = new MediaRecorder(webcamRef.current.stream, mediaRecorderOptions);\n\t\t\t\tmediaRecorderRef.current.addEventListener(\"dataavailable\", handleSpinDataAvailable);\n\n\t\t\t\tsetEvents([...events, handleSpinDataAvailable]);\n\t\t\t\tmediaRecorderRef.current.start(1000);\n\t\t\t\tsetMediaRecorderStopped(false);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.log(\"error while using media recorder\", e);\n\t\t}\n\t}, [webcamRef, supportedTypes, handleSpinDataAvailable, events]);\n\n\tconst postPoseProcess = useCallback(async () => {\n\t\tif (captureVideoTimeOutHandle.current) {\n\t\t\tclearTimeout(captureVideoTimeOutHandle.current);\n\t\t}\n\t\thandleStartCaptureClick();\n\t\tif (allowAudioToPlay.current) {\n\t\t\tcaptureVideoTimeOutHandle.current = setTimeout(async () => {\n\t\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}SpotOn.mp3`);\n\t\t\t\t\tsetRecordingStarted(false);\n\t\t\t\t}\n\t\t\t}, 15000);\n\t\t}\n\t\tsetFaceDone(true);\n\t\tif (allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}Spin.mp3`);\n\t\t}\n\t}, [handleStartCaptureClick, allowAudioToPlay, speechService]);\n\n\tuseEffect(() => {\n\t\tpostPoseProcessRef.current = postPoseProcess;\n\t}, [postPoseProcess]);\n\n\tconst handleDataAvailable = useCallback(\n\t\t({ data }: BlobEvent) => {\n\t\t\tif (data.size > 0 && swan.poseDetection.connected()) {\n\t\t\t\tif (!poseListenerRegistered.current) {\n\t\t\t\t\tposeListenerRegistered.current = true;\n\t\t\t\t\tswan.poseDetection.poseStatus(async (data: any) => {\n\t\t\t\t\t\tconsole.log(\"poseStatus data:\", data); \n\t\t\t\t\t\tif (data && data.audio && data.audio.length > 0) {\n\t\t\t\t\t\t\tposthog.capture(`${shopDomain}/pose_instruction_received`, {\n\t\t\t\t\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\t\t\t\t\temail,\n\t\t\t\t\t\t\t\taudio: data.audio,\n\t\t\t\t\t\t\t\tstatus: data.status,\n\t\t\t\t\t\t\t\tsid: data.sid,\n\t\t\t\t\t\t\t\tcounter: counterRef.current,\n\t\t\t\t\t\t\t\tconsecutiveFalse: consecutiveFalseRef.current,\n\t\t\t\t\t\t\t\ttype:\"body_scan_instruction\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst audio = document.querySelector(\"#audioElement\") as HTMLAudioElement | null;\n\t\t\t\t\t\t\tif (data.status === true && data.sid === id) {\n\t\t\t\t\t\t\t\tconsecutiveFalseRef.current = 0;\n\t\t\t\t\t\t\t\tif (counterRef.current < 2) {\n\t\t\t\t\t\t\t\t\tcounterRef.current += 1;\n\t\t\t\t\t\t\t\t\tif (counterRef.current === 1 && !brilliantPlayedRef.current) {\n\t\t\t\t\t\t\t\t\t\tbrilliantPlayedRef.current = true;\n\t\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\t\tspeechService.stopAudio();\n\t\t\t\t\t\t\t\t\t\tawait speechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t} else if (counterRef.current === 2 && audio?.paused) {\n\t\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsetEmptyAudioSource(data.audio);\n\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\tswan.poseDetection.disconnect();\n\t\t\t\t\t\t\t\t\tposeListenerRegistered.current = false;\n\t\t\t\t\t\t\t\t\tsetTimeout(() => postPoseProcessRef.current(), 1000);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconsecutiveFalseRef.current += 1;\n\t\t\t\t\t\t\t\tif (consecutiveFalseRef.current >= 3) {\n\t\t\t\t\t\t\t\t\tcounterRef.current = 0;\n\t\t\t\t\t\t\t\t\tbrilliantPlayedRef.current = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (audio?.paused && (!lastVideoPlayed || lastVideoPlayed?.audioName !== data.audio)) {\n\t\t\t\t\t\t\t\t\tlastVideoPlayed = {\n\t\t\t\t\t\t\t\t\t\tskipCount: 2,\n\t\t\t\t\t\t\t\t\t\tno_of_times_skipped: 0,\n\t\t\t\t\t\t\t\t\t\taudioName: data.audio,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t} else if (lastVideoPlayed?.audioName === data.audio && audio?.paused) {\n\t\t\t\t\t\t\t\t\tif (lastVideoPlayed && lastVideoPlayed.no_of_times_skipped >= lastVideoPlayed.skipCount) {\n\t\t\t\t\t\t\t\t\t\tlastVideoPlayed.no_of_times_skipped = 0;\n\t\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tif (lastVideoPlayed) lastVideoPlayed.no_of_times_skipped += 1;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (webcamRef?.current && webcamRef.current.getScreenshot() !== null) {\n\t\t\t\t\tswan.poseDetection.videoEmit({\n\t\t\t\t\t\timage: webcamRef.current.getScreenshot() || \"\",\n\t\t\t\t\t\tscanId: scanIDRef.current,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[webcamRef, swan, speechService, shopDomain, email],\n\t);\n\n\tconst startSendingVideoFrames = useCallback(async () => {\n\t\tsetIsScanning(true);\n\t\tsetStartGyro(true);\n\t\tonScanStart?.();\n\t\tif (firstScan.current) {\n\t\t\tfirstScan.current = false;\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: \"scan started\",\n\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t}\n\t\tsetScanStartTime(getCurrentTimeInSeconds());\n\t\tsetLoadingCam(true);\n\t\tif (allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}StartScan.mp3`);\n\t\t}\n\t\tif (allowAudioToPlay.current) {\n\t\t\tawait speechService.playAudio(`${voiceOverAssetsPath}LiftArmsAndHoldAtHip.mp3`);\n\t\t}\n\t\tif (allowAudioToPlay.current) {\n\t\t\tsetIsScanning(false);\n\t\t\tsetRecordingStarted(true);\n\t\t\tsetRestart(true);\n\t\t\tsetShowPause(true);\n\t\t\thandleUserMedia();\n\t\t}\n\t\ttry {\n\t\t\tif (webcamRef && webcamRef.current && webcamRef.current.stream && allowAudioToPlay.current) {\n\t\t\t\t// Capture FPS from stream settings\n\t\t\t\tconst videoTrack = webcamRef.current.stream.getVideoTracks()[0];\n\t\t\t\tif (videoTrack) {\n\t\t\t\t\tconst settings = videoTrack.getSettings();\n\t\t\t\t\trecordedFpsRef.current = settings.frameRate || null;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst mediaRecorderOptions: MediaRecorderOptions = {\n\t\t\t\t\tvideoBitsPerSecond: 1_500_000,\n\t\t\t\t};\n\t\t\t\tif (supportedTypes[0]) {\n\t\t\t\t\tmediaRecorderOptions.mimeType = supportedTypes[0];\n\t\t\t\t}\n\t\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\t\tmediaRecorderRef.current = new MediaRecorder(webcamRef.current.stream, mediaRecorderOptions);\n\t\t\t\t}\n\t\t\t\tif (allowAudioToPlay.current && mediaRecorderRef.current) {\n\t\t\t\t\tmediaRecorderRef.current.addEventListener(\"dataavailable\", handleDataAvailable);\n\t\t\t\t}\n\n\t\t\t\tsetEvents([...eventsRef.current, handleDataAvailable]);\n\t\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.start(1000);\n\t\t\t\tsetMediaRecorderStopped(false);\n\t\t\t\tif (allowAudioToPlay.current) {\n\t\t\t\t\taudioTimeoutId = setTimeout(playAudio, 2000);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconsole.log(\"error ----------\", err);\n\t\t}\n\t}, [webcamRef, supportedTypes, handleDataAvailable, playAudio, allowAudioToPlay, onScanStart]);\n\n\tuseEffect(() => { startSendingVideoFramesRef.current = startSendingVideoFrames; }, [startSendingVideoFrames]);\n\n\tuseEffect(() => {\n\t\tif (shopDomain) {\n\t\t\tsetIsScanLocked(true);\n\t\t\thandleSocket();\n\t\t}\n\t\treturn () => {\n\t\t\tif (id) {\n\t\t\t\tswan.poseDetection.disconnect();\n\t\t\t\tposthog.capture(`${shopDomain}/pose_detection_disconnected`, {\n\t\t\t\t\tscanID: scanIDRef.current,\n\t\t\t\t\temail,\n\t\t\t\t\tid,\n\t\t\t\t});\n\t\t\t}\n\t\t\tevents.forEach((el: any) => {\n\t\t\t\tmediaRecorderRef?.current?.removeEventListener(\"dataavailable\", el);\n\t\t\t});\n\t\t};\n\t}, [shopDomain]);\n\tuseEffect(() => {\n\t\taudioSourceList.push(audioSource);\n\t}, [audioSource]);\n\n\tuseEffect(() => {\n\t\tsetAudioSourceList([]);\n\t}, [emptyAudioSource]);\n\tuseEffect(() => {\n\t\tconst bypassChecksToBackup = recordedChunks.length && recordedChunks.length > 0;\n\t\tif (!mediaRecorderStopped && bypassChecksToBackup && !recordingStarted && allowAudioToPlay.current && !pause) {\n\t\t\tif (mediaRecorderRef && mediaRecorderRef.current) {\n\t\t\t\tif (!recordingStarted) {\n\t\t\t\t\tmediaRecorderRef.current.stop();\n\t\t\t\t\tsetMediaRecorderStopped(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [mediaRecorderStopped, recordingStarted, recordedChunks, pause]);\n\n\tuseEffect(() => {\n\t\tconst bypassChecksToBackup = recordedChunks.length && recordedChunks.length > 0;\n\t\tif (!mediaRecorderStopped && bypassChecksToBackup && !recordingStarted) {\n\t\t\tif (mediaRecorderRef && mediaRecorderRef.current && allowAudioToPlay.current && !pause) {\n\t\t\t\tif (!recordingStarted) {\n\t\t\t\t\tconst videoFile = new File(recordedChunks, `${scanID}.${recordingExtension}`, {\n\t\t\t\t\t\ttype: recordingMimeType,\n\t\t\t\t\t});\n\t\t\t\t\tonCaptureComplete?.();\n\t\t\t\t\tsetUploadLoading?.(true);\n\t\t\t\t\tsetScanFailsError(\"\");\n\t\t\t\t\t// Pass FPS captured at recording time\n\t\t\t\t\tuploadScanFile?.(videoFile, recordedFpsRef.current);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(\"No video found to upload.\");\n\t\t}\n\t}, [mediaRecorderStopped, recordingStarted, recordedChunks, pause, mediaRecorderRef, allowAudioToPlay]);\n\tuseEffect(() => {\n\t\tconst supported = getSupportedMediaRecorderTypes(preferredVideoTypes, videoTypes);\n\t\tsetSupportedTypes(supported);\n\t}, [preferredVideoTypes]);\n\tuseEffect(() => {\n\t\tresetScan();\n\t}, []);\n\n\treturn (\n\t\t<CameraScanChild\n\t\t\tresetDetector={resetDetector}\n\t\t\tresetScan={resetScan}\n\t\t\tloadingCam={loadingCam}\n\t\t\tonPause={handlePause}\n\t\t\tshowRestart={showRestart}\n\t\t\tpause={pause}\n\t\t\tonReScan={handleReScan}\n\t\t\trecordingStarted={recordingStarted}\n\t\t\tisScanning={isScanning}\n\t\t\tstartSendingVideoFrames={startSendingVideoFrames}\n\t\t\tfaceDone={faceDone}\n\t\t\tstopRecording={stopRecording}\n\t\t\tshowPause={showPause}\n\t\t\twebcamRef={webcamRef}\n\t\t\tonUserMedia={handleUserMedia}\n\t\t\tonUserMediaError={handleUserMediaError}\n\t\t\tvideoConstraints={currentVideoConstraints}\n\t\t\twebcamKey={webcamKey}\n\t\t\t/>\n\t);\n}\n\nexport default React.memo(ScanningComponent);\n","/* eslint-disable no-use-before-define */\n\nimport { useEffect, useState, useRef } from \"react\";\nimport { IOSDeviceOrientationEvent } from \"../../customHooks/useGyroSensor\";\nimport LevelScreen from \"./LevelScreen\";\nimport ScanningComponent from \"./ScanningComponent\";\nimport { AngleDetectorProps } from \"../../types/interfaces\";\n\nexport default function AngleDetector({\n scanID,\n userDetails,\n setIsVideoUploaded,\n setScanFailsError,\n setScanStartTime,\n setScanUniqueKey,\n}: Omit<AngleDetectorProps, \"config\">) {\n const [angle, setAngle] = useState(90);\n const [calibrationOffset, setCalibrationOffset] = useState(0);\n const [countdown, setCountdown] = useState<number | null>(null);\n const [isScanning, setIsScanning] = useState(false);\n const [stabilityScore, setStabilityScore] = useState(0);\n const lastAnglesRef = useRef<number[]>([]);\n const [isScanLocked, setIsScanLocked] = useState(false);\n const calibratedAngle = angle - calibrationOffset;\n const isInTargetRange = calibratedAngle >= 80 && calibratedAngle <= 95;\n\n const resetDetector = () => {\n setAngle(90);\n setCalibrationOffset(0);\n setCountdown(null);\n setIsScanning(false);\n setStabilityScore(0);\n setIsScanLocked(false);\n lastAnglesRef.current = [];\n };\n\n useEffect(() => {\n if (typeof window !== \"undefined\" && window.DeviceOrientationEvent) {\n const handleOrientation = (event: DeviceOrientationEvent) => {\n if (event.beta !== null) {\n let newAngle = Math.abs(event.beta);\n if (event.gamma !== null) {\n newAngle *= Math.cos((event.gamma * Math.PI) / 180);\n }\n newAngle = Math.max(0, Math.min(180, newAngle));\n setAngle(newAngle);\n }\n };\n\n const requestPermission = async () => {\n const DeviceOrientation =\n DeviceOrientationEvent as unknown as IOSDeviceOrientationEvent;\n\n if (\n DeviceOrientation &&\n typeof DeviceOrientation.requestPermission === \"function\"\n ) {\n try {\n const permission = await DeviceOrientation.requestPermission();\n if (permission === \"granted\") {\n // wrappedHandler = timeout(handleOrientation, 2000);\n window.addEventListener(\"deviceorientation\", handleOrientation);\n }\n } catch (e) {\n console.error(\"Permission error\", e);\n }\n } else {\n // wrappedHandler = handleOrientation;\n window.addEventListener(\"deviceorientation\", handleOrientation);\n }\n\n return () => {\n if (handleOrientation) {\n window.removeEventListener(\"deviceorientation\", handleOrientation);\n }\n };\n };\n\n document.addEventListener(\"click\", requestPermission, { once: true });\n }\n }, []);\n\n useEffect(() => {\n lastAnglesRef.current = [\n ...lastAnglesRef.current.slice(-4),\n calibratedAngle,\n ];\n\n if (lastAnglesRef.current.length >= 5) {\n const variation =\n Math.max(...lastAnglesRef.current) - Math.min(...lastAnglesRef.current);\n if (isInTargetRange && variation < 2) {\n setStabilityScore((prev) => Math.min(100, prev + 10));\n } else {\n setStabilityScore((prev) => Math.max(0, prev - 20));\n }\n }\n\n if (!isInTargetRange && (countdown !== null || isScanning)) {\n resetCountdown();\n }\n }, [calibratedAngle, isInTargetRange, countdown, isScanning]);\n\n\tuseEffect(() => {\n\t\tif (stabilityScore >= 100 && countdown === null && !isScanning ) {\n\t\t\tstartCountdown();\n\t\t}\n\t\tif (stabilityScore < 50 && countdown !== null) {\n\t\t\tresetCountdown();\n\t\t}\n\t}, [stabilityScore, countdown, isScanning]);\n\n const startCountdown = () => {\n setCountdown(3);\n const timer = setInterval(() => {\n setCountdown((prev) => {\n if (prev === null || prev <= 1) {\n clearInterval(timer);\n setIsScanning(true);\n return null;\n }\n return prev - 1;\n });\n }, 1000);\n };\n\n const resetCountdown = () => {\n setCountdown(null);\n if (!isScanLocked) {\n setIsScanning(false);\n }\n };\n\n\n return (\n // <LevelScreen\n // angle={calibratedAngle}\n // countdown={countdown}\n // isScanning={isScanning}\n // isInTargetRange={isInTargetRange}\n // stabilityScore={stabilityScore}\n // >\n // {isScanning && (\n // <ScanningComponent\n // setIsScanLocked={setIsScanLocked}\n // resetDetector={resetDetector}\n // scanID={scanID}\n // userDetails={userDetails}\n // setIsVideoUploaded={setIsVideoUploaded}\n // setScanFailsError={setScanFailsError}\n // setScanStartTime={setScanStartTime}\n // setScanUniqueKey={setScanUniqueKey}\n // />\n // )}\n // </LevelScreen>\n <ScanningComponent\n setIsScanLocked={setIsScanLocked}\n resetDetector={resetDetector}\n scanID={scanID}\n userDetails={userDetails}\n setIsVideoUploaded={setIsVideoUploaded}\n setScanFailsError={setScanFailsError}\n setScanStartTime={setScanStartTime}\n setScanUniqueKey={setScanUniqueKey}\n />\n );\n}\n","import { useContext } from \"react\";\nimport {Dialog} from \"@mui/material\";\nimport { getBrowserName } from \"../utils/utils\";\nimport { LanguageContext } from \"../utils/context/languageContext\";\nimport { LanguageKeys } from \"../utils/languageKeys\";\nimport { Config } from \"../types/interfaces\";\n\nfunction Modal({ message, config }: { message?: string; config?: Config }) {\n const { translate } = useContext(LanguageContext) || {};\n\n\n\n return (\n <Dialog open className=\"confirm-modal common-ui-main\">\n <div className=\"modal-main\">\n <div className=\"text-center\">\n {message ? (\n <>\n <h2\n style={{\n fontFamily:\n config?.style?.heading?.headingFontFamily ||\n \"SeriouslyNostalgic Fn\",\n fontSize: config?.style?.heading?.headingFontSize || \"32px\",\n color: config?.style?.heading?.headingColor || \"#000\",\n fontWeight:\n config?.style?.heading?.headingFontWeight || \"normal\",\n }}\n >\n {translate?.(LanguageKeys.cameraAlreadyInUse)}\n </h2>\n <p\n className=\"mt-[0.5rem] text-sm\"\n style={{\n fontFamily:\n config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n fontSize: config?.style?.base?.baseFontSize || \"16px\",\n color: config?.style?.base?.baseTextColor || \"#000\",\n }}\n >\n {translate?.(LanguageKeys.tryClosingBrowser)}\n </p>\n </>\n ) : (\n <>\n <h2\n style={{\n fontFamily:\n config?.style?.heading?.headingFontFamily ||\n \"SeriouslyNostalgic Fn\",\n fontSize: config?.style?.heading?.headingFontSize || \"32px\",\n color: config?.style?.heading?.headingColor || \"#000\",\n fontWeight:\n config?.style?.heading?.headingFontWeight || \"normal\",\n }}\n >\n {translate?.(LanguageKeys.checkCameraSettings)}\n </h2>\n <p\n className=\"mt-[0.5rem] text-sm\"\n style={{\n fontFamily:\n config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n fontSize: config?.style?.base?.baseFontSize || \"16px\",\n color: config?.style?.base?.baseTextColor || \"#000\",\n }}\n >{`${translate?.(\n LanguageKeys.setting\n )} > ${getBrowserName()} > ${translate?.(\n LanguageKeys.enableCameraPermissions\n )}`}</p>\n </>\n )}\n </div>\n </div>\n </Dialog>\n );\n}\n\nexport default Modal;\n","import { useEffect, useState, useRef, useCallback, Dispatch, SetStateAction } from \"react\";\nimport Webcam from \"react-webcam\";\nimport Modal from \"../Modal\";\nimport LoadingScreen from \"../LoadingScreen\";\nimport { checkCameraPermission } from \"../../utils/utils\";\nimport { videoConstraints } from \"../../utils/constants\";\n\n\nfunction CameraPermission({ setShowDrawer, config,loader }: { setShowDrawer?: Dispatch<SetStateAction<boolean>>; config?: any,loader?:string }) {\n\tconst [showDeniedModal, setShowDeniedModal] = useState({\n\t\tdisabled: false,\n\t\tmessage: \"\",\n\t});\n\tconst [loading, setLoading] = useState(true);\n\tconst webcamRef = useRef(null);\n\n\tconst handleCameraPermission = useCallback(async () => {\n\t\tconst permission = await checkCameraPermission();\n\t\tsetShowDeniedModal(permission);\n\t\tsetLoading(false);\n\t}, []);\n\n\tuseEffect(() => {\n\t\thandleCameraPermission();\n\t}, []);\n\n\tif (loading) {\n\t\treturn <LoadingScreen url={loader} loaderType=\"black\" />\n\t}\n\n\tif (showDeniedModal?.disabled) {\n\t\treturn <Modal config={config} message={showDeniedModal?.message} />;\n\t}\n\treturn (\n\t\t<Webcam\n\t\t\taudio={false}\n\t\t\tref={webcamRef}\n\t\t\tscreenshotQuality={1}\n\t\t\tvideoConstraints={videoConstraints}\n\t\t\tmirrored\n\t\t\tonUserMedia={() => setShowDrawer?.(true)}\n\t\t\tscreenshotFormat=\"image/jpeg\"\n\t\t\tstyle={{\n\t\t\t\tposition: \"relative\",\n\t\t\t\ttop: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tzIndex: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100%\",\n\t\t\t\tobjectFit: \"cover\",\n\t\t\t}}\n\t\t/>\n\t);\n}\n\nexport default CameraPermission;\n","\nimport React, { useEffect, useRef } from \"react\";\nimport videojs from \"video.js\";\nimport type Player from \"video.js/dist/types/player\";\nimport { videoPoster } from \"../../utils/constants\";\n\nfunction VideoPlayer({ link, onReady, wrapperClassName = \"[&_video]:rounded-t-[20px] w-full h-full\" }: { link?: string; wrapperClassName?: string; onReady?: (args: Player) => void }) {\n\tconst videoReference = useRef<HTMLVideoElement | null>(null);\n\tconst playerReference = useRef<Player | null>(null);\n\n\tlet videoJsOptions: any = {\n\t\tautoplay: true,\n\t\tcontrols: false,\n\t\tresponsive: true,\n\t\tfluid: true,\n\t\tmuted: true,\n\t\tnavigationUI: \"hide\",\n\t\tpreload: \"metadata\",\n\t\tposter: videoPoster,\n\t};\n\n\tuseEffect(() => {\n\t\tif (!playerReference.current && link && videoReference?.current) {\n\t\t\tconst player = videojs(videoReference.current, {\n\t\t\t\t...videoJsOptions,\n\t\t\t});\n\t\t\tplayer.ready(() => {\n\t\t\t\tplayerReference.current = player;\n\n\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t...videoJsOptions,\n\t\t\t\t\tsources: [{ src: link, type: \"application/x-mpegURL\" }],\n\t\t\t\t};\n\n\t\t\t\tplayer.autoplay(updatedOptions.autoplay);\n\t\t\t\tplayer.src(updatedOptions.sources);\n\n\t\t\t\tonReady?.(player);\n\t\t\t});\n\t\t}\n\t}, [link, videoReference]);\n\n\tuseEffect(() => {\n\t\tconst player = playerReference.current;\n\t\treturn () => {\n\t\t\tif (player && !player.isDisposed()) {\n\t\t\t\tplayer.dispose();\n\t\t\t\tplayerReference.current = null;\n\t\t\t}\n\t\t};\n\t}, [playerReference]);\n\n\treturn (\n\t\t<div className={wrapperClassName}>\n\t\t\t<video ref={videoReference} muted className=\"video-js\" playsInline onDrag={(e) => e.preventDefault()} />\n\t\t</div>\n\t);\n}\nexport default VideoPlayer;\n","import { useContext, useState } from \"react\";\nimport {Dialog} from \"@mui/material\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport Header from \"../Header\";\nimport VideoPlayer from \"./VideoPlayer\";\nimport { ScanErrorMessageProps } from \"../../types/interfaces\";\nimport { generateUuid, handleErrorMessage } from \"../../utils/utils\";\nimport { GENDER, VIDEO_POSTER_GENDER_BASED } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { X } from \"lucide-react\";\nimport { useConfig } from \"../../utils/context/configContext\";\n\nfunction ScanErrorMessage({ scanFailsError, onNext, gender, setScanUniqueKey, setIsVideoUploaded }: ScanErrorMessageProps) {\n\tconst { translate } = useContext(LanguageContext) || {};\n\tconst resolvedConfig = useConfig();\n\tconst [showModal, setShowModal] = useState(false);\n\n\tconst handleBtnClick = () => {\n\t\tif (onNext) {\n\t\t\tonNext?.();\n\t\t} else {\n\t\t\tsetScanUniqueKey?.(generateUuid());\n\t\t}\n\t\tsetIsVideoUploaded?.(false);\n\t};\n\n\tconst handleShowModal = () => {\n\t\tsetShowModal(!showModal);\n\t};\n\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"flex common-ui-main flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto\" style={{ background: resolvedConfig?.style?.base?.backgroundColor }}>\n\t\t\t\t<div className=\"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]\">\n\t\t\t\t\t<Header noTitle />\n\t\t\t\t</div>\n\t\t\t\t<div className=\"flex-1\">\n\t\t\t\t\t{scanFailsError && (\n\t\t\t\t\t\t<div className=\"px-[1rem]\">\n\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\tclassName=\"text-center\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.heading?.headingFontFamily || \"SeriouslyNostalgic Fn\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.heading?.headingFontSize || \"32px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.heading?.headingColor || \"#000\",\n\t\t\t\t\t\t\t\t\tfontWeight: resolvedConfig?.style?.heading?.headingFontWeight || \"normal\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.issueWithScan)}\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.reason)}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{handleErrorMessage(scanFailsError)}\n\t\t\t\t\t\t\t</p>\n\n\t\t\t\t\t\t\t<img className=\"my-[0.5rem] aspect-[2/1.4] w-full object-cover\" onClick={handleShowModal} src={VIDEO_POSTER_GENDER_BASED[gender]} alt=\"icon\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{scanFailsError && (\n\t\t\t\t\t<div className=\"p-[1rem] flex gap-[0.5rem]\">\n\t\t\t\t\t\t<SpecificButton disabled={false} buttonText={translate?.(LanguageKeys.scanAgain)} className=\"!shadow-none\" buttonFunc={handleBtnClick} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t{showModal && (\n\t\t\t\t<Dialog className=\"w-screen h-screen video-modal\" onClose={handleShowModal} open={showModal}>\n\t\t\t\t\t<div className=\"flex justifyEnd \">\n\t\t\t\t\t\t<span className=\"closeBtn\" onClick={handleShowModal}>\n\t\t\t\t\t\t\t<X className=\"absolute right-[8px] top-[8px] text-white z-[9]\" />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"aspect-video object-cover rounded-[20px] \">\n\t\t\t\t\t\t<VideoPlayer link={gender ? GENDER[gender].PRE_LINK : GENDER.male.PRE_LINK} wrapperClassName=\"w-screen h-screen fixed top-[0] left-[0]\" />\n\t\t\t\t\t</div>\n\t\t\t\t</Dialog>\n\t\t\t)}\n\t\t</>\n\t);\n}\n\nexport default ScanErrorMessage;\n","import { useCallback, useContext, useEffect, useState } from \"react\";\nimport {Box,Drawer} from \"@mui/material\";\nimport posthog from \"../utils/posthog\";\nimport Header from \"./Header\";\nimport CameraPermission from \"./bodyScan/CameraPermission\";\nimport { SignUpProps } from \"../types/interfaces\";\nimport { CLOTHING_BANNER_SCAN, CLOTHING_CUSTOM_FIT_SCAN, CLOTHING_CUSTOM_SCAN, maleMeasurementProgress, measurementProgress } from \"../utils/constants\";\nimport { GenderType } from \"../utils/enums\";\nimport SpecificButton from \"../atoms/specificButton/SpecificButton\";\nimport { LanguageContext } from \"../utils/context/languageContext\";\nimport { LanguageKeys } from \"../utils/languageKeys\";\n\nfunction SignUp({\n\tscanId,\n\tuserDetails,\n\tconfig,\n\tisVideoUploadedCorrect,\n\tisMeasurementAvailable,\n\tonComplete,\n\tisSuccess,\n\tonCustomScanSuccess,\n\tswan,\n}: SignUpProps) {\n\tconst { gender, shopDomain, heightInCm, deviceFocalLength, userName, email, scanType } = userDetails || {};\n\tconst isCustom = [CLOTHING_CUSTOM_SCAN, CLOTHING_BANNER_SCAN, CLOTHING_CUSTOM_FIT_SCAN].includes(scanType ?? \"\");\n\tconst [showDrawer, setShowDrawer] = useState(true);\n\tconst handlePostHogEvent = () => {\n\t\tposthog.capture(shopDomain??\"\", {\n\t\t\tscanID: scanId,\n\t\t\temail: email,\n\t\t\theight: heightInCm,\n\t\t\tfocalLength: deviceFocalLength,\n\t\t\tclothesFit: \"0\",\n\t\t\tgender: gender,\n\t\t});\n\t};\n\n\tconst handleSignUp = useCallback(async () => {\n\t\ttry {\n\t\t\tif (isCustom) {\n\t\t\t\tawait swan?.auth.addUser({\n\t\t\t\t\tscanId,\n\t\t\t\t\temail,\n\t\t\t\t\tname: userName,\n\t\t\t\t\tgender,\n\t\t\t\t\theight: heightInCm,\n\t\t\t\t});\n\t\t\t\tonCustomScanSuccess?.();\n\t\t\t}\n\t\t\thandlePostHogEvent();\n\t\t} catch (error) {\n\t\t\tconsole.log(error);\n\t\t}\n\t}, [isCustom]);\n\n\tconst { translate } = useContext(LanguageContext) || {};\n\n\tuseEffect(() => {\n\t\tif (isVideoUploadedCorrect || isMeasurementAvailable) {\n\t\t\thandleSignUp();\n\t\t}\n\t}, [isVideoUploadedCorrect, isMeasurementAvailable]);\n\n\tconst showNextButton = isSuccess || isVideoUploadedCorrect || isMeasurementAvailable;\n\n\treturn (\n\t\t<Box className=\"flex h-full w-full flex-col common-ui-main\">\n\t\t\t<div className=\"h-full w-full flex-col items-center justify-center flex\">\n\t\t\t\t<CameraPermission loader={config?.loader} setShowDrawer={setShowDrawer} />\n\t\t\t\t<Drawer\n\t\t\t\t\topen={showDrawer}\n\t\t\t\t\tonClose={(_, reason) => {\n\t\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\t\tanchor=\"bottom\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]\"\n\t\t\t\t\t\tstyle={{ background: config?.style?.base?.backgroundColor }}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"w-full h-full flex flex-col\">\n\t\t\t\t\t\t\t<Header title={translate?.(LanguageKeys.measurementsBeingTaken)} />\n\t\t\t\t\t\t\t<div className=\"flex items-center justify-center flex-1\">\n\t\t\t\t\t\t\t\t<video preload=\"auto\" className=\"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none\" muted loop autoPlay playsInline>\n\t\t\t\t\t\t\t\t\t<source src={gender === GenderType.Male ? maleMeasurementProgress : measurementProgress} type=\"video/mp4\" />\n\t\t\t\t\t\t\t\t</video>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{showNextButton && <SpecificButton className=\"!w-[180px] mx-auto\" buttonText={translate?.(LanguageKeys.next)} buttonFunc={()=>{onComplete?.()\n\t\t\t\t\t\t\t}} />}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</Drawer>\n\t\t\t</div>\n\t\t</Box>\n\t);\n}\nexport default SignUp;\n","\"use client\";\nimport { useContext } from \"react\";\nimport AngleDetector from \"./AngleDetector\";\nimport CameraPermission from \"./CameraPermission\";\nimport Modal from \"../Modal\";\nimport { Drawer } from \"@mui/material\";\nimport ScanErrorMessage from \"./ScanErrorMessage\";\nimport LoadingScreen from \"../LoadingScreen\";\nimport SignUp from \"../Signup\";\nimport { useConfig } from \"../../utils/context/configContext\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\n\nexport const BodyScanSteps = () => {\n\tconst {\n\t\tuserDetails,\n\t\tonRetry,\n\t\tisError,\n\t\tisSuccess,\n\t\tgender,\n\t\tscanUniqueKey,\n\t\tscanFailsError,\n\t\tsetScanUniqueKey,\n\t\tsetIsVideoUploaded,\n\t\tisMeasurementAvailable,\n\t\tisVideoUploadedCorrect,\n\t\tloading,\n\t\tshowDeniedModal,\n\t\tuploadLoading,\n\t\tsetScanFailsError,\n\t\tsetScanStartTime,\n\t\tresetScan,\n\t\tonCustomScanSuccess,\n\t\tswan,\n\t\tonComplete,\n\t} = useContext(ParamsContext);\n\tconst resolvedConfig = useConfig();\n\n\tif (isError) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<CameraPermission />\n\t\t\t\t<Drawer\n\t\t\t\t\tanchor=\"bottom\"\n\t\t\t\t\topen={true}\n\t\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\t\tonClose={(event, reason) => {\n\t\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<ScanErrorMessage scanFailsError onNext={onRetry} gender={gender} />\n\t\t\t\t</Drawer>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif (isSuccess) {\n\t\treturn <SignUp isSuccess onComplete={onComplete} config={resolvedConfig} />;\n\t}\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div className=\"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full\" style={{ background: resolvedConfig?.style?.base?.backgroundColor }}>\n\t\t\t\t<LoadingScreen url={resolvedConfig?.loader} loaderType=\"black\" />\n\t\t\t</div>\n\t\t);\n\t}\n\tif (showDeniedModal.disabled) {\n\t\treturn <Modal />;\n\t}\n\n\tif (!uploadLoading && !scanFailsError && !isMeasurementAvailable && !isVideoUploadedCorrect) {\n\t\treturn (\n\t\t\t<AngleDetector\n\t\t\t\tscanID={scanUniqueKey}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\tsetScanFailsError={setScanFailsError}\n\t\t\t\tsetScanStartTime={setScanStartTime}\n\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t/>\n\t\t);\n\t}\n\tif ((uploadLoading || isMeasurementAvailable || isVideoUploadedCorrect) && !scanFailsError) {\n\t\treturn (\n\t\t\t<SignUp\n\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\tonCustomScanSuccess={onCustomScanSuccess}\n\t\t\t\tswan={swan}\n\t\t\t\tonComplete={onComplete}\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<CameraPermission />\n\t\t\t<Drawer\n\t\t\t\tanchor=\"bottom\"\n\t\t\t\topen\n\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\tonClose={(event, reason) => {\n\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<ScanErrorMessage\n\t\t\t\t\tscanFailsError={scanFailsError}\n\t\t\t\t\tonNext={() => {\n\t\t\t\t\t\tonRetry?.();\n\t\t\t\t\t\tresetScan();\n\t\t\t\t\t}}\n\t\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t\t\tgender={gender}\n\t\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\t/>\n\t\t\t</Drawer>\n\t\t</>\n\t);\n};\n","\"use client\";\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport useGyroSensor from \"../../customHooks/useGyroSensor\";\nimport usePosthogPageview from \"../../customHooks/usePosthogPageview\";\nimport {\n\tcheckCameraPermission,\n\tcreateObjectMetadataArray,\n\tgenerateUuid,\n\tgetCurrentTimeInSeconds,\n\tgetVideoFPS,\n\thandleErrorMessage,\n\thandleScanTimeCapture,\n\thandleWebSocketCapture,\n} from \"../../utils/utils\";\nimport LanguageContextProvider from \"../../utils/context/languageContext\";\nimport { ConfigProvider } from \"../../utils/context/configContext\";\nimport { getSwanService } from \"../../utils/service/swanService\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport MediaContextProvider from \"../../utils/context/mediaContext\";\nimport { BodyScanProps, UserDetails } from \"../../types/interfaces\";\nimport { BodyScanSteps } from \"./BodyScanSteps\";\n\nconst clothesFit = \"0\";\n\nexport const BodyScan: React.FC<BodyScanProps> = (props) => {\n\tconst {\n\t\tconfig,\n\t\tonRetry,\n\t\tonScanStart,\n\t\tonCaptureComplete,\n\t\tonUploadStart,\n\t\tonUploadEnd,\n\t\tonMeasurementSocketStart,\n\t\tonMeasurementSocketClose,\n\t\tonIntermediateScanSuccess,\n\t\tonScanError,\n\t\tonScanSuccess,\n\t\tonCustomScanSuccess,\n\t\tonComplete,\n\t\tisError,\n\t\tisSuccess,\n\t} = props;\n\tconst userDetails: UserDetails = {\n\t\temail: \"\",\n\t\tshopDomain: \"\",\n\t\tgender: \"male\",\n\t\theightInCm: 0,\n\t\tscanType: \"\",\n\t\tdeviceFocalLength: 0,\n\t\tdeviceModelName: \"\",\n\t\tsourceTag: \"\",\n\t\t...(props.userDetails ?? {}),\n\t};\n\tconst token = props.token ?? \"\";\n\tconst { gender, scanType, shopDomain, heightInCm, email, deviceFocalLength, deviceModelName, callbackUrl, sourceTag } = userDetails;\n\tconst swan = useMemo(() => getSwanService(token), [token]);\n\tconst [uploadLoading, setUploadLoading] = useState(false);\n\tconst [isVideoUploadedCorrect, setIsVideoUploadedCorrect] = useState(false);\n\tconst [isMeasurementAvailable, setIsMeasurementAvailable] = useState(false);\n\tconst [showDeniedModal, setShowDeniedModal] = useState({\n\t\tdisabled: false,\n\t\tmessage: \"\",\n\t});\n\tconst [scanFailsError, setScanFailsError] = useState(\"\");\n\tconst [isVideoUploaded, setIsVideoUploaded] = useState(false);\n\tconst [loading, setLoading] = useState(true);\n\tconst [startGyro, setStartGyro] = useState(false);\n\tconst [scanUniqueKey, setScanUniqueKey] = useState(\"\");\n\tconst [scanStartTime, setScanStartTime] = useState<number | null>(getCurrentTimeInSeconds());\n\tconst { gyroData } = useGyroSensor(startGyro);\n\tusePosthogPageview();\n\n\tconst resetScan = useCallback(() => {\n\t\tsetScanUniqueKey(generateUuid());\n\t\tsetScanFailsError(\"\");\n\t\tsetUploadLoading(false);\n\t\tsetIsVideoUploaded(false);\n\t}, []);\n\n\tconst onError = (data: any) => {\n\t\tonScanError?.({ ...data, message: handleErrorMessage(data) });\n\t\tclearScanStartTimeAndScanId();\n\t\tsetIsMeasurementAvailable(false);\n\t\tsetScanFailsError(data);\n\t\tsetIsVideoUploadedCorrect(false);\n\t\thandleScanTimeCapture({\n\t\t\teventName: `${shopDomain}/measurement_failed/fit-view`,\n\t\t\tscanID: scanUniqueKey,\n\t\t\tstatus: \"failed\",\n\t\t\temail,\n\t\t\tmessage: handleErrorMessage(data),\n\t\t});\n\t\tif (scanStartTime)\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/scan_completion_time`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tcompletionTime: getCurrentTimeInSeconds() - scanStartTime,\n\t\t\t\temail,\n\t\t\t});\n\t};\n\n\tconst clearScanStartTimeAndScanId = () => {\n\t\tsetScanStartTime(null);\n\t\tsetScanUniqueKey(\"\");\n\t};\n\n\tconst onSuccess = useCallback(\n\t\tasync (data: any) => {\n\t\t\tif (data && data?.scanStatus === \"success\" && data?.resultType === \"intermediate\" && data?.code === 200) {\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/measurement_success/intermediate`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tsetIsVideoUploadedCorrect(true);\n\t\t\t\tonIntermediateScanSuccess?.(data);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonScanSuccess?.(data);\n\t\t\tsetIsVideoUploadedCorrect(true);\n\t\t\tclearScanStartTimeAndScanId();\n\t\t\tconst scanIdToSet = scanUniqueKey;\n\t\t\tsetIsMeasurementAvailable(true);\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/measurement_success/fit-view`,\n\t\t\t\tscanID: scanIdToSet,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t\tif (scanStartTime)\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_completion_time`,\n\t\t\t\t\tscanID: scanIdToSet,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\tcompletionTime: getCurrentTimeInSeconds() - scanStartTime,\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t},\n\t\t[scanType, shopDomain, scanUniqueKey],\n\t);\n\n\tconst handleMeasurementRecommendation = (scanId?: string) => {\n\t\tsetIsMeasurementAvailable(false);\n\t\tsetScanFailsError(\"\");\n\t\tsetIsVideoUploadedCorrect(false);\n\t\tswan.measurement.handleMeasurementSocket({\n\t\t\tscanId: scanId || scanUniqueKey,\n\t\t\tonPreopen: () => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"pre_open\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonOpen: () => {\n\t\t\t\tonMeasurementSocketStart?.();\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"open\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonClose: () => {\n\t\t\t\tonMeasurementSocketClose?.();\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"close\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonError: (err) => {\n\t\t\t\tonError(err);\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"error\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonSuccess: (data) => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"success\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tonSuccess(data);\n\t\t\t},\n\t\t});\n\t};\n\n\tconst uploadScanFile = useCallback(\n\t\tasync (file: File, recordedFps?: number | null) => {\n\t\t\tconst fileSizeInMB = Number((file.size / (1024 * 1024)).toFixed(2));\n\t\t\t// Use FPS captured at recording time, fallback to calculation if not available\n\t\t\tconst videoFps = recordedFps !== undefined && recordedFps !== null ? recordedFps : await getVideoFPS(file);\n\t\t\tconst arrayMetaData = createObjectMetadataArray({\n\t\t\t\tgender,\n\t\t\t\tfocal_length: `${deviceFocalLength}`,\n\t\t\t\theight: `${heightInCm}`,\n\t\t\t\tcustomer_store_url: shopDomain,\n\t\t\t\tclothes_fit: clothesFit,\n\t\t\t\tscan_type: scanType,\n\t\t\t\tcallback_url: callbackUrl,\n\t\t\t\tsource_tag: sourceTag,\n\t\t\t});\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/body_scan_meta_data`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\temail,\n\t\t\t\tdata: JSON.stringify([...arrayMetaData, { fileSizeInMB, video_fps: videoFps || 0 }]),\n\t\t\t});\n\t\t\tonUploadStart?.();\n\t\t\ttry {\n\t\t\t\tawait swan.fileUpload.uploadFileFrontend({\n\t\t\t\t\tfile,\n\t\t\t\t\tarrayMetaData,\n\t\t\t\t\tscanId: scanUniqueKey,\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tawait swan.fileUpload.setDeviceInfo({\n\t\t\t\t\tmodel: deviceModelName,\n\t\t\t\t\tdetection: \"manual\",\n\t\t\t\t\tgyro: gyroData,\n\t\t\t\t\tscanId: scanUniqueKey,\n\t\t\t\t});\n\t\t\t\tconsole.log(\"video successfully uploaded\");\n\t\t\t\tsetIsVideoUploaded(false);\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_success`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t\t});\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: \"scan finished\",\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tsetScanStartTime(getCurrentTimeInSeconds());\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tsetIsVideoUploaded(true);\n\t\t\t\t}, 3000);\n\t\t\t} catch (error:any) {\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: \"scan finished\",\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\temail,\n\t\t\t\t\tmessage: handleErrorMessage(error),\n\t\t\t\t});\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_failed`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\temail,\n\t\t\t\t\tmessage: handleErrorMessage(error),\n\t\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t\t});\n\t\t\t\tsetScanFailsError(handleErrorMessage(error));\n\t\t\t\tsetIsVideoUploaded(false);\n\t\t\t\tonScanError?.({...error, message: handleErrorMessage(error) });\n\t\t\t\tclearScanStartTimeAndScanId();\n\t\t\t} finally {\n\t\t\t\tsetStartGyro(false);\n\t\t\t\tonUploadEnd?.();\n\t\t\t}\n\t\t},\n\t\t[scanUniqueKey, gyroData, onUploadStart, onUploadEnd],\n\t);\n\t// const checkMeasurementStatus = useCallback(\n\t// \tasync (scanId: string) => {\n\t// \t\ttry {\n\t// \t\t\tconst res = await swan.measurement.getMeasurementResult(scanId);\n\t// \t\t\tconst isMeasured = res?.data?.isMeasured;\n\t// \t\t\tconst tempScanStartTime = scanStartTime || getCurrentTimeInSeconds();\n\t// \t\t\tconst currentTimeInSeconds = getCurrentTimeInSeconds();\n\t// \t\t\tconst fiveMinutesInSeconds = 5 * 60;\n\t// \t\t\tsetLoading(false);\n\t// \t\t\tif (isMeasured === false) {\n\t// \t\t\t\tclearScanStartTimeAndScanId();\n\t// \t\t\t\tsetScanUniqueKey(generateUuid());\n\t// \t\t\t\treturn;\n\t// \t\t\t}\n\t// \t\t\tsetUploadLoading(true);\n\t// \t\t\tif (isMeasured === true) {\n\t// \t\t\t\tawait onSuccess(null);\n\t// \t\t\t} else if (isMeasured === null && tempScanStartTime > currentTimeInSeconds + fiveMinutesInSeconds) {\n\t// \t\t\t\tonError(res?.data?.error);\n\t// \t\t\t} else {\n\t// \t\t\t\thandleMeasurementRecommendation(scanId);\n\t// \t\t\t}\n\t// \t\t} catch (error) {\n\t// \t\t\tconsole.log(error);\n\t// \t\t\tclearScanStartTimeAndScanId();\n\t// \t\t\tsetScanUniqueKey(generateUuid());\n\t// \t\t\tsetUploadLoading(false);\n\t// \t\t}\n\t// \t},\n\t// \t[onError, onSuccess, setScanUniqueKey],\n\t// );\n\n\tconst handleCameraPermission = useCallback(async () => {\n\t\tif (+heightInCm < 152.4 || +heightInCm > 213.36) {\n\t\t\tonScanError?.({\n\t\t\t\tmessage: \"Height must be between 152.4cm (5ft) and 213.36cm (7ft)\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst permission = await checkCameraPermission();\n\t\tif (permission.disabled) {\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/camera_activation`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\temail,\n\t\t\t});\n\t\t\tsetLoading(false);\n\t\t} else {\n\t\t\t// const scanId = scanUniqueKey;\n\t\t\t// if (scanId) {\n\t\t\t// \tcheckMeasurementStatus(scanId);\n\t\t\t// } else {\n\t\t\t// \tsetLoading(false);\n\t\t\t// }\n\t\t\tsetLoading(false);\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/camera_activation`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t}\n\t\tsetShowDeniedModal(permission);\n\t\tsetScanFailsError(\"\");\n\t\tsetIsVideoUploaded(false);\n\t}, [email, scanUniqueKey, setScanUniqueKey, shopDomain]);\n\n\tuseEffect(() => {\n\t\tif (isError || isSuccess) return;\n\t\tif (shopDomain) {\n\t\t\thandleCameraPermission();\n\t\t}\n\t}, [shopDomain, heightInCm, isError, isSuccess]);\n\n\tuseEffect(() => {\n\t\tif (isError || isSuccess) return;\n\t\tif (isVideoUploaded && shopDomain && scanUniqueKey) {\n\t\t\thandleMeasurementRecommendation();\n\t\t}\n\t}, [isVideoUploaded, shopDomain, scanUniqueKey, isError, isSuccess]);\n\treturn (\n\t\t<LanguageContextProvider>\n\t\t\t<ConfigProvider config={config}>\n\t\t\t\t<MediaContextProvider>\n\t\t\t\t\t<ParamsContext.Provider\n\t\t\t\t\t\tvalue={{\n\t\t\t\t\t\t\tuserDetails,\n\t\t\t\t\t\t\tonRetry,\n\t\t\t\t\t\t\tonScanError,\n\t\t\t\t\t\t\tisError,\n\t\t\t\t\t\t\tisSuccess,\n\t\t\t\t\t\t\tonScanSuccess,\n\t\t\t\t\t\t\tgender,\n\t\t\t\t\t\t\tscanUniqueKey,\n\t\t\t\t\t\t\tscanFailsError,\n\t\t\t\t\t\t\tsetScanUniqueKey,\n\t\t\t\t\t\t\tsetIsVideoUploaded,\n\t\t\t\t\t\t\tisMeasurementAvailable,\n\t\t\t\t\t\t\tisVideoUploadedCorrect,\n\t\t\t\t\t\t\tloading,\n\t\t\t\t\t\t\tshowDeniedModal,\n\t\t\t\t\t\t\tuploadLoading,\n\t\t\t\t\t\t\tsetStartGyro,\n\t\t\t\t\t\t\tuploadScanFile,\n\t\t\t\t\t\t\tsetUploadLoading,\n\t\t\t\t\t\t\tresetScan,\n\t\t\t\t\t\t\tsetScanFailsError,\n\t\t\t\t\t\t\tsetScanStartTime,\n\t\t\t\t\t\t\tonScanStart,\n\t\t\t\t\t\t\tonCaptureComplete,\n\t\t\t\t\t\t\tonCustomScanSuccess,\n\t\t\t\t\t\t\tonComplete,\n\t\t\t\t\t\t\tswan,\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BodyScanSteps />\n\t\t\t\t\t</ParamsContext.Provider>\n\t\t\t\t</MediaContextProvider>\n\t\t\t</ConfigProvider>\n\t\t</LanguageContextProvider>\n\t);\n};\n","import { useCallback, useEffect, useState } from \"react\";\n\ninterface GyroDataItem {\n alpha?: string;\n beta?: string;\n gamma?: string;\n timestamp?: string;\n}\n\nexport interface IOSDeviceOrientationEvent extends DeviceOrientationEvent {\n requestPermission?: () => Promise<PermissionState>;\n}\n\nfunction useGyroSensor(startGyro: boolean) {\n const [gyroData, setGyroData] = useState<GyroDataItem[]>([]);\n const [permissionGranted, setPermissionGranted] = useState(false);\n\n const handleOrientation = useCallback((event: DeviceOrientationEvent) => {\n try {\n const { alpha, beta, gamma } = event;\n setGyroData((prev: GyroDataItem[]) => [\n ...prev,\n {\n alpha: alpha?.toString() || undefined,\n beta: beta?.toString() || undefined,\n gamma: gamma?.toString() || undefined,\n timestamp: new Date().toISOString(),\n },\n ]);\n } catch (error) {\n console.log(error);\n }\n }, []);\n\n const requestPermission = useCallback(async () => {\n const DeviceOrientation =\n DeviceOrientationEvent as unknown as IOSDeviceOrientationEvent;\n\n if (\n typeof DeviceOrientation !== \"undefined\" &&\n typeof DeviceOrientation.requestPermission === \"function\"\n ) {\n try {\n const response = await DeviceOrientation.requestPermission();\n if (response === \"granted\") {\n setPermissionGranted(true);\n } else {\n console.warn(\"Device orientation permission denied.\");\n }\n } catch (error) {\n console.error(\"Error requesting device orientation permission:\", error);\n }\n } else {\n // Permission not required on non-iOS devices\n setPermissionGranted(true);\n }\n }, []);\n\n useEffect(() => {\n if (startGyro && permissionGranted) {\n window.addEventListener(\"deviceorientation\", handleOrientation);\n } else {\n setGyroData([]);\n }\n return () => {\n window.removeEventListener(\"deviceorientation\", handleOrientation);\n };\n }, [startGyro, permissionGranted, handleOrientation]);\n\n useEffect(() => {\n if (startGyro) {\n requestPermission();\n }\n }, [startGyro, requestPermission]);\n\n return { gyroData };\n}\n\nexport default useGyroSensor;\n"],"names":["MEDIA_TYPES","MediaContext","createContext","undefined","MediaContextProvider","children","size","setSize","useState","window","innerWidth","innerHeight","clearInputs","setClearInputs","updateSize","useEffect","useLayoutEffect","addEventListener","removeEventListener","media","mediaDetails","useMemo","_jsx","Provider","value","CameraScanChild","resetScan","loadingCam","onUserMedia","onPause","pause","recordingStarted","startSendingVideoFrames","showPause","webcamRef","onUserMediaError","resetDetector","videoConstraints","webcamKey","useContext","translate","LanguageContext","_jsxs","className","onClick","X","Webcam","audio","ref","screenshotQuality","mirrored","screenshotFormat","style","position","top","bottom","zIndex","width","height","objectFit","SpecificButton","prefix","pauseIcon","buttonText","LanguageKeys","buttonFunc","btnSecondary","restart","startScan","disabled","id","crossOrigin","preload","src","voiceOverAssetsPath","globalLoadingPromise","globalDetector","globalPoseLib","audioTimeoutId","lastVideoPlayed","ScanningComponent$1","React","memo","setIsScanLocked","scanID","setIsVideoUploaded","setScanFailsError","setScanStartTime","setScanUniqueKey","userDetails","gender","heightInCm","email","shopDomain","useRef","mediaRecorderRef","recordedFpsRef","recordedChunks","setRecordedChunks","setLoadingCam","setRecordingStarted","faceDone","setFaceDone","mediaRecorderStopped","setMediaRecorderStopped","isScanning","setIsScanning","captureVideoTimeOutHandle","audioSource","setAudioSource","audioSourceList","setAudioSourceList","emptyAudioSource","setEmptyAudioSource","startAgain","setStartAgain","showRestart","setRestart","setPause","events","setEvents","setShowPause","allowAudioToPlay","poseDetector","consecutiveFronts","setConsecutiveFronts","spinPhase","setSpinPhase","isLoaded","setIsLoaded","spinPhaseRef","consecutiveFrontsRef","mounted","async","loadDependenciesGlobal","navigator","console","log","poseLib","tfjsCore","tfjsBackend","Promise","all","resolve","then","require","import","setBackend","ready","modelConfig","runtime","modelType","solutionPath","createDetector","SupportedModels","BlazePose","mediapipeError","warn","error","isFrontFrame","body","length","filter","p","current","success","s","callback","video","readyState","poses","estimatePoses","flipHorizontal","keypoints","slice","map","kp","x","y","score","prev","err","retryLoading","useTensorFlow","firstScan","poseStoppedRef","counterRef","consecutiveFalseRef","poseListenerRegistered","brilliantPlayedRef","postPoseProcessRef","supportedTypes","setSupportedTypes","setWebcamKey","currentVideoConstraints","setCurrentVideoConstraints","videoConstraintsExact","setStartGyro","uploadScanFile","setUploadLoading","swan","onScanStart","onCaptureComplete","ParamsContext","scanIDRef","eventsRef","startSendingVideoFramesRef","clearTimeout","generateUuid","speechService","stopAudio","stop","forEach","el","stream","handleUserMedia","useCallback","setTimeout","handleUserMediaError","videoConstraintsFallback","handlePause","poseDetection","disconnect","preferredVideoTypes","getPreferredMediaRecorderTypes","recordingMimeType","getRecordingMimeType","recordingExtension","getRecordingExtension","stopRecording","playAudio","handleSocket","connect","posthog","capture","handleReScan","rescanSupportCaptureEvent","eventName","status","handleSpinDataAvailable","data","concat","handleScanTimeCapture","message","handleStartCaptureClick","videoTrack","getVideoTracks","settings","getSettings","frameRate","mediaRecorderOptions","videoBitsPerSecond","mimeType","MediaRecorder","start","e","postPoseProcess","handleDataAvailable","connected","poseStatus","sid","counter","consecutiveFalse","type","document","querySelector","paused","audioName","no_of_times_skipped","skipCount","getScreenshot","videoEmit","image","scanId","getCurrentTimeInSeconds","push","bypassChecksToBackup","videoFile","File","supported","getSupportedMediaRecorderTypes","videoTypes","onReScan","AngleDetector","angle","setAngle","calibrationOffset","setCalibrationOffset","countdown","setCountdown","stabilityScore","setStabilityScore","lastAnglesRef","isScanLocked","calibratedAngle","isInTargetRange","DeviceOrientationEvent","handleOrientation","event","beta","newAngle","Math","abs","gamma","cos","PI","max","min","requestPermission","DeviceOrientation","once","variation","resetCountdown","startCountdown","timer","setInterval","clearInterval","ScanningComponent","Modal","config","Dialog","open","_Fragment","fontFamily","heading","headingFontFamily","fontSize","headingFontSize","color","headingColor","fontWeight","headingFontWeight","cameraAlreadyInUse","base","baseFontFamily","baseFontSize","baseTextColor","tryClosingBrowser","checkCameraSettings","setting","getBrowserName","enableCameraPermissions","CameraPermission","setShowDrawer","loader","showDeniedModal","setShowDeniedModal","loading","setLoading","handleCameraPermission","permission","checkCameraPermission","LoadingScreen","url","loaderType","VideoPlayer","link","onReady","wrapperClassName","videoReference","playerReference","videoJsOptions","autoplay","controls","responsive","fluid","muted","navigationUI","poster","videoPoster","player","videojs","updatedOptions","sources","isDisposed","dispose","playsInline","onDrag","preventDefault","ScanErrorMessage","scanFailsError","onNext","resolvedConfig","useConfig","showModal","setShowModal","handleShowModal","background","backgroundColor","Header","noTitle","issueWithScan","reason","handleErrorMessage","VIDEO_POSTER_GENDER_BASED","alt","scanAgain","onClose","GENDER","PRE_LINK","male","SignUp","isVideoUploadedCorrect","isMeasurementAvailable","onComplete","isSuccess","onCustomScanSuccess","deviceFocalLength","userName","scanType","isCustom","CLOTHING_CUSTOM_SCAN","CLOTHING_BANNER_SCAN","CLOTHING_CUSTOM_FIT_SCAN","includes","showDrawer","handleSignUp","auth","addUser","name","focalLength","clothesFit","showNextButton","Box","Drawer","_","anchor","title","measurementsBeingTaken","loop","autoPlay","GenderType","Male","maleMeasurementProgress","measurementProgress","next","BodyScanSteps","onRetry","isError","scanUniqueKey","uploadLoading","props","onUploadStart","onUploadEnd","onMeasurementSocketStart","onMeasurementSocketClose","onIntermediateScanSuccess","onScanError","onScanSuccess","deviceModelName","sourceTag","token","callbackUrl","getSwanService","setIsVideoUploadedCorrect","setIsMeasurementAvailable","isVideoUploaded","startGyro","scanStartTime","gyroData","setGyroData","permissionGranted","setPermissionGranted","alpha","toString","timestamp","Date","toISOString","useGyroSensor","usePosthogPageview","clearScanStartTimeAndScanId","onSuccess","scanStatus","resultType","code","scanIdToSet","completionTime","handleMeasurementRecommendation","measurement","handleMeasurementSocket","onPreopen","handleWebSocketCapture","connection","onOpen","onError","file","recordedFps","fileSizeInMB","Number","toFixed","videoFps","getVideoFPS","arrayMetaData","createObjectMetadataArray","focal_length","customer_store_url","clothes_fit","scan_type","callback_url","source_tag","JSON","stringify","video_fps","fileUpload","uploadFileFrontend","setDeviceInfo","model","detection","gyro","LanguageContextProvider","ConfigProvider"],"mappings":"iNAYO,MAAMA,EACF,UADEA,EAEN,MAFMA,EAGH,SAWGC,EAAeC,EAAAA,mBAC1BC,GAGF,SAASC,GAAqBC,SAAEA,IAC9B,MAAOC,EAAMC,GAAWC,EAAAA,SAAS,CAACC,QAAQC,WAAYD,QAAQE,eACvDC,EAAaC,GAAkBL,EAAAA,UAAS,GAEzCM,EAAa,KACjBP,EAAQ,CAAC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ACRlJ,UAEDgQ,GAAW,KAQXA,GAAW,GACX1G,wBAAsB,CACrBL,UAAW,GAAGhJ,sBACdT,OAAQmW,EACRzM,OAAQ,UACRlJ,WAGF8P,EAAmBI,GACnBxQ,EAAkB,IAClBD,GAAmB,IACjB,CAACO,EAAO2V,EAAe/V,EAAkBK,IAe5C,OAbA9E,EAAAA,UAAU,KACLua,GAAWjC,GACXxT,GACHgQ,MAEC,CAAChQ,EAAYF,EAAY2V,EAASjC,IAErCtY,EAAAA,UAAU,KACLua,GAAWjC,GACXmD,GAAmB3W,GAAc0V,GACpCsC,MAEC,CAACrB,EAAiB3W,EAAY0V,EAAeD,EAASjC,IAExD/X,EAAAA,IAACue,EAAAA,wBAAuB,CAAAxf,SACvBiB,EAAAA,IAACwe,EAAAA,eAAc,CAAC/L,OAAQA,WACvBzS,EAAAA,IAAClB,YACAkB,EAAAA,IAACqL,gBAAcpL,SAAQ,CACtBC,MAAO,CACNiE,cACA4V,UACAU,cACAT,UACAjC,YACA2C,gBACAtW,SACA6V,gBACA3D,iBACApS,mBACAH,qBACA8T,yBACAD,yBACAvD,UACAF,kBACA+F,gBACAnP,eACAC,kBACAC,mBACA7K,aACA4D,oBACAC,mBACAkH,cACAC,oBACA4M,sBACAF,aACA5M,QACAnM,SAEDiB,EAAAA,IAAC8Z,EAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import r,{useState as a,useCallback as s,useEffect as o,createContext as c,useLayoutEffect as i,useMemo as l,useContext as d,useRef as u}from"react";import{L as m,u as p,H as f,b as h,S as g,y,v,h as w,P as b,n as x,s as S,i as C,j as N,k as D,p as F,w as I,z as k,o as T,q as E,e as L,A as M,B as $,c as _,a as U,D as z,E as A,V as j,I as P,J as V,K as R,G as B,M as q,N as K,O as W,f as O,l as H,t as J,Q as G,r as Q,C as Y,x as X}from"./LoadingScreen-C_pA2xaB.js";import Z from"clsx";import ee from"react-webcam";import{X as te}from"lucide-react";import{Dialog as ne,Box as re,Drawer as ae}from"@mui/material";import se from"video.js";const oe="DESKTOP",ce="TAB",ie="MOBILE",le=c(void 0);function de({children:t}){const[n,r]=a([window?.innerWidth,window?.innerHeight]),[s,c]=a(!1),d=()=>{r([window?.innerWidth,window?.innerHeight])};o(()=>{d()},[]),i(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[d]);let u=oe;n[0]>768&&n[0]<1024&&(u=ce),n[0]<768&&(u=ie);const m=l(()=>({size:n,setSize:r,clearInputs:s,setClearInputs:c,media:u}),[n,s,u]);return e(le.Provider,{value:m,children:t})}var ue=r.memo(function({size:n=16}){return t("svg",{width:n,height:n,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("path",{d:"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})});var me=r.memo(function({angle:n,countdown:r,isScanning:a,isInTargetRange:o,stabilityScore:c,children:i}){const{translate:u}=d(m)||{},g=p(),y=s(()=>n<80?Math.max(0,Math.min(100,10*(n-60))):n>95?Math.max(0,Math.min(100,10*(105-n))):100,[n]),v=l(()=>{if(a)return g?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=y();if(0===e)return g?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return g?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[a,y]),w=s((e,t)=>t>70?e?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${g?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),b=s((e=!1)=>{const t=y();return a?`text-[${g?.style?.angleDetector?.successAngleTextLightColor}]`:w(e,t)},[a,y]),x=s((e,t)=>t>70||e?g?.style?.angleDetector?.successAngleTextLightColor:g?.style?.angleDetector?.successAngleTextDarkColor,[]),S=s((e=!1)=>{const t=y();return a?g?.style?.angleDetector?.successAngleTextLightColor:x(e,t)},[a,y]),C=r;function N(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return N(),window.addEventListener("resize",N),t("div",{className:"flex common-ui-main w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto",style:{backgroundColor:v},children:[e("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:e("div",{className:"flex justify-start ",children:e(f,{noTitle:!0})})}),null!==C?e("div",{className:"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300",style:{border:`2px solid ${S()}`},children:e("div",{className:`text-[3rem] font-bold text-[${S()}]`,style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:C})}):t("div",a?{className:"relative flex flex-col items-center justify-center",children:[e("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),i]}:{className:Z("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",o?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-n)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${S()}`},children:[e("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${S()}]/80`,style:{backgroundColor:`${S()}B3`}}),t("div",{className:Z("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",b()),style:{color:S()},children:[e(ue,{size:30}),t("p",{style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",u?.(h.startLevelCheck),e("br",{})]})]})]}),null!==C&&e("div",{className:"absolute bottom-[8rem] text-center",children:e("div",{className:Z("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",b()),style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:u?.(h.leavePhone)})}),o&&null===C&&!a&&e("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e("div",{className:`h-[.375rem] w-full bg-[${S()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${S()}33`},children:e("div",{className:`h-full bg-[${S()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${n}%`,backgroundColor:`${S()}B3`}})})}),null===C&&!a&&e("div",{className:"absolute bottom-[5rem] text-center",children:t("div",{className:Z("text-[1.5rem] font-light",b()),style:{color:S()},children:[Math.round(n),"°"]})}),null===C&&!a&&e("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e("div",{className:Z("text-[.75rem] opacity-50",b()),style:{fontFamily:g?.style?.base?.baseFontFamily||"Inter, sans-serif",color:S()},children:u?.(h.placePhoneUpright)})})]})});function pe({resetScan:n,loadingCam:r,onUserMedia:a,onPause:s,onReScan:o,pause:c,recordingStarted:i,startSendingVideoFrames:l,showPause:u,webcamRef:p,onUserMediaError:f,resetDetector:w,videoConstraints:b,webcamKey:x}){const{media:S}=d(le)||{},{translate:C}=d(m)||{};return t("div",{className:"App w-screen h-[100vh] relative common-ui-main",children:[e("span",{onClick:()=>{n(),w()},className:"fixed right-[20px] top-[20px] z-[999]",children:e(te,{className:"text-[#fff]"})}),e("div",{className:"w-full h-full overflow-hidden ",children:S===ie&&e(ee,{audio:!1,ref:p,screenshotQuality:1,videoConstraints:b,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:a,onUserMediaError:f,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}},x)}),t("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[u&&e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:y,buttonText:C?.(h.pause),buttonFunc:s,btnSecondary:!0}),c?e("div",{children:e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:C?.(h.restart),buttonFunc:o,btnSecondary:!0})}):i?null:e(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(r?"!opacity-50":""),buttonText:C?.(h.startScan),buttonFunc:l,disabled:r})]}),e("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${v}scanAudioInstructions/silence.mp3`})]})}let fe=null,he=null,ge=null;let ye,ve=null,we=null;var be=r.memo(function({setIsScanLocked:t,resetDetector:n,scanID:r,setIsVideoUploaded:c,setScanFailsError:i,setScanStartTime:m,setScanUniqueKey:p,userDetails:f}){const{email:h,shopDomain:g}=f,y=u(null),M=u(null),$=u(null),[_,U]=a([]),[z,A]=a(!0),[j,P]=a(!1),[V,R]=a(!1),[B,q]=a(!0),[K,W]=a(!1),O=u(null),[H,J]=a(""),[G,Q]=a([]),[Y,X]=a(""),[Z,ee]=a(!1),[te,ne]=a(!1),[re,ae]=a(!1),[se,oe]=a([]),[ce,ie]=a(!1),le=u(!0),{poseDetector:de}=function(){const[e,t]=a(0),[n,r]=a(0),[s,c]=a(!1),i=u(0),l=u(0),d=u(!0);async function m(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;try{console.log("Starting TensorFlow preload...");const[e,t,n]=await Promise.all([import("./pose-detection.esm-c4ZA7-te.js"),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);ge=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const r={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{he=await ge.createDetector(ge.SupportedModels.BlazePose,r),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),he=await ge.createDetector(ge.SupportedModels.BlazePose,{runtime:"tfjs",modelType:"full"}),console.log("TFJS detector created successfully")}return!0}catch(e){return console.error("Failed to load TensorFlow dependencies:",e),fe=null,!1}}function p(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return o(()=>{if(d.current=!0,!he)return fe||(fe=m()),fe.then(e=>{e&&d.current&&c(!0)}),()=>{d.current=!1};c(!0)},[]),o(()=>{l.current=e,e>6&&i.current<2&&(r(e=>e+1),t(0))},[e]),o(()=>{i.current=n},[n]),{poseDetector:async(e,n)=>{if(!he||!d.current||!n?.current?.video)return;const r=n.current.video;if(!(r.readyState<2))try{const n=await he.estimatePoses(r,{flipHorizontal:!1});if(!n||!n.length)return;const a=n[0].keypoints.slice(11).map(e=>[e.x>0&&e.x<720?e.x:-1,e.y>0&&e.y<1280?e.y:-1,e.score??0]);0!==i.current||p(a)||t(e=>e+1),1===i.current&&p(a)&&t(e=>e+1),2===i.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:s,spinPhase:n,resetDetector:()=>{i.current=0,l.current=0,t(0),r(0)},retryLoading:async()=>{he||fe||(fe=m(),await fe&&d.current&&c(!0))}}}(),ue=u(!0),me=u(!1),be=u(0),xe=u(0),Se=u(!1),Ce=u(!1),Ne=u(()=>{}),[De,Fe]=a([]),[Ie,ke]=a(0),[Te,Ee]=a(w),{setStartGyro:Le,uploadScanFile:Me,setUploadLoading:$e,swan:_e,onScanStart:Ue,onCaptureComplete:ze}=d(b),Ae=u(r);o(()=>{Ae.current=r},[r]);const je=u(se);o(()=>{je.current=se},[se]);const Pe=u(()=>{}),Ve=()=>{me.current=!1,clearTimeout(ye),O.current&&clearTimeout(O.current),p(L()),i(""),$e?.(!1),U([]),$.current=null,A(!0),P(!1),R(!1),q(!0),W(!1),O.current=null,J(""),Q([]),X(""),ee(!Z),Le(!1),S.stopAudio(),ne(!1),ae(!1),be.current=0,xe.current=0,Se.current=!1,Ce.current=!1,null!==M.current&&M.current.stop(),se.forEach(e=>{M.current&&M.current.removeEventListener("dataavailable",e)}),oe([]),le.current=!0,ie(!1),c(!1),y.current?.stream&&A(!1)},Re=s(()=>{setTimeout(()=>{A(!1)},1e3)},[]),Be=s(e=>{if(console.log("camera error",e),Te===w)return Ee(x),void ke(e=>e+1);A(!1)},[Te]),qe=s(()=>{le.current=!1,ae(!0),ie(!1),O.current&&clearTimeout(O.current),M.current&&M.current.pause(),S.stopAudio(),_e.poseDetection.disconnect(),be.current=0,xe.current=0,Se.current=!1,Ce.current=!1,M.current&&M.current.stop(),se.forEach(e=>{M.current&&M.current.removeEventListener("dataavailable",e)}),oe([]),clearTimeout(ye)},[M,se,S,le]),Ke=l(()=>C(),[]),We=N(De),Oe=D(We),He=s(async()=>{le.current=!0,await S.playAudio(`${v}SpotOn.mp3`),ae(!1),ie(!1),O.current&&clearTimeout(O.current),P(!1)},[O,S]),Je=s(async()=>{try{ve=await _e.poseDetection.connect(),console.log(ve,"websocket connected, connected():",_e.poseDetection.connected()),F.capture(`${g}/pose_detection_connected`,{scanID:Ae.current,email:h,id:ve})}catch(e){console.log(e,"while connecting websocket")}},[g,h,_e]),Ge=s(({data:e})=>{e&&e.size>0&&le.current&&(U(t=>t.concat(e)),!me.current&&y.current&&(me.current=!0,de(()=>{He(),I({eventName:`${g}/tensorFlow`,scanID:Ae.current,email:h,message:"recording stopped by tensorflow "})},y)))},[He,I,g,h,y]),Qe=s(async()=>{G.length>0&&le.current&&(await S.playAudio(v+G[G.length-1]),le.current&&(ye=setTimeout(Qe,2e3)))},[G,le]),Ye=s(()=>{M&&M.current&&M.current.stop(),P(!0);try{if(y&&y.current&&y.current.stream){const e=y.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();$.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};De[0]&&(t.mimeType=De[0]),M.current=new MediaRecorder(y.current.stream,t),M.current.addEventListener("dataavailable",Ge),oe([...se,Ge]),M.current.start(1e3),q(!1)}}catch(e){console.log("error while using media recorder",e)}},[y,De,Ge,se]),Xe=s(async()=>{O.current&&clearTimeout(O.current),Ye(),le.current&&(O.current=setTimeout(async()=>{le.current&&(await S.playAudio(`${v}SpotOn.mp3`),P(!1))},15e3)),R(!0),le.current&&await S.playAudio(`${v}Spin.mp3`)},[Ye,le,S]);o(()=>{Ne.current=Xe},[Xe]);const Ze=s(({data:e})=>{console.log("[handleDataAvailable] data.size:",e.size,"connected:",_e.poseDetection.connected(),"poseListenerRegistered:",Se.current),e.size>0&&_e.poseDetection.connected()&&(Se.current||(Se.current=!0,_e.poseDetection.poseStatus(async e=>{if(console.log("poseStatus data:",e),e&&e.audio&&e.audio.length>0){F.capture(`${g}/pose_instruction_received`,{scanID:Ae.current,email:h,audio:e.audio,status:e.status,sid:e.sid,counter:be.current,consecutiveFalse:xe.current,type:"body_scan_instruction"});const t=document.querySelector("#audioElement");!0===e.status&&e.sid===ve?(xe.current=0,be.current<2?(be.current+=1,1!==be.current||Ce.current?2===be.current&&t?.paused&&(clearTimeout(ye),S.playAudio(v+e.audio)):(Ce.current=!0,clearTimeout(ye),S.stopAudio(),await S.playAudio(v+e.audio))):(X(e.audio),clearTimeout(ye),_e.poseDetection.disconnect(),Se.current=!1,setTimeout(()=>Ne.current(),1e3))):(xe.current+=1,xe.current>=3&&(be.current=0,Ce.current=!1),!t?.paused||we&&we?.audioName===e.audio?we?.audioName===e.audio&&t?.paused&&(we&&we.no_of_times_skipped>=we.skipCount?(we.no_of_times_skipped=0,S.playAudio(v+e.audio)):we&&(we.no_of_times_skipped+=1)):(we={skipCount:2,no_of_times_skipped:0,audioName:e.audio},S.playAudio(v+e.audio)))}})),y?.current&&null!==y.current.getScreenshot()&&(console.log("[videoEmit] sending frame with scanId:",Ae.current),_e.poseDetection.videoEmit({image:y.current.getScreenshot()||"",scanId:Ae.current})))},[y,_e,S,g,h]),et=s(async()=>{W(!0),Le(!0),Ue?.(),ue.current&&(ue.current=!1,I({eventName:"scan started",scanID:Ae.current,status:"success",email:h})),m(k()),A(!0),le.current&&await S.playAudio(`${v}StartScan.mp3`),le.current&&await S.playAudio(`${v}LiftArmsAndHoldAtHip.mp3`),le.current&&(W(!1),P(!0),ne(!0),ie(!0),Re());try{if(y&&y.current&&y.current.stream&&le.current){const e=y.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();$.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};De[0]&&(t.mimeType=De[0]),le.current&&(M.current=new MediaRecorder(y.current.stream,t)),le.current&&M.current&&M.current.addEventListener("dataavailable",Ze),oe([...je.current,Ze]),M.current&&M.current.start(1e3),q(!1),le.current&&(ye=setTimeout(Qe,2e3))}}catch(e){console.log("error ----------",e)}},[y,De,Ze,Qe,le,Ue]);return o(()=>{Pe.current=et},[et]),o(()=>(g&&(t(!0),Je()),()=>{ve&&(_e.poseDetection.disconnect(),F.capture(`${g}/pose_detection_disconnected`,{scanID:Ae.current,email:h,id:ve})),se.forEach(e=>{M?.current?.removeEventListener("dataavailable",e)})}),[g]),o(()=>{G.push(H)},[H]),o(()=>{Q([])},[Y]),o(()=>{const e=_.length&&_.length>0;B||!e||j||!le.current||re||M&&M.current&&(j||(M.current.stop(),q(!0)))},[B,j,_,re]),o(()=>{const e=_.length&&_.length>0;if(B||!e||j)console.log("No video found to upload.");else if(M&&M.current&&le.current&&!re&&!j){const e=new File(_,`${r}.${Oe}`,{type:We});ze?.(),$e?.(!0),i(""),Me?.(e,$.current)}},[B,j,_,re,M,le]),o(()=>{const e=T(Ke,E);Fe(e)},[Ke]),o(()=>{Ve()},[]),e(pe,{resetDetector:n,resetScan:Ve,loadingCam:z,onPause:qe,showRestart:te,pause:re,onReScan:async()=>{_e.poseDetection.disconnect(),Ve(),await Je()},recordingStarted:j,isScanning:K,startSendingVideoFrames:et,faceDone:V,stopRecording:He,showPause:ce,webcamRef:y,onUserMedia:Re,onUserMediaError:Be,videoConstraints:Te,webcamKey:Ie})});function xe({scanID:t,userDetails:n,setIsVideoUploaded:r,setScanFailsError:s,setScanStartTime:c,setScanUniqueKey:i}){const[l,d]=a(90),[m,p]=a(0),[f,h]=a(null),[g,y]=a(!1),[v,w]=a(0),b=u([]),[x,S]=a(!1),C=l-m,N=C>=80&&C<=95;o(()=>{if("undefined"!=typeof window&&window.DeviceOrientationEvent){const e=e=>{if(null!==e.beta){let t=Math.abs(e.beta);null!==e.gamma&&(t*=Math.cos(e.gamma*Math.PI/180)),t=Math.max(0,Math.min(180,t)),d(t)}},t=async()=>{const t=DeviceOrientationEvent;if(t&&"function"==typeof t.requestPermission)try{"granted"===await t.requestPermission()&&window.addEventListener("deviceorientation",e)}catch(e){console.error("Permission error",e)}else window.addEventListener("deviceorientation",e);return()=>{e&&window.removeEventListener("deviceorientation",e)}};document.addEventListener("click",t,{once:!0})}},[]),o(()=>{if(b.current=[...b.current.slice(-4),C],b.current.length>=5){const e=Math.max(...b.current)-Math.min(...b.current);w(N&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}N||null===f&&!g||F()},[C,N,f,g]),o(()=>{v>=100&&null===f&&!g&&D(),v<50&&null!==f&&F()},[v,f,g]);const D=()=>{h(3);const e=setInterval(()=>{h(t=>null===t||t<=1?(clearInterval(e),y(!0),null):t-1)},1e3)},F=()=>{h(null),x||y(!1)};return e(me,{angle:C,countdown:f,isScanning:g,isInTargetRange:N,stabilityScore:v,children:g&&e(be,{setIsScanLocked:S,resetDetector:()=>{d(90),p(0),h(null),y(!1),w(0),S(!1),b.current=[]},scanID:t,userDetails:n,setIsVideoUploaded:r,setScanFailsError:s,setScanStartTime:c,setScanUniqueKey:i})})}function Se({message:r,config:a}){const{translate:s}=d(m)||{};return e(ne,{open:!0,className:"confirm-modal common-ui-main",children:e("div",{className:"modal-main",children:e("div",{className:"text-center",children:t(n,r?{children:[e("h2",{style:{fontFamily:a?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:a?.style?.heading?.headingFontSize||"32px",color:a?.style?.heading?.headingColor||"#000",fontWeight:a?.style?.heading?.headingFontWeight||"normal"},children:s?.(h.cameraAlreadyInUse)}),e("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:a?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:a?.style?.base?.baseFontSize||"16px",color:a?.style?.base?.baseTextColor||"#000"},children:s?.(h.tryClosingBrowser)})]}:{children:[e("h2",{style:{fontFamily:a?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:a?.style?.heading?.headingFontSize||"32px",color:a?.style?.heading?.headingColor||"#000",fontWeight:a?.style?.heading?.headingFontWeight||"normal"},children:s?.(h.checkCameraSettings)}),e("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:a?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:a?.style?.base?.baseFontSize||"16px",color:a?.style?.base?.baseTextColor||"#000"},children:`${s?.(h.setting)} > ${M()} > ${s?.(h.enableCameraPermissions)}`})]})})})})}function Ce({setShowDrawer:t,config:n,loader:r}){const[c,i]=a({disabled:!1,message:""}),[l,d]=a(!0),m=u(null),p=s(async()=>{const e=await $();i(e),d(!1)},[]);return o(()=>{p()},[]),l?e(_,{url:r,loaderType:"black"}):c?.disabled?e(Se,{config:n,message:c?.message}):e(ee,{audio:!1,ref:m,screenshotQuality:1,videoConstraints:U,mirrored:!0,onUserMedia:()=>t?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function Ne({link:t,onReady:n,wrapperClassName:r="[&_video]:rounded-t-[20px] w-full h-full"}){const a=u(null),s=u(null);let c={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:z};return o(()=>{if(!s.current&&t&&a?.current){const e=se(a.current,{...c});e.ready(()=>{s.current=e;const r={...c,sources:[{src:t,type:"application/x-mpegURL"}]};e.autoplay(r.autoplay),e.src(r.sources),n?.(e)})}},[t,a]),o(()=>{const e=s.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),s.current=null)}},[s]),e("div",{className:r,children:e("video",{ref:a,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function De({scanFailsError:r,onNext:s,gender:o,setScanUniqueKey:c,setIsVideoUploaded:i}){const{translate:l}=d(m)||{},u=p(),[y,v]=a(!1),w=()=>{v(!y)};return t(n,{children:[t("div",{className:"flex common-ui-main flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:u?.style?.base?.backgroundColor},children:[e("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e(f,{noTitle:!0})}),e("div",{className:"flex-1",children:r&&t("div",{className:"px-[1rem]",children:[e("h2",{className:"text-center",style:{fontFamily:u?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:u?.style?.heading?.headingFontSize||"32px",color:u?.style?.heading?.headingColor||"#000",fontWeight:u?.style?.heading?.headingFontWeight||"normal"},children:l?.(h.issueWithScan)}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:l?.(h.reason)}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:A(r)}),e("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:w,src:j[o],alt:"icon"})]})}),r&&e("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e(g,{disabled:!1,buttonText:l?.(h.scanAgain),className:"!shadow-none",buttonFunc:()=>{s?s?.():c?.(L()),i?.(!1)}})})]}),y&&t(ne,{className:"w-screen h-screen video-modal",onClose:w,open:y,children:[e("div",{className:"flex justifyEnd ",children:e("span",{className:"closeBtn",onClick:w,children:e(te,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e("div",{className:"aspect-video object-cover rounded-[20px] ",children:e(Ne,{link:o?P[o].PRE_LINK:P.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function Fe({scanId:n,userDetails:r,config:c,isVideoUploadedCorrect:i,isMeasurementAvailable:l,onComplete:u,isSuccess:p,onCustomScanSuccess:y,swan:v}){const{gender:w,shopDomain:b,heightInCm:x,deviceFocalLength:S,userName:C,email:N,scanType:D}=r||{},I=[q,K,W].includes(D??""),[k,T]=a(!0),E=s(async()=>{try{I&&(await(v?.auth.addUser({scanId:n,email:N,name:C,gender:w,height:x})),y?.()),F.capture(b??"",{scanID:n,email:N,height:x,focalLength:S,clothesFit:"0",gender:w})}catch(e){console.log(e)}},[I]),{translate:L}=d(m)||{};o(()=>{(i||l)&&E()},[i,l]);const M=p||i||l;return e(re,{className:"flex h-full w-full flex-col common-ui-main",children:t("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e(Ce,{loader:c?.loader,setShowDrawer:T}),e(ae,{open:k,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:e("div",{className:"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]",style:{background:c?.style?.base?.backgroundColor},children:t("div",{className:"w-full h-full flex flex-col",children:[e(f,{title:L?.(h.measurementsBeingTaken)}),e("div",{className:"flex items-center justify-center flex-1",children:e("video",{preload:"auto",className:"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e("source",{src:w===B.Male?V:R,type:"video/mp4"})})}),M&&e(g,{className:"!w-[180px] mx-auto",buttonText:L?.(h.next),buttonFunc:()=>{u?.()}})]})})})]})})}const Ie=()=>{const{userDetails:r,onRetry:a,isError:s,isSuccess:o,gender:c,scanUniqueKey:i,scanFailsError:l,setScanUniqueKey:u,setIsVideoUploaded:m,isMeasurementAvailable:f,isVideoUploadedCorrect:h,loading:g,showDeniedModal:y,uploadLoading:v,setScanFailsError:w,setScanStartTime:x,resetScan:S,onCustomScanSuccess:C,swan:N,onComplete:D}=d(b),F=p();return s?t(n,{children:[e(Ce,{}),e(ae,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(De,{scanFailsError:!0,onNext:a,gender:c})})]}):o?e(Fe,{isSuccess:!0,onComplete:D,config:F}):g?e("div",{className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:F?.style?.base?.backgroundColor},children:e(_,{url:F?.loader,loaderType:"black"})}):y.disabled?e(Se,{}):v||l||f||h?(v||f||h)&&!l?e(Fe,{scanId:i,isMeasurementAvailable:f,userDetails:r,isVideoUploadedCorrect:h,onCustomScanSuccess:C,swan:N,onComplete:D,config:F}):t(n,{children:[e(Ce,{}),e(ae,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(De,{scanFailsError:l,onNext:()=>{a?.(),S()},setScanUniqueKey:u,gender:c,setIsVideoUploaded:m})})]}):e(xe,{scanID:i,userDetails:r,setIsVideoUploaded:m,setScanFailsError:w,setScanStartTime:x,setScanUniqueKey:u})},ke=t=>{const{config:n,onRetry:r,onScanStart:c,onCaptureComplete:i,onUploadStart:d,onUploadEnd:u,onMeasurementSocketStart:m,onMeasurementSocketClose:p,onIntermediateScanSuccess:f,onScanError:h,onScanSuccess:g,onCustomScanSuccess:y,onComplete:v,isError:w,isSuccess:x}=t,S={email:"",shopDomain:"",gender:"male",heightInCm:0,scanType:"",deviceFocalLength:0,deviceModelName:"",sourceTag:"",...t.userDetails??{}},C=t.token??"",{gender:N,scanType:D,shopDomain:F,heightInCm:T,email:E,deviceFocalLength:M,deviceModelName:_,callbackUrl:U,sourceTag:z}=S,j=l(()=>O(C),[C]),[P,V]=a(!1),[R,B]=a(!1),[q,K]=a(!1),[W,Z]=a({disabled:!1,message:""}),[ee,te]=a(""),[ne,re]=a(!1),[ae,se]=a(!0),[oe,ce]=a(!1),[ie,le]=a(""),[ue,me]=a(k()),{gyroData:pe}=function(e){const[t,n]=a([]),[r,c]=a(!1),i=s(e=>{try{const{alpha:t,beta:r,gamma:a}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:r?.toString()||void 0,gamma:a?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),l=s(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?c(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else c(!0)},[]);return o(()=>(e&&r?window.addEventListener("deviceorientation",i):n([]),()=>{window.removeEventListener("deviceorientation",i)}),[e,r,i]),o(()=>{e&&l()},[e,l]),{gyroData:t}}(oe);H();const fe=s(()=>{le(L()),te(""),V(!1),re(!1)},[]),he=()=>{me(null),le("")},ge=s(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return I({eventName:`${F}/measurement_success/intermediate`,scanID:ie,status:"success",email:E}),B(!0),void f?.(e);g?.(e),B(!0),he();const t=ie;K(!0),I({eventName:`${F}/measurement_success/fit-view`,scanID:t,status:"success",email:E}),ue&&I({eventName:`${F}/scan_completion_time`,scanID:t,status:"success",completionTime:k()-ue,email:E})},[D,F,ie]),ye=e=>{K(!1),te(""),B(!1),j.measurement.handleMeasurementSocket({scanId:ie,onPreopen:()=>{X({eventName:`${F}/webSocket`,scanID:ie,connection:"pre_open",type:"measurement_recommendation",email:E})},onOpen:()=>{m?.(),X({eventName:`${F}/webSocket`,scanID:ie,connection:"open",type:"measurement_recommendation",email:E})},onClose:()=>{p?.(),X({eventName:`${F}/webSocket`,scanID:ie,connection:"close",type:"measurement_recommendation",email:E})},onError:e=>{var t;t=e,h?.({...t,message:A(t)}),he(),K(!1),te(t),B(!1),I({eventName:`${F}/measurement_failed/fit-view`,scanID:ie,status:"failed",email:E,message:A(t)}),ue&&I({eventName:`${F}/scan_completion_time`,scanID:ie,status:"failed",completionTime:k()-ue,email:E}),X({eventName:`${F}/webSocket`,scanID:ie,connection:"error",type:"measurement_recommendation",email:E})},onSuccess:e=>{X({eventName:`${F}/webSocket`,scanID:ie,connection:"success",type:"measurement_recommendation",email:E}),ge(e)}})},ve=s(async(e,t)=>{const n=Number((e.size/1048576).toFixed(2)),r=null!=t?t:await J(e),a=G({gender:N,focal_length:`${M}`,height:`${T}`,customer_store_url:F,clothes_fit:"0",scan_type:D,callback_url:U,source_tag:z});I({eventName:`${F}/body_scan_meta_data`,scanID:ie,email:E,data:JSON.stringify([...a,{fileSizeInMB:n,video_fps:r||0}])}),d?.();try{await j.fileUpload.uploadFileFrontend({file:e,arrayMetaData:a,scanId:ie,email:E}),await j.fileUpload.setDeviceInfo({model:_,detection:"manual",gyro:pe,scanId:ie}),console.log("video successfully uploaded"),re(!1),I({eventName:`${F}/scan_success`,scanID:ie,status:"success",email:E,data:JSON.stringify(a)}),I({eventName:"scan finished",scanID:ie,status:"success",email:E}),me(k()),setTimeout(()=>{re(!0)},3e3)}catch(e){I({eventName:"scan finished",scanID:ie,status:"failed",email:E,message:A(e)}),I({eventName:`${F}/scan_failed`,scanID:ie,status:"failed",email:E,message:A(e),data:JSON.stringify(a)}),te(A(e)),re(!1),h?.({...e,message:A(e)}),he()}finally{ce(!1),u?.()}},[ie,pe,d,u]),we=s(async()=>{if(+T<152.4||+T>213.36)return void h?.({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await $();e.disabled?(I({eventName:`${F}/camera_activation`,scanID:ie,status:"failed",email:E}),se(!1)):(se(!1),I({eventName:`${F}/camera_activation`,scanID:ie,status:"success",email:E})),Z(e),te(""),re(!1)},[E,ie,le,F]);return o(()=>{w||x||F&&we()},[F,T,w,x]),o(()=>{w||x||ne&&F&&ie&&ye()},[ne,F,ie,w,x]),e(Q,{children:e(Y,{config:n,children:e(de,{children:e(b.Provider,{value:{userDetails:S,onRetry:r,onScanError:h,isError:w,isSuccess:x,onScanSuccess:g,gender:N,scanUniqueKey:ie,scanFailsError:ee,setScanUniqueKey:le,setIsVideoUploaded:re,isMeasurementAvailable:q,isVideoUploadedCorrect:R,loading:ae,showDeniedModal:W,uploadLoading:P,setStartGyro:ce,uploadScanFile:ve,setUploadLoading:V,resetScan:fe,setScanFailsError:te,setScanStartTime:me,onScanStart:c,onCaptureComplete:i,onCustomScanSuccess:y,onComplete:v,swan:j},children:e(Ie,{})})})})})};export{ke as B};
2
+ //# sourceMappingURL=BodyScan-C7dkFVxY.js.map