@swan-admin/swan-dev-web-component 0.1.0-alpha.1770638227 → 0.1.0-alpha.1770639513
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BodyScan-BLHAo6qL.js +2 -0
- package/dist/BodyScan-BLHAo6qL.js.map +1 -0
- package/dist/BodyScan-CsfWzkns.js +2 -0
- package/dist/BodyScan-CsfWzkns.js.map +1 -0
- package/dist/FaceScan-CcyLahUS.js +2 -0
- package/dist/FaceScan-CcyLahUS.js.map +1 -0
- package/dist/FaceScan-IzazcYL7.js +2 -0
- package/dist/FaceScan-IzazcYL7.js.map +1 -0
- package/dist/bodyScan.js +1 -1
- package/dist/bodyScan.mjs +1 -1
- package/dist/faceScan.js +1 -1
- package/dist/faceScan.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),a=require("posthog-js"),s=require("./LoadingScreen-oRPslIdH.js"),n=require("clsx"),r=require("react-webcam"),o=require("lucide-react"),i=require("@mui/material"),c=require("video.js");const l="DESKTOP",u="TAB",d="MOBILE",m=t.createContext(void 0);function f({children:a}){const[s,n]=t.useState([window?.innerWidth,window?.innerHeight]),[r,o]=t.useState(!1),i=()=>{n([window?.innerWidth,window?.innerHeight])};t.useEffect(()=>{i()},[]),t.useLayoutEffect(()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]);let c=l;s[0]>768&&s[0]<1024&&(c=u),s[0]<768&&(c=d);const f=t.useMemo(()=>({size:s,setSize:n,clearInputs:r,setClearInputs:o,media:c}),[s,r,c]);return e.jsx(m.Provider,{value:f,children:a})}var h=t.memo(function({size:t=16}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("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.jsx("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.jsx("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.jsx("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.jsx("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 g=t.memo(function({angle:a,countdown:r,isScanning:o,isInTargetRange:i,stabilityScore:c,children:l,config:u}){const{translate:d}=t.useContext(s.LanguageContext)||{},m=t.useCallback(()=>a<80?Math.max(0,Math.min(100,10*(a-60))):a>95?Math.max(0,Math.min(100,10*(105-a))):100,[a]),f=t.useMemo(()=>{if(o)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=m();if(0===e)return u?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[o,m]),g=t.useCallback((e,t)=>t>70?e?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${u?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),p=t.useCallback((e=!1)=>{const t=m();return o?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]`:g(e,t)},[o,m]),x=t.useCallback((e,t)=>t>70||e?u?.style?.angleDetector?.successAngleTextLightColor:u?.style?.angleDetector?.successAngleTextDarkColor,[]),y=t.useCallback((e=!1)=>{const t=m();return o?u?.style?.angleDetector?.successAngleTextLightColor:x(e,t)},[o,m]),v=r;function S(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return S(),window.addEventListener("resize",S),e.jsxs("div",{className:"flex 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:f},children:[e.jsx("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:e.jsx("div",{className:"flex justify-start ",children:e.jsx(s.Header,{noTitle:!0,resolvedConfig:u})})}),null!==v?e.jsx("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 ${y()}`},children:e.jsx("div",{className:`text-[3rem] font-bold text-[${y()}]`,style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:v})}):o?e.jsxs("div",{className:"relative flex flex-col items-center justify-center",children:[e.jsx("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e.jsx("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),l]}):e.jsxs("div",{className:n("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",i?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-a)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${y()}`},children:[e.jsx("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${y()}]/80`,style:{backgroundColor:`${y()}B3`}}),e.jsxs("div",{className:n("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",p()),style:{color:y()},children:[e.jsx(h,{size:30}),e.jsxs("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",d?.(s.LanguageKeys.startLevelCheck),e.jsx("br",{})]})]})]}),null!==v&&e.jsx("div",{className:"absolute bottom-[8rem] text-center",children:e.jsx("div",{className:n("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",p()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:d?.(s.LanguageKeys.leavePhone)})}),i&&null===v&&!o&&e.jsx("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e.jsx("div",{className:`h-[.375rem] w-full bg-[${y()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${y()}33`},children:e.jsx("div",{className:`h-full bg-[${y()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${a}%`,backgroundColor:`${y()}B3`}})})}),null===v&&!o&&e.jsx("div",{className:"absolute bottom-[5rem] text-center",children:e.jsxs("div",{className:n("text-[1.5rem] font-light",p()),style:{color:y()},children:[Math.round(a),"°"]})}),null===v&&!o&&e.jsx("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e.jsx("div",{className:n("text-[.75rem] opacity-50",p()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:d?.(s.LanguageKeys.placePhoneUpright)})})]})});function p({handleShowStreamCamera:a,loadingCam:n,handleUserMedia:i,handlePause:c,pause:l,recordingStarted:u,startSendingVideoFrames:f,showPause:h,webcamRef:g,handleUserMediaError:p,resetDetector:x,videoConstraints:y,webcamKey:v,config:S}){const{media:b}=t.useContext(m)||{},{translate:C}=t.useContext(s.LanguageContext)||{};return e.jsxs("div",{className:"App w-screen h-[100vh] relative ",children:[e.jsx("span",{onClick:()=>{a(),x()},className:"fixed right-[20px] top-[20px] z-[999]",children:e.jsx(o.X,{className:"text-[#fff]"})}),e.jsx("div",{className:"w-full h-full overflow-hidden ",children:b===d&&e.jsx(r,{audio:!1,ref:g,screenshotQuality:1,videoConstraints:y,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:i,onUserMediaError:p,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}},v)}),e.jsxs("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[h&&e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:s.pauseIcon,buttonText:C?.(s.LanguageKeys.pause),buttonFunc:c,resolvedConfig:S,btnSecondary:!0}),l?e.jsx("div",{children:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:C?.(s.LanguageKeys.restart),buttonFunc:a,resolvedConfig:S,btnSecondary:!0})}):u?null:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(n?"!opacity-50":""),buttonText:C?.(s.LanguageKeys.startScan),buttonFunc:f,disabled:n,resolvedConfig:S})]}),e.jsx("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${s.voiceOverAssetsPath}scanAudioInstructions/silence.mp3`})]})}let x=null,y=null,v=null;let S,b=null,C=null;var w=t.memo(function({setIsScanLocked:n,resetDetector:r,scanID:o,setIsVideoUploaded:i,setScanFailsError:c,setScanStartTime:l,setScanUniqueKey:u,userDetails:d,config:m}){const{gender:f,heightInCm:h,email:g,shopDomain:w}=d,j=t.useRef(null),k=t.useRef(null),F=t.useRef(null),[N,E]=t.useState([]),[T,D]=t.useState(!0),[L,I]=t.useState(!1),[M,U]=t.useState(!1),[P,_]=t.useState(!0),[A,$]=t.useState(!1),R=t.useRef(null),[V,z]=t.useState(""),[K,O]=t.useState([]),[q,B]=t.useState(""),[W,H]=t.useState(!1),[G,J]=t.useState(!1),[Q,X]=t.useState(!1),[Y,Z]=t.useState([]),[ee,te]=t.useState(!1),ae=t.useRef(!0),{poseDetector:se}=function(){const[e,a]=t.useState(0),[s,n]=t.useState(0),[r,o]=t.useState(!1),i=t.useRef(0),c=t.useRef(0),l=t.useRef(!0);async function u(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;try{console.log("Starting TensorFlow preload...");const[e,t,a]=await Promise.all([Promise.resolve().then(function(){return require("./pose-detection.esm-BIjr5TBZ.js")}),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);v=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const s={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{y=await v.createDetector(v.SupportedModels.BlazePose,s),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),y=await v.createDetector(v.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),x=null,!1}}function d(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return t.useEffect(()=>{if(l.current=!0,!y)return x||(x=u()),x.then(e=>{e&&l.current&&o(!0)}),()=>{l.current=!1};o(!0)},[]),t.useEffect(()=>{c.current=e,e>6&&i.current<2&&(n(e=>e+1),a(0))},[e]),t.useEffect(()=>{i.current=s},[s]),{poseDetector:async(e,t)=>{if(!y||!l.current||!t?.current?.video)return;const s=t.current.video;if(!(s.readyState<2))try{const t=await y.estimatePoses(s,{flipHorizontal:!1});if(!t||!t.length)return;const n=t[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||d(n)||a(e=>e+1),1===i.current&&d(n)&&a(e=>e+1),2===i.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:r,spinPhase:s,resetDetector:()=>{i.current=0,c.current=0,a(0),n(0)},retryLoading:async()=>{y||x||(x=u(),await x&&l.current&&o(!0))}}}(),ne=t.useRef(!0),re=t.useRef(!1),[oe,ie]=t.useState([]),[ce,le]=t.useState(0),[ue,de]=t.useState(s.videoConstraintsExact);let me=0;const{setStartGyro:fe,handleFileUpload:he,setUploadLoading:ge}=t.useContext(s.ParamsContext),pe=()=>{re.current=!1,clearTimeout(S),R.current&&clearTimeout(R.current),u(s.generateUuid()),c(""),ge?.(!1),E([]),F.current=null,D(!0),I(!1),U(!1),_(!0),$(!1),R.current=null,z(""),O([]),B(""),H(!W),fe(!1),s.speechService.stopAudio(),J(!1),X(!1),me=0,null!==k.current&&k.current.stop(),Y.forEach(e=>{k.current&&k.current.removeEventListener("dataavailable",e)}),Z([]),ae.current=!0,te(!1),i(!1),j.current?.stream&&D(!1)},xe=t.useCallback(()=>{setTimeout(()=>{D(!1)},1e3)},[]),ye=t.useCallback(e=>{if(console.log("camera error",e),ue===s.videoConstraintsExact)return de(s.videoConstraintsFallback),void le(e=>e+1);D(!1)},[ue]),ve=t.useCallback(()=>{s.rescanSupportCaptureEvent({eventName:`${w}/rescan`,email:g,scanID:o,height:h,gender:f,status:!1}),ae.current=!1,pe(),Ee()},[pe,o,g]),Se=t.useCallback(()=>{ae.current=!1,X(!0),te(!1),R.current&&clearTimeout(R.current),k.current&&k.current.pause(),s.speechService.stopAudio(),s.swan.poseDetection.disconnect(),me=0,k.current&&k.current.stop(),Y.forEach(e=>{k.current&&k.current.removeEventListener("dataavailable",e)}),Z([]),clearTimeout(S)},[k,Y,s.speechService,ae]),be=t.useCallback(async()=>{ae.current=!0,await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),X(!1),te(!1),R.current&&clearTimeout(R.current),I(!1)},[R,s.speechService]),Ce=t.useCallback(async()=>{try{b=await s.swan.poseDetection.connect(),a.capture(`${w}/pose_detection_connected`,{scanID:o,email:g,id:b})}catch(e){console.log(e,"while connecting websocket")}},[o,w,g]),we=t.useCallback(({data:e})=>{e&&e.size>0&&ae.current&&(E(t=>t.concat(e)),!re.current&&j.current&&(re.current=!0,se(()=>{be(),s.handleScanTimeCapture({eventName:`${w}/tensorFlow`,scanID:o,email:g,message:"recording stopped by tensorflow "})},j)))},[be,s.handleScanTimeCapture,w,o,g,j]),je=t.useCallback(async()=>{K.length>0&&ae.current&&(await s.speechService.playAudio(s.voiceOverAssetsPath+K[K.length-1]),ae.current&&(S=setTimeout(je,2e3)))},[K,ae]),ke=t.useCallback(()=>{k&&k.current&&k.current.stop(),I(!0);try{if(j&&j.current&&j.current.stream){const e=j.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();F.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};oe[0]&&(t.mimeType=oe[0]),k.current=new MediaRecorder(j.current.stream,t),k.current.addEventListener("dataavailable",we),Z([...Y,we]),k.current.start(1e3),_(!1)}}catch(e){console.log("error while using media recorder",e)}},[j,oe,we,Y]),Fe=t.useCallback(async()=>{R.current&&clearTimeout(R.current),ke(),ae.current&&(R.current=setTimeout(async()=>{ae.current&&(await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),I(!1))},15e3)),U(!0),ae.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}Spin.mp3`)},[ke,ae,s.speechService]),Ne=t.useCallback(({data:e})=>{e.size>0&&s.swan.poseDetection.connected()&&(s.swan.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){const t=document.querySelector("#audioElement");!0===e.status&&e.sid===b?me<2?(0===me&&t?.paused&&await s.speechService.playAudio(s.voiceOverAssetsPath+e.audio),me+=1):(B(e.audio),clearTimeout(S),s.swan.poseDetection.disconnect(),setTimeout(Fe,1e3)):(me=0,!t?.paused||C&&C?.audioName===e.audio?C?.audioName===e.audio&&t?.paused&&(C&&C.no_of_times_skipped>=C.skipCount?(C.no_of_times_skipped=0,s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)):C&&(C.no_of_times_skipped+=1)):(C={skipCount:2,no_of_times_skipped:0,audioName:e.audio},s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)))}}),j?.current&&null!==j.current.getScreenshot()&&s.swan.poseDetection.videoEmit({image:j.current.getScreenshot()||"",scanId:o}))},[j,o,s.swan,b,me,Fe,s.speechService]),Ee=t.useCallback(async()=>{$(!0),fe(!0),ne.current&&(ne.current=!1,s.handleScanTimeCapture({eventName:"scan started",scanID:o,status:"success",email:g})),l(s.getCurrentTimeInSeconds()),D(!0),ae.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}StartScan.mp3`),ae.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}LiftArmsAndHoldAtHip.mp3`),ae.current&&($(!1),I(!0),J(!0),te(!0),xe());try{if(j&&j.current&&j.current.stream&&ae.current){const e=j.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();F.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};oe[0]&&(t.mimeType=oe[0]),ae.current&&(k.current=new MediaRecorder(j.current.stream,t)),ae.current&&k.current&&k.current.addEventListener("dataavailable",Ne),Z([...Y,Ne]),k.current&&k.current.start(1e3),_(!1),ae.current&&(S=setTimeout(je,2e3))}}catch(e){console.log("error ----------",e)}},[j,oe,Ne,Y,je,ae]);return t.useEffect(()=>(w&&(n(!0),Ce()),()=>{b&&(s.swan.poseDetection.disconnect(),a.capture(`${w}/pose_detection_disconnected`,{scanID:o,email:g,id:b})),Y.forEach(e=>{k?.current?.removeEventListener("dataavailable",e)})}),[W,w]),t.useEffect(()=>{K.push(V)},[V]),t.useEffect(()=>{O([])},[q]),t.useEffect(()=>{const e=N.length&&N.length>0;P||!e||L||!ae.current||Q||k&&k.current&&(L||(k.current.stop(),_(!0)))},[P,L,N,Q]),t.useEffect(()=>{const e=N.length&&N.length>0;if(P||!e||L)console.log("No video found to upload.");else if(k&&k.current&&ae.current&&!Q&&!L){const e=new File(N,`${o}.webm`,{type:"video/webm"});ge?.(!0),c(""),he?.(e,F.current)}},[P,L,N,Q,k,ae]),t.useEffect(()=>{if("undefined"!=typeof MediaRecorder){const e=s.videoTypes.filter(e=>MediaRecorder.isTypeSupported(e));ie(e)}},[]),t.useEffect(()=>{pe()},[]),e.jsx(p,{resetDetector:r,handleShowStreamCamera:pe,loadingCam:T,handlePause:Se,showRestart:G,pause:Q,handleReScan:ve,recordingStarted:L,isScanning:A,startSendingVideoFrames:Ee,faceDone:M,stopRecording:be,showPause:ee,webcamRef:j,handleUserMedia:xe,handleUserMediaError:ye,videoConstraints:ue,webcamKey:ce,config:m})});function j({scanID:a,userDetails:s,setIsVideoUploaded:n,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:i,config:c}){const[l,u]=t.useState(90),[d,m]=t.useState(0),[f,h]=t.useState(null),[p,x]=t.useState(!1),[y,v]=t.useState(0),S=t.useRef([]),[b,C]=t.useState(!1),j=l-d,k=j>=80&&j<=95;t.useEffect(()=>{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)),u(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})}},[]),t.useEffect(()=>{if(S.current=[...S.current.slice(-4),j],S.current.length>=5){const e=Math.max(...S.current)-Math.min(...S.current);v(k&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}k||null===f&&!p||N()},[j,k,f,p]),t.useEffect(()=>{y>=100&&null===f&&!p&&F(),y<50&&null!==f&&N()},[y,f,p]);const F=()=>{h(3);const e=setInterval(()=>{h(t=>null===t||t<=1?(clearInterval(e),x(!0),null):t-1)},1e3)},N=()=>{h(null),b||x(!1)};return e.jsx(g,{angle:j,countdown:f,isScanning:p,isInTargetRange:k,stabilityScore:y,config:c,children:p&&e.jsx(w,{setIsScanLocked:C,resetDetector:()=>{u(90),m(0),h(null),x(!1),v(0),C(!1),S.current=[]},scanID:a,userDetails:s,setIsVideoUploaded:n,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:i,config:c})})}function k({message:a,config:n}){const{translate:r}=t.useContext(s.LanguageContext)||{};return e.jsx(i.Dialog,{open:!0,className:"confirm-modal",children:e.jsx("div",{className:"modal-main",children:e.jsx("div",{className:"text-center",children:a?e.jsxs(e.Fragment,{children:[e.jsx("h2",{style:{fontFamily:n?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:n?.style?.heading?.headingFontSize||"32px",color:n?.style?.heading?.headingColor||"#000",fontWeight:n?.style?.heading?.headingFontWeight||"normal"},children:r?.(s.LanguageKeys.cameraAlreadyInUse)}),e.jsx("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:n?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:n?.style?.base?.baseFontSize||"16px",color:n?.style?.base?.baseTextColor||"#000"},children:r?.(s.LanguageKeys.tryClosingBrowser)})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{style:{fontFamily:n?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:n?.style?.heading?.headingFontSize||"32px",color:n?.style?.heading?.headingColor||"#000",fontWeight:n?.style?.heading?.headingFontWeight||"normal"},children:r?.(s.LanguageKeys.checkCameraSettings)}),e.jsx("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:n?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:n?.style?.base?.baseFontSize||"16px",color:n?.style?.base?.baseTextColor||"#000"},children:`${r?.(s.LanguageKeys.setting)} > ${s.getBrowserName()} > ${r?.(s.LanguageKeys.enableCameraPermissions)}`})]})})})})}function F({setShowDrawer:a,config:n,loader:o}){const[i,c]=t.useState({disabled:!1,message:""}),[l,u]=t.useState(!0),d=t.useRef(null),m=t.useCallback(async()=>{const e=await s.checkCameraPermission();c(e),u(!1)},[]);return t.useEffect(()=>{m()},[]),l?e.jsx(s.LoadingScreen,{url:o,loaderType:"black"}):i?.disabled?e.jsx(k,{config:n,message:i?.message}):e.jsx(r,{audio:!1,ref:d,screenshotQuality:1,videoConstraints:s.videoConstraints,mirrored:!0,onUserMedia:()=>a?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function N({link:a,onReady:n,wrapperClassName:r="[&_video]:rounded-t-[20px] w-full h-full"}){const o=t.useRef(null),i=t.useRef(null);let l={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:s.videoPoster};return t.useEffect(()=>{if(!i.current&&a&&o?.current){const e=c(o.current,{...l});e.ready(()=>{i.current=e;const t={...l,sources:[{src:a,type:"application/x-mpegURL"}]};e.autoplay(t.autoplay),e.src(t.sources),n?.(e)})}},[a,o]),t.useEffect(()=>{const e=i.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),i.current=null)}},[i]),e.jsx("div",{className:r,children:e.jsx("video",{ref:o,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function E({scanFailsError:a,serverAtCapacity:n=!1,onNext:r,gender:c,setScanUniqueKey:l,resolvedConfig:u,setIsVideoUploaded:d}){const{translate:m}=t.useContext(s.LanguageContext)||{},[f,h]=t.useState(!1),g=()=>{h(!f)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex 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.jsx("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e.jsx(s.Header,{noTitle:!0,resolvedConfig:u})}),e.jsxs("div",{className:"flex-1",children:[a&&e.jsxs("div",{className:"px-[1rem]",children:[e.jsx("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:m?.(s.LanguageKeys.issueWithScan)}),e.jsx("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:m?.(s.LanguageKeys.reason)}),e.jsx("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:s.handleErrorMessage(a)}),e.jsx("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:g,src:s.VIDEO_POSTER_GENDER_BASED[c],alt:"icon"})]}),n&&e.jsxs("div",{className:"p-[1rem] text-center",children:[e.jsx("h3",{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:m?.(s.LanguageKeys.serverAtCapacity)}),e.jsx("p",{className:"text-base mt-[0.5rem]",style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:u?.style?.base?.baseFontSize||"16px",color:u?.style?.base?.baseTextColor||"#1E1E1E"},children:m?.(s.LanguageKeys.serverAtCapacityDescription)})]})]}),a&&e.jsx("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e.jsx(s.SpecificButton,{disabled:!1,buttonText:m?.(s.LanguageKeys.scanAgain),className:"!shadow-none",buttonFunc:()=>{r?r?.():l(s.generateUuid()),d(!1)},resolvedConfig:u})})]}),f&&e.jsxs(i.Dialog,{className:"w-screen h-screen video-modal",onClose:g,open:f,children:[e.jsx("div",{className:"flex justifyEnd ",children:e.jsx("span",{className:"closeBtn",onClick:g,children:e.jsx(o.X,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e.jsx("div",{className:"aspect-video object-cover rounded-[20px] ",children:e.jsx(N,{link:c?s.GENDER[c].PRE_LINK:s.GENDER.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function T({scanId:n,userDetails:r,config:o,isFaceScan:c,isVideoUploadedCorrect:l,isMeasurementAvailable:u,onScanSuccess:d,isSuccess:m,onVideoUploaded:f}){const{gender:h,shopDomain:g,heightInCm:p,deviceFocalLength:x,userName:y,email:v,scanType:S}=r,b=[s.CLOTHING_CUSTOM_SCAN,s.CLOTHING_BANNER_SCAN,s.CLOTHING_CUSTOM_FIT_SCAN].includes(S),[C,w]=t.useState(!0),j=t.useCallback(async()=>{try{b&&(await s.swan.auth.addUser({scanId:n,email:v,name:y,gender:h,height:p}),f?.()),a.posthog.capture(g,{scanID:n,email:v,height:p,focalLength:x,clothesFit:"0",gender:h})}catch(e){console.log(e)}},[b]),{translate:k}=t.useContext(s.LanguageContext)||{};t.useEffect(()=>{(l||u)&&j()},[l,u]);const N=m||(c?u&&l:l||u);return e.jsx(i.Box,{className:"flex h-full w-full flex-col ",children:e.jsxs("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e.jsx(F,{loader:o?.loader,setShowDrawer:w}),e.jsx(i.Drawer,{open:C,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:e.jsx("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:o?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsx(s.Header,{title:k?.(s.LanguageKeys.measurementsBeingTaken),resolvedConfig:o}),e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx("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.jsx("source",{src:h===s.GenderType.Male?s.maleMeasurementProgress:s.measurementProgress,type:"video/mp4"})})}),N&&e.jsx(s.SpecificButton,{resolvedConfig:o,className:"!w-[180px] mx-auto",buttonText:k?.(s.LanguageKeys.next),buttonFunc:()=>{d?.(),f?.()}})]})})})]})})}const D=()=>{const{userDetails:a,config:n,onRetry:r,isError:o,isSuccess:c,onScanSuccess:l,gender:u,scanUniqueKey:d,scanFailsError:m,setScanUniqueKey:f,setIsVideoUploaded:h,isMeasurementAvailable:g,isVideoUploadedCorrect:p,loading:x,showDeniedModal:y,uploadLoading:v,setScanFailsError:S,setScanStartTime:b,handleShowStreamCamera:C,onVideoUploaded:w}=t.useContext(s.ParamsContext),{setPreferredLanguage:N}=t.useContext(s.LanguageContext)||{},D=s.useLocalConfig(n);return t.useEffect(()=>{N?.(D?.language)},[D]),o?e.jsxs(e.Fragment,{children:[e.jsx(F,{}),e.jsx(i.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(E,{scanFailsError:m||o,onNext:()=>{r?.(),C()},setScanUniqueKey:f,gender:u,resolvedConfig:D,setIsVideoUploaded:h})})]}):c?e.jsx(T,{isFaceScan:!1,scanId:d,isMeasurementAvailable:g,userDetails:a,isVideoUploadedCorrect:p,config:D,isSuccess:c,onVideoUploaded:w}):x?e.jsx("div",{className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:D?.style?.base?.backgroundColor},children:e.jsx(s.LoadingScreen,{url:D?.loader,loaderType:"black"})}):y.disabled?e.jsx(k,{}):v||m||g||p?(v||g||p)&&!m?e.jsx(T,{isFaceScan:!1,scanId:d,isMeasurementAvailable:g,userDetails:a,onScanSuccess:l,isVideoUploadedCorrect:p,config:D,onVideoUploaded:w}):e.jsxs(e.Fragment,{children:[e.jsx(F,{}),e.jsx(i.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(E,{scanFailsError:m,onNext:()=>{r?.(),C()},setScanUniqueKey:f,gender:u,resolvedConfig:D,setIsVideoUploaded:h})})]}):e.jsx(j,{config:D,scanID:d,userDetails:a,setIsVideoUploaded:h,setScanFailsError:S,setScanStartTime:b,setScanUniqueKey:f})};exports.BodyScan=({userDetails:n,config:r,onRetry:o,onScanError:i,isError:c,isSuccess:l,onScanSuccess:u,onVideoUploaded:d})=>{const{gender:m,scanType:h,shopDomain:g,heightInCm:p,email:x,deviceFocalLength:y,deviceModelName:v,callbackUrl:S}=n,[b,C]=t.useState(!1),[w,j]=t.useState(!1),[k,F]=t.useState(!1),[N,E]=t.useState({disabled:!1,message:""}),[T,L]=t.useState(""),[I,M]=t.useState(!1),[U,P]=t.useState(!0),[_,A]=t.useState(!1),[$,R]=t.useState(""),[V,z]=t.useState(s.getCurrentTimeInSeconds()),{gyroData:K}=function(e){const[a,s]=t.useState([]),[n,r]=t.useState(!1),o=t.useCallback(e=>{try{const{alpha:t,beta:a,gamma:n}=e;s(e=>[...e,{alpha:t?.toString()||void 0,beta:a?.toString()||void 0,gamma:n?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),i=t.useCallback(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?r(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else r(!0)},[]);return t.useEffect(()=>(e&&n?window.addEventListener("deviceorientation",o):s([]),()=>{window.removeEventListener("deviceorientation",o)}),[e,n,o]),t.useEffect(()=>{e&&i()},[e,i]),{gyroData:a}}(_),O=t.useCallback(()=>{R(s.generateUuid()),L(""),C(!1),M(!1)},[]),q=e=>{i({...e,message:s.handleErrorMessage(e)}),B(),F(!1),L(e),j(!1),s.handleScanTimeCapture({eventName:`${g}/measurement_failed/fit-view`,scanID:$,status:"failed",email:x,message:s.handleErrorMessage(e)}),V&&s.handleScanTimeCapture({eventName:`${g}/scan_completion_time`,scanID:$,status:"failed",completionTime:s.getCurrentTimeInSeconds()-V,email:x})},B=()=>{z(null),R("")};function W(e){return new Promise(t=>{const a=document.createElement("video");a.preload="auto",a.muted=!0,a.playsInline=!0;const s=URL.createObjectURL(e);a.src=s;const n=setTimeout(()=>{a.pause(),URL.revokeObjectURL(s),t(null)},3e3),r=()=>{clearTimeout(n),a.pause(),a.currentTime=0,a.removeEventListener("timeupdate",onTimeUpdate),a.removeEventListener("seeked",onSeeked),URL.revokeObjectURL(s)};let o=!1;const i=()=>{let e=0,s=-1;const n=performance.now();a.addEventListener("timeupdate",()=>{if(o)return;const i=a.currentTime;Math.abs(i-s)>.001&&(e++,s=i);const c=(performance.now()-n)/1e3;if((c>=1.5||a.currentTime>=1.5)&&!o){o=!0;const a=c>0?e/c:null;r(),t(a&&a>0?a:null)}}),a.play().then(()=>{setTimeout(()=>{if(!o){o=!0;const a=(performance.now()-n)/1e3,s=a>0?e/a:null;r(),t(s&&s>0?s:null)}},2500)}).catch(()=>{o||(o=!0,r(),t(null))})};a.onloadedmetadata=()=>{if(!o)return!a.duration||a.duration<=0?(o=!0,r(),void t(null)):void(()=>{if(a.requestVideoFrameCallback){let e=0;const s=performance.now();let n=null;const c=()=>{if(o)return;e++;const i=(performance.now()-s)/1e3;if(i>=1){if(!o){o=!0,null!==n&&a.cancelVideoFrameCallback&&a.cancelVideoFrameCallback(n);const s=e;r(),t(s>0?s:null)}}else if(i<2)n=a.requestVideoFrameCallback(c);else if(!o){o=!0,null!==n&&a.cancelVideoFrameCallback&&a.cancelVideoFrameCallback(n);const s=i>0?e/i:null;r(),t(s&&s>0?s:null)}};a.play().then(()=>{n=a.requestVideoFrameCallback(c),setTimeout(()=>{!o&&null!==n&&a.cancelVideoFrameCallback&&(a.cancelVideoFrameCallback(n),i())},2500)}).catch(()=>{o||i()})}else i()})()},a.oncanplay=()=>{o||void 0===a.webkitDecodedFrameCount||setTimeout(()=>{if(!o&&a.webkitDecodedFrameCount&&a.webkitDecodedFrameCount>0&&a.duration>0){o=!0;const e=a.webkitDecodedFrameCount/a.duration;r(),t(e)}},500)},a.onerror=()=>{o||(o=!0,r(),t(null))}})}const H=t.useCallback(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return s.handleScanTimeCapture({eventName:`${g}/measurement_success/intermediate`,scanID:$,status:"success",email:x}),void j(!0);j(!0),B();const t=$;F(!0),s.handleScanTimeCapture({eventName:`${g}/measurement_success/fit-view`,scanID:t,status:"success",email:x}),V&&s.handleScanTimeCapture({eventName:`${g}/scan_completion_time`,scanID:t,status:"success",completionTime:s.getCurrentTimeInSeconds()-V,email:x})},[h,g,$]),G=e=>{F(!1),L(""),j(!1),s.swan.measurement.handleMeasurementSocket({scanId:e||$,onPreopen:()=>{s.handleWebSocketCapture({eventName:`${g}/webSocket`,scanID:$,connection:"pre_open",type:"measurement_recommendation",email:x})},onOpen:()=>{s.handleWebSocketCapture({eventName:`${g}/webSocket`,scanID:$,connection:"open",type:"measurement_recommendation",email:x})},onClose:()=>s.handleWebSocketCapture({eventName:`${g}/webSocket`,scanID:$,connection:"close",type:"measurement_recommendation",email:x}),onError:e=>{q(e),s.handleWebSocketCapture({eventName:`${g}/webSocket`,scanID:$,connection:"error",type:"measurement_recommendation",email:x})},onSuccess:e=>{s.handleWebSocketCapture({eventName:`${g}/webSocket`,scanID:$,connection:"success",type:"measurement_recommendation",email:x}),H(e)}})},J=t.useCallback(async(e,t)=>{const a=Number((e.size/1048576).toFixed(2)),n=null!=t?t:await Promise.race([W(e),new Promise(e=>setTimeout(()=>e(null),2e3))]),r=s.createObjectMetadataArray({gender:m,focal_length:`${y}`,height:`${p}`,customer_store_url:g,clothes_fit:"0",scan_type:h,callback_url:S});s.handleScanTimeCapture({eventName:`${g}/body_scan_meta_data`,scanID:$,email:x,data:JSON.stringify([...r,{fileSizeInMB:a,video_fps:n||0}])});try{await s.swan.fileUpload.uploadFileFrontend({file:e,arrayMetaData:r,scanId:$,email:x}),await s.swan.fileUpload.setDeviceInfo({model:v,detection:"manual",gyro:K,scanId:$}),console.log("video successfully uploaded"),M(!1),s.handleScanTimeCapture({eventName:`${g}/scan_success`,scanID:$,status:"success",email:x,data:JSON.stringify(r)}),s.handleScanTimeCapture({eventName:"scan finished",scanID:$,status:"success",email:x}),z(s.getCurrentTimeInSeconds()),setTimeout(()=>{M(!0)},3e3)}catch(e){s.handleScanTimeCapture({eventName:"scan finished",scanID:$,status:"failed",email:x,message:s.handleErrorMessage(e)}),s.handleScanTimeCapture({eventName:`${g}/scan_failed`,scanID:$,status:"failed",email:x,message:s.handleErrorMessage(e),data:JSON.stringify(r)}),L(s.handleErrorMessage(e)),M(!1),console.log(e,"video upload failed")}finally{A(!1)}},[$,K]),Q=t.useCallback(async e=>{try{const t=await s.swan.measurement.getMeasurementResult(e),a=t?.data?.isMeasured,n=V||s.getCurrentTimeInSeconds(),r=s.getCurrentTimeInSeconds(),o=300;if(P(!1),!1===a)return B(),void R(s.generateUuid());C(!0),!0===a?await H(null):null===a&&n>r+o?q(t?.data?.error):G(e)}catch(e){console.log(e),B(),R(s.generateUuid()),C(!1)}},[q,H,R]),X=t.useCallback(async()=>{if(+p<152.4||+p>213.36)return void i({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await s.checkCameraPermission();if(e.disabled)s.handleScanTimeCapture({eventName:`${g}/camera_activation`,scanID:$,status:"failed",email:x}),P(!1);else{$?Q($):P(!1),s.handleScanTimeCapture({eventName:`${g}/camera_activation`,scanID:$,status:"success",email:x})}E(e),L(""),M(!1)},[Q,x,$,R,g]);return t.useEffect(()=>{a.init(s.posthogPublicKey,{api_host:s.posthogPublicHost}),a.capture("$pageview")},[]),t.useEffect(()=>{c||l||g&&X()},[g,p,c,l]),t.useEffect(()=>{c||l||I&&g&&$&&G()},[I,g,$,c,l]),e.jsx(s.LanguageContextProvider,{children:e.jsx(f,{children:e.jsx(s.ParamsContext.Provider,{value:{userDetails:n,config:r,onRetry:o,onScanError:i,isError:c,isSuccess:l,onScanSuccess:u,gender:m,scanUniqueKey:$,scanFailsError:T,setScanUniqueKey:R,setIsVideoUploaded:M,isMeasurementAvailable:k,isVideoUploadedCorrect:w,loading:U,showDeniedModal:N,uploadLoading:b,setStartGyro:A,handleFileUpload:J,setUploadLoading:C,handleShowStreamCamera:O,setScanFailsError:L,setScanStartTime:z,onVideoUploaded:d},children:e.jsx(D,{})})})})};
|
|
2
|
+
//# sourceMappingURL=BodyScan-BLHAo6qL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BodyScan-BLHAo6qL.js","sources":["../src/utils/context/mediaContext.tsx","../src/Icons/SwitchIcon.tsx","../src/components/bodyScan/LevelScreen.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 React from \"react\";\n\nfunction SwitchIcon({ size = 16 }: { size?: number }) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n 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\"\n stroke=\"white\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n 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\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n 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\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n 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\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n 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\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nexport default React.memo(SwitchIcon);\n","/* eslint-disable no-nested-ternary */\n\nimport React, { useCallback, useContext, useMemo } from \"react\";\nimport Header from \"../Header\";\nimport cn from \"clsx\";\nimport { LevelScreenProps } from \"../../types/interfaces\";\nimport SwitchIcon from \"../../Icons/SwitchIcon\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\n\nfunction LevelScreen({ angle, countdown, isScanning, isInTargetRange, stabilityScore, children, config }: LevelScreenProps) {\n\tconst { translate } = useContext(LanguageContext) || {};\n\n\tconst getProximityToTarget = useCallback(() => {\n\t\tif (angle < 80) return Math.max(0, Math.min(100, (angle - 60) * 10));\n\t\tif (angle > 95) return Math.max(0, Math.min(100, (105 - angle) * 10));\n\t\treturn 100;\n\t}, [angle]);\n\n\tconst backgroundColor = useMemo(() => {\n\t\tif (isScanning) return config?.style?.angleDetector?.successAngleBackground || \"#4f46e5\";\n\n\t\tconst proximity = getProximityToTarget();\n\t\tif (proximity === 0) return config?.style?.angleDetector?.successAngleLowBackground || \"#ffffff\";\n\t\tif (proximity === 100) return config?.style?.angleDetector?.successAngleBackground || \"#4f46e5\";\n\n const r = Math.round(255 - (255 - 139) * (proximity / 100));\n const g = Math.round(255 - (255 - 92) * (proximity / 100));\n const b = Math.round(255 - (255 - 246) * (proximity / 100));\n return `rgb(${r}, ${g}, ${b})`;\n }, [isScanning, getProximityToTarget]);\n\n\tconst handelTextColour = useCallback((isLight: boolean, proximity: number) => {\n\t\tif (proximity > 70) {\n\t\t\treturn isLight ? `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]/70` : `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]`;\n\t\t}\n\t\treturn isLight ? `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]/40` : `text-[${config?.style?.angleDetector?.successAngleTextDarkColor}]/70`;\n\t}, []);\n\n\tconst getTextColor = useCallback(\n\t\t(isLight = false) => {\n\t\t\tconst proximity = getProximityToTarget();\n\t\t\tif (isScanning) return `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]`;\n\t\t\treturn handelTextColour(isLight, proximity);\n\t\t},\n\t\t[isScanning, getProximityToTarget],\n\t);\n\n\tconst handelColourCode = useCallback((isLight: boolean, proximity: number) => {\n\t\tif (proximity > 70) {\n\t\t\treturn isLight ? config?.style?.angleDetector?.successAngleTextLightColor : config?.style?.angleDetector?.successAngleTextLightColor;\n\t\t}\n\t\treturn isLight ? config?.style?.angleDetector?.successAngleTextLightColor : config?.style?.angleDetector?.successAngleTextDarkColor;\n\t}, []);\n\tconst getColorCode = useCallback(\n\t\t(isLight = false) => {\n\t\t\tconst proximity = getProximityToTarget();\n\t\t\tif (isScanning) return config?.style?.angleDetector?.successAngleTextLightColor;\n\t\t\treturn handelColourCode(isLight, proximity);\n\t\t},\n\t\t[isScanning, getProximityToTarget],\n\t);\n\tconst cd = countdown;\n\tfunction fixVh() {\n\t\tdocument.documentElement.style.setProperty(\"--real-vh\", window.innerHeight + \"px\");\n\t}\n\tfixVh();\n\twindow.addEventListener(\"resize\", fixVh);\n\treturn (\n\t\t<div\n\t\t\tclassName=\"flex 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\"\n\t\t\tstyle={{ backgroundColor }}\n\t\t\t// onDoubleClick={onDoubleClick}\n\t\t>\n\t\t\t<div className=\"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]\">\n\t\t\t\t<div className=\"flex justify-start \">\n\t\t\t\t\t<Header noTitle resolvedConfig={config} />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{cd !== null ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tborder: `2px solid ${getColorCode()}`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`text-[3rem] font-bold text-[${getColorCode()}]`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{cd}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : isScanning ? (\n\t\t\t\t<div className=\"relative flex flex-col items-center justify-center\">\n\t\t\t\t\t<div className=\"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]\">\n\t\t\t\t\t\t<div className=\"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\tclassName={cn(\"relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] \", isInTargetRange ? \"bg-[#fff]/20 border-[#fff]\" : \"bg-[#fff]/10 border-[#fff]\")}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\ttransform: `translateY(${(90 - angle) * 3}px)`,\n\t\t\t\t\t\ttransition: \"transform 0.2s ease-out\",\n\t\t\t\t\t\tborder: `2px solid ${getColorCode()}`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div className={`h-[1rem] w-[1rem] rounded-[9999px] bg-[${getColorCode()}]/80`}\n style={{\n\t\t\t\t\t\tbackgroundColor: `${getColorCode()}B3`,\n\t\t\t\t\t}}\n />\n\t\t\t\t\t<div\n\t\t\t\t\t\t// className=\" text-[#fff]\"\n\t\t\t\t\t\tclassName={cn(\"mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]\", getTextColor())}\n style={{\n\t\t\t\t\t\tcolor: getColorCode(),\n\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SwitchIcon size={30} />\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{\" \"}\n\t\t\t\t\t\t\t{translate?.(LanguageKeys.startLevelCheck)}\n\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{cd !== null && (\n\t\t\t\t<div className=\"absolute bottom-[8rem] text-center\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\"text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8\", getTextColor())}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{translate?.(LanguageKeys.leavePhone)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{isInTargetRange && cd === null && !isScanning && (\n\t\t\t\t<div className=\"absolute bottom-[8rem] w-[12rem]\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`h-[.375rem] w-full bg-[${getColorCode()}]/20 rounded-[9999px] overflow-hidden`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackgroundColor: `${getColorCode()}33`, // 20% opacity\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={`h-full bg-[${getColorCode()}]/70 transition-all duration-300 rounded-[9999px]`}\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: `${angle}%`,\n\t\t\t\t\t\t\t\tbackgroundColor: `${getColorCode()}B3`,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n {cd === null && !isScanning && (\n <div className=\"absolute bottom-[5rem] text-center\">\n <div className={cn(\"text-[1.5rem] font-light\", getTextColor())}\n style={{\n\t\t\t\t\t\tcolor: getColorCode(),\n\t\t\t\t\t}}\n >\n {Math.round(angle)}°\n </div>\n </div>\n )}\n\n\t\t\t{cd === null && !isScanning && (\n\t\t\t\t<div className=\"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\"text-[.75rem] opacity-50\", getTextColor())}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{translate?.(LanguageKeys.placePhoneUpright)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\nexport default React.memo(LevelScreen);\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 handleShowStreamCamera,\n loadingCam,\n handleUserMedia,\n handlePause,\n pause,\n recordingStarted,\n startSendingVideoFrames,\n showPause,\n webcamRef,\n handleUserMediaError,\n resetDetector,\n videoConstraints,\n webcamKey,\n config,\n}: CameraScanChildProps) {\n const { media } = useContext(MediaContext) || {};\n const { translate } = useContext(LanguageContext) || {};\n\n return (\n <div className=\"App w-screen h-[100vh] relative \">\n <span\n onClick={() => {\n handleShowStreamCamera();\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={handleUserMedia}\n onUserMediaError={handleUserMediaError}\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={handlePause}\n resolvedConfig={config}\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={handleShowStreamCamera}\n resolvedConfig={config}\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 resolvedConfig={config}\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, useRef, useState } from \"react\";\nimport CameraScanChild from \"./CameraScanChild\";\nimport posthog from \"posthog-js\";\nimport Webcam from \"react-webcam\";\nimport { ScanningComponentProps } from \"../../types/interfaces\";\nimport useTensorFlow from \"../../customHooks/useTensorFlow\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport { generateUuid, getCurrentTimeInSeconds, handleScanTimeCapture, rescanSupportCaptureEvent } from \"../../utils/utils\";\nimport speechService from \"../../utils/service/speechService\";\nimport swan from \"../../utils/service/swanService\";\nimport { videoConstraintsExact, videoConstraintsFallback, videoTypes, voiceOverAssetsPath } from \"../../utils/constants\";\n\nlet id: string | null = null;\nlet audioTimeoutId: number | undefined | NodeJS.Timeout;\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, config }: ScanningComponentProps) {\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<number | null | NodeJS.Timeout>(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 [supportedTypes, setSupportedTypes] = useState<string[]>([]);\n\tconst [webcamKey, setWebcamKey] = useState(0);\n\tconst [currentVideoConstraints, setCurrentVideoConstraints] = useState<MediaTrackConstraints>(videoConstraintsExact);\n\n\tlet counter = 0;\n\n\tconst { setStartGyro, handleFileUpload, setUploadLoading } = useContext(ParamsContext);\n\n\tconst handleShowStreamCamera = () => {\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\tcounter = 0;\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 handleReScan = useCallback(() => {\n\t\trescanSupportCaptureEvent({\n\t\t\teventName: `${shopDomain}/rescan`,\n\t\t\temail,\n\t\t\tscanID: scanID,\n\t\t\theight: heightInCm,\n\t\t\tgender,\n\t\t\tstatus: false,\n\t\t});\n\t\tallowAudioToPlay.current = false;\n\t\thandleShowStreamCamera();\n\t\tstartSendingVideoFrames();\n\t}, [handleShowStreamCamera, scanID, email]);\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\tcounter = 0;\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\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\n\t\t\tposthog.capture(`${shopDomain}/pose_detection_connected`, {\n\t\t\t\tscanID: scanID,\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}, [scanID, shopDomain, email]);\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: scanID,\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, scanID, 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\tconst handleDataAvailable = useCallback(\n\t\t({ data }: BlobEvent) => {\n\t\t\tif (data.size > 0 && swan.poseDetection.connected()) {\n\t\t\t\tswan.poseDetection.poseStatus(async (data) => {\n\t\t\t\t\tif (data && data.audio && data.audio.length > 0) {\n\t\t\t\t\t\tconst audio = document.querySelector(\"#audioElement\") as HTMLAudioElement | null;\n\t\t\t\t\t\tif (data.status === true && data.sid === id) {\n\t\t\t\t\t\t\tif (counter < 2) {\n\t\t\t\t\t\t\t\tif (counter === 0 && audio?.paused) {\n\t\t\t\t\t\t\t\t\tawait speechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcounter += 1;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tsetEmptyAudioSource(data.audio);\n\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\tswan.poseDetection.disconnect();\n\t\t\t\t\t\t\t\tsetTimeout(postPoseProcess, 1000);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcounter = 0;\n\t\t\t\t\t\t\tif (audio?.paused && (!lastVideoPlayed || lastVideoPlayed?.audioName !== data.audio)) {\n\t\t\t\t\t\t\t\tlastVideoPlayed = {\n\t\t\t\t\t\t\t\t\tskipCount: 2,\n\t\t\t\t\t\t\t\t\tno_of_times_skipped: 0,\n\t\t\t\t\t\t\t\t\taudioName: data.audio,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t} else if (lastVideoPlayed?.audioName === data.audio && audio?.paused) {\n\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\tlastVideoPlayed.no_of_times_skipped = 0;\n\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t} else {\n\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}\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: scanID,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[webcamRef, scanID, swan, id, counter, postPoseProcess, speechService],\n\t);\n\n\tconst startSendingVideoFrames = useCallback(async () => {\n\t\tsetIsScanning(true);\n\t\tsetStartGyro(true);\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: scanID,\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([...events, 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, events, playAudio, allowAudioToPlay]);\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: scanID,\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}, [startAgain, 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}.webm`, {\n\t\t\t\t\t\ttype: \"video/webm\",\n\t\t\t\t\t});\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\thandleFileUpload?.(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\tif (typeof MediaRecorder !== \"undefined\") {\n\t\t\tconst supported = videoTypes.filter((type) => MediaRecorder.isTypeSupported(type));\n\t\t\tsetSupportedTypes(supported);\n\t\t}\n\t}, []);\n\tuseEffect(() => {\n\t\thandleShowStreamCamera();\n\t}, []);\n\n\treturn (\n\t\t<CameraScanChild\n\t\t\tresetDetector={resetDetector}\n\t\t\thandleShowStreamCamera={handleShowStreamCamera}\n\t\t\tloadingCam={loadingCam}\n\t\t\thandlePause={handlePause}\n\t\t\tshowRestart={showRestart}\n\t\t\tpause={pause}\n\t\t\thandleReScan={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\thandleUserMedia={handleUserMedia}\n\t\t\thandleUserMediaError={handleUserMediaError}\n\t\t\tvideoConstraints={currentVideoConstraints}\n\t\t\twebcamKey={webcamKey}\n\t\t\tconfig={config}\n\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 config,\n}: AngleDetectorProps) {\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 config={config}\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 config={config}\n />\n )}\n </LevelScreen>\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\">\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\";\n// import \"video.js/dist/video-js.css\";\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\";\n\nfunction ScanErrorMessage({ scanFailsError, serverAtCapacity = false, onNext, gender, setScanUniqueKey, resolvedConfig, setIsVideoUploaded }: ScanErrorMessageProps) {\n\tconst { translate } = useContext(LanguageContext) || {};\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 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 resolvedConfig={resolvedConfig} />\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\t{serverAtCapacity && (\n\t\t\t\t\t\t<div className=\"p-[1rem] text-center\">\n\t\t\t\t\t\t\t<h3\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.serverAtCapacity)}\n\t\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName=\"text-base mt-[0.5rem]\"\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.serverAtCapacityDescription)}\n\t\t\t\t\t\t\t</p>\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} resolvedConfig={resolvedConfig} />\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 \"posthog-js\";\nimport Header from \"./Header\";\nimport CameraPermission from \"./bodyScan/CameraPermission\";\nimport { UserDetails } 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\";\nimport swan from \"../utils/service/swanService\";\n\nfunction SignUp({\n\tscanId,\n\tuserDetails,\n\tconfig,\n\tisFaceScan,\n\tisVideoUploadedCorrect,\n\tisMeasurementAvailable,\n\tonScanSuccess,\n\tisSuccess,\n\tonVideoUploaded\n}: {\n\tconfig?: any;\n\tisFaceScan: boolean;\n\tscanId: string;\n\tisVideoUploadedCorrect?: boolean;\n\tisMeasurementAvailable?: boolean;\n\tuserDetails: UserDetails;\n\tonScanSuccess?: () => void;\n\tisSuccess?: boolean;\n\tonVideoUploaded?: () => void;\n}) {\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\tonVideoUploaded?.();\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 || (isFaceScan ? isMeasurementAvailable && isVideoUploadedCorrect : isVideoUploadedCorrect || isMeasurementAvailable);\n\n\treturn (\n\t\t<Box className=\"flex h-full w-full flex-col \">\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)} resolvedConfig={config} />\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 resolvedConfig={config} className=\"!w-[180px] mx-auto\" buttonText={translate?.(LanguageKeys.next)} buttonFunc={()=>{onScanSuccess?.()\n\t\t\t\t\t\t\t\tonVideoUploaded?.();\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, useEffect } 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 { LanguageContext } from \"../../utils/context/languageContext\";\nimport { useLocalConfig } from \"../../config/useLocalConfig\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\n\nexport const BodyScanSteps = () => {\n\tconst {\n\t\tuserDetails,\n\t\tconfig,\n\t\tonRetry,\n\t\tisError,\n\t\tisSuccess,\n\t\tonScanSuccess,\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\thandleShowStreamCamera,\n\t\tonVideoUploaded\n\t} = useContext(ParamsContext);\n\tconst { setPreferredLanguage } = useContext(LanguageContext) || {};\n\tconst resolvedConfig = useLocalConfig(config);\n\n\tuseEffect(() => {\n\t\tsetPreferredLanguage?.(resolvedConfig?.language);\n\t}, [resolvedConfig]);\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\n\t\t\t\t\t\tscanFailsError={scanFailsError || isError}\n\t\t\t\t\t\tonNext={() => {\n\t\t\t\t\t\t\tonRetry?.();\n\t\t\t\t\t\t\thandleShowStreamCamera();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t\t\t\tgender={gender}\n\t\t\t\t\t\tresolvedConfig={resolvedConfig}\n\t\t\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\t\t/>\n\t\t\t\t</Drawer>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif (isSuccess) {\n\t\treturn (\n\t\t\t<SignUp\n\t\t\t\tisFaceScan={false}\n\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\t// onComplete={onComplete}\n\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t\tisSuccess={isSuccess}\n\t\t\t\tonVideoUploaded={onVideoUploaded}\n\t\t\t/>\n\t\t);\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\"\n style={{ background: resolvedConfig?.style?.base?.backgroundColor }}\n >\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\tconfig={resolvedConfig}\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\tisFaceScan={false}\n\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tonScanSuccess={onScanSuccess}\n\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t\tonVideoUploaded={onVideoUploaded}\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\thandleShowStreamCamera();\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\tresolvedConfig={resolvedConfig}\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\";\n\"use client\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport posthog from \"posthog-js\";\nimport useGyroSensor from \"../../customHooks/useGyroSensor\";\nimport { checkCameraPermission, createObjectMetadataArray, generateUuid, getCurrentTimeInSeconds, handleErrorMessage, handleScanTimeCapture, handleWebSocketCapture } from \"../../utils/utils\";\nimport LanguageContextProvider from \"../../utils/context/languageContext\";\nimport swan from \"../../utils/service/swanService\";\nimport { posthogPublicHost, posthogPublicKey } from \"../../utils/constants\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport MediaContextProvider from \"../../utils/context/mediaContext\";\nimport { BodyScanProps } from \"../../bodyScan\";\nimport { BodyScanSteps } from \"./BodyScanSteps\";\n\nconst clothesFit = \"0\";\n\nexport const BodyScan: React.FC<BodyScanProps> = ({ userDetails, config, onRetry, onScanError, isError, isSuccess, onScanSuccess, onVideoUploaded }) => {\n\tconst { gender, scanType, shopDomain, heightInCm, email, deviceFocalLength, deviceModelName, callbackUrl } = userDetails;\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\n\tconst handleShowStreamCamera = 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\tfunction getVideoFPS(file:File) {\n\t\treturn new Promise((resolve) => {\n\t\t const video = document.createElement(\"video\") as HTMLVideoElement & {\n\t\t\twebkitDecodedFrameCount?: number;\n\t\t\trequestVideoFrameCallback?: (callback: () => void) => number;\n\t\t\tcancelVideoFrameCallback?: (handle: number) => void;\n\t\t\tgetVideoPlaybackQuality?: () => { totalVideoFrames: number; droppedVideoFrames: number };\n\t\t };\n\t\t video.preload = \"auto\";\n\t\t video.muted = true;\n\t\t video.playsInline = true;\n\t\t const objectUrl = URL.createObjectURL(file);\n\t\t video.src = objectUrl;\n\t\t \n\t\t // Overall timeout to prevent hanging\n\t\t const overallTimeout = setTimeout(() => {\n\t\t\tvideo.pause();\n\t\t\tURL.revokeObjectURL(objectUrl);\n\t\t\tresolve(null);\n\t\t }, 3000);\n\t \n\t\t const cleanup = () => {\n\t\t\tclearTimeout(overallTimeout);\n\t\t\tvideo.pause();\n\t\t\tvideo.currentTime = 0;\n\t\t\tvideo.removeEventListener(\"timeupdate\", onTimeUpdate);\n\t\t\tvideo.removeEventListener(\"seeked\", onSeeked);\n\t\t\tURL.revokeObjectURL(objectUrl);\n\t\t };\n\t\t \n\t\t let resolved = false;\n\t\t \n\t\t // Method 1: Try webkitDecodedFrameCount first (Safari/WebKit) - most reliable when available\n\t\t const tryWebkitMethod = () => {\n\t\t\tif (video.webkitDecodedFrameCount !== undefined) {\n\t\t\t video.play().then(() => {\n\t\t\t\t// Wait for frames to decode\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t if (!resolved && video.webkitDecodedFrameCount && video.webkitDecodedFrameCount > 0 && video.duration > 0) {\n\t\t\t\t\tresolved = true;\n\t\t\t\t\tconst fps = video.webkitDecodedFrameCount / video.duration;\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve(fps);\n\t\t\t\t } else if (!resolved) {\n\t\t\t\t\ttryTimeUpdateMethod();\n\t\t\t\t }\n\t\t\t\t}, 1500);\n\t\t\t }).catch(() => {\n\t\t\t\tif (!resolved) tryTimeUpdateMethod();\n\t\t\t });\n\t\t\t} else {\n\t\t\t tryTimeUpdateMethod();\n\t\t\t}\n\t\t };\n\t\t \n\t\t // Method 2: Use timeupdate events to count frames (works in most browsers)\n\t\t const tryTimeUpdateMethod = () => {\n\t\t\tlet frameCount = 0;\n\t\t\tlet lastTime = -1;\n\t\t\tconst startTime = performance.now();\n\t\t\t\n\t\t\tconst onTimeUpdate = () => {\n\t\t\t if (resolved) return;\n\t\t\t const currentTime = video.currentTime;\n\t\t\t if (Math.abs(currentTime - lastTime) > 0.001) {\n\t\t\t\tframeCount++;\n\t\t\t\tlastTime = currentTime;\n\t\t\t }\n\t\t\t \n\t\t\t const elapsed = (performance.now() - startTime) / 1000;\n\t\t\t if (elapsed >= 1.5 || video.currentTime >= 1.5) {\n\t\t\t\tif (!resolved) {\n\t\t\t\t resolved = true;\n\t\t\t\t const fps = elapsed > 0 ? frameCount / elapsed : null;\n\t\t\t\t cleanup();\n\t\t\t\t resolve(fps && fps > 0 ? fps : null);\n\t\t\t\t}\n\t\t\t }\n\t\t\t};\n\t\t\t\n\t\t\tvideo.addEventListener(\"timeupdate\", onTimeUpdate);\n\t\t\tvideo.play().then(() => {\n\t\t\t // Safety timeout\n\t\t\t setTimeout(() => {\n\t\t\t\tif (!resolved) {\n\t\t\t\t resolved = true;\n\t\t\t\t const elapsed = (performance.now() - startTime) / 1000;\n\t\t\t\t const fps = elapsed > 0 ? frameCount / elapsed : null;\n\t\t\t\t cleanup();\n\t\t\t\t resolve(fps && fps > 0 ? fps : null);\n\t\t\t\t}\n\t\t\t }, 2500);\n\t\t\t}).catch(() => {\n\t\t\t if (!resolved) {\n\t\t\t\tresolved = true;\n\t\t\t\tcleanup();\n\t\t\t\tresolve(null);\n\t\t\t }\n\t\t\t});\n\t\t };\n\t\t\t\t\n\t\t // Method 3: Try requestVideoFrameCallback (Chrome/Edge)\n\t\t const tryRequestVideoFrameCallback = () => {\n\t\t\tif (video.requestVideoFrameCallback) {\n\t\t\t let frameCount = 0;\n\t\t\t const startTime = performance.now();\n\t\t\t let callbackHandle: number | null = null;\n\t\t\t \n\t\t\t const countFrame = () => {\n\t\t\t\tif (resolved) return;\n\t\t\t\tframeCount++;\n\t\t\t\tconst elapsed = (performance.now() - startTime) / 1000;\n\t\t\t\t\n\t\t\t\tif (elapsed >= 1) {\n\t\t\t\t if (!resolved) {\n\t\t\t\t\tresolved = true;\n\t\t\t\t\tif (callbackHandle !== null && video.cancelVideoFrameCallback) {\n\t\t\t\t\t video.cancelVideoFrameCallback(callbackHandle);\n\t\t\t\t\t}\n\t\t\t\t\tconst fps = frameCount;\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve(fps > 0 ? fps : null);\n\t\t\t\t }\n\t\t\t\t} else if (elapsed < 2) {\n\t\t\t\t callbackHandle = video.requestVideoFrameCallback(countFrame);\n\t\t\t\t} else {\n\t\t\t\t if (!resolved) {\n\t\t\t\t\tresolved = true;\n\t\t\t\t\tif (callbackHandle !== null && video.cancelVideoFrameCallback) {\n\t\t\t\t\t video.cancelVideoFrameCallback(callbackHandle);\n\t\t\t\t\t}\n\t\t\t\t\tconst fps = elapsed > 0 ? frameCount / elapsed : null;\n\t\t\t\t\tcleanup();\n\t\t\t\t\tresolve(fps && fps > 0 ? fps : null);\n\t\t\t\t }\n\t\t\t\t}\n\t\t\t };\n\t\t\t \n\t\t\t video.play().then(() => {\n\t\t\t\tcallbackHandle = video.requestVideoFrameCallback(countFrame);\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t if (!resolved && callbackHandle !== null && video.cancelVideoFrameCallback) {\n\t\t\t\t\tvideo.cancelVideoFrameCallback(callbackHandle);\n\t\t\t\t\ttryTimeUpdateMethod();\n\t\t\t\t }\n\t\t\t\t}, 2500);\n\t\t\t }).catch(() => {\n\t\t\t\tif (!resolved) tryTimeUpdateMethod();\n\t\t\t });\n\t\t\t} else {\n\t\t\t tryTimeUpdateMethod();\n\t\t\t}\n\t\t };\n\t \n\t\t video.onloadedmetadata = () => {\n\t\t\tif (resolved) return;\n\t\t\tif (!video.duration || video.duration <= 0) {\n\t\t\t resolved = true;\n\t\t\t cleanup();\n\t\t\t resolve(null);\n\t\t\t return;\n\t\t\t}\n\t\t\t\n\t\t\t// Try requestVideoFrameCallback first (Chrome/Edge)\n\t\t\ttryRequestVideoFrameCallback();\n\t\t };\n\t\t \n\t\t // Also try webkit method after metadata loads\n\t\t video.oncanplay = () => {\n\t\t\tif (!resolved && video.webkitDecodedFrameCount !== undefined) {\n\t\t\t setTimeout(() => {\n\t\t\t\tif (!resolved && video.webkitDecodedFrameCount && video.webkitDecodedFrameCount > 0 && video.duration > 0) {\n\t\t\t\t resolved = true;\n\t\t\t\t const fps = video.webkitDecodedFrameCount / video.duration;\n\t\t\t\t cleanup();\n\t\t\t\t resolve(fps);\n\t\t\t\t}\n\t\t\t }, 500);\n\t\t\t}\n\t\t };\n\t \n\t\t video.onerror = () => {\n\t\t\tif (!resolved) {\n\t\t\t resolved = true;\n\t\t\t cleanup();\n\t\t\t resolve(null);\n\t\t\t}\n\t\t };\n\t\t});\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\t// onScanSuccess?.(data);\n\t\t\t\treturn;\n\t\t\t}\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\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\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\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 handleFileUpload = useCallback(\n\t\tasync (file: File, recordedFps?: number | null) => {\n const 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 Promise.race([\n\t\t\t\tgetVideoFPS(file),\n\t\t\t\tnew Promise<null>((resolve) => setTimeout(() => resolve(null), 2000))\n\t\t\t]);\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});\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\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) {\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\tconsole.log(error, \"video upload failed\");\n\t\t\t} finally {\n\t\t\t\tsetStartGyro(false);\n\t\t\t}\n\t\t},\n\t\t[scanUniqueKey, gyroData],\n\t);\n\tconst 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\tconst scanId = scanUniqueKey;\n\t\t\tif (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\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}, [checkMeasurementStatus, email, scanUniqueKey, setScanUniqueKey, shopDomain]);\n\n\tuseEffect(() => {\n\t\tposthog.init(posthogPublicKey, { api_host: posthogPublicHost });\n\t\tposthog.capture(\"$pageview\");\n\t}, []);\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<MediaContextProvider>\n\t\t\t\t<ParamsContext.Provider\n\t\t\t\t\tvalue={{\n\t\t\t\t\t\tuserDetails,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tonRetry,\n\t\t\t\t\t\tonScanError,\n\t\t\t\t\t\tisError,\n\t\t\t\t\t\tisSuccess,\n\t\t\t\t\t\tonScanSuccess,\n\t\t\t\t\t\tgender,\n\t\t\t\t\t\tscanUniqueKey,\n\t\t\t\t\t\tscanFailsError,\n\t\t\t\t\t\tsetScanUniqueKey,\n\t\t\t\t\t\tsetIsVideoUploaded,\n\t\t\t\t\t\tisMeasurementAvailable,\n\t\t\t\t\t\tisVideoUploadedCorrect,\n\t\t\t\t\t\tloading,\n\t\t\t\t\t\tshowDeniedModal,\n\t\t\t\t\t\tuploadLoading,\n\t\t\t\t\t\tsetStartGyro,\n\t\t\t\t\t\thandleFileUpload,\n\t\t\t\t\t\tsetUploadLoading,\n\t\t\t\t\t\thandleShowStreamCamera,\n\t\t\t\t\t\tsetScanFailsError,\n\t\t\t\t\t\tsetScanStartTime,\n\t\t\t\t\t\tonVideoUploaded\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<BodyScanSteps />\n\t\t\t\t</ParamsContext.Provider>\n\t\t\t</MediaContextProvider>\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","SwitchIcon$1","React","memo","_jsxs","width","height","viewBox","fill","xmlns","d","stroke","strokeWidth","strokeLinecap","strokeLinejoin","LevelScreen$1","angle","countdown","isScanning","isInTargetRange","stabilityScore","config","translate","useContext","LanguageContext","getProximityToTarget","useCallback","Math","max","min","backgroundColor","style","angleDetector","successAngleBackground","proximity","successAngleLowBackground","round","handelTextColour","isLight","successAngleTextLightColor","successAngleTextDarkColor","getTextColor","handelColourCode","getColorCode","cd","fixVh","document","documentElement","setProperty","className","Header","noTitle","resolvedConfig","border","fontFamily","base","baseFontFamily","color","cn","transform","transition","SwitchIcon","LanguageKeys","startLevelCheck","leavePhone","placePhoneUpright","CameraScanChild","handleShowStreamCamera","loadingCam","handleUserMedia","handlePause","pause","recordingStarted","startSendingVideoFrames","showPause","webcamRef","handleUserMediaError","resetDetector","videoConstraints","webcamKey","onClick","X","Webcam","audio","ref","screenshotQuality","mirrored","screenshotFormat","onUserMedia","onUserMediaError","position","top","bottom","zIndex","objectFit","SpecificButton","prefix","pauseIcon","buttonText","buttonFunc","btnSecondary","restart","startScan","disabled","id","crossOrigin","preload","src","voiceOverAssetsPath","globalLoadingPromise","globalDetector","globalPoseLib","audioTimeoutId","lastVideoPlayed","ScanningComponent$1","setIsScanLocked","scanID","setIsVideoUploaded","setScanFailsError","setScanStartTime","setScanUniqueKey","userDetails","gender","heightInCm","email","shopDomain","useRef","mediaRecorderRef","recordedFpsRef","recordedChunks","setRecordedChunks","setLoadingCam","setRecordingStarted","faceDone","setFaceDone","mediaRecorderStopped","setMediaRecorderStopped","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","supportedTypes","setSupportedTypes","setWebcamKey","currentVideoConstraints","setCurrentVideoConstraints","videoConstraintsExact","counter","setStartGyro","handleFileUpload","setUploadLoading","ParamsContext","clearTimeout","generateUuid","speechService","stopAudio","stop","forEach","el","stream","setTimeout","videoConstraintsFallback","handleReScan","rescanSupportCaptureEvent","eventName","status","swan","poseDetection","disconnect","stopRecording","playAudio","handleSocket","connect","posthog","capture","handleSpinDataAvailable","data","concat","handleScanTimeCapture","message","handleStartCaptureClick","videoTrack","getVideoTracks","settings","getSettings","frameRate","mediaRecorderOptions","videoBitsPerSecond","mimeType","MediaRecorder","start","e","postPoseProcess","handleDataAvailable","connected","poseStatus","querySelector","sid","paused","audioName","no_of_times_skipped","skipCount","getScreenshot","videoEmit","image","scanId","getCurrentTimeInSeconds","push","bypassChecksToBackup","videoFile","File","type","supported","videoTypes","isTypeSupported","AngleDetector","setAngle","calibrationOffset","setCalibrationOffset","setCountdown","setStabilityScore","lastAnglesRef","isScanLocked","calibratedAngle","DeviceOrientationEvent","handleOrientation","event","beta","newAngle","abs","gamma","cos","PI","requestPermission","DeviceOrientation","once","variation","resetCountdown","startCountdown","timer","setInterval","clearInterval","LevelScreen","ScanningComponent","Modal","Dialog","open","_Fragment","heading","headingFontFamily","fontSize","headingFontSize","headingColor","fontWeight","headingFontWeight","cameraAlreadyInUse","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","serverAtCapacity","onNext","showModal","setShowModal","handleShowModal","background","issueWithScan","reason","handleErrorMessage","VIDEO_POSTER_GENDER_BASED","alt","serverAtCapacityDescription","scanAgain","onClose","GENDER","PRE_LINK","male","SignUp","isFaceScan","isVideoUploadedCorrect","isMeasurementAvailable","onScanSuccess","isSuccess","onVideoUploaded","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","setPreferredLanguage","useLocalConfig","language","onScanError","deviceModelName","callbackUrl","setIsVideoUploadedCorrect","setIsMeasurementAvailable","isVideoUploaded","startGyro","scanStartTime","gyroData","setGyroData","permissionGranted","setPermissionGranted","alpha","toString","timestamp","Date","toISOString","useGyroSensor","onError","clearScanStartTimeAndScanId","completionTime","getVideoFPS","file","createElement","objectUrl","URL","createObjectURL","overallTimeout","revokeObjectURL","cleanup","currentTime","onTimeUpdate","onSeeked","resolved","tryTimeUpdateMethod","frameCount","lastTime","startTime","performance","now","elapsed","fps","play","catch","onloadedmetadata","duration","requestVideoFrameCallback","callbackHandle","countFrame","cancelVideoFrameCallback","tryRequestVideoFrameCallback","oncanplay","webkitDecodedFrameCount","onerror","onSuccess","scanStatus","resultType","code","scanIdToSet","handleMeasurementRecommendation","measurement","handleMeasurementSocket","onPreopen","handleWebSocketCapture","connection","onOpen","recordedFps","fileSizeInMB","Number","toFixed","videoFps","race","arrayMetaData","createObjectMetadataArray","focal_length","customer_store_url","clothes_fit","scan_type","callback_url","JSON","stringify","video_fps","fileUpload","uploadFileFrontend","setDeviceInfo","model","detection","gyro","checkMeasurementStatus","res","getMeasurementResult","isMeasured","tempScanStartTime","currentTimeInSeconds","fiveMinutesInSeconds","init","posthogPublicKey","api_host","posthogPublicHost","LanguageContextProvider"],"mappings":"2PAYO,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,CAACE,QAAQC,WAAYD,QAAQE,eAEvCI,EAAAA,UAAU,KACRD,KACC,IACHE,EAAAA,gBAAgB,KACdP,OAAOQ,iBAAiB,SAAUH,GAC3B,IAAML,OAAOS,oBAAoB,SAAUJ,IACjD,CAACA,IACJ,IAAIK,EAAQnB,EACRM,EAAK,GAAK,KAAOA,EAAK,GAAK,OAC7Ba,EAAQnB,GAENM,EAAK,GAAK,MACZa,EAAQnB,GAGV,MAAMoB,EAAeC,EAAAA,QACnB,KAAA,CACEf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|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import a,{useState as r,useCallback as o,useEffect as s,createContext as i,useLayoutEffect as l,useMemo as c,useContext as d,useRef as u}from"react";import m,{posthog as f}from"posthog-js";import{L as p,H as h,b as g,S as y,q as v,v as b,f as w,P as x,h as S,r as C,s as F,n as N,l as D,t as k,i as I,e as T,w as E,x as L,c as U,a as M,y as $,z as _,V as z,A as V,B as j,C as A,G as P,D as R,E as q,I as B,u as W,J as K,p as O,j as H,k as J,o as G}from"./LoadingScreen-7f8tlI6E.js";import Q from"clsx";import Y from"react-webcam";import{X}from"lucide-react";import{Dialog as Z,Box as ee,Drawer as te}from"@mui/material";import ne from"video.js";const ae="DESKTOP",re="TAB",oe="MOBILE",se=i(void 0);function ie({children:t}){const[n,a]=r([window?.innerWidth,window?.innerHeight]),[o,i]=r(!1),d=()=>{a([window?.innerWidth,window?.innerHeight])};s(()=>{d()},[]),l(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[d]);let u=ae;n[0]>768&&n[0]<1024&&(u=re),n[0]<768&&(u=oe);const m=c(()=>({size:n,setSize:a,clearInputs:o,setClearInputs:i,media:u}),[n,o,u]);return e(se.Provider,{value:m,children:t})}var le=a.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 ce=a.memo(function({angle:n,countdown:a,isScanning:r,isInTargetRange:s,stabilityScore:i,children:l,config:u}){const{translate:m}=d(p)||{},f=o(()=>n<80?Math.max(0,Math.min(100,10*(n-60))):n>95?Math.max(0,Math.min(100,10*(105-n))):100,[n]),y=c(()=>{if(r)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=f();if(0===e)return u?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[r,f]),v=o((e,t)=>t>70?e?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${u?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),b=o((e=!1)=>{const t=f();return r?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]`:v(e,t)},[r,f]),w=o((e,t)=>t>70||e?u?.style?.angleDetector?.successAngleTextLightColor:u?.style?.angleDetector?.successAngleTextDarkColor,[]),x=o((e=!1)=>{const t=f();return r?u?.style?.angleDetector?.successAngleTextLightColor:w(e,t)},[r,f]),S=a;function C(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return C(),window.addEventListener("resize",C),t("div",{className:"flex 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:y},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(h,{noTitle:!0,resolvedConfig:u})})}),null!==S?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 ${x()}`},children:e("div",{className:`text-[3rem] font-bold text-[${x()}]`,style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:x()},children:S})}):t("div",r?{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"})}),l]}:{className:Q("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",s?"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 ${x()}`},children:[e("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${x()}]/80`,style:{backgroundColor:`${x()}B3`}}),t("div",{className:Q("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",b()),style:{color:x()},children:[e(le,{size:30}),t("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",m?.(g.startLevelCheck),e("br",{})]})]})]}),null!==S&&e("div",{className:"absolute bottom-[8rem] text-center",children:e("div",{className:Q("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",b()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:x()},children:m?.(g.leavePhone)})}),s&&null===S&&!r&&e("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e("div",{className:`h-[.375rem] w-full bg-[${x()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${x()}33`},children:e("div",{className:`h-full bg-[${x()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${n}%`,backgroundColor:`${x()}B3`}})})}),null===S&&!r&&e("div",{className:"absolute bottom-[5rem] text-center",children:t("div",{className:Q("text-[1.5rem] font-light",b()),style:{color:x()},children:[Math.round(n),"°"]})}),null===S&&!r&&e("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e("div",{className:Q("text-[.75rem] opacity-50",b()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:x()},children:m?.(g.placePhoneUpright)})})]})});function de({handleShowStreamCamera:n,loadingCam:a,handleUserMedia:r,handlePause:o,pause:s,recordingStarted:i,startSendingVideoFrames:l,showPause:c,webcamRef:u,handleUserMediaError:m,resetDetector:f,videoConstraints:h,webcamKey:w,config:x}){const{media:S}=d(se)||{},{translate:C}=d(p)||{};return t("div",{className:"App w-screen h-[100vh] relative ",children:[e("span",{onClick:()=>{n(),f()},className:"fixed right-[20px] top-[20px] z-[999]",children:e(X,{className:"text-[#fff]"})}),e("div",{className:"w-full h-full overflow-hidden ",children:S===oe&&e(Y,{audio:!1,ref:u,screenshotQuality:1,videoConstraints:h,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:r,onUserMediaError:m,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}},w)}),t("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[c&&e(y,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:v,buttonText:C?.(g.pause),buttonFunc:o,resolvedConfig:x,btnSecondary:!0}),s?e("div",{children:e(y,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:C?.(g.restart),buttonFunc:n,resolvedConfig:x,btnSecondary:!0})}):i?null:e(y,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(a?"!opacity-50":""),buttonText:C?.(g.startScan),buttonFunc:l,disabled:a,resolvedConfig:x})]}),e("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${b}scanAudioInstructions/silence.mp3`})]})}let ue=null,me=null,fe=null;let pe,he=null,ge=null;var ye=a.memo(function({setIsScanLocked:t,resetDetector:n,scanID:a,setIsVideoUploaded:i,setScanFailsError:l,setScanStartTime:c,setScanUniqueKey:f,userDetails:p,config:h}){const{gender:g,heightInCm:y,email:v,shopDomain:E}=p,L=u(null),U=u(null),M=u(null),[$,_]=r([]),[z,V]=r(!0),[j,A]=r(!1),[P,R]=r(!1),[q,B]=r(!0),[W,K]=r(!1),O=u(null),[H,J]=r(""),[G,Q]=r([]),[Y,X]=r(""),[Z,ee]=r(!1),[te,ne]=r(!1),[ae,re]=r(!1),[oe,se]=r([]),[ie,le]=r(!1),ce=u(!0),{poseDetector:ye}=function(){const[e,t]=r(0),[n,a]=r(0),[o,i]=r(!1),l=u(0),c=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-BNzTL1FH.js"),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);fe=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const a={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{me=await fe.createDetector(fe.SupportedModels.BlazePose,a),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),me=await fe.createDetector(fe.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),ue=null,!1}}function f(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return s(()=>{if(d.current=!0,!me)return ue||(ue=m()),ue.then(e=>{e&&d.current&&i(!0)}),()=>{d.current=!1};i(!0)},[]),s(()=>{c.current=e,e>6&&l.current<2&&(a(e=>e+1),t(0))},[e]),s(()=>{l.current=n},[n]),{poseDetector:async(e,n)=>{if(!me||!d.current||!n?.current?.video)return;const a=n.current.video;if(!(a.readyState<2))try{const n=await me.estimatePoses(a,{flipHorizontal:!1});if(!n||!n.length)return;const r=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!==l.current||f(r)||t(e=>e+1),1===l.current&&f(r)&&t(e=>e+1),2===l.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:o,spinPhase:n,resetDetector:()=>{l.current=0,c.current=0,t(0),a(0)},retryLoading:async()=>{me||ue||(ue=m(),await ue&&d.current&&i(!0))}}}(),ve=u(!0),be=u(!1),[we,xe]=r([]),[Se,Ce]=r(0),[Fe,Ne]=r(w);let De=0;const{setStartGyro:ke,handleFileUpload:Ie,setUploadLoading:Te}=d(x),Ee=()=>{be.current=!1,clearTimeout(pe),O.current&&clearTimeout(O.current),f(T()),l(""),Te?.(!1),_([]),M.current=null,V(!0),A(!1),R(!1),B(!0),K(!1),O.current=null,J(""),Q([]),X(""),ee(!Z),ke(!1),F.stopAudio(),ne(!1),re(!1),De=0,null!==U.current&&U.current.stop(),oe.forEach(e=>{U.current&&U.current.removeEventListener("dataavailable",e)}),se([]),ce.current=!0,le(!1),i(!1),L.current?.stream&&V(!1)},Le=o(()=>{setTimeout(()=>{V(!1)},1e3)},[]),Ue=o(e=>{if(console.log("camera error",e),Fe===w)return Ne(S),void Ce(e=>e+1);V(!1)},[Fe]),Me=o(()=>{C({eventName:`${E}/rescan`,email:v,scanID:a,height:y,gender:g,status:!1}),ce.current=!1,Ee(),qe()},[Ee,a,v]),$e=o(()=>{ce.current=!1,re(!0),le(!1),O.current&&clearTimeout(O.current),U.current&&U.current.pause(),F.stopAudio(),N.poseDetection.disconnect(),De=0,U.current&&U.current.stop(),oe.forEach(e=>{U.current&&U.current.removeEventListener("dataavailable",e)}),se([]),clearTimeout(pe)},[U,oe,F,ce]),_e=o(async()=>{ce.current=!0,await F.playAudio(`${b}SpotOn.mp3`),re(!1),le(!1),O.current&&clearTimeout(O.current),A(!1)},[O,F]),ze=o(async()=>{try{he=await N.poseDetection.connect(),m.capture(`${E}/pose_detection_connected`,{scanID:a,email:v,id:he})}catch(e){console.log(e,"while connecting websocket")}},[a,E,v]),Ve=o(({data:e})=>{e&&e.size>0&&ce.current&&(_(t=>t.concat(e)),!be.current&&L.current&&(be.current=!0,ye(()=>{_e(),D({eventName:`${E}/tensorFlow`,scanID:a,email:v,message:"recording stopped by tensorflow "})},L)))},[_e,D,E,a,v,L]),je=o(async()=>{G.length>0&&ce.current&&(await F.playAudio(b+G[G.length-1]),ce.current&&(pe=setTimeout(je,2e3)))},[G,ce]),Ae=o(()=>{U&&U.current&&U.current.stop(),A(!0);try{if(L&&L.current&&L.current.stream){const e=L.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();M.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};we[0]&&(t.mimeType=we[0]),U.current=new MediaRecorder(L.current.stream,t),U.current.addEventListener("dataavailable",Ve),se([...oe,Ve]),U.current.start(1e3),B(!1)}}catch(e){console.log("error while using media recorder",e)}},[L,we,Ve,oe]),Pe=o(async()=>{O.current&&clearTimeout(O.current),Ae(),ce.current&&(O.current=setTimeout(async()=>{ce.current&&(await F.playAudio(`${b}SpotOn.mp3`),A(!1))},15e3)),R(!0),ce.current&&await F.playAudio(`${b}Spin.mp3`)},[Ae,ce,F]),Re=o(({data:e})=>{e.size>0&&N.poseDetection.connected()&&(N.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){const t=document.querySelector("#audioElement");!0===e.status&&e.sid===he?De<2?(0===De&&t?.paused&&await F.playAudio(b+e.audio),De+=1):(X(e.audio),clearTimeout(pe),N.poseDetection.disconnect(),setTimeout(Pe,1e3)):(De=0,!t?.paused||ge&&ge?.audioName===e.audio?ge?.audioName===e.audio&&t?.paused&&(ge&&ge.no_of_times_skipped>=ge.skipCount?(ge.no_of_times_skipped=0,F.playAudio(b+e.audio)):ge&&(ge.no_of_times_skipped+=1)):(ge={skipCount:2,no_of_times_skipped:0,audioName:e.audio},F.playAudio(b+e.audio)))}}),L?.current&&null!==L.current.getScreenshot()&&N.poseDetection.videoEmit({image:L.current.getScreenshot()||"",scanId:a}))},[L,a,N,he,De,Pe,F]),qe=o(async()=>{K(!0),ke(!0),ve.current&&(ve.current=!1,D({eventName:"scan started",scanID:a,status:"success",email:v})),c(k()),V(!0),ce.current&&await F.playAudio(`${b}StartScan.mp3`),ce.current&&await F.playAudio(`${b}LiftArmsAndHoldAtHip.mp3`),ce.current&&(K(!1),A(!0),ne(!0),le(!0),Le());try{if(L&&L.current&&L.current.stream&&ce.current){const e=L.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();M.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};we[0]&&(t.mimeType=we[0]),ce.current&&(U.current=new MediaRecorder(L.current.stream,t)),ce.current&&U.current&&U.current.addEventListener("dataavailable",Re),se([...oe,Re]),U.current&&U.current.start(1e3),B(!1),ce.current&&(pe=setTimeout(je,2e3))}}catch(e){console.log("error ----------",e)}},[L,we,Re,oe,je,ce]);return s(()=>(E&&(t(!0),ze()),()=>{he&&(N.poseDetection.disconnect(),m.capture(`${E}/pose_detection_disconnected`,{scanID:a,email:v,id:he})),oe.forEach(e=>{U?.current?.removeEventListener("dataavailable",e)})}),[Z,E]),s(()=>{G.push(H)},[H]),s(()=>{Q([])},[Y]),s(()=>{const e=$.length&&$.length>0;q||!e||j||!ce.current||ae||U&&U.current&&(j||(U.current.stop(),B(!0)))},[q,j,$,ae]),s(()=>{const e=$.length&&$.length>0;if(q||!e||j)console.log("No video found to upload.");else if(U&&U.current&&ce.current&&!ae&&!j){const e=new File($,`${a}.webm`,{type:"video/webm"});Te?.(!0),l(""),Ie?.(e,M.current)}},[q,j,$,ae,U,ce]),s(()=>{if("undefined"!=typeof MediaRecorder){const e=I.filter(e=>MediaRecorder.isTypeSupported(e));xe(e)}},[]),s(()=>{Ee()},[]),e(de,{resetDetector:n,handleShowStreamCamera:Ee,loadingCam:z,handlePause:$e,showRestart:te,pause:ae,handleReScan:Me,recordingStarted:j,isScanning:W,startSendingVideoFrames:qe,faceDone:P,stopRecording:_e,showPause:ie,webcamRef:L,handleUserMedia:Le,handleUserMediaError:Ue,videoConstraints:Fe,webcamKey:Se,config:h})});function ve({scanID:t,userDetails:n,setIsVideoUploaded:a,setScanFailsError:o,setScanStartTime:i,setScanUniqueKey:l,config:c}){const[d,m]=r(90),[f,p]=r(0),[h,g]=r(null),[y,v]=r(!1),[b,w]=r(0),x=u([]),[S,C]=r(!1),F=d-f,N=F>=80&&F<=95;s(()=>{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)),m(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})}},[]),s(()=>{if(x.current=[...x.current.slice(-4),F],x.current.length>=5){const e=Math.max(...x.current)-Math.min(...x.current);w(N&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}N||null===h&&!y||k()},[F,N,h,y]),s(()=>{b>=100&&null===h&&!y&&D(),b<50&&null!==h&&k()},[b,h,y]);const D=()=>{g(3);const e=setInterval(()=>{g(t=>null===t||t<=1?(clearInterval(e),v(!0),null):t-1)},1e3)},k=()=>{g(null),S||v(!1)};return e(ce,{angle:F,countdown:h,isScanning:y,isInTargetRange:N,stabilityScore:b,config:c,children:y&&e(ye,{setIsScanLocked:C,resetDetector:()=>{m(90),p(0),g(null),v(!1),w(0),C(!1),x.current=[]},scanID:t,userDetails:n,setIsVideoUploaded:a,setScanFailsError:o,setScanStartTime:i,setScanUniqueKey:l,config:c})})}function be({message:a,config:r}){const{translate:o}=d(p)||{};return e(Z,{open:!0,className:"confirm-modal",children:e("div",{className:"modal-main",children:e("div",{className:"text-center",children:t(n,a?{children:[e("h2",{style:{fontFamily:r?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:r?.style?.heading?.headingFontSize||"32px",color:r?.style?.heading?.headingColor||"#000",fontWeight:r?.style?.heading?.headingFontWeight||"normal"},children:o?.(g.cameraAlreadyInUse)}),e("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:r?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:r?.style?.base?.baseFontSize||"16px",color:r?.style?.base?.baseTextColor||"#000"},children:o?.(g.tryClosingBrowser)})]}:{children:[e("h2",{style:{fontFamily:r?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:r?.style?.heading?.headingFontSize||"32px",color:r?.style?.heading?.headingColor||"#000",fontWeight:r?.style?.heading?.headingFontWeight||"normal"},children:o?.(g.checkCameraSettings)}),e("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:r?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:r?.style?.base?.baseFontSize||"16px",color:r?.style?.base?.baseTextColor||"#000"},children:`${o?.(g.setting)} > ${E()} > ${o?.(g.enableCameraPermissions)}`})]})})})})}function we({setShowDrawer:t,config:n,loader:a}){const[i,l]=r({disabled:!1,message:""}),[c,d]=r(!0),m=u(null),f=o(async()=>{const e=await L();l(e),d(!1)},[]);return s(()=>{f()},[]),c?e(U,{url:a,loaderType:"black"}):i?.disabled?e(be,{config:n,message:i?.message}):e(Y,{audio:!1,ref:m,screenshotQuality:1,videoConstraints:M,mirrored:!0,onUserMedia:()=>t?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function xe({link:t,onReady:n,wrapperClassName:a="[&_video]:rounded-t-[20px] w-full h-full"}){const r=u(null),o=u(null);let i={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:$};return s(()=>{if(!o.current&&t&&r?.current){const e=ne(r.current,{...i});e.ready(()=>{o.current=e;const a={...i,sources:[{src:t,type:"application/x-mpegURL"}]};e.autoplay(a.autoplay),e.src(a.sources),n?.(e)})}},[t,r]),s(()=>{const e=o.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),o.current=null)}},[o]),e("div",{className:a,children:e("video",{ref:r,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function Se({scanFailsError:a,serverAtCapacity:o=!1,onNext:s,gender:i,setScanUniqueKey:l,resolvedConfig:c,setIsVideoUploaded:u}){const{translate:m}=d(p)||{},[f,v]=r(!1),b=()=>{v(!f)};return t(n,{children:[t("div",{className:"flex flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:c?.style?.base?.backgroundColor},children:[e("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e(h,{noTitle:!0,resolvedConfig:c})}),t("div",{className:"flex-1",children:[a&&t("div",{className:"px-[1rem]",children:[e("h2",{className:"text-center",style:{fontFamily:c?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:c?.style?.heading?.headingFontSize||"32px",color:c?.style?.heading?.headingColor||"#000",fontWeight:c?.style?.heading?.headingFontWeight||"normal"},children:m?.(g.issueWithScan)}),e("p",{style:{fontFamily:c?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:c?.style?.base?.baseFontSize||"16px",color:c?.style?.base?.baseTextColor||"#1E1E1E"},children:m?.(g.reason)}),e("p",{style:{fontFamily:c?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:c?.style?.base?.baseFontSize||"16px",color:c?.style?.base?.baseTextColor||"#1E1E1E"},children:_(a)}),e("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:b,src:z[i],alt:"icon"})]}),o&&t("div",{className:"p-[1rem] text-center",children:[e("h3",{style:{fontFamily:c?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:c?.style?.heading?.headingFontSize||"32px",color:c?.style?.heading?.headingColor||"#000",fontWeight:c?.style?.heading?.headingFontWeight||"normal"},children:m?.(g.serverAtCapacity)}),e("p",{className:"text-base mt-[0.5rem]",style:{fontFamily:c?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:c?.style?.base?.baseFontSize||"16px",color:c?.style?.base?.baseTextColor||"#1E1E1E"},children:m?.(g.serverAtCapacityDescription)})]})]}),a&&e("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e(y,{disabled:!1,buttonText:m?.(g.scanAgain),className:"!shadow-none",buttonFunc:()=>{s?s?.():l(T()),u(!1)},resolvedConfig:c})})]}),f&&t(Z,{className:"w-screen h-screen video-modal",onClose:b,open:f,children:[e("div",{className:"flex justifyEnd ",children:e("span",{className:"closeBtn",onClick:b,children:e(X,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e("div",{className:"aspect-video object-cover rounded-[20px] ",children:e(xe,{link:i?V[i].PRE_LINK:V.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function Ce({scanId:n,userDetails:a,config:i,isFaceScan:l,isVideoUploadedCorrect:c,isMeasurementAvailable:u,onScanSuccess:m,isSuccess:v,onVideoUploaded:b}){const{gender:w,shopDomain:x,heightInCm:S,deviceFocalLength:C,userName:F,email:D,scanType:k}=a,I=[R,q,B].includes(k),[T,E]=r(!0),L=o(async()=>{try{I&&(await N.auth.addUser({scanId:n,email:D,name:F,gender:w,height:S}),b?.()),f.capture(x,{scanID:n,email:D,height:S,focalLength:C,clothesFit:"0",gender:w})}catch(e){console.log(e)}},[I]),{translate:U}=d(p)||{};s(()=>{(c||u)&&L()},[c,u]);const M=v||(l?u&&c:c||u);return e(ee,{className:"flex h-full w-full flex-col ",children:t("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e(we,{loader:i?.loader,setShowDrawer:E}),e(te,{open:T,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:i?.style?.base?.backgroundColor},children:t("div",{className:"w-full h-full flex flex-col",children:[e(h,{title:U?.(g.measurementsBeingTaken),resolvedConfig:i}),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===P.Male?j:A,type:"video/mp4"})})}),M&&e(y,{resolvedConfig:i,className:"!w-[180px] mx-auto",buttonText:U?.(g.next),buttonFunc:()=>{m?.(),b?.()}})]})})})]})})}const Fe=()=>{const{userDetails:a,config:r,onRetry:o,isError:i,isSuccess:l,onScanSuccess:c,gender:u,scanUniqueKey:m,scanFailsError:f,setScanUniqueKey:h,setIsVideoUploaded:g,isMeasurementAvailable:y,isVideoUploadedCorrect:v,loading:b,showDeniedModal:w,uploadLoading:S,setScanFailsError:C,setScanStartTime:F,handleShowStreamCamera:N,onVideoUploaded:D}=d(x),{setPreferredLanguage:k}=d(p)||{},I=W(r);return s(()=>{k?.(I?.language)},[I]),i?t(n,{children:[e(we,{}),e(te,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(Se,{scanFailsError:f||i,onNext:()=>{o?.(),N()},setScanUniqueKey:h,gender:u,resolvedConfig:I,setIsVideoUploaded:g})})]}):l?e(Ce,{isFaceScan:!1,scanId:m,isMeasurementAvailable:y,userDetails:a,isVideoUploadedCorrect:v,config:I,isSuccess:l,onVideoUploaded:D}):b?e("div",{className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:I?.style?.base?.backgroundColor},children:e(U,{url:I?.loader,loaderType:"black"})}):w.disabled?e(be,{}):S||f||y||v?(S||y||v)&&!f?e(Ce,{isFaceScan:!1,scanId:m,isMeasurementAvailable:y,userDetails:a,onScanSuccess:c,isVideoUploadedCorrect:v,config:I,onVideoUploaded:D}):t(n,{children:[e(we,{}),e(te,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(Se,{scanFailsError:f,onNext:()=>{o?.(),N()},setScanUniqueKey:h,gender:u,resolvedConfig:I,setIsVideoUploaded:g})})]}):e(ve,{config:I,scanID:m,userDetails:a,setIsVideoUploaded:g,setScanFailsError:C,setScanStartTime:F,setScanUniqueKey:h})},Ne=({userDetails:t,config:n,onRetry:a,onScanError:i,isError:l,isSuccess:c,onScanSuccess:d,onVideoUploaded:u})=>{const{gender:f,scanType:p,shopDomain:h,heightInCm:g,email:y,deviceFocalLength:v,deviceModelName:b,callbackUrl:w}=t,[S,C]=r(!1),[F,I]=r(!1),[E,U]=r(!1),[M,$]=r({disabled:!1,message:""}),[z,V]=r(""),[j,A]=r(!1),[P,R]=r(!0),[q,B]=r(!1),[W,Q]=r(""),[Y,X]=r(k()),{gyroData:Z}=function(e){const[t,n]=r([]),[a,i]=r(!1),l=o(e=>{try{const{alpha:t,beta:a,gamma:r}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:a?.toString()||void 0,gamma:r?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),c=o(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?i(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else i(!0)},[]);return s(()=>(e&&a?window.addEventListener("deviceorientation",l):n([]),()=>{window.removeEventListener("deviceorientation",l)}),[e,a,l]),s(()=>{e&&c()},[e,c]),{gyroData:t}}(q),ee=o(()=>{Q(T()),V(""),C(!1),A(!1)},[]),te=e=>{i({...e,message:_(e)}),ne(),U(!1),V(e),I(!1),D({eventName:`${h}/measurement_failed/fit-view`,scanID:W,status:"failed",email:y,message:_(e)}),Y&&D({eventName:`${h}/scan_completion_time`,scanID:W,status:"failed",completionTime:k()-Y,email:y})},ne=()=>{X(null),Q("")};function ae(e){return new Promise(t=>{const n=document.createElement("video");n.preload="auto",n.muted=!0,n.playsInline=!0;const a=URL.createObjectURL(e);n.src=a;const r=setTimeout(()=>{n.pause(),URL.revokeObjectURL(a),t(null)},3e3),o=()=>{clearTimeout(r),n.pause(),n.currentTime=0,n.removeEventListener("timeupdate",onTimeUpdate),n.removeEventListener("seeked",onSeeked),URL.revokeObjectURL(a)};let s=!1;const i=()=>{let e=0,a=-1;const r=performance.now();n.addEventListener("timeupdate",()=>{if(s)return;const i=n.currentTime;Math.abs(i-a)>.001&&(e++,a=i);const l=(performance.now()-r)/1e3;if((l>=1.5||n.currentTime>=1.5)&&!s){s=!0;const n=l>0?e/l:null;o(),t(n&&n>0?n:null)}}),n.play().then(()=>{setTimeout(()=>{if(!s){s=!0;const n=(performance.now()-r)/1e3,a=n>0?e/n:null;o(),t(a&&a>0?a:null)}},2500)}).catch(()=>{s||(s=!0,o(),t(null))})};n.onloadedmetadata=()=>{if(!s)return!n.duration||n.duration<=0?(s=!0,o(),void t(null)):void(()=>{if(n.requestVideoFrameCallback){let e=0;const a=performance.now();let r=null;const l=()=>{if(s)return;e++;const i=(performance.now()-a)/1e3;if(i>=1){if(!s){s=!0,null!==r&&n.cancelVideoFrameCallback&&n.cancelVideoFrameCallback(r);const a=e;o(),t(a>0?a:null)}}else if(i<2)r=n.requestVideoFrameCallback(l);else if(!s){s=!0,null!==r&&n.cancelVideoFrameCallback&&n.cancelVideoFrameCallback(r);const a=i>0?e/i:null;o(),t(a&&a>0?a:null)}};n.play().then(()=>{r=n.requestVideoFrameCallback(l),setTimeout(()=>{!s&&null!==r&&n.cancelVideoFrameCallback&&(n.cancelVideoFrameCallback(r),i())},2500)}).catch(()=>{s||i()})}else i()})()},n.oncanplay=()=>{s||void 0===n.webkitDecodedFrameCount||setTimeout(()=>{if(!s&&n.webkitDecodedFrameCount&&n.webkitDecodedFrameCount>0&&n.duration>0){s=!0;const e=n.webkitDecodedFrameCount/n.duration;o(),t(e)}},500)},n.onerror=()=>{s||(s=!0,o(),t(null))}})}const re=o(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return D({eventName:`${h}/measurement_success/intermediate`,scanID:W,status:"success",email:y}),void I(!0);I(!0),ne();const t=W;U(!0),D({eventName:`${h}/measurement_success/fit-view`,scanID:t,status:"success",email:y}),Y&&D({eventName:`${h}/scan_completion_time`,scanID:t,status:"success",completionTime:k()-Y,email:y})},[p,h,W]),oe=e=>{U(!1),V(""),I(!1),N.measurement.handleMeasurementSocket({scanId:e||W,onPreopen:()=>{G({eventName:`${h}/webSocket`,scanID:W,connection:"pre_open",type:"measurement_recommendation",email:y})},onOpen:()=>{G({eventName:`${h}/webSocket`,scanID:W,connection:"open",type:"measurement_recommendation",email:y})},onClose:()=>G({eventName:`${h}/webSocket`,scanID:W,connection:"close",type:"measurement_recommendation",email:y}),onError:e=>{te(e),G({eventName:`${h}/webSocket`,scanID:W,connection:"error",type:"measurement_recommendation",email:y})},onSuccess:e=>{G({eventName:`${h}/webSocket`,scanID:W,connection:"success",type:"measurement_recommendation",email:y}),re(e)}})},se=o(async(e,t)=>{const n=Number((e.size/1048576).toFixed(2)),a=null!=t?t:await Promise.race([ae(e),new Promise(e=>setTimeout(()=>e(null),2e3))]),r=K({gender:f,focal_length:`${v}`,height:`${g}`,customer_store_url:h,clothes_fit:"0",scan_type:p,callback_url:w});D({eventName:`${h}/body_scan_meta_data`,scanID:W,email:y,data:JSON.stringify([...r,{fileSizeInMB:n,video_fps:a||0}])});try{await N.fileUpload.uploadFileFrontend({file:e,arrayMetaData:r,scanId:W,email:y}),await N.fileUpload.setDeviceInfo({model:b,detection:"manual",gyro:Z,scanId:W}),console.log("video successfully uploaded"),A(!1),D({eventName:`${h}/scan_success`,scanID:W,status:"success",email:y,data:JSON.stringify(r)}),D({eventName:"scan finished",scanID:W,status:"success",email:y}),X(k()),setTimeout(()=>{A(!0)},3e3)}catch(e){D({eventName:"scan finished",scanID:W,status:"failed",email:y,message:_(e)}),D({eventName:`${h}/scan_failed`,scanID:W,status:"failed",email:y,message:_(e),data:JSON.stringify(r)}),V(_(e)),A(!1),console.log(e,"video upload failed")}finally{B(!1)}},[W,Z]),le=o(async e=>{try{const t=await N.measurement.getMeasurementResult(e),n=t?.data?.isMeasured,a=Y||k(),r=k(),o=300;if(R(!1),!1===n)return ne(),void Q(T());C(!0),!0===n?await re(null):null===n&&a>r+o?te(t?.data?.error):oe(e)}catch(e){console.log(e),ne(),Q(T()),C(!1)}},[te,re,Q]),ce=o(async()=>{if(+g<152.4||+g>213.36)return void i({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await L();if(e.disabled)D({eventName:`${h}/camera_activation`,scanID:W,status:"failed",email:y}),R(!1);else{W?le(W):R(!1),D({eventName:`${h}/camera_activation`,scanID:W,status:"success",email:y})}$(e),V(""),A(!1)},[le,y,W,Q,h]);return s(()=>{m.init(O,{api_host:H}),m.capture("$pageview")},[]),s(()=>{l||c||h&&ce()},[h,g,l,c]),s(()=>{l||c||j&&h&&W&&oe()},[j,h,W,l,c]),e(J,{children:e(ie,{children:e(x.Provider,{value:{userDetails:t,config:n,onRetry:a,onScanError:i,isError:l,isSuccess:c,onScanSuccess:d,gender:f,scanUniqueKey:W,scanFailsError:z,setScanUniqueKey:Q,setIsVideoUploaded:A,isMeasurementAvailable:E,isVideoUploadedCorrect:F,loading:P,showDeniedModal:M,uploadLoading:S,setStartGyro:B,handleFileUpload:se,setUploadLoading:C,handleShowStreamCamera:ee,setScanFailsError:V,setScanStartTime:X,onVideoUploaded:u},children:e(Fe,{})})})})};export{Ne as B};
|
|
2
|
+
//# sourceMappingURL=BodyScan-CsfWzkns.js.map
|