@swan-admin/swan-dev-web-component 0.1.0-alpha.1772113614 → 0.1.0-alpha.1772707975

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/BodyScan-9r5xhZtT.js +2 -0
  2. package/dist/BodyScan-9r5xhZtT.js.map +1 -0
  3. package/dist/BodyScan-B3KPlpJh.js +2 -0
  4. package/dist/BodyScan-B3KPlpJh.js.map +1 -0
  5. package/dist/BodyScan-BHab8msP.js +2 -0
  6. package/dist/BodyScan-BHab8msP.js.map +1 -0
  7. package/dist/BodyScan-Bl1cMFAR.js +2 -0
  8. package/dist/BodyScan-Bl1cMFAR.js.map +1 -0
  9. package/dist/BodyScan-C7ccmu4z.js +2 -0
  10. package/dist/BodyScan-C7ccmu4z.js.map +1 -0
  11. package/dist/BodyScan-CY-otNxt.js +2 -0
  12. package/dist/BodyScan-CY-otNxt.js.map +1 -0
  13. package/dist/BodyScan-CadnO5G7.js +2 -0
  14. package/dist/BodyScan-CadnO5G7.js.map +1 -0
  15. package/dist/BodyScan-Cm9CLXiD.js +2 -0
  16. package/dist/BodyScan-Cm9CLXiD.js.map +1 -0
  17. package/dist/BodyScan-CtvQU3W_.js +2 -0
  18. package/dist/BodyScan-CtvQU3W_.js.map +1 -0
  19. package/dist/BodyScan-D3sbCXE3.js +2 -0
  20. package/dist/BodyScan-D3sbCXE3.js.map +1 -0
  21. package/dist/BodyScan-YjQhf52S.js +2 -0
  22. package/dist/BodyScan-YjQhf52S.js.map +1 -0
  23. package/dist/BodyScan-qE2C5lyU.js +2 -0
  24. package/dist/BodyScan-qE2C5lyU.js.map +1 -0
  25. package/dist/FaceScan-0sQRTiDg.js +2 -0
  26. package/dist/FaceScan-0sQRTiDg.js.map +1 -0
  27. package/dist/FaceScan-BKNQASGz.js +2 -0
  28. package/dist/FaceScan-BKNQASGz.js.map +1 -0
  29. package/dist/FaceScan-CSAit6e6.js +2 -0
  30. package/dist/FaceScan-CSAit6e6.js.map +1 -0
  31. package/dist/FaceScan-CoYz9-ne.js +2 -0
  32. package/dist/FaceScan-CoYz9-ne.js.map +1 -0
  33. package/dist/FaceScan-D4oEsdmd.js +2 -0
  34. package/dist/FaceScan-D4oEsdmd.js.map +1 -0
  35. package/dist/FaceScan-DLawc3mp.js +2 -0
  36. package/dist/FaceScan-DLawc3mp.js.map +1 -0
  37. package/dist/FaceScan-DaO5QJ2P.js +2 -0
  38. package/dist/FaceScan-DaO5QJ2P.js.map +1 -0
  39. package/dist/FaceScan-PfuFJUck.js +2 -0
  40. package/dist/FaceScan-PfuFJUck.js.map +1 -0
  41. package/dist/FaceScan-UGdieN4m.js +2 -0
  42. package/dist/FaceScan-UGdieN4m.js.map +1 -0
  43. package/dist/FaceScan-URaHhFm9.js +2 -0
  44. package/dist/FaceScan-URaHhFm9.js.map +1 -0
  45. package/dist/FaceScan-jfvLuGF8.js +2 -0
  46. package/dist/FaceScan-jfvLuGF8.js.map +1 -0
  47. package/dist/LoadingScreen-Bpbe8TTf.js +2 -0
  48. package/dist/LoadingScreen-Bpbe8TTf.js.map +1 -0
  49. package/dist/LoadingScreen-C0x3_zHI.js.map +1 -1
  50. package/dist/LoadingScreen-COOSbWM_.js +2 -0
  51. package/dist/LoadingScreen-COOSbWM_.js.map +1 -0
  52. package/dist/LoadingScreen-CPoVy1B3.js +2 -0
  53. package/dist/LoadingScreen-CPoVy1B3.js.map +1 -0
  54. package/dist/LoadingScreen-Cu1SAl9Y.js +2 -0
  55. package/dist/LoadingScreen-Cu1SAl9Y.js.map +1 -0
  56. package/dist/LoadingScreen-DjbTg0B7.js.map +1 -1
  57. package/dist/LoadingScreen-JKEo-IqS.js +2 -0
  58. package/dist/LoadingScreen-JKEo-IqS.js.map +1 -0
  59. package/dist/LoadingScreen-XpTbgEdb.js +2 -0
  60. package/dist/LoadingScreen-XpTbgEdb.js.map +1 -0
  61. package/dist/LoadingScreen-xK5L8Cwd.js +2 -0
  62. package/dist/LoadingScreen-xK5L8Cwd.js.map +1 -0
  63. package/dist/bodyScan.d.ts +2 -2
  64. package/dist/bodyScan.js +1 -1
  65. package/dist/bodyScan.mjs +1 -1
  66. package/dist/faceScan.d.ts +2 -2
  67. package/dist/faceScan.js +1 -1
  68. package/dist/faceScan.mjs +1 -1
  69. package/dist/index.d.ts +2 -2
  70. package/dist/index.js +1 -1
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +1 -1
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/interfaces-B41pyG-M.d.ts +205 -0
  75. package/dist/interfaces-CegASd3K.d.ts +206 -0
  76. package/dist/interfaces-LWgRZJ8r.d.ts +165 -0
  77. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import a,{useState as r,useCallback as s,useEffect as o,createContext as i,useLayoutEffect as c,useMemo as l,useContext as d,useRef as u}from"react";import m,{posthog as f}from"posthog-js";import{L as p,H as h,b as g,a as y,S as v,n as w,v as b,P as x,r as S,s as C,k as N,j as F,o as D,f as I,e as k,q as T,t as E,c as L,w as $,x as M,V as U,y as _,z as A,A as z,G as j,C as P,B as V,D as R,u as q,E as W,p as B,h as K,i as O,l as H}from"./LoadingScreen-xK5L8Cwd.js";import J from"clsx";import G from"react-webcam";import{X as Q}from"lucide-react";import{Dialog as Y,Box as X,Drawer as Z}from"@mui/material";import ee from"video.js";const te="DESKTOP",ne="TAB",ae="MOBILE",re=i(void 0);function se({children:t}){const[n,a]=r([window?.innerWidth,window?.innerHeight]),[s,i]=r(!1),d=()=>{a([window?.innerWidth,window?.innerHeight])};o(()=>{d()},[]),c(()=>(window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)),[d]);let u=te;n[0]>768&&n[0]<1024&&(u=ne),n[0]<768&&(u=ae);const m=l(()=>({size:n,setSize:a,clearInputs:s,setClearInputs:i,media:u}),[n,s,u]);return e(re.Provider,{value:m,children:t})}var oe=a.memo(function({size:n=16}){return t("svg",{width:n,height:n,viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e("path",{d:"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})});var ie=a.memo(function({angle:n,countdown:a,isScanning:r,isInTargetRange:o,stabilityScore:i,children:c,config:u}){const{translate:m}=d(p)||{},f=s(()=>n<80?Math.max(0,Math.min(100,10*(n-60))):n>95?Math.max(0,Math.min(100,10*(105-n))):100,[n]),y=l(()=>{if(r)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=f();if(0===e)return u?.style?.angleDetector?.successAngleLowBackground||"#ffffff";if(100===e)return u?.style?.angleDetector?.successAngleBackground||"#4f46e5";return`rgb(${Math.round(255-e/100*116)}, ${Math.round(255-e/100*163)}, ${Math.round(255-e/100*9)})`},[r,f]),v=s((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`,[]),w=s((e=!1)=>{const t=f();return r?`text-[${u?.style?.angleDetector?.successAngleTextLightColor}]`:v(e,t)},[r,f]),b=s((e,t)=>t>70||e?u?.style?.angleDetector?.successAngleTextLightColor:u?.style?.angleDetector?.successAngleTextDarkColor,[]),x=s((e=!1)=>{const t=f();return r?u?.style?.angleDetector?.successAngleTextLightColor:b(e,t)},[r,f]),S=a;function C(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return C(),window.addEventListener("resize",C),t("div",{className:"flex w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto",style:{backgroundColor:y},children:[e("div",{className:"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]",children:e("div",{className:"flex justify-start ",children:e(h,{noTitle:!0,resolvedConfig:u})})}),null!==S?e("div",{className:"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300",style:{border:`2px solid ${x()}`},children:e("div",{className:`text-[3rem] font-bold text-[${x()}]`,style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:x()},children:S})}):t("div",r?{className:"relative flex flex-col items-center justify-center",children:[e("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),c]}:{className:J("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",o?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-n)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${x()}`},children:[e("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${x()}]/80`,style:{backgroundColor:`${x()}B3`}}),t("div",{className:J("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",w()),style:{color:x()},children:[e(oe,{size:30}),t("p",{style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",m?.(g.startLevelCheck),e("br",{})]})]})]}),null!==S&&e("div",{className:"absolute bottom-[8rem] text-center",children:e("div",{className:J("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",w()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:x()},children:m?.(g.leavePhone)})}),o&&null===S&&!r&&e("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e("div",{className:`h-[.375rem] w-full bg-[${x()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${x()}33`},children:e("div",{className:`h-full bg-[${x()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${n}%`,backgroundColor:`${x()}B3`}})})}),null===S&&!r&&e("div",{className:"absolute bottom-[5rem] text-center",children:t("div",{className:J("text-[1.5rem] font-light",w()),style:{color:x()},children:[Math.round(n),"°"]})}),null===S&&!r&&e("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e("div",{className:J("text-[.75rem] opacity-50",w()),style:{fontFamily:u?.style?.base?.baseFontFamily||"Inter, sans-serif",color:x()},children:m?.(g.placePhoneUpright)})})]})});function ce({handleShowStreamCamera:n,loadingCam:a,handleUserMedia:r,handlePause:s,pause:o,recordingStarted:i,startSendingVideoFrames:c,showPause:l,webcamRef:u,resetDetector:m,config:f}){const{media:h}=d(re)||{},{translate:x}=d(p)||{};return t("div",{className:"App w-screen h-[100vh] relative ",children:[e("span",{onClick:()=>{n(),m()},className:"fixed right-[20px] top-[20px] z-[999]",children:e(Q,{className:"text-[#fff]"})}),e("div",{className:"w-full h-full overflow-hidden ",children:h===ae&&e(G,{audio:!1,ref:u,screenshotQuality:1,videoConstraints:y,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:r,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}),t("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[l&&e(v,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:w,buttonText:x?.(g.pause),buttonFunc:s,resolvedConfig:f,btnSecondary:!0}),o?e("div",{children:e(v,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:x?.(g.restart),buttonFunc:n,resolvedConfig:f,btnSecondary:!0})}):i?null:e(v,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(a?"!opacity-50":""),buttonText:x?.(g.startScan),buttonFunc:c,disabled:a,resolvedConfig:f})]}),e("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${b}scanAudioInstructions/silence.mp3`})]})}let le=null,de=null,ue=null;let me,fe=null,pe=null;var he=a.memo(function({setIsScanLocked:t,resetDetector:n,scanID:a,setIsVideoUploaded:i,setScanFailsError:c,setScanStartTime:l,setScanUniqueKey:f,userDetails:p,config:h}){const{gender:g,heightInCm:y,email:v,shopDomain:w}=p,T=u(null),E=u(null),[L,$]=r([]),[M,U]=r(!0),[_,A]=r(!1),[z,j]=r(!1),[P,V]=r(!0),[R,q]=r(!1),W=u(null),[B,K]=r(""),[O,H]=r([]),[J,G]=r(""),[Q,Y]=r(!1),[X,Z]=r(!1),[ee,te]=r(!1),[ne,ae]=r([]),[re,se]=r(!1),oe=u(!0),{poseDetector:ie}=function(){const[e,t]=r(0),[n,a]=r(0),[s,i]=r(!1),c=u(0),l=u(0),d=u(!0);async function m(){if("undefined"==typeof window||"undefined"==typeof navigator)return!1;try{console.log("Starting TensorFlow preload...");const[e,t,n]=await Promise.all([import("./pose-detection.esm-BpdMeLUd.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),le=null,!1}}function f(e){return!(!e||0===e.length)&&22===e.filter(e=>e[2]>.7).length}return o(()=>{if(d.current=!0,!de)return le||(le=m()),le.then(e=>{e&&d.current&&i(!0)}),()=>{d.current=!1};i(!0)},[]),o(()=>{l.current=e,e>6&&c.current<2&&(a(e=>e+1),t(0))},[e]),o(()=>{c.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 r=n[0].keypoints.slice(11).map(e=>[e.x>0&&e.x<720?e.x:-1,e.y>0&&e.y<1280?e.y:-1,e.score??0]);0!==c.current||f(r)||t(e=>e+1),1===c.current&&f(r)&&t(e=>e+1),2===c.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:s,spinPhase:n,resetDetector:()=>{c.current=0,l.current=0,t(0),a(0)},retryLoading:async()=>{de||le||(le=m(),await le&&d.current&&i(!0))}}}(),he=u(!0),ge=u(!1),ye=u(0),ve=u(0),we=u(!1),be=u(()=>{}),[xe,Se]=r([]),{setStartGyro:Ce,handleFileUpload:Ne,setUploadLoading:Fe}=d(x),De=()=>{ge.current=!1,clearTimeout(me),W.current&&clearTimeout(W.current),f(k()),c(""),Fe?.(!1),$([]),U(!0),A(!1),j(!1),V(!0),q(!1),W.current=null,K(""),H([]),G(""),Y(!Q),Ce(!1),C.stopAudio(),Z(!1),te(!1),ye.current=0,ve.current=0,we.current=!1,null!==E.current&&E.current.stop(),ne.forEach(e=>{E.current&&E.current.removeEventListener("dataavailable",e)}),ae([]),oe.current=!0,se(!1),i(!1),T.current?.stream&&U(!1)},Ie=s(()=>{setTimeout(()=>{U(!1)},1e3)},[]),ke=s(()=>{S({eventName:`${w}/rescan`,email:v,scanID:a,height:y,gender:g,status:!1}),oe.current=!1,De(),ze()},[De,a,v]),Te=s(()=>{oe.current=!1,te(!0),se(!1),W.current&&clearTimeout(W.current),E.current&&E.current.pause(),C.stopAudio(),N.poseDetection.disconnect(),ye.current=0,ve.current=0,we.current=!1,E.current&&E.current.stop(),ne.forEach(e=>{E.current&&E.current.removeEventListener("dataavailable",e)}),ae([]),clearTimeout(me)},[E,ne,C,oe]),Ee=s(async()=>{oe.current=!0,await C.playAudio(`${b}SpotOn.mp3`),te(!1),se(!1),W.current&&clearTimeout(W.current),A(!1)},[W,C]),Le=s(async()=>{try{fe=await N.poseDetection.connect(),m.capture(`${w}/pose_detection_connected`,{scanID:a,email:v,id:fe})}catch(e){console.log(e,"while connecting websocket")}},[a,w,v]),$e=s(({data:e})=>{e&&e.size>0&&oe.current&&($(t=>t.concat(e)),!ge.current&&T.current&&(ge.current=!0,ie(()=>{Ee(),F({eventName:`${w}/tensorFlow`,scanID:a,email:v,message:"recording stopped by tensorflow "})},T)))},[Ee,F,w,a,v,T]),Me=s(async()=>{O.length>0&&oe.current&&(await C.playAudio(b+O[O.length-1]),oe.current&&(me=setTimeout(Me,2e3)))},[O,oe]),Ue=s(()=>{E&&E.current&&E.current.stop(),A(!0);try{if(T&&T.current&&T.current.stream){const e={mimeType:xe[0]};E.current=new MediaRecorder(T.current.stream,e),E.current.addEventListener("dataavailable",$e),ae([...ne,$e]),E.current.start(1e3),V(!1)}}catch(e){console.log("error while using media recorder",e)}},[T,xe,$e,ne]),_e=s(async()=>{W.current&&clearTimeout(W.current),Ue(),oe.current&&(W.current=setTimeout(async()=>{oe.current&&(await C.playAudio(`${b}SpotOn.mp3`),A(!1))},15e3)),j(!0),oe.current&&await C.playAudio(`${b}Spin.mp3`)},[Ue,oe,C]);o(()=>{be.current=_e},[_e]);const Ae=s(({data:e})=>{e.size>0&&N.poseDetection.connected()&&(we.current||(we.current=!0,N.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){const t=document.querySelector("#audioElement");!0===e.status&&e.sid===fe?(ve.current=0,ye.current<2?(0===ye.current&&t?.paused&&await C.playAudio(b+e.audio),ye.current+=1):(G(e.audio),clearTimeout(me),N.poseDetection.disconnect(),we.current=!1,setTimeout(()=>be.current(),1e3))):(ve.current+=1,ve.current>=3&&(ye.current=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,C.playAudio(b+e.audio)):pe&&(pe.no_of_times_skipped+=1)):(pe={skipCount:2,no_of_times_skipped:0,audioName:e.audio},C.playAudio(b+e.audio)))}})),T?.current&&null!==T.current.getScreenshot()&&N.poseDetection.videoEmit({image:T.current.getScreenshot()||"",scanId:a}))},[T,a,N,fe,C]),ze=s(async()=>{q(!0),Ce(!0),he.current&&(he.current=!1,F({eventName:"scan started",scanID:a,status:"success",email:v})),l(D()),U(!0),oe.current&&await C.playAudio(`${b}StartScan.mp3`),oe.current&&await C.playAudio(`${b}LiftArmsAndHoldAtHip.mp3`),oe.current&&(q(!1),A(!0),Z(!0),se(!0),Ie());try{if(T&&T.current&&T.current.stream&&oe.current){const e={mimeType:xe[0]};oe.current&&(E.current=new MediaRecorder(T.current.stream,e)),oe.current&&E.current&&E.current.addEventListener("dataavailable",Ae),ae([...ne,Ae]),E.current&&E.current.start(1e3),V(!1),oe.current&&(me=setTimeout(Me,2e3))}}catch(e){console.log("error ----------",e)}},[T,xe,Ae,ne,Me,oe]);return o(()=>(w&&(t(!0),Le()),()=>{fe&&(N.poseDetection.disconnect(),m.capture(`${w}/pose_detection_disconnected`,{scanID:a,email:v,id:fe})),ne.forEach(e=>{E?.current?.removeEventListener("dataavailable",e)})}),[Q,w]),o(()=>{O.push(B)},[B]),o(()=>{H([])},[J]),o(()=>{const e=L.length&&L.length>0;P||!e||_||!oe.current||ee||E&&E.current&&(_||(E.current.stop(),V(!0)))},[P,_,L,ee]),o(()=>{const e=L.length&&L.length>0;if(P||!e||_)console.log("No video found to upload");else if(E&&E.current&&oe.current&&!ee&&!_){const e=new File(L,`${a}.webm`,{type:"video/webm"});Fe?.(!0),c(""),Ne?.(e)}},[P,_,L,ee,E,oe]),o(()=>{if("undefined"!=typeof MediaRecorder){const e=I.filter(e=>MediaRecorder.isTypeSupported(e));Se(e)}},[]),o(()=>{De()},[]),e(ce,{resetDetector:n,handleShowStreamCamera:De,loadingCam:M,handlePause:Te,showRestart:X,pause:ee,handleReScan:ke,recordingStarted:_,isScanning:R,startSendingVideoFrames:ze,faceDone:z,stopRecording:Ee,showPause:re,webcamRef:T,handleUserMedia:Ie,config:h})});function ge({scanID:t,userDetails:n,setIsVideoUploaded:a,setScanFailsError:s,setScanStartTime:i,setScanUniqueKey:c,config:l}){const[d,m]=r(90),[f,p]=r(0),[h,g]=r(null),[y,v]=r(!1),[w,b]=r(0),x=u([]),[S,C]=r(!1),N=d-f,F=N>=80&&N<=95;o(()=>{if("undefined"!=typeof window&&window.DeviceOrientationEvent){const e=e=>{if(null!==e.beta){let t=Math.abs(e.beta);null!==e.gamma&&(t*=Math.cos(e.gamma*Math.PI/180)),t=Math.max(0,Math.min(180,t)),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})}},[]),o(()=>{if(x.current=[...x.current.slice(-4),N],x.current.length>=5){const e=Math.max(...x.current)-Math.min(...x.current);b(F&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}F||null===h&&!y||I()},[N,F,h,y]),o(()=>{w>=100&&null===h&&!y&&D(),w<50&&null!==h&&I()},[w,h,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 e(ie,{angle:N,countdown:h,isScanning:y,isInTargetRange:F,stabilityScore:w,config:l,children:y&&e(he,{setIsScanLocked:C,resetDetector:()=>{m(90),p(0),g(null),v(!1),b(0),C(!1),x.current=[]},scanID:t,userDetails:n,setIsVideoUploaded:a,setScanFailsError:s,setScanStartTime:i,setScanUniqueKey:c,config:l})})}function ye({message:a,config:r}){const{translate:s}=d(p)||{};return e(Y,{open:!0,className:"confirm-modal",children:e("div",{className:"modal-main",children:e("div",{className:"text-center",children:t(n,a?{children:[e("h2",{style:{fontFamily:r?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:r?.style?.heading?.headingFontSize||"32px",color:r?.style?.heading?.headingColor||"#000",fontWeight:r?.style?.heading?.headingFontWeight||"normal"},children:s?.(g.cameraAlreadyInUse)}),e("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:r?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:r?.style?.base?.baseFontSize||"16px",color:r?.style?.base?.baseTextColor||"#000"},children:s?.(g.tryClosingBrowser)})]}:{children:[e("h2",{style:{fontFamily:r?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:r?.style?.heading?.headingFontSize||"32px",color:r?.style?.heading?.headingColor||"#000",fontWeight:r?.style?.heading?.headingFontWeight||"normal"},children:s?.(g.checkCameraSettings)}),e("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:r?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:r?.style?.base?.baseFontSize||"16px",color:r?.style?.base?.baseTextColor||"#000"},children:`${s?.(g.setting)} > ${T()} > ${s?.(g.enableCameraPermissions)}`})]})})})})}function ve({setShowDrawer:t,config:n,loader:a}){const[i,c]=r({disabled:!1,message:""}),[l,d]=r(!0),m=u(null),f=s(async()=>{const e=await E();c(e),d(!1)},[]);return o(()=>{f()},[]),l?e(L,{url:a,loaderType:"black"}):i?.disabled?e(ye,{config:n,message:i?.message}):e(G,{audio:!1,ref:m,screenshotQuality:1,videoConstraints:y,mirrored:!0,onUserMedia:()=>t?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function we({link:t,onReady:n,wrapperClassName:a="[&_video]:rounded-t-[20px] w-full h-full"}){const r=u(null),s=u(null);let i={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:$};return o(()=>{if(!s.current&&t&&r?.current){const e=ee(r.current,{...i});e.ready(()=>{s.current=e;const a={...i,sources:[{src:t,type:"application/x-mpegURL"}]};e.autoplay(a.autoplay),e.src(a.sources),n?.(e)})}},[t,r]),o(()=>{const e=s.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),s.current=null)}},[s]),e("div",{className:a,children:e("video",{ref:r,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function be({scanFailsError:a,serverAtCapacity:s=!1,onNext:o,gender:i,setScanUniqueKey:c,resolvedConfig:l,setIsVideoUploaded:u}){const{translate:m}=d(p)||{},[f,y]=r(!1),w=()=>{y(!f)};return t(n,{children:[t("div",{className:"flex flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto",style:{background:l?.style?.base?.backgroundColor},children:[e("div",{className:"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]",children:e(h,{noTitle:!0,resolvedConfig:l})}),t("div",{className:"flex-1",children:[a&&t("div",{className:"px-[1rem]",children:[e("h2",{className:"text-center",style:{fontFamily:l?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:l?.style?.heading?.headingFontSize||"32px",color:l?.style?.heading?.headingColor||"#000",fontWeight:l?.style?.heading?.headingFontWeight||"normal"},children:m?.(g.issueWithScan)}),e("p",{style:{fontFamily:l?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:l?.style?.base?.baseFontSize||"16px",color:l?.style?.base?.baseTextColor||"#1E1E1E"},children:m?.(g.reason)}),e("p",{style:{fontFamily:l?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:l?.style?.base?.baseFontSize||"16px",color:l?.style?.base?.baseTextColor||"#1E1E1E"},children:M(a)}),e("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:w,src:U[i],alt:"icon"})]}),s&&t("div",{className:"p-[1rem] text-center",children:[e("h3",{style:{fontFamily:l?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:l?.style?.heading?.headingFontSize||"32px",color:l?.style?.heading?.headingColor||"#000",fontWeight:l?.style?.heading?.headingFontWeight||"normal"},children:m?.(g.serverAtCapacity)}),e("p",{className:"text-base mt-[0.5rem]",style:{fontFamily:l?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:l?.style?.base?.baseFontSize||"16px",color:l?.style?.base?.baseTextColor||"#1E1E1E"},children:m?.(g.serverAtCapacityDescription)})]})]}),a&&e("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e(v,{disabled:!1,buttonText:m?.(g.scanAgain),className:"!shadow-none",buttonFunc:()=>{o?o?.():c(k()),u(!1)},resolvedConfig:l})})]}),f&&t(Y,{className:"w-screen h-screen video-modal",onClose:w,open:f,children:[e("div",{className:"flex justifyEnd ",children:e("span",{className:"closeBtn",onClick:w,children:e(Q,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e("div",{className:"aspect-video object-cover rounded-[20px] ",children:e(we,{link:i?_[i].PRE_LINK:_.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function xe({scanId:n,userDetails:a,config:i,isFaceScan:c,isVideoUploadedCorrect:l,isMeasurementAvailable:u,onScanSuccess:m,isSuccess:y,onVideoUploaded:w}){const{gender:b,shopDomain:x,heightInCm:S,deviceFocalLength:C,userName:F,email:D,scanType:I}=a,k=[P,V,R].includes(I),[T,E]=r(!0),L=s(async()=>{try{k&&(await N.auth.addUser({scanId:n,email:D,name:F,gender:b,height:S}),w?.()),f.capture(x,{scanID:n,email:D,height:S,focalLength:C,clothesFit:"0",gender:b})}catch(e){console.log(e)}},[k]),{translate:$}=d(p)||{};o(()=>{(l||u)&&L()},[l,u]);const M=y||(c?u&&l:l||u);return e(X,{className:"flex h-full w-full flex-col ",children:t("div",{className:"h-full w-full flex-col items-center justify-center flex",children:[e(ve,{loader:i?.loader,setShowDrawer:E}),e(Z,{open:T,onClose:(e,t)=>{},className:"camera-drawer",anchor:"bottom",children:e("div",{className:"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]",style:{background:i?.style?.base?.backgroundColor},children:t("div",{className:"w-full h-full flex flex-col",children:[e(h,{title:$?.(g.measurementsBeingTaken),resolvedConfig:i}),e("div",{className:"flex items-center justify-center flex-1",children:e("video",{preload:"auto",className:"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none",muted:!0,loop:!0,autoPlay:!0,playsInline:!0,children:e("source",{src:b===j.Male?A:z,type:"video/mp4"})})}),M&&e(v,{resolvedConfig:i,className:"!w-[180px] mx-auto",buttonText:$?.(g.next),buttonFunc:()=>{m?.(),w?.()}})]})})})]})})}const Se=()=>{const{userDetails:a,config:r,onRetry:s,isError:i,isSuccess:c,onScanSuccess:l,gender:u,scanUniqueKey:m,scanFailsError:f,setScanUniqueKey:h,setIsVideoUploaded:g,isMeasurementAvailable:y,isVideoUploadedCorrect:v,loading:w,showDeniedModal:b,uploadLoading:S,setScanFailsError:C,setScanStartTime:N,handleShowStreamCamera:F,onVideoUploaded:D}=d(x),{setPreferredLanguage:I}=d(p)||{},k=q(r);return o(()=>{I?.(k?.language)},[k]),i?t(n,{children:[e(ve,{}),e(Z,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(be,{scanFailsError:f||i,onNext:()=>{s?.(),F()},setScanUniqueKey:h,gender:u,resolvedConfig:k,setIsVideoUploaded:g})})]}):c?e(xe,{isFaceScan:!1,scanId:m,isMeasurementAvailable:y,userDetails:a,isVideoUploadedCorrect:v,config:k,isSuccess:c,onVideoUploaded:D}):w?e("div",{className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:k?.style?.base?.backgroundColor},children:e(L,{url:k?.loader,loaderType:"black"})}):b.disabled?e(ye,{}):S||f||y||v?(S||y||v)&&!f?e(xe,{isFaceScan:!1,scanId:m,isMeasurementAvailable:y,userDetails:a,onScanSuccess:l,isVideoUploadedCorrect:v,config:k,onVideoUploaded:D}):t(n,{children:[e(ve,{}),e(Z,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e(be,{scanFailsError:f,onNext:()=>{s?.(),F()},setScanUniqueKey:h,gender:u,resolvedConfig:k,setIsVideoUploaded:g})})]}):e(ge,{config:k,scanID:m,userDetails:a,setIsVideoUploaded:g,setScanFailsError:C,setScanStartTime:N,setScanUniqueKey:h})},Ce=({userDetails:t,config:n,onRetry:a,onScanError:i,isError:c,isSuccess:l,onScanSuccess:d,onVideoUploaded:u})=>{const{gender:f,scanType:p,shopDomain:h,heightInCm:g,email:y,deviceFocalLength:v,deviceModelName:w,callbackUrl:b}=t,[S,C]=r(!1),[I,T]=r(!1),[L,$]=r(!1),[U,_]=r({disabled:!1,message:""}),[A,z]=r(""),[j,P]=r(!1),[V,R]=r(!0),[q,J]=r(!1),[G,Q]=r(""),[Y,X]=r(D()),{gyroData:Z}=function(e){const[t,n]=r([]),[a,i]=r(!1),c=s(e=>{try{const{alpha:t,beta:a,gamma:r}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:a?.toString()||void 0,gamma:r?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),l=s(async()=>{const e=DeviceOrientationEvent;if(void 0!==e&&"function"==typeof e.requestPermission)try{"granted"===await e.requestPermission()?i(!0):console.warn("Device orientation permission denied.")}catch(e){console.error("Error requesting device orientation permission:",e)}else i(!0)},[]);return o(()=>(e&&a?window.addEventListener("deviceorientation",c):n([]),()=>{window.removeEventListener("deviceorientation",c)}),[e,a,c]),o(()=>{e&&l()},[e,l]),{gyroData:t}}(q),ee=s(()=>{Q(k()),z(""),C(!1),P(!1)},[]),te=e=>{i({...e,message:M(e)}),ne(),$(!1),z(e),T(!1),F({eventName:`${h}/measurement_failed/fit-view`,scanID:G,status:"failed",email:y,message:M(e)}),Y&&F({eventName:`${h}/scan_completion_time`,scanID:G,status:"failed",completionTime:D()-Y,email:y})},ne=()=>{X(null),Q("")},ae=s(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return F({eventName:`${h}/measurement_success/intermediate`,scanID:G,status:"success",email:y}),void T(!0);T(!0),ne();const t=G;$(!0),F({eventName:`${h}/measurement_success/fit-view`,scanID:t,status:"success",email:y}),Y&&F({eventName:`${h}/scan_completion_time`,scanID:t,status:"success",completionTime:D()-Y,email:y})},[p,h,G]),re=e=>{$(!1),z(""),T(!1),N.measurement.handleMeasurementSocket({scanId:e||G,onPreopen:()=>{H({eventName:`${h}/webSocket`,scanID:G,connection:"pre_open",type:"measurement_recommendation",email:y})},onOpen:()=>{H({eventName:`${h}/webSocket`,scanID:G,connection:"open",type:"measurement_recommendation",email:y})},onClose:()=>H({eventName:`${h}/webSocket`,scanID:G,connection:"close",type:"measurement_recommendation",email:y}),onError:e=>{te(e),H({eventName:`${h}/webSocket`,scanID:G,connection:"error",type:"measurement_recommendation",email:y})},onSuccess:e=>{H({eventName:`${h}/webSocket`,scanID:G,connection:"success",type:"measurement_recommendation",email:y}),ae(e)}})},oe=s(async e=>{const t=W({gender:f,focal_length:`${v}`,height:`${g}`,customer_store_url:h,clothes_fit:"0",scan_type:p,callback_url:b});F({eventName:`${h}/body_scan_meta_data`,scanID:G,email:y,data:JSON.stringify(t)});try{await N.fileUpload.uploadFileFrontend({file:e,arrayMetaData:t,scanId:G,email:y}),await N.fileUpload.setDeviceInfo({model:w,detection:"manual",gyro:Z,scanId:G}),console.log("video successfully uploaded"),P(!1),F({eventName:`${h}/scan_success`,scanID:G,status:"success",email:y,data:JSON.stringify(t)}),F({eventName:"scan finished",scanID:G,status:"success",email:y}),X(D()),setTimeout(()=>{P(!0)},3e3)}catch(e){F({eventName:"scan finished",scanID:G,status:"failed",email:y,message:M(e)}),F({eventName:`${h}/scan_failed`,scanID:G,status:"failed",email:y,message:M(e),data:JSON.stringify(t)}),z(M(e)),P(!1),i?.({message:M(e)}),ne()}finally{J(!1)}},[G,Z]),ie=s(async e=>{try{const t=await N.measurement.getMeasurementResult(e),n=t?.data?.isMeasured,a=Y||D(),r=D(),s=300;if(R(!1),!1===n)return ne(),void Q(k());C(!0),!0===n?await ae(null):null===n&&a>r+s?te(t?.data?.error):re(e)}catch(e){console.log(e),ne(),Q(k()),C(!1)}},[te,ae,Q]),ce=s(async()=>{if(+g<152.4||+g>213.36)return void i({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await E();if(e.disabled)F({eventName:`${h}/camera_activation`,scanID:G,status:"failed",email:y}),R(!1);else{G?ie(G):R(!1),F({eventName:`${h}/camera_activation`,scanID:G,status:"success",email:y})}_(e),z(""),P(!1)},[ie,y,G,Q,h]);return o(()=>{m.init(B,{api_host:K}),m.capture("$pageview")},[]),o(()=>{c||l||h&&ce()},[h,g,c,l]),o(()=>{c||l||j&&h&&G&&re()},[j,h,G,c,l]),e(O,{children:e(se,{children:e(x.Provider,{value:{userDetails:t,config:n,onRetry:a,onScanError:i,isError:c,isSuccess:l,onScanSuccess:d,gender:f,scanUniqueKey:G,scanFailsError:A,setScanUniqueKey:Q,setIsVideoUploaded:P,isMeasurementAvailable:L,isVideoUploadedCorrect:I,loading:V,showDeniedModal:U,uploadLoading:S,setStartGyro:J,handleFileUpload:oe,setUploadLoading:C,handleShowStreamCamera:ee,setScanFailsError:z,setScanStartTime:X,onVideoUploaded:u},children:e(Se,{})})})})};export{Ce as B};
2
+ //# sourceMappingURL=BodyScan-9r5xhZtT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BodyScan-9r5xhZtT.js","sources":["../src/utils/context/mediaContext.tsx","../src/Icons/SwitchIcon.tsx","../src/components/bodyScan/LevelScreen.tsx","../src/components/bodyScan/CameraScanChild.tsx","../src/customHooks/useTensorFlow.ts","../src/components/bodyScan/ScanningComponent.tsx","../src/components/bodyScan/AngleDetector.tsx","../src/components/Modal.tsx","../src/components/bodyScan/CameraPermission.tsx","../src/components/bodyScan/VideoPlayer.tsx","../src/components/bodyScan/ScanErrorMessage.tsx","../src/components/Signup.tsx","../src/components/bodyScan/BodyScanSteps.tsx","../src/components/bodyScan/BodyScan.tsx","../src/customHooks/useGyroSensor.ts"],"sourcesContent":["\"use client\"\nimport React, {\n createContext,\n Dispatch,\n ReactNode,\n SetStateAction,\n useEffect,\n useLayoutEffect,\n useMemo,\n useState,\n} from \"react\";\n\nexport const MEDIA_TYPES = {\n DESKTOP: \"DESKTOP\",\n TAB: \"TAB\",\n MOBILE: \"MOBILE\",\n};\n\ninterface MediaContextType {\n size: number[];\n setSize: Dispatch<SetStateAction<number[]>>;\n clearInputs: boolean;\n setClearInputs: Dispatch<SetStateAction<boolean>>;\n media: string;\n}\n\nexport const MediaContext = createContext<MediaContextType | undefined>(\n undefined\n);\n\nfunction MediaContextProvider({ children }: { children: ReactNode }) {\n const [size, setSize] = useState([window?.innerWidth, window?.innerHeight]);\n const [clearInputs, setClearInputs] = useState(false);\n\n const updateSize = () => {\n setSize([window?.innerWidth, window?.innerHeight]);\n };\n useEffect(() => {\n updateSize();\n }, []);\n useLayoutEffect(() => {\n window.addEventListener(\"resize\", updateSize);\n return () => window.removeEventListener(\"resize\", updateSize);\n }, [updateSize]);\n let media = MEDIA_TYPES.DESKTOP;\n if (size[0] > 768 && size[0] < 1024) {\n media = MEDIA_TYPES.TAB;\n }\n if (size[0] < 768) {\n media = MEDIA_TYPES.MOBILE;\n }\n\n const mediaDetails = useMemo(\n () => ({\n size,\n setSize,\n clearInputs,\n setClearInputs,\n media,\n }),\n [size, clearInputs, media]\n );\n\n return (\n <MediaContext.Provider value={mediaDetails}>\n {children}\n </MediaContext.Provider>\n );\n}\n\nexport default MediaContextProvider;\n","import React from \"react\";\n\nfunction SwitchIcon({ size = 16 }: { size?: number }) {\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 25 25\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M22.6968 14.6968C22.6968 16.8185 21.8539 18.8533 20.3536 20.3536C18.8533 21.8539 16.8185 22.6968 14.6968 22.6968\"\n stroke=\"white\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M18.6968 11.6968V10.6968C18.6968 10.1663 18.4861 9.65764 18.111 9.28256C17.7359 8.90749 17.2272 8.69678 16.6968 8.69678C16.1663 8.69678 15.6576 8.90749 15.2826 9.28256C14.9075 9.65764 14.6968 10.1663 14.6968 10.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M14.6968 10.6968V9.69678C14.6968 9.16634 14.4861 8.65764 14.111 8.28256C13.7359 7.90749 13.2272 7.69678 12.6968 7.69678C12.1663 7.69678 11.6576 7.90749 11.2826 8.28256C10.9075 8.65764 10.6968 9.16634 10.6968 9.69678V10.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M10.6968 10.1968V4.69678C10.6968 4.16634 10.4861 3.65764 10.111 3.28256C9.73592 2.90749 9.22721 2.69678 8.69678 2.69678C8.16634 2.69678 7.65764 2.90749 7.28256 3.28256C6.90749 3.65764 6.69678 4.16634 6.69678 4.69678V14.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path\n d=\"M18.6969 11.6968C18.6969 11.1663 18.9076 10.6576 19.2827 10.2826C19.6577 9.90749 20.1664 9.69678 20.6969 9.69678C21.2273 9.69678 21.736 9.90749 22.1111 10.2826C22.4862 10.6576 22.6969 11.1663 22.6969 11.6968V14.6968C22.6969 16.8185 21.854 18.8533 20.3537 20.3536C18.8534 21.8539 16.8186 22.6968 14.6969 22.6968H12.6969C9.89688 22.6968 8.19688 21.8368 6.70688 20.3568L3.10688 16.7568C2.76282 16.3757 2.57847 15.8769 2.592 15.3637C2.60554 14.8505 2.81593 14.3621 3.1796 13.9997C3.54327 13.6373 4.03238 13.4287 4.54565 13.417C5.05892 13.4053 5.55704 13.5914 5.93688 13.9368L7.69688 15.6968\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\nexport default React.memo(SwitchIcon);\n","/* eslint-disable no-nested-ternary */\n\nimport React, { useCallback, useContext, useMemo } from \"react\";\nimport Header from \"../Header\";\nimport cn from \"clsx\";\nimport { LevelScreenProps } from \"../../types/interfaces\";\nimport SwitchIcon from \"../../Icons/SwitchIcon\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\n\nfunction LevelScreen({ angle, countdown, isScanning, isInTargetRange, stabilityScore, children, config }: LevelScreenProps) {\n\tconst { translate } = useContext(LanguageContext) || {};\n\n\tconst getProximityToTarget = useCallback(() => {\n\t\tif (angle < 80) return Math.max(0, Math.min(100, (angle - 60) * 10));\n\t\tif (angle > 95) return Math.max(0, Math.min(100, (105 - angle) * 10));\n\t\treturn 100;\n\t}, [angle]);\n\n\tconst backgroundColor = useMemo(() => {\n\t\tif (isScanning) return config?.style?.angleDetector?.successAngleBackground || \"#4f46e5\";\n\n\t\tconst proximity = getProximityToTarget();\n\t\tif (proximity === 0) return config?.style?.angleDetector?.successAngleLowBackground || \"#ffffff\";\n\t\tif (proximity === 100) return config?.style?.angleDetector?.successAngleBackground || \"#4f46e5\";\n\n const r = Math.round(255 - (255 - 139) * (proximity / 100));\n const g = Math.round(255 - (255 - 92) * (proximity / 100));\n const b = Math.round(255 - (255 - 246) * (proximity / 100));\n return `rgb(${r}, ${g}, ${b})`;\n }, [isScanning, getProximityToTarget]);\n\n\tconst handelTextColour = useCallback((isLight: boolean, proximity: number) => {\n\t\tif (proximity > 70) {\n\t\t\treturn isLight ? `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]/70` : `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]`;\n\t\t}\n\t\treturn isLight ? `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]/40` : `text-[${config?.style?.angleDetector?.successAngleTextDarkColor}]/70`;\n\t}, []);\n\n\tconst getTextColor = useCallback(\n\t\t(isLight = false) => {\n\t\t\tconst proximity = getProximityToTarget();\n\t\t\tif (isScanning) return `text-[${config?.style?.angleDetector?.successAngleTextLightColor}]`;\n\t\t\treturn handelTextColour(isLight, proximity);\n\t\t},\n\t\t[isScanning, getProximityToTarget],\n\t);\n\n\tconst handelColourCode = useCallback((isLight: boolean, proximity: number) => {\n\t\tif (proximity > 70) {\n\t\t\treturn isLight ? config?.style?.angleDetector?.successAngleTextLightColor : config?.style?.angleDetector?.successAngleTextLightColor;\n\t\t}\n\t\treturn isLight ? config?.style?.angleDetector?.successAngleTextLightColor : config?.style?.angleDetector?.successAngleTextDarkColor;\n\t}, []);\n\tconst getColorCode = useCallback(\n\t\t(isLight = false) => {\n\t\t\tconst proximity = getProximityToTarget();\n\t\t\tif (isScanning) return config?.style?.angleDetector?.successAngleTextLightColor;\n\t\t\treturn handelColourCode(isLight, proximity);\n\t\t},\n\t\t[isScanning, getProximityToTarget],\n\t);\n\tconst cd = countdown;\n\tfunction fixVh() {\n\t\tdocument.documentElement.style.setProperty(\"--real-vh\", window.innerHeight + \"px\");\n\t}\n\tfixVh();\n\twindow.addEventListener(\"resize\", fixVh);\n\treturn (\n\t\t<div\n\t\t\tclassName=\"flex w-screen flex-col items-center h-[var(--real-vh)] overflow-hidden touch-none justify-center transition-all duration-300 max-w-[28rem] mx-auto\"\n\t\t\tstyle={{ backgroundColor }}\n\t\t\t// onDoubleClick={onDoubleClick}\n\t\t>\n\t\t\t<div className=\"flex justify-start fixed top-[.5rem] max-w-[28rem] mx-auto w-full px-[1rem]\">\n\t\t\t\t<div className=\"flex justify-start \">\n\t\t\t\t\t<Header noTitle resolvedConfig={config} />\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{cd !== null ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"relative flex h-[6rem] w-[6rem] items-center justify-center rounded-[9999px] bg-[#fff]/20 transition-all duration-300\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tborder: `2px solid ${getColorCode()}`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`text-[3rem] font-bold text-[${getColorCode()}]`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{cd}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) : isScanning ? (\n\t\t\t\t<div className=\"relative flex flex-col items-center justify-center\">\n\t\t\t\t\t<div className=\"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]\">\n\t\t\t\t\t\t<div className=\"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80\" />\n\t\t\t\t\t</div>\n\t\t\t\t\t{children}\n\t\t\t\t</div>\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\tclassName={cn(\"relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] \", isInTargetRange ? \"bg-[#fff]/20 border-[#fff]\" : \"bg-[#fff]/10 border-[#fff]\")}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\ttransform: `translateY(${(90 - angle) * 3}px)`,\n\t\t\t\t\t\ttransition: \"transform 0.2s ease-out\",\n\t\t\t\t\t\tborder: `2px solid ${getColorCode()}`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<div className={`h-[1rem] w-[1rem] rounded-[9999px] bg-[${getColorCode()}]/80`}\n style={{\n\t\t\t\t\t\tbackgroundColor: `${getColorCode()}B3`,\n\t\t\t\t\t}}\n />\n\t\t\t\t\t<div\n\t\t\t\t\t\t// className=\" text-[#fff]\"\n\t\t\t\t\t\tclassName={cn(\"mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]\", getTextColor())}\n style={{\n\t\t\t\t\t\tcolor: getColorCode(),\n\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SwitchIcon size={30} />\n\t\t\t\t\t\t<p\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{\" \"}\n\t\t\t\t\t\t\t{translate?.(LanguageKeys.startLevelCheck)}\n\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n\t\t\t{cd !== null && (\n\t\t\t\t<div className=\"absolute bottom-[8rem] text-center\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\"text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8\", getTextColor())}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{translate?.(LanguageKeys.leavePhone)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t{isInTargetRange && cd === null && !isScanning && (\n\t\t\t\t<div className=\"absolute bottom-[8rem] w-[12rem]\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={`h-[.375rem] w-full bg-[${getColorCode()}]/20 rounded-[9999px] overflow-hidden`}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackgroundColor: `${getColorCode()}33`, // 20% opacity\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={`h-full bg-[${getColorCode()}]/70 transition-all duration-300 rounded-[9999px]`}\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\twidth: `${angle}%`,\n\t\t\t\t\t\t\t\tbackgroundColor: `${getColorCode()}B3`,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\n {cd === null && !isScanning && (\n <div className=\"absolute bottom-[5rem] text-center\">\n <div className={cn(\"text-[1.5rem] font-light\", getTextColor())}\n style={{\n\t\t\t\t\t\tcolor: getColorCode(),\n\t\t\t\t\t}}\n >\n {Math.round(angle)}°\n </div>\n </div>\n )}\n\n\t\t\t{cd === null && !isScanning && (\n\t\t\t\t<div className=\"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\"text-[.75rem] opacity-50\", getTextColor())}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tfontFamily: config?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n color: getColorCode(),\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{translate?.(LanguageKeys.placePhoneUpright)}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\nexport default React.memo(LevelScreen);\n","import { useContext } from \"react\";\nimport Webcam from \"react-webcam\";\nimport { CameraScanChildProps } from \"../../types/interfaces\";\nimport { MEDIA_TYPES, MediaContext } from \"../../utils/context/mediaContext\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { pauseIcon, videoConstraints, voiceOverAssetsPath } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { X } from \"lucide-react\";\n\n\n\nfunction CameraScanChild({\n handleShowStreamCamera,\n loadingCam,\n handleUserMedia,\n handlePause,\n pause,\n recordingStarted,\n startSendingVideoFrames,\n showPause,\n webcamRef,\n 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 <X 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}","/* 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 counterRef = useRef(0);\n\tconst consecutiveFalseRef = useRef(0);\n\tconst poseListenerRegistered = useRef(false);\n\tconst postPoseProcessRef = useRef<() => void>(() => {});\n\tconst [supportedTypes, setSupportedTypes] = useState<string[]>([]);\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\tcounterRef.current = 0;\n\t\tconsecutiveFalseRef.current = 0;\n\t\tposeListenerRegistered.current = false;\n\t\tif (mediaRecorderRef.current !== null) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\n\t\tevents.forEach((el: any) => {\n\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.removeEventListener(\"dataavailable\", el);\n\t\t});\n\n\t\tsetEvents([]);\n\t\tallowAudioToPlay.current = true;\n\t\tsetShowPause(false);\n\t\tsetIsVideoUploaded(false);\n\t\tif (webcamRef.current?.stream) {\n\t\t\tsetLoadingCam(false);\n\t\t}\n\t};\n\n\tconst handleUserMedia = useCallback(() => {\n\t\tsetTimeout(() => {\n\t\t\tsetLoadingCam(false);\n\t\t}, 1000);\n\t}, []);\n\n\tconst 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\tcounterRef.current = 0;\n\t\tconsecutiveFalseRef.current = 0;\n\t\tposeListenerRegistered.current = false;\n\t\tif (mediaRecorderRef.current) {\n\t\t\tmediaRecorderRef.current.stop();\n\t\t}\n\t\tevents.forEach((el: any) => {\n\t\t\tif (mediaRecorderRef.current) mediaRecorderRef.current.removeEventListener(\"dataavailable\", el);\n\t\t});\n\t\tsetEvents([]);\n\t\tclearTimeout(audioTimeoutId);\n\t}, [mediaRecorderRef, events, speechService, allowAudioToPlay]);\n\n\t// const supportedTypes = videoTypes.filter((type) => MediaRecorder.isTypeSupported(type));\n\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\tuseEffect(() => {\n\t\tpostPoseProcessRef.current = postPoseProcess;\n\t}, [postPoseProcess]);\n\n\tconst handleDataAvailable = useCallback(\n\t\t({ data }: BlobEvent) => {\n\t\t\tif (data.size > 0 && swan.poseDetection.connected()) {\n\t\t\t\tif (!poseListenerRegistered.current) {\n\t\t\t\t\tposeListenerRegistered.current = true;\n\t\t\t\t\tswan.poseDetection.poseStatus(async (data: any) => {\n\t\t\t\t\t\tif (data && data.audio && data.audio.length > 0) {\n\t\t\t\t\t\t\tconst audio = document.querySelector(\"#audioElement\") as HTMLAudioElement | null;\n\t\t\t\t\t\t\tif (data.status === true && data.sid === id) {\n\t\t\t\t\t\t\t\tconsecutiveFalseRef.current = 0;\n\t\t\t\t\t\t\t\tif (counterRef.current < 2) {\n\t\t\t\t\t\t\t\t\tif (counterRef.current === 0 && audio?.paused) {\n\t\t\t\t\t\t\t\t\t\tawait speechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcounterRef.current += 1;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tsetEmptyAudioSource(data.audio);\n\t\t\t\t\t\t\t\t\tclearTimeout(audioTimeoutId);\n\t\t\t\t\t\t\t\t\tswan.poseDetection.disconnect();\n\t\t\t\t\t\t\t\t\tposeListenerRegistered.current = false;\n\t\t\t\t\t\t\t\t\tsetTimeout(() => postPoseProcessRef.current(), 1000);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconsecutiveFalseRef.current += 1;\n\t\t\t\t\t\t\t\tif (consecutiveFalseRef.current >= 3) {\n\t\t\t\t\t\t\t\t\tcounterRef.current = 0;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (audio?.paused && (!lastVideoPlayed || lastVideoPlayed?.audioName !== data.audio)) {\n\t\t\t\t\t\t\t\t\tlastVideoPlayed = {\n\t\t\t\t\t\t\t\t\t\tskipCount: 2,\n\t\t\t\t\t\t\t\t\t\tno_of_times_skipped: 0,\n\t\t\t\t\t\t\t\t\t\taudioName: data.audio,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t} else if (lastVideoPlayed?.audioName === data.audio && audio?.paused) {\n\t\t\t\t\t\t\t\t\tif (lastVideoPlayed && lastVideoPlayed.no_of_times_skipped >= lastVideoPlayed.skipCount) {\n\t\t\t\t\t\t\t\t\t\tlastVideoPlayed.no_of_times_skipped = 0;\n\t\t\t\t\t\t\t\t\t\tspeechService.playAudio(voiceOverAssetsPath + data.audio);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tif (lastVideoPlayed) lastVideoPlayed.no_of_times_skipped += 1;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (webcamRef?.current && webcamRef.current.getScreenshot() !== null) {\n\t\t\t\t\tswan.poseDetection.videoEmit({\n\t\t\t\t\t\timage: webcamRef.current.getScreenshot() || \"\",\n\t\t\t\t\t\tscanId: 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, 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} loaderType=\"black\" />\n\t}\n\n\tif (showDeniedModal?.disabled) {\n\t\treturn <Modal config={config} message={showDeniedModal?.message} />;\n\t}\n\treturn (\n\t\t<Webcam\n\t\t\taudio={false}\n\t\t\tref={webcamRef}\n\t\t\tscreenshotQuality={1}\n\t\t\tvideoConstraints={videoConstraints}\n\t\t\tmirrored\n\t\t\tonUserMedia={() => setShowDrawer?.(true)}\n\t\t\tscreenshotFormat=\"image/jpeg\"\n\t\t\tstyle={{\n\t\t\t\tposition: \"relative\",\n\t\t\t\ttop: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tzIndex: 0,\n\t\t\t\twidth: \"100%\",\n\t\t\t\theight: \"100%\",\n\t\t\t\tobjectFit: \"cover\",\n\t\t\t}}\n\t\t/>\n\t);\n}\n\nexport default CameraPermission;\n","\nimport React, { useEffect, useRef } from \"react\";\nimport videojs from \"video.js\";\nimport type Player from \"video.js/dist/types/player\";\n// import \"video.js/dist/video-js.css\";\nimport { videoPoster } from \"../../utils/constants\";\n\nfunction VideoPlayer({ link, onReady, wrapperClassName = \"[&_video]:rounded-t-[20px] w-full h-full\" }: { link?: string; wrapperClassName?: string; onReady?: (args: Player) => void }) {\n\tconst videoReference = useRef<HTMLVideoElement | null>(null);\n\tconst playerReference = useRef<Player | null>(null);\n\n\tlet videoJsOptions: any = {\n\t\tautoplay: true,\n\t\tcontrols: false,\n\t\tresponsive: true,\n\t\tfluid: true,\n\t\tmuted: true,\n\t\tnavigationUI: \"hide\",\n\t\tpreload: \"metadata\",\n\t\tposter: videoPoster,\n\t};\n\n\tuseEffect(() => {\n\t\tif (!playerReference.current && link && videoReference?.current) {\n\t\t\tconst player = videojs(videoReference.current, {\n\t\t\t\t...videoJsOptions,\n\t\t\t});\n\t\t\tplayer.ready(() => {\n\t\t\t\tplayerReference.current = player;\n\n\t\t\t\tconst updatedOptions = {\n\t\t\t\t\t...videoJsOptions,\n\t\t\t\t\tsources: [{ src: link, type: \"application/x-mpegURL\" }],\n\t\t\t\t};\n\n\t\t\t\tplayer.autoplay(updatedOptions.autoplay);\n\t\t\t\tplayer.src(updatedOptions.sources);\n\n\t\t\t\tonReady?.(player);\n\t\t\t});\n\t\t}\n\t}, [link, videoReference]);\n\n\tuseEffect(() => {\n\t\tconst player = playerReference.current;\n\t\treturn () => {\n\t\t\tif (player && !player.isDisposed()) {\n\t\t\t\tplayer.dispose();\n\t\t\t\tplayerReference.current = null;\n\t\t\t}\n\t\t};\n\t}, [playerReference]);\n\n\treturn (\n\t\t<div className={wrapperClassName}>\n\t\t\t<video ref={videoReference} muted className=\"video-js\" playsInline onDrag={(e) => e.preventDefault()} />\n\t\t</div>\n\t);\n}\nexport default VideoPlayer;\n","import { useContext, useState } from \"react\";\nimport {Dialog} from \"@mui/material\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport Header from \"../Header\";\nimport VideoPlayer from \"./VideoPlayer\";\nimport { ScanErrorMessageProps } from \"../../types/interfaces\";\nimport { generateUuid, handleErrorMessage } from \"../../utils/utils\";\nimport { GENDER, VIDEO_POSTER_GENDER_BASED } from \"../../utils/constants\";\nimport SpecificButton from \"../../atoms/specificButton/SpecificButton\";\nimport { LanguageKeys } from \"../../utils/languageKeys\";\nimport { X } from \"lucide-react\";\n\nfunction ScanErrorMessage({ scanFailsError, serverAtCapacity = false, onNext, gender, setScanUniqueKey, resolvedConfig, setIsVideoUploaded }: ScanErrorMessageProps) {\n\tconst { translate } = useContext(LanguageContext) || {};\n\tconst [showModal, setShowModal] = useState(false);\n\n\tconst handleBtnClick = () => {\n\t\tif (onNext) {\n\t\t\tonNext?.();\n\t\t} else {\n\t\t\tsetScanUniqueKey(generateUuid());\n\t\t}\n\t\tsetIsVideoUploaded(false);\n\t};\n\n\tconst handleShowModal = () => {\n\t\tsetShowModal(!showModal);\n\t};\n\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"flex flex-col h-full max-w-[28rem] mx-auto w-full rounded-t-[20px] overflow-y-auto\" style={{ background: resolvedConfig?.style?.base?.backgroundColor }}>\n\t\t\t\t<div className=\"w-full max-w-[28rem] mx-auto pt-[1rem] px-[1rem]\">\n\t\t\t\t\t<Header noTitle resolvedConfig={resolvedConfig} />\n\t\t\t\t</div>\n\t\t\t\t<div className=\"flex-1\">\n\t\t\t\t\t{scanFailsError && (\n\t\t\t\t\t\t<div className=\"px-[1rem]\">\n\t\t\t\t\t\t\t<h2\n\t\t\t\t\t\t\t\tclassName=\"text-center\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.heading?.headingFontFamily || \"SeriouslyNostalgic Fn\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.heading?.headingFontSize || \"32px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.heading?.headingColor || \"#000\",\n\t\t\t\t\t\t\t\t\tfontWeight: resolvedConfig?.style?.heading?.headingFontWeight || \"normal\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.issueWithScan)}\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.reason)}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{handleErrorMessage(scanFailsError)}\n\t\t\t\t\t\t\t</p>\n\n\t\t\t\t\t\t\t<img className=\"my-[0.5rem] aspect-[2/1.4] w-full object-cover\" onClick={handleShowModal} src={VIDEO_POSTER_GENDER_BASED[gender]} alt=\"icon\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t\t{serverAtCapacity && (\n\t\t\t\t\t\t<div className=\"p-[1rem] text-center\">\n\t\t\t\t\t\t\t<h3\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.heading?.headingFontFamily || \"SeriouslyNostalgic Fn\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.heading?.headingFontSize || \"32px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.heading?.headingColor || \"#000\",\n\t\t\t\t\t\t\t\t\tfontWeight: resolvedConfig?.style?.heading?.headingFontWeight || \"normal\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.serverAtCapacity)}\n\t\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\tclassName=\"text-base mt-[0.5rem]\"\n\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\tfontFamily: resolvedConfig?.style?.base?.baseFontFamily || \"Inter, sans-serif\",\n\t\t\t\t\t\t\t\t\tfontSize: resolvedConfig?.style?.base?.baseFontSize || \"16px\",\n\t\t\t\t\t\t\t\t\tcolor: resolvedConfig?.style?.base?.baseTextColor || \"#1E1E1E\",\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{translate?.(LanguageKeys.serverAtCapacityDescription)}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{scanFailsError && (\n\t\t\t\t\t<div className=\"p-[1rem] flex gap-[0.5rem]\">\n\t\t\t\t\t\t<SpecificButton disabled={false} buttonText={translate?.(LanguageKeys.scanAgain)} className=\"!shadow-none\" buttonFunc={handleBtnClick} resolvedConfig={resolvedConfig} />\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t{showModal && (\n\t\t\t\t<Dialog className=\"w-screen h-screen video-modal\" onClose={handleShowModal} open={showModal}>\n\t\t\t\t\t<div className=\"flex justifyEnd \">\n\t\t\t\t\t\t<span className=\"closeBtn\" onClick={handleShowModal}>\n\t\t\t\t\t\t\t<X className=\"absolute right-[8px] top-[8px] text-white z-[9]\" />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"aspect-video object-cover rounded-[20px] \">\n\t\t\t\t\t\t<VideoPlayer link={gender ? GENDER[gender].PRE_LINK : GENDER.male.PRE_LINK} wrapperClassName=\"w-screen h-screen fixed top-[0] left-[0]\" />\n\t\t\t\t\t</div>\n\t\t\t\t</Dialog>\n\t\t\t)}\n\t\t</>\n\t);\n}\n\nexport default ScanErrorMessage;\n","import { useCallback, useContext, useEffect, useState } from \"react\";\nimport {Box,Drawer} from \"@mui/material\";\nimport { posthog } from \"posthog-js\";\nimport Header from \"./Header\";\nimport CameraPermission from \"./bodyScan/CameraPermission\";\nimport { UserDetails } from \"../types/interfaces\";\nimport { CLOTHING_BANNER_SCAN, CLOTHING_CUSTOM_FIT_SCAN, CLOTHING_CUSTOM_SCAN, maleMeasurementProgress, measurementProgress } from \"../utils/constants\";\nimport { GenderType } from \"../utils/enums\";\nimport SpecificButton from \"../atoms/specificButton/SpecificButton\";\nimport { LanguageContext } from \"../utils/context/languageContext\";\nimport { LanguageKeys } from \"../utils/languageKeys\";\nimport swan from \"../utils/service/swanService\";\n\nfunction SignUp({\n\tscanId,\n\tuserDetails,\n\tconfig,\n\tisFaceScan,\n\tisVideoUploadedCorrect,\n\tisMeasurementAvailable,\n\tonScanSuccess,\n\tisSuccess,\n\tonVideoUploaded\n}: {\n\tconfig?: any;\n\tisFaceScan: boolean;\n\tscanId: string;\n\tisVideoUploadedCorrect?: boolean;\n\tisMeasurementAvailable?: boolean;\n\tuserDetails: UserDetails;\n\tonScanSuccess?: () => void;\n\tisSuccess?: boolean;\n\tonVideoUploaded?: () => void;\n}) {\n\tconst { gender, shopDomain, heightInCm, deviceFocalLength, userName, email, scanType } = userDetails;\n\tconst isCustom = [CLOTHING_CUSTOM_SCAN, CLOTHING_BANNER_SCAN, CLOTHING_CUSTOM_FIT_SCAN].includes(scanType);\n\tconst [showDrawer, setShowDrawer] = useState(true);\n\tconst handlePostHogEvent = () => {\n\t\tposthog.capture(shopDomain, {\n\t\t\tscanID: scanId,\n\t\t\temail: email,\n\t\t\theight: heightInCm,\n\t\t\tfocalLength: deviceFocalLength,\n\t\t\tclothesFit: \"0\",\n\t\t\tgender: gender,\n\t\t});\n\t};\n\n\tconst handleSignUp = useCallback(async () => {\n\t\ttry {\n\t\t\tif (isCustom) {\n\t\t\t\tawait swan.auth.addUser({\n\t\t\t\t\tscanId,\n\t\t\t\t\temail,\n\t\t\t\t\tname: userName,\n\t\t\t\t\tgender,\n\t\t\t\t\theight: heightInCm,\n\t\t\t\t});\n\t\t\t\tonVideoUploaded?.();\n\t\t\t}\n\t\t\thandlePostHogEvent();\n\t\t} catch (error) {\n\t\t\tconsole.log(error);\n\t\t}\n\t}, [isCustom]);\n\n\tconst { translate } = useContext(LanguageContext) || {};\n\n\tuseEffect(() => {\n\t\tif (isVideoUploadedCorrect || isMeasurementAvailable) {\n\t\t\thandleSignUp();\n\t\t}\n\t}, [isVideoUploadedCorrect, isMeasurementAvailable]);\n\n\tconst showNextButton = isSuccess || (isFaceScan ? isMeasurementAvailable && isVideoUploadedCorrect : isVideoUploadedCorrect || isMeasurementAvailable);\n\n\treturn (\n\t\t<Box className=\"flex h-full w-full flex-col \">\n\t\t\t<div className=\"h-full w-full flex-col items-center justify-center flex\">\n\t\t\t\t<CameraPermission loader={config?.loader} setShowDrawer={setShowDrawer} />\n\t\t\t\t<Drawer\n\t\t\t\t\topen={showDrawer}\n\t\t\t\t\tonClose={(_, reason) => {\n\t\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\t\tanchor=\"bottom\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"max-w-[28rem] mx-auto w-full h-full flex text-center flex-col justify-between items-center bg-primary rounded-t-[30px] p-[1rem]\"\n\t\t\t\t\t\tstyle={{ background: config?.style?.base?.backgroundColor }}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className=\"w-full h-full flex flex-col\">\n\t\t\t\t\t\t\t<Header title={translate?.(LanguageKeys.measurementsBeingTaken)} resolvedConfig={config} />\n\t\t\t\t\t\t\t<div className=\"flex items-center justify-center flex-1\">\n\t\t\t\t\t\t\t\t<video preload=\"auto\" className=\"max-h-[calc(100vh-450px)] mx-auto w-full object-contain border-none\" muted loop autoPlay playsInline>\n\t\t\t\t\t\t\t\t\t<source src={gender === GenderType.Male ? maleMeasurementProgress : measurementProgress} type=\"video/mp4\" />\n\t\t\t\t\t\t\t\t</video>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{showNextButton && <SpecificButton resolvedConfig={config} className=\"!w-[180px] mx-auto\" buttonText={translate?.(LanguageKeys.next)} buttonFunc={()=>{onScanSuccess?.()\n\t\t\t\t\t\t\t\tonVideoUploaded?.();\n\t\t\t\t\t\t\t}} />}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</Drawer>\n\t\t\t</div>\n\t\t</Box>\n\t);\n}\nexport default SignUp;\n","\"use client\";\nimport { useContext, useEffect } from \"react\";\nimport AngleDetector from \"./AngleDetector\";\nimport CameraPermission from \"./CameraPermission\";\nimport Modal from \"../Modal\";\nimport { Drawer } from \"@mui/material\";\nimport ScanErrorMessage from \"./ScanErrorMessage\";\nimport LoadingScreen from \"../LoadingScreen\";\nimport SignUp from \"../Signup\";\nimport { LanguageContext } from \"../../utils/context/languageContext\";\nimport { useLocalConfig } from \"../../config/useLocalConfig\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\n\nexport const BodyScanSteps = () => {\n\tconst {\n\t\tuserDetails,\n\t\tconfig,\n\t\tonRetry,\n\t\tisError,\n\t\tisSuccess,\n\t\tonScanSuccess,\n\t\tgender,\n\t\tscanUniqueKey,\n\t\tscanFailsError,\n\t\tsetScanUniqueKey,\n\t\tsetIsVideoUploaded,\n\t\tisMeasurementAvailable,\n\t\tisVideoUploadedCorrect,\n\t\tloading,\n\t\tshowDeniedModal,\n\t\tuploadLoading,\n\t\tsetScanFailsError,\n\t\tsetScanStartTime,\n\t\thandleShowStreamCamera,\n\t\tonVideoUploaded\n\t} = useContext(ParamsContext);\n\tconst { setPreferredLanguage } = useContext(LanguageContext) || {};\n\tconst resolvedConfig = useLocalConfig(config);\n\n\tuseEffect(() => {\n\t\tsetPreferredLanguage?.(resolvedConfig?.language);\n\t}, [resolvedConfig]);\n\n\tif (isError) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<CameraPermission />\n\t\t\t\t<Drawer\n\t\t\t\t\tanchor=\"bottom\"\n\t\t\t\t\topen={true}\n\t\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\t\tonClose={(event, reason) => {\n\t\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<ScanErrorMessage\n\t\t\t\t\t\tscanFailsError={scanFailsError || isError}\n\t\t\t\t\t\tonNext={() => {\n\t\t\t\t\t\t\tonRetry?.();\n\t\t\t\t\t\t\thandleShowStreamCamera();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t\t\t\tgender={gender}\n\t\t\t\t\t\tresolvedConfig={resolvedConfig}\n\t\t\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\t\t/>\n\t\t\t\t</Drawer>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif (isSuccess) {\n\t\treturn (\n\t\t\t<SignUp\n\t\t\t\tisFaceScan={false}\n\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\t// onComplete={onComplete}\n\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t\tisSuccess={isSuccess}\n\t\t\t\tonVideoUploaded={onVideoUploaded}\n\t\t\t/>\n\t\t);\n\t}\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div className=\"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full\"\n style={{ background: resolvedConfig?.style?.base?.backgroundColor }}\n >\n\t\t\t\t<LoadingScreen url={resolvedConfig?.loader} loaderType=\"black\" />\n\t\t\t</div>\n\t\t);\n\t}\n\tif (showDeniedModal.disabled) {\n\t\treturn <Modal />;\n\t}\n\n\tif (!uploadLoading && !scanFailsError && !isMeasurementAvailable && !isVideoUploadedCorrect) {\n\t\treturn (\n\t\t\t<AngleDetector\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t\tscanID={scanUniqueKey}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\tsetScanFailsError={setScanFailsError}\n\t\t\t\tsetScanStartTime={setScanStartTime}\n\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t/>\n\t\t);\n\t}\n\tif ((uploadLoading || isMeasurementAvailable || isVideoUploadedCorrect) && !scanFailsError) {\n\t\treturn (\n\t\t\t<SignUp\n\t\t\t\tisFaceScan={false}\n\t\t\t\tscanId={scanUniqueKey}\n\t\t\t\tisMeasurementAvailable={isMeasurementAvailable}\n\t\t\t\tuserDetails={userDetails}\n\t\t\t\tonScanSuccess={onScanSuccess}\n\t\t\t\tisVideoUploadedCorrect={isVideoUploadedCorrect}\n\t\t\t\tconfig={resolvedConfig}\n\t\t\t\tonVideoUploaded={onVideoUploaded}\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<CameraPermission />\n\t\t\t<Drawer\n\t\t\t\tanchor=\"bottom\"\n\t\t\t\topen\n\t\t\t\tclassName=\"camera-drawer\"\n\t\t\t\tonClose={(event, reason) => {\n\t\t\t\t\tif (reason === \"backdropClick\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<ScanErrorMessage\n\t\t\t\t\tscanFailsError={scanFailsError}\n\t\t\t\t\tonNext={() => {\n\t\t\t\t\t\tonRetry?.();\n\t\t\t\t\t\thandleShowStreamCamera();\n\t\t\t\t\t}}\n\t\t\t\t\tsetScanUniqueKey={setScanUniqueKey}\n\t\t\t\t\tgender={gender}\n\t\t\t\t\tresolvedConfig={resolvedConfig}\n\t\t\t\t\tsetIsVideoUploaded={setIsVideoUploaded}\n\t\t\t\t/>\n\t\t\t</Drawer>\n\t\t</>\n\t);\n};\n","\"use client\";\n\"use client\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport posthog from \"posthog-js\";\nimport useGyroSensor from \"../../customHooks/useGyroSensor\";\nimport { checkCameraPermission, createObjectMetadataArray, generateUuid, getCurrentTimeInSeconds, handleErrorMessage, handleScanTimeCapture, handleWebSocketCapture } from \"../../utils/utils\";\nimport LanguageContextProvider from \"../../utils/context/languageContext\";\nimport swan from \"../../utils/service/swanService\";\nimport { posthogPublicHost, posthogPublicKey } from \"../../utils/constants\";\nimport ParamsContext from \"../../utils/context/paramsContext\";\nimport MediaContextProvider from \"../../utils/context/mediaContext\";\nimport { BodyScanProps } from \"../../bodyScan\";\nimport { BodyScanSteps } from \"./BodyScanSteps\";\n\nconst clothesFit = \"0\";\n\nexport const BodyScan: React.FC<BodyScanProps> = ({ userDetails, config, onRetry, onScanError, isError, isSuccess, onScanSuccess, onVideoUploaded }) => {\n\tconst { gender, scanType, shopDomain, heightInCm, email, deviceFocalLength, deviceModelName, callbackUrl } = userDetails;\n\tconst [uploadLoading, setUploadLoading] = useState(false);\n\tconst [isVideoUploadedCorrect, setIsVideoUploadedCorrect] = useState(false);\n\tconst [isMeasurementAvailable, setIsMeasurementAvailable] = useState(false);\n\tconst [showDeniedModal, setShowDeniedModal] = useState({\n\t\tdisabled: false,\n\t\tmessage: \"\",\n\t});\n\tconst [scanFailsError, setScanFailsError] = useState(\"\");\n\tconst [isVideoUploaded, setIsVideoUploaded] = useState(false);\n\tconst [loading, setLoading] = useState(true);\n\tconst [startGyro, setStartGyro] = useState(false);\n\tconst [scanUniqueKey, setScanUniqueKey] = useState(\"\");\n\tconst [scanStartTime, setScanStartTime] = useState<number | null>(getCurrentTimeInSeconds());\n\tconst { gyroData } = useGyroSensor(startGyro);\n\n\tconst handleShowStreamCamera = useCallback(() => {\n\t\tsetScanUniqueKey(generateUuid());\n\t\tsetScanFailsError(\"\");\n\t\tsetUploadLoading(false);\n\t\tsetIsVideoUploaded(false);\n\t}, []);\n\n\tconst onError = (data: any) => {\n\t\tonScanError({ ...data, message: handleErrorMessage(data) });\n\t\tclearScanStartTimeAndScanId();\n\t\tsetIsMeasurementAvailable(false);\n\t\tsetScanFailsError(data);\n\t\tsetIsVideoUploadedCorrect(false);\n\t\thandleScanTimeCapture({\n\t\t\teventName: `${shopDomain}/measurement_failed/fit-view`,\n\t\t\tscanID: scanUniqueKey,\n\t\t\tstatus: \"failed\",\n\t\t\temail,\n\t\t\tmessage: handleErrorMessage(data),\n\t\t});\n\t\tif (scanStartTime)\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/scan_completion_time`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\tcompletionTime: getCurrentTimeInSeconds() - scanStartTime,\n\t\t\t\temail,\n\t\t\t});\n\t};\n\n\tconst clearScanStartTimeAndScanId = () => {\n\t\tsetScanStartTime(null);\n\t\tsetScanUniqueKey(\"\");\n\t};\n\n\tconst onSuccess = useCallback(\n\t\tasync (data: any) => {\n\t\t\tif (data && data?.scanStatus === \"success\" && data?.resultType === \"intermediate\" && data?.code === 200) {\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/measurement_success/intermediate`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tsetIsVideoUploadedCorrect(true);\n\t\t\t\t// onScanSuccess?.(data);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsVideoUploadedCorrect(true);\n\t\t\tclearScanStartTimeAndScanId();\n\t\t\tconst scanIdToSet = scanUniqueKey;\n\t\t\tsetIsMeasurementAvailable(true);\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/measurement_success/fit-view`,\n\t\t\t\tscanID: scanIdToSet,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t\tif (scanStartTime)\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_completion_time`,\n\t\t\t\t\tscanID: scanIdToSet,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\tcompletionTime: getCurrentTimeInSeconds() - scanStartTime,\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t},\n\t\t[scanType, shopDomain, scanUniqueKey],\n\t);\n\n\tconst handleMeasurementRecommendation = (scanId?: string) => {\n\t\tsetIsMeasurementAvailable(false);\n\t\tsetScanFailsError(\"\");\n\t\tsetIsVideoUploadedCorrect(false);\n\t\tswan.measurement.handleMeasurementSocket({\n\t\t\tscanId: scanId || scanUniqueKey,\n\t\t\tonPreopen: () => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"pre_open\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonOpen: () => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"open\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonClose: () =>\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"close\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t}),\n\t\t\tonError: (err) => {\n\t\t\t\tonError(err);\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"error\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t},\n\t\t\tonSuccess: (data) => {\n\t\t\t\thandleWebSocketCapture({\n\t\t\t\t\teventName: `${shopDomain}/webSocket`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tconnection: \"success\",\n\t\t\t\t\ttype: \"measurement_recommendation\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tonSuccess(data);\n\t\t\t},\n\t\t});\n\t};\n\n\tconst handleFileUpload = useCallback(\n\t\tasync (file: File) => {\n\t\t\tconst arrayMetaData = createObjectMetadataArray({\n\t\t\t\tgender,\n\t\t\t\tfocal_length: `${deviceFocalLength}`,\n\t\t\t\theight: `${heightInCm}`,\n\t\t\t\tcustomer_store_url: shopDomain,\n\t\t\t\tclothes_fit: clothesFit,\n\t\t\t\tscan_type: scanType,\n\t\t\t\tcallback_url: callbackUrl,\n\t\t\t});\t\t\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/body_scan_meta_data`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\temail,\n\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t});\n\t\t\ttry {\n\t\t\t\tawait swan.fileUpload.uploadFileFrontend({\n\t\t\t\t\tfile,\n\t\t\t\t\tarrayMetaData,\n\t\t\t\t\tscanId: scanUniqueKey,\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tawait swan.fileUpload.setDeviceInfo({\n\t\t\t\t\tmodel: deviceModelName,\n\t\t\t\t\tdetection: \"manual\",\n\t\t\t\t\tgyro: gyroData,\n\t\t\t\t\tscanId: scanUniqueKey,\n\t\t\t\t});\n\t\t\t\tconsole.log(\"video successfully uploaded\");\n\t\t\t\tsetIsVideoUploaded(false);\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_success`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t\t});\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: \"scan finished\",\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\temail,\n\t\t\t\t});\n\t\t\t\tsetScanStartTime(getCurrentTimeInSeconds());\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tsetIsVideoUploaded(true);\n\t\t\t\t}, 3000);\n\t\t\t} catch (error) {\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: \"scan finished\",\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\temail,\n\t\t\t\t\tmessage: handleErrorMessage(error),\n\t\t\t\t});\n\t\t\t\thandleScanTimeCapture({\n\t\t\t\t\teventName: `${shopDomain}/scan_failed`,\n\t\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\t\tstatus: \"failed\",\n\t\t\t\t\temail,\n\t\t\t\t\tmessage: handleErrorMessage(error),\n\t\t\t\t\tdata: JSON.stringify(arrayMetaData),\n\t\t\t\t});\n\t\t\t\tsetScanFailsError(handleErrorMessage(error));\n\t\t\t\tsetIsVideoUploaded(false);\n\t\t\t\tonScanError?.({ message: handleErrorMessage(error) });\n\t\t\t clearScanStartTimeAndScanId();\n\t\t\t} finally {\n\t\t\t\tsetStartGyro(false);\n\t\t\t}\n\t\t},\n\t\t[scanUniqueKey, gyroData],\n\t);\n\tconst checkMeasurementStatus = useCallback(\n\t\tasync (scanId: string) => {\n\t\t\ttry {\n\t\t\t\tconst res = await swan.measurement.getMeasurementResult(scanId);\n\t\t\t\tconst isMeasured = res?.data?.isMeasured;\n\t\t\t\tconst tempScanStartTime = scanStartTime || getCurrentTimeInSeconds();\n\t\t\t\tconst currentTimeInSeconds = getCurrentTimeInSeconds();\n\t\t\t\tconst fiveMinutesInSeconds = 5 * 60;\n\t\t\t\tsetLoading(false);\n\t\t\t\tif (isMeasured === false) {\n\t\t\t\t\tclearScanStartTimeAndScanId();\n\t\t\t\t\tsetScanUniqueKey(generateUuid());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsetUploadLoading(true);\n\t\t\t\tif (isMeasured === true) {\n\t\t\t\t\tawait onSuccess(null);\n\t\t\t\t} else if (isMeasured === null && tempScanStartTime > currentTimeInSeconds + fiveMinutesInSeconds) {\n\t\t\t\t\tonError(res?.data?.error);\n\t\t\t\t} else {\n\t\t\t\t\thandleMeasurementRecommendation(scanId);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.log(error);\n\t\t\t\tclearScanStartTimeAndScanId();\n\t\t\t\tsetScanUniqueKey(generateUuid());\n\t\t\t\tsetUploadLoading(false);\n\t\t\t}\n\t\t},\n\t\t[onError, onSuccess, setScanUniqueKey],\n\t);\n\n\tconst handleCameraPermission = useCallback(async () => {\n\t\tif (+heightInCm < 152.4 || +heightInCm > 213.36) {\n\t\t\tonScanError({\n\t\t\t\tmessage: \"Height must be between 152.4cm (5ft) and 213.36cm (7ft)\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst permission = await checkCameraPermission();\n\t\tif (permission.disabled) {\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/camera_activation`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"failed\",\n\t\t\t\temail,\n\t\t\t});\n\t\t\tsetLoading(false);\n\t\t} else {\n\t\t\tconst scanId = scanUniqueKey;\n\t\t\tif (scanId) {\n\t\t\t\tcheckMeasurementStatus(scanId);\n\t\t\t} else {\n\t\t\t\tsetLoading(false);\n\t\t\t}\n\t\t\thandleScanTimeCapture({\n\t\t\t\teventName: `${shopDomain}/camera_activation`,\n\t\t\t\tscanID: scanUniqueKey,\n\t\t\t\tstatus: \"success\",\n\t\t\t\temail,\n\t\t\t});\n\t\t}\n\t\tsetShowDeniedModal(permission);\n\t\tsetScanFailsError(\"\");\n\t\tsetIsVideoUploaded(false);\n\t}, [checkMeasurementStatus, email, scanUniqueKey, setScanUniqueKey, shopDomain]);\n\n\tuseEffect(() => {\n\t\tposthog.init(posthogPublicKey, { api_host: posthogPublicHost });\n\t\tposthog.capture(\"$pageview\");\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (isError || isSuccess) return;\n\t\tif (shopDomain) {\n\t\t\thandleCameraPermission();\n\t\t}\n\t}, [shopDomain, heightInCm, isError, isSuccess]);\n\n\tuseEffect(() => {\n\t\tif (isError || isSuccess) return;\n\t\tif (isVideoUploaded && shopDomain && scanUniqueKey) {\n\t\t\thandleMeasurementRecommendation();\n\t\t}\n\t}, [isVideoUploaded, shopDomain, scanUniqueKey, isError, isSuccess]);\n\treturn (\n\t\t<LanguageContextProvider>\n\t\t\t<MediaContextProvider>\n\t\t\t\t<ParamsContext.Provider\n\t\t\t\t\tvalue={{\n\t\t\t\t\t\tuserDetails,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tonRetry,\n\t\t\t\t\t\tonScanError,\n\t\t\t\t\t\tisError,\n\t\t\t\t\t\tisSuccess,\n\t\t\t\t\t\tonScanSuccess,\n\t\t\t\t\t\tgender,\n\t\t\t\t\t\tscanUniqueKey,\n\t\t\t\t\t\tscanFailsError,\n\t\t\t\t\t\tsetScanUniqueKey,\n\t\t\t\t\t\tsetIsVideoUploaded,\n\t\t\t\t\t\tisMeasurementAvailable,\n\t\t\t\t\t\tisVideoUploadedCorrect,\n\t\t\t\t\t\tloading,\n\t\t\t\t\t\tshowDeniedModal,\n\t\t\t\t\t\tuploadLoading,\n\t\t\t\t\t\tsetStartGyro,\n\t\t\t\t\t\thandleFileUpload,\n\t\t\t\t\t\tsetUploadLoading,\n\t\t\t\t\t\thandleShowStreamCamera,\n\t\t\t\t\t\tsetScanFailsError,\n\t\t\t\t\t\tsetScanStartTime,\n\t\t\t\t\t\tonVideoUploaded\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<BodyScanSteps />\n\t\t\t\t</ParamsContext.Provider>\n\t\t\t</MediaContextProvider>\n\t\t</LanguageContextProvider>\n\t);\n};\n","import { useCallback, useEffect, useState } from \"react\";\n\ninterface GyroDataItem {\n alpha?: string;\n beta?: string;\n gamma?: string;\n timestamp?: string;\n}\n\nexport interface IOSDeviceOrientationEvent extends DeviceOrientationEvent {\n requestPermission?: () => Promise<PermissionState>;\n}\n\nfunction useGyroSensor(startGyro: boolean) {\n const [gyroData, setGyroData] = useState<GyroDataItem[]>([]);\n const [permissionGranted, setPermissionGranted] = useState(false);\n\n const handleOrientation = useCallback((event: DeviceOrientationEvent) => {\n try {\n const { alpha, beta, gamma } = event;\n setGyroData((prev: GyroDataItem[]) => [\n ...prev,\n {\n alpha: alpha?.toString() || undefined,\n beta: beta?.toString() || undefined,\n gamma: gamma?.toString() || undefined,\n timestamp: new Date().toISOString(),\n },\n ]);\n } catch (error) {\n console.log(error);\n }\n }, []);\n\n const requestPermission = useCallback(async () => {\n const DeviceOrientation =\n DeviceOrientationEvent as unknown as IOSDeviceOrientationEvent;\n\n if (\n typeof DeviceOrientation !== \"undefined\" &&\n typeof DeviceOrientation.requestPermission === \"function\"\n ) {\n try {\n const response = await DeviceOrientation.requestPermission();\n if (response === \"granted\") {\n setPermissionGranted(true);\n } else {\n console.warn(\"Device orientation permission denied.\");\n }\n } catch (error) {\n console.error(\"Error requesting device orientation permission:\", error);\n }\n } else {\n // Permission not required on non-iOS devices\n setPermissionGranted(true);\n }\n }, []);\n\n useEffect(() => {\n if (startGyro && permissionGranted) {\n window.addEventListener(\"deviceorientation\", handleOrientation);\n } else {\n setGyroData([]);\n }\n return () => {\n window.removeEventListener(\"deviceorientation\", handleOrientation);\n };\n }, [startGyro, permissionGranted, handleOrientation]);\n\n useEffect(() => {\n if (startGyro) {\n requestPermission();\n }\n }, [startGyro, requestPermission]);\n\n return { gyroData };\n}\n\nexport default useGyroSensor;\n"],"names":["MEDIA_TYPES","MediaContext","createContext","undefined","MediaContextProvider","children","size","setSize","useState","window","innerWidth","innerHeight","clearInputs","setClearInputs","updateSize","useEffect","useLayoutEffect","addEventListener","removeEventListener","media","mediaDetails","useMemo","_jsx","Provider","value","SwitchIcon","React","memo","_jsxs","width","height","viewBox","fill","xmlns","d","stroke","strokeWidth","strokeLinecap","strokeLinejoin","LevelScreen","angle","countdown","isScanning","isInTargetRange","stabilityScore","config","translate","useContext","LanguageContext","getProximityToTarget","useCallback","Math","max","min","backgroundColor","style","angleDetector","successAngleBackground","proximity","successAngleLowBackground","round","handelTextColour","isLight","successAngleTextLightColor","successAngleTextDarkColor","getTextColor","handelColourCode","getColorCode","cd","fixVh","document","documentElement","setProperty","className","Header","noTitle","resolvedConfig","border","fontFamily","base","baseFontFamily","color","cn","transform","transition","LanguageKeys","startLevelCheck","leavePhone","placePhoneUpright","CameraScanChild","handleShowStreamCamera","loadingCam","handleUserMedia","handlePause","pause","recordingStarted","startSendingVideoFrames","showPause","webcamRef","resetDetector","onClick","X","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","audioTimeoutId","lastVideoPlayed","ScanningComponent","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","import","setBackend","ready","modelConfig","runtime","modelType","solutionPath","createDetector","SupportedModels","BlazePose","mediapipeError","warn","error","isFrontFrame","body","length","filter","p","current","then","success","s","callback","video","readyState","poses","estimatePoses","flipHorizontal","keypoints","slice","map","kp","x","y","score","prev","err","retryLoading","useTensorFlow","firstScan","poseStoppedRef","counterRef","consecutiveFalseRef","poseListenerRegistered","postPoseProcessRef","supportedTypes","setSupportedTypes","setStartGyro","handleFileUpload","setUploadLoading","ParamsContext","clearTimeout","generateUuid","speechService","stopAudio","stop","forEach","el","stream","setTimeout","handleReScan","rescanSupportCaptureEvent","eventName","status","swan","poseDetection","disconnect","stopRecording","playAudio","handleSocket","connect","posthog","capture","handleSpinDataAvailable","data","concat","handleScanTimeCapture","message","handleStartCaptureClick","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","Modal","Dialog","open","_Fragment","heading","headingFontFamily","fontSize","headingFontSize","headingColor","fontWeight","headingFontWeight","cameraAlreadyInUse","baseFontSize","baseTextColor","tryClosingBrowser","checkCameraSettings","setting","getBrowserName","enableCameraPermissions","CameraPermission","setShowDrawer","loader","showDeniedModal","setShowDeniedModal","loading","setLoading","handleCameraPermission","permission","checkCameraPermission","LoadingScreen","url","loaderType","VideoPlayer","link","onReady","wrapperClassName","videoReference","playerReference","videoJsOptions","autoplay","controls","responsive","fluid","muted","navigationUI","poster","videoPoster","player","videojs","updatedOptions","sources","isDisposed","dispose","playsInline","onDrag","preventDefault","ScanErrorMessage","scanFailsError","serverAtCapacity","onNext","showModal","setShowModal","handleShowModal","background","issueWithScan","reason","handleErrorMessage","VIDEO_POSTER_GENDER_BASED","alt","serverAtCapacityDescription","scanAgain","onClose","GENDER","PRE_LINK","male","SignUp","isFaceScan","isVideoUploadedCorrect","isMeasurementAvailable","onScanSuccess","isSuccess","onVideoUploaded","deviceFocalLength","userName","scanType","isCustom","CLOTHING_CUSTOM_SCAN","CLOTHING_BANNER_SCAN","CLOTHING_CUSTOM_FIT_SCAN","includes","showDrawer","handleSignUp","auth","addUser","name","focalLength","clothesFit","showNextButton","Box","Drawer","_","anchor","title","measurementsBeingTaken","loop","autoPlay","GenderType","Male","maleMeasurementProgress","measurementProgress","next","BodyScanSteps","onRetry","isError","scanUniqueKey","uploadLoading","setPreferredLanguage","useLocalConfig","language","BodyScan","onScanError","deviceModelName","callbackUrl","setIsVideoUploadedCorrect","setIsMeasurementAvailable","isVideoUploaded","startGyro","scanStartTime","gyroData","setGyroData","permissionGranted","setPermissionGranted","alpha","toString","timestamp","Date","toISOString","useGyroSensor","onError","clearScanStartTimeAndScanId","completionTime","onSuccess","scanStatus","resultType","code","scanIdToSet","handleMeasurementRecommendation","measurement","handleMeasurementSocket","onPreopen","handleWebSocketCapture","connection","onOpen","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","LanguageContextProvider"],"mappings":"0rBAYO,MAAMA,GACF,UADEA,GAEN,MAFMA,GAGH,SAWGC,GAAeC,OAC1BC,GAGF,SAASC,IAAqBC,SAAEA,IAC9B,MAAOC,EAAMC,GAAWC,EAAS,CAACC,QAAQC,WAAYD,QAAQE,eACvDC,EAAaC,GAAkBL,GAAS,GAEzCM,EAAa,KACjBP,EAAQ,CAACE,QAAQC,WAAYD,QAAQE,eAEvCI,EAAU,KACRD,KACC,IACHE,EAAgB,KACdP,OAAOQ,iBAAiB,SAAU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,EAAY,CACXjL,QAAS,4DAKX,MAAMoF,QAAmBC,IACzB,GAAID,EAAWvO,SACdkJ,EAAsB,CACrBd,UAAW,GAAG9G,sBACdT,OAAQiT,EACRzL,OAAQ,SACRhH,UAEDgN,GAAW,OACL,CACSyF,EAEduD,GAFcvD,GAIdzF,GAAW,GAEZnF,EAAsB,CACrBd,UAAW,GAAG9G,sBACdT,OAAQiT,EACRzL,OAAQ,UACRhH,SAED,CACD8M,EAAmBI,GACnBxN,EAAkB,IAClBD,GAAmB,IACjB,CAACuW,GAAwBhW,EAAOyS,EAAe7S,EAAkBK,IAoBpE,OAlBAlI,EAAU,KACTyP,EAAQ+O,KAAKC,EAAkB,CAAEC,SAAUC,IAC3ClP,EAAQC,QAAQ,cACd,IAEH1P,EAAU,KACLya,GAAWjC,GACXtQ,GACHgN,MAEC,CAAChN,EAAYF,EAAYyS,EAASjC,IAErCxY,EAAU,KACLya,GAAWjC,GACX6C,GAAmBnT,GAAcwS,GACpCgC,MAEC,CAACrB,EAAiBnT,EAAYwS,EAAeD,EAASjC,IAExDjY,EAACqe,EAAuB,CAAAtf,SACvBiB,EAAClB,GAAoB,CAAAC,SACpBiB,EAAC6N,EAAc5N,SAAQ,CACtBC,MAAO,CACNqH,cACAhG,SACA0Y,UACAQ,cACAP,UACAjC,YACAD,gBACAxQ,SACA2S,gBACAzD,iBACApP,mBACAH,qBACA4Q,yBACAD,yBACArD,UACAF,kBACA6F,gBACA1M,eACAC,oBACAC,mBACAxJ,0BACAgD,oBACAC,mBACA6Q,mBACAnZ,SAEDiB,EAACga,GAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),s=require("./LoadingScreen-CPoVy1B3.js"),n=require("clsx"),a=require("react-webcam"),r=require("lucide-react"),o=require("@mui/material"),c=require("video.js");const i="DESKTOP",l="TAB",u="MOBILE",d=t.createContext(void 0);function m({children:s}){const[n,a]=t.useState([window?.innerWidth,window?.innerHeight]),[r,o]=t.useState(!1),c=()=>{a([window?.innerWidth,window?.innerHeight])};t.useEffect(()=>{c()},[]),t.useLayoutEffect(()=>(window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[c]);let m=i;n[0]>768&&n[0]<1024&&(m=l),n[0]<768&&(m=u);const f=t.useMemo(()=>({size:n,setSize:a,clearInputs:r,setClearInputs:o,media:m}),[n,r,m]);return e.jsx(d.Provider,{value:f,children:s})}var f=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 p=t.memo(function({angle:a,countdown:r,isScanning:o,isInTargetRange:c,stabilityScore:i,children:l}){const{translate:u}=t.useContext(s.LanguageContext)||{},d=s.useConfig(),m=t.useCallback(()=>a<80?Math.max(0,Math.min(100,10*(a-60))):a>95?Math.max(0,Math.min(100,10*(105-a))):100,[a]),p=t.useMemo(()=>{if(o)return d?.style?.angleDetector?.successAngleBackground||"#4f46e5";const e=m();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,m]),h=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`,[]),g=t.useCallback((e=!1)=>{const t=m();return o?`text-[${d?.style?.angleDetector?.successAngleTextLightColor}]`:h(e,t)},[o,m]),x=t.useCallback((e,t)=>t>70||e?d?.style?.angleDetector?.successAngleTextLightColor:d?.style?.angleDetector?.successAngleTextDarkColor,[]),y=t.useCallback((e=!1)=>{const t=m();return o?d?.style?.angleDetector?.successAngleTextLightColor:x(e,t)},[o,m]),S=r;function v(){document.documentElement.style.setProperty("--real-vh",window.innerHeight+"px")}return v(),window.addEventListener("resize",v),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:p},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})})}),null!==S?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",color:y()},children:S})}):o?e.jsxs("div",{className:"relative flex flex-col items-center justify-center",children:[e.jsx("div",{className:"relative flex h-16 w-16 items-center justify-center rounded-[9999px] border-2 bg-[#fff]/30 border-[#fff]",children:e.jsx("div",{className:"h-4 w-4 rounded-[9999px] animate-pulse bg-[#fff]/80"})}),l]}):e.jsxs("div",{className:n("relative flex h-[4rem] w-[4rem] items-center justify-center rounded-[9999px] ",c?"bg-[#fff]/20 border-[#fff]":"bg-[#fff]/10 border-[#fff]"),style:{transform:`translateY(${3*(90-a)}px)`,transition:"transform 0.2s ease-out",border:`2px solid ${y()}`},children:[e.jsx("div",{className:`h-[1rem] w-[1rem] rounded-[9999px] bg-[${y()}]/80`,style:{backgroundColor:`${y()}B3`}}),e.jsxs("div",{className:n("mt-[.5rem] text-center w-[180px] flex-col flex items-center absolute top-[60px]",g()),style:{color:y()},children:[e.jsx(f,{size:30}),e.jsxs("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif"},children:[" ",u?.(s.LanguageKeys.startLevelCheck),e.jsx("br",{})]})]})]}),null!==S&&e.jsx("div",{className:"absolute bottom-[8rem] text-center",children:e.jsx("div",{className:n("text-sm font-medium px-4 py-1.5 bg-black/20 rounded-[9999px] mt-8",g()),style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:u?.(s.LanguageKeys.leavePhone)})}),c&&null===S&&!o&&e.jsx("div",{className:"absolute bottom-[8rem] w-[12rem]",children:e.jsx("div",{className:`h-[.375rem] w-full bg-[${y()}]/20 rounded-[9999px] overflow-hidden`,style:{backgroundColor:`${y()}33`},children:e.jsx("div",{className:`h-full bg-[${y()}]/70 transition-all duration-300 rounded-[9999px]`,style:{width:`${a}%`,backgroundColor:`${y()}B3`}})})}),null===S&&!o&&e.jsx("div",{className:"absolute bottom-[5rem] text-center",children:e.jsxs("div",{className:n("text-[1.5rem] font-light",g()),style:{color:y()},children:[Math.round(a),"°"]})}),null===S&&!o&&e.jsx("div",{className:"absolute bottom-[2rem] text-center max-w-[20rem] mx-auto",children:e.jsx("div",{className:n("text-[.75rem] opacity-50",g()),style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",color:y()},children:u?.(s.LanguageKeys.placePhoneUpright)})})]})});function h({resetScan:n,loadingCam:o,onUserMedia:c,onPause:i,pause:l,recordingStarted:m,startSendingVideoFrames:f,showPause:p,webcamRef:h,onUserMediaError:g,resetDetector:x,videoConstraints:y,webcamKey:S}){const{media:v}=t.useContext(d)||{},{translate:b}=t.useContext(s.LanguageContext)||{};return e.jsxs("div",{className:"App w-screen h-[100vh] relative ",children:[e.jsx("span",{onClick:()=>{n(),x()},className:"fixed right-[20px] top-[20px] z-[999]",children:e.jsx(r.X,{className:"text-[#fff]"})}),e.jsx("div",{className:"w-full h-full overflow-hidden ",children:v===u&&e.jsx(a,{audio:!1,ref:h,screenshotQuality:1,videoConstraints:y,mirrored:!0,screenshotFormat:"image/jpeg",onUserMedia:c,onUserMediaError:g,style:{position:"fixed",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}},S)}),e.jsxs("div",{className:"fixed bottom-[30px] w-full z-[999] flex flex-col gap-4 items-center justify-center",children:[p&&e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto ",prefix:s.pauseIcon,buttonText:b?.(s.LanguageKeys.pause),buttonFunc:i,btnSecondary:!0}),l?e.jsx("div",{children:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto",buttonText:b?.(s.LanguageKeys.restart),buttonFunc:n,btnSecondary:!0})}):m?null:e.jsx(s.SpecificButton,{className:"!w-[180px] !h-[40px] !py-[0] mx-auto !bg-[#ffffff] !text-[#000000] "+(o?"!opacity-50":""),buttonText:b?.(s.LanguageKeys.startScan),buttonFunc:f,disabled:o})]}),e.jsx("audio",{id:"audioElement",crossOrigin:"anonymous",preload:"auto",style:{position:"absolute",zIndex:-99999},src:`${s.voiceOverAssetsPath}scanAudioInstructions/silence.mp3`})]})}let g=null,x=null,y=null;let S,v=null,b=null;var C=t.memo(function({setIsScanLocked:n,resetDetector:a,scanID:r,setIsVideoUploaded:o,setScanFailsError:c,setScanStartTime:i,setScanUniqueKey:l,userDetails:u}){const{gender:d,heightInCm:m,email:f,shopDomain:p}=u,C=t.useRef(null),w=t.useRef(null),j=t.useRef(null),[N,k]=t.useState([]),[E,D]=t.useState(!0),[T,F]=t.useState(!1),[I,L]=t.useState(!1),[M,P]=t.useState(!0),[_,$]=t.useState(!1),A=t.useRef(null),[U,R]=t.useState(""),[z,K]=t.useState([]),[O,B]=t.useState(""),[q,V]=t.useState(!1),[W,H]=t.useState(!1),[G,J]=t.useState(!1),[Q,X]=t.useState([]),[Y,Z]=t.useState(!1),ee=t.useRef(!0),{poseDetector:te}=function(){const[e,s]=t.useState(0),[n,a]=t.useState(0),[r,o]=t.useState(!1),c=t.useRef(0),i=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-BaWguRmj.js")}),import("@tensorflow/tfjs-core"),import("@tensorflow/tfjs-backend-webgl")]);y=e,await t.setBackend("webgl"),await t.ready(),console.log("TensorFlow backend ready (WebGL)");const n={runtime:"mediapipe",modelType:"full",solutionPath:"https://cdn.jsdelivr.net/npm/@mediapipe/pose"};try{x=await y.createDetector(y.SupportedModels.BlazePose,n),console.log("MediaPipe detector created successfully")}catch(e){console.warn("MediaPipe failed, falling back to TFJS runtime:",e),x=await y.createDetector(y.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),g=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,!x)return g||(g=u()),g.then(e=>{e&&l.current&&o(!0)}),()=>{l.current=!1};o(!0)},[]),t.useEffect(()=>{i.current=e,e>6&&c.current<2&&(a(e=>e+1),s(0))},[e]),t.useEffect(()=>{c.current=n},[n]),{poseDetector:async(e,t)=>{if(!x||!l.current||!t?.current?.video)return;const n=t.current.video;if(!(n.readyState<2))try{const t=await x.estimatePoses(n,{flipHorizontal:!1});if(!t||!t.length)return;const a=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!==c.current||d(a)||s(e=>e+1),1===c.current&&d(a)&&s(e=>e+1),2===c.current&&e()}catch(e){console.error("Pose detection error:",e)}},isLoaded:r,spinPhase:n,resetDetector:()=>{c.current=0,i.current=0,s(0),a(0)},retryLoading:async()=>{x||g||(g=u(),await g&&l.current&&o(!0))}}}(),se=t.useRef(!0),ne=t.useRef(!1),ae=t.useRef(0),re=t.useRef(0),oe=t.useRef(!1),ce=t.useRef(()=>{}),[ie,le]=t.useState([]),[ue,de]=t.useState(0),[me,fe]=t.useState(s.videoConstraintsExact),{setStartGyro:pe,uploadScanFile:he,setUploadLoading:ge,swan:xe,onScanStart:ye}=t.useContext(s.ParamsContext),Se=()=>{ne.current=!1,clearTimeout(S),A.current&&clearTimeout(A.current),l(s.generateUuid()),c(""),ge?.(!1),k([]),j.current=null,D(!0),F(!1),L(!1),P(!0),$(!1),A.current=null,R(""),K([]),B(""),V(!q),pe(!1),s.speechService.stopAudio(),H(!1),J(!1),ae.current=0,re.current=0,oe.current=!1,null!==w.current&&w.current.stop(),Q.forEach(e=>{w.current&&w.current.removeEventListener("dataavailable",e)}),X([]),ee.current=!0,Z(!1),o(!1),C.current?.stream&&D(!1)},ve=t.useCallback(()=>{setTimeout(()=>{D(!1)},1e3)},[]),be=t.useCallback(e=>{if(console.log("camera error",e),me===s.videoConstraintsExact)return fe(s.videoConstraintsFallback),void de(e=>e+1);D(!1)},[me]),Ce=t.useCallback(()=>{s.rescanSupportCaptureEvent({eventName:`${p}/rescan`,email:f,scanID:r,height:m,gender:d,status:!1}),ee.current=!1,Se(),Pe()},[Se,r,f]),we=t.useCallback(()=>{ee.current=!1,J(!0),Z(!1),A.current&&clearTimeout(A.current),w.current&&w.current.pause(),s.speechService.stopAudio(),xe.poseDetection.disconnect(),ae.current=0,re.current=0,oe.current=!1,w.current&&w.current.stop(),Q.forEach(e=>{w.current&&w.current.removeEventListener("dataavailable",e)}),X([]),clearTimeout(S)},[w,Q,s.speechService,ee]),je=t.useMemo(()=>s.getPreferredMediaRecorderTypes(),[]),Ne=s.getRecordingMimeType(ie),ke=s.getRecordingExtension(Ne),Ee=t.useCallback(async()=>{ee.current=!0,await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),J(!1),Z(!1),A.current&&clearTimeout(A.current),F(!1)},[A,s.speechService]),De=t.useCallback(async()=>{try{v=await xe.poseDetection.connect(),s.posthog.capture(`${p}/pose_detection_connected`,{scanID:r,email:f,id:v})}catch(e){console.log(e,"while connecting websocket")}},[r,p,f]),Te=t.useCallback(({data:e})=>{e&&e.size>0&&ee.current&&(k(t=>t.concat(e)),!ne.current&&C.current&&(ne.current=!0,te(()=>{Ee(),s.handleScanTimeCapture({eventName:`${p}/tensorFlow`,scanID:r,email:f,message:"recording stopped by tensorflow "})},C)))},[Ee,s.handleScanTimeCapture,p,r,f,C]),Fe=t.useCallback(async()=>{z.length>0&&ee.current&&(await s.speechService.playAudio(s.voiceOverAssetsPath+z[z.length-1]),ee.current&&(S=setTimeout(Fe,2e3)))},[z,ee]),Ie=t.useCallback(()=>{w&&w.current&&w.current.stop(),F(!0);try{if(C&&C.current&&C.current.stream){const e=C.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();j.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};ie[0]&&(t.mimeType=ie[0]),w.current=new MediaRecorder(C.current.stream,t),w.current.addEventListener("dataavailable",Te),X([...Q,Te]),w.current.start(1e3),P(!1)}}catch(e){console.log("error while using media recorder",e)}},[C,ie,Te,Q]),Le=t.useCallback(async()=>{A.current&&clearTimeout(A.current),Ie(),ee.current&&(A.current=setTimeout(async()=>{ee.current&&(await s.speechService.playAudio(`${s.voiceOverAssetsPath}SpotOn.mp3`),F(!1))},15e3)),L(!0),ee.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}Spin.mp3`)},[Ie,ee,s.speechService]);t.useEffect(()=>{ce.current=Le},[Le]);const Me=t.useCallback(({data:e})=>{e.size>0&&xe.poseDetection.connected()&&(oe.current||(oe.current=!0,xe.poseDetection.poseStatus(async e=>{if(e&&e.audio&&e.audio.length>0){const t=document.querySelector("#audioElement");!0===e.status&&e.sid===v?(re.current=0,ae.current<2?(0===ae.current&&t?.paused&&await s.speechService.playAudio(s.voiceOverAssetsPath+e.audio),ae.current+=1):(B(e.audio),clearTimeout(S),xe.poseDetection.disconnect(),oe.current=!1,setTimeout(()=>ce.current(),1e3))):(re.current+=1,re.current>=3&&(ae.current=0),!t?.paused||b&&b?.audioName===e.audio?b?.audioName===e.audio&&t?.paused&&(b&&b.no_of_times_skipped>=b.skipCount?(b.no_of_times_skipped=0,s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)):b&&(b.no_of_times_skipped+=1)):(b={skipCount:2,no_of_times_skipped:0,audioName:e.audio},s.speechService.playAudio(s.voiceOverAssetsPath+e.audio)))}})),C?.current&&null!==C.current.getScreenshot()&&xe.poseDetection.videoEmit({image:C.current.getScreenshot()||"",scanId:r}))},[C,r,xe,v,s.speechService]),Pe=t.useCallback(async()=>{$(!0),pe(!0),ye?.(),se.current&&(se.current=!1,s.handleScanTimeCapture({eventName:"scan started",scanID:r,status:"success",email:f})),i(s.getCurrentTimeInSeconds()),D(!0),ee.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}StartScan.mp3`),ee.current&&await s.speechService.playAudio(`${s.voiceOverAssetsPath}LiftArmsAndHoldAtHip.mp3`),ee.current&&($(!1),F(!0),H(!0),Z(!0),ve());try{if(C&&C.current&&C.current.stream&&ee.current){const e=C.current.stream.getVideoTracks()[0];if(e){const t=e.getSettings();j.current=t.frameRate||null}const t={videoBitsPerSecond:15e5};ie[0]&&(t.mimeType=ie[0]),ee.current&&(w.current=new MediaRecorder(C.current.stream,t)),ee.current&&w.current&&w.current.addEventListener("dataavailable",Me),X([...Q,Me]),w.current&&w.current.start(1e3),P(!1),ee.current&&(S=setTimeout(Fe,2e3))}}catch(e){console.log("error ----------",e)}},[C,ie,Me,Q,Fe,ee,ye]);return t.useEffect(()=>(p&&(n(!0),De()),()=>{v&&(xe.poseDetection.disconnect(),s.posthog.capture(`${p}/pose_detection_disconnected`,{scanID:r,email:f,id:v})),Q.forEach(e=>{w?.current?.removeEventListener("dataavailable",e)})}),[q,p]),t.useEffect(()=>{z.push(U)},[U]),t.useEffect(()=>{K([])},[O]),t.useEffect(()=>{const e=N.length&&N.length>0;M||!e||T||!ee.current||G||w&&w.current&&(T||(w.current.stop(),P(!0)))},[M,T,N,G]),t.useEffect(()=>{const e=N.length&&N.length>0;if(M||!e||T)console.log("No video found to upload.");else if(w&&w.current&&ee.current&&!G&&!T){const e=new File(N,`${r}.${ke}`,{type:Ne});ge?.(!0),c(""),he?.(e,j.current)}},[M,T,N,G,w,ee]),t.useEffect(()=>{const e=s.getSupportedMediaRecorderTypes(je,s.videoTypes);le(e)},[je]),t.useEffect(()=>{Se()},[]),e.jsx(h,{resetDetector:a,resetScan:Se,loadingCam:E,onPause:we,showRestart:W,pause:G,onReScan:Ce,recordingStarted:T,isScanning:_,startSendingVideoFrames:Pe,faceDone:I,stopRecording:Ee,showPause:Y,webcamRef:C,onUserMedia:ve,onUserMediaError:be,videoConstraints:me,webcamKey:ue})});function w({scanID:s,userDetails:n,setIsVideoUploaded:a,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:c}){const[i,l]=t.useState(90),[u,d]=t.useState(0),[m,f]=t.useState(null),[h,g]=t.useState(!1),[x,y]=t.useState(0),S=t.useRef([]),[v,b]=t.useState(!1),w=i-u,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)),l(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);y(j&&e<2?e=>Math.min(100,e+10):e=>Math.max(0,e-20))}j||null===m&&!h||k()},[w,j,m,h]),t.useEffect(()=>{x>=100&&null===m&&!h&&N(),x<50&&null!==m&&k()},[x,m,h]);const N=()=>{f(3);const e=setInterval(()=>{f(t=>null===t||t<=1?(clearInterval(e),g(!0),null):t-1)},1e3)},k=()=>{f(null),v||g(!1)};return e.jsx(p,{angle:w,countdown:m,isScanning:h,isInTargetRange:j,stabilityScore:x,children:h&&e.jsx(C,{setIsScanLocked:b,resetDetector:()=>{l(90),d(0),f(null),g(!1),y(0),b(!1),S.current=[]},scanID:s,userDetails:n,setIsVideoUploaded:a,setScanFailsError:r,setScanStartTime:o,setScanUniqueKey:c})})}function j({message:n,config:a}){const{translate:r}=t.useContext(s.LanguageContext)||{};return e.jsx(o.Dialog,{open:!0,className:"confirm-modal",children:e.jsx("div",{className:"modal-main",children:e.jsx("div",{className:"text-center",children:n?e.jsxs(e.Fragment,{children:[e.jsx("h2",{style:{fontFamily:a?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:a?.style?.heading?.headingFontSize||"32px",color:a?.style?.heading?.headingColor||"#000",fontWeight:a?.style?.heading?.headingFontWeight||"normal"},children:r?.(s.LanguageKeys.cameraAlreadyInUse)}),e.jsx("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:a?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:a?.style?.base?.baseFontSize||"16px",color:a?.style?.base?.baseTextColor||"#000"},children:r?.(s.LanguageKeys.tryClosingBrowser)})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{style:{fontFamily:a?.style?.heading?.headingFontFamily||"SeriouslyNostalgic Fn",fontSize:a?.style?.heading?.headingFontSize||"32px",color:a?.style?.heading?.headingColor||"#000",fontWeight:a?.style?.heading?.headingFontWeight||"normal"},children:r?.(s.LanguageKeys.checkCameraSettings)}),e.jsx("p",{className:"mt-[0.5rem] text-sm",style:{fontFamily:a?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:a?.style?.base?.baseFontSize||"16px",color:a?.style?.base?.baseTextColor||"#000"},children:`${r?.(s.LanguageKeys.setting)} > ${s.getBrowserName()} > ${r?.(s.LanguageKeys.enableCameraPermissions)}`})]})})})})}function N({setShowDrawer:n,config:r,loader:o}){const[c,i]=t.useState({disabled:!1,message:""}),[l,u]=t.useState(!0),d=t.useRef(null),m=t.useCallback(async()=>{const e=await s.checkCameraPermission();i(e),u(!1)},[]);return t.useEffect(()=>{m()},[]),l?e.jsx(s.LoadingScreen,{url:o,loaderType:"black"}):c?.disabled?e.jsx(j,{config:r,message:c?.message}):e.jsx(a,{audio:!1,ref:d,screenshotQuality:1,videoConstraints:s.videoConstraints,mirrored:!0,onUserMedia:()=>n?.(!0),screenshotFormat:"image/jpeg",style:{position:"relative",top:0,bottom:0,zIndex:0,width:"100%",height:"100%",objectFit:"cover"}})}function k({link:n,onReady:a,wrapperClassName:r="[&_video]:rounded-t-[20px] w-full h-full"}){const o=t.useRef(null),i=t.useRef(null);let l={autoplay:!0,controls:!1,responsive:!0,fluid:!0,muted:!0,navigationUI:"hide",preload:"metadata",poster:s.videoPoster};return t.useEffect(()=>{if(!i.current&&n&&o?.current){const e=c(o.current,{...l});e.ready(()=>{i.current=e;const t={...l,sources:[{src:n,type:"application/x-mpegURL"}]};e.autoplay(t.autoplay),e.src(t.sources),a?.(e)})}},[n,o]),t.useEffect(()=>{const e=i.current;return()=>{e&&!e.isDisposed()&&(e.dispose(),i.current=null)}},[i]),e.jsx("div",{className:r,children:e.jsx("video",{ref:o,muted:!0,className:"video-js",playsInline:!0,onDrag:e=>e.preventDefault()})})}function E({scanFailsError:n,onNext:a,gender:c,setScanUniqueKey:i,setIsVideoUploaded:l}){const{translate:u}=t.useContext(s.LanguageContext)||{},d=s.useConfig(),[m,f]=t.useState(!1),p=()=>{f(!m)};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:d?.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})}),e.jsx("div",{className:"flex-1",children:n&&e.jsxs("div",{className:"px-[1rem]",children:[e.jsx("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:u?.(s.LanguageKeys.issueWithScan)}),e.jsx("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:u?.(s.LanguageKeys.reason)}),e.jsx("p",{style:{fontFamily:d?.style?.base?.baseFontFamily||"Inter, sans-serif",fontSize:d?.style?.base?.baseFontSize||"16px",color:d?.style?.base?.baseTextColor||"#1E1E1E"},children:s.handleErrorMessage(n)}),e.jsx("img",{className:"my-[0.5rem] aspect-[2/1.4] w-full object-cover",onClick:p,src:s.VIDEO_POSTER_GENDER_BASED[c],alt:"icon"})]})}),n&&e.jsx("div",{className:"p-[1rem] flex gap-[0.5rem]",children:e.jsx(s.SpecificButton,{disabled:!1,buttonText:u?.(s.LanguageKeys.scanAgain),className:"!shadow-none",buttonFunc:()=>{a?a?.():i?.(s.generateUuid()),l?.(!1)}})})]}),m&&e.jsxs(o.Dialog,{className:"w-screen h-screen video-modal",onClose:p,open:m,children:[e.jsx("div",{className:"flex justifyEnd ",children:e.jsx("span",{className:"closeBtn",onClick:p,children:e.jsx(r.X,{className:"absolute right-[8px] top-[8px] text-white z-[9]"})})}),e.jsx("div",{className:"aspect-video object-cover rounded-[20px] ",children:e.jsx(k,{link:c?s.GENDER[c].PRE_LINK:s.GENDER.male.PRE_LINK,wrapperClassName:"w-screen h-screen fixed top-[0] left-[0]"})})]})]})}function D({scanId:n,userDetails:a,config:r,isVideoUploadedCorrect:c,isMeasurementAvailable:i,onComplete:l,isSuccess:u,onCustomScanSuccess:d,swan:m}){const{gender:f,shopDomain:p,heightInCm:h,deviceFocalLength:g,userName:x,email:y,scanType:S}=a||{},v=[s.CLOTHING_CUSTOM_SCAN,s.CLOTHING_BANNER_SCAN,s.CLOTHING_CUSTOM_FIT_SCAN].includes(S??""),[b,C]=t.useState(!0),w=t.useCallback(async()=>{try{v&&(await(m?.auth.addUser({scanId:n,email:y,name:x,gender:f,height:h})),d?.()),s.posthog.capture(p??"",{scanID:n,email:y,height:h,focalLength:g,clothesFit:"0",gender:f})}catch(e){console.log(e)}},[v]),{translate:j}=t.useContext(s.LanguageContext)||{};t.useEffect(()=>{(c||i)&&w()},[c,i]);const k=u||c||i;return e.jsx(o.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(N,{loader:r?.loader,setShowDrawer:C}),e.jsx(o.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)}),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"})})}),k&&e.jsx(s.SpecificButton,{className:"!w-[180px] mx-auto",buttonText:j?.(s.LanguageKeys.next),buttonFunc:()=>{l?.()}})]})})})]})})}const T=()=>{const{userDetails:n,onRetry:a,isError:r,isSuccess:c,gender:i,scanUniqueKey:l,scanFailsError:u,setScanUniqueKey:d,setIsVideoUploaded:m,isMeasurementAvailable:f,isVideoUploadedCorrect:p,loading:h,showDeniedModal:g,uploadLoading:x,setScanFailsError:y,setScanStartTime:S,resetScan:v,onCustomScanSuccess:b,swan:C,onComplete:k}=t.useContext(s.ParamsContext),T=s.useConfig();return r?e.jsxs(e.Fragment,{children:[e.jsx(N,{}),e.jsx(o.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(E,{scanFailsError:!0,onNext:a,gender:i})})]}):c?e.jsx(D,{isSuccess:!0,onComplete:k}):h?e.jsx("div",{className:"flex top-0 !mt-0 left-0 z-[999] absolute justify-center items-center w-full h-full",style:{background:T?.style?.base?.backgroundColor},children:e.jsx(s.LoadingScreen,{url:T?.loader,loaderType:"black"})}):g.disabled?e.jsx(j,{}):x||u||f||p?(x||f||p)&&!u?e.jsx(D,{scanId:l,isMeasurementAvailable:f,userDetails:n,isVideoUploadedCorrect:p,onCustomScanSuccess:b,swan:C,onComplete:k}):e.jsxs(e.Fragment,{children:[e.jsx(N,{}),e.jsx(o.Drawer,{anchor:"bottom",open:!0,className:"camera-drawer",onClose:(e,t)=>{},children:e.jsx(E,{scanFailsError:u,onNext:()=>{a?.(),v()},setScanUniqueKey:d,gender:i,setIsVideoUploaded:m})})]}):e.jsx(w,{scanID:l,userDetails:n,setIsVideoUploaded:m,setScanFailsError:y,setScanStartTime:S,setScanUniqueKey:d})};exports.BodyScan=n=>{const{config:a,onRetry:r,onScanStart:o,onUploadStart:c,onUploadEnd:i,onMeasurementSocketStart:l,onMeasurementSocketClose:u,onIntermediateScanSuccess:d,onScanError:f,onScanSuccess:p,onCustomScanSuccess:h,onComplete:g,isError:x,isSuccess:y}=n,S={email:"",shopDomain:"",gender:"male",heightInCm:0,scanType:"",deviceFocalLength:0,deviceModelName:"",...n.userDetails??{}},v=n.token??"",{gender:b,scanType:C,shopDomain:w,heightInCm:j,email:N,deviceFocalLength:k,deviceModelName:E,callbackUrl:D}=S,F=t.useMemo(()=>s.getSwanService(v),[v]),[I,L]=t.useState(!1),[M,P]=t.useState(!1),[_,$]=t.useState(!1),[A,U]=t.useState({disabled:!1,message:""}),[R,z]=t.useState(""),[K,O]=t.useState(!1),[B,q]=t.useState(!0),[V,W]=t.useState(!1),[H,G]=t.useState(""),[J,Q]=t.useState(s.getCurrentTimeInSeconds()),{gyroData:X}=function(e){const[s,n]=t.useState([]),[a,r]=t.useState(!1),o=t.useCallback(e=>{try{const{alpha:t,beta:s,gamma:a}=e;n(e=>[...e,{alpha:t?.toString()||void 0,beta:s?.toString()||void 0,gamma:a?.toString()||void 0,timestamp:(new Date).toISOString()}])}catch(e){console.log(e)}},[]),c=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&&a?window.addEventListener("deviceorientation",o):n([]),()=>{window.removeEventListener("deviceorientation",o)}),[e,a,o]),t.useEffect(()=>{e&&c()},[e,c]),{gyroData:s}}(V);s.usePosthogPageview();const Y=t.useCallback(()=>{G(s.generateUuid()),z(""),L(!1),O(!1)},[]),Z=()=>{Q(null),G("")},ee=t.useCallback(async e=>{if(e&&"success"===e?.scanStatus&&"intermediate"===e?.resultType&&200===e?.code)return s.handleScanTimeCapture({eventName:`${w}/measurement_success/intermediate`,scanID:H,status:"success",email:N}),P(!0),void d?.(e);p?.(e),P(!0),Z();const t=H;$(!0),s.handleScanTimeCapture({eventName:`${w}/measurement_success/fit-view`,scanID:t,status:"success",email:N}),J&&s.handleScanTimeCapture({eventName:`${w}/scan_completion_time`,scanID:t,status:"success",completionTime:s.getCurrentTimeInSeconds()-J,email:N})},[C,w,H]),te=e=>{$(!1),z(""),P(!1),F.measurement.handleMeasurementSocket({scanId:H,onPreopen:()=>{s.handleWebSocketCapture({eventName:`${w}/webSocket`,scanID:H,connection:"pre_open",type:"measurement_recommendation",email:N})},onOpen:()=>{l?.(),s.handleWebSocketCapture({eventName:`${w}/webSocket`,scanID:H,connection:"open",type:"measurement_recommendation",email:N})},onClose:()=>{u?.(),s.handleWebSocketCapture({eventName:`${w}/webSocket`,scanID:H,connection:"close",type:"measurement_recommendation",email:N})},onError:e=>{var t;t=e,f?.({...t,message:s.handleErrorMessage(t)}),Z(),$(!1),z(t),P(!1),s.handleScanTimeCapture({eventName:`${w}/measurement_failed/fit-view`,scanID:H,status:"failed",email:N,message:s.handleErrorMessage(t)}),J&&s.handleScanTimeCapture({eventName:`${w}/scan_completion_time`,scanID:H,status:"failed",completionTime:s.getCurrentTimeInSeconds()-J,email:N}),s.handleWebSocketCapture({eventName:`${w}/webSocket`,scanID:H,connection:"error",type:"measurement_recommendation",email:N})},onSuccess:e=>{s.handleWebSocketCapture({eventName:`${w}/webSocket`,scanID:H,connection:"success",type:"measurement_recommendation",email:N}),ee(e)}})},se=t.useCallback(async(e,t)=>{const n=Number((e.size/1048576).toFixed(2)),a=null!=t?t:await s.getVideoFPS(e),r=s.createObjectMetadataArray({gender:b,focal_length:`${k}`,height:`${j}`,customer_store_url:w,clothes_fit:"0",scan_type:C,callback_url:D});s.handleScanTimeCapture({eventName:`${w}/body_scan_meta_data`,scanID:H,email:N,data:JSON.stringify([...r,{fileSizeInMB:n,video_fps:a||0}])}),c?.();try{await F.fileUpload.uploadFileFrontend({file:e,arrayMetaData:r,scanId:H,email:N}),await F.fileUpload.setDeviceInfo({model:E,detection:"manual",gyro:X,scanId:H}),console.log("video successfully uploaded"),O(!1),s.handleScanTimeCapture({eventName:`${w}/scan_success`,scanID:H,status:"success",email:N,data:JSON.stringify(r)}),s.handleScanTimeCapture({eventName:"scan finished",scanID:H,status:"success",email:N}),Q(s.getCurrentTimeInSeconds()),setTimeout(()=>{O(!0)},3e3)}catch(e){s.handleScanTimeCapture({eventName:"scan finished",scanID:H,status:"failed",email:N,message:s.handleErrorMessage(e)}),s.handleScanTimeCapture({eventName:`${w}/scan_failed`,scanID:H,status:"failed",email:N,message:s.handleErrorMessage(e),data:JSON.stringify(r)}),z(s.handleErrorMessage(e)),O(!1),f?.({message:s.handleErrorMessage(e)}),Z()}finally{W(!1),i?.()}},[H,X,c,i]),ne=t.useCallback(async()=>{if(+j<152.4||+j>213.36)return void f?.({message:"Height must be between 152.4cm (5ft) and 213.36cm (7ft)"});const e=await s.checkCameraPermission();e.disabled?(s.handleScanTimeCapture({eventName:`${w}/camera_activation`,scanID:H,status:"failed",email:N}),q(!1)):(q(!1),s.handleScanTimeCapture({eventName:`${w}/camera_activation`,scanID:H,status:"success",email:N})),U(e),z(""),O(!1)},[N,H,G,w]);return t.useEffect(()=>{x||y||w&&ne()},[w,j,x,y]),t.useEffect(()=>{x||y||K&&w&&H&&te()},[K,w,H,x,y]),e.jsx(s.LanguageContextProvider,{children:e.jsx(s.ConfigProvider,{config:a,children:e.jsx(m,{children:e.jsx(s.ParamsContext.Provider,{value:{userDetails:S,onRetry:r,onScanError:f,isError:x,isSuccess:y,onScanSuccess:p,gender:b,scanUniqueKey:H,scanFailsError:R,setScanUniqueKey:G,setIsVideoUploaded:O,isMeasurementAvailable:_,isVideoUploadedCorrect:M,loading:B,showDeniedModal:A,uploadLoading:I,setStartGyro:W,uploadScanFile:se,setUploadLoading:L,resetScan:Y,setScanFailsError:z,setScanStartTime:Q,onScanStart:o,onCustomScanSuccess:h,onComplete:g,swan:F},children:e.jsx(T,{})})})})})};
2
+ //# sourceMappingURL=BodyScan-B3KPlpJh.js.map