1import{j as e}from"./vendor-ui-apakGoHS.js";import{r as S,f as $o}from"./vendor-react-jvbcysPe.js";import"./vendor-data-8a2i1Wjw.js";function Co(n){if(!n||!n.startsWith("#")||n.length<7)return"239, 68, 68";const t=n.replace("#","");return`${parseInt(t.substring(0,2),16)}, ${parseInt(t.substring(2,4),16)}, ${parseInt(t.substring(4,6),16)}`}function Bo(n,t){const o=t||{},a=o.density||"default";return{domainColor:n,rgb:Co(n),bodyFont:o.fontFamily?`'${o.fontFamily}', sans-serif`:"'DM Sans', sans-serif",monoFont:"'JetBrains Mono', monospace",scale:o.textScale||1,pad:a==="compact"?.75:a==="spacious"?1.25:1}}const Eo={bmr:{bg:"rgba(239,68,68,0.05)",border:"rgba(239,68,68,0.10)",label:"#991B1B",value:"#EF4444"},activity:{bg:"rgba(59,130,246,0.05)",border:"rgba(59,130,246,0.10)",label:"#1E40AF",value:"#3B82F6"},tef:{bg:"rgba(245,158,11,0.05)",border:"rgba(245,158,11,0.10)",label:"#92400E",value:"#F59E0B"}},z={protein:"#16A34A",carbs:"#3B82F6",fat:"#F59E0B"},zo={slowCut:{bg:"rgba(22,163,74,0.05)",border:"rgba(22,163,74,0.10)",label:"#166534",value:"#16A34A"},aggressiveCut:{bg:"rgba(239,68,68,0.05)",border:"rgba(239,68,68,0.10)",label:"#991B1B",value:"#EF4444"},leanBulk:{bg:"rgba(59,130,246,0.05)",border:"rgba(59,130,246,0.10)",label:"#1E40AF",value:"#3B82F6"}},A=[{key:"sedentary",label:"Sedentary",desc:"Desk job, little exercise",multiplier:1.2},{key:"light",label:"Light",desc:"1-2 days/week",multiplier:1.375},{key:"moderate",label:"Moderate",desc:"3-5 days/week",multiplier:1.55},{key:"heavy",label:"Heavy",desc:"6-7 days/week",multiplier:1.725},{key:"athlete",label:"Athlete",desc:"2x per day",multiplier:1.9}],J={sex:"male",age:30,weight_lbs:190,height_ft:5,height_in:10,weight_kg:86.2,height_cm:177.8,activity:"moderate",body_fat_pct:0,goal:"maintain",macro_preset:"high_protein",unit_system:"imperial"},D=[{key:"high_protein",label:"High protein",pct:{protein:40,carbs:30,fat:30}},{key:"balanced",label:"Balanced",pct:{protein:30,carbs:40,fat:30}},{key:"low_carb",label:"Low carb",pct:{protein:35,carbs:25,fat:40}},{key:"keto",label:"Keto",pct:{protein:25,carbs:5,fat:70}}],L={cut:{label:"Lose fat",delta:-500,desc:"~1 lb/week",lbs_per_week:1},maintain:{label:"Maintain",delta:0,desc:"current weight",lbs_per_week:0},bulk:{label:"Build muscle",delta:300,desc:"lean gain",lbs_per_week:-.3}},co=[{label:"Essential",min:2,max:6,color:"#EF4444"},{label:"Athletic",min:6,max:14,color:"#3B82F6"},{label:"Fitness",min:14,max:18,color:"#16A34A"},{label:"Average",min:18,max:25,color:"#F59E0B"},{label:"Obese",min:25,max:50,color:"#EF4444"}],go=[{label:"Essential",min:10,max:14,color:"#EF4444"},{label:"Athletic",min:14,max:21,color:"#3B82F6"},{label:"Fitness",min:21,max:25,color:"#16A34A"},{label:"Average",min:25,max:32,color:"#F59E0B"},{label:"Obese",min:32,max:50,color:"#EF4444"}];function To(n){return S.useMemo(()=>{var no;const{sex:t,weight_lbs:o,height_ft:a,height_in:l,weight_kg:r,height_cm:s,activity:g,goal:h,macro_preset:c,unit_system:b}=n,m=Math.max(15,Math.min(100,n.age||30)),d=n.body_fat_pct>0?Math.max(2,Math.min(60,n.body_fat_pct)):0,f=o>0?o:150,y=r>0?r:68,v=a>0?a:5,_=l>=0?l:10,k=s>0?s:170,i=b==="imperial"?f*.453592:y,p=b==="imperial"?(v*12+_)*2.54:k,F=b==="imperial"?f:y*2.20462,$=p/100,u=Math.round(t==="male"?10*i+6.25*p-5*m+5:10*i+6.25*p-5*m-161),B=Math.round(t==="male"?13.397*i+4.799*p-5.677*m+88.362:9.247*i+3.098*p-4.33*m+447.593);let W=null,T=null;if(d>0){const M=i*(1-d/100);W=Math.round(370+21.6*M),T=Math.round(500+22*M)}const x=d>0?"katch":"msj",w=d>0?W:u,C=((no=A.find(M=>M.key===g))==null?void 0:no.multiplier)??1.55,E=Math.round(w*C),j={};for(const M of A)j[M.key]=Math.round(w*M.multiplier);const po=Math.round(E*.1),fo=E-w,N=Math.round(i/($*$)*10)/10,yo=N<18.5?"Underweight":N<25?"Normal":N<30?"Overweight":"Obese",Y=L[h].delta,R=Math.round(E+Y),bo=Math.abs(Y),H=D.find(M=>M.key===c)??D[0],U=Math.round(R*H.pct.protein/100),q=Math.round(R*H.pct.carbs/100),X=Math.round(R*H.pct.fat/100),Q=Math.round(U/4),uo=Math.round(q/4),xo=Math.round(X/9),mo=Math.round(Q/F*100)/100,vo=Math.round(R/4);let Z=null,oo=null,O=null,K=null,eo=null;if(d>0){O=Math.round(i*d/100*10)/10,K=Math.round((i-O)*10)/10,Z=Math.round(O*2.20462*10)/10,oo=Math.round(K*2.20462*10)/10;const M=t==="male"?co:go,G=M.find(lo=>d>=lo.min&&d<lo.max);eo=(G==null?void 0:G.label)??(d<M[0].min?M[0].label:M[M.length-1].label)}const ao=b==="imperial"?v*12+_:Math.round(p/2.54),ro=t==="male"?50+2.3*(ao-60):45.5+2.3*(ao-60),ho=Math.round(ro*2.20462),_o=Math.round(ro*10)/10,P=L[h].lbs_per_week,Fo=Math.round((F-P*4)*10)/10,jo=Math.round((F-P*8)*10)/10,ko=Math.round((F-P*12)*10)/10,So=Math.round(E-500),to=Math.round(E-1e3),wo=Math.round(E+300),Mo=to<(t==="female"?12
100:1500);return{weight_kg:Math.round(i*10)/10,height_cm:Math.round(p*10)/10,bmr_msj:u,bmr_harris:B,bmr_katch:W,bmr_cunningham:T,primary_bmr:w,primary_formula:x,tdee:E,tdee_by_activity:j,tef:po,activity_burn:fo,bmi:N,bmi_category:yo,goal_calories:R,goal_deficit:bo,protein_g:Q,carbs_g:uo,fat_g:xo,protein_cal:U,carbs_cal:q,fat_cal:X,protein_per_lb:mo,meals_per_day_cal:vo,fat_mass_lbs:Z,lean_mass_lbs:oo,fat_mass_kg:O,lean_mass_kg:K,bf_category:eo,ideal_weight_lbs:ho,ideal_weight_kg:_o,weight_4wk:Fo,weight_8wk:jo,weight_12wk:ko,slow_cut_cal:So,aggressive_cut_cal:to,lean_bulk_cal:wo,aggressive_cut_warning:Mo}},[n])}function Wo({tdee:n,formulaName:t,activityLabel:o,theme:a}){var h;const[l,r]=S.useState(n),s=S.useRef(n),g=typeof window<"u"&&((h=window.matchMedia)==null?void 0:h.call(window,"(prefers-reduced-motion: reduce)").matches);return S.useEffect(()=>{if(g||s.current===n){r(n),s.current=n;return}const c=s.current,b=n-c,m=performance.now(),d=400,f=y=>{const v=Math.min((y-m)/d,1),_=1-Math.pow(1-v,3);r(Math.round(c+b*_)),v<1&&requestAnimationFrame(f)};requestAnimationFrame(f),s.current=n},[n,g]),e.jsxs("div",{style:{textAlign:"center",padding:`${20*a.pad}px ${16*a.pad}px`},"aria-live":"polite",children:[e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:12*a.scale,color:"var(--muted-foreground)",marginBottom:4},children:"Your daily energy expenditure"}),e.jsx("div",{style:{fontFamily:a.monoFont,fontSize:52*a.scale,fontWeight:500,color:a.domainColor,lineHeight:1},children:l.toLocaleString()}),e.jsxs("div",{style:{fontFamily:a.bodyFont,fontSize:13*a.scale,color:"var(--muted-foreground)",marginTop:6,display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexWrap:"wrap"},children:[e.jsx("span",{children:"calories/day"}),e.jsx("span",{children:"·"}),e.jsx("span",{children:o}),e.jsx("span",{style:{background:`rgba(${a.rgb}, 0.08)`,color:a.domainColor,fontSize:11*a.scale,fontWeight:600,padding:"2px 8px",borderRadius:6},children:t})]})]})}function Ao({bmr:n,activityBurn:t,bmi:o,bmiCategory:a,theme:l}){const r=[{key:"bmr",label:"Where your energy goes",value:n.toLocaleString(),desc:"burned just existing (BMR)"},{key:"activity",label:"Movement adds",value:`+${t.toLocaleString()}`,desc:"exercise + daily activity"},{key:"tef",label:"BMI",value:String(o),desc:a}];return e.jsx("div",{style:{display:"flex",gap:6*l.pad,padding:`0 ${16*l.pad}px ${12*l.pad}px`,flexWrap:"wrap"},children:r.map(s=>{const g=Eo[s.key];return e.jsxs("div",{style:{flex:"1 1 170px",background:g.bg,border:`1px solid ${g.border}`,borderRadius:8,padding:`${8*l.pad}px ${12*l.pad}px`},children:[e.jsx("div",{style:{fontFamily:l.bodyFont,fontSize:11*l.scale,fontWeight:700,textTransform:"uppercase",color:g.label,letterSpacing:"0.04em"},children:s.label}),e.jsx("div",{style:{fontFamily:l.monoFont,fontSize:18*l.scale,fontWeight:700,color:g.value},children:s.value}),e.jsx("div",{style:{fontFamily:l.bodyFont,fontSize:12*l.scale,color:"var(--muted-foreground)"},children:s.desc})]},s.key)})})}const io=[{key:"BMR",color:"#EF4444"},{key:"Activity",color:"#3B82F6"},{key:"TEF",color:"#F59E0B"}];function Lo({bmr:n,activityBurn:t,tef:o,theme:a}){const l=n+t+o,r=[n,t,o];return e.jsxs("div",{style:{padding:`0 ${16*a.pad}px ${14*a.pad}px`},children:[e.jsx("div",{style:{display:"flex",height:8,borderRadius:4,overflow:"hidden"},children:io.map((s,g)=>e.jsx("div",{style:{flex:l>0?r[g]/l:1,backgroundColor:s.color,transition:"flex 0.3s ease"}},s.key))}),e.jsx("div",{style:{display:"flex",gap:14,marginTop:8,justifyContent:"center",flexWrap:"wrap"},children:io.map((s,g)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,backgroundColor:s.color,flexShrink:0}}),e.jsx("span",{style:{fontFamily:a.bodyFont,fontSize:12*a.scale,color:"var(--muted-foreground)"},children:s.key}),e.jsx("span",{style:{fontFamily:a.monoFont,fontSize:12*a.scale,fontWeight:600,color:"var(--foreground)"},children:r[g].toLocaleString()})]},s.key))})]})}const Ro=["cut","maintain","bulk"];function Io({goal:n,goalCalories:t,goalDeficit:o,onGoalChange:a,theme:l}){const r=L[n];return e.jsxs("div",{style:{padding:`0 ${16*l.pad}px ${14*l.pad}px`},children:[e.jsx("div",{style:{display:"flex",gap:6,marginBottom:10},children:Ro.map(s=>{const g=s===n;return e.jsx("button",{onClick:()=>a(s),style:{flex:1,padding:`${6*l.pad}px ${10*l.pad}px`,borderRadius:8,cursor:"pointer",background:g?`rgba(${l.rgb}, 0.08)`:"var(--muted)",border:`1px solid ${g?`rgba(${l.rgb}, 0.3)`:"var(--border)"}`,color:g?l.domainColor:"var(--muted-foreground)",fontFamily:l.bodyFont,fontSize:12*l.scale,fontWeight:g?600:400,transition:"all 150ms ease"},children:L[s].label},s)})}),e.jsxs("div",{style:{background:`rgba(${l.rgb}, 0.04)`,border:`1px solid rgba(${l.rgb}, 0.1)`,borderRadius:10,padding:`${12*l.pad}px`,textAlign:"center"},children:[e.jsx("div",{style:{fontFamily:l.bodyFont,fontSize:12*l.scale,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--muted-foreground)"},children:"Target intake"}),e.jsx("div",{style:{fontFamily:l.monoFont,fontSize:24*l.scale,fontWeight:600,color:l.domainColor}
1,children:t.toLocaleString()}),e.jsxs("div",{style:{fontFamily:l.bodyFont,fontSize:12*l.scale,color:"var(--muted-foreground)"},children:["cal/day · ",r.desc,o>0?` (${n==="bulk"?"+":"-"}${o})`:""]})]})]})}function Do({currentActivity:n,tdeeByActivity:t,theme:o}){return e.jsxs("div",{style:{padding:`0 ${16*o.pad}px ${16*o.pad}px`},children:[e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--muted-foreground)",marginBottom:8},children:"TDEE by activity level"}),e.jsx("div",{style:{borderRadius:8,overflow:"hidden",border:"1px solid var(--border)"},children:A.map((a,l)=>{const r=a.key===n;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:`${7*o.pad}px ${12*o.pad}px`,borderBottom:l<A.length-1?"0.5px solid var(--border)":"none",background:r?`rgba(${o.rgb}, 0.04)`:"transparent"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontFamily:o.bodyFont,fontSize:13*o.scale,fontWeight:r?600:400,color:r?o.domainColor:"var(--foreground)"},children:a.label}),e.jsx("span",{style:{fontFamily:o.bodyFont,fontSize:11*o.scale,color:"var(--muted-foreground)",marginLeft:6},children:a.desc})]}),e.jsx("span",{style:{fontFamily:o.monoFont,fontSize:13*o.scale,fontWeight:r?600:400,color:r?o.domainColor:"var(--foreground)"},children:t[a.key].toLocaleString()})]},a.key)})})]})}function I({label:n,value:t,min:o,max:a,step:l,sliderStep:r,suffix:s,displayFormat:g,parseInput:h,theme:c,onChange:b}){const[m,d]=S.useState(null),f=S.useRef(null),y=m!==null,v=i=>Math.min(a,Math.max(o,i)),_=S.useCallback(()=>{if(m===null)return;const i=h(m);b(v(isNaN(i)?t:i)),d(null)},[m,h,o,a,t,b]),k={padding:"6px 10px",background:"var(--card)",color:"var(--muted-foreground)",fontSize:16,cursor:"pointer",border:"none",lineHeight:1,fontFamily:c.monoFont,fontWeight:500,userSelect:"none"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13*c.scale,fontWeight:500,fontFamily:c.bodyFont,color:"var(--foreground)",marginBottom:4},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"center",borderRadius:8,overflow:"hidden",border:y?`2px solid ${c.domainColor}`:`1.5px solid rgba(${c.rgb}, 0.25)`,transition:"border-color 150ms ease"},children:[e.jsx("button",{onClick:()=>b(v(t-l)),style:{...k,borderRight:"0.5px solid var(--border)"},"aria-label":`Decrease ${n}`,children:"â"}),e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--card)",padding:"6px 4px",minWidth:0},children:[e.jsx("input",{ref:f,type:"text",inputMode:"decimal",value:y?m:g(t),onFocus:()=>d(String(t)),onChange:i=>d(i.target.value),onBlur:_,onKeyDown:i=>{var p;i.key==="Enter"&&(_(),(p=f.current)==null||p.blur())},style:{fontSize:14*c.scale,fontWeight:500,fontFamily:c.monoFont,color:"var(--foreground)",border:"none",outline:"none",backgroundColor:"transparent",textAlign:"center",width:"100%",minWidth:0},"aria-label":n}),s&&!y&&e.jsx("span",{style:{fontSize:11*c.scale,color:"var(--muted-foreground)",marginLeft:2,flexShrink:0,fontFamily:c.bodyFont},children:s})]}),e.jsx("button",{onClick:()=>b(v(t+l)),style:{...k,borderLeft:"0.5px solid var(--border)"},"aria-label":`Increase ${n}`,children:"+"})]}),e.jsx("input",{type:"range",min:o,max:a,step:r||l,value:t,onChange:i=>b(Number(i.target.value)),className:"w-full",style:{accentColor:c.domainColor,marginTop:4},"aria-label":n})]})}function No({ft:n,inches:t,theme:o,onFtChange:a,onInChange:l}){const r=n*12+t,[s,g]=S.useState(null),h=S.useRef(null),c=s!==null,b=f=>{const y=Math.min(84,Math.max(48,f));a(Math.floor(y/12)),l(y%12)},m=S.useCallback(()=>{if(s===null)return;const f=s.match(/(\d+)['\s.](\d+)/);if(f)b(parseInt(f[1])*12+parseInt(f[2]));else{const y=parseInt(s);isNaN(y)||(y>12?b(y):b(y*12))}g(null)},[s,a,l]),d={padding:"6px 10px",background:"var(--card)",color:"var(--muted-foreground)",fontSize:16,cursor:"pointer",border:"none",lineHeight:1,fontFamily:o.monoFont,fontWeight:500,userSelect:"none"};return e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13*o.scale,fontWeight:500,fontFamily:o.bodyFont,color:"var(--foreground)",marginBottom:4},children:"Height"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",borderRadius:8,overflow:"hidden",border:c?`2px s
1olid ${o.domainColor}`:`1.5px solid rgba(${o.rgb}, 0.25)`,transition:"border-color 150ms ease"},children:[e.jsx("button",{onClick:()=>b(r-1),style:{...d,borderRight:"0.5px solid var(--border)"},"aria-label":"Decrease height",children:"â"}),e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--card)",padding:"6px 4px"},children:e.jsx("input",{ref:h,type:"text",inputMode:"numeric",value:c?s:`${n}'${t}"`,onFocus:()=>g(`${n}'${t}`),onChange:f=>g(f.target.value),onBlur:m,onKeyDown:f=>{var y;f.key==="Enter"&&(m(),(y=h.current)==null||y.blur())},style:{fontSize:14*o.scale,fontWeight:500,fontFamily:o.monoFont,color:"var(--foreground)",border:"none",outline:"none",backgroundColor:"transparent",textAlign:"center",width:"100%"},"aria-label":"Height"})}),e.jsx("button",{onClick:()=>b(r+1),style:{...d,borderLeft:"0.5px solid var(--border)"},"aria-label":"Increase height",children:"+"})]}),e.jsx("input",{type:"range",min:48,max:84,step:1,value:r,onChange:f=>b(Number(f.target.value)),className:"w-full",style:{accentColor:o.domainColor,marginTop:4},"aria-label":"Height"})]})}function Oo({inputs:n,onInputChange:t,theme:o}){const a=r=>{if(r!==n.unit_system)if(r==="metric")t("unit_system","metric"),t("weight_kg",Math.round(n.weight_lbs*.453592*10)/10),t("height_cm",Math.round((n.height_ft*12+n.height_in)*2.54*10)/10);else{t("unit_system","imperial"),t("weight_lbs",Math.round(n.weight_kg*2.20462));const s=Math.round(n.height_cm/2.54);t("height_ft",Math.floor(s/12)),t("height_in",s%12)}},l=r=>({padding:`${6*o.pad}px ${14*o.pad}px`,borderRadius:8,cursor:"pointer",border:r?`1px solid rgba(${o.rgb}, 0.3)`:"1.5px solid var(--border)",background:r?`rgba(${o.rgb}, 0.08)`:"var(--muted)",color:r?o.domainColor:"var(--foreground)",fontFamily:o.bodyFont,fontSize:13*o.scale,fontWeight:r?600:500,transition:"all 150ms ease"});return e.jsxs("div",{style:{background:"var(--muted)",borderTop:"1px solid var(--border)",padding:`${14*o.pad}px ${16*o.pad}px`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:12*o.pad},children:[["male","female"].map(r=>e.jsx("button",{onClick:()=>t("sex",r),style:l(n.sex===r),children:r==="male"?"Male":"Female"},r)),e.jsx("div",{style:{flex:1}}),["imperial","metric"].map(r=>e.jsx("button",{onClick:()=>a(r),style:{...l(n.unit_system===r),fontSize:11*o.scale,padding:`${4*o.pad}px ${10*o.pad}px`},children:r==="imperial"?"Imperial":"Metric"},r))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:10,marginBottom:12*o.pad},children:[e.jsx(I,{label:"Age",value:n.age,min:15,max:100,step:1,displayFormat:r=>String(Math.round(r)),parseInput:r=>Math.round(Number(r.replace(/[^0-9]/g,""))),theme:o,onChange:r=>t("age",r)}),n.unit_system==="imperial"?e.jsx(I,{label:"Weight",value:n.weight_lbs,min:80,max:400,step:5,sliderStep:1,suffix:"lbs",displayFormat:r=>String(Math.round(r)),parseInput:r=>Math.round(Number(r.replace(/[^0-9.-]/g,""))),theme:o,onChange:r=>t("weight_lbs",r)}):e.jsx(I,{label:"Weight",value:Math.round(n.weight_kg),min:36,max:180,step:2,sliderStep:1,suffix:"kg",displayFormat:r=>String(Math.round(r)),parseInput:r=>Math.round(Number(r.replace(/[^0-9.-]/g,""))),theme:o,onChange:r=>t("weight_kg",r)}),n.unit_system==="imperial"?e.jsx(No,{ft:n.height_ft,inches:n.height_in,theme:o,onFtChange:r=>t("height_ft",r),onInChange:r=>t("height_in",r)}):e.jsx(I,{label:"Height",value:Math.round(n.height_cm),min:120,max:220,step:2,sliderStep:1,suffix:"cm",displayFormat:r=>String(Math.round(r)),parseInput:r=>Math.round(Number(r.replace(/[^0-9.-]/g,""))),theme:o,onChange:r=>t("height_cm",r)}),e.jsx(I,{label:"Body fat",value:n.body_fat_pct,min:0,max:60,step:1,suffix:"%",displayFormat:r=>r===0?"â":String(Math.round(r)),parseInput:r=>{const s=Number(r.replace(/[^0-9.-]/g,""));return isNaN(s)?0:Math.round(s)},theme:o,onChange:r=>t("body_fat_pct",r)})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:4},children:A.map(r=>e.jsx("button",{onClick:()=>t("activity",r.key),style:{...l(n.activity===r.key),textAlign:"center",padding:`${7*o.pad}px ${4*o.pad}px`},children:r.label},r.key))})]})}function Ho({results:n,inputs:t,onInputChange:o,theme:a}){const{protein_g:l,carbs_g:r,fat_g:s,protein_cal:g,carbs_cal:h,fat_cal:c,goal_calories:b,protein_per_lb:m,meals_per_day_cal:d}=n,f=D.find(u=>u.key===t.macro_preset)??D[0],y=L[t.goal].label,v=g+h+c,_=v>0?g/v:.33,k=v>0?h/v:.33,i=2*Math.PI*50,p=i*_,F=i*k,$=i*(1-_-k);return e.jsxs("div",{style:{padding:`${16*a.pad}px`},children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:16*a.pad},children:[e.jsxs("div",{style:{fontFamily:a.bodyFont,fontSize:12*a.scale,color:"var(--muted-foreground)"},children:["Daily macro split · ",y]}),e.jsx("div",{style:{fontFamily:a.monoFont,fontSize:36*a.scale,fontWeight:500,color:a.domainColor}
1,children:b.toLocaleString()}),e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:12*a.scale,color:"var(--muted-foreground)"},children:"calories/day"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:24*a.pad,flexWrap:"wrap",marginBottom:16*a.pad},children:[e.jsxs("svg",{width:150,height:150,viewBox:"0 0 120 120","aria-label":"Macro split donut chart showing protein, carbs, and fat proportions",role:"img",children:[e.jsx("circle",{cx:"60",cy:"60",r:"50",fill:"none",stroke:z.protein,strokeWidth:"12",strokeDasharray:`${p} ${i-p}`,strokeDashoffset:i*.25}),e.jsx("circle",{cx:"60",cy:"60",r:"50",fill:"none",stroke:z.carbs,strokeWidth:"12",strokeDasharray:`${F} ${i-F}`,strokeDashoffset:i*.25-p}),e.jsx("circle",{cx:"60",cy:"60",r:"50",fill:"none",stroke:z.fat,strokeWidth:"12",strokeDasharray:`${$} ${i-$}`,strokeDashoffset:i*.25-p-F}),e.jsxs("text",{x:"60",y:"56",textAnchor:"middle",style:{fontFamily:a.monoFont,fontSize:14,fontWeight:600,fill:"var(--foreground)"},children:[f.pct.protein,"/",f.pct.carbs,"/",f.pct.fat]}),e.jsx("text",{x:"60",y:"70",textAnchor:"middle",style:{fontFamily:a.bodyFont,fontSize:10,fill:"var(--muted-foreground)"},children:"P / C / F"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[{label:"Protein",g:l,cal:g,color:z.protein},{label:"Carbs",g:r,cal:h,color:z.carbs},{label:"Fat",g:s,cal:c,color:z.fat}].map(u=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:2,backgroundColor:u.color,flexShrink:0}}),e.jsx("span",{style:{fontFamily:a.bodyFont,fontSize:13*a.scale,color:"var(--foreground)",minWidth:55},children:u.label}),e.jsxs("span",{style:{fontFamily:a.monoFont,fontSize:13*a.scale,fontWeight:600,color:"var(--foreground)"},children:[u.g,"g"]}),e.jsxs("span",{style:{fontFamily:a.monoFont,fontSize:11*a.scale,color:"var(--muted-foreground)"},children:[u.cal," cal"]})]},u.label))})]}),e.jsx("div",{style:{display:"flex",gap:6,marginBottom:14*a.pad,flexWrap:"wrap"},children:D.map(u=>{const B=u.key===t.macro_preset;return e.jsx("button",{onClick:()=>o("macro_preset",u.key),style:{flex:"1 1 80px",padding:`${6*a.pad}px ${10*a.pad}px`,borderRadius:8,cursor:"pointer",background:B?`rgba(${a.rgb}, 0.08)`:"var(--muted)",border:`1px solid ${B?`rgba(${a.rgb}, 0.3)`:"var(--border)"}`,color:B?a.domainColor:"var(--muted-foreground)",fontFamily:a.bodyFont,fontSize:12*a.scale,fontWeight:B?600:400,transition:"all 150ms ease"},children:u.label},u.key)})}),e.jsx("div",{style:{background:`rgba(${a.rgb}, 0.04)`,border:`1px solid rgba(${a.rgb}, 0.1)`,borderRadius:10,padding:14*a.pad,marginBottom:14*a.pad},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:8,textAlign:"center"},children:[{label:"Protein",value:`${l}g`,color:z.protein},{label:"Carbs",value:`${r}g`,color:z.carbs},{label:"Fat",value:`${s}g`,color:z.fat}].map(u=>e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:11*a.scale,fontWeight:700,textTransform:"uppercase",color:"var(--muted-foreground)",letterSpacing:"0.04em"},children:u.label}),e.jsx("div",{style:{fontFamily:a.monoFont,fontSize:16*a.scale,fontWeight:600,color:u.color},children:u.value})]},u.label))})}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:"1 1 150px",background:"rgba(22,163,74,0.05)",border:"1px solid rgba(22,163,74,0.1)",borderRadius:8,padding:`${8*a.pad}px ${12*a.pad}px`},children:[e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:11*a.scale,fontWeight:700,textTransform:"uppercase",color:"#166534",letterSpacing:"0.04em"},children:"Protein per lb"}),e.jsxs("div",{style:{fontFamily:a.monoFont,fontSize:18*a.scale,fontWeight:700,color:"#16A34A"},children:[m,"g"]}),e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:12*a.scale,color:"var(--muted-foreground)"},children:"per lb bodyweight"})]}),e.jsxs("div",{style:{flex:"1 1 150px",background:"rgba(59,130,246,0.05)",border:"1px solid rgba(59,130,246,0.1)",borderRadius:8,padding:`${8*a.pad}px ${12*a.pad}px`},children:[e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:11*a.scale,fontWeight:700,textTransform:"uppercase",color:"#1E40AF",letterSpacing:"0.04em"},children:"Meals at 4/day"}),e.jsxs("div",{style:{fontFamily:a.monoFont,fontSize:18*a.scale,fontWeight:700,color:"#3B82F6"},children:[d," cal"]}
1),e.jsx("div",{style:{fontFamily:a.bodyFont,fontSize:12*a.scale,color:"var(--muted-foreground)"},children:"per meal target"})]})]})]})}function Ko({results:n,inputs:t,theme:o}){if(t.body_fat_pct<=0)return e.jsxs("div",{style:{padding:40*o.pad,textAlign:"center"},children:[e.jsx("div",{style:{fontFamily:o.monoFont,fontSize:36*o.scale,marginBottom:12},children:"ðï¸"}),e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:16*o.scale,fontWeight:600,color:"var(--foreground)",marginBottom:8},children:"Body composition analysis"}),e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:14*o.scale,color:"var(--muted-foreground)"},children:"Enter your body fat % in the inputs below to unlock lean mass, fat mass, category analysis, and goal projection."})]});const{fat_mass_lbs:a,lean_mass_lbs:l,fat_mass_kg:r,lean_mass_kg:s,bf_category:g,bmi:h,bmi_category:c,ideal_weight_lbs:b,ideal_weight_kg:m}=n,d=t.unit_system==="imperial",f=d?`${a} lbs`:`${r} kg`,y=d?`${l} lbs`:`${s} kg`,v=d?`${b} lbs`:`${m} kg`,_=t.sex==="male"?co:go,k=t.sex==="male"?15:22,i=r??0,$=(s??0)/(1-k/100)*k/100,u=i-$,B=Math.round(u*2.20462*10)/10,W=Math.round(B),T=t.body_fat_pct<=k,x=_[0].min,w=_[_.length-1].max,C=Math.max(0,Math.min(100,(t.body_fat_pct-x)/(w-x)*100)),E=100-t.body_fat_pct;return e.jsxs("div",{style:{padding:`${16*o.pad}px`},children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:16*o.pad},children:[e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,color:"var(--muted-foreground)"},children:"Body composition estimate"}),e.jsxs("div",{style:{fontFamily:o.monoFont,fontSize:36*o.scale,fontWeight:500,color:o.domainColor},children:[t.body_fat_pct,"%"]}),e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,color:"var(--muted-foreground)"},children:"body fat"})]}),e.jsxs("div",{style:{display:"flex",gap:20*o.pad,alignItems:"center",justifyContent:"center",flexWrap:"wrap",marginBottom:16*o.pad},children:[e.jsxs("div",{style:{width:80,height:200,borderRadius:16,border:`2px solid rgba(${o.rgb}, 0.3)`,overflow:"hidden",display:"flex",flexDirection:"column",flexShrink:0},children:[e.jsx("div",{style:{flex:E,backgroundColor:"#3B82F6",transition:"flex 0.3s ease"}}),e.jsx("div",{style:{flex:t.body_fat_pct,backgroundColor:`rgba(${o.rgb}, 0.4)`,transition:"flex 0.3s ease"}})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[{label:"Fat mass",value:f,color:o.domainColor},{label:"Lean mass",value:y,color:"#3B82F6"},{label:"BMI",value:`${h} · ${c}`,color:"var(--foreground)"},{label:"Ideal weight",value:`${v} (Devine)`,color:"var(--foreground)"}].map(j=>e.jsxs("div",{children:[e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:11*o.scale,color:"var(--muted-foreground)",textTransform:"uppercase",fontWeight:700,letterSpacing:"0.04em"},children:j.label}),e.jsx("div",{style:{fontFamily:o.monoFont,fontSize:15*o.scale,fontWeight:600,color:j.color},children:j.value})]},j.label))})]}),e.jsxs("div",{style:{marginBottom:16*o.pad},children:[e.jsx("div",{style:{display:"flex",height:10,borderRadius:5,overflow:"hidden",position:"relative"},children:_.map(j=>e.jsx("div",{style:{flex:j.max-j.min,backgroundColor:j.color,opacity:.5}},j.label))}),e.jsx("div",{style:{position:"relative",height:16},children:e.jsx("span",{style:{position:"absolute",left:`${C}%`,transform:"translateX(-50%)",fontSize:12,color:o.domainColor,fontWeight:700},children:"â²"})}),e.jsx("div",{style:{display:"flex"},children:_.map(j=>e.jsx("div",{style:{flex:j.max-j.min,textAlign:"center",fontFamily:o.bodyFont,fontSize:10*o.scale,color:g===j.label?o.domainColor:"var(--muted-foreground)",fontWeight:g===j.label?700:400},children:j.label},j.label))})]}),e.jsxs("div",{style:{background:`rgba(${o.rgb}, 0.04)`,border:`1px solid rgba(${o.rgb}, 0.1)`,borderRadius:10,padding:14*o.pad},children:[e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,fontWeight:700,textTransform:"uppercase",color:"var(--muted-foreground)",letterSpacing:"0.04em",marginBottom:6},children:"Goal projection"}),T?e.jsxs("div",{style:{fontFamily:o.bodyFont,fontSize:13*o.scale,color:"#16A34A",fontWeight:600},children:["You're already at or below the ",k,"% fitness target. Focus on maintaining lean mass and performance."]}):e.jsxs("div",{style:{fontFamily:o.bodyFont,fontSize:13*o.scale,color:"var(--foreground)",lineHeight:1.6},children:["To reach ",e.jsxs("strong",{style:{fontFamily:o.monoFont},children:[k,"%"]})," body fat, you'd need to lose ~",e.jsxs("strong",{style:{fontFamily:o.monoFont},children:[B," lbs"]})," of fat while maintaining lean mass. At a 500 cal/day deficit, that's roughly ",e.jsxs("strong",{style:{fontFamily:o.monoFont},children:[W," weeks"]}),"."]})]})]})}function Po({results:n,inputs:t,theme:o}){const{bmr_msj:a,bmr_harris:l,bmr_katch:r,bmr_cunningham:s,primary_formula:g,slow_cut_cal:h,aggressive_cut_cal:c,lean_bulk_cal:b,weight_4wk:m,weight_8wk:d,weight_12wk:f,aggressive_cut_warning:y}=n,v=t.unit_system==="imperial",_=v?t.weight_lbs:Math.round(t.weight_kg*2.20462),k=L[t.goal].label,i=[{name:"Mifflin-St Jeor",value:a,key:"msj"},{name:"Harris-Benedict",value:l,key:"harris"},{name:"Katch-McArdle",value:r,key:"katch"},{name:"Cunningham",value:s,key:"cunningham"}],p=i.map(x=>x.value).filter(x=>x!==null),F=Math.min(...p),$=Math.max(...p),u=$-F,B=t.sex==="female"?12
100:1500,W=[{key:"slowCut",label:"Slow cut",cal:h,desc:"~1 lb/week",delta:"-500"},{key:"aggressiveCut",label:"Aggressive cut",cal:c,desc:"~2 lb/week",delta:"-1000"},{key:"leanBulk",label:"Lean bulk",cal:b,desc:"lean gain",delta:"+300"}],T=[{label:"Now",value:v?`${_} lbs`:`${t.weight_kg} kg`},{label:"4 weeks",value:v?`${m} lbs`:`${Math.round(m*.453592*10)/10} kg`},{label:"8 weeks",value:v?`${d} lbs`:`${Math.round(d*.453592*10)/10} kg`},{label:"12 weeks",value:v?`${f} lbs`:`${Math.round(f*.453592*10)/10} kg`}];return e.jsxs("div",{style:{padding:`${16*o.pad}px`},children:[e.jsxs("div",{style:{marginBottom:16*o.pad},children:[e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--muted-foreground)",marginBottom:8},children:"BMR formula comparison"}),e.jsxs("div",{style:{borderRadius:8,overflow:"hidden",border:"1px solid var(--border)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:`${6*o.pad}px ${12*o.pad}px`,background:"var(--muted)",fontFamily:o.bodyFont,fontSize:11*o.scale,fontWeight:700,textTransform:"uppercase",color:"var(--muted-foreground)"},children:[e.jsx("span",{children:"Formula"}),e.jsx("span",{children:"BMR"})]}),i.map((x,w)=>{const C=x.key===g;return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:`${7*o.pad}px ${12*o.pad}px`,borderBottom:w<i.length-1?"0.5px solid var(--border)":"none",background:C?`rgba(${o.rgb}, 0.04)`:"transparent"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontFamily:o.bodyFont,fontSize:13*o.scale,fontWeight:C?600:400,color:C?o.domainColor:"var(--foreground)"},children:x.name}),C&&e.jsx("span",{style:{fontSize:10*o.scale,background:`rgba(${o.rgb}, 0.08)`,color:o.domainColor,padding:"1px 6px",borderRadius:4,fontWeight:600,fontFamily:o.bodyFont},children:"primary"})]}),e.jsx("span",{style:{fontFamily:o.monoFont,fontSize:13*o.scale,fontWeight:C?600:400,color:C?o.domainColor:"var(--foreground)"},children:x.value!==null?x.value.toLocaleString():"â"})]},x.key)})]}),e.jsxs("div",{style:{fontFamily:o.bodyFont,fontSize:11*o.scale,color:"var(--muted-foreground)",marginTop:6},children:["Range: ",F.toLocaleString(),"â",$.toLocaleString()," cal/day (",u," cal spread)",!r&&" · Enter body fat % to see Katch-McArdle & Cunningham"]})]}),e.jsx("div",{style:{display:"flex",gap:6,marginBottom:16*o.pad,flexWrap:"wrap"},children:W.map(x=>{const w=zo[x.key];return e.jsxs("div",{style:{flex:"1 1 150px",background:w.bg,border:`1px solid ${w.border}`,borderRadius:8,padding:`${8*o.pad}px ${12*o.pad}px`},children:[e.jsx("div",{style:{fontFamily:o.bodyFont,fontSize:11*o.scale,fontWeight:700,textTransform:"uppercase",color:w.label,letterSpacing:"0.04em"},children:x.label}),e.jsxs("div",{style:{fontFamily:o.monoFont,fontSize:18*o.scale,fontWeight:700,color:w.value},children:[x.cal.toLocaleString(),x.key==="aggressiveCut"&&y&&e.jsx("span",{style:{fontSize:12*o.scale,marginLeft:4},children:"â ï¸"})]}),e.jsxs("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,color:"var(--muted-foreground)"},children:[x.desc," (",x.delta,")"]}),x.key==="aggressiveCut"&&y&&e.jsxs("div",{style:{fontFamily:o.bodyFont,fontSize:10*o.scale,color:w.value,marginTop:4,fontWeight:600},children:["below safe minimum (",B,")"]})]},x.key)})}),e.jsxs("div",{style:{background:`rgba(${o.rgb}, 0.04)`,border:`1px solid rgba(${o.rgb}, 0.1)`,borderRadius:10,padding:14*o.pad},children:[e.jsxs("div",{style:{fontFamily:o.bodyFont,fontSize:12*o.scale,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--muted-foreground)",marginBottom:8},children:["Weight projection (",k,")"]}),T.map((x,w)=>{const C=w===T.length-1,E=C?t.goal==="bulk"?"#3B82F6":t.goal==="cut"?"#16A34A":"var(--foreground)":"var(--foreground)";return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:`${5*o.pad}px 0`,borderBottom:w<T.length-1?"0.5px solid var(--border)":"none"},children:[e.jsx("span",{style:{fontFamily:o.bodyFont,fontSize:13*o.scale,color:"var(--muted-foreground)"},children:x.label}),e.jsx("span",{style:{fontFamily:o.monoFont,fontSize:13*o.scale,fontWeight:C?600:400,color:E},children:x.value})]},x.label)})]})]})}const so=[{key:"calculate",label:"Calculate"},{key:"macros",label:"Macros"},{key:"bodycomp",label:"Body Comp"},{key:"compare",label:"Compare"}],V="procalc_tdee_inputs";function Uo({domainColor:n,calculator:t}){var k;const o=S.useMemo(()=>Bo(n||"#EF4444",t==null?void 0:t.style_overrides),[n,t==null?void 0:t.style_overrides]),[a,l]=$o(),r=a.get("tab"),[s,g]=S.useState(r&&so.some(i=>i.key===r)?r:"calculate"),h="v2",[c,b]=S.useState(()=>{try{const i=localStorage.getItem(V);if(i){const p=JSON.parse(i);return p._v!==h?(localStorage.removeItem(V),{...J}):{...J,...p}}}catch{}return{...J}}),m=S.useRef();S.useEffect(()=>(clearTimeout(m.current),m.current=setTimeout(()=>{localStorage.setItem(V,JSON.stringify({...c,_v:h}))},500),()=>clearTimeout(m.current)),[c]);const d=To(c),f=S.useCallback(i=>{g(i),l(i==="calculate"?{}:{tab:i},{replace:!0})},[l]),y=S.useCallback((i,p)=>{b(F=>({...F,[i]:p}))},[]),v=d.primary_formula==="katch"?"Katch-McArdle":d.primary_formula==="harris"?"Harris-Benedict":d.primary_formula==="cunningham"?"Cunningham":"Mifflin-St Jeor",_=((k=A.find(i=>i.key===c.activity))==null?void 0:k.label)??"Moderate";return S.useEffect(()=>{const i={"@context":"https://schema.org","@type":"SoftwareApplication",name:"TDEE Calculator with Macros & Body Composition",applicationCategory:"CalculatorApplication",operatingSystem:"Web",description:"Calculate your Total Daily Energy Expenditure (TDEE), plan macros, analyze body composition, and compare BMR formulas.",url:"https://procalc.ai/health/tdee",featureList:"TDEE calculation, BMR comparison (4 formulas), macro planning, body composition analysis, goal scenarios"},p={"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:"https://procalc.ai"},{"@type":"ListItem",position:2,name:"Health",item:"https://procalc.ai/health"},{"@type":"ListItem",position:3,name:"TDEE Calculator"}]},F=document.createElement("script");F.type="application/ld+json",F.textContent=JSON.stringify([i,p]),F.id="tdee-schema";const $=document.getElementById("tdee-schema");return $&&$.remove(),document.head.appendChild(F),()=>{var u;(u=document.getElementById("tdee-schema"))==null||u.remove()}},[]),e.jsx("article",{className:"mx-auto w-full",style:{maxWidth:1100,fontFamily:o.bodyFont},children:e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{backgroundColor:"var(--card)",border:"1px solid var(--border)"},children:[e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--border)"},role:"tablist",children:so.map(i=>{const p=i.key===s;return e.jsx("button",{role:"tab","aria-selected":p,onClick:()=>f(i.key),style:{flex:1,padding:`${12*o.pad}px 0`,fontFamily:o.bodyFont,fontSize:14*o.scale,fontWeight:p?500:400,color:p?o.domainColor:"var(--muted-foreground)",backgroundColor:p?"var(--card)":"var(--muted)",borderBottom:`3px solid ${p?o.domainColor:"transparent"}`,border:"none",borderTop:"none",borderLeft:"none",borderRight:"none",cursor:"pointer",transition:"all 150ms ease"},children:i.label},i.key)})}),e.jsxs("div",{role:"tabpanel",children:[s==="calculate"&&e.jsxs(e.Fragment,{children:[e.jsx(Wo,{tdee:d.tdee,formulaName:v,activityLabel:_,theme:o}),e.jsx(Lo,{bmr:d.primary_bmr,activityBurn:d.activity_burn,tef:d.tef,theme:o}),e.jsx(Ao,{bmr:d.primary_bmr,activityBurn:d.activity_burn,bmi:d.bmi,bmiCategory:d.bmi_category,theme:o}),e.jsx(Oo,{inputs:c,onInputChange:y,theme:o}),e.jsx(Io,{goal:c.goal,goalCalories:d.goal_calories,goalDeficit:d.goal_deficit,onGoalChange:i=>y("goal",i),theme:o}
1),e.jsx(Do,{currentActivity:c.activity,tdeeByActivity:d.tdee_by_activity,theme:o})]}),s==="macros"&&e.jsx(Ho,{results:d,inputs:c,onInputChange:y,theme:o}),s==="bodycomp"&&e.jsx(Ko,{results:d,inputs:c,theme:o}),s==="compare"&&e.jsx(Po,{results:d,inputs:c,theme:o})]})]})})}export{Uo 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.