1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[41315],{22964:(e,t,n)=>{n.d(t,{k_:()=>S,vd:()=>_,nH:()=>N});var r=n(21851),a=n(78059),s=n(53235);let i=/^(workout-logs\/\d{4}-\d{2}-\d{2}_log\.json|weekly-workouts\/\d{4}-\d{2}-\d{2}_weekly_workout\.json|week-ahead\/\d{4}-\d{2}-\d{2}_week_ahead\.json|progression_ledger\.json|training_blueprint\.json)$/;function o(e){var t;return e.status?["completed","modified","partial","skipped"].includes(String(e.status)):!0===e.completed||!!e.completed_at||!!(null==(t=e.execution)?void 0:t.completed_at)}async function l(e,t){let{data:n,error:r}=await e.rpc("workout_write_snapshot",{p_name:t});if((null==r?void 0:r.code)==="PGRST202")return null;if(r)throw Error("Cannot verify workout write version");if((null==n?void 0:n.protocol)!==1||"string"!=typeof n.version)throw Error("Invalid workout write version");return n}var c=n(52492);let d=[/^workout-logs\/\d{4}-\d{2}-\d{2}_log\.json$/,/^weekly-workouts\/\d{4}-\d{2}-\d{2}_weekly_workout\.json$/,/^week-ahead\/\d{4}-\d{2}-\d{2}_week_ahead\.json$/,/^week-summary\/\d{4}-\d{2}-\d{2}_week_summary.*\.json$/,/^month-summary\/\d{4}-\d{2}_month_summary\.json$/,/^plan-input\/\d{4}-\d{2}-\d{2}_plan_questions\.json$/,/^nutrition\/week_\d{4}-\d{2}-\d{2}_nutrition\.json$/,/^goals\.json$/,/^injuries\.json$/,/^nutrition_profile\.json$/,/^training_blueprint\.json$/,/^progression_ledger\.json$/,/^blueprint\.json$/,/^genetics\/phenotype_overlay\.json$/,/^health_investment_guide\.json$/,/^overview\.json$/,/^pending_reprograms\.json$/,/^microbiome_profile\.json$/,/^systems\/systems_status\.json$/,/^supplements\/supplement_protocol\.json$/,/^biomarkers\/biomarker_reference\.json$/,/^biomarkers\/interpretations\/[A-Za-z0-9][A-Za-z0-9_.-]{0,159}_interpretation\.json$/,/^biomarkers\/interventions\.json$/,/^biomarkers-history\/(?:
1dexa_history|fitness_test_history)\.json$/,/^longitudinal_profile_index\.json$/,/^wearables\/inbody_measurements\.json$/,/^wearables\/smart_scale_measurements\.json$/,/^wearables\/body_comp_goals\.json$/,/^wearables\/body_comp_analysis\.json$/,/^wearables\/hr_zones\.json$/,/^equipment\/gym_equipment\.md$/,/^context\/health_context\.md$/,/^context\/llm_index\.md$/,/^context\/genetic_profile_extended\.md$/,/^context\/timeline_historical\.md$/];async function u(e){return"string"==typeof e?new TextEncoder().encode(e):e instanceof Blob?new Uint8Array(await e.arrayBuffer()):e instanceof ArrayBuffer?new Uint8Array(e):e}async function m(e){return Array.from(new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",e))).map(e=>e.toString(16).padStart(2,"0")).join("")}async function h(){let{createClient:e}=await Promise.resolve().then(n.bind(n,31122));return e("https://tywijdxuygkflsojvvfi.supabase.co",c.env.SUPABASE_SERVICE_ROLE_KEY)}async function f(e,t,n,r,a){var s,c,f,p,g,w,x,b;let v,y=await u(r),k=null!=(s=a.contentType)?s:n.endsWith(".json")?"application/json":n.endsWith(".md")?"text/markdown":n.endsWith(".pdf")?"application/pdf":"application/octet-stream",j=null==(c=a.upsert)||c,_=!n.startsWith("versions/")&&d.some(e=>e.test(n));if(i.test(n))try{if("expectedRemoteHash"in a&&void 0===a.expectedRemoteHash)throw Error("Cannot verify original workout read");let r="".concat(t,"/").concat(n),s=await l(await h(),r),i=n.startsWith("workout-logs/"),c=i&&o(JSON.parse(new TextDecoder().decode(y))),d=null!=(f=a.workoutWriteIntent)?f:i&&!c?"autosave":"replace";if(s){if("autosave"===d||void 0!==a.expectedRemoteHash){if("__absent__"!==s.version){let{data:t,error:n}=await e.storage.from("user-data").createSignedUrl(r,60);if(n||!(null==t?void 0:t.signedUrl))throw Error("Cannot read current workout version");let l=new URL(t.signedUrl);l.searchParams.set("_workout_version",s.version);let c=await fetch(l,{cache:"no-store",signal:AbortSignal.timeout(15e3)});if(!c.ok)throw Error("Cannot read current workout version");let u=new Uint8Array(await c.arrayBuffer());if(void 0!==a.expectedRemoteHash&&await m(u)!==a.expectedRemoteHash)throw Error("workout_write_conflict");if("autosave"===d&&((null==(p=s.write)?void 0:p.terminal)||o(JSON.parse(new TextDecoder().decode(u)))))throw Error("workout_already_finished");if(i&&"autosave"===d){let e=JSON.parse(new TextDecoder().decode(u)),t=JSON.parse(new TextDecoder().decode(y));e.additional_sessions?t.additional_sessions=e.additional_sessions:delete t.additional_sessions,e.session_id&&(t.session_id=e.session_id),delete t.session_revision,delete t.preserved_primary_projection_sha256,y=new TextEncoder().encode(JSON.stringify(t,null,2))}}else if(a.expectedRemoteHash&&"__absent__"!==a.expectedRemoteHash)throw Error("workout_write_conflict")}v={workout_write:{protocol:1,base_version:s.version,sha256:await m(y),terminal:c,intent:d}}}}catch(e){return{error:{message:e instanceof Error?e.message:"Workout write refused"},version:null}}let N="",S="";if(_){N=await m(y);let r=n.includes(".")?n.slice(n.lastIndexOf(".")):".json";S="".concat(t,"/versions/").concat(n,"/").concat(N.slice(0,16)).concat(r);let{error:a}=await e.storage.from("user-data").upload(S,y,{contentType:k,upsert:!0});if(a)return{error:{message:"Version object upload failed: ".concat(a.message)},version:null}}let{error:T}=await e.storage.from("user-data").upload("".concat(t,"/").concat(n),y,{contentType:k,upsert:j,...v?{metadata:v}:{}});if(T){if(v)try{let e=await l(await h(),"".concat(t,"/").concat(n)),r=v.workout_write;if((null==e||null==(g=e.write)?void 0:g.terminal)&&"autosave"===r.intent)return{error:{message:"workout_already_finished"},version:null};if(e&&e.version!==r.base_version)return{error:{message:"workout_write_conflict"},version:null}}catch(e){}return{error:{message:T.message},version:null}}if(!_)return{error:null,version:null};try{let e=await h(),{data:r,error:s}=await e.rpc("bump_file_revision",{p_user_id:t,p_file_path:n,p_storage_path:S,p_changed_by:a.changedBy,p_change_type:null!=(w=a.changeType)?w:"update",p_content_hash:N,p_size_bytes:y.length,p_change_summary:null!=(x=a.changeSummary)?x:null});if(s)return console.error("saveUserFile: bump_file_revision failed for ".concat(t,"/").concat(n,": ").concat(s.message)),{error:null,version:null};let i=Array.isArray(r)?r[0]:r;return{error:null,version:null!=(b=null==i?void 0:i.version)?b:null}}catch(e){return console.error("saveUserFile: bump_file_revision threw for ".concat(t,"/").concat(n,":"),e),{error:null,version:null}}}var p=n(46470),g=n(58660);let w="\x3c!-- ROUND_BREAK --\x3e";var x=n(67217),b=n(83350),v=n(93031);let y=/^web_[0-9a-f]{32}$/;function k(e,t){if(0===t.length)return e;let n=new Set(e.map(e=>e.id)),r=t.filter(e=>{var t;return"string"==typeof(t=e.id)&&y.test(t)&&!n.has(e.id)});return 0===r.length?e:[...e,...r]}let j=(0,a.createContext)(null);function _(){let e=(0,a.useContext)(j);if(!e)throw Error("useChatContext must be used within ChatProvider");return e}function N(){return(0,a.useContext)(j)}function S(e){let{children:t,chatContext:n}=e,i=(0,a.useRef)((0,g.r9)()),[o,l]=(0,a.useState)("ad_hoc:".concat(i.current)),c=(0,a.useRef)({}),d=(0,a.useCallback)(async()=>{let e=await (0,p.z5)();return e.authorization&&(c.current=e),c.current},[]),[u,m]=(0,a.useState)(!1),[h,y]=(0,a.useState)([]),[_,N]=(0,a.useState)(!1),[S,T]=(0,a.useState)(""),[R,A]=(0,a.useState)(null),[C,P]=(0,a.useState)(null),[I,E]=(0,a.useState)([]),[$,U]=(0,a.useState)("Ask TakeHelm anything..."),[D,O]=(0,a.useState)(!1),[H,W]=(0,a.useState)(null),[B,z]=(0,a.useState)(!1),Q=(0,a.useRef)(null),[F,q]=(0,a.useState)(!1),[L,Z]=(0,a.useState)(null),[J,K]=(0,a.useState)(null),M=(0,a.useRef)(0),G=(0,a.useRef)(!1),Y=(0,a.useRef)(!1),V=(0,a.useCallback)(()=>{z(!0);try{Q.current&&localStorage.setItem(Q.current,"dismissed")}catch(e){}},[]),X=(0,a.useCallback)(e=>{let t=e.trim(),n=!1;if(G.current=!0,Y.current=!0,t){try{var r;let e=null==(r=sessionStorage.getItem(b.I))?void 0:r.trim();if(e&&e!==t&&!(n=window.confirm("Replace your unsent message with this suggested draft?"))){q(!1),Z(null),m(!0);return}sessionStorage.setItem(b.I,t)}catch(e){}M.current+=1,K({id:M.current,text:t,replaceExisting:n})}q(!1),Z(null),m(!0)},[]),ee=(0,a.useCallback)(e=>{K(t=>(null==t?void 0:t.id)===e?null:t)},[]);(0,a.useEffect)(()=>{(async()=>{var e;let t=await (0,p.iD)();t&&(c.current={authorization:"Bearer ".concat(t)});let n=null==(e=(0,p.Ti)())?void 0:e.id;if(n){Q.current="helm:chat-introduction:v1:".concat(n);try{z("dismissed"===localStorage.getItem(Q.current))}catch(e){}}let[r,a]=await Promise.all([fetch("/api/chat/agenda",{headers:c.current}).catch(()=>null),fetch("/api/chat/session?type=ad_hoc:auto&includeDiscovery=1",{headers:c.current}).catch(()=>null)]);if(null==r?void 0:r.ok){let e=await r.json();E(e.items||[]),U(e.topTeaser||"Ask TakeHelm anything...")}if(null==a?void 0:a.ok){let e=await a.json();W("boolean"==typeof e.hasPreviousChat?e.hasPreviousChat:null),"string"==typeof e.resolvedType&&e.resolvedType.startsWith("ad_hoc")&&l(e.resolvedType),e.session&&y(t=>k(e.session.messages||[],t))}O(!0)})()},[]);let et=(0,a.useRef)(!1),en=(0,a.useRef)(null),er=(0,a.useRef)(""),ea=(0,a.useRef)(null),es=(0,a.useRef)(null),ei=(0,a.useCallback)(async e=>{if(et.current)return;et.current=!0,N(!0),T(""),A(null),P(null);let t=new AbortController;en.current=t;let n="";try{let r=await d(),a=await fetch("/api/chat/message",{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(e),signal:t.signal});if(!a.ok||!a.body){let e=await a.json().catch(()=>({error:"Request failed"}));P(e.error||"Failed to get response"),N(!1),et.current=!1;return}let s=a.body.getReader(),i=new TextDecoder;for(;;){let{done:e,value:t}=await s.read();if(e)break;let r=(n+=i.decode(t,{stream:!0})).match(/<!-- STATUS: (.+?) -->\n/g);if(r){let e=r[r.length-1].match(/<!-- STATUS: (.+?) -->/);e&&A(e[1])}let a=n.replace(/<!-- STATUS: .+? -->\n/g,"").split(w);
1a[a.length-1]=a[a.length-1].replace(/\n?<!--[\s\S]*$/,"");let o=a.join(w);er.current=o,ea.current||(ea.current=requestAnimationFrame(()=>{T(er.current),ea.current=null})),o.length>0&&!es.current&&(es.current=setTimeout(()=>{A(null),es.current=null},150))}ea.current&&(cancelAnimationFrame(ea.current),ea.current=null);let o=n.match(/<!-- ERROR: (.+?) -->\n/);if(o){try{let e=JSON.parse(o[1]);P(e.message||"Something went wrong. Please try again.")}catch(e){P("Something went wrong. Please try again.")}N(!1),et.current=!1;return}let l=n.includes("\x3c!-- DONE --\x3e"),c=n.replace(/<!-- STATUS: .+? -->\n/g,"").replace(/\n?<!-- DONE -->\n?/g,"").split(w).map(e=>e.trim()).filter(Boolean);if(c.length>0){let e=Date.now();y(t=>[...t,...c.map((t,n)=>({id:"msg-".concat(e,"-").concat(n),role:"assistant",content:t}))])}T(""),l||P("Response was interrupted â please try again.")}catch(e){if(e instanceof DOMException&&"AbortError"===e.name){ea.current&&(cancelAnimationFrame(ea.current),ea.current=null);let e=n.replace(/<!-- STATUS: .+? -->\n/g,"").split(w).map(e=>e.trim()).filter(Boolean);if(e.length>0){let t=Date.now();y(n=>[...n,...e.map((e,n)=>({id:"msg-".concat(t,"-").concat(n),role:"assistant",content:e}))])}T("")}else P("Connection error. Please try again.")}finally{ea.current&&(cancelAnimationFrame(ea.current),ea.current=null),es.current&&(clearTimeout(es.current),es.current=null),A(null),en.current=null,N(!1),et.current=!1}},[d]),eo=(0,a.useCallback)(()=>{var e;null==(e=en.current)||e.abort()},[]),el=(0,a.useCallback)(async()=>{let e=await d(),t=await fetch("/api/chat/session?type=".concat(encodeURIComponent(o)),{headers:e}).catch(()=>null);if(null==t?void 0:t.ok){let e=await t.json().catch(()=>null);(null==e?void 0:e.session)&&y(t=>k(e.session.messages||[],t))}},[d,o]);(0,x.n)((0,a.useCallback)(e=>{"imessage"===e.channel&&e.sessionType===o&&!et.current&&(L||el())},[o,L,el]));let ec=(0,a.useRef)(!1);(0,a.useEffect)(()=>{(I.length>0||D&&"Ask TakeHelm anything..."!==$)&&(ec.current=!0)},[I,D,$]),(0,a.useEffect)(()=>{if(u)try{var e;(null==(e=sessionStorage.getItem(b.I))?void 0:e.trim())&&(G.current=!0,Y.current=!0)}catch(e){}},[u]),(0,a.useEffect)(()=>{if(u&&D&&0===h.length&&!G.current&&!L&&ec.current){G.current=!0;let e=I.some(e=>"weekly_review_due"===e.type);Y.current=e,ei({sessionType:o,message:e?"[Start today's conversation. A weekly review is due â lead with that. Reference their week's highlights, then ask the first planning question conversationally. Be warm and specific.]":"[Start today's conversation. Address the most important agenda item first. Keep it to 2-3 sentences. Be warm and specific.]",isResume:!0,isAutoStart:!0,...e?{}:{isGreeting:!0,agendaItems:I}})}},[u,D,h.length,L,I]),(0,a.useEffect)(()=>{if(u&&D&&ec.current&&h.length>0&&!Y.current&&!G.current&&!_&&!L&&I.some(e=>"weekly_review_due"===e.type)){let e=h[h.length-1];(null==e?void 0:e.role)==="assistant"&&(Y.current=!0,ei({sessionType:o,message:"[The user just opened the chat to plan next week. A weekly review is due â pivot to the weekly review now. Acknowledge the transition briefly, then start the review by referencing their week's highlights and asking the first planning question.]",isResume:!0}))}},[u,D,h.length,L,I,_]);let ed=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if("reprogram"===n&&D&&!ed.current&&!_){ed.current=!0,m(!0);{let e=new URL(window.location.href);e.searchParams.delete("context"),window.history.replaceState({},"",e.pathname+e.search)}let e={id:"temp-".concat(Date.now()),role:"user",content:"I'd like to adjust my plan for this week."};y(t=>[...t,e]),ei({sessionType:o,message:"I'd like to adjust my plan for this week."})}if("monthly-review"===n&&D&&!ed.current&&!_){ed.current=!0,m(!0);let e="";{let t=new URL(window.location.href),n=t.searchParams.get("month");if(n){let[t,r]=n.split("-"),a=new Date(Number(t),Number(r)-1);e=" for ".concat(a.toLocaleDateString("en-US",{month:"long",year:"numeric"}))}t.searchParams.delete("context"),t.searchParams.delete("month"),window.history.replaceState({},"",t.pathname+t.search)}let t="I'd like to discuss my monthly review".concat(e,"."),n={id:"temp-".concat(Date.now()),role:"user",content:t};y(e=>[...e,n]),ei({sessionType:o,message:t})}if("checkin"===n&&D&&!ed.current&&!_){ed.current=!0,m(!0);{let e=new URL(window.location.href);e.searchParams.delete("context"),window.history.replaceState({},"",e.pathname+e.search)}fetch("/api/me/check-ins/replied",{method:"POST"}).catch(()=>{});let e="I'd like to talk about my weekly check-in.",t={id:"temp-".concat(Date.now()),role:"user",content:e};y(e=>[...e,t]),ei({sessionType:o,message:e})}if("lab"===n&&D&&!ed.current&&!_){ed.current=!0,m(!0);let e=null;{let t=new URL(window.location.href);e=t.searchParams.get("eventId"),t.searchParams.delete("context"),t.searchParams.delete("eventId"),window.history.replaceState({},"",t.pathname+t.search)}let t="I just reviewed my latest lab results. Can you help me understand them and what I should focus on?",n={id:"temp-".concat(Date.now()),role:"user",content:t};y(e=>[...e,n]),ei({sessionType:o,message:t,...e?{analysisContext:{kind:"bloodwork",eventId:e}}:{}})}if("microbiome"===n&&D&&!ed.current&&!_){ed.current=!0,m(!0);let e=null;{let t=new URL(window.location.href);e=t.searchParams.get("eventId"),t.searchParams.delete("context"),t.searchParams.delete("eventId"),window.history.replaceState({},"",t.pathname+t.search)}let t="I just reviewed my microbiome results. Can you help me understand the key patterns and what I should focus on?",n={id:"temp-".concat(Date.now()),role:"user",content:t};y(e=>[...e,n]),ei({sessionType:o,message:t,...e?{analysisContext:{kind:"microbiome",eventId:e}}:{}})}let e=n?({genetics:{message:"I just reviewed my genetic blueprint. Can you help me understand the most important patterns and how cautiously I should interpret them?",kind:"genetics"},dexa:{message:"I just reviewed my DEXA analysis. Can you help me understand the body-composition patterns and what I should focus on?",kind:"dexa"},"fitness-test":{message:"I just reviewed my fitness test analysis. Can you help me understand the measurements, thresholds, and what they mean for my training?",kind:"fitness"}})[n]:void 0;if(e&&D&&!ed.current&&!_){ed.current=!0,m(!0);let t=null;{let e=new URL(window.location.href);t=e.searchParams.get("eventId"),e.searchParams.delete("context"),e.searchParams.delete("eventId"),window.history.replaceState({},"",e.pathname+e.search)}let n={id:"temp-".concat(Date.now()),role:"user",content:e.message};y(e=>[...e,n]),ei({sessionType:o,message:e.message,...t?{analysisContext:{kind:e.kind,eventId:t}}:{}})}},[n,D,_]);let eu=(0,a.useRef)([]),em=(0,a.useRef)(null),eh=(0,a.useCallback)(async(e,t)=>{var n,r;let a,i=Array.isArray(t),l=i?void 0:t,c=i?t:null!=(n=null==l?void 0:l.attachments)?n:[],d=null==l?void 0:l.systemHint,u=null==l?void 0:l.workflow,m=null==l?void 0:l.visitContext;if(L)return;if(_){let t={id:"temp-".concat(Date.now()),role:"user",content:e||(c.length?"Attached: ".concat(c.map(e=>e.file.name).join(", ")):"")};y(e=>[...e,t]),eu.current.push({text:e,options:{attachments:c,systemHint:d,workflow:u,visitContext:m}});return}em.current={text:e,systemHint:d,workflow:u,visitContext:m},Y.current=!0;let h={id:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:crypto.randomUUID();return"web_".concat(e.replaceAll("-","").toLowerCase())}(),role:"user",content:e||(c.length?"Attached: ".concat(c.map(e=>e.file.name).join(", ")):""),createdAt:new Date().toISOString()};if(y(e=>[...e,h]),c.length)try{let t=(0,s.cT)(),n=null==(r=(0,p.Ti)())?void 0:r.id;if(!n)throw Error("Not authenticated");for(let e of(a=[],c)){let r=e.file.name.split(".").pop()||("pdf"===e.type?"pdf":"jpg"),s="chat-attachments/".concat(crypto.randomUUID(),"_web.").concat(r),i="".concat(n,"/").concat(s),{error:o}=await f(t,n,s,e.file,{changedBy:"user",contentType:e.file.type,upsert:!1});if(o)throw o;a.push({storageKey:i,mediaType:e.file.type,filename:e.file.name})}em.current={text:e,attachments:a,systemHint:d,workflow:u,visitContext:m}}catch(e){console.error("[ChatProvider] Upload error:",e),P("Failed to upload file. Please try again.");return}await ei({sessionType:o,message:e||(c.length?"What are these?":""),clientMessageId:h.id,...a?{attachments:a}:{},clientContext:(0,v.U)(),...d?{systemHint:d}:{},...u?{workflow:u}:{},...m?{visitContext:m}:{}})},[_,L,o,ei]);(0,a.useEffect)(()=>
1{if(!_&&eu.current.length>0){var e;let t=eu.current;eu.current=[],eh(t.map(e=>e.text).filter(Boolean).join("\n"),null==(e=[...t].reverse().find(e=>e.options))?void 0:e.options)}},[_,eh]);let ef=(0,a.useCallback)(async()=>{if(!_)if(P(null),em.current){let{text:e,attachments:t,systemHint:n,workflow:r,visitContext:a}=em.current;await ei({sessionType:o,message:e||((null==t?void 0:t.length)?"What are these?":""),isResume:!0,...(null==t?void 0:t.length)?{attachments:t}:{},clientContext:(0,v.U)(),...n?{systemHint:n}:{},...r?{workflow:r}:{},...a?{visitContext:a}:{}})}else await ei({sessionType:o,message:"[Start today's conversation. Address the most important agenda item first. Keep it to 2-3 sentences. Be warm and specific.]",isResume:!0})},[_,o,ei]),ep=(0,a.useCallback)(async e=>{var t,n;if(!e){Z(null),q(!1);try{let e=await d(),n=await fetch("/api/chat/session?type=".concat(encodeURIComponent(o)),{headers:e});if(n.ok){let e=await n.json();y((null==(t=e.session)?void 0:t.messages)||[])}}catch(e){}return}Z(e),q(!1);try{let t=await d(),r=await fetch("/api/chat/session?type=".concat(encodeURIComponent(e)),{headers:t});if(r.ok){let e=await r.json();y((null==(n=e.session)?void 0:n.messages)||[])}}catch(e){P("Failed to load conversation")}},[o,d]),eg=I.filter(e=>"pending_workout"===e.type).length,ew=D&&!1===H&&!B&&!n&&!h.some(e=>"user"===e.role);return(0,r.jsx)(j.Provider,{value:{expanded:u,setExpanded:m,sessionType:o,messages:h,isStreaming:_,streamingContent:S,streamingStatus:R,error:C,agendaItems:I,topTeaser:$,pendingCount:eg,sendMessage:eh,openChatWithDraft:X,draftRequest:J,clearDraftRequest:ee,retryLastMessage:ef,stopStreaming:eo,isHistoryOpen:F,setHistoryOpen:q,viewingHistorySession:L,viewHistorySession:ep,initDone:D,showIntroduction:ew,dismissIntroduction:V},children:t})}},31144:(e,t,n)=>{n.d(t,{ZB:()=>l,Zp:()=>i,aR:()=>o});var r=n(21851),a=n(30188);let s={none:"",sm:"p-3",md:"p-4",lg:"p-6"};function i(e){let{children:t,padding:n="md",className:i}=e;return(0,r.jsx)("div",{className:(0,a.QP)("bg-surface rounded-xl border border-hairline shadow-card",s[n],i),children:t})}function o(e){let{children:t,className:n}=e;return(0,r.jsx)("div",{className:(0,a.QP)("flex items-center justify-between mb-4",n),children:t})}function l(e){let{children:t,className:n}=e;return(0,r.jsx)("h3",{className:(0,a.QP)("text-[15px] font-semibold text-ink-strong",n),children:t})}},41315:(e,t,n)=>{n.d(t,{md:()=>s,W:()=>r.W,$n:()=>i.$,Pq:()=>d,Zp:()=>u.Zp,aR:()=>u.aR,ZB:()=>u.ZB,vu:()=>m.v,e0:()=>h.CollapsibleSectionCard,pp:()=>p,W5:()=>g.ErrorState,Q5:()=>w.ExpandableSection,gu:()=>f.GeneChip,lq:()=>x,K0:()=>v,Gu:()=>k,zY:()=>j,z2:()=>N,iv:()=>S,Tk:()=>A});var r=n(86693),a=n(21851);function s(){return(0,a.jsx)("div",{className:"bg-surface-sunken border-b border-hairline px-4 py-2",children:(0,a.jsx)("p",{className:"max-w-[1200px] mx-auto text-xs font-medium text-ink-muted text-center",children:"Summaries, check-ins, and lab interpretations in this view are AI-generated â exercise independent clinical judgment."})})}var i=n(64370),o=n(30188);let l={insight:"border-brand-400 bg-brand-50/50",good:"border-good-line bg-good-soft",warn:"border-warn-line bg-warn-soft",crit:"border-crit-line bg-crit-soft",info:"border-info-line bg-info-soft"},c={insight:"text-brand-600",good:"text-good",warn:"text-warn",crit:"text-crit",info:"text-info"};function d(e){let{variant:t="insight",overline:n,title:r,children:s,className:i,wide:d}=e;return(0,a.jsxs)("div",{className:(0,o.QP)("border-l-[3px] rounded-lg px-4 py-3",l[t],i),children:[n&&(0,a.jsx)("p",{className:(0,o.QP)("text-[11px] font-semibold uppercase tracking-[0.08em] mb-1",c[t]),children:n}),r&&(0,a.jsx)("p",{className:"text-sm font-semibold text-ink-strong mb-1",children:r}),(0,a.jsx)("div",{className:(0,o.QP)("text-sm leading-6 text-ink max-w-[68ch]",d&&"max-w-none"),children:s})]})}var u=n(31144),m=n(91660),h=n(86389),f=n(90095);function p(e){let{icon:t,title:n,description:r,action:s}=e;return(0,a.jsxs)("div",{className:"bg-surface rounded-xl border border-hairline shadow-card p-8 text-center max-w-md mx-auto",children:[(0,a.jsx)("div",{className:"w-14 h-14 roun
1ded-xl bg-brand-50 text-brand-600 flex items-center justify-center mx-auto mb-4",children:(0,a.jsx)(t,{className:"w-7 h-7"})}),(0,a.jsx)("h2",{className:"text-[15px] font-semibold text-ink-strong mb-1.5",children:n}),r&&(0,a.jsx)("p",{className:"text-sm text-ink-muted mb-4",children:r}),s]})}var g=n(83451),w=n(66479);function x(e){let{eyebrow:t,title:n,children:r}=e;return(0,a.jsxs)("div",{className:"bg-brand-950 text-white rounded-xl p-6",children:[t&&(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-brand-300 mb-2",children:t}),(0,a.jsx)("h2",{className:"text-lg font-semibold tracking-tight leading-snug",children:n}),r&&(0,a.jsx)("div",{className:"text-sm leading-6 text-brand-100 mt-3 max-w-[68ch]",children:r})]})}let b={sm:"p-1",md:"p-1.5"};function v(e){let{size:t="sm",children:n,className:r,...s}=e;return(0,a.jsx)("button",{type:"button",className:(0,o.QP)("inline-flex items-center justify-center rounded-lg text-ink-muted hover:text-ink-strong hover:bg-surface-sunken transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",b[t],r),...s,children:n})}var y=n(72012);function k(e){let{label:t,fullScreen:n=!0}=e,r=(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,a.jsx)(y.A,{className:"w-6 h-6 animate-spin text-brand-500"}),t&&(0,a.jsx)("p",{className:"text-sm text-ink-muted",children:t})]});return n?(0,a.jsx)("div",{className:"min-h-screen bg-ground flex items-center justify-center",children:r}):(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:r})}function j(e){let{icon:t,title:n,subtitle:r,actions:s}=e;return(0,a.jsxs)("div",{className:"flex items-center justify-between w-full gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,a.jsx)("div",{className:"w-9 h-9 rounded-lg bg-brand-50 text-brand-600 flex items-center justify-center shrink-0",children:(0,a.jsx)(t,{className:"w-5 h-5"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h1",{className:"text-lg font-semibold text-ink-strong tracking-tight truncate",children:n}),r&&(0,a.jsx)("p",{className:"text-sm text-ink-muted truncate",children:r})]})]}),s&&(0,a.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:s})]})}let _={brand:"bg-brand-500",good:"bg-good",warn:"bg-warn",crit:"bg-crit"};function N(e){let{value:t,status:n="brand",showLabel:r=!1,className:s}=e,i=Math.min(100,Math.max(0,t));return(0,a.jsxs)("div",{className:(0,o.QP)("w-full",s),children:[(0,a.jsx)("div",{className:"w-full bg-hairline rounded-full overflow-hidden h-1.5",children:(0,a.jsx)("div",{className:(0,o.QP)("h-full rounded-full transition-all duration-300",_[n]),style:{width:"".concat(i,"%")}})}),r&&(0,a.jsxs)("span",{className:"text-xs text-ink-faint mt-1",children:[i,"%"]})]})}function S(e){let{icon:t,title:n,subtitle:r,actions:s,children:i,className:l}=e;return(0,a.jsxs)("section",{className:(0,o.QP)("bg-surface rounded-xl border border-hairline shadow-card p-5",l),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[t&&(0,a.jsx)("div",{className:"w-9 h-9 rounded-lg bg-brand-50 text-brand-600 flex items-center justify-center shrink-0",children:(0,a.jsx)(t,{className:"w-5 h-5","aria-hidden":"true"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h2",{className:"text-[15px] font-semibold text-ink-strong truncate",children:n}),r&&(0,a.jsx)("p",{className:"text-xs text-ink-faint truncate",children:r})]})]}),s&&(0,a.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:s})]}),i]})}var T=n(61810);let R={good:"text-good",warn:"text-warn",crit:"text-crit",info:"text-info"};function A(e){let{label:t,value:n,unit:r,sub:s,description:i,valueStatus:l,className:c}=e;return(0,a.jsxs)("div",{className:(0,o.QP)("relative overflow-visible bg-surface rounded-xl border border-hairline shadow-card px-4 py-3.5",c),children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-ink-faint",children:t}),i&&(0,a.jsxs)("details",{className:"group/stat-help relative -mr-1 -mt-1",children:[(0,a.jsx)("summary",{"aria-label":"About ".concat(t),className:"flex h-6 w-6 cursor-help list-none items-center justify-center rounded-full text-ink-faint transition-colors hover:bg-surface-sunken hover:text-ink-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1 [&::-webkit-details-marker]:hidden",children:(0,a.jsx)(T.A,{"aria-hidden":"true",className:"h-3.5 w-3.5"})}),(0,a.jsx)("div",{role:"note",className:"fixed inset-x-4 bottom-4 z-30 hidden rounded-lg border border-hairline-strong bg-surface px-3 py-2.5 text-xs font-normal normal-case leading-5 tracking-normal text-ink shadow-lg group-hover/stat-help:block group-focus-within/stat-help:block group-open/stat-help:block sm:absolute sm:inset-x-auto sm:bottom-auto sm:right-0 sm:mt-1.5 sm:w-72",children:i})]})]}),(0,a.jsxs)("p",{className:(0,o.QP)("text-2xl font-bold tracking-tight tabular-nums mt-0.5 text-ink-strong",l&&R[l]),children:[n,r&&(0,a.jsx)("span",{className:"text-[13px] font-normal text-ink-faint ml-1",children:r})]}),s&&(0,a.jsx)("div",{className:"text-xs text-ink-faint mt-0.5",children:s})]})}},58660:(e,t,n)=>{function r(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(n,"-").concat(r)}function a(){return r(new Date)}n.d(t,{TJ:()=>r,r9:()=>a})},64370:(e,t,n)=>{n.d(t,{$:()=>o});var r=n(21851),a=n(30188);let s={primary:"bg-brand-600 hover:bg-brand-700 text-white",secondary:"bg-surface border border-hairline-strong text-ink hover:bg-surface-sunken",ghost:"bg-transparent hover:bg-surface-sunken text-ink",destructive:"bg-crit hover:opacity-90 text-white"},i={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-5 py-2.5 text-sm"};function o(e){let{variant:t="primary",size:n="md",icon:o,children:l,className:c,...d}=e;return(0,r.jsxs)("button",{className:(0,a.QP)("inline-flex items-center justify-center gap-2 font-medium rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",s[t],i[n],c),...d,children:[o&&(0,r.jsx)("span",{className:"w-4 h-4 flex items-center justify-center",children:o}),l]})}},66479:(e,t,n)=>{n.d(t,{ExpandableSection:()=>i});var r=n(21851),a=n(78059),s=n(9236);let i=(0,a.memo)(function(e){let{title:t,children:n,defaultOpen:i=!1,icon:o}=e,[l,c]=(0,a.useState)(i);return(0,r.jsxs)("div",{className:"border-t border-hairline pt-3",children:[(0,r.jsxs)("button",{onClick:()=>c(!l),className:"flex items-center gap-2 w-full text-left cursor-pointer",children:[(0,r.jsx)(s.A,{className:"w-4 h-4 text-ink-faint transition-transform ".concat(l?"":"-rotate-90")}),o,(0,r.jsx)("span",{className:"text-sm font-medium text-ink",children:t})]}),l&&(0,r.jsx)("div",{className:"mt-3 pl-6",children:n})]})})},67217:(e,t,n)=>{n.d(t,{n:()=>p,q:()=>f});var r=n(78059),a=n(53235),s=n(46470);let i=null,o=new Set,l=new Set,c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,t=new Map;return{dispatch(n,r){for(let a of r){if(null!==a.segments&&!a.segments.includes(n.segment))continue;let r=t.get(a);r&&clearTimeout(r),t.set(a,setTimeout(()=>{t.delete(a),a.callback()},e))}},remove(e){let n=t.get(e);n&&clearTimeout(n),t.delete(e)},clear(){for(let e of t.values())clearTimeout(e);t.clear()}}}(),d=new Map,u=function(e){let t=null;return()=>{if(t)return t;let n=e().finally(()=>{t===n&&(t=null)});return t=n,n}}(async()=>{var e;if(i)return;let t=await (0,s.iD)(),n=null==(e=(0,s.Ti)())?void 0:e.id;if(!t||!n)return;let r=(0,a.cT)();await Promise.race([r.realtime.setAuth(t),new Promise(e=>setTimeout(e,5e3))]),i||0===o.size&&0===l.size||(i=r.channel("user:".concat(n),{config:{private:!0}}).on("broadcast",{event:"file_changed"},e=>{let t=e.payload;(null==t?void 0:t.segment)&&c.dispatch(t,o)}).on("broadcast",{event:"chat_message"},e=>{let t=e.payload;(null==t?void 0:t.sessionId)&&function(e){let t=d.get(e.sessionId);t&&clearTimeout(t),d.set(e.sessionId,setTimeout(()=>{for(let t of(d.delete(e.sessionId),l))t.callback(e)},800))}(t)}).subscribe())});async function m(){if(!i)try{await u()}finally{h()}}function h(){if(i&&0===o.size&&0===l.size){for(let e of((0,a.cT)().removeChannel(i),i=null,c.clear(),d.values())
1)clearTimeout(e);d.clear()}}function f(e,t){let n=(0,r.useRef)(t);n.current=t;let s=(0,r.useRef)(e);s.current=e,(0,r.useEffect)(()=>{let e={get segments(){return s.current},get callback(){return n.current}};o.add(e),m();let t=(0,a.cT)(),{data:r}=t.auth.onAuthStateChange(async(e,n)=>{if("TOKEN_REFRESHED"===e){let e=null==n?void 0:n.access_token;e&&await Promise.race([t.realtime.setAuth(e),new Promise(e=>setTimeout(e,5e3))])}});return()=>{o.delete(e),c.remove(e),r.subscription.unsubscribe(),h()}},[])}function p(e){let t=(0,r.useRef)(e);t.current=e,(0,r.useEffect)(()=>{let e={get callback(){return t.current}};l.add(e),m();let n=(0,a.cT)(),{data:r}=n.auth.onAuthStateChange(async(e,t)=>{if("TOKEN_REFRESHED"===e){let e=null==t?void 0:t.access_token;e&&await Promise.race([n.realtime.setAuth(e),new Promise(e=>setTimeout(e,5e3))])}});return()=>{l.delete(e),r.subscription.unsubscribe(),h()}},[])}},83350:(e,t,n)=>{n.d(t,{I:()=>r,l:()=>s});let r="chat-draft",a="/dashboard";function s(e){let t=function(e){if(!e)return a;let t=e.trim().split(/[?#]/,1)[0];return!t.startsWith("/dashboard")||t.length>240||/[\r\n\u0000]/.test(t)?a:t}(e);return["I'd like to report an issue with TakeHelm.\n\nWhat happened â or what data doesn't look right:\nWhat I expected:","Page: ".concat(t)].join("\n")}},83451:(e,t,n)=>{n.d(t,{ErrorState:()=>i});var r=n(21851),a=n(14237),s=n(64370);function i(e){let{title:t="Something went wrong",description:n="Your data is safe. Try again in a moment.",onRetry:i,retryLabel:o="Try Again"}=e;return(0,r.jsxs)("div",{className:"bg-surface rounded-xl border border-hairline shadow-card p-8 text-center max-w-md mx-auto",children:[(0,r.jsx)("div",{className:"w-14 h-14 rounded-xl bg-warn-soft text-warn flex items-center justify-center mx-auto mb-4",children:(0,r.jsx)(a.A,{className:"w-7 h-7"})}),(0,r.jsx)("h2",{className:"text-[15px] font-semibold text-ink-strong mb-1.5",children:t}),n&&(0,r.jsx)("p",{className:"text-sm text-ink-muted mb-4",children:n}),i&&(0,r.jsx)(s.$,{onClick:i,children:o})]})}},86389:(e,t,n)=>{n.d(t,{CollapsibleSectionCard:()=>i});var r=n(21851),a=n(78059),s=n(9236);function i(e){let{title:t,subtitle:n,icon:i,children:o,defaultOpen:l=!0,actions:c,id:d}=e,[u,m]=(0,a.useState)(l);return(0,a.useEffect)(()=>{d&&window.location.hash.slice(1)===d&&(m(!0),setTimeout(()=>{var e;null==(e=document.getElementById(d))||e.scrollIntoView({behavior:"smooth",block:"start"})},100))},[d]),(0,r.jsx)("div",{id:d,className:"bg-surface rounded-xl border border-hairline shadow-card w-full",children:(0,r.jsxs)("div",{className:"p-5",children:[(0,r.jsxs)("button",{onClick:()=>m(!u),className:"w-full flex items-center justify-between gap-3 text-left",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,r.jsx)("div",{className:"w-9 h-9 rounded-lg bg-brand-50 text-brand-600 flex items-center justify-center shrink-0",children:(0,r.jsx)(i,{className:"w-5 h-5"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("h3",{className:"text-[15px] font-semibold text-ink-strong",children:t}),n&&(0,r.jsx)("p",{className:"text-xs text-ink-faint",children:n})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[c,(0,r.jsx)(s.A,{className:"w-5 h-5 text-ink-faint transition-transform ".concat(u?"":"-rotate-90")})]})]}),u&&(0,r.jsx)("div",{className:"mt-4",children:o})]})})}},86693:(e,t,n)=>{n.d(t,{W:()=>i});var r=n(21851),a=n(18527),s=n.n(a);function i(){return(0,r.jsxs)("p",{className:"text-center text-xs text-ink-faint pt-4 pb-2",children:["AI-generated analysis for informational purposes only â not medical advice."," ",(0,r.jsx)(s(),{href:"/legal/disclaimers",className:"underline hover:text-ink-muted",children:"Full disclaimers"})]})}},90095:(e,t,n)=>{n.d(t,{GeneChip:()=>i});var r=n(21851),a=n(22964),s=n(91660);function i(e){let{gene:t,icon:n}=e,i=(0,a.nH)();return i?(0,r.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),i.setExpanded(!0),i.sendMessage("What does my ".concat(t," variant mean for me, practically? Keep it short â what it affects, and what I'm already doing (or should consider) because of it."))},title:"Ask TakeHelm what ".concat(t," means for you"),className:"cursor-pointer rounded-full transition-opacity hover:opacity-75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500",children:(0,r.jsx)(s.v,{variant:"gene",icon:n,children:t})}):(0,r.jsx)(s.v,{variant:"gene",icon:n,children:t})}},91660:(e,t,n)=>{n.d(t,{v:()=>i});var r=n(21851),a=n(30188);let s={good:"bg-good-soft text-good",warn:"bg-warn-soft text-warn",crit:"bg-crit-soft text-crit",info:"bg-info-soft text-info",neutral:"bg-surface-sunken text-ink-muted",brand:"bg-brand-50 text-brand-700",gene:"bg-brand-50 text-brand-700 font-mono text-[11px] tracking-tight"};function i(e){let{variant:t="neutral",icon:n,children:i,className:o}=e;return(0,r.jsxs)("span",{className:(0,a.QP)("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium whitespace-nowrap",s[t],o),children:[n&&(0,r.jsx)("span",{className:"w-3.5 h-3.5 flex items-center justify-center",children:n}),i]})}},93031:(e,t,n)=>{n.d(t,{U:()=>r});function r(){var e;return{pagePath:"".concat(window.location.pathname).concat(window.location.search).slice(0,240),occurredAt:new Date().toISOString(),locale:navigator.language.slice(0,40),timezone:(null!=(e=Intl.DateTimeFormat().resolvedOptions().timeZone)?e:"").slice(0,80),viewportWidth:window.innerWidth,viewportHe
1ight:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}}}]);
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.