1import{r as n,t as o,b as r,j as e,A as ee,C as u,e as g,B as N,i as se,c as U,d as L,k as te}from"./index-bM8UT4Os.js";import{I as p}from"./input-BwpLlRYf.js";import{L as y}from"./label-2Seh_wFH.js";import{S as T}from"./scale-C2__GAhb.js";import{P as O}from"./plus-DSaqw8wa.js";import{F as G,C as ae}from"./file-up-B_NGjEWN.js";import{T as re}from"./trash-2-4iirX7DH.js";import"./dialog-CxcTDVnZ.js";import"./useComposition-DO5dIJEj.js";function pe(){const[W,b]=n.useState(""),[i,v]=n.useState(""),[m,w]=n.useState(""),[x,F]=n.useState(""),[C,E]=n.useState(""),[h,S]=n.useState("manual"),[Q,M]=n.useState(!1),[a,k]=n.useState(null),[H,z]=n.useState(""),K=n.useRef(null),d=o.useUtils(),{data:D,isLoading:J}=o.bodyMeasurements.getHistory.useQuery({limit:30}),{data:c}=o.bodyMeasurements.getTrend.useQuery({days:90}),P=o.bodyMeasurements.add.useMutation({onSuccess:()=>{r.success("ä¸ç£
è¨éå·²å²å âï¸"),$(),d.bodyMeasurements.getHistory.invalidate(),d.bodyMeasurements.getTrend.invalidate(),d.bodyMeasurements.getLatest.invalidate()},onError:s=>r.error("å²ååå°: "+s.message)}),q=o.healthReport.analyze.useMutation({onSuccess:s=>{if(M(!1),!s||!s.extractedData){r.error("AI åè¦æ ¼å¼é¯èª¤");return}k(s.extractedData),z(s.reportUrl||""),s.extractedData.weight&&b(String(s.extractedData.weight)),s.extractedData.bodyFatPercentage&&v(String(s.extractedData.bodyFatPercentage)),s.extractedData.muscleMass&&w(String(s.extractedData.muscleMass)),s.extractedData.waistCircumference&&F(String(s.extractedData.waistCircumference)),r.success("AI 已辨èå ±åæ¸æï¼OK å°±å²å â
")},onError:s=>{M(!1),r.error("辨èåå°: "+s.message)}}),R=o.healthReport.confirmAndSave.useMutation({onSuccess:()=>{r.success("å¥åº·å ±åæ¸æå·²å²å ð"),$(),d.bodyMeasurements.getHistory.invalidate(),d.bodyMeasurements.getTrend.invalidate(),d.bodyMeasurements.getLatest.invalidate()},onError:s=>r.error("å²ååå°: "+s.message)}),V=o.bodyMeasurements.delete.useMutation({onSuccess:()=>{r.success("å·²å·å"),d.bodyMeasurements.getHistory.invalidate(),d.bodyMeasurements.getTrend.invalidate()}}),$=()=>{b(""),v(""),w(""),F(""),E(""),k(null),z(""),S("manual")},X=s=>{s.preventDefault();const t=parseFloat(W);if(!t||t<20||t>300){r.error("å
¥è¿ææé«é (20-300 kg)");return}a&&H?R.mutate({weight:t,bodyFatPercentage:i?parseFloat(i):void 0,muscleMass:m?parseFloat(m):void 0,waistCircumference:x?parseFloat(x):void 0,visceralFat:a.visceralFat||void 0,bmi:a.bmi||void 0,basalMetabolicRate:a.basalMetabolicRate||void 0,bodyWater:a.bodyWater||void 0,boneMass:a.boneMass||void 0,reportUrl:H,notes:C||void 0}):P.mutate({weight:t,bodyFatPercentage:i?parseFloat(i):void 0,muscleMass:m?parseFloat(m):void 0,waistCircumference:x?parseFloat(x):void 0,notes:C||void 0})},Y=s=>{const t=s.target.files?.[0];if(!t)return;if(t.size>20*1024*1024){r.error("æªæ¡å¤ªå¤§ï¼æå¤§ 20MB");return}M(!0);const A=new FileReader;A.onload=I=>{const l=I.target?.result,f=l.split(","),j=f.length>1?f[1]:l;if(!j){r.error("æªæ¡è®å失æ"),M(!1);return}q.mutate({fileBase64:j,mimeType:t.type,fileName:t.name})},A.readAsDataURL(t)},B=(()=>{if(!c||!Array.isArray(c)||c.length<2)return null;const s=c[c.length-1]?.weight,t=c[0]?.weight;return s===void 0||t===void 0?null:{change:s-t,latest:s,first:t}})(),Z=s=>s?s.split(/[|ï½]/).map(t=>t.trim()).filter(Boolean).filter(t=>!/^(å
§èèèª|BMI|BMR|髿°´å|骨質é|å ±å)\s*[:ï¼]/i.test(t)).filter(t=>!t.includes("manus-storage")).join(" · "):"",_=()=>{if(!c||!Array.isArray(c)||c.length<2)return null;const s=c.map(l=>l?.weight).filter(l=>l!==void 0),t=Math.min(...s),I=Math.max(...s)-t||1;return e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:184",className:"flex items-end gap-[2px] h-16 mt-2",children:s.map((l,f)=>{const j=(l-t)/I*100;return e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:188",className:"flex-1 bg-gradient-to-t from-blue-500 to-cyan-400 rounded-t-sm min-w-[3px] transition-all",style:{height:`${Math.max(10,j)}%`},title:`${l} kg`},f)})})};return e.jsx(ee,{"data-loc":"client/src/pages/BodyMeasurements.tsx:201",title:"ä¸ç£
è¨é",showBack:!0,children:e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:202",className:"py-6 px-4",children:e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:203",className:"max-w-2xl mx-auto
1space-y-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:205",className:"mb-2",children:[e.jsxs("h1",{"data-loc":"client/src/pages/BodyMeasurements.tsx:206",className:"text-2xl md:text-3xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(T,{"data-loc":"client/src/pages/BodyMeasurements.tsx:207",className:"w-6 h-6 text-primary"}),"ä¸ç£
è¨é"]}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:210",className:"text-sm text-muted-foreground mt-1",children:"èªå·±å
¥æ Upload InBody / é»åç£
å ±å ð"})]}),B&&e.jsx(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:217",className:"card-premium",children:e.jsxs(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:218",className:"pt-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:219",className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:220",children:[e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:221",className:"text-xs text-muted-foreground",children:"90 æ¥é«éè®å"}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:222",className:"flex items-center gap-2 mt-1",children:[e.jsx(T,{"data-loc":"client/src/pages/BodyMeasurements.tsx:223",className:"w-5 h-5 text-primary"}),e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:224",className:"text-xl font-bold text-primary",children:[B.change>0?"+":"",B.change.toFixed(1)," kg"]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:229",className:"text-right",children:[e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:230",className:"text-xs text-muted-foreground",children:"ææ°é«é"}),e.jsxs("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:231",className:"text-2xl font-bold text-foreground",children:[B.latest.toFixed(1),e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:231",className:"text-sm text-muted-foreground ml-1",children:"kg"})]})]})]}),_()]})}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:240",className:"flex gap-2",children:[e.jsxs(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:241",variant:h==="manual"?"default":"outline",className:"flex-1",onClick:()=>{S("manual"),k(null)},children:[e.jsx(O,{"data-loc":"client/src/pages/BodyMeasurements.tsx:246",className:"w-4 h-4 mr-1"})," èªå·±å
¥"]}),e.jsxs(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:248",variant:h==="upload"?"default":"outline",className:"flex-1",onClick:()=>S("upload"),children:[e.jsx(G,{"data-loc":"client/src/pages/BodyMeasurements.tsx:253",className:"w-4 h-4 mr-1"})," Upload å ±å"]})]}),h==="upload"&&!a&&e.jsx(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:259",className:"card-premium border-dashed border-2",children:e.jsxs(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:260",className:"pt-6 pb-6",children:[e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:261",onClick:()=>K.current?.click(),className:"text-center cursor-pointer py-6",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(se,{"data-loc":"client/src/pages/BodyMeasurements.tsx:267",className:"w-10 h-10 text-blue-400 mx-auto mb-3 animate-spin"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:268",className:"text-sm text-foreground/80",children:"AI 辨èä¸..."}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:269",className:"text-xs text-muted-foreground mt-1",children:"æ£å¨åæä½ å
å¥åº·å ±å"})]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{"data-loc":"client/src/pages/BodyMeasurements.tsx:273",className:"w-10 h-10 text-blue-400 mx-auto mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:274",className:"text-sm text-foreground/80",children:"æ³å¢åº¦ Upload å¥åº·å ±å"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:275",className:"text-xs text-muted-foreground mt-1",children:"æ¯æ´ InBody å ±åãé»åç£
æªåã髿ª¢ PDF ç任使 ¼å¼"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:278",className:"text-xs text-foreground
1/70 mt-2",children:"PDF / JPG / PNG / HEICï¼æå¤§ 20MBï¼"})]})}),e.jsx("input",{"data-loc":"client/src/pages/BodyMeasurements.tsx:284",ref:K,type:"file",accept:"image/*,.pdf,.heic",onChange:Y,className:"hidden"})]})}),a&&e.jsxs(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:297",className:"card-premium",children:[e.jsx(U,{"data-loc":"client/src/pages/BodyMeasurements.tsx:298",className:"pb-2",children:e.jsxs(L,{"data-loc":"client/src/pages/BodyMeasurements.tsx:299",className:"text-sm flex items-center gap-2 text-foreground",children:[e.jsx(ae,{"data-loc":"client/src/pages/BodyMeasurements.tsx:300",className:"w-4 h-4"}),"AI 辨èçµæ â Check 䏿¸æ"]})}),e.jsxs(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:304",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:305",className:"grid grid-cols-2 gap-2 text-xs mb-3",children:[a.visceralFat&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:307",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:308",className:"text-muted-foreground",children:"å
§èèèª:"})," ",e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:309",className:"text-foreground font-medium",children:a.visceralFat})]}),a.bmi&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:313",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:314",className:"text-muted-foreground",children:"BMI:"})," ",e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:315",className:"text-foreground font-medium",children:a.bmi})]}),a.basalMetabolicRate&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:319",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:320",className:"text-muted-foreground",children:"BMR:"})," ",e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:321",className:"text-foreground font-medium",children:[a.basalMetabolicRate," kcal"]})]}),a.bodyWater&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:325",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:326",className:"text-muted-foreground",children:"髿°´å:"})," ",e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:327",className:"text-foreground font-medium",children:a.bodyWater})]}),a.boneMass&&e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:331",className:"bg-secondary/60 p-2 rounded",children:[e.jsx("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:332",className:"text-muted-foreground",children:"骨質é:"})," ",e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:333",className:"text-foreground font-medium",children:[a.boneMass," kg"]})]})]}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:337",className:"text-xs text-muted-foreground",children:"以䏿¬ä½å·²èªåå¡«å
¥ï¼ä½ å¯ä»¥æ¹å®åå²å"})]})]}),(h==="manual"||a)&&e.jsxs(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:346",className:"card-premium",children:[e.jsx(U,{"data-loc":"client/src/pages/BodyMeasurements.tsx:347",className:"pb-3",children:e.jsxs(L,{"data-loc":"client/src/pages/BodyMeasurements.tsx:348",className:"text-lg flex items-center gap-2",children:[e.jsx(O,{"data-loc":"client/src/pages/BodyMeasurements.tsx:349",className:"w-4 h-4"}),a?"OK å²å":"è¨é仿¥æ¸æ"]})}),e.jsx(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:353",children:e.jsxs("form",{"data-loc":"client/src/pages/BodyMeasurements.tsx:354",onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:355",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:356",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:357",className:"text-sm",children:"é«é (kg) *"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:358",type:"number",step:"0.1",placeholder:"ä¾
1å¦ 65.5",value:W,onChange:s=>b(s.target.value),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:367",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:368",className:"text-sm",children:"é«èç (%)"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:369",type:"number",step:"0.1",placeholder:"ä¾å¦ 20.5",value:i,onChange:s=>v(s.target.value),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:378",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:379",className:"text-sm",children:"èèé (kg)"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:380",type:"number",step:"0.1",placeholder:"ä¾å¦ 28.0",value:m,onChange:s=>w(s.target.value),className:"mt-1"})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:389",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:390",className:"text-sm",children:"è
°å (cm)"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:391",type:"number",step:"0.1",placeholder:"ä¾å¦ 75.0",value:x,onChange:s=>F(s.target.value),className:"mt-1"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:401",children:[e.jsx(y,{"data-loc":"client/src/pages/BodyMeasurements.tsx:402",className:"text-sm",children:"å註"}),e.jsx(p,{"data-loc":"client/src/pages/BodyMeasurements.tsx:403",placeholder:"ä¾å¦ï¼æ©ä¸ç©ºè
¹é度",value:C,onChange:s=>E(s.target.value),className:"mt-1"})]}),e.jsx(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:410",type:"submit",className:"w-full",disabled:P.isPending||R.isPending,children:P.isPending||R.isPending?"å²åç·...":a?"OK å²åå ±åæ¸æ â
":"è¨éä¸ç£
âï¸"})]})})]}),e.jsxs(u,{"data-loc":"client/src/pages/BodyMeasurements.tsx:428",className:"card-premium",children:[e.jsx(U,{"data-loc":"client/src/pages/BodyMeasurements.tsx:429",className:"pb-3",children:e.jsxs(L,{"data-loc":"client/src/pages/BodyMeasurements.tsx:430",className:"text-lg flex items-center gap-2",children:[e.jsx(te,{"data-loc":"client/src/pages/BodyMeasurements.tsx:431",className:"w-4 h-4"}),"æ·å²è¨é"]})}),e.jsx(g,{"data-loc":"client/src/pages/BodyMeasurements.tsx:435",children:J?e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:437",className:"text-center text-muted-foreground py-4",children:"è¼å
¥ä¸..."}):!D||D.length===0?e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:439",className:"text-center py-8",children:[e.jsx(T,{"data-loc":"client/src/pages/BodyMeasurements.tsx:440",className:"w-12 h-12 text-foreground/70 mx-auto mb-3"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:441",className:"text-muted-foreground",children:"ä»²æªæè¨é"}),e.jsx("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:442",className:"text-xs text-muted-foreground mt-1",children:"ä¸é¢å
¥è¿ä½ å
é«ééå§è¿½è¹¤"})]}):e.jsx("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:445",className:"space-y-2",children:D.map(s=>{const t=Z(s.notes);return e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:450",className:"flex items-center justify-between gap-3 p-3 rounded-lg bg-secondary/60 border border-border",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:451",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/BodyMeasurements.tsx:452",className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:453",className:"text-lg font-bold text-foreground",children:[s.weight.toFixed(1)," kg"]}),s.bodyFatPercentage&&e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:455",className:"text-xs px-2 py-0.5 rounded-full bg-orange-500/20 text-orange-300",children:[s.bodyFatPercentage.toFixed(1),"% é«è"]}),s.muscleMass&&e.jsxs("span",{"data-loc":"client/src/pages/BodyMeasurements.tsx:460",className:"text-xs px-2 py-0.5 rounded-full bg-green-500/20 text-green-300",children:[s.muscleMass.toFixed(1)," kg èè"]})]}),e.jsxs("p",{"data-loc":"client/src/pages/BodyMeasurements.tsx:465",className:"text-xs text-muted-foreground mt-1",children:[new Date(s.measuredAt).toLocaleDateString("zh-HK",{year:"numeric",month:"short",day:"numeric",weekday:"short"}),t&&` · ${t}`]})]}),e.jsx(N,{"data-loc":"client/src/pages/BodyMeasurements.tsx:470",variant:"ghost",size:"sm",onClick:()=>V.mutate({id:s.id}),className:"text-muted-foreground hover:text-red-400","aria-label":`åªé¤ ${s.weight.toFixed(1)} å
¬æ¤ç髿åè¨é`,children:e.jsx(re,{"data-loc":"client/src/pages/BodyMeasurements.tsx:477",className:"w-4 h-4"})})]},s.id)})})})]})]})})})}export{pe 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.