@swan-admin/swan-web-component 1.0.84 → 1.0.85
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-CUlUT-1a.js +2 -0
- package/dist/BodyScan-CUlUT-1a.js.map +1 -0
- package/dist/BodyScan-DtKrwfBB.js +2 -0
- package/dist/BodyScan-DtKrwfBB.js.map +1 -0
- package/dist/bodyScan.js +1 -1
- package/dist/bodyScan.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),s=require("./LoadingScreen-C__KGOn0.js"),a=require("clsx"),n=require("react-webcam"),r=require("@mui/icons-material/Close"),o=require("posthog-js"),i=require("@mui/material"),c=require("@mui/icons-material"),l=require("video.js");var u=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 d=t.memo(function({angle:n,countdown:r,isScanning:o,isInTargetRange:i,stabilityScore:c,children:l,config:d}){const{translate:m}=t.useContext(s.LanguageContext)||{},f=t.useCallback(()=>n<80?Math.max(0,Math.min(100,10*(n-60))):n>95?Math.max(0,Math.min(100,10*(105-n))):100,[n]),h=t.useMemo(()=>{if(o)return d?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=f();if(0===e)return d?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return d?.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,f]),g=t.useCallback((e,t)=>t>70?e?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]/70`:`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]`:e?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]/40`:`text-[${d?.style?.angleDetector?.successAngleTextDarkColor}]/70`,[]),p=t.useCallback((e=!1)=>{const t=f();return o?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]`:g(e,t)},[o,f]),x=t.useCallback((e,t)=>t>70||e?d?.style?.angleDetector?.successAngleTextLightColor:d?.style?.angleDetector?.successAngleTextDarkColor,[]),y=t.useCallback((e=!1)=>{const t=f();return o?d?.style?.angleDetector?.successAngleTextLightColor:x(e,t)},[o,f]),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:h},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:d})})}),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:d?.style?.base?.baseFontFamily||"Inter, sans-serif"},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:a("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-n)}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:a("mt-[.5rem] w-[180px] flex-col flex items-center absolute top-[60px]",p()),style:{color:y()},children:[e.jsx(u,{size:30}),e.jsxs("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",m?.(s.LanguageKeys.startLevelCheck),e.jsx("br",{})]})]})]}),null!==v&&e.jsx("div",{className:"absolute bottom-[8rem] text-center",children:e.jsx("div",{className:a("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",p()),style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:m?.(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:`${n}%`,backgroundColor:`${y()}B3`}})})}),null===v&&!o&&e.jsx("div",{className:"absolute bottom-[5rem] text-center",children:e.jsxs("div",{className:a("text-[1.5rem] font-light",p()),style:{color:y()},children:[Math.round(n),"°"]})}),null===v&&!o&&e.jsx("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e.jsx("div",{className:a("text-[.75rem] opacity-50",p()),style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:m?.(s.LanguageKeys.placePhoneUpright)})})]})});const m="DESKTOP",f="TAB",h="MOBILE",g=t.createContext(void 0);function p({children:s}){const[a,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=m;a[0]>768&&a[0]<1024&&(c=f),a[0]<768&&(c=h);const l=t.useMemo(()=>({size:a,setSize:n,clearInputs:r,setClearInputs:o,media:c}),[a,r,c]);return e.jsx(g.Provider,{value:l,children:s})}function x({handleShowStreamCamera:a,loadingCam:o,handleUserMedia:i,handlePause:c,pause:l,recordingStarted:u,startSendingVideoFrames:d,showPause:m,webcamRef:f,resetDetector:p,config:x}){const{media:y}=t.useContext(g)||{},{translate:v}=t.useContext(s.LanguageContext)||{};return e.jsxs("div",{className:"App w-screen h-[100vh] relative ",children:[e.jsx("span",{onClick:()=>{a(),p()},className:"fixed right-[20px] top-[20px] z-[999]",children:e.jsx(r,{className:"text-[#fff]"})}),e.jsx("div",{className:"w-full h-full overflow-hidden ",children:y===h&&e.jsx(n,{audio:!1,ref:f,screenshotQuality:1,videoConstraints:s.videoConstraints,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:i,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}),e.jsxs("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[m&&e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:s.pauseIcon,buttonText:v?.(s.LanguageKeys.pause),buttonFunc:c,resolvedConfig:x,btnSecondary:!0}),l?e.jsx("div",{children:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:v?.(s.LanguageKeys.restart),buttonFunc:a,resolvedConfig:x,btnSecondary:!0})}):u?null:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(o?"!opacity-50":""),buttonText:v?.(s.LanguageKeys.startScan),buttonFunc:d,disabled:o,resolvedConfig:x})]}),e.jsx("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${s.voiceOverAssetsPath}scanAudioInstructions/silence.mp3`})]})}let y=null,v=null,S=null;const b=t.createContext(null);let C,w=null,j=null;var N=t.memo(function({setIsScanLocked:a,resetDetector:n,scanID:r,setIsVideoUploaded:i,setScanFailsError:c,setScanStartTime:l,setScanUniqueKey:u,userDetails:d,config:m}){const{gender:f,heightInCm:h,email:g,shopDomain:p}=d,N=t.useRef(null),k=t.useRef(null),[F,D]=t.useState([]),[E,I]=t.useState(!0),[T,L]=t.useState(!1),[M,P]=t.useState(!1),[_,A]=t.useState(!0),[$,U]=t.useState(!1),z=t.useRef(null),[R,O]=t.useState(""),[K,q]=t.useState([]),[B,W]=t.useState(""),[V,H]=t.useState(!1),[G,J]=t.useState(!1),[Q,Y]=t.useState(!1),[X,Z]=t.useState([]),[ee,te]=t.useState(!1),se=t.useRef(!0),{poseDetector:ae}=function(){const[e,s]=t.useState(0),[a,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,s]=await Promise.all([Promise.resolve().then(function(){return require("./pose-detection.esm-DouwBFG2.js")}),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);S=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{v=await S.createDetector(S.SupportedModels.BlazePose,a),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),v=await S.createDetector(S.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),y=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,!v)return y||(y=u()),y.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),s(0))},[e]),t.useEffect(()=>{i.current=a},[a]),{poseDetector:async(e,t)=>{if(!v||!l.current||!t?.current?.video)return;const a=t.current.video;if(!(a.readyState<2))try{const t=await v.estimatePoses(a,{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)||s(e=>e+1),1===i.current&&d(n)&&s(e=>e+1),2===i.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:r,spinPhase:a,resetDetector:()=>{i.current=0,c.current=0,s(0),n(0)},retryLoading:async()=>{v||y||(y=u(),await y&&l.current&&o(!0))}}}(),ne=t.useRef(!0),re=t.useRef(!1),[oe,ie]=t.useState([]);let ce=0;const{setStartGyro:le,handleFileUpload:ue,setUploadLoading:de}=t.useContext(b),me=()=>{re.current=!1,clearTimeout(C),z.current&&clearTimeout(z.current),u(s.generateUuid()),c(""),de?.(!1),D([]),I(!0),L(!1),P(!1),A(!0),U(!1),z.current=null,O(""),q([]),W(""),H(!V),le(!1),s.speechService.stopAudio(),J(!1),Y(!1),ce=0,null!==k.current&&k.current.stop(),X.forEach(e=>{k.current&&k.current.removeEventListener("dataavailable",e)}),Z([]),se.current=!0,te(!1),i(!1)},fe=t.useCallback(()=>{setTimeout(()=>{I(!1)},1e3)},[]),he=t.useCallback(()=>{s.rescanSupportCaptureEvent({eventName:`${p}/rescan`,email:g,scanID:r,height:h,gender:f,status:!1}),se.current=!1,me(),we()},[me,r,g]),ge=t.useCallback(()=>{se.current=!1,Y(!0),te(!1),z.current&&clearTimeout(z.current),k.current&&k.current.pause(),s.speechService.stopAudio(),s.swan.poseDetection.disconnect(),ce=0,k.current&&k.current.stop(),X.forEach(e=>{k.current&&k.current.removeEventListener("dataavailable",e)}),Z([]),clearTimeout(C)},[k,X,s.speechService,se]),pe=t.useCallback(async()=>{se.current=!0,await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),Y(!1),te(!1),z.current&&clearTimeout(z.current),L(!1)},[z,s.speechService]),xe=t.useCallback(async()=>{try{w=await s.swan.poseDetection.connect(),o.capture(`${p}/pose_detection_connected`,{scanID:r,email:g,id:w})}catch(e){console.log(e,"while connecting websocket")}},[r,p,g]),ye=t.useCallback(({data:e})=>{e&&e.size>0&&se.current&&(D(t=>t.concat(e)),!re.current&&N.current&&(re.current=!0,ae(()=>{pe(),s.handleScanTimeCapture({eventName:`${p}/tensorFlow`,scanID:r,email:g,message:"recording stopped by tensorflow "})},N)))},[pe,s.handleScanTimeCapture,p,r,g,N]),ve=t.useCallback(async()=>{K.length>0&&se.current&&(await s.speechService.playAudio(s.voiceOverAssetsPath+K[K.length-1]),se.current&&(C=setTimeout(ve,2e3)))},[K,se]),Se=t.useCallback(()=>{k&&k.current&&k.current.stop(),L(!0);try{if(N&&N.current&&N.current.stream){const e={mimeType:oe[0]};k.current=new MediaRecorder(N.current.stream,e),k.current.addEventListener("dataavailable",ye),Z([...X,ye]),k.current.start(1e3),A(!1)}}catch(e){console.log("error while using media recorder",e)}},[N,oe,ye,X]),be=t.useCallback(async()=>{z.current&&clearTimeout(z.current),Se(),se.current&&(z.current=setTimeout(async()=>{se.current&&(await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),L(!1))},15e3)),P(!0),se.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}Spin.mp3`)},[Se,se,s.speechService]),Ce=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===w?ce<2?(0===ce&&t?.paused&&await s.speechService.playAudio(s.voiceOverAssetsPath+e.audio),ce+=1):(W(e.audio),clearTimeout(C),s.swan.poseDetection.disconnect(),setTimeout(be,1e3)):(ce=0,!t?.paused||j&&j?.audioName===e.audio?j?.audioName===e.audio&&t?.paused&&(j&&j.no_of_times_skipped>=j.skipCount?(j.no_of_times_skipped=0,s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)):j&&(j.no_of_times_skipped+=1)):(j={skipCount:2,no_of_times_skipped:0,audioName:e.audio},s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)))}}),N?.current&&null!==N.current.getScreenshot()&&s.swan.poseDetection.videoEmit({image:N.current.getScreenshot()||"",scanId:r}))},[N,r,s.swan,w,ce,be,s.speechService]),we=t.useCallback(async()=>{U(!0),le(!0),ne.current&&(ne.current=!1,s.handleScanTimeCapture({eventName:"scan started",scanID:r,status:"success",email:g})),l(s.getCurrentTimeInSeconds()),I(!0),se.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}StartScan.mp3`),se.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}LiftArmsAndHoldAtHip.mp3`),se.current&&(U(!1),L(!0),J(!0),te(!0),fe());try{if(N&&N.current&&N.current.stream&&se.current){const e={mimeType:oe[0]};se.current&&(k.current=new MediaRecorder(N.current.stream,e)),se.current&&k.current&&k.current.addEventListener("dataavailable",Ce),Z([...X,Ce]),k.current&&k.current.start(1e3),A(!1),se.current&&(C=setTimeout(ve,2e3))}}catch(e){console.log("error ----------",e)}},[N,oe,Ce,X,ve,se]);return t.useEffect(()=>(p&&(a(!0),xe()),()=>{w&&(s.swan.poseDetection.disconnect(),o.capture(`${p}/pose_detection_disconnected`,{scanID:r,email:g,id:w})),X.forEach(e=>{k?.current?.removeEventListener("dataavailable",e)})}),[V,p]),t.useEffect(()=>{K.push(R)},[R]),t.useEffect(()=>{q([])},[B]),t.useEffect(()=>{const e=F.length&&F.length>0;_||!e||T||!se.current||Q||k&&k.current&&(T||(k.current.stop(),A(!0)))},[_,T,F,Q]),t.useEffect(()=>{const e=F.length&&F.length>0;if(_||!e||T)console.log("No video found to upload");else if(k&&k.current&&se.current&&!Q&&!T){const e=new File(F,`${r}.webm`,{type:"video/webm"});de?.(!0),c(""),ue?.(e)}},[_,T,F,Q,k,se]),t.useEffect(()=>{if("undefined"!=typeof MediaRecorder){const e=s.videoTypes.filter(e=>MediaRecorder.isTypeSupported(e));ie(e)}},[]),t.useEffect(()=>{me()},[]),e.jsx(x,{resetDetector:n,handleShowStreamCamera:me,loadingCam:E,handlePause:ge,showRestart:G,pause:Q,handleReScan:he,recordingStarted:T,isScanning:$,startSendingVideoFrames:we,faceDone:M,stopRecording:pe,showPause:ee,webcamRef:N,handleUserMedia:fe,config:m})});function k({scanID:s,userDetails:a,setIsVideoUploaded:n,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:i,config:c}){const[l,u]=t.useState(90),[m,f]=t.useState(0),[h,g]=t.useState(null),[p,x]=t.useState(!1),[y,v]=t.useState(0),S=t.useRef([]),[b,C]=t.useState(!1),w=l-m,j=w>=80&&w<=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),w],S.current.length>=5){const e=Math.max(...S.current)-Math.min(...S.current);v(j&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}j||null===h&&!p||F()},[w,j,h,p]),t.useEffect(()=>{y>=100&&null===h&&!p&&k(),y<50&&null!==h&&F()},[y,h,p]);const k=()=>{g(3);const e=setInterval(()=>{g(t=>null===t||t<=1?(clearInterval(e),x(!0),null):t-1)},1e3)},F=()=>{g(null),b||x(!1)};return e.jsx(d,{angle:w,countdown:h,isScanning:p,isInTargetRange:j,stabilityScore:y,config:c,children:p&&e.jsx(N,{setIsScanLocked:C,resetDetector:()=>{u(90),f(0),g(null),x(!1),v(0),C(!1),S.current=[]},scanID:s,userDetails:a,setIsVideoUploaded:n,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:i,config:c})})}function F({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 D({setShowDrawer:a,config:r,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}):i?.disabled?e.jsx(F,{config:r,message:i?.message}):e.jsx(n,{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 E({link:a,onReady:n,wrapperClassName:r="[&_video]:rounded-t-[20px] w-full h-full"}){const o=t.useRef(null),i=t.useRef(null);let c={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=l(o.current,{...c});e.ready(()=>{i.current=e;const t={...c,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 I({scanFailsError:a,serverAtCapacity:n=!1,onNext:r,gender:o,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[o],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(c.Close,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e.jsx("div",{className:"aspect-video object-cover rounded-[20px] ",children:e.jsx(E,{link:o?s.GENDER[o].PRE_LINK:s.GENDER.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function T({scanId:a,userDetails:n,config:r,isFaceScan:c,isVideoUploadedCorrect:l,isMeasurementAvailable:u,onScanSuccess:d,isSuccess:m}){const{gender:f,shopDomain:h,heightInCm:g,deviceFocalLength:p,userName:x,email:y,scanType:v}=n,S=[s.CLOTHING_CUSTOM_SCAN,s.CLOTHING_BANNER_SCAN,s.CLOTHING_CUSTOM_FIT_SCAN].includes(v),[b,C]=t.useState(!0),w=t.useCallback(async()=>{try{S&&await s.swan.auth.addUser({scanId:a,email:y,name:x,gender:f,height:g}),o.posthog.capture(h,{scanID:a,email:y,height:g,focalLength:p,clothesFit:"0",gender:f})}catch(e){console.log(e)}},[S]),{translate:j}=t.useContext(s.LanguageContext)||{};t.useEffect(()=>{l&&w()},[l]);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(D,{loader:r?.loader,setShowDrawer:C}),e.jsx(i.Drawer,{open:b,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:r?.style?.base?.backgroundColor},children:e.jsxs("div",{className:"w-full h-full flex flex-col",children:[e.jsx(s.Header,{title:j?.(s.LanguageKeys.measurementsBeingTaken),resolvedConfig:r}),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:f===s.GenderType.Male?s.maleMeasurementProgress:s.measurementProgress,type:"video/mp4"})})}),N&&e.jsx(s.SpecificButton,{resolvedConfig:r,className:"!w-[180px] mx-auto",buttonText:j?.(s.LanguageKeys.next),buttonFunc:d&&d})]})})})]})})}exports.BodyScan=({userDetails:a,config:n,onRetry:r,onScanError:c,isError:l,isSuccess:u,onScanSuccess:d})=>{const{gender:m,scanType:f,shopDomain:h,heightInCm:g,email:x,deviceFocalLength:y,deviceModelName:v,callbackUrl:S}=a,[C,w]=t.useState(!1),[j,N]=t.useState(!1),[E,L]=t.useState(!1),[M,P]=t.useState({disabled:!1,message:""}),[_,A]=t.useState(""),[$,U]=t.useState(!1),[z,R]=t.useState(!0),[O,K]=t.useState(!1),[q,B]=t.useState(""),[W,V]=t.useState(s.getCurrentTimeInSeconds()),{gyroData:H}=function(e){const[s,a]=t.useState([]),[n,r]=t.useState(!1),o=t.useCallback(e=>{try{const{alpha:t,beta:s,gamma:n}=e;a(e=>[...e,{alpha:t?.toString()||void 0,beta:s?.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):a([]),()=>{window.removeEventListener("deviceorientation",o)}),[e,n,o]),t.useEffect(()=>{e&&i()},[e,i]),{gyroData:s}}(O),{setPreferredLanguage:G}=t.useContext(s.LanguageContext)||{},J=s.useLocalConfig(n),Q=t.useCallback(()=>{B(s.generateUuid()),A(""),w(!1),U(!1)},[]),Y=e=>{c({...e,message:s.handleErrorMessage(e)}),X(),L(!1),A(e),N(!1),s.handleScanTimeCapture({eventName:`${h}/measurement_failed/fit-view`,scanID:q,status:"failed",email:x,message:s.handleErrorMessage(e)}),W&&s.handleScanTimeCapture({eventName:`${h}/scan_completion_time`,scanID:q,status:"failed",completionTime:s.getCurrentTimeInSeconds()-W,email:x})},X=()=>{V(null),B("")},Z=t.useCallback(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return void s.handleScanTimeCapture({eventName:`${h}/measurement_success/intermediate`,scanID:q,status:"success",email:x});X();const t=q;L(!0),s.handleScanTimeCapture({eventName:`${h}/measurement_success/fit-view`,scanID:t,status:"success",email:x}),W&&s.handleScanTimeCapture({eventName:`${h}/scan_completion_time`,scanID:t,status:"success",completionTime:s.getCurrentTimeInSeconds()-W,email:x})},[f,h,q]),ee=e=>{L(!1),A(""),N(!1),s.swan.measurement.handleMeasurementSocket({scanId:e||q,onOpen:()=>{s.handleWebSocketCapture({eventName:`${h}/webSocket`,scanID:q,connection:"open",type:"measurement_recommendation",email:x})},onClose:()=>s.handleWebSocketCapture({eventName:`${h}/webSocket`,scanID:q,connection:"close",type:"measurement_recommendation",email:x}),onError:e=>{Y(e),s.handleWebSocketCapture({eventName:`${h}/webSocket`,scanID:q,connection:"error",type:"measurement_recommendation",email:x})},onSuccess:e=>{s.handleWebSocketCapture({eventName:`${h}/webSocket`,scanID:q,connection:"success",type:"measurement_recommendation",email:x}),Z(e)}})},te=t.useCallback(async e=>{const t=s.createObjectMetadataArray({gender:m,focal_length:`${y}`,height:`${g}`,customer_store_url:h,clothes_fit:"0",scan_type:f,callback_url:S||"https://example.com/webhook"});s.handleScanTimeCapture({eventName:`${h}/body_scan_meta_data`,scanID:q,email:x,data:JSON.stringify(t)});try{await s.swan.fileUpload.uploadFileFrontend({file:e,arrayMetaData:t,scanId:q,email:x}),await s.swan.fileUpload.setDeviceInfo({model:v,detection:"manual",gyro:H,scanId:q}),console.log("video successfully uploaded"),U(!1),s.handleScanTimeCapture({eventName:`${h}/scan_success`,scanID:q,status:"success",email:x,data:JSON.stringify(t)}),s.handleScanTimeCapture({eventName:"scan finished",scanID:q,status:"success",email:x}),V(s.getCurrentTimeInSeconds()),setTimeout(()=>{U(!0)},3e3)}catch(e){s.handleScanTimeCapture({eventName:"scan finished",scanID:q,status:"failed",email:x,message:s.handleErrorMessage(e)}),s.handleScanTimeCapture({eventName:`${h}/scan_failed`,scanID:q,status:"failed",email:x,message:s.handleErrorMessage(e),data:JSON.stringify(t)}),A(s.handleErrorMessage(e)),U(!1),console.log(e,"video upload failed")}finally{K(!1)}},[q,H]),se=t.useCallback(async e=>{try{const t=await s.swan.measurement.getMeasurementResult(e),a=t?.data?.isMeasured,n=W||s.getCurrentTimeInSeconds(),r=s.getCurrentTimeInSeconds(),o=300;if(R(!1),!1===a)return X(),void B(s.generateUuid());w(!0),!0===a?await Z(null):null===a&&n>r+o?Y(t?.data?.error):ee(e)}catch(e){console.log(e),X(),B(s.generateUuid()),w(!1)}},[Y,Z,B]),ae=t.useCallback(async()=>{if(+g<152.4||+g>213.36)return void c({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await s.checkCameraPermission();if(e.disabled)s.handleScanTimeCapture({eventName:`${h}/camera_activation`,scanID:q,status:"failed",email:x}),R(!1);else{q?se(q):R(!1),s.handleScanTimeCapture({eventName:`${h}/camera_activation`,scanID:q,status:"success",email:x})}P(e),A(""),U(!1)},[se,x,q,B,h]);return t.useEffect(()=>{o.init(s.posthogPublicKey,{api_host:s.posthogPublicHost}),o.capture("$pageview")},[]),t.useEffect(()=>{G?.(J?.language)},[J]),t.useEffect(()=>{l||u||h&&ae()},[h,g,l,u]),t.useEffect(()=>{l||u||$&&h&&q&&ee()},[$,h,q,l,u]),l?e.jsxs(s.LanguageContextProvider,{children:[e.jsx(D,{}),e.jsx(i.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(I,{scanFailsError:_||l,onNext:()=>{},setScanUniqueKey:B,gender:m,resolvedConfig:J,setIsVideoUploaded:U})})]}):u?e.jsx(T,{isFaceScan:!1,scanId:q,isMeasurementAvailable:E,userDetails:a,isVideoUploadedCorrect:j,config:J,isSuccess:u}):z?e.jsx("div",{className:"flex top-0 !mt-0 left-0 z-[999] bg-opacity-80 bg-[#1b1b1b] absolute justify-center items-center w-full h-full",children:e.jsx(s.LoadingScreen,{url:J?.loader})}):M.disabled?e.jsx(s.LanguageContextProvider,{children:e.jsx(F,{})}):C||_?!C&&!E||_?e.jsxs(s.LanguageContextProvider,{children:[e.jsx(D,{}),e.jsx(i.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(I,{scanFailsError:_,onNext:()=>{r?.(),Q()},setScanUniqueKey:B,gender:m,resolvedConfig:J,setIsVideoUploaded:U})})]}):e.jsx(s.LanguageContextProvider,{children:e.jsx(T,{isFaceScan:!1,scanId:q,isMeasurementAvailable:E,userDetails:a,onScanSuccess:d,isVideoUploadedCorrect:j,config:J})}):e.jsx(b.Provider,{value:{setStartGyro:K,handleFileUpload:te,setUploadLoading:w},children:e.jsx(p,{children:e.jsx(s.LanguageContextProvider,{children:e.jsx(k,{config:J,scanID:q,userDetails:a,setIsVideoUploaded:U,setScanFailsError:A,setScanStartTime:V,setScanUniqueKey:B})})})})};
|
|
2
|
+
//# sourceMappingURL=BodyScan-CUlUT-1a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BodyScan-CUlUT-1a.js","sources":["../src/Icons/SwitchIcon.tsx","../src/components/bodyScan/LevelScreen.tsx","../src/utils/context/mediaContext.tsx","../src/components/bodyScan/CameraScanChild.tsx","../src/customHooks/useTensorFlow.ts","../src/utils/context/paramsContext.tsx","../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/BodyScan.tsx","../src/customHooks/useGyroSensor.ts"],"sourcesContent":["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\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] 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","\"use client\"\nimport React, {\n createContext,\n Dispatch,\n ReactNode,\n SetStateAction,\n useEffect,\n useLayoutEffect,\n useMemo,\n useState,\n} from \"react\";\n\nexport const MEDIA_TYPES = {\n DESKTOP: \"DESKTOP\",\n TAB: \"TAB\",\n MOBILE: \"MOBILE\",\n};\n\ninterface MediaContextType {\n size: number[];\n setSize: Dispatch<SetStateAction<number[]>>;\n clearInputs: boolean;\n setClearInputs: Dispatch<SetStateAction<boolean>>;\n media: string;\n}\n\nexport const MediaContext = createContext<MediaContextType | undefined>(\n undefined\n);\n\nfunction MediaContextProvider({ children }: { children: ReactNode }) {\n const [size, setSize] = useState([window?.innerWidth, window?.innerHeight]);\n const [clearInputs, setClearInputs] = useState(false);\n\n const updateSize = () => {\n setSize([window?.innerWidth, window?.innerHeight]);\n };\n useEffect(() => {\n updateSize();\n }, []);\n useLayoutEffect(() => {\n window.addEventListener(\"resize\", updateSize);\n return () => window.removeEventListener(\"resize\", updateSize);\n }, [updateSize]);\n let media = MEDIA_TYPES.DESKTOP;\n if (size[0] > 768 && size[0] < 1024) {\n media = MEDIA_TYPES.TAB;\n }\n if (size[0] < 768) {\n media = MEDIA_TYPES.MOBILE;\n }\n\n const mediaDetails = useMemo(\n () => ({\n size,\n setSize,\n clearInputs,\n setClearInputs,\n media,\n }),\n [size, clearInputs, media]\n );\n\n return (\n <MediaContext.Provider value={mediaDetails}>\n {children}\n </MediaContext.Provider>\n );\n}\n\nexport default MediaContextProvider;\n","import { useContext } from \"react\";\nimport Webcam from \"react-webcam\";\nimport CloseIcon from \"@mui/icons-material/Close\";\nimport { CameraScanChildProps } from \"../../types/interfaces\";\nimport { MEDIA_TYPES, MediaContext } from \"../../utils/context/mediaContext\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { pauseIcon, videoConstraints, voiceOverAssetsPath } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\n\n\n\nfunction CameraScanChild({\n handleShowStreamCamera,\n loadingCam,\n handleUserMedia,\n handlePause,\n pause,\n recordingStarted,\n startSendingVideoFrames,\n showPause,\n webcamRef,\n resetDetector,\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 <CloseIcon className=\"text-[#fff]\" />\n </span>\n\n <div className=\"w-full h-full overflow-hidden \">\n {media === MEDIA_TYPES.MOBILE && (\n <Webcam\n audio={false}\n ref={webcamRef}\n screenshotQuality={1}\n videoConstraints={videoConstraints}\n mirrored\n screenshotFormat=\"image/jpeg\"\n onUserMedia={handleUserMedia}\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}","\"use client\"\nimport { createContext } from \"react\";\n\nconst ParamsContext = createContext<any>(null);\n\nexport default ParamsContext;\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 { 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 [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\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\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};\n\n\tconst handleUserMedia = useCallback(() => {\n\t\tsetTimeout(() => {\n\t\t\tsetLoadingCam(false);\n\t\t}, 1000);\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\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\tconst mediaRecorderOptions = {\n\t\t\t\t\tmimeType: 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\tconst mediaRecorderOptions = {\n\t\t\t\t\tmimeType: 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\thandleFileUpload?.(videoFile);\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\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} />\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 { Close as CloseIcon } from \"@mui/icons-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\";\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{/* <VideoPlayer link={gender ? GENDER[gender].PRE_LINK : GENDER.male.PRE_LINK} /> */}\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<CloseIcon 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 swan from \"../utils/service/swanService\";\nimport { GenderType } from \"../utils/enums\";\nimport SpecificButton from \"../atoms/specificButton/SpecificButton\";\nimport { LanguageContext } from \"../utils/context/languageContext\";\nimport { LanguageKeys } from \"../utils/languageKeys\";\n\nfunction SignUp({\n\tscanId,\n\tuserDetails,\n\tconfig,\n\tisFaceScan,\n\tisVideoUploadedCorrect,\n\tisMeasurementAvailable,\n\tonScanSuccess,\n\tisSuccess,\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}) {\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}\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) {\n\t\t\thandleSignUp();\n\t\t}\n\t}, [isVideoUploadedCorrect]);\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 && onScanSuccess} />}\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 { useCallback, useContext, useEffect, useState } 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 posthog from \"posthog-js\";\nimport { BodyScanProps } from \"../../bodyScan\";\nimport useGyroSensor from \"../../customHooks/useGyroSensor\";\nimport { checkCameraPermission, createObjectMetadataArray, generateUuid, getCurrentTimeInSeconds, handleErrorMessage, handleScanTimeCapture, handleWebSocketCapture } from \"../../utils/utils\";\nimport LanguageContextProvider, { LanguageContext } from \"../../utils/context/languageContext\";\nimport { useLocalConfig } from \"../../config/useLocalConfig\";\nimport swan from \"../../utils/service/swanService\";\nimport { posthogPublicHost, posthogPublicKey } from \"../../utils/constants\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport MediaContextProvider from \"../../utils/context/mediaContext\";\n\nconst clothesFit = \"0\";\n\nexport const BodyScan: React.FC<BodyScanProps> = ({ userDetails, config, onRetry, onScanError, isError, isSuccess, onScanSuccess }) => {\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\tconst { setPreferredLanguage } = useContext(LanguageContext) || {};\n\tconst resolvedConfig = useLocalConfig(config);\n\n const handleShowStreamCamera = useCallback(() => {\n setScanUniqueKey(generateUuid());\n setScanFailsError(\"\");\n setUploadLoading(false);\n setIsVideoUploaded(false);\n }, []);\n\n const onError = (data: any) => {\n onScanError({ ...data, message: handleErrorMessage(data) });\n clearScanStartTimeAndScanId();\n setIsMeasurementAvailable(false);\n setScanFailsError(data);\n setIsVideoUploadedCorrect(false);\n handleScanTimeCapture({\n eventName: `${shopDomain}/measurement_failed/fit-view`,\n scanID: scanUniqueKey,\n status: \"failed\",\n email,\n message: handleErrorMessage(data),\n });\n if (scanStartTime)\n handleScanTimeCapture({\n eventName: `${shopDomain}/scan_completion_time`,\n scanID: scanUniqueKey,\n status: \"failed\",\n completionTime: getCurrentTimeInSeconds() - scanStartTime,\n email,\n });\n };\n\n const clearScanStartTimeAndScanId = () => {\n setScanStartTime(null);\n setScanUniqueKey(\"\");\n };\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\t// onScanSuccess?.(data);\n\t\t\t\treturn;\n\t\t\t}\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 const handleMeasurementRecommendation = (scanId?: string) => {\n setIsMeasurementAvailable(false);\n setScanFailsError(\"\");\n setIsVideoUploadedCorrect(false);\n swan.measurement.handleMeasurementSocket({\n scanId: scanId || scanUniqueKey,\n onOpen: () => {\n handleWebSocketCapture({\n eventName: `${shopDomain}/webSocket`,\n scanID: scanUniqueKey,\n connection: \"open\",\n type: \"measurement_recommendation\",\n email,\n });\n },\n onClose: () =>\n handleWebSocketCapture({\n eventName: `${shopDomain}/webSocket`,\n scanID: scanUniqueKey,\n connection: \"close\",\n type: \"measurement_recommendation\",\n email,\n }),\n onError: (err) => {\n onError(err);\n handleWebSocketCapture({\n eventName: `${shopDomain}/webSocket`,\n scanID: scanUniqueKey,\n connection: \"error\",\n type: \"measurement_recommendation\",\n email,\n });\n },\n onSuccess: (data) => {\n handleWebSocketCapture({\n eventName: `${shopDomain}/webSocket`,\n scanID: scanUniqueKey,\n connection: \"success\",\n type: \"measurement_recommendation\",\n email,\n });\n onSuccess(data);\n },\n });\n };\n\n const handleFileUpload = useCallback(\n async (file: File) => {\n const arrayMetaData = createObjectMetadataArray({\n gender,\n focal_length: `${deviceFocalLength}`,\n height: `${heightInCm}`,\n customer_store_url: shopDomain,\n clothes_fit: clothesFit,\n scan_type: scanType,\n callback_url: callbackUrl || \"https://example.com/webhook\",\n });\n handleScanTimeCapture({\n eventName: `${shopDomain}/body_scan_meta_data`,\n scanID: scanUniqueKey,\n email,\n data: JSON.stringify(arrayMetaData),\n });\n try {\n await swan.fileUpload.uploadFileFrontend({\n file,\n arrayMetaData,\n scanId: scanUniqueKey,\n email,\n });\n await swan.fileUpload.setDeviceInfo({\n model: deviceModelName,\n detection: \"manual\",\n gyro: gyroData,\n scanId: scanUniqueKey,\n });\n console.log(\"video successfully uploaded\");\n setIsVideoUploaded(false);\n handleScanTimeCapture({\n eventName: `${shopDomain}/scan_success`,\n scanID: scanUniqueKey,\n status: \"success\",\n email,\n data: JSON.stringify(arrayMetaData),\n });\n handleScanTimeCapture({\n eventName: \"scan finished\",\n scanID: scanUniqueKey,\n status: \"success\",\n email,\n });\n setScanStartTime(getCurrentTimeInSeconds());\n setTimeout(() => {\n setIsVideoUploaded(true);\n }, 3000);\n } catch (error) {\n handleScanTimeCapture({\n eventName: \"scan finished\",\n scanID: scanUniqueKey,\n status: \"failed\",\n email,\n message: handleErrorMessage(error),\n });\n handleScanTimeCapture({\n eventName: `${shopDomain}/scan_failed`,\n scanID: scanUniqueKey,\n status: \"failed\",\n email,\n message: handleErrorMessage(error),\n data: JSON.stringify(arrayMetaData),\n });\n setScanFailsError(handleErrorMessage(error));\n setIsVideoUploaded(false);\n console.log(error, \"video upload failed\");\n } finally {\n setStartGyro(false);\n }\n },\n [scanUniqueKey, gyroData]\n );\n const checkMeasurementStatus = useCallback(\n async (scanId: string) => {\n try {\n const res = await swan.measurement.getMeasurementResult(scanId);\n const isMeasured = res?.data?.isMeasured;\n const tempScanStartTime = scanStartTime || getCurrentTimeInSeconds();\n const currentTimeInSeconds = getCurrentTimeInSeconds();\n const fiveMinutesInSeconds = 5 * 60;\n setLoading(false);\n if (isMeasured === false) {\n clearScanStartTimeAndScanId();\n setScanUniqueKey(generateUuid());\n return;\n }\n setUploadLoading(true);\n if (isMeasured === true) {\n await onSuccess(null);\n } else if (\n isMeasured === null &&\n tempScanStartTime > currentTimeInSeconds + fiveMinutesInSeconds\n ) {\n onError(res?.data?.error);\n } else {\n handleMeasurementRecommendation(scanId);\n }\n } catch (error) {\n console.log(error);\n clearScanStartTimeAndScanId();\n setScanUniqueKey(generateUuid());\n setUploadLoading(false);\n }\n },\n [onError, onSuccess, setScanUniqueKey]\n );\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 const permission = await checkCameraPermission();\n if (permission.disabled) {\n handleScanTimeCapture({\n eventName: `${shopDomain}/camera_activation`,\n scanID: scanUniqueKey,\n status: \"failed\",\n email,\n });\n setLoading(false);\n } else {\n const scanId = scanUniqueKey;\n if (scanId) {\n checkMeasurementStatus(scanId);\n } else {\n setLoading(false);\n }\n handleScanTimeCapture({\n eventName: `${shopDomain}/camera_activation`,\n scanID: scanUniqueKey,\n status: \"success\",\n email,\n });\n }\n setShowDeniedModal(permission);\n setScanFailsError(\"\");\n setIsVideoUploaded(false);\n }, [\n checkMeasurementStatus,\n email,\n scanUniqueKey,\n setScanUniqueKey,\n shopDomain,\n ]);\n\n\tuseEffect(() => {\n\t\tposthog.init(posthogPublicKey, { api_host: posthogPublicHost });\n\t\tposthog.capture(\"$pageview\");\n\t}, []);\n\tuseEffect(() => {\n\t\tsetPreferredLanguage?.(resolvedConfig?.language);\n\t}, [resolvedConfig]);\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\n\tif (isError) {\n\t\treturn (\n\t\t\t<LanguageContextProvider>\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\t// onRetry?.();\n\t\t\t\t\t\t\t// handleShowStreamCamera();\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</LanguageContextProvider>\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/>\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] bg-opacity-80 bg-[#1b1b1b] absolute justify-center items-center w-full h-full\">\n\t\t\t\t<LoadingScreen url={resolvedConfig?.loader} />\n\t\t\t</div>\n\t\t);\n\t}\n\tif (showDeniedModal.disabled) {\n\t\treturn (\n\t\t\t<LanguageContextProvider>\n\t\t\t\t<Modal />\n\t\t\t</LanguageContextProvider>\n\t\t);\n\t}\n\n\tif (!uploadLoading && !scanFailsError) {\n\t\treturn (\n\t\t\t<ParamsContext.Provider value={{ setStartGyro, handleFileUpload, setUploadLoading }}>\n\t\t\t\t<MediaContextProvider>\n\t\t\t\t\t<LanguageContextProvider>\n\t\t\t\t\t\t<AngleDetector\n\t\t\t\t\t\t\tconfig={resolvedConfig}\n\t\t\t\t\t\t\tscanID={scanUniqueKey}\n\t\t\t\t\t\t\tuserDetails={userDetails}\n\t\t\t\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\t\t\t\tsetScanFailsError={setScanFailsError}\n\t\t\t\t\t\t\tsetScanStartTime={setScanStartTime}\n\t\t\t\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</LanguageContextProvider>\n\t\t\t\t</MediaContextProvider>\n\t\t\t</ParamsContext.Provider>\n\t\t);\n\t}\n\tif ((uploadLoading || isMeasurementAvailable) && !scanFailsError) {\n\t\treturn (\n\t\t\t<LanguageContextProvider>\n\t\t\t\t<SignUp\n\t\t\t\t\tisFaceScan={false}\n\t\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\t\tuserDetails={userDetails}\n\t\t\t\t\tonScanSuccess={onScanSuccess}\n\t\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\t\tconfig={resolvedConfig}\n\t\t\t\t/>\n\t\t\t</LanguageContextProvider>\n\t\t);\n\t}\n\treturn (\n\t\t<LanguageContextProvider>\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</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":["SwitchIcon$1","React","memo","size","_jsxs","width","height","viewBox","fill","xmlns","children","_jsx","d","stroke","strokeWidth","strokeLinecap","strokeLinejoin","LevelScreen$1","angle","countdown","isScanning","isInTargetRange","stabilityScore","config","translate","useContext","LanguageContext","getProximityToTarget","useCallback","Math","max","min","backgroundColor","useMemo","style","angleDetector","successAngleBackground","proximity","successAngleLowBackground","round","handelTextColour","isLight","successAngleTextLightColor","successAngleTextDarkColor","getTextColor","handelColourCode","getColorCode","cd","fixVh","document","documentElement","setProperty","window","innerHeight","addEventListener","className","Header","noTitle","resolvedConfig","border","fontFamily","base","baseFontFamily","cn","transform","transition","color","SwitchIcon","LanguageKeys","startLevelCheck","leavePhone","placePhoneUpright","MEDIA_TYPES","MediaContext","createContext","undefined","MediaContextProvider","setSize","useState","innerWidth","clearInputs","setClearInputs","updateSize","useEffect","useLayoutEffect","removeEventListener","media","mediaDetails","Provider","value","CameraScanChild","handleShowStreamCamera","loadingCam","handleUserMedia","handlePause","pause","recordingStarted","startSendingVideoFrames","showPause","webcamRef","resetDetector","onClick","CloseIcon","Webcam","audio","ref","screenshotQuality","videoConstraints","mirrored","screenshotFormat","onUserMedia","position","top","bottom","zIndex","objectFit","SpecificButton","prefix","pauseIcon","buttonText","buttonFunc","btnSecondary","restart","startScan","disabled","id","crossOrigin","preload","src","voiceOverAssetsPath","globalLoadingPromise","globalDetector","globalPoseLib","ParamsContext","audioTimeoutId","lastVideoPlayed","ScanningComponent$1","setIsScanLocked","scanID","setIsVideoUploaded","setScanFailsError","setScanStartTime","setScanUniqueKey","userDetails","gender","heightInCm","email","shopDomain","useRef","mediaRecorderRef","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","counter","setStartGyro","handleFileUpload","setUploadLoading","clearTimeout","generateUuid","speechService","stopAudio","stop","forEach","el","setTimeout","handleReScan","rescanSupportCaptureEvent","eventName","status","swan","poseDetection","disconnect","stopRecording","playAudio","handleSocket","connect","posthog","capture","handleSpinDataAvailable","data","concat","handleScanTimeCapture","message","handleStartCaptureClick","stream","mediaRecorderOptions","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","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","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","onRetry","onScanError","isError","deviceModelName","callbackUrl","uploadLoading","setIsVideoUploadedCorrect","setIsMeasurementAvailable","isVideoUploaded","startGyro","scanUniqueKey","scanStartTime","gyroData","setGyroData","permissionGranted","setPermissionGranted","alpha","toString","timestamp","Date","toISOString","useGyroSensor","setPreferredLanguage","useLocalConfig","onError","clearScanStartTimeAndScanId","completionTime","onSuccess","scanStatus","resultType","code","scanIdToSet","handleMeasurementRecommendation","measurement","handleMeasurementSocket","onOpen","handleWebSocketCapture","connection","file","arrayMetaData","createObjectMetadataArray","focal_length","customer_store_url","clothes_fit","scan_type","callback_url","JSON","stringify","fileUpload","uploadFileFrontend","setDeviceInfo","model","detection","gyro","checkMeasurementStatus","res","getMeasurementResult","isMeasured","tempScanStartTime","currentTimeInSeconds","fiveMinutesInSeconds","init","posthogPublicKey","api_host","posthogPublicHost","language","LanguageContextProvider"],"mappings":"ySAkDA,IAAAA,EAAeC,EAAMC,KAhDrB,UAAoBC,KAAEA,EAAO,KAC3B,OACEC,EAAAA,KAAA,MAAA,CACEC,MAAOF,EACPG,OAAQH,EACRI,QAAQ,YACRC,KAAK,OACLC,MAAM,6BAA4BC,SAAA,CAElCC,EAAAA,IAAA,OAAA,CACEC,EAAE,mHACFC,OAAO,QACPC,YAAY,IACZC,cAAc,QACdC,eAAe,UAEjBL,EAAAA,IAAA,OAAA,CACEC,EAAE,0NACFC,OAAO,eACPC,YAAY,IACZC,cAAc,QACdC,eAAe,UAEjBL,EAAAA,IAAA,OAAA,CACEC,EAAE,kOACFC,OAAO,eACPC,YAAY,IACZC,cAAc,QACdC,eAAe,UAEjBL,MAAA,OAAA,CACEC,EAAE,kOACFC,OAAO,eACPC,YAAY,IACZC,cAAc,QACdC,eAAe,UAEjBL,EAAAA,IAAA,OAAA,CACEC,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AAM,CACNC,YAAY,EACZlH,OAAQ8J,EACR1C,uBAAwBA,EACxBvQ,YAAaA,EACbwQ,cAAeA,EACfF,uBAAwBA,EACxB9X,OAAQmC,MA3BV/C,EAAAA,IAAC0H,EAAc7C,SAAQ,CAACC,MAAO,CAAEwJ,eAAcC,oBAAkBC,oBAAkBzO,SAClFC,EAAAA,IAACiE,EAAoB,CAAAlE,SACpBC,EAAAA,IAAC6e,EAAAA,wBAAuB,CAAA9e,SACvBC,EAAAA,IAACiS,EAAa,CACbrR,OAAQmC,EACRgF,OAAQsT,EACRjT,YAAaA,EACbJ,mBAAoBA,EACpBC,kBAAmBA,EACnBC,iBAAkBA,EAClBC,iBAAkBA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import a,{useContext as s,useCallback as r,useMemo as o,createContext as i,useState as l,useEffect as c,useLayoutEffect as d,useRef as u}from"react";import{L as m,H as f,a as h,b as p,S as g,n as y,v,r as x,s as b,k as w,j as S,o as N,e as C,c as F,q as D,t as I,i as k,w as T,x as L,V as E,y as $,C as M,z as _,A as z,B as A,D as j,G as U,u as P,E as V,p as R,f as W,h as B,l as q}from"./LoadingScreen-DgDeiI0O.js";import O from"clsx";import K from"react-webcam";import H from"@mui/icons-material/Close";import J,{posthog as G}from"posthog-js";import{Dialog as Q,Box as Y,Drawer as X}from"@mui/material";import{Close as Z}from"@mui/icons-material";import ee from"video.js";var te=a.memo(function({size:n=16}){return e("svg",{width:n,height:n,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t("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"}),t("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"}),t("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"}),t("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"}),t("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 ne=a.memo(function({angle:n,countdown:a,isScanning:i,isInTargetRange:l,stabilityScore:c,children:d,config:u}){const{translate:p}=s(m)||{},g=r(()=>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=o(()=>{if(i)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=g();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)})`},[i,g]),v=r((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`,[]),x=r((e=!1)=>{const t=g();return i?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]`:v(e,t)},[i,g]),b=r((e,t)=>t>70||e?u?.style?.angleDetector?.successAngleTextLightColor:u?.style?.angleDetector?.successAngleTextDarkColor,[]),w=r((e=!1)=>{const t=g();return i?u?.style?.angleDetector?.successAngleTextLightColor:b(e,t)},[i,g]),S=a;function N(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return N(),window.addEventListener("resize",N),e("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:[t("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:t("div",{className:"flex justify-start ",children:t(f,{noTitle:!0,resolvedConfig:u})})}),null!==S?t("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 ${w()}`},children:t("div",{className:`text-[3rem] font-bold text-[${w()}]`,style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:S})}):e("div",i?{className:"relative flex flex-col items-center justify-center",children:[t("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:t("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),d]}:{className:O("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",l?"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 ${w()}`},children:[t("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${w()}]/80`,style:{backgroundColor:`${w()}B3`}}),e("div",{className:O("mt-[.5rem] w-[180px] flex-col flex items-center absolute top-[60px]",x()),style:{color:w()},children:[t(te,{size:30}),e("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",p?.(h.startLevelCheck),t("br",{})]})]})]}),null!==S&&t("div",{className:"absolute bottom-[8rem] text-center",children:t("div",{className:O("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",x()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:w()},children:p?.(h.leavePhone)})}),l&&null===S&&!i&&t("div",{className:"absolute bottom-[8rem] w-[12rem]",children:t("div",{className:`h-[.375rem] w-full bg-[${w()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${w()}33`},children:t("div",{className:`h-full bg-[${w()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${n}%`,backgroundColor:`${w()}B3`}})})}),null===S&&!i&&t("div",{className:"absolute bottom-[5rem] text-center",children:e("div",{className:O("text-[1.5rem] font-light",x()),style:{color:w()},children:[Math.round(n),"°"]})}),null===S&&!i&&t("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:t("div",{className:O("text-[.75rem] opacity-50",x()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:w()},children:p?.(h.placePhoneUpright)})})]})});const ae="DESKTOP",se="TAB",re="MOBILE",oe=i(void 0);function ie({children:e}){const[n,a]=l([window?.innerWidth,window?.innerHeight]),[s,r]=l(!1),i=()=>{a([window?.innerWidth,window?.innerHeight])};c(()=>{i()},[]),d(()=>(window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]);let u=ae;n[0]>768&&n[0]<1024&&(u=se),n[0]<768&&(u=re);const m=o(()=>({size:n,setSize:a,clearInputs:s,setClearInputs:r,media:u}),[n,s,u]);return t(oe.Provider,{value:m,children:e})}function le({handleShowStreamCamera:n,loadingCam:a,handleUserMedia:r,handlePause:o,pause:i,recordingStarted:l,startSendingVideoFrames:c,showPause:d,webcamRef:u,resetDetector:f,config:x}){const{media:b}=s(oe)||{},{translate:w}=s(m)||{};return e("div",{className:"App w-screen h-[100vh] relative ",children:[t("span",{onClick:()=>{n(),f()},className:"fixed right-[20px] top-[20px] z-[999]",children:t(H,{className:"text-[#fff]"})}),t("div",{className:"w-full h-full overflow-hidden ",children:b===re&&t(K,{audio:!1,ref:u,screenshotQuality:1,videoConstraints:p,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:r,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}),e("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[d&&t(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:y,buttonText:w?.(h.pause),buttonFunc:o,resolvedConfig:x,btnSecondary:!0}),i?t("div",{children:t(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:w?.(h.restart),buttonFunc:n,resolvedConfig:x,btnSecondary:!0})}):l?null:t(g,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(a?"!opacity-50":""),buttonText:w?.(h.startScan),buttonFunc:c,disabled:a,resolvedConfig:x})]}),t("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${v}scanAudioInstructions/silence.mp3`})]})}let ce=null,de=null,ue=null;const me=i(null);let fe,he=null,pe=null;var ge=a.memo(function({setIsScanLocked:e,resetDetector:n,scanID:a,setIsVideoUploaded:o,setScanFailsError:i,setScanStartTime:d,setScanUniqueKey:m,userDetails:f,config:h}){const{gender:p,heightInCm:g,email:y,shopDomain:D}=f,I=u(null),k=u(null),[T,L]=l([]),[E,$]=l(!0),[M,_]=l(!1),[z,A]=l(!1),[j,U]=l(!0),[P,V]=l(!1),R=u(null),[W,B]=l(""),[q,O]=l([]),[K,H]=l(""),[G,Q]=l(!1),[Y,X]=l(!1),[Z,ee]=l(!1),[te,ne]=l([]),[ae,se]=l(!1),re=u(!0),{poseDetector:oe}=function(){const[e,t]=l(0),[n,a]=l(0),[s,r]=l(!1),o=u(0),i=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-BehJiApJ.js"),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);ue=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{de=await ue.createDetector(ue.SupportedModels.BlazePose,a),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),de=await ue.createDetector(ue.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),ce=null,!1}}function f(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return c(()=>{if(d.current=!0,!de)return ce||(ce=m()),ce.then(e=>{e&&d.current&&r(!0)}),()=>{d.current=!1};r(!0)},[]),c(()=>{i.current=e,e>6&&o.current<2&&(a(e=>e+1),t(0))},[e]),c(()=>{o.current=n},[n]),{poseDetector:async(e,n)=>{if(!de||!d.current||!n?.current?.video)return;const a=n.current.video;if(!(a.readyState<2))try{const n=await de.estimatePoses(a,{flipHorizontal:!1});if(!n||!n.length)return;const s=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!==o.current||f(s)||t(e=>e+1),1===o.current&&f(s)&&t(e=>e+1),2===o.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:s,spinPhase:n,resetDetector:()=>{o.current=0,i.current=0,t(0),a(0)},retryLoading:async()=>{de||ce||(ce=m(),await ce&&d.current&&r(!0))}}}(),ie=u(!0),ge=u(!1),[ye,ve]=l([]);let xe=0;const{setStartGyro:be,handleFileUpload:we,setUploadLoading:Se}=s(me),Ne=()=>{ge.current=!1,clearTimeout(fe),R.current&&clearTimeout(R.current),m(F()),i(""),Se?.(!1),L([]),$(!0),_(!1),A(!1),U(!0),V(!1),R.current=null,B(""),O([]),H(""),Q(!G),be(!1),b.stopAudio(),X(!1),ee(!1),xe=0,null!==k.current&&k.current.stop(),te.forEach(e=>{k.current&&k.current.removeEventListener("dataavailable",e)}),ne([]),re.current=!0,se(!1),o(!1)},Ce=r(()=>{setTimeout(()=>{$(!1)},1e3)},[]),Fe=r(()=>{x({eventName:`${D}/rescan`,email:y,scanID:a,height:g,gender:p,status:!1}),re.current=!1,Ne(),_e()},[Ne,a,y]),De=r(()=>{re.current=!1,ee(!0),se(!1),R.current&&clearTimeout(R.current),k.current&&k.current.pause(),b.stopAudio(),w.poseDetection.disconnect(),xe=0,k.current&&k.current.stop(),te.forEach(e=>{k.current&&k.current.removeEventListener("dataavailable",e)}),ne([]),clearTimeout(fe)},[k,te,b,re]),Ie=r(async()=>{re.current=!0,await b.playAudio(`${v}SpotOn.mp3`),ee(!1),se(!1),R.current&&clearTimeout(R.current),_(!1)},[R,b]),ke=r(async()=>{try{he=await w.poseDetection.connect(),J.capture(`${D}/pose_detection_connected`,{scanID:a,email:y,id:he})}catch(e){console.log(e,"while connecting websocket")}},[a,D,y]),Te=r(({data:e})=>{e&&e.size>0&&re.current&&(L(t=>t.concat(e)),!ge.current&&I.current&&(ge.current=!0,oe(()=>{Ie(),S({eventName:`${D}/tensorFlow`,scanID:a,email:y,message:"recording stopped by tensorflow "})},I)))},[Ie,S,D,a,y,I]),Le=r(async()=>{q.length>0&&re.current&&(await b.playAudio(v+q[q.length-1]),re.current&&(fe=setTimeout(Le,2e3)))},[q,re]),Ee=r(()=>{k&&k.current&&k.current.stop(),_(!0);try{if(I&&I.current&&I.current.stream){const e={mimeType:ye[0]};k.current=new MediaRecorder(I.current.stream,e),k.current.addEventListener("dataavailable",Te),ne([...te,Te]),k.current.start(1e3),U(!1)}}catch(e){console.log("error while using media recorder",e)}},[I,ye,Te,te]),$e=r(async()=>{R.current&&clearTimeout(R.current),Ee(),re.current&&(R.current=setTimeout(async()=>{re.current&&(await b.playAudio(`${v}SpotOn.mp3`),_(!1))},15e3)),A(!0),re.current&&await b.playAudio(`${v}Spin.mp3`)},[Ee,re,b]),Me=r(({data:e})=>{e.size>0&&w.poseDetection.connected()&&(w.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){const t=document.querySelector("#audioElement");!0===e.status&&e.sid===he?xe<2?(0===xe&&t?.paused&&await b.playAudio(v+e.audio),xe+=1):(H(e.audio),clearTimeout(fe),w.poseDetection.disconnect(),setTimeout($e,1e3)):(xe=0,!t?.paused||pe&&pe?.audioName===e.audio?pe?.audioName===e.audio&&t?.paused&&(pe&&pe.no_of_times_skipped>=pe.skipCount?(pe.no_of_times_skipped=0,b.playAudio(v+e.audio)):pe&&(pe.no_of_times_skipped+=1)):(pe={skipCount:2,no_of_times_skipped:0,audioName:e.audio},b.playAudio(v+e.audio)))}}),I?.current&&null!==I.current.getScreenshot()&&w.poseDetection.videoEmit({image:I.current.getScreenshot()||"",scanId:a}))},[I,a,w,he,xe,$e,b]),_e=r(async()=>{V(!0),be(!0),ie.current&&(ie.current=!1,S({eventName:"scan started",scanID:a,status:"success",email:y})),d(N()),$(!0),re.current&&await b.playAudio(`${v}StartScan.mp3`),re.current&&await b.playAudio(`${v}LiftArmsAndHoldAtHip.mp3`),re.current&&(V(!1),_(!0),X(!0),se(!0),Ce());try{if(I&&I.current&&I.current.stream&&re.current){const e={mimeType:ye[0]};re.current&&(k.current=new MediaRecorder(I.current.stream,e)),re.current&&k.current&&k.current.addEventListener("dataavailable",Me),ne([...te,Me]),k.current&&k.current.start(1e3),U(!1),re.current&&(fe=setTimeout(Le,2e3))}}catch(e){console.log("error ----------",e)}},[I,ye,Me,te,Le,re]);return c(()=>(D&&(e(!0),ke()),()=>{he&&(w.poseDetection.disconnect(),J.capture(`${D}/pose_detection_disconnected`,{scanID:a,email:y,id:he})),te.forEach(e=>{k?.current?.removeEventListener("dataavailable",e)})}),[G,D]),c(()=>{q.push(W)},[W]),c(()=>{O([])},[K]),c(()=>{const e=T.length&&T.length>0;j||!e||M||!re.current||Z||k&&k.current&&(M||(k.current.stop(),U(!0)))},[j,M,T,Z]),c(()=>{const e=T.length&&T.length>0;if(j||!e||M)console.log("No video found to upload");else if(k&&k.current&&re.current&&!Z&&!M){const e=new File(T,`${a}.webm`,{type:"video/webm"});Se?.(!0),i(""),we?.(e)}},[j,M,T,Z,k,re]),c(()=>{if("undefined"!=typeof MediaRecorder){const e=C.filter(e=>MediaRecorder.isTypeSupported(e));ve(e)}},[]),c(()=>{Ne()},[]),t(le,{resetDetector:n,handleShowStreamCamera:Ne,loadingCam:E,handlePause:De,showRestart:Y,pause:Z,handleReScan:Fe,recordingStarted:M,isScanning:P,startSendingVideoFrames:_e,faceDone:z,stopRecording:Ie,showPause:ae,webcamRef:I,handleUserMedia:Ce,config:h})});function ye({scanID:e,userDetails:n,setIsVideoUploaded:a,setScanFailsError:s,setScanStartTime:r,setScanUniqueKey:o,config:i}){const[d,m]=l(90),[f,h]=l(0),[p,g]=l(null),[y,v]=l(!1),[x,b]=l(0),w=u([]),[S,N]=l(!1),C=d-f,F=C>=80&&C<=95;c(()=>{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})}},[]),c(()=>{if(w.current=[...w.current.slice(-4),C],w.current.length>=5){const e=Math.max(...w.current)-Math.min(...w.current);b(F&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}F||null===p&&!y||I()},[C,F,p,y]),c(()=>{x>=100&&null===p&&!y&&D(),x<50&&null!==p&&I()},[x,p,y]);const D=()=>{g(3);const e=setInterval(()=>{g(t=>null===t||t<=1?(clearInterval(e),v(!0),null):t-1)},1e3)},I=()=>{g(null),S||v(!1)};return t(ne,{angle:C,countdown:p,isScanning:y,isInTargetRange:F,stabilityScore:x,config:i,children:y&&t(ge,{setIsScanLocked:N,resetDetector:()=>{m(90),h(0),g(null),v(!1),b(0),N(!1),w.current=[]},scanID:e,userDetails:n,setIsVideoUploaded:a,setScanFailsError:s,setScanStartTime:r,setScanUniqueKey:o,config:i})})}function ve({message:a,config:r}){const{translate:o}=s(m)||{};return t(Q,{open:!0,className:"confirm-modal",children:t("div",{className:"modal-main",children:t("div",{className:"text-center",children:e(n,a?{children:[t("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?.(h.cameraAlreadyInUse)}),t("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?.(h.tryClosingBrowser)})]}:{children:[t("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?.(h.checkCameraSettings)}),t("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?.(h.setting)} > ${D()} > ${o?.(h.enableCameraPermissions)}`})]})})})})}function xe({setShowDrawer:e,config:n,loader:a}){const[s,o]=l({disabled:!1,message:""}),[i,d]=l(!0),m=u(null),f=r(async()=>{const e=await I();o(e),d(!1)},[]);return c(()=>{f()},[]),i?t(k,{url:a}):s?.disabled?t(ve,{config:n,message:s?.message}):t(K,{audio:!1,ref:m,screenshotQuality:1,videoConstraints:p,mirrored:!0,onUserMedia:()=>e?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function be({link:e,onReady:n,wrapperClassName:a="[&_video]:rounded-t-[20px] w-full h-full"}){const s=u(null),r=u(null);let o={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:T};return c(()=>{if(!r.current&&e&&s?.current){const t=ee(s.current,{...o});t.ready(()=>{r.current=t;const a={...o,sources:[{src:e,type:"application/x-mpegURL"}]};t.autoplay(a.autoplay),t.src(a.sources),n?.(t)})}},[e,s]),c(()=>{const e=r.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),r.current=null)}},[r]),t("div",{className:a,children:t("video",{ref:s,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function we({scanFailsError:a,serverAtCapacity:r=!1,onNext:o,gender:i,setScanUniqueKey:c,resolvedConfig:d,setIsVideoUploaded:u}){const{translate:p}=s(m)||{},[y,v]=l(!1),x=()=>{v(!y)};return e(n,{children:[e("div",{className:"flex flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:d?.style?.base?.backgroundColor},children:[t("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:t(f,{noTitle:!0,resolvedConfig:d})}),e("div",{className:"flex-1",children:[a&&e("div",{className:"px-[1rem]",children:[t("h2",{className:"text-center",style:{fontFamily:d?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:d?.style?.heading?.headingFontSize||"32px",color:d?.style?.heading?.headingColor||"#000",fontWeight:d?.style?.heading?.headingFontWeight||"normal"},children:p?.(h.issueWithScan)}),t("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:p?.(h.reason)}),t("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:L(a)}),t("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:x,src:E[i],alt:"icon"})]}),r&&e("div",{className:"p-[1rem] text-center",children:[t("h3",{style:{fontFamily:d?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:d?.style?.heading?.headingFontSize||"32px",color:d?.style?.heading?.headingColor||"#000",fontWeight:d?.style?.heading?.headingFontWeight||"normal"},children:p?.(h.serverAtCapacity)}),t("p",{className:"text-base mt-[0.5rem]",style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:p?.(h.serverAtCapacityDescription)})]})]}),a&&t("div",{className:"p-[1rem] flex gap-[0.5rem]",children:t(g,{disabled:!1,buttonText:p?.(h.scanAgain),className:"!shadow-none",buttonFunc:()=>{o?o?.():c(F()),u(!1)},resolvedConfig:d})})]}),y&&e(Q,{className:"w-screen h-screen video-modal",onClose:x,open:y,children:[t("div",{className:"flex justifyEnd ",children:t("span",{className:"closeBtn",onClick:x,children:t(Z,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),t("div",{className:"aspect-video object-cover rounded-[20px] ",children:t(be,{link:i?$[i].PRE_LINK:$.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function Se({scanId:n,userDetails:a,config:o,isFaceScan:i,isVideoUploadedCorrect:d,isMeasurementAvailable:u,onScanSuccess:p,isSuccess:y}){const{gender:v,shopDomain:x,heightInCm:b,deviceFocalLength:S,userName:N,email:C,scanType:F}=a,D=[M,_,z].includes(F),[I,k]=l(!0),T=r(async()=>{try{D&&await w.auth.addUser({scanId:n,email:C,name:N,gender:v,height:b}),G.capture(x,{scanID:n,email:C,height:b,focalLength:S,clothesFit:"0",gender:v})}catch(e){console.log(e)}},[D]),{translate:L}=s(m)||{};c(()=>{d&&T()},[d]);const E=y||(i?u&&d:d||u);return t(Y,{className:"flex h-full w-full flex-col ",children:e("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[t(xe,{loader:o?.loader,setShowDrawer:k}),t(X,{open:I,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:t("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("div",{className:"w-full h-full flex flex-col",children:[t(f,{title:L?.(h.measurementsBeingTaken),resolvedConfig:o}),t("div",{className:"flex items-center justify-center flex-1",children:t("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:t("source",{src:v===U.Male?A:j,type:"video/mp4"})})}),E&&t(g,{resolvedConfig:o,className:"!w-[180px] mx-auto",buttonText:L?.(h.next),buttonFunc:p&&p})]})})})]})})}const Ne=({userDetails:n,config:a,onRetry:o,onScanError:i,isError:d,isSuccess:u,onScanSuccess:f})=>{const{gender:h,scanType:p,shopDomain:g,heightInCm:y,email:v,deviceFocalLength:x,deviceModelName:b,callbackUrl:C}=n,[D,T]=l(!1),[E,$]=l(!1),[M,_]=l(!1),[z,A]=l({disabled:!1,message:""}),[j,U]=l(""),[O,K]=l(!1),[H,G]=l(!0),[Q,Y]=l(!1),[Z,ee]=l(""),[te,ne]=l(N()),{gyroData:ae}=function(e){const[t,n]=l([]),[a,s]=l(!1),o=r(e=>{try{const{alpha:t,beta:a,gamma:s}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:a?.toString()||void 0,gamma:s?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),i=r(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?s(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else s(!0)},[]);return c(()=>(e&&a?window.addEventListener("deviceorientation",o):n([]),()=>{window.removeEventListener("deviceorientation",o)}),[e,a,o]),c(()=>{e&&i()},[e,i]),{gyroData:t}}(Q),{setPreferredLanguage:se}=s(m)||{},re=P(a),oe=r(()=>{ee(F()),U(""),T(!1),K(!1)},[]),le=e=>{i({...e,message:L(e)}),ce(),_(!1),U(e),$(!1),S({eventName:`${g}/measurement_failed/fit-view`,scanID:Z,status:"failed",email:v,message:L(e)}),te&&S({eventName:`${g}/scan_completion_time`,scanID:Z,status:"failed",completionTime:N()-te,email:v})},ce=()=>{ne(null),ee("")},de=r(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return void S({eventName:`${g}/measurement_success/intermediate`,scanID:Z,status:"success",email:v});ce();const t=Z;_(!0),S({eventName:`${g}/measurement_success/fit-view`,scanID:t,status:"success",email:v}),te&&S({eventName:`${g}/scan_completion_time`,scanID:t,status:"success",completionTime:N()-te,email:v})},[p,g,Z]),ue=e=>{_(!1),U(""),$(!1),w.measurement.handleMeasurementSocket({scanId:e||Z,onOpen:()=>{q({eventName:`${g}/webSocket`,scanID:Z,connection:"open",type:"measurement_recommendation",email:v})},onClose:()=>q({eventName:`${g}/webSocket`,scanID:Z,connection:"close",type:"measurement_recommendation",email:v}),onError:e=>{le(e),q({eventName:`${g}/webSocket`,scanID:Z,connection:"error",type:"measurement_recommendation",email:v})},onSuccess:e=>{q({eventName:`${g}/webSocket`,scanID:Z,connection:"success",type:"measurement_recommendation",email:v}),de(e)}})},fe=r(async e=>{const t=V({gender:h,focal_length:`${x}`,height:`${y}`,customer_store_url:g,clothes_fit:"0",scan_type:p,callback_url:C||"https://example.com/webhook"});S({eventName:`${g}/body_scan_meta_data`,scanID:Z,email:v,data:JSON.stringify(t)});try{await w.fileUpload.uploadFileFrontend({file:e,arrayMetaData:t,scanId:Z,email:v}),await w.fileUpload.setDeviceInfo({model:b,detection:"manual",gyro:ae,scanId:Z}),console.log("video successfully uploaded"),K(!1),S({eventName:`${g}/scan_success`,scanID:Z,status:"success",email:v,data:JSON.stringify(t)}),S({eventName:"scan finished",scanID:Z,status:"success",email:v}),ne(N()),setTimeout(()=>{K(!0)},3e3)}catch(e){S({eventName:"scan finished",scanID:Z,status:"failed",email:v,message:L(e)}),S({eventName:`${g}/scan_failed`,scanID:Z,status:"failed",email:v,message:L(e),data:JSON.stringify(t)}),U(L(e)),K(!1),console.log(e,"video upload failed")}finally{Y(!1)}},[Z,ae]),he=r(async e=>{try{const t=await w.measurement.getMeasurementResult(e),n=t?.data?.isMeasured,a=te||N(),s=N(),r=300;if(G(!1),!1===n)return ce(),void ee(F());T(!0),!0===n?await de(null):null===n&&a>s+r?le(t?.data?.error):ue(e)}catch(e){console.log(e),ce(),ee(F()),T(!1)}},[le,de,ee]),pe=r(async()=>{if(+y<152.4||+y>213.36)return void i({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await I();if(e.disabled)S({eventName:`${g}/camera_activation`,scanID:Z,status:"failed",email:v}),G(!1);else{Z?he(Z):G(!1),S({eventName:`${g}/camera_activation`,scanID:Z,status:"success",email:v})}A(e),U(""),K(!1)},[he,v,Z,ee,g]);return c(()=>{J.init(R,{api_host:W}),J.capture("$pageview")},[]),c(()=>{se?.(re?.language)},[re]),c(()=>{d||u||g&&pe()},[g,y,d,u]),c(()=>{d||u||O&&g&&Z&&ue()},[O,g,Z,d,u]),d?e(B,{children:[t(xe,{}),t(X,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:t(we,{scanFailsError:j||d,onNext:()=>{},setScanUniqueKey:ee,gender:h,resolvedConfig:re,setIsVideoUploaded:K})})]}):u?t(Se,{isFaceScan:!1,scanId:Z,isMeasurementAvailable:M,userDetails:n,isVideoUploadedCorrect:E,config:re,isSuccess:u}):H?t("div",{className:"flex top-0 !mt-0 left-0 z-[999] bg-opacity-80 bg-[#1b1b1b] absolute justify-center items-center w-full h-full",children:t(k,{url:re?.loader})}):z.disabled?t(B,{children:t(ve,{})}):D||j?!D&&!M||j?e(B,{children:[t(xe,{}),t(X,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:t(we,{scanFailsError:j,onNext:()=>{o?.(),oe()},setScanUniqueKey:ee,gender:h,resolvedConfig:re,setIsVideoUploaded:K})})]}):t(B,{children:t(Se,{isFaceScan:!1,scanId:Z,isMeasurementAvailable:M,userDetails:n,onScanSuccess:f,isVideoUploadedCorrect:E,config:re})}):t(me.Provider,{value:{setStartGyro:Y,handleFileUpload:fe,setUploadLoading:T},children:t(ie,{children:t(B,{children:t(ye,{config:re,scanID:Z,userDetails:n,setIsVideoUploaded:K,setScanFailsError:U,setScanStartTime:ne,setScanUniqueKey:ee})})})})};export{Ne as B};
|
|
2
|
+
//# sourceMappingURL=BodyScan-DtKrwfBB.js.map
|