1import{r as i,j as e,P as de,T as I,W as me,$ as ue,aE as fe,Y as pe,aD as te,a1 as he,aF as xe,aG as ge,Q as ye,z as $,B as D,L as G,a7 as ve,i as O,s as be,c as je,C as A,e as L,a4 as J,a5 as Q,a3 as Ne,y as we,A as Ce}from"./index-CbUVcLen.js";import{D as Se}from"./DemoHeader-CZd_350Q.js";import{B as _e}from"./BaselineBarGraph-SxE0ZC7c.js";import{S as ke}from"./ScreeningSymptomProfile-DP55aiku.js";import{P as re,N as Ie}from"./journeyMetrics-bF9LVsmE.js";import{P as Ee,a as Re,N as Te,g as De,d as Pe,c as Ae}from"./baselineDynamicText-DLHwycdb.js";import{a as Le,c as Oe,S as He,d as qe,g as Me}from"./screeningDynamicText-CeHh5M2h.js";import{a as Be,b as Fe}from"./screeningQuestions-CiBOpQnU.js";import{u as We}from"./useAIRecommendations-D1Hqe0n3.js";import{I as X}from"./InlineGlossaryText-D-WWh2tm.js";import{B as F}from"./badge-CZIH4sEl.js";import{C as Z}from"./circle-help-sZbQjbrV.js";import{D as $e,a as Ge,b as Ye,c as Ke}from"./dialog-CTxxYOzo.js";import{A as Ue}from"./AIInsightsDisclosure-Br7lkWWM.js";import{T as ee}from"./TruncatedIntro-B3gXKvEd.js";import{M as ze}from"./mouse-pointer-click-C3paJu4A.js";import{A as Ve}from"./arrow-right-CiTmDFtw.js";import"./SwirlLogo-C34WGKNa.js";import"./LanguageSelector-Cabh3t_d.js";import"./dropdown-menu-C6245JAw.js";import"./Combination-mypONuiH.js";import"./index-DN-eOJHr.js";import"./check-UJLIhtLN.js";import"./circle-xAkeTpgX.js";import"./patient-BGAHPpHJ.js";import"./use-mobile-DgwQRiXk.js";import"./index-Ism7gw5U.js";import"./chevron-up-Urz6d9RP.js";import"./chevron-down-Bn2ixTyI.js";var Je=Object.defineProperty,R=(a,t)=>Je(a,"name",{value:t,configurable:!0}),W,K="HoverCard",[se,Ft]=pe(K,[te]),U=te(),[Qe,z]=se(K),Xe=R(a=>{const{__scopeHoverCard:t,children:m,open:r,defaultOpen:f,onOpenChange:c,openDelay:p=700,closeDelay:u=300}=a,y=U(t),x=i.useRef(0),j=i.useRef(0),N=i.useRef(!1),C=i.useRef(!1),[w,v]=he({prop:r,defaultProp:f??!1,onChange:c,caller:K}),h=i.useCallback(()=>{clearTimeout(j.current),x.current=window.setTimeout(()=>v(!0),p)},[p,v]),b=i.useCallback(()=>{clearTimeout(x.current),!N.current&&!C.current&&(j.current=window.setTimeout(()=>v(!1),u))},[u,v]),s=i.useCallback(()=>v(!1),[v]);return i.useEffect(()=>()=>{clearTimeout(x.current),clearTimeout(j.current)},[]),e.jsx(Qe,{scope:t,open:w,onOpenChange:v,onOpen:h,onClose:b,onDismiss:s,hasSelectionRef:N,isPointerDownOnContentRef:C,children:e.jsx(xe,{...y,children:m})})},"HoverCard"),Ze="HoverCardTrigger",et=i.forwardRef(R(function(t,m){const{__scopeHoverCard:r,...f}=t,c=z(Ze,r),p=U(r);return e.jsx(ge,{asChild:!0,...p,children:e.jsx(ye.a,{"data-state":c.open?"open":"closed",...f,ref:m,onPointerEnter:I(t.onPointerEnter,H(c.onOpen)),onPointerLeave:I(t.onPointerLeave,H(c.onClose)),onFocus:I(t.onFocus,c.onOpen),onBlur:I(t.onBlur,c.onClose),onTouchStart:I(t.onTouchStart,u=>u.preventDefault())})})},"HoverCardTrigger")),tt="HoverCardPortal",[Wt,rt]=se(tt,{forceMount:void 0}),Y="HoverCardContent",st=i.forwardRef(R(function(t,m){const r=rt(Y,t.__scopeHoverCard),{forceMount:f=r.forceMount,...c}=t,p=z(Y,t.__scopeHoverCard);return e.jsx(de,{present:f||p.open,children:e.jsx(nt,{"data-state":p.open?"open":"closed",...c,onPointerEnter:I(t.onPointerEnter,H(p.onOpen)),onPointerLeave:I(t.onPointerLeave,H(p.onClose)),ref:m})})},"HoverCardContent")),nt=i.forwardRef(R(function(t,m){const{__scopeHoverCard:r,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:p,onInteractOutside:u,...y}=t,x=z(Y,r),j=U(r),N=i.useRef(null),C=me(m,N),[w,v]=i.useState(!1);return i.useEffect(()=>{if(w){const h=document.body;return W=h.style.userSelect||h.style.webkitUserSelect,h.style.userSelect="none",h.style.webkitUserSelect="none",()=>{h.style.userSelect=W,h.style.webkitUserSelect=W}}},[w]),i.useEffect(()=>{if(N.current){const h=R(()=>{v(!1),x.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(x.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",h),()=>{document.removeEventListener("pointerup",h),x.hasSelectionRef.current=!1,x.isPointerDownOnContentRef.current=!1}}},[x.isPointerDownOnContentRef,x.hasSelectionRef]),i.useEffect(()=>{N.current&&ne(N.current).forEach(b=>b.setAttribute("tabindex","-1"))}),e.jsx(ue,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:u,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:I(p,h=>{h.preventDefault()}),onDismiss:x.onDismiss,children:e.jsx(fe,{...j,...y,onPointerDown:I(y.onPointerDown,h=>{h.currentTarget.contains(h.target)&&v(!0),x.hasSelectionRef.current=!1,x.isPointerDownOnContentRef.current=!0}),ref:C,style:{...y.style,userSelect:w?"text":void 0,WebkitUserSelect:w?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function H(a){return t=>t.pointerType==="touch"?void 0:a()}R(H,"excludeTouch");function ne(a){const t=[],m=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,{acceptNode:R(r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;m.nextNode();)t.push(m.currentNode);return t}R(ne,"getTabbableNodes");var ot=Xe,it=et,oe=st;const at=ot,lt=it,ie=i.forwardRef(({className:a,align:t="center",sideOffset:m=4,...r},f)=>e.jsx(oe,{ref:f,align:t,sideOffset:m,className:$("z-50 w-64 roun
1ded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...r}));ie.displayName=oe.displayName;const ae={"screen-graph":{title:"Your E360 Screen",description:"A profile of symptom clusters showing lifetime impact (how much a symptom has affected your life) and current level (how present it is right now).",faqs:[{q:"What does lifetime vs current mean?",a:"Lifetime is the total burden a symptom has placed on your life over time. Current is how strongly you're experiencing it right now â a snapshot of the last few weeks."},{q:"Why are some bars taller than others?",a:"Taller bars mean that symptom cluster has had a bigger footprint on your life or is currently more active. It doesn't mean 'bad' â it just tells us where to focus."},{q:"What do I do with this?",a:"Click any bar to open the result, recommendation, and an AI insight. Use it as a starting point for what to explore or discuss with a clinician."}]},"baseline-graph":{title:"Your E360 Baseline",description:"Your current strengths (positive metrics like mood, energy, resilience) alongside your current risk indicators (mood and behavioral variability).",faqs:[{q:"What's the difference between strengths and risk indicators?",a:"Strengths are protective â the resources you can lean on. Risk indicators are areas that need watching. Both use different scales so we can measure them fairly."},{q:"Why is the risk scale 5 to 10?",a:"For risk indicators, 5 is 'None' and 10 is 'Extreme'. This is by design â it keeps the sensitivity of the scale where it matters clinically."},{q:"How is this different from the Screen?",a:"The Screen looks at symptom clusters. The Baseline looks at how you're functioning right now â your day-to-day capacity."}]},result:{title:"Result",description:"Plain-language interpretation of your score for this metric â what the number actually means for you.",faqs:[{q:"Is this a diagnosis?",a:"No. This is a description of how you scored, not a clinical diagnosis. Only a licensed clinician can diagnose."},{q:"Can my result change?",a:"Yes. Baseline scores reflect the last few weeks and can shift with treatment, life changes, or coping work."}]},recommendation:{title:"Recommendation",description:"Suggested next steps based on your score â the kind of support or practice that tends to help at this level.",faqs:[{q:"Do I have to do all of this?",a:"No. Recommendations are options, not prescriptions. Pick what feels doable and discuss the rest with a clinician."},{q:"Where do these come from?",a:"They're drawn from patterns across thousands of real-world encounters plus current clinical guidelines."}]},"ai-insight":{title:"AI Insight",description:"A personalized synthesis generated by our AI, using your full profile and patterns from similar cases with good outcomes.",faqs:[{q:"Is the AI reading my personal information?",a:"No PII (name, contact info) is sent to the AI. Only your scores are used to generate the insight."},{q:"How accurate is it?",a:"The AI is a decision-support tool, not a clinician. Treat it as a thoughtful second perspective â always verify with a professional."}]},score:{title:"Score",description:"Your numeric value on this metric. Strengths use 0â10 (higher is better). Risk indicators use 5â10 (higher is worse).",faqs:[{q:"Why decimals?",a:"Half-point precision (like 7.5) lets us track meaningful change over time without forcing everything into whole numbers."}]},report:{title:"Report",description:"A full narrative version of your Screen and Baseline results, formatted to save, print, or share with a clinician.",faqs:[{q:"Can I download this?",a:"Saving, downloading, and printing are part of a paid plan. You can view your report on this device for free."}]}},ct=(a,t)=>{const m=ae[a];if(!m)return null;const r=t.toLowerCase().trim();if(!r)return null;const f=m.faqs.find(u=>u.q.toLowerCase()===r);if(f)return f.a;const c=new Set(r.split(/\W+/).filter(u=>u.length>3));let p=null;for(const u of m.faqs){const y=new Set(u.q.toLowerCase().split(/\W+/).filter(j=>j.length>3));let x=0;
1c.forEach(j=>{y.has(j)&&(x+=1)}),(!p||x>p.score)&&(p={entry:u,score:x})}return p&&p.score>=2?p.entry.a:null},E=({fieldId:a,children:t,iconOnly:m=!1,className:r})=>{const f=ae[a],[c,p]=i.useState(""),[u,y]=i.useState(null),[x,j]=i.useState(null),[N,C]=i.useState(!1),[w,v]=i.useState(null);if(!f)return e.jsx(e.Fragment,{children:t});const h=async()=>{if(!c.trim()||N)return;v(null),y(null),j(null);const s=ct(a,c);if(s){y(s),j("faq");return}C(!0);try{const{data:k,error:T}=await be.functions.invoke("dashboard-help",{body:{fieldTitle:f.title,fieldDescription:f.description,question:c}});if(T)throw T;if(k?.error)throw new Error(k.error);y(k?.answer??"No answer returned."),j("ai")}catch(k){v(k instanceof Error?k.message:"Something went wrong.")}finally{C(!1)}},b=m?e.jsx("button",{type:"button","aria-label":`Help: ${f.title}`,className:$("inline-flex items-center justify-center rounded-full text-muted-foreground hover:text-primary transition-colors",r),children:e.jsx(Z,{className:"h-3.5 w-3.5"})}):e.jsxs("span",{className:$("inline-flex items-center gap-1.5 cursor-help",r),children:[t,e.jsx(Z,{className:"h-3.5 w-3.5 text-muted-foreground/70"})]});return e.jsxs(at,{openDelay:120,closeDelay:200,children:[e.jsx(lt,{asChild:!0,children:b}),e.jsxs(ie,{side:"top",align:"start",className:"w-80 p-0 overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-border/60 bg-muted/30",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:f.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:f.description})]}),e.jsxs("div",{className:"p-3 space-y-2 max-h-56 overflow-y-auto",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.15em] text-muted-foreground font-semibold",children:"Common questions"}),f.faqs.map(s=>e.jsxs("details",{className:"text-xs group",children:[e.jsxs("summary",{className:"cursor-pointer text-foreground/90 hover:text-primary py-1 list-none flex items-start gap-1.5",children:[e.jsx("span",{className:"text-primary group-open:rotate-90 transition-transform",children:"âº"}),e.jsx("span",{children:s.q})]}),e.jsx("p",{className:"pl-4 pt-1 text-foreground/75 leading-relaxed",children:s.a})]},s.q))]}),e.jsxs("div",{className:"p-3 border-t border-border/60 bg-muted/20 space-y-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.15em] text-muted-foreground font-semibold",children:"Ask your own question"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{type:"text",value:c,onChange:s=>p(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),h())},placeholder:"e.g. What does this score mean?",className:"flex-1 text-xs px-2 py-1.5 rounded border border-input bg-background text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-1 focus:ring-primary"}),e.jsx(D,{size:"sm",variant:"outline",onClick:h,disabled:N||!c.trim(),className:"h-7 px-2",children:N?e.jsx(G,{className:"h-3 w-3 animate-spin"}):e.jsx(ve,{className:"h-3 w-3"})})]}),u&&e.jsxs("div",{className:"text-xs text-foreground/85 leading-relaxed bg-background rounded border border-border/60 p-2",children:[x==="ai"&&e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-primary mb-1",children:[e.jsx(O,{className:"h-3 w-3"})," AI answer"]}),u]}),w&&e.jsx("div",{className:"text-xs text-destructive",children:w})]})]})]})},dt=Be.reduce((a,t)=>(t.description&&(a[t.id]=t.description),a),{}),mt=a=>{const t={},m={};return re.forEach(r=>{a[r.key]!==void 0&&(t[r.key]=a[r.key])}),Ie.forEach(r=>{a[r.key]!==void 0&&(m[r.key]=a[r.key])}),{pos:t,neg:m}},$t=()=>{const a=je(),[t,m]=i.useState(null),[r,f]=i.useState(null),[c,p]=i.useState({}),[u,y]=i.useState(null),[x,j]=i.useState(!1),[N,C]=i.useState(!1),[w,v]=i.useState({}),{generateRecommendation:h}=We(),b=i.useMemo(()=>{try{const n=sessionStorage.getItem("demoBaselineData");return n?JSON.parse(n).scores??null:null}catch{return null}},[]),s=i.useMemo(()=>{try{const n=sessionStorage.getItem("demoScreeningData");if(!n)return null;const o=JSON.parse(n),l={};return Object.keys(o.lifetimeScores||{}
1).forEach(d=>{l[d]={lifetime:o.lifetimeScores?.[d]??0,current:o.currentWeekScores?.[d]??0}}),l}catch{return null}},[]),k=i.useMemo(()=>{try{const n=sessionStorage.getItem("demoScreeningData");return n?JSON.parse(n).skipLogicAnswers??{}:{}}catch{return{}}},[]),T=b?mt(b):null,S=i.useMemo(()=>{if(!t||!b)return null;const n=b[t.key];if(n===void 0)return null;if(t.kind==="positive"){const d=Ee[t.key];if(!d)return null;const _=Pe(n);return{title:d.title,shortDefinition:d.intro,longDefinition:d.intro,label:Re(_),score:n,result:d.results[_],recommendation:d.recommendations[_]}}const o=Te[t.key];if(!o)return null;const l=Ae(n);return{title:o.title,shortDefinition:o.intro,longDefinition:o.intro,label:De(l),score:n,result:o.results[l],recommendation:o.recommendations[l]}},[t,b]),g=i.useMemo(()=>{if(!r||!s)return null;const n=s[r];if(!n)return null;const o=He[r];if(!o)return null;const l=Le(n.lifetime),d=Oe(n.current),_=k[r]===!0,P=Fe.includes(r)&&_,B=n.current>0?d:l;return{title:o.title,shortDefinition:dt[r]??null,longDefinition:o.intro,lifetimeScore:n.lifetime,lifetimeLabel:Me(l),lifetimeResult:o.lifetimeResults[l],currentScore:n.current,currentLabel:qe(d),currentRecommendation:P?o.currentRecommendations[d]:null,epiphanyRecommendation:o.currentRecommendations[B]}},[r,s,k]),le=async()=>{if(!t||!b||!S)return;const n=`${t.kind}_${t.key}`;if(!(c[n]||u)&&!(c[n]||u)){y(n);try{const o=await h({depression_lifetime:10-(b.mood??5),anxiety_lifetime:10-(b.peaceOfMind??5)},`baseline_${t.kind}_${t.key}`);p(l=>({...l,[n]:o}))}catch(o){console.error(o)}finally{y(null)}}},ce=async()=>{if(!r||!s||!g)return;const n=`screening_${r}`;if(!(c[n]||u)){y(n);try{const o=await h({depression_lifetime:s.depression_history?.lifetime,depression_current:s.depression_history?.current,anxiety_lifetime:s.anxiety?.lifetime,mania_lifetime:s.mania_history?.lifetime,mania_current:s.mania_history?.current,trauma_lifetime:s.trauma?.lifetime,trauma_current:s.trauma?.current,substance_use_lifetime:s.substance_use?.lifetime,substance_use_current:s.substance_use?.current,eating_disorder_lifetime:s.eating_disorder?.lifetime,eating_disorder_current:s.eating_disorder?.current,compulsive_habits_lifetime:s.compulsive_habits?.lifetime,compulsive_habits_current:s.compulsive_habits?.current,obsessive_compulsions_lifetime:s.obsessive_compulsions?.lifetime,obsessive_compulsions_current:s.obsessive_compulsions?.current,chronic_pain_fatigue_lifetime:s.chronic_pain_fatigue?.lifetime,chronic_pain_fatigue_current:s.chronic_pain_fatigue?.current,social_sensitivity_lifetime:s.social_sensitivity?.lifetime,focus_difficulty_lifetime:s.focus_difficulty?.lifetime,aggression_lifetime:s.aggression?.lifetime,novelty_seeking_lifetime:s.novelty_seeking?.lifetime},r);p(l=>({...l,[n]:o}))}catch(o){console.error(o)}finally{y(null)}}},q=t?`${t.kind}_${t.key}`:"",M=r?`screening_${r}`:"",V=!!(b||s);return e.jsxs("div",{className:"min-h-[100dvh] flex flex-col bg-background",children:[e.jsx(Se,{}),e.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-8",children:e.jsxs("div",{className:"max-w-2xl mx-auto space-y-5",children:[e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground",children:"My Results"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your scores from the E360 Screen and Baseline."})]}),!V&&e.jsx(A,{className:"border-dashed",children:e.jsxs(L,{className:"p-5 text-sm text-muted-foreground",children:["You haven't completed the ",e.jsx("strong",{className:"text-foreground",children:"E360 Screen"})," or ",e.jsx("strong",{className:"text-foreground",children:"E360 Baseline"})," yet. Complete them from the home page to see your results here."]})}),(T||s)&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-sm text-foreground",children:[e.jsx(ze,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("span",{children:["Click any bar to see your ",e.jsx("strong",{children:"results, recommendations & AI insights"}),"."]})]}),s&&e.jsx(A,{children:e.jsxs(L,{className:"p-4 space-y-2",children:[e.jsx(E,{fieldId:"screen-graph",children:e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground font-semibold",children:"Your E360 Screen"})}),e.jsx(ke,{scores:s,onBarClick:n=>{f(n),m(null)},selectedSymptom:r??void 0})]})}),g&&e.jsx(A,{className:"border-l-4 border-l-primary",children:e.jsxs(L,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-base font-semibold text-foreground",children:g.title}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{fieldId:"lifetime-score",iconOnly:!0}),e.jsx("span",{className:"font-mono text-sm text-foreground",children:g.lifetimeScore.toFixed(1)}),e.jsx(F,{variant:"outline",children:g.lifetimeLabel})]})]}),(g.shortDefinition||g.longDefinition)&&(()=>{const n=`screen_${r}`,o=!!w[n],l=g.shortDefinition,d=g.longDefinition,_=!!d&&d!==l;return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"Definition"}
1),e.jsx("p",{className:"text-sm text-foreground/85 leading-relaxed",children:o&&_?d:l??d}),_&&e.jsx("button",{type:"button",onClick:()=>v(P=>({...P,[n]:!o})),className:"mt-1 text-xs text-primary hover:underline font-medium",children:o?"Show less":"Read more"})]})})(),e.jsxs("div",{children:[e.jsx(E,{fieldId:"lifetime-result",children:e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"Lifetime Result"})}),e.jsx(ee,{text:g.lifetimeResult,className:"text-[13px] text-foreground/85 leading-relaxed"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"Epiphany-based Recommendation"}),e.jsx(X,{text:g.epiphanyRecommendation,className:"text-[13px] text-foreground/85 leading-relaxed"})]}),g.currentRecommendation&&g.currentRecommendation!==g.epiphanyRecommendation&&e.jsxs("div",{children:[e.jsx(E,{fieldId:"current-recommendation",children:e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"This Week's Recommendation"})}),e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-sm text-foreground",children:g.currentScore.toFixed(1)}),e.jsx(F,{variant:"outline",children:g.currentLabel})]}),e.jsx(X,{text:g.currentRecommendation,className:"text-[13px] text-foreground/85 leading-relaxed"})]}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("button",{type:"button",onClick:()=>C(!0),className:"inline-flex items-center gap-1 text-[10px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1 hover:text-primary transition-colors",children:["AI Insight ",e.jsx(J,{className:"h-3 w-3"})]}),c[M]?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-foreground/85 leading-relaxed whitespace-pre-line",children:c[M]}),e.jsxs("div",{className:"mt-2 flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-foreground/75",children:[e.jsx(Q,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-600","aria-hidden":!0}),e.jsx("span",{children:"AI Insights reflect commonly reported language and may miss the correct clinical framing. Discuss any concerns with a qualified clinician."})]})]}):e.jsx(D,{size:"sm",variant:"outline",onClick:ce,disabled:u===M,className:"gap-2",children:u===M?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3 w-3 animate-spin"})," Generatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-3 w-3"})," Generate AI insight"]})})]})]})}),T&&e.jsx(A,{children:e.jsxs(L,{className:"p-4 space-y-2",children:[e.jsx(E,{fieldId:"baseline-graph",children:e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground font-semibold",children:"Your E360 Baseline"})}),e.jsx(_e,{positiveScores:T.pos,negativeScores:T.neg,onBarClick:n=>{const o=re.some(l=>l.key===n)?"positive":"negative";m({key:n,kind:o}),f(null)},selectedMetric:t?.key})]})}),S&&e.jsx(A,{className:"border-l-4 border-l-primary",children:e.jsxs(L,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-base font-semibold text-foreground",children:S.title}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{fieldId:"score",iconOnly:!0}),e.jsx("span",{className:"font-mono text-sm text-foreground",children:S.score.toFixed(1)}),e.jsx(F,{variant:"outline",children:S.label})]})]}),(S.shortDefinition||S.longDefinition)&&(()=>{const n=`base_${t?.kind}_${t?.key}`,o=!!w[n],l=S.shortDefinition,d=S.longDefinition,_=!!d&&d!==l&&d.length>240,P=l&&l.length>240?l.slice(0,240).trimEnd()+"â¦":l;return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"Definition"}),e.jsx("p",{className:"text-sm text-foreground/85 leading-relaxed",children:o?d??l:P??d}),(_||l&&l.length>240)&&e.jsx("button",{type:"button",onClick:()=>v(B=>({...B,[n]:!o})),className:"mt-1 text-xs text-primary hover:underline font-medium",children:o?"Show less":"Read more"})]})})(),e.jsxs("div",{children:[e.jsx(E,{fieldId:"result",children:e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"Result"})}),e.jsx(ee,{text:S.result,className:"text-[13px] text-foreground
1/85 leading-relaxed"})]}),e.jsxs("div",{children:[e.jsx(E,{fieldId:"recommendation",children:e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1",children:"Epiphany-based Recommendation"})}),e.jsx("p",{className:"text-[13px] text-foreground/85 leading-relaxed",children:S.recommendation})]}),e.jsxs("div",{className:"pt-1",children:[e.jsxs("button",{type:"button",onClick:()=>C(!0),className:"inline-flex items-center gap-1 text-[10px] uppercase tracking-[0.18em] text-muted-foreground font-semibold mb-1 hover:text-primary transition-colors",children:["AI Insight ",e.jsx(J,{className:"h-3 w-3"})]}),c[q]?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-foreground/85 leading-relaxed whitespace-pre-line",children:c[q]}),e.jsxs("div",{className:"mt-2 flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-foreground/75",children:[e.jsx(Q,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-600","aria-hidden":!0}),e.jsx("span",{children:"AI Insights reflect commonly reported language and may miss the correct clinical framing. Discuss any concerns with a qualified clinician."})]})]}):e.jsx(D,{size:"sm",variant:"outline",onClick:le,disabled:u===q,className:"gap-2",children:u===q?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"h-3 w-3 animate-spin"})," Generatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-3 w-3"})," Generate AI insight"]})})]})]})}),V&&e.jsxs("div",{className:"pt-4 text-center",children:[e.jsxs(D,{onClick:()=>{Ne.message("Come back next week to add your new data and watch your journey unfold.",{duration:6e3}),a("/dashboard/individual?live=1")},className:"gap-2",children:[e.jsx(O,{className:"h-4 w-4"})," Go to my dashboard â"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-2",children:"This is the early version of your personal dashboard. My E360 Journey will fill in as you add data over time."})]})]})}),e.jsx($e,{open:N,onOpenChange:C,children:e.jsxs(Ge,{className:"max-w-md",children:[e.jsx(Ye,{children:e.jsxs(Ke,{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-4 w-4 text-primary"})," About AI Insights"]})}),e.jsxs("div",{className:"space-y-3 text-sm text-foreground/85 pt-2",children:[e.jsx(Ue,{}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-primary/30 bg-primary/5 p-3",children:[e.jsx(we,{className:"h-4 w-4 text-primary shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-xs leading-relaxed",children:[e.jsx("strong",{className:"text-foreground",children:"Your PHI stays private."})," None of your personal health information is sent to, saved, transmitted, or stored in any large language model. Only de-identified numerical scores and clinical categories are used to generate the insight."]})]})]})]})}),e.jsx("footer",{className:"w-full px-4 py-4 border-t border-border/40 bg-background/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-2xl mx-auto flex justify-between items-center",children:[e.jsxs(D,{variant:"outline",onClick:()=>a(-1),children:[e.jsx(Ce,{className:"h-4 w-4 mr-2"})," Back"]}),e.jsxs(D,{onClick:()=>a("/my-report"),children:["Next ",e.jsx(Ve,{className:"h-4 w-4 ml-2"})]})]})})]})};export{$t as default};
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.