PageSourceSearch

https://my.aheadhealth.com/_next/static/chunks/3994fc11690f8949.js

js aheadhealth.com collected 2026-10-04 14:44:03 UTC 32,499 bytes, 6 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5d31d6c7-c202-516c-959e-e926b7c7deed")}catch(e){}}();
3(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,445772,e=>{"use strict";e.s(["captureRejection",()=>n]);var t=e.i(662537);let n=e=>n=>{(0,t.captureException)(Error("".concat(e," failed"),{cause:n}))}},546369,737851,e=>{"use strict";e.s(["AUTOMATED_SESSION_FLAG",()=>t],546369);let t="__aheadAutomation";e.s(["shouldClearStaleTestId",()=>r,"shouldSeedTestIdFromTourId",()=>i],737851);var n=e.i(838423),a=e.i(608718);let r=e=>{let{pathname:t,search:n,isAutomatedSession:r,testId:i}=e;return!!i&&t.split("/").includes("demo")&&!new URLSearchParams(n).has(a.TEST_ID_STORAGE_KEY)&&!r},i=e=>{let{tourId:t,isAutomatedSession:a}=e;return a&&!!t&&(0,n.isTestDocId)(t)}},6974,585592,776751,641282,e=>{"use strict";e.s(["signupModeParamName",()=>t],6974);let t="sign_up";e.s(["ConsentModal",()=>y],585592);var n=e.i(843476),a=e.i(909139),r=e.i(100919),i=e.i(27570),s=e.i(689940),o=e.i(926071);let l=(0,e.i(737505).default)("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);var c=e.i(271645),d=e.i(653145),u=e.i(551973),h=e.i(208976),m=e.i(127272),p=e.i(785983),g=e.i(41276);let f=e=>{let{text:t,links:a}=e,r=t.split(/({[^}]+})/g);return(0,n.jsx)(n.Fragment,{children:r.map((e,t)=>{if(e.startsWith("{")&&e.endsWith("}")){let r=e.slice(1,-1);return a[r]?(0,n.jsx)(c.default.Fragment,{children:a[r]},t):e}return e})})},x=e=>{let{control:t,errors:a={}}=e,r=(0,d.useWatch)({control:t,name:"tosAndPpConsent"}),i=(0,d.useWatch)({control:t,name:"medicalProcessing"}),[o,l]=(0,c.useState)(!1),x=(0,g.useMarketingLinks)(),y=(0,c.useRef)(()=>{}),{t:w}=(0,s.useT)(),T=(e,a,r,i,s,o)=>(0,n.jsx)(d.Controller,{name:e,control:t,rules:{required:a},render:t=>{let{field:a}=t,l=e=>{let t=void 0!==e?e:!a.value;a.onChange(t),!t&&o&&y.current(!1)};return(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:(0,p.cn)("flex items-start space-x-3 transition-opacity",s&&"opacity-50"),children:[(0,n.jsxs)("div",{className:"mt-0.5 flex-shrink-0",children:[(0,n.jsx)("input",{type:"checkbox",checked:!!a.value,onChange:e=>!s&&l(e.target.checked),className:"sr-only","aria-invalid":!!i,"aria-disabled":s}),(0,n.jsx)("div",{onClick:()=>!s&&l(),className:(0,p.cn)("flex h-5 w-5 items-center justify-center rounded border-2 transition-all duration-200",s?"cursor-not-allowed border-gray-300 bg-gray-100":"cursor-pointer",a.value?"border-transparent":"border-gray-400 hover:border-gray-500",i&&"border-red-500"),style:{background:a.value&&!s?"linear-gradient(135deg, #4C2652 0%, #5C4279 100%)":"transparent"},role:"checkbox","aria-checked":!!a.value,"aria-labelledby":"".concat(e,"-label"),tabIndex:s?-1:0,onKeyDown:e=>{s||" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),l())},children:a.value&&(0,n.jsx)(u.Check,{className:"h-4 w-4 text-white"})})]}),(0,n.jsx)("div",{className:"flex-1",id:"".concat(e,"-label"),children:r(()=>!s&&l())})]}),i&&(0,n.jsx)("span",{id:"".concat(e,"-error"),className:"ml-8 block text-sm text-red-600",children:w(v.privacyconsentfield_RequiredError)})]})}});return(0,n.jsx)("div",{className:"font-sans text-gray-800",children:(0,n.jsxs)("div",{className:"space-y-4",children:[T("tosAndPpConsent",!0,e=>(0,n.jsx)("label",{onClick:e,className:"cursor-pointer text-sm leading-relaxed text-gray-700",children:(0,n.jsx)(f,{text:w(v.privacyconsentfield_TosAndPp_Text),links:{termsLink:(0,n.jsx)("a",{href:x.termsAndConditions,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[rgb(92,66,121)] underline",onClick:e=>e.stopPropagation(),children:w(v.privacyconsentfield_TosAndPp_TermsLinkText)}),privacyLink:(0,n.jsx)("a",{href:x.privacyPolicy,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[rgb(92,66,121)] underline",onClick:e=>e.stopPropagation(),children:w(v.privacyconsentfield_TosAndPp_PrivacyLinkText)})}})}
3),a.tosAndPpConsent,!1,!0),T("medicalProcessing",!0,e=>(0,n.jsx)("label",{onClick:e,className:"cursor-pointer text-sm leading-relaxed text-gray-700",children:(0,n.jsx)(f,{text:w(v.privacyconsentfield_MedicalData_Text),links:{consentLink:(0,n.jsx)("a",{href:x.medicalDataSharing,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[rgb(92,66,121)] underline",onClick:e=>e.stopPropagation(),children:w(v.privacyconsentfield_MedicalData_ConsentLinkText)})}})}),a.medicalProcessing,!1,!0),(0,n.jsx)(d.Controller,{name:"anonymousDataUsage",control:t,render:e=>{let{field:t}=e;y.current=t.onChange;let a=!r||!i;return(0,n.jsx)("div",{className:(0,p.cn)("space-y-2 transition-opacity",a&&"opacity-50"),children:(0,n.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,n.jsxs)("div",{className:"mt-0.5 flex-shrink-0",children:[(0,n.jsx)("input",{type:"checkbox",checked:!!t.value,onChange:e=>!a&&t.onChange(e.target.checked),className:"sr-only","aria-disabled":a}),(0,n.jsx)("div",{onClick:()=>!a&&t.onChange(!t.value),className:(0,p.cn)("flex h-5 w-5 items-center justify-center rounded border-2 transition-all duration-200",a?"cursor-not-allowed border-gray-300 bg-gray-100":"cursor-pointer",t.value?"border-transparent":"border-gray-400 hover:border-gray-500"),style:{background:t.value&&!a?"linear-gradient(135deg, #4C2652 0%, #5C4279 100%)":"transparent"},role:"checkbox","aria-checked":!!t.value,tabIndex:a?-1:0,children:t.value&&(0,n.jsx)(u.Check,{className:"h-4 w-4 text-white"})})]}),(0,n.jsxs)("div",{className:"flex flex-1 items-center space-x-2",children:[(0,n.jsx)("label",{onClick:()=>!a&&t.onChange(!t.value),className:(0,p.cn)("text-sm leading-relaxed text-gray-700",a?"cursor-not-allowed":"cursor-pointer"),children:(0,n.jsx)("span",{className:"mt-[1px]",children:w(v.privacyconsentfield_Optional_Text)})}),w(v.privacyconsentfield_Optional_Tooltip)&&(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(h.Info,{className:(0,p.cn)("mt-0.5 h-4 w-4 flex-shrink-0 cursor-pointer text-gray-400 hover:text-gray-600",a&&"opacity-50"),onClick:e=>{e.stopPropagation(),a||l(!o)}}),o&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed inset-0 z-[9998]",onClick:e=>{e.stopPropagation(),l(!1)}}),(0,n.jsxs)("div",{className:"fixed top-1/2 left-1/2 z-[9999] w-[90vw] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-lg bg-gray-900 p-4 text-white shadow-2xl",children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),l(!1)},className:"absolute top-2 right-2 text-white/70 hover:text-white",children:(0,n.jsx)(m.X,{className:"h-4 w-4"})}),(0,n.jsx)("p",{className:"pr-6 text-sm",children:w(v.privacyconsentfield_Optional_Tooltip)})]})]})]})]})]})})}})]})})},v={privacyconsentfield_TosAndPp_Text:"I agree to Ahead Health's {termsLink} and confirm that I have read the {privacyLink}.",privacyconsentfield_TosAndPp_TermsLinkText:"Terms & Conditions",privacyconsentfield_TosAndPp_PrivacyLinkText:"Privacy Policy",privacyconsentfield_MedicalData_Text:"I agree to the {consentLink}.",privacyconsentfield_MedicalData_ConsentLinkText:"Consent for the Use and Secure Sharing of my Medical Data",privacyconsentfield_Optional_Text:"I consent to the use of my anonymised data for product improvement (optional)",privacyconsentfield_Optional_Tooltip:"This helps Ahead Health enhance its services and provide better, more personalised care. Giving consent is voluntary, does not affect your access to services, and you may withdraw it at any time.",privacyconsentfield_RequiredError:"This consent is required to proceed."};function y(e){let{onComplete:t}=e,{t:u}=(0,s.useT)(),{user:h}=(0,r.useUser)(),[m,p]=(0,c.useState)(!1),[g,f]=(0,c.useState)(null),{control:v,handleSubmit:y,formState:{errors:w}}=(0,d.useForm)({defaultValues:{tosAndPpConsent:!1,medicalProcessing:!1,anonymousDataUsage:!1}}),T=async e=>{if((null==h?void 0:h.uid)&&(null==h?void 0:h.email)){p(!0),f(null);try{let n=new Date().toISOString().split("T")[0],a={tosAndPp:{acceptedDate:e.tosAndPpConsent?n:null,version:1,optional:!1},medicalProcessing:{acceptedDate:e.medicalProcessing?n:null,version:1,optional:!1},anonymousDataUsage:{acceptedDate:e.anonymousDataUsage?n:null,version:1,optional:!0}};await (0,i.setDoc)("userProfile",h.uid,{consent:a});let r="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname,s={email:h.email,tosAndPpConsentDate:e.tosAndPpConsent?n:null,medicalProcessingConsentDate:e.medicalProcessing?n:null,anonymousDataUsageConsentDate:e.anonymousDataUsage?n:null};await fetch(r?"http://127.0.0.1:54321/functions/v1/relay-consent":"https://rnaixxwwvyedkujwijlp.supabase.co/functions/v1/relay-consent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r?"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJuYWl4eHd3dnllZGt1andpamxwIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mzg2MTQ3NjUsImV4cCI6MjA1NDE5MDc2NX0.-Zjo0-YsilhjvooPC40aHCYvcIVB-6X6KgaUwEmrmhA")},body:JSON.stringify(s)}),t()}catch(e){console.error("Error saving consent:",e),f(u("Failed to save consent. Please try again."))}finally{p(!1)}}};return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:(0,n.jsx)("div",{className:"w-full max-w-md overflow-hidden rounded-lg border border-slate-200 bg-white shadow-xl",children:(0,n.jsxs)("div",{className:"p-8",children:[(0,n.jsxs)("div",{className:"mb-6 flex flex-col items-center gap-3 text-center",children:[(0,n.jsx)(l,{className:"text-aubergine-600 h-10 w-10"}),(0,n.jsx)("h2",{className:"text-2xl font-bold text-slate-900",children:u("Consent required")}),(0,n.jsx)("p",{className:"text-sm text-slate-600",children:u("Please review and accept the following consents to continue.")})]}),g&&(0,n.jsx)("div",{className:"mb-4 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-800",children:g}),(0,n.jsxs)("form",{onSubmit:y(T),className:"space-y-4",children:[(0,n.jsx)(x,{control:v,errors:w}),(0,n.jsx)(a.Button,{type:"submit",disabled:m,className:"bg-aubergine-600 hover:bg-aubergine-700 w-full",children:m?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),u("Saving...")]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l,{className:"mr-2 h-4 w-4"}),u("Continue")]})})]})]})})})}e.s(["getPostHogPersonInfo",()=>
3A],776751);var w=e.i(865672),T=e.i(838423);let A=e=>{var t,n,a;return{ageBucket:(0,w.getAgeBucket)(null==(t=e.patientData)?void 0:t.birthday),langCode:null!=(a=e.interfaceLanguage)?a:null,isTestUser:(0,T.isTestUserId)(e.uid),isInternalUser:!!(null==(n=e.internalRoles)?void 0:n.internal),isIdentified:!0}};async function S(e){let t=new TextEncoder().encode(e);return"hash-"+Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>e.toString(16).padStart(2,"0")).join("")}e.s(["hashUid",()=>S],641282)},460508,e=>{"use strict";e.s(["signInAsTestUserWithRetry",()=>s]);var t=e.i(738784),n=e.i(239858);e.i(151718);var a=e.i(618357);let r=new Set(["auth/custom-token-mismatch","auth/invalid-custom-token","auth/operation-not-allowed","auth/user-disabled"]),i=e=>"object"==typeof e&&null!==e&&"code"in e&&"string"==typeof e.code&&r.has(e.code),s=async(e,r)=>{for(let s=1;s<=2;s++){let o=2===s;try{let e=await r();if(!e)throw Error("no custom token returned");return await (0,a.signInWithCustomToken)((0,a.getAuth)((0,t.init)().app),e),!0}catch(a){let t=i(a);if(console.error("Test user sign-in attempt ".concat(s,"/").concat(2," failed for ").concat(e," (project ").concat((0,n.getProjectIdSync)(),")").concat(t?", not retryable":"",":"),a),o||t)return!1;await new Promise(e=>setTimeout(e,750))}}return!1}},731405,e=>{"use strict";e.s(["useTestMode",()=>a]);var t=e.i(271645),n=e.i(608718);function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{persistToLocalStorage:a=!0,onTestIdSet:r,onTestIdClear:i}=e,[s,o]=(0,t.useState)(()=>(0,n.getTestId)());return(0,t.useEffect)(()=>{if("undefined"==typeof window)return;let e=new URLSearchParams(window.location.search).get(n.TEST_ID_STORAGE_KEY);if(e){a&&(0,n.setTestId)(e),o(e),null==r||r(e);return}let t=(0,n.getTestId)();t&&(o(t),null==r||r(t))},[]),{isTestMode:null!==s,testId:s,clearTestId:()=>{(0,n.clearTestId)(),o(null),null==i||i()}}}},53244,e=>{"use strict";e.s(["useTestMode",()=>c],53244);var t=e.i(271645),n=e.i(731405),a=e.i(608718),r=e.i(320847),i=e.i(546369),s=e.i(737851),o=e.i(100919),l=e.i(868752);function c(){let{isTestUser:e,loading:c,user:d}=(0,o.useUser)(),u=function(){let[e,n]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{var e;window.__setIsAutomated=()=>{n(!0)},n("true"===(null==(e=(0,l.safeLocalStorage)())?void 0:e.getItem(i.AUTOMATED_SESSION_FLAG)))},[]),e}(),{isTestMode:h,testId:m,clearTestId:p}=(0,n.useTestMode)({persistToLocalStorage:u,onTestIdSet:e=>(0,r.setTestId)(e)});return(0,t.useEffect)(()=>{window.__setTestIdInLocalStorage=()=>{if(m){var e;null==(e=(0,l.safeLocalStorage)())||e.setItem(a.TEST_ID_STORAGE_KEY,m)}}},[m]),(0,t.useEffect)(()=>{!e&&!c&&(null==d?void 0:d.uid)&&m&&(p(),(0,r.setTestId)(void 0))},[e,c,null==d?void 0:d.uid,m,p]),(0,t.useEffect)(()=>{var e;let t=(null==(e=(0,l.safeLocalStorage)())?void 0:e.getItem(i.AUTOMATED_SESSION_FLAG))==="true";(0,s.shouldClearStaleTestId)({pathname:window.location.pathname,search:window.location.search,isAutomatedSession:t,testId:m})&&(p(),(0,r.setTestId)(void 0))},[m,p]),{isTestMode:h,testId:null!=m?m:void 0}}},577947,e=>{"use strict";e.s(["AlertDialog",()=>D,"AlertDialogAction",()=>L,"AlertDialogCancel",()=>M,"AlertDialogContent",()=>k,"AlertDialogDescription",()=>U,"AlertDialogFooter",()=>R,"AlertDialogHeader",()=>E,"AlertDialogTitle",()=>O],577947);var t=e.i(843476),n=e.i(271645),a=e.i(30030),r=e.i(820783),i=e.i(326999),s=e.i(981140),o=e.i(991918),l="AlertDialog",[c,d]=(0,a.createContextScope)(l,[i.createDialogScope]),u=(0,i.createDialogScope)(),h=e=>{let{__scopeAlertDialog:n,...a}=e,r=u(n);return(0,t.jsx)(i.Root,{...r,...a,modal:!0})};h.displayName=l,n.forwardRef((e,n)=>{let{__scopeAlertDialog:a,...r}=e,s=u(a);return(0,t.jsx)(i.Trigger,{...s,...r,ref:n})}).displayName="AlertDialogTrigger";var m=e=>{let{__scopeAlertDialog:n,...a}=e,r=u(n);return(0,t.jsx)(i.Portal,{...r,...a})};m.displayName="AlertDialogPortal";var p=n.forwardRef((e,n)=>{let{__scopeAlertDialog:a,...r}=e,s=u(a);return(0,t.jsx)(i.Overlay,{...s,...r,ref:n})});p.displayName="AlertDialogOverlay";var g="AlertDialogContent",[f,x]=c(g),v=(0,o.createSlottable)("AlertDialogContent"),y=n.forwardRef((e,a)=>{let{__scopeAlertDialog:o,children:l,...c}=e,d=u(o),h=n.useRef(null),m=(0,r.useComposedRefs)(a,h),p=n.useRef(null);return(0,t.jsx)(i.WarningProvider,{contentName:g,titleName:w,docsSlug:"alert-dialog",children:(0,t.jsx)(f,{scope:o,cancelRef:p,children:(0,t.jsxs)(i.Content,{role:"alertdialog",...d,...c,ref:m,onOpenAutoFocus:(0,s.composeEventHandlers)(c.onOpenAutoFocus,e=>{var t;
3e.preventDefault(),null==(t=p.current)||t.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,t.jsx)(v,{children:l}),(0,t.jsx)(b,{contentRef:h})]})})})});y.displayName=g;var w="AlertDialogTitle",T=n.forwardRef((e,n)=>{let{__scopeAlertDialog:a,...r}=e,s=u(a);return(0,t.jsx)(i.Title,{...s,...r,ref:n})});T.displayName=w;var A="AlertDialogDescription",S=n.forwardRef((e,n)=>{let{__scopeAlertDialog:a,...r}=e,s=u(a);return(0,t.jsx)(i.Description,{...s,...r,ref:n})});S.displayName=A;var j=n.forwardRef((e,n)=>{let{__scopeAlertDialog:a,...r}=e,s=u(a);return(0,t.jsx)(i.Close,{...s,...r,ref:n})});j.displayName="AlertDialogAction";var N="AlertDialogCancel",C=n.forwardRef((e,n)=>{let{__scopeAlertDialog:a,...s}=e,{cancelRef:o}=x(N,a),l=u(a),c=(0,r.useComposedRefs)(n,o);return(0,t.jsx)(i.Close,{...l,...s,ref:c})});C.displayName=N;var b=e=>{let{contentRef:t}=e,a="`".concat(g,"` requires a description for the component to be accessible for screen reader users.\n\nYou can add a description to the `").concat(g,"` by passing a `").concat(A,"` component as a child, which also benefits sighted users by adding visible context to the dialog.\n\nAlternatively, you can use your own component as a description by assigning it an `id` and passing the same value to the `aria-describedby` prop in `").concat(g,"`. If the description is confusing or duplicative for sighted users, you can use the `@radix-ui/react-visually-hidden` primitive as a wrapper around your description component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/alert-dialog");return n.useEffect(()=>{var e;document.getElementById(null==(e=t.current)?void 0:e.getAttribute("aria-describedby"))||console.warn(a)},[a,t]),null},I=e.i(785983),P=e.i(909139);let D=h,_=n.forwardRef((e,n)=>{let{className:a,...r}=e;return(0,t.jsx)(p,{className:(0,I.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",a),...r,ref:n})});_.displayName=p.displayName;let k=n.forwardRef((e,n)=>{let{className:a,...r}=e;return(0,t.jsxs)(m,{children:[(0,t.jsx)(_,{}),(0,t.jsx)(y,{ref:n,className:(0,I.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] fixed top-[50%] left-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",a),...r})]})});k.displayName=y.displayName;let E=e=>{let{className:n,...a}=e;return(0,t.jsx)("div",{className:(0,I.cn)("flex flex-col space-y-2 text-center sm:text-left",n),...a}
3)};E.displayName="AlertDialogHeader";let R=e=>{let{className:n,...a}=e;return(0,t.jsx)("div",{className:(0,I.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...a})};R.displayName="AlertDialogFooter";let O=n.forwardRef((e,n)=>{let{className:a,...r}=e;return(0,t.jsx)(T,{ref:n,className:(0,I.cn)("text-lg font-semibold",a),...r})});O.displayName=T.displayName;let U=n.forwardRef((e,n)=>{let{className:a,...r}=e;return(0,t.jsx)(S,{ref:n,className:(0,I.cn)("text-muted-foreground text-sm",a),...r})});U.displayName=S.displayName;let L=n.forwardRef((e,n)=>{let{className:a,...r}=e;return(0,t.jsx)(j,{ref:n,className:(0,I.cn)((0,P.buttonVariants)(),a),...r})});L.displayName=j.displayName;let M=n.forwardRef((e,n)=>{let{className:a,...r}=e;return(0,t.jsx)(C,{ref:n,className:(0,I.cn)((0,P.buttonVariants)({variant:"ghost"}),"mt-2 sm:mt-0",a),...r})});M.displayName=C.displayName},862155,e=>{"use strict";e.s(["HandleAuthenticationState",()=>H,"authTokenParamName",()=>k,"getLngFromPathname",()=>U,"getLngFromPathnameString",()=>R,"getUrlWithLanguage",()=>L,"resolveCurrentRouteLng",()=>O,"resolveRouteLngParam",()=>E],862155);var t=e.i(843476),n=e.i(6974),a=e.i(557136),r=e.i(585592),i=e.i(662537),s=e.i(618566),o=e.i(604570),l=e.i(271645),c=e.i(360888),d=e.i(201848),u=e.i(601022),h=e.i(100919),m=e.i(776751),p=e.i(838423),g=e.i(641282),f=e.i(445772),x=e.i(961129);e.i(151718);var v=e.i(618357),y=e.i(738784),w=e.i(460508),T=e.i(53244),A=e.i(577947),S=e.i(487230),j=e.i(868752),N=e.i(903057),C=e.i(546369),b=e.i(514779);let I=e.i(417047).aheadPackage.environments.production.url,P=new URL(I).host;e.i(144702);var D=e.i(335936),_=e.i(145468);let k="authToken",E=e=>"string"==typeof e?e:Array.isArray(e)?e[0]:void 0,R=e=>{let t=e.split("/").filter(Boolean)[0];if(t&&N.languages.includes(t))return t},O=(e,t,n)=>{var a,r,i;return null!=(i=null!=(r=null!=(a=R(e))?a:E(t))?r:n)?i:void 0},U=()=>R(window.location.pathname),L=(e,t)=>{var n,a;let r=null!=(a=null!=(n=R(window.location.pathname))?n:E(t))?a:U();if(!r)return null;let i=Array.isArray(r)?r[0]:r;return window.location.href.replace("/".concat(i,"/"),"/".concat(e,"/"))},M=e=>{let{open:n,onOpenChange:a,currentEmail:r,onCancel:i,onConfirm:s,variant:o}=e,l="testUser"===o;return(0,t.jsx)(A.AlertDialog,{open:n,onOpenChange:a,children:(0,t.jsxs)(A.AlertDialogContent,{children:[(0,t.jsxs)(A.AlertDialogHeader,{children:[(0,t.jsx)(A.AlertDialogTitle,{children:l?"Switch to Test User?":"Switch User via Auth Token?"}),(0,t.jsx)(A.AlertDialogDescription,{children:l?"You are currently logged in as ".concat(r,". Do you want to switch to the test user? We recommend using an incognito window for test user sessions."):"You are currently logged in as ".concat(r,". Do you want to switch to a different user via auth token? We recommend using an incognito window for this.")})]}),(0,t.jsxs)(A.AlertDialogFooter,{children:[(0,t.jsx)(A.AlertDialogCancel,{onClick:i,children:"Cancel"}),(0,t.jsx)(A.AlertDialogAction,{onClick:s,children:"Switch User"})]})]})})},F=["/profile","/questionnaire"],H=e=>{var N,U,H,W,G,z,J,Y;let{children:B}=e,K=(0,s.usePathname)(),X=(0,s.useRouter)(),V=(0,s.useParams)(),Z=(0,s.useSearchParams)(),q=Z.get(u.prefillSignInEmailParamName),Q=Z.get(u.redirectParamName)||"/home",$=Z.get("testUserId"),ee=(0,h.useUser)(),et=K.includes("/sign_in"),{isTestMode:en}=(0,T.useTestMode)(),[ea,er]=(0,l.useState)(!1),[ei,es]=(0,l.useState)(null),[eo,el]=(0,l.useState)(!1),ec=(0,l.useRef)(!1),ed=(0,l.useRef)(!1),eu=Z.get(k),eh=(0,_.usePrereleaseRenderMode)(),em=!(0,S.isServerside)()&&window.self!==window.top,ep=(0,l.useRef)(null),[eg,ef]=(0,l.useState)(!1),[ex,ev]=(0,l.useState)(null),[ey,ew]=(0,l.useState)(!1),eT=(0,l.useRef)(!1);(null==(N=ee.user)?void 0:N.uid)&&(ed.current=!0);
3let{setUserLoading:eA,isTestUser:eS}=ee,ej=(0,l.useCallback)(async()=>{if(ec.current=!0,eA(!0),!await (0,w.signInAsTestUserWithRetry)($,async()=>{let e=await fetch("/api/get-test-user-auth-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testUserId:$})});if(!e.ok)return null;let{customToken:t}=await e.json();return t})){ec.current=!1,eA(!1),el(!0);return}let e=new URLSearchParams(Z.toString());e.delete("testUserId");let t=e.toString();X.replace("".concat(K).concat(t?"?".concat(t):"")),ec.current=!1},[$,K,X,Z,eA]),eN=(0,l.useCallback)(async()=>{if(!ei)return;if(ec.current=!0,eA(!0),er(!1),!await (0,w.signInAsTestUserWithRetry)(ei,async()=>{let e=await fetch("/api/get-test-user-auth-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({testUserId:ei})});if(!e.ok)return null;let{customToken:t}=await e.json();return t})){es(null),ec.current=!1,eA(!1),el(!0);return}let e=new URLSearchParams(Z.toString());e.delete("testUserId");let t=e.toString();X.replace("".concat(K).concat(t?"?".concat(t):"")),es(null),ec.current=!1},[ei,K,X,Z,eA]),eC=(0,l.useCallback)(()=>{let e=new URLSearchParams(Z.toString());e.delete("testUserId");let t=e.toString();X.replace("".concat(K).concat(t?"?".concat(t):"")),er(!1),es(null)},[K,X,Z]),eb=(0,l.useCallback)(async()=>{if(eu){ep.current=eu,eT.current=!0,eA(!0);try{let e=(0,v.getAuth)((0,y.init)().app);eh&&em&&await (0,v.setPersistence)(e,v.inMemoryPersistence),await (0,v.signInWithCustomToken)(e,eu);let t=new URLSearchParams(Z.toString());t.delete(k);let n=t.toString();X.replace("".concat(K).concat(n?"?".concat(n):""))}catch(e){console.error("Failed to login with auth token:",e),ew(!0),eA(!1)}eT.current=!1}},[eu,em,eh,K,X,Z,eA]),eI=(0,l.useCallback)(async()=>{if(ex){eT.current=!0,eA(!0),ef(!1);try{await (0,v.signInWithCustomToken)((0,v.getAuth)((0,y.init)().app),ex);let e=new URLSearchParams(Z.toString());e.delete(k);let t=e.toString();X.replace("".concat(K).concat(t?"?".concat(t):""))}catch(e){console.error("Failed to login with auth token:",e),ew(!0),eA(!1)}ev(null),eT.current=!1}},[ex,K,X,Z,eA]),eP=(0,l.useCallback)(()=>{let e=new URLSearchParams(Z.toString());e.delete(k);let t=e.toString();X.replace("".concat(K).concat(t?"?".concat(t):"")),ef(!1),ev(null)},[K,X,Z]);(0,l.useEffect)(()=>{var e,t;if((null==(e=ee.user)?void 0:e.uid)&&ee.userProfile&&!ee.loadingClaims){if(ee.user.getIdToken().then(e=>{fetch("/api/customer-events/sign-in",{method:"POST",headers:{"Content-Type":"application/json",[b.USER_AUTH_HEADER]:"Bearer ".concat(e)}}).catch(()=>{})}).catch(()=>{}),(0,p.isTestUserId)(ee.user.uid)&&o.default.stopSessionRecording(),K.includes("/demo/"))return;let e=ee.userProfile;(0,g.hashUid)(ee.user.uid).then(t=>{let n=(0,m.getPostHogPersonInfo)(e);o.default.identify(t,n),(0,i.setUser)({id:t,...n})}).catch((0,f.captureRejection)("posthog identify"))}else if(!(null==(t=ee.user)?void 0:t.uid)){let e=new URLSearchParams(window.location.search).has("testId");!function(e,t){!t&&(0,j.safeLocalStorage)()&&(e.reset(),(0,D.applyInitialPosthogConsent)(e))}(o.default,e)}},[null==(U=ee.user)?void 0:U.uid,ee.userProfile,ee.loadingClaims]);let eD=null==ee||null==(H=ee.userProfile)?void 0:H.interfaceLanguage,e_=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=O(K,V.lng,eD)||"en",a=(0,c.addParamsToLink)((0,d.addRedirectToPath)("/".concat(t,"/sign_in"),{dropParams:ed.current?["reportKey"]:[]}),{[u.prefillSignInEmailParamName]:q,[n.signupModeParamName]:e?"true":null});X.push(a)},ek=!!$,eE=(null==(W=ee.user)?void 0:W.uid)===$,eR=ec.current,eO=!!ee.user,eU=eO&&!eS,eL=ek&&eU&&!eE&&!ea&&!eh,eM=!!eu,eF=eT.current,eH=eM&&eO&&!eg&&!eh,eW=eg&&eM&&eO,eG=(e=>F.some(t=>e.includes(t))||e.includes("/home")||e.includes("/upload"))(K),ez=(()=>{var e;if(!(null==(e=ee.userProfile)?void 0:e.consent))return!1;let t=ee.userProfile.consent,n=t.tosAndPp&&!t.tosAndPp.acceptedDate&&1===t.tosAndPp.version,a=t.medicalProcessing&&!t.medicalProcessing.acceptedDate&&1===t.medicalProcessing.version;return n||a})(),eJ=!(0,S.isServerside)()&&(e=>{let{host:t,hasUser:n,claimsLoading:a,hasInternalRole:r,isTestSession:i,isPrereleaseCheck:s}=e;return n&&!a&&!r&&!i&&!s&&!/^(localhost|127\.0\.0\.1|\[::1\])(:|$)/.test(t)&&t!==P})({host:window.location.host,hasUser:eO,claimsLoading:ee.loadingClaims,hasInternalRole:ee.isInternal||ee.isReadAdmin||ee.isPractitioner||ee.isRestrictedPractitioner,isTestSession:en||eS||(null==(G=(0,j.safeLocalStorage)())?void 0:G.getItem(C.AUTOMATED_SESSION_FLAG))==="true",isPrereleaseCheck:eh}),eY=null!=(Y=R(K))?Y:E(V.lng),eB=eD&&eY&&eY!==eD&&!eh,eK=(0,t.jsx)(a.WholePageLoading,{}),eX=(0,t.jsxs)(t.Fragment,{children:[B,(0,t.jsx)(x.default,{children:(0,t.jsx)(r.ConsentModal,{onComplete:()=>{}})})]}),eV=(0,t.jsxs)(t.Fragment,{children:[B,(0,t.jsx)(M,{open:ea,onOpenChange:er,currentEmail:null==(z=ee.user)?void 0:z.email,onCancel:eC,onConfirm:eN,variant:"testUser"})]}),eZ=(0,t.jsxs)(t.Fragment,{children:[B,(0,t.jsx)(M,{open:eg,onOpenChange:ef,currentEmail:null==(J=ee.user)?void 0:J.email,onCancel:eP,onConfirm:eI,variant:"authToken"})]}),eq=(0,t.jsx)(t.Fragment,{children:B}),eQ=(0,t.jsx)("div",{children:(0,t.jsx)(A.AlertDialog,{open:!0,onOpenChange:()=>{},children:(0,t.jsx)(A.AlertDialogContent,{children:(0,t.jsxs)(A.AlertDialogHeader,{children:[(0,t.jsx)(A.AlertDialogTitle,{children:"Failed to login as test user"}),(0,t.jsx)(A.AlertDialogDescription,{children:"We were unable to login as the test user. Please try again or use a different user."})]})})})}),e$=(0,t.jsx)("div",{children:(0,t.jsx)(A.AlertDialog,{open:!0,onOpenChange:()=>{},children:(0,t.jsx)(A.AlertDialogContent,{children:(0,t.jsxs)(A.AlertDialogHeader,{children:[(0,t.jsx)(A.AlertDialogTitle,{children:"Failed to login with auth token"}),(0,t.jsx)(A.AlertDialogDescription,{children:"We were unable to login with the provided auth token. The token may be invalid or expired. Please try again with a new token."})]})})})}),e0={INITIALIZING:{isActive:ee.loading,onStateEnter:()=>{},render:eK},TEST_USER_LOGIN_FAILED:{isActive:eo&&ek,onStateEnter:()=>{},render:eQ}
3,TEST_USER_SWITCH_CONFIRMATION_SHOULD_START:{isActive:eL,onStateEnter:()=>{es($),er(!0)},render:eq},TEST_USER_SWITCH_CONFIRMATION:{isActive:ea&&ek&&eU,onStateEnter:()=>{},render:eV},TEST_USER_SIGN_IN_SHOULD_START:{isActive:ek&&!eE&&!eR&&!eo&&(!eO||eS),onStateEnter:async()=>{await ej()},render:eK},AUTH_TOKEN_LOGIN_FAILED:{isActive:ey&&eM,onStateEnter:()=>{},render:e$},AUTH_TOKEN_SWITCH_CONFIRMATION_SHOULD_START:{isActive:eH,onStateEnter:()=>{ev(eu),ef(!0)},render:eq},AUTH_TOKEN_SWITCH_CONFIRMATION:{isActive:eW,onStateEnter:()=>{},render:eZ},AUTH_TOKEN_SIGN_IN_SHOULD_START:{isActive:eM&&eu!==ep.current&&!eF&&!ey&&(!eO||eh&&em),onStateEnter:async()=>{await eb()},render:eK},UNAUTHENTICATED_ON_PROTECTED_ROUTE:{isActive:eG&&!eO,onStateEnter:()=>{e_()},render:eK},CONSENT_REQUIRED:{isActive:eO&&ez&&!eh,onStateEnter:()=>{},render:eX},AUTHENTICATED_ON_SIGNIN_PAGE:{isActive:et&&eO&&!ez,onStateEnter:()=>{X.push(Q)},render:eK},WRONG_DOMAIN:{isActive:eJ,onStateEnter:()=>{window.location.href="".concat(I).concat(K)},render:eK},WRONG_LANGUAGE:{isActive:eO&&eB,onStateEnter:()=>{(()=>{var e;let t=null!=(e=R(K))?e:E(V.lng);if(eD&&t&&t!==eD){let e=L(eD,t);e&&X.replace(e)}})()},render:eK},READY:{isActive:!1,onStateEnter:()=>{},render:eq}};e0.READY.isActive=!Object.entries(e0).filter(e=>{let[t]=e;return"READY"!==t}).some(e=>{let[,t]=e;return t.isActive});let e1=Object.entries(e0).filter(e=>{let[,t]=e;return t.isActive}).map(e=>{let[t]=e;return t});e1.length>1&&!(0,S.isServerside)()&&console.warn("⚠️ Multiple auth states active:",e1);let e5=Object.entries(e0).find(e=>{let[,t]=e;return t.isActive}),e2=null==e5?void 0:e5[0];return(0,l.useEffect)(()=>{if(e2){let e=e0[e2];Promise.resolve(null==e?void 0:e.onStateEnter()).catch((0,f.captureRejection)("auth state ".concat(e2," onStateEnter")))}},[e2]),e5?e5[1].render:eq}},927117,e=>{"use strict";e.s(["MFASetupCardModal",()=>h]);var t=e.i(843476),n=e.i(100919),a=e.i(618566),r=e.i(145468),i=e.i(271645),s=e.i(127272),o=e.i(689940),l=e.i(27570);e.i(436180);var c=e.i(98925),d=e.i(202641),u=e.i(266774);function h(){let{isOpen:e,onClose:h}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{isAuthenticated:m,has2FA:p,user:g,userProfile:f,userProfileIsLoading:x,refresh2faEnrollment:v}=(0,n.useUser)(),{t:y}=(0,o.useT)(),w=(0,a.usePathname)(),T=(0,r.usePrereleaseRenderMode)(),{toast:A}=(0,u.useToast)(),[S,j]=(0,i.useState)(!1),[N,C]=(0,i.useState)(!1),b=async()=>{A({title:y("Additional account protection activated"),description:y("Your account is now protected with additional SMS-verification.")}),v(),j(!0),h&&h()},I=()=>{},P=null==w?void 0:w.includes("/profile/security"),D=null==w?void 0:w.includes("/sign_in"),_=async()=>{C(!0),j(!0),(null==g?void 0:g.uid)&&await (0,l.setDoc)("userProfile",g.uid,{mfaSkipDismissedAt:c.Timestamp.now()}),h&&h(),C(!1)};return void 0!==e?e&&g?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:(0,t.jsxs)("div",{className:"relative flex h-[500px] max-h-[85vh] w-full max-w-sm flex-col overflow-hidden rounded-3xl bg-white",children:[(0,t.jsx)("button",{onClick:_,disabled:N,className:"absolute top-4 right-4 z-10 rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:opacity-50","aria-label":y("Close"),children:(0,t.jsx)(s.X,{className:"h-5 w-5"})}),(0,t.jsx)(d.PhoneVerification,{user:g,phone:(null==f?void 0:f.phoneNumber)||"",onContinue:b,onEnrollComplete:b,onBack:I,onClose:_,isOpen:!1,showInitialOptions:!0})]})}):null:x||!m||p||S||(null==f?void 0:f.mfaSkipDismissedAt)||P||D||T?null:(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:(0,t.jsxs)("div",{className:"relative flex h-[500px] max-h-[85vh] w-full max-w-sm flex-col overflow-hidden rounded-3xl bg-white",children:[(0,t.jsx)("button",{onClick:_,disabled:N,className:"absolute top-4 right-4 z-10 rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:opacity-50","aria-label":y("Close"),children:(0,t.jsx)(s.X,{className:"h-5 w-5"})}),g&&(0,t.jsx)(d.PhoneVerification,{user:g,phone:(null==f?void 0:f.phoneNumber)||"",onContinue:b,onEnrollC
3omplete:b,onBack:I,onClose:_,isOpen:!1,showInitialOptions:!0})]})})}}]);
4
5//# sourceMappingURL=59c1f96b4b0e244e.js.map
6//# debugId=5d31d6c7-c202-516c-959e-e926b7c7deed

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.